Skip to content

Commit 1d7c8c8

Browse files
committed
WIP: Enable partial trimming of the Arise.Client project.
Closes #52.
1 parent 6cae922 commit 1d7c8c8

File tree

9 files changed

+33
-3
lines changed

9 files changed

+33
-3
lines changed

src/client/Launcher/Templates/WindowLocatorDataTemplate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public bool Match(object? data)
2121
return data is LauncherController;
2222
}
2323

24+
[UnconditionalSuppressMessage("", "IL2026")]
2425
public Control Build(object? param)
2526
{
2627
return Unsafe.As<Control>(

src/client/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace Arise.Client;
1515

1616
internal static class Program
1717
{
18+
[UnconditionalSuppressMessage("", "IL2026")]
1819
private static Task Main(string[] args)
1920
{
2021
var context = InjectedProgramContext.Instance;

src/client/client.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22
<PropertyGroup>
33
<AssemblyName>arise</AssemblyName>
44
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
5+
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
56
<CopyDebugSymbolFilesFromPackages Condition="'$(DebugSymbols)' == 'true'">true</CopyDebugSymbolFilesFromPackages>
7+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
68
<EventSourceSupport>false</EventSourceSupport>
79
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
810
<IsPublishable>true</IsPublishable>
911
<NullabilityInfoContextSupport>false</NullabilityInfoContextSupport>
1012
<OutputType>WinExe</OutputType>
13+
<PublishTrimmed>true</PublishTrimmed>
1114
<RootNamespace>Arise.Client</RootNamespace>
1215
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1316
<RuntimeIdentifiers />
1417
<SelfContained>true</SelfContained>
18+
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
19+
<TrimmerRemoveSymbols Condition="'$(DebugSymbols)' != 'true'">true</TrimmerRemoveSymbols>
20+
<TrimMode>partial</TrimMode>
1521
<!-- This is unfortunately needed due to the patcher reference. -->
1622
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
1723
</PropertyGroup>

src/shared/Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)..'))" />
3+
4+
<PropertyGroup>
5+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
6+
</PropertyGroup>
7+
</Project>

src/shared/game/Bridge/BridgeModuleActivator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ namespace Arise.Bridge;
22

33
public static class BridgeModuleActivator
44
{
5+
[UnconditionalSuppressMessage("", "IL2026")]
6+
[UnconditionalSuppressMessage("", "IL2072")]
57
public static BridgeModule Create(ReadOnlyMemory<byte> module)
68
{
79
using var stream = SlimMemoryStream.CreateReadOnly(module);

src/shared/game/Net/Serialization/AriseGamePacketSerializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ private AriseGamePacketSerializer()
4242

4343
protected override void GenerateDeserializer(Expression packet, Expression accessor)
4444
{
45+
[UnconditionalSuppressMessage("", "IL2072")]
4546
void GenerateForObject(Expression @object)
4647
{
48+
[UnconditionalSuppressMessage("", "IL2060")]
4749
void GenerateForValue(Type type, Action<Expression> handler)
4850
{
4951
Expression result;
@@ -119,8 +121,10 @@ void GenerateForValue(Type type, Action<Expression> handler)
119121

120122
protected override void GenerateSerializer(Expression packet, Expression accessor)
121123
{
124+
[UnconditionalSuppressMessage("", "IL2072")]
122125
void GenerateForObject(Expression @object)
123126
{
127+
[UnconditionalSuppressMessage("", "IL2060")]
124128
void GenerateForValue(Expression value)
125129
{
126130
var type = value.Type;

src/shared/game/Net/Serialization/GamePacketSerializer`2.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ internal abstract class GamePacketSerializer<TCode, TPacket>
2424

2525
private int _variableCounter;
2626

27+
[UnconditionalSuppressMessage("", "IL2026")]
28+
[UnconditionalSuppressMessage("", "IL2072")]
2729
private protected GamePacketSerializer()
2830
{
2931
var creators = new Dictionary<TCode, Func<TPacket>>();
3032
var deserializers = new Dictionary<TCode, Action<TPacket, GameStreamAccessor>>();
3133
var serializers = new Dictionary<TCode, Action<TPacket, GameStreamAccessor>>();
3234

35+
[SuppressMessage("", "SA1134")]
3336
Action<TPacket, GameStreamAccessor> CompileFunction(Type type, Action<Expression, Expression> generator)
3437
{
35-
return Lambda<Action<TPacket, GameStreamAccessor>>(ctx =>
38+
return Lambda<Action<TPacket, GameStreamAccessor>>([UnconditionalSuppressMessage("", "IL2060")] (ctx) =>
3639
{
3740
var (packet, accessor) = ctx;
3841

@@ -62,7 +65,8 @@ Action<TPacket, GameStreamAccessor> CompileFunction(Type type, Action<Expression
6265
_serializers = serializers.ToFrozenDictionary();
6366
}
6467

65-
protected static IEnumerable<PropertyInfo> EnumerateProperties(Type type)
68+
protected static IEnumerable<PropertyInfo> EnumerateProperties(
69+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type)
6670
{
6771
var isPacket = type.IsSubclassOf(typeof(GamePacket));
6872

src/shared/game/Net/Serialization/TeraGamePacketSerializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ private TeraGamePacketSerializer()
3333

3434
protected override void GenerateDeserializer(Expression packet, Expression accessor)
3535
{
36+
[UnconditionalSuppressMessage("", "IL2072")]
3637
void GenerateForObject(Expression @object)
3738
{
39+
[UnconditionalSuppressMessage("", "IL2060")]
3840
void GenerateForValue(Type type, Action<Expression> handler)
3941
{
4042
Expression result;
@@ -142,8 +144,10 @@ void GenerateForValue(Type type, Action<Expression> handler)
142144

143145
protected override void GenerateSerializer(Expression packet, Expression accessor)
144146
{
147+
[UnconditionalSuppressMessage("", "IL2072")]
145148
void GenerateForObject(Expression @object)
146149
{
150+
[UnconditionalSuppressMessage("", "IL2060")]
147151
void GenerateFirstPassForValue(Expression value, Action<ParameterExpression> handler)
148152
{
149153
var type = value.Type;

src/shared/game/Net/Sessions/GameSessionDispatcher`2.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
namespace Arise.Net.Sessions;
55

6-
public abstract class GameSessionDispatcher<TSession, THandler>
6+
public abstract class GameSessionDispatcher<TSession, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] THandler>
77
where TSession : GameSession
88
where THandler : class
99
{
1010
private static readonly MethodInfo _as = typeof(Unsafe).GetMethod("As", 1, [typeof(object)])!;
1111

1212
private readonly FrozenDictionary<Type, Action<TSession, GamePacket>> _handlers;
1313

14+
[UnconditionalSuppressMessage("", "IL2060")]
1415
protected GameSessionDispatcher()
1516
{
1617
_handlers = typeof(THandler)

0 commit comments

Comments
 (0)