Skip to content

Commit

Permalink
Allow writing to init property setters of generic classes on .NET 6+
Browse files Browse the repository at this point in the history
Only .NET 6 has the fix to `MethodBuilder` required for this to work. .NET Framework has not been fixed.

Closes #1134 (once again)
  • Loading branch information
AArnott committed Jul 5, 2024
1 parent 3aec9fd commit 83019ef
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,12 @@ public bool IsValueType
/// <see href="https://github.com/neuecc/MessagePack-CSharp/issues/1134">A bug</see> in <see cref="MethodBuilder"/>
/// blocks its ability to invoke property init accessors when in a generic class.
/// </remarks>
internal bool IsProblematicInitProperty => this.PropertyInfo is PropertyInfo property && property.DeclaringType!.IsGenericType && this.IsInitOnly;
internal bool IsProblematicInitProperty
#if NET6_0_OR_GREATER
=> false;
#else
=> this.PropertyInfo is PropertyInfo property && property.DeclaringType!.IsGenericType && this.IsInitOnly;
#endif

public MessagePackFormatterAttribute? GetMessagePackFormatterAttribute()
{
Expand Down

0 comments on commit 83019ef

Please sign in to comment.