Skip to content

Commit 89555b8

Browse files
committed
Fix issues from trimming support commit
1 parent 43c7005 commit 89555b8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Tomlet.Tests/ObjectToStringTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ public void SerializingAnEmptyObjectGivesAnEmptyString()
106106
}
107107

108108
[Fact]
109-
public void AttemptingToDirectlySerializeNullThrows()
109+
public void AttemptingToDirectlySerializeNullReturnsNull()
110110
{
111111
//We need to use a type of T that actually has something to serialize
112-
Assert.Throws<ArgumentNullException>(() => TomletMain.DocumentFrom(typeof(SimplePrimitiveTestClass), null!, null));
112+
Assert.Null(TomletMain.DocumentFrom(typeof(SimplePrimitiveTestClass), null!, null));
113113
}
114114
}
115115
}

Tomlet.Tests/Tomlet.Tests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7</TargetFramework>
4+
<TargetFramework>net9</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<LangVersion>11</LangVersion>
7+
<IsTrimmable>false</IsTrimmable>
78
</PropertyGroup>
89

910
<ItemGroup>

Tomlet/TomletMain.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public static object To(Type what, TomlValue value, TomlSerializerOptions? optio
6969

7070
#if MODERN_DOTNET
7171
[return: NotNullIfNotNull("t")]
72+
[UnconditionalSuppressMessage("AOT", "IL2072", Justification = "Any object that is being serialized must have been in the consuming code in order for this call to be occurring, so the dynamic code requirement is already satisfied.")]
7273
#if NET7_0_OR_GREATER
7374
[RequiresDynamicCode("The native code for underlying implementations of serialize helper methods may not be available for a given type.")]
7475
#endif // NET7_0_OR_GREATER
@@ -80,7 +81,7 @@ public static object To(Type what, TomlValue value, TomlSerializerOptions? optio
8081
if (t == null)
8182
return null;
8283

83-
return ValueFrom(typeof(T), t, options);
84+
return ValueFrom(t.GetType(), t, options);
8485
}
8586

8687
#if MODERN_DOTNET

0 commit comments

Comments
 (0)