Skip to content

Commit

Permalink
Fix System.MissingMethodException occurring in trimmed ASF binary
Browse files Browse the repository at this point in the history
The Lazy<T> constructor that takes a value parameter is trimmed in the official ASF binary, which causes a System.MissingMethodException when the plugin tries to access it. This commit fixes this issue by using a static lambda expression that returns the default cancellation token instead.

This commit closes #43.
  • Loading branch information
maxisoft committed Nov 7, 2023
1 parent 270eebb commit 90e22dd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ASFFreeGames/PluginContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed record PluginContext(IReadOnlyCollection<Bot> Bots, IContextRegi
/// </summary>
public CancellationToken CancellationToken => CancellationTokenLazy.Value;

internal Lazy<CancellationToken> CancellationTokenLazy { private get; set; } = new(default(CancellationToken));
internal Lazy<CancellationToken> CancellationTokenLazy { private get; set; } = new(static () => default(CancellationToken));

/// <summary>
/// A struct that implements IDisposable and temporarily changes the cancellation token of the PluginContext instance.
Expand Down

0 comments on commit 90e22dd

Please sign in to comment.