#pragma warning disable EmptyGeneralCatchClause "Invalid Number"
When using resharper to do a one-time suppression for the warning "Empty general catch clause suppresses any errors," resharper adds "#pragma warning disable EmptyGeneralCatchClause" to the code, resulting in the visual studio 2005 warning "Invalid Number."
Sample code:
try
{
logSomething();
}
#pragma warning disable EmptyGeneralCatchClause
catch
#pragma warning restore EmptyGeneralCatchClause
{
; // don't do anything if logging fails
}
Please sign in to leave a comment.
Hello David,
You can add "1692" to the "Suppress warnings" project property (build tab)
Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
IR> #pragma
IR>
Do I really have to use visual studio's warning suppression as a result of wanting to suppress a single instance of a resharper warning? Are there any other warnings I might accidentally suppress if I suppress all "1692" warning numbers?
Hello evolve12345,
We've found this problem too late in the release cycle, so proposed solution
is a matter of a workaround. Suppressing 1692 warning suppresses just "wrong
#pragma warning number" message and nothing else. If you do write "#pragma
warning disable" by hand, it may be a problem for you, but otherwise it is
safe. We are looking for a solution to this problem currently, but didn't
find anything better yet.
Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
IR> Do I really have to use visual studio's warning suppression as a
IR> result of wanting to suppress a single instance of a resharper
IR> warning? Are there any other warnings I might accidentally suppress
IR> if I suppress all "1692" warning numbers?
IR>
I am experiencing the same warning, "Invalid number". I added 1692 to my suppress warning in build properties but I am still getting that error!
Sample code:
#pragma warning disable UnusedPrivateMember
private enum Rectangle {
#pragma warning disable UnusedMemberInPrivateClass
Sample warning:
Warning 1 Invalid number D:\proj1\file1.cs 17 25 Nmspace
This is really annoying because I have unused private member disabled all over the place and now I get warning during build which is even worse than warning during resharper analysis.
I found the solution; But its hard to get and needs extreme experience in Development with Visual Studio 2005.
Close Visual Studio and reopen it (Menu File\Close Solution)
Greetings
I'd suggest more elegant solution. It still not perfect, but...
#pragma warning disable 1692
#pragma warning disable EmptyGeneralCatchClause
catch
#pragma warning restore EmptyGeneralCatchClause, 1692
Hi,
Actually, it's not really a solution. It's rather an ugly kludge, and it doesn't even solve much.
The problem is that ReSharper inserts #pragmas like this into the code but the symbol used in the pragma (e.g. EmptyGeneralCatchClause) isn't defined anywhere. And I believe that it actually makes the entire "Suppress warning" option in the context menu useless because it doesn't suppress anything.
Example: auto-generated InitializeComponent() methods always generate lots of warnings of certain types (e.g. RedundantThisQualifier, RedundantNameQualifier). Adding a #pragma before the method doesn't remove the warnings, and adds the "Invalid number" warnings instead. So as a result I have double the number of warnings :)
It's hard for me to believe that the ReSharper team didn't catch this problem before.
Or maybe all one needs to to is to include a DLL into the project? I mean, a DLL that contains these identifiers?
Best,
Michal Blazejczyk
"Andriy Kvasnyts'a" <professor.kam@gmail.com> wrote in message news:27666751.1191503548953.JavaMail.itn@is.intellij.net...
Has this issue been addressed? I'm using the workaround suggested but am hoping for something better.
I still favour using SuppressMessageAttribute:
http://www.jetbrains.net/jira/browse/RSRP-31257
http://msdn2.microsoft.com/en-us/library/system.diagnostics.codeanalysis.suppressmessageattribute(vs.80).aspx