Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Assets/TestProjects/KitchenSink/TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<CustomResourceTypesSupport>false</CustomResourceTypesSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<DynamicCodeSupport>true</DynamicCodeSupport>
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
<BuiltInComInteropSupport>false</BuiltInComInteropSupport>
<_EnableConsumingManagedCodeFromNativeHosting>false</_EnableConsumingManagedCodeFromNativeHosting>
<EnableCppCLIHostActivation>false</EnableCppCLIHostActivation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<_IsTrimmingEnabled Condition="'$(_IsTrimmingEnabled)' == '' And ('$(PublishTrimmed)' == 'true' Or '$(IsTrimmable)' == 'true')">true</_IsTrimmingEnabled>
<_IsTrimmingEnabled Condition="'$(_IsTrimmingEnabled)' == ''">false</_IsTrimmingEnabled>
<DynamicCodeSupport Condition="'$(DynamicCodeSupport)' == '' And '$(PublishAot)' == 'true'">false</DynamicCodeSupport>
<JsonSerializerIsReflectionEnabledByDefault Condition="'$(JsonSerializerIsReflectionEnabledByDefault)' == '' And '$(PublishAot)' == 'true'">false</JsonSerializerIsReflectionEnabledByDefault>
</PropertyGroup>

<ItemDefinitionGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ Copyright (c) .NET Foundation. All rights reserved.
Value="$(DynamicCodeSupport)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault"
Condition="'$(JsonSerializerIsReflectionEnabledByDefault)' != ''"
Value="$(JsonSerializerIsReflectionEnabledByDefault)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.BuiltInComInterop.IsSupported"
Condition="'$(BuiltInComInteropSupport)' != ''"
Value="$(BuiltInComInteropSupport)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string []
""System.Runtime.TieredPGO"": true,
""System.StartupHookProvider.IsSupported"": false,
""System.Text.Encoding.EnableUnsafeUTF7Encoding"": false,
""System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault"": false,
""System.Threading.Thread.EnableAutoreleasePool"": false,
""System.Threading.ThreadPool.MinThreads"": 2,
""System.Threading.ThreadPool.MaxThreads"": 9,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,31 @@ public void It_builds_with_dynamiccodesupport_false_when_publishaot_true(string
.Should().BeFalse();
}

[RequiresMSBuildVersionTheory("17.0.0.32901")]
[InlineData(ToolsetInfo.CurrentTargetFramework)]
public void It_builds_with_jsonserializerisreflectionenabledbydefault_false_when_publishaot_true(string targetFramework)
{
var projectName = "JsonSerializerIsReflectionEnabledByDefaultFalseApp";
var testProject = CreateHelloWorldTestProject(targetFramework, projectName, true);
testProject.AdditionalProperties["PublishAot"] = "true";
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute()
.Should()
.Pass();

string outputDirectory = buildCommand.GetOutputDirectory(targetFramework: targetFramework).FullName;
string runtimeConfigFile = Path.Combine(outputDirectory, $"{projectName}.runtimeconfig.json");
string runtimeConfigContents = File.ReadAllText(runtimeConfigFile);

JObject runtimeConfig = JObject.Parse(runtimeConfigContents);
JToken configProperties = runtimeConfig["runtimeOptions"]["configProperties"];
configProperties["System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault"].Value<bool>()
.Should().BeFalse();
}

private void CheckIlcVersions(string projectPath, string targetFramework, string rid, string expectedVersion)
{
// Compiler version matches expected version
Expand Down