Skip to content

Commit d46db80

Browse files
authored
Merge pull request #802 from AArnott/AOTTestOn10
Test NativeAOT compat on .NET 10
2 parents b906e51 + 61fa4ae commit d46db80

5 files changed

Lines changed: 32 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ jobs:
6262
(gci $Path).Length / 1024 / 1024
6363
}
6464
65-
$Path = './bin/AotNativeConsole/${{ env.BUILDCONFIGURATION }}/net9.0/${{ matrix.rid }}/publish/AotNativeConsole'
65+
$Path = './bin/AotNativeConsole/${{ env.BUILDCONFIGURATION }}/net10.0/${{ matrix.rid }}/publish/AotNativeConsole'
6666
$ActualSize = GetSizeInMB($Path)
6767
6868
# Allow variance of a small threshold of the expected value.
6969
# Fail even if it's smaller than anticipated so that the expected window can be shrunk in this file.
7070
if ($IsLinux) {
71-
$ExpectedSize = 8.01
71+
$ExpectedSize = 7.03
7272
} elseif ($IsMacOS) {
73-
$ExpectedSize = 7.87
73+
$ExpectedSize = 6.43
7474
} else {
75-
$ExpectedSize = 6.79
75+
$ExpectedSize = 6.83
7676
}
7777
$AllowedVariance = 0.2
7878
$SizeCheckPassed = [math]::Abs($ActualSize - $ExpectedSize) -le $AllowedVariance

src/Nerdbank.MessagePack/ConverterTypeCollection.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,22 @@ internal bool TryGetConverterType(Type dataType, [NotNullWhen(true), Dynamically
9898
/// <summary>
9999
/// A wrapper around <see cref="Type"/> that ensures a trimmed application will preserve the type's public default constructor.
100100
/// </summary>
101-
/// <param name="type">The wrapped type. A type that does not declare a public default constructor may still be wrapped, but may result in a runtime error later.</param>
102-
public readonly struct TypeWithDefaultConstructor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type type)
101+
public readonly struct TypeWithDefaultConstructor
103102
{
103+
/// <summary>
104+
/// Initializes a new instance of the <see cref="TypeWithDefaultConstructor"/> struct.
105+
/// </summary>
106+
/// <param name="type">The wrapped type. A type that does not declare a public default constructor may still be wrapped, but may result in a runtime error later.</param>
107+
public TypeWithDefaultConstructor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type type)
108+
{
109+
this.Type = type;
110+
}
111+
104112
/// <summary>
105113
/// Gets the wrapped type.
106114
/// </summary>
107115
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
108-
public Type Type => type;
116+
public Type Type { get; }
109117

110118
/// <summary>
111119
/// Implicitly converts a <see cref="Type"/> to a <see cref="TypeWithDefaultConstructor"/>.

src/Nerdbank.MessagePack/MessagePackConverterAttribute.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,25 @@ namespace Nerdbank.MessagePack;
99
/// A class applied to a custom data type to prescribe a custom <see cref="MessagePackConverter{T}"/>
1010
/// implementation to use for serialization.
1111
/// </summary>
12-
/// <param name="converterType">
13-
/// A type that implements <see cref="MessagePackConverter{T}"/>
14-
/// where <c>T</c> is a type argument matching the type to which this attribute is applied.
15-
/// </param>
1612
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
17-
[AssociatedTypeAttribute(nameof(converterType), TypeShapeRequirements.Constructor)]
18-
public class MessagePackConverterAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type converterType) : Attribute
13+
[AssociatedTypeAttribute("converterType", TypeShapeRequirements.Constructor)]
14+
public class MessagePackConverterAttribute : Attribute
1915
{
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="MessagePackConverterAttribute"/> class.
18+
/// </summary>
19+
/// <param name="converterType">
20+
/// A type that implements <see cref="MessagePackConverter{T}"/>
21+
/// where <c>T</c> is a type argument matching the type to which this attribute is applied.
22+
/// </param>
23+
public MessagePackConverterAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type converterType)
24+
{
25+
this.ConverterType = converterType;
26+
}
27+
2028
/// <summary>
2129
/// Gets the type that implements <see cref="MessagePackConverter{T}"/>.
2230
/// </summary>
2331
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
24-
public Type ConverterType => converterType;
32+
public Type ConverterType { get; }
2533
}

test/AotCompatibilityTest/AotCompatibilityTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\AOT.props" />
33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<IsTestProject>false</IsTestProject>
66
</PropertyGroup>
77

test/AotNativeConsole/AotNativeConsole.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\AOT.props" />
33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<IsTestProject>false</IsTestProject>
66
</PropertyGroup>
77

0 commit comments

Comments
 (0)