Feature request: [ContractAnnotation] On top of class

Hey there, I'm wondering why it's not possible to add ContractAnnotation on top of classes and interfaces.

What I'd want for this, is make resharper understand that some classes are used by reflected dependency injection.

For example:

public class foo : IBar{}

[ContractAnnotation("UnusedType.Global => halt")]

public class IBar {}

 

That way interfaces and baseclasses that are used by dependency injection can be marked as "used" and resharper doesn't complain about every class that it's not used

3 comments
Comment actions Permalink

How about the [UsedImplicitly] attribute?

 

0
Comment actions Permalink

Agree. Ron, is using the UsedImplicitly attribute appropriate for your task?

0
Comment actions Permalink

Sorry for the late response.

Yes, that should work in for this exact specific case, though it would be nice to have a generic way to halt any warning.

Like to give another example, I have a abstract baseclass RequestValidator<T> which would validate objects based on their interfaces. So RequestValidator<IPageRequest> would be called `class IPageRequestValidator<IPageRequest>` (because it's a class that validates IPageRequest based objects.

In that case Reshaper is complaining about `InconsistentNaming`. So it would be nice to add an attribute of `[ContractAnnotation("InconsistentNaming => halt")]` to indicate this

 

0

Please sign in to leave a comment.