Skip to content

NullRef in analyzer when generic instantiation used in cref #3014

@vitek-karas

Description

@vitek-karas
			class C<TOuter>
			{
				/// <summary>
				/// <remarks>
				/// <see cref="CRequires{TOuter}.IsIt"/>  This causes NullRef
				/// </remarks>
				/// </summary>
				static CRequires<TOuter> Value => throw new Exception();
			}

                        // This produces a warning as it should
			class CRequires<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] TInner> { public static bool IsIt => false; }

The NullRef happens because we try to validate the generic instantiation (matching annotations), and in this case it leads to us trying to produce a warning on the cref. But the type argument given to us by Roslyn doesn't have a containing type (not sure why), and so we fail to produce a display name for it (NullRef).

The fix is to actually disallow analysis of any symbol inside a cref, we don't want to produce warnings for that. We already did that for some crefs, but not all.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions