dotnet / roslyn-analyzers

MIT License
1.59k stars 466 forks source link

Fix DoNotIgnoreMethodResultsAnalyzer (CA1806 port) to handle PreserveSig methods #746

Open mavasani opened 8 years ago

mavasani commented 8 years ago

DoNotIgnoreMethodResultsAnalyzer.IsHResultOrErrorCodeReturningMethod does not completely match the FXCop implementation here - especially for ComImport types with methods marked with PreserveSig.

We need to tune this method to match the FxCop behavior once https://github.com/dotnet/roslyn/issues/7282 is addressed. I will also add a skip test UnusedComImportPreserveSig for this issue.

mavasani commented 8 years ago

Also extend it to handle Pure attribute - @nguerrera can you please add more context on what needs to be done?

nguerrera commented 8 years ago

Any method marked [Pure] indicates that it has no side effect. As such, it is always wrong to call it and not use the return value.

nguerrera commented 8 years ago

https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.pureattribute(v=vs.110).aspx

mavasani commented 8 years ago

This is blocked on dotnet/roslyn#7282, moving to Unknown milestone.

Youssef1313 commented 3 years ago

@mavasani The linked roslyn issue is now fixed. The issue can be addressed once you move to a version containing the new API.