mathnet-spatial icon indicating copy to clipboard operation
mathnet-spatial copied to clipboard

Methods should be marked as pure

Open Brunni opened this issue 8 years ago • 2 comments

To reproduce: Create a field like this: private static readonly UnitVector3D DefaultDirection = new UnitVector3D(0, 1, 1);

If you then access it using DefaultDirection.Negate() you get a warning from VisualStudio/Resharper: 'Impure method is called for a readonly field of value type'

I guess the method is pure and therefore perhaps it would be possible to give a hint using the [Pure] attribute? https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.pureattribute(v=vs.110).aspx

Brunni avatar Oct 20 '17 08:10 Brunni

There are a couple of [Pure] sprinkled in the code but they are sparse, sry about that.

JohanLarsson avatar Oct 20 '17 17:10 JohanLarsson

I'm going to write a roslyn analyzer for this.

JohanLarsson avatar Dec 06 '17 11:12 JohanLarsson