Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure AOT Compatibility #100

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Cpp2IL.Core/Attributes/RegisterCpp2IlPluginAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ namespace Cpp2IL.Core.Attributes;
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public class RegisterCpp2IlPluginAttribute : Attribute
{
#if NET6_0
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
#endif
public Type PluginType { get; }

public RegisterCpp2IlPluginAttribute(Type pluginType)
public RegisterCpp2IlPluginAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type pluginType)
{
if (!typeof(Cpp2IlPlugin).IsAssignableFrom(pluginType))
throw new ArgumentException("Plugin type to register must extend Cpp2IlPlugin", nameof(pluginType));
Expand All @@ -22,4 +20,4 @@ public RegisterCpp2IlPluginAttribute(Type pluginType)

PluginType = pluginType;
}
}
}
14 changes: 11 additions & 3 deletions Cpp2IL.Core/Cpp2IL.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/SamboyCoding/Cpp2IL.git</RepositoryUrl>
<TargetFrameworks>net7.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
<Title>Cpp2IL.Core</Title>
<VersionPrefix>2022.1.0</VersionPrefix>
<!--Plugins make this non-trimmable-->

<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand All @@ -40,7 +48,7 @@
<!--Not used at runtime, but needed for the build-->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />

<PackageReference Include="PolySharp" Version="1.12.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
Expand Down
1 change: 1 addition & 0 deletions Cpp2IL.Core/Cpp2IlApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static class Cpp2IlApi
{
public static ApplicationAnalysisContext? CurrentAppContext;

[RequiresUnreferencedCode("Plugins are loaded dynamically.")]
public static void Init(string pluginsDir = "Plugins")
{
Cpp2IlPluginManager.LoadFromDirectory(Path.Combine(Environment.CurrentDirectory, pluginsDir));
Expand Down
4 changes: 3 additions & 1 deletion Cpp2IL.Core/Cpp2IlPluginManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
Expand All @@ -13,6 +14,7 @@ public static class Cpp2IlPluginManager
{
private static List<Cpp2IlPlugin> _loadedPlugins = new();

[RequiresUnreferencedCode("Plugins are loaded dynamically.")]
internal static void LoadFromDirectory(string pluginsDir)
{
Logger.InfoNewline($"Loading plugins from {pluginsDir}...", "Plugins");
Expand Down Expand Up @@ -101,4 +103,4 @@ public static void CallOnFinish()
cpp2IlPlugin.CallOnFinish();
}
}
}
}
10 changes: 7 additions & 3 deletions LibCpp2IL/LibCpp2IL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Description>Library for interacting with IL2CPP metadata and binaries</Description>
<Configurations>Debug;Release</Configurations>
<TargetFrameworks>net7.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AssetRipper.Primitives" Version="2.1.0" />
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<PackageReference Include="IndexRange" Version="1.0.2" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion WasmDisassembler/WasmDisassembler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@
<RepositoryUrl>https://github.com/SamboyCoding/Cpp2IL.git</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Description>Simple, zero-dependency disassembler for WebAssembly bytecode</Description>
<TargetFrameworks>net7.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

</Project>
Loading