#pragma warning disable EmptyConstructor
The compiler now complains about 'EmptyConstrutor' not being a valid number. Fair enough it is not.
So I removed the pragma since any other pragma would get ReSharper complaining again. To keep ReSharper quiet the constructor now looks as follows:
public class Foo() {
// ... the XML markup for documentation
public Foo() {
; // to shut up ReSharper
}
}
Now both, the compiler and ReSharper, are happy! :-)
No big issue but the better solution would have been if ReSharper would modify the code only in such a way that it doesn't cause additional warnings.
Update
This applies to essentially all such pragma's ReSharper inserts, including but not limited to:
- UnusedMemberInPrivateClass
- PossibleNullReferenceException
As stated before: Best option would be if the code inserted by ReSharper would not cause additional warnings from the C# compiler. Or in other words: The added code should be "compatible" with the compiler. One option could be to use comments instead. The compiler ignores them.
The C# preprocessor is not as powerful and flexible as the C/C++ one. The latter allows your extensions by ignoring unknown ones. The C# version does not have that "back door" but checks them for validity as well. In essence you can't define your own. (Or at least you shouldn't if you don't want to cause compiler warnings.)
1 comments:
Seems like this warning is a bug in the csc compiler, as the pragma is not required to be a number by the standard. So it's pretty safe to suppress the compiler warning in the project settings by its number (and that's what we'd do).
Post a Comment
All comments, questions and other feedback is much appreciated. Thank you!