In my test project, I've got private fields that are not assigned to in the code, but are assigned with reflection.
When compiling I get warnings like:
Warning CS0649 Field 'CLASSNAME.FIELDNAME' is never assigned to, and will always have its default value null
I've tried adding <NoWarn>649</NoWarn>
to the first PropertyGroup in the xproj. But I still get the errors.
Does NoWarn not work in DNX? Or am I doing something wrong? Is there any other solution to the problem?
Compiler options cannot be specified in the xproj file. Follow these steps to suppress a compiler warning:
Open the
project.json
file of the project. All compiler options must be specified in this file.Add the compilationOptions section to the end of the file:
"compilationOptions": { "noWarn": [649] }
Save the file and wait for few seconds until you see the "Package Restore completed" message in the status bar of Visual Studio.
Rebuild the project.
This should suppress the warning. However, sometimes (probably a bug), the changes you make to
project.json
do not take effect even after a clean build. In this case, by making additional dummy changes to the file and rebuilding usually solves the problem.