Skip to content

Commit b7d6c57

Browse files
committed
Add unit tests for new attributes
1 parent 4bd01e5 commit b7d6c57

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

tests/PolySharp.NuGet/PolySharp.NuGet.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
https://api.nuget.org/v3/index.json;
77
..\..\artifacts;
88
</RestoreSources>
9+
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
910
</PropertyGroup>
1011

1112
<ItemGroup>
@@ -15,6 +16,7 @@
1516

1617
<ItemGroup>
1718
<Compile Include="..\PolySharp.Tests\LanguageFeatures.cs" />
19+
<Compile Include="..\PolySharp.Tests\RuntimeSupport.cs" />
1820
</ItemGroup>
1921

2022
</Project>

tests/PolySharp.Tests/PolySharp.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net6.0</TargetFrameworks>
5+
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
56
</PropertyGroup>
67

8+
<ItemGroup>
9+
<CompilerVisibleProperty Include="PolySharpIncludeRuntimeSupportedAttributes"/>
10+
</ItemGroup>
11+
712
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
813
<PackageReference Include="System.Memory" Version="4.5.5" />
914
</ItemGroup>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.Diagnostics.CodeAnalysis;
4+
using System.Runtime.InteropServices;
5+
using System.Runtime.Versioning;
6+
7+
[assembly: TargetPlatform("windows6.1")]
8+
9+
namespace PolySharp.Tests;
10+
11+
internal class RandomApis
12+
{
13+
[StackTraceHidden]
14+
public void HideMe()
15+
{
16+
}
17+
}
18+
19+
internal class PlatformSpecificApis
20+
{
21+
[UnmanagedCallersOnly]
22+
public static void NativeFunction()
23+
{
24+
}
25+
26+
[ObsoletedOSPlatform("windows6.1")]
27+
public void Obsoleted()
28+
{
29+
}
30+
31+
[SupportedOSPlatform("windows6.1")]
32+
public void Supported()
33+
{
34+
}
35+
36+
[SupportedOSPlatformGuard("windows6.1")]
37+
public void SupportedGuard()
38+
{
39+
}
40+
41+
[UnsupportedOSPlatform("windows6.1")]
42+
public void Unsupported()
43+
{
44+
}
45+
46+
[UnsupportedOSPlatformGuard("windows6.1")]
47+
public void UnsupportedGuard()
48+
{
49+
}
50+
}
51+
52+
internal class ReflectionApis
53+
{
54+
[RequiresUnreferencedCode("No idea what I'll reflect on")]
55+
public void ReflectOnSomethingCrazy()
56+
{
57+
}
58+
59+
public void ReflectOnInputType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type)
60+
{
61+
}
62+
63+
[DynamicDependency("PolySharp.Tests.ReflectionApis.ReflectOnSomethingCrazy()")]
64+
public void ReflectDependingOnStuff()
65+
{
66+
}
67+
68+
[UnconditionalSuppressMessage("Don't worry about it", "0000")]
69+
public void SuppressEverything(Type type)
70+
{
71+
_ = type.GetProperties();
72+
}
73+
}

0 commit comments

Comments
 (0)