#pragma warning disable & restore

后端 未结 3 600
独厮守ぢ
独厮守ぢ 2020-12-15 04:11

I have used c# to create a First Project. I have many warning errors and all these warning errors are to be single Error(Internal compiler error. See the console log for mo

相关标签:
3条回答
  • 2020-12-15 04:22

    I got this error in my asp.net mvc (.net core) application. Based on this above and other article show this error comes from your c sharp code in chtml side.

    To identify the issue, just open console or open cshtml in separate window.

    I have a popup where this error comes, I separately open this popup and while investing error in console, I got that one semi-colon not in cshtml, so while rendering chtml it throw the error.

    0 讨论(0)
  • 2020-12-15 04:25

    At the very least you should be specific about which warnings you've deliberately chosen to ignore. That way, if later maintenance introduces a 'new' warning/issue that you should be made aware of, the warning about the newly-introduced error won't be suppressed by your blanket pragma warning disable directive.

    You can get the warning numbers pertaining to the build issues you've decided to ignore from the build Output window in Visual Studio. They're usually labelled "Warning CS0168...." or similar. In which case you can specifically target just the those error(s) you've decided to ignore like so:

    #pragma warning disable 168, 3021
    
        //Your code that generates warnings CS0168 and CS3021 here
    
    #pragma warning restore 168, 3021
    
    0 讨论(0)
  • 2020-12-15 04:30

    If it is code of any practical value you should not have any warning and compile with "warnings as error" setting with all warnings turned on.

    Code you showing does not seem like it have any errors in itself. So I see no reasons why you need the pragma.

    But it is really your call - your code and if no one need to use/look/pay for it - do whatever works for you.

    0 讨论(0)
提交回复
热议问题