Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -14,6 +14,7 @@
<EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>false</EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>
<DebuggerSupport>true</DebuggerSupport>
<EventSourceSupport>false</EventSourceSupport>
<MetricsSupport>false</MetricsSupport>
<InvariantGlobalization>true</InvariantGlobalization>
<PredefinedCulturesOnly>true</PredefinedCulturesOnly>
<ConcurrentGarbageCollection>false</ConcurrentGarbageCollection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ Copyright (c) .NET Foundation. All rights reserved.
Value="$(DebuggerSupport)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Diagnostics.Metrics.Meter.IsSupported"
Condition="'$(MetricsSupport)' != ''"
Value="$(MetricsSupport)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Diagnostics.Tracing.EventSource.IsSupported"
Condition="'$(EventSourceSupport)' != ''"
Value="$(EventSourceSupport)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,50 @@ public void It_can_implicitly_define_predefined_Cultures_only(string targetFrame
}
}

[Theory]
[InlineData("True")]
[InlineData("False")]
[InlineData(null)]
public void It_can_evaluate_metrics_support(string value)
{
var testProj = new TestProject()
{
Name = "CheckMetricsSupport",
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
IsExe = true,
};

if (value is not null)
{
testProj.AdditionalProperties["MetricsSupport"] = value;
}

var testAsset = _testAssetsManager.CreateTestProject(testProj, identifier: value);
var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute()
.Should()
.Pass();

string runtimeConfigName = $"{testProj.Name}.runtimeconfig.json";
var outputDirectory = buildCommand.GetOutputDirectory(testProj.TargetFrameworks);
outputDirectory.Should().HaveFile(runtimeConfigName);

string runtimeConfigFile = Path.Combine(outputDirectory.FullName, runtimeConfigName);
string runtimeConfigContents = File.ReadAllText(runtimeConfigFile);
JObject runtimeConfig = JObject.Parse(runtimeConfigContents);
JToken metricsSupport = runtimeConfig["runtimeOptions"]["configProperties"]["System.Diagnostics.Metrics.Meter.IsSupported"];

if (value is null)
{
metricsSupport.Should().BeNull();
}
else
{
metricsSupport.Value<string>().Should().Be(value);
}
}

[Theory]
[InlineData("netcoreapp2.2", null, false, null, false)]
[InlineData(ToolsetInfo.CurrentTargetFramework, null, true, null, true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string []
""System.AggressiveAttributeTrimming"": true,
""System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"": false,
""System.Diagnostics.Debugger.IsSupported"": true,
""System.Diagnostics.Metrics.Meter.IsSupported"": false,
""System.Diagnostics.Tracing.EventSource.IsSupported"": false,
""System.Globalization.Invariant"": true,
""System.Globalization.PredefinedCulturesOnly"": true,
Expand Down Expand Up @@ -101,7 +102,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string []
baselineConfigJsonObject["runtimeOptions"]["tfm"] = targetFramework;
baselineConfigJsonObject["runtimeOptions"]["framework"]["version"] =
targetFramework == "net6.0" ? "6.0.0" : "1.1.2";

runtimeConfigJsonObject
.Should()
.BeEquivalentTo(baselineConfigJsonObject);
Expand Down