Skip to content

Support unsafe accessors for static methods when they become available.Β #220

@eiriktsarpalis

Description

@eiriktsarpalis

Support for unsafe accessors of static methods was added in .NET 10 via the new UnsafeAccessorTypeAttribute. The source generator should be updated to leverage that once .NET 10 gets released.

We should update the logic here:

CanUseUnsafeAccessors = _knownSymbols.TargetFramework switch
{
// .NET 8 or later supports unsafe accessors for methods of non-generic types.
// .NET 10 or later supports unsafe accessors for static methods cf. https://github.com/eiriktsarpalis/PolyType/issues/220
var target when target >= TargetFramework.Net80 => !m.Method.ContainingType.IsGenericType && !m.Method.IsStatic,
_ => false
},

such that net10.0 targets also support static methods for unsafe accessors. Then the codegen should take advantage of the new UnsafeAccessorTypeAttribute.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions