Skip to content

Commit

Permalink
Fix issues from trimming support commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SamboyCoding committed Dec 22, 2024
1 parent 43c7005 commit 89555b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Tomlet.Tests/ObjectToStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ public void SerializingAnEmptyObjectGivesAnEmptyString()
}

[Fact]
public void AttemptingToDirectlySerializeNullThrows()
public void AttemptingToDirectlySerializeNullReturnsNull()
{
//We need to use a type of T that actually has something to serialize
Assert.Throws<ArgumentNullException>(() => TomletMain.DocumentFrom(typeof(SimplePrimitiveTestClass), null!, null));
Assert.Null(TomletMain.DocumentFrom(typeof(SimplePrimitiveTestClass), null!, null));
}
}
}
3 changes: 2 additions & 1 deletion Tomlet.Tests/Tomlet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7</TargetFramework>
<TargetFramework>net9</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>11</LangVersion>
<IsTrimmable>false</IsTrimmable>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Tomlet/TomletMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static object To(Type what, TomlValue value, TomlSerializerOptions? optio

#if MODERN_DOTNET
[return: NotNullIfNotNull("t")]
[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.")]
#if NET7_0_OR_GREATER
[RequiresDynamicCode("The native code for underlying implementations of serialize helper methods may not be available for a given type.")]
#endif // NET7_0_OR_GREATER
Expand All @@ -80,7 +81,7 @@ public static object To(Type what, TomlValue value, TomlSerializerOptions? optio
if (t == null)
return null;

return ValueFrom(typeof(T), t, options);
return ValueFrom(t.GetType(), t, options);
}

#if MODERN_DOTNET
Expand Down

0 comments on commit 89555b8

Please sign in to comment.