Skip to content

NCR-Engage/ActionResponseTypeAnalyzer

Repository files navigation

ActionResponseTypeAnalyzer

Build status

Problem

WebApi's HttpResponseMessage is not a generic type. It was at the beginning, but before the release it was decided that it should not be and so we stuck with non-descriptive action method calls like

public HttpResponseMessage Get([FromUri] int someId) { ... }

Creators of WebApi documentation needed to know what the type is, so they invented System.Web.Http.Description.ResponseTypeAttribute. So now there are two sources of truth about what the method returns - method body decides what is being run by computers and attribute decides whay is being read by humans. This leads to mismatches.

Solution

This analyzer is a patch that compares actual types with the declared ones. It contains two diagnostics:

  • ARTA001: Value type declared in ResponseType should match to actual response type.
  • ARTA002: Public controller method specify their response type in the ResponseType attribute.

About

Roslyn analyzer for checking WebApi response type documentation accuracy.

Topics

Resources

License

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors