This is a migrated thread and some comments may be shown as answers.

Any way to ignore a specific extension method for analysis?

1 Answer 54 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin
Top achievements
Rank 1
Kevin asked on 12 Jun 2015, 09:48 PM

I'm using NSubstitute for some unit testing, and I have some scenarios where I want to return a certain exception, rather than the expected data type.

var service = new FooService();
service.Repository = Substitute.For<IRepository>();
service.Repository.GetWidgetById(0).Returns(x => { throw new WidgetException(); });

Normally, this would be the kind of thing I would want to be warned about; the return type doesn't match the signature of the method it's extending.

Currently, I'm manually ignoring those errors, but I was wondering if there was a way to exempt certain definitions or libraries from certain analysis rules.

 Thanks!

 

 

1 Answer, 1 is accepted

Sort by
0
Svetlozar
Telerik team
answered on 17 Jun 2015, 03:25 PM
Hi,

I am really sorry for the inconvenience!

In that particular case I would suggest that we have failed to resolve the correct overload of Returns. You could try to make the lambda explicit and hopefully we will be able to resolve it correctly.

As for ignoring errors, in pre Visual Studio 2015 versions, we don't have fine-grained filters for ignoring markers. You can turn off the error reporting for the entire file. If that works for you I suggest you have a look at JustCode Options | Code Analysis | General | Exclude file filters.

Please, have in mind that starting with Visual Studio 2015 we are reworking our warning analysis, we are reworking them to be Roslyn extensions. That way you will be able to ignore them with #pragma or attribute as any other msbuild warning.

If you have other problems or suggestions, please don't hesitate to write back!

Regards,
Svetlozar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Code Analysis
Asked by
Kevin
Top achievements
Rank 1
Answers by
Svetlozar
Telerik team
Share this question
or