Skip to content

Commit

Permalink
Revert "Fix missing analyzer warning for generics in containing type (#…
Browse files Browse the repository at this point in the history
…109392)" (#109520)

This reverts commit ed77814.

Fixes a timeout in CLR_Tools_Tests.
  • Loading branch information
sbomer authored Nov 4, 2024
1 parent 43b5280 commit 10af5e0
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ internal static class GenericArgumentDataFlow
{
public static void ProcessGenericArgumentDataFlow (Location location, INamedTypeSymbol type, Action<Diagnostic> reportDiagnostic)
{
while (type is { IsGenericType: true }) {
ProcessGenericArgumentDataFlow (location, type.TypeArguments, type.TypeParameters, reportDiagnostic);
type = type.ContainingType;
}
ProcessGenericArgumentDataFlow (location, type.TypeArguments, type.TypeParameters, reportDiagnostic);
}

public static void ProcessGenericArgumentDataFlow (Location location, IMethodSymbol method, Action<Diagnostic> reportDiagnostic)
Expand Down Expand Up @@ -58,7 +55,7 @@ static void ProcessGenericArgumentDataFlow (

public static bool RequiresGenericArgumentDataFlow (INamedTypeSymbol type)
{
while (type is { IsGenericType: true }) {
if (type.IsGenericType) {
if (RequiresGenericArgumentDataFlow (type.TypeParameters))
return true;

Expand All @@ -67,8 +64,6 @@ public static bool RequiresGenericArgumentDataFlow (INamedTypeSymbol type)
&& RequiresGenericArgumentDataFlow (namedTypeSymbol))
return true;
}

type = type.ContainingType;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ public Task RequiresInLibraryAssembly ()
return RunTest ();
}

[Fact]
public Task RequiresInRootAllAssembly ()
{
return RunTest ();
}

[Fact]
public Task RequiresOnAttribute ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public Task MethodByRefParameterDataFlow ()
return RunTest (allowMissingWarnings: true);
}

[Fact]
public Task ModifierDataFlow ()
{
return RunTest (allowMissingWarnings: true);
}

[Fact]
public Task StaticInterfaceMethodDataflow ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public static void Main ()

TestNoWarningsInRUCMethod<TestType> ();
TestNoWarningsInRUCType<TestType, TestType> ();
TestGenericParameterFlowsToNestedType.Test ();
}

static void TestSingleGenericParameterOnType ()
Expand Down Expand Up @@ -850,59 +849,6 @@ static void TestNoWarningsInRUCType<T, U> ()
rucType.VirtualMethodRequiresPublicMethods<T> ();
}

class TestGenericParameterFlowsToNestedType
{
class Generic<T> {
[ExpectedWarning ("IL2091")]
public T CallNestedMethod () => GenericRequires<T>.Nested.Method ();

[ExpectedWarning ("IL2091")]
public T AccessNestedField () => GenericRequires<T>.Nested.Field;

[ExpectedWarning ("IL2091")]
public T AccessNestedProperty () => GenericRequires<T>.Nested.Property;

[ExpectedWarning ("IL2091")]
public void AccessNestedEvent () => GenericRequires<T>.Nested.Event += null;

[ExpectedWarning ("IL2091")]
public void UseNestedTypeArgument () {
new Generic<GenericRequires<T>.Nested> ();
}

[ExpectedWarning ("IL2091")]
public class DerivedFromNestedType : GenericRequires<T>.Nested
{
[ExpectedWarning ("IL2091")]
public DerivedFromNestedType () {
}
}
}

class GenericRequires<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T> {
public class Nested {
public static T? Method () => default;

public static T? Field = default;

public static T? Property { get; set; } = default;

public static event Action<T>? Event;
}
}

public static void Test ()
{
var instance = new Generic<string> ();
instance.CallNestedMethod ();
instance.AccessNestedField ();
instance.AccessNestedProperty ();
instance.AccessNestedEvent ();
instance.UseNestedTypeArgument ();
new Generic<string>.DerivedFromNestedType ();
}
}

[RequiresUnreferencedCode ("message")]
public class RUCTypeRequiresPublicFields<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T>
Expand Down

0 comments on commit 10af5e0

Please sign in to comment.