Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Assembly Trimming Annotations for SharpGen.Runtime
- Loading branch information
Showing
14 changed files
with
179 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
// I'm a dummy project for testing trimmability, since the analyzer outside of publish time isn't fully perfect yet | ||
// test my trimming with `dotnet publish -r win-x64` | ||
|
||
Console.WriteLine("Hello SharpGenTools"); |
20 changes: 20 additions & 0 deletions
20
SharpGen.Runtime.Trim.Dummy/SharpGen.Runtime.Trim.Dummy.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishTrimmed>true</PublishTrimmed> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\SharpGen.Runtime\SharpGen.Runtime.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<TrimmerRootAssembly Include="SharpGen.Runtime" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reflection; | ||
|
||
namespace SharpGen.Runtime.TrimmingWrappers | ||
{ | ||
internal static class TrimmingExtensions | ||
{ | ||
#if NET6_0_OR_GREATER | ||
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] | ||
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2068", Justification = "We're preserving nested interfaces via wrapper method.")] | ||
#endif | ||
public static TypeInfo GetTypeInfoWithPreservedInterfaces(this Type type) | ||
{ | ||
return type.GetTypeInfo(); | ||
} | ||
|
||
|
||
#if NET6_0_OR_GREATER | ||
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] | ||
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2073", Justification = "We're preserving nested interfaces via wrapper method.")] | ||
#endif | ||
public static Type GetTypeWithPreservedInterfaces(this object obj) | ||
{ | ||
return obj.GetType(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.