Skip to content

Commit

Permalink
Add runtime detection for CovariantReturnsOfClasses (dotnet#37315)
Browse files Browse the repository at this point in the history
Was missed in dotnet#37276.
  • Loading branch information
MichalStrehovsky authored Jun 4, 2020
1 parent 4a4e347 commit 4c23c57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static bool IsSupported(string feature)
switch (feature)
{
case PortablePdb:
case CovariantReturnsOfClasses:
#if FEATURE_DEFAULT_INTERFACES
case DefaultImplementationsOfInterfaces:
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using Xunit;

Expand Down Expand Up @@ -35,5 +37,23 @@ public static void DynamicCode_Jit()
Assert.True(RuntimeFeature.IsDynamicCodeSupported);
Assert.True(RuntimeFeature.IsDynamicCodeCompiled);
}

public static IEnumerable<object[]> GetStaticFeatureNames()
{
foreach (var field in typeof(RuntimeFeature).GetFields(BindingFlags.Public | BindingFlags.Static))
{
if (!field.IsLiteral)
continue;

yield return new object[] { field.Name };
}
}

[Theory]
[MemberData(nameof(GetStaticFeatureNames))]
public static void StaticDataMatchesDynamicProbing(string probedValue)
{
Assert.True(RuntimeFeature.IsSupported(probedValue));
}
}
}

0 comments on commit 4c23c57

Please sign in to comment.