bkoelman / ResharperCodeContractNullability

Reports diagnostics, helping you to annotate your source tree with (Item)NotNull / (Item)CanBeNull attributes.
https://www.jetbrains.com/resharper/help/Code_Analysis__Code_Annotations.html
Apache License 2.0
26 stars 4 forks source link

Parameter in non-generic class that derives from a generic base class that implements a generic interface is incorrectly reported #13

Closed bkoelman closed 8 years ago

bkoelman commented 8 years ago

Created a new issue to track the bug submitted at https://github.com/bkoelman/ResharperCodeContractNullability/issues/5#issuecomment-169161211.

@starkcolin Thanks for reporting!

Minimal repro for v1.0.3:

    public interface I<T>
    {
        void Do([NotNull] T p);
    }

    public class B<T> : I<T>
    {
        public virtual void Do(T p)
        {
        }
    }

    public class D : B<string>
    {
        public override void Do(string p)
        {
        }
    }

The nullability analyzer incorrectly reports on the line of D.Do:

Parameter 'p' is missing nullability annotation.
bkoelman commented 8 years ago

The strange thing is: the nullability report goes away when renaming method Do to M.

Tracked this down to a Roslyn API call and created https://github.com/dotnet/roslyn/issues/7794.

bkoelman commented 8 years ago

@starkcolin Feel free to try out this fix in the prerelease version (see https://github.com/bkoelman/ResharperCodeContractNullability#trying-out-the-latest-build).

If that works for you, I'll create a new release.

starkcolin commented 8 years ago

Happy to report that the issue appears to be resolved. Thanks!

bkoelman commented 8 years ago

https://github.com/bkoelman/ResharperCodeContractNullability/releases/tag/v1.0.4