Any way to ignore a specific extension method for analysis?

Thread is closed for posting
2 posts, 0 answers
  1. Kevin
    Kevin avatar
    1 posts
    Member since:
    Jun 2015

    Posted 12 Jun 2015 Link to this post

    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.




  2. Svetlozar
    Svetlozar avatar
    294 posts

    Posted 17 Jun 2015 Link to this post


    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!

    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
Back to Top