Skip to content

Commit 6f3d7f8

Browse files
committed
Reapply reverted changes
1 parent a99af9c commit 6f3d7f8

File tree

9 files changed

+58
-66
lines changed

9 files changed

+58
-66
lines changed

src/Cli/dotnet/Commands/Run/CSharpCompilerCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ private void PrepareAuxiliaryFiles(out string rspPath)
210210
build_property.EnableSingleFileAnalyzer = true
211211
build_property.EnableTrimAnalyzer = true
212212
build_property.IncludeAllContentForSelfExtract =
213+
build_property.VerifyReferenceTrimCompatibility =
214+
build_property.VerifyReferenceAotCompatibility =
213215
build_property.TargetFramework = net{TargetFrameworkVersion}
214216
build_property.TargetFrameworkIdentifier = .NETCoreApp
215217
build_property.TargetFrameworkVersion = v{TargetFrameworkVersion}

test/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ public void ItCanBuildWithMicrosoftBuildArtifactsSdk()
532532

533533
}
534534

535-
[Fact]
535+
[Fact(Skip = "https://github.com/dotnet/sdk/issues/50140")]
536536
public void PublishingRegistersWrittenFilesForProperCleanup()
537537
{
538538
var testProject = new TestProject()
@@ -580,7 +580,7 @@ public void PublishingRegistersWrittenFilesForProperCleanup()
580580
LocateAndRunApp(publishDir);
581581

582582
// now build the app in Release configuration.
583-
// now self-contained, so that we are forced to clean up the runtime
583+
// not self-contained, so that we are forced to clean up the runtime
584584
// files that were published.
585585
new DotnetBuildCommand(Log)
586586
.WithWorkingDirectory(projectDir)

test/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ public void It_respects_opt_outs(string attributeToOptOut)
5050
.Should()
5151
.Pass();
5252

53-
var expectedInfo = new SortedDictionary<string, string>
54-
{
55-
{ "AssemblyInformationalVersionAttribute", "1.2.3-beta" },
56-
{ "AssemblyFileVersionAttribute", "4.5.6.7" },
57-
{ "AssemblyVersionAttribute", "8.9.10.11" },
58-
{ "AssemblyCompanyAttribute", "TestCompany" },
59-
{ "AssemblyConfigurationAttribute", "Release" },
60-
{ "AssemblyCopyrightAttribute", "TestCopyright" },
61-
{ "AssemblyDescriptionAttribute", "TestDescription" },
62-
{ "AssemblyProductAttribute", "TestProduct" },
63-
{ "AssemblyTitleAttribute", "TestTitle" },
64-
{ "AssemblyTrademarkAttribute", "TestTrademark" },
65-
{ "NeutralResourcesLanguageAttribute", "fr" },
53+
var expectedInfo = new HashSet<(string Key, string Value)>
54+
{
55+
("AssemblyInformationalVersionAttribute", "1.2.3-beta"),
56+
("AssemblyFileVersionAttribute", "4.5.6.7"),
57+
("AssemblyVersionAttribute", "8.9.10.11"),
58+
("AssemblyCompanyAttribute", "TestCompany"),
59+
("AssemblyConfigurationAttribute", "Release"),
60+
("AssemblyCopyrightAttribute", "TestCopyright"),
61+
("AssemblyDescriptionAttribute", "TestDescription"),
62+
("AssemblyProductAttribute", "TestProduct"),
63+
("AssemblyTitleAttribute", "TestTitle"),
64+
("AssemblyTrademarkAttribute", "TestTrademark"),
65+
("NeutralResourcesLanguageAttribute", "fr"),
6666
};
6767

6868
if (attributeToOptOut == "All")
@@ -71,15 +71,15 @@ public void It_respects_opt_outs(string attributeToOptOut)
7171
}
7272
else
7373
{
74-
expectedInfo.Remove(attributeToOptOut);
74+
expectedInfo.RemoveWhere(i => i.Key == attributeToOptOut);
7575
}
7676

77-
expectedInfo.Add("TargetFrameworkAttribute", $".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}");
77+
expectedInfo.Add(("TargetFrameworkAttribute", $".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}"));
7878

7979
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework, "Release").FullName, "HelloWorld.dll");
8080
var actualInfo = AssemblyInfo.Get(assemblyPath);
8181

82-
actualInfo.Should().Equal(expectedInfo);
82+
actualInfo.Should().BeEquivalentTo(expectedInfo);
8383
}
8484

8585
[Fact]
@@ -235,7 +235,7 @@ public void It_includes_source_revision_id_if_available__version_with_plus()
235235
command.GetValues().Should().BeEquivalentTo(new[] { "1.2.3+abc.xyz" });
236236
}
237237

238-
[WindowsOnlyTheory]
238+
[Theory]
239239
[InlineData(ToolsetInfo.CurrentTargetFramework)]
240240
[InlineData("net45")]
241241
public void It_respects_version_prefix(string targetFramework)
@@ -258,9 +258,9 @@ public void It_respects_version_prefix(string targetFramework)
258258
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory(targetFramework).FullName, "HelloWorld.dll");
259259
var info = AssemblyInfo.Get(assemblyPath);
260260

261-
info["AssemblyVersionAttribute"].Should().Be("1.2.3.0");
262-
info["AssemblyFileVersionAttribute"].Should().Be("1.2.3.0");
263-
info["AssemblyInformationalVersionAttribute"].Should().Be("1.2.3");
261+
info.Should().Contain(("AssemblyVersionAttribute", "1.2.3.0"));
262+
info.Should().Contain(("AssemblyFileVersionAttribute", "1.2.3.0"));
263+
info.Should().Contain(("AssemblyInformationalVersionAttribute", "1.2.3"));
264264
}
265265

266266
[WindowsOnlyTheory]
@@ -285,7 +285,7 @@ public void It_respects_version_changes_on_incremental_build(string targetFramew
285285
// Then the version of the built assembly shall match the provided VersionPrefix
286286
var assemblyPath = Path.Combine(incrementalBuildCommand.GetOutputDirectory(targetFramework).FullName, "HelloWorld.dll");
287287
var info = AssemblyInfo.Get(assemblyPath);
288-
info["AssemblyVersionAttribute"].Should().Be("1.2.4.0");
288+
info.Should().Contain(("AssemblyVersionAttribute", "1.2.4.0"));
289289

290290
BuildCommand BuildProject(string versionPrefix)
291291
{
@@ -307,7 +307,7 @@ public void It_respects_custom_assembly_attribute_items_on_incremental_build()
307307

308308
var firstBuildCommand = BuildProject(buildNumber: "1");
309309
var assemblyPath = Path.Combine(firstBuildCommand.GetOutputDirectory(targetFramework).FullName, "TestLibrary.dll");
310-
AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("BuildNumber:1");
310+
AssemblyInfo.Get(assemblyPath).Should().Contain(("AssemblyMetadataAttribute", "BuildNumber:1"));
311311

312312
var firstWriteTime = File.GetLastWriteTimeUtc(assemblyPath);
313313

@@ -324,7 +324,7 @@ public void It_respects_custom_assembly_attribute_items_on_incremental_build()
324324
File.GetLastWriteTimeUtc(assemblyPath).Should().NotBe(firstWriteTime);
325325

326326
// and the custom assembly should be generated with the updated value.
327-
AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("BuildNumber:2");
327+
AssemblyInfo.Get(assemblyPath).Should().Contain(("AssemblyMetadataAttribute", "BuildNumber:2"));
328328

329329
BuildCommand BuildProject(string buildNumber)
330330
{
@@ -358,7 +358,7 @@ public void It_includes_internals_visible_to()
358358

359359
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netstandard2.0").FullName, "HelloWorld.dll");
360360

361-
AssemblyInfo.Get(assemblyPath)["InternalsVisibleToAttribute"].Should().Be("Tests");
361+
AssemblyInfo.Get(assemblyPath).Should().Contain(("InternalsVisibleToAttribute", "Tests"));
362362
}
363363

364364
[RequiresMSBuildVersionTheory("17.0.0.32901")]
@@ -552,7 +552,7 @@ public void It_respects_out_out_of_internals_visible_to()
552552

553553
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netstandard2.0").FullName, "HelloWorld.dll");
554554

555-
Assert.False(AssemblyInfo.Get(assemblyPath).ContainsKey("InternalsVisibleToAttribute"));
555+
AssemblyInfo.Get(assemblyPath).Should().NotContain(i => i.Key == "InternalsVisibleToAttribute");
556556
}
557557

558558
[Fact]
@@ -578,7 +578,7 @@ public void It_includes_internals_visible_to_with_key()
578578

579579
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netstandard2.0").FullName, "HelloWorld.dll");
580580

581-
AssemblyInfo.Get(assemblyPath)["InternalsVisibleToAttribute"].Should().Be("Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001001d3e6bbb36e11ea61ceff6e1022b23dd779fc6230838db2d25a2c7c8433b3fcf86b16c25b281fc3db1027c0675395e7d0548e6add88b6a811962bf958101fa9e243b1618313bee11f5e3b3fefda7b1d1226311b6cc2d07e87ff893ba6890b20082df34a0aac14b605b8be055e81081a626f8c69e9ed4bbaa4eae9f94a35accd2");
581+
AssemblyInfo.Get(assemblyPath).Should().Contain(("InternalsVisibleToAttribute", "Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001001d3e6bbb36e11ea61ceff6e1022b23dd779fc6230838db2d25a2c7c8433b3fcf86b16c25b281fc3db1027c0675395e7d0548e6add88b6a811962bf958101fa9e243b1618313bee11f5e3b3fefda7b1d1226311b6cc2d07e87ff893ba6890b20082df34a0aac14b605b8be055e81081a626f8c69e9ed4bbaa4eae9f94a35accd2"));
582582
}
583583

584584
[Fact]
@@ -605,7 +605,7 @@ public void It_includes_internals_visible_to_with_project_publickey()
605605

606606
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netstandard2.0").FullName, "HelloWorld.dll");
607607

608-
AssemblyInfo.Get(assemblyPath)["InternalsVisibleToAttribute"].Should().Be("Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001001d3e6bbb36e11ea61ceff6e1022b23dd779fc6230838db2d25a2c7c8433b3fcf86b16c25b281fc3db1027c0675395e7d0548e6add88b6a811962bf958101fa9e243b1618313bee11f5e3b3fefda7b1d1226311b6cc2d07e87ff893ba6890b20082df34a0aac14b605b8be055e81081a626f8c69e9ed4bbaa4eae9f94a35accd2");
608+
AssemblyInfo.Get(assemblyPath).Should().Contain(("InternalsVisibleToAttribute", "Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001001d3e6bbb36e11ea61ceff6e1022b23dd779fc6230838db2d25a2c7c8433b3fcf86b16c25b281fc3db1027c0675395e7d0548e6add88b6a811962bf958101fa9e243b1618313bee11f5e3b3fefda7b1d1226311b6cc2d07e87ff893ba6890b20082df34a0aac14b605b8be055e81081a626f8c69e9ed4bbaa4eae9f94a35accd2"));
609609
}
610610

611611
[Fact]
@@ -631,11 +631,11 @@ public void It_includes_assembly_metadata()
631631

632632
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netstandard2.0").FullName, "HelloWorld.dll");
633633

634-
AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("MetadataKey:MetadataValue");
634+
AssemblyInfo.Get(assemblyPath).Should().Contain(("AssemblyMetadataAttribute", "MetadataKey:MetadataValue"));
635635
}
636636

637637
[Fact]
638-
public void It_respects_out_out_of_assembly_metadata()
638+
public void It_respects_opt_out_of_assembly_metadata()
639639
{
640640
var testAsset = _testAssetsManager
641641
.CopyTestAsset("HelloWorld")
@@ -659,7 +659,7 @@ public void It_respects_out_out_of_assembly_metadata()
659659

660660
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netstandard2.0").FullName, "HelloWorld.dll");
661661

662-
Assert.False(AssemblyInfo.Get(assemblyPath).ContainsKey("AssemblyMetadataAttribute"));
662+
AssemblyInfo.Get(assemblyPath).Should().NotContain(i => i.Key == "AssemblyMetadataAttribute");
663663
}
664664

665665
[Theory]
@@ -699,11 +699,11 @@ public void GenerateUserSecrets(bool referenceAspNetCore, bool referenceExtensio
699699

700700
if (shouldHaveAttribute)
701701
{
702-
AssemblyInfo.Get(assemblyPath)["UserSecretsIdAttribute"].Should().Be("SecretsIdValue");
702+
AssemblyInfo.Get(assemblyPath).Should().Contain(("UserSecretsIdAttribute", "SecretsIdValue"));
703703
}
704704
else
705705
{
706-
AssemblyInfo.Get(assemblyPath).Should().NotContainKey("SecretsIdValue");
706+
AssemblyInfo.Get(assemblyPath).Should().NotContain(i => i.Key == "SecretsIdValue");
707707
}
708708
}
709709

@@ -743,7 +743,7 @@ public void GenerateUserSecretsForTestProject()
743743

744744
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory(testTestProject.TargetFrameworks).FullName, testTestProject.Name + ".dll");
745745

746-
AssemblyInfo.Get(assemblyPath)["UserSecretsIdAttribute"].Should().Be("SecretsIdValue");
746+
AssemblyInfo.Get(assemblyPath).Should().Contain(("UserSecretsIdAttribute", "SecretsIdValue"));
747747
}
748748

749749
[Theory]
@@ -775,7 +775,7 @@ public void It_includes_repository_url(bool privateRepo)
775775

776776
var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory(testProject.TargetFrameworks).FullName, testProject.Name + ".dll");
777777

778-
AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("RepositoryUrl:" + fakeUrl);
778+
AssemblyInfo.Get(assemblyPath).Should().Contain(("AssemblyMetadataAttribute", "RepositoryUrl:" + fakeUrl));
779779
}
780780

781781
[Theory]
@@ -804,11 +804,11 @@ public void It_does_not_write_to_undefined_assembly_metadata_attribute(string ta
804804

805805
if (containsAttribute)
806806
{
807-
AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("RepositoryUrl:" + fakeUrl);
807+
AssemblyInfo.Get(assemblyPath).Should().Contain(("AssemblyMetadataAttribute", "RepositoryUrl:" + fakeUrl));
808808
}
809809
else
810810
{
811-
AssemblyInfo.Get(assemblyPath).ContainsKey("AssemblyMetadataAttribute").Should().Be(false);
811+
AssemblyInfo.Get(assemblyPath).Should().NotContain(i => i.Key == "AssemblyMetadataAttribute");
812812
}
813813
}
814814

test/Microsoft.NET.Build.Tests/GivenThatWeWantToVerifyNuGetReferenceCompat.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ public void Nuget_reference_compat(string referencerTarget, string testDescripti
4141

4242
// Process all dependencies in parallel
4343
Parallel.ForEach(
44-
rawDependencyTargets.Split(',', ';', ' ').Where(s => !string.IsNullOrWhiteSpace(s)),
44+
rawDependencyTargets.Split(',', ';', ' ').Where(s => !string.IsNullOrWhiteSpace(s)),
4545
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount },
46-
dependencyTarget =>
46+
dependencyTarget =>
4747
{
4848
// Create the dependency project and package
4949
TestProject dependencyProject = GetTestProject(
50-
ConstantStringValues.DependencyDirectoryNamePrefix + dependencyTarget.Replace('.', '_'),
51-
dependencyTarget,
50+
ConstantStringValues.DependencyDirectoryNamePrefix + dependencyTarget.Replace('.', '_'),
51+
dependencyTarget,
5252
true);
53-
53+
5454
TestPackageReference dependencyPackageReference = new(
5555
dependencyProject.Name,
5656
"1.0.0",
@@ -208,7 +208,7 @@ public void It_chooses_lowest_netfx_in_default_atf()
208208
buildCommand.Execute().Should().Pass();
209209

210210
var referencedDll = buildCommand.GetOutputDirectory().File("net462_net472_pkg.dll").FullName;
211-
var referencedTargetFramework = AssemblyInfo.Get(referencedDll)["TargetFrameworkAttribute"];
211+
var referencedTargetFramework = AssemblyInfo.Get(referencedDll).Where(i => i.Key == "TargetFrameworkAttribute").Single().Value;
212212
referencedTargetFramework.Should().Be(".NETFramework,Version=v4.6.2");
213213
}
214214

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ public void IsAotCompatible_implies_enable_analyzers(string targetFramework)
593593
var assemblyPath = Path.Combine(outputDirectory, $"{projectName}.dll");
594594

595595
// injects the IsTrimmable attribute
596-
AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("IsTrimmable:True");
596+
AssemblyInfo.Get(assemblyPath).Should().Contain(("AssemblyMetadataAttribute", "IsTrimmable:True"));
597597

598598
var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
599599
publishCommand

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void ILLink_runs_and_creates_linked_app(string targetFramework, bool refe
108108
}
109109

110110
// https://github.com/dotnet/sdk/issues/49665
111-
// ILLINK : Failed to load /private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/10.0.0-preview.6.25315.102/libhostpolicy.dylib, error : dlopen(/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/10.0.0-preview.6.25315.102/libhostpolicy.dylib, 0x0001): tried: '/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/10.0.0-preview.6.25315.102/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
111+
// ILLINK : Failed to load /private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/10.0.0-preview.6.25315.102/libhostpolicy.dylib, error : dlopen(/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/10.0.0-preview.6.25315.102/libhostpolicy.dylib, 0x0001): tried: '/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/10.0.0-preview.6.25315.102/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
112112
[PlatformSpecificTheory(TestPlatforms.Any & ~TestPlatforms.OSX)]
113113
[MemberData(nameof(SupportedTfms), MemberType = typeof(PublishTestUtils))]
114114
public void ILLink_links_simple_app_without_analysis_warnings_and_it_runs(string targetFramework)
@@ -599,7 +599,7 @@ public void ILLink_analysis_warnings_are_disabled_by_default(string targetFramew
599599
}
600600

601601
// https://github.com/dotnet/sdk/issues/49665
602-
// ILLINK : Failed to load /private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/7.0.0/libhostpolicy.dylib, error : dlopen(/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/7.0.0/libhostpolicy.dylib, 0x0001): tried: '/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/7.0.0/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
602+
// ILLINK : Failed to load /private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/7.0.0/libhostpolicy.dylib, error : dlopen(/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/7.0.0/libhostpolicy.dylib, 0x0001): tried: '/private/tmp/helix/working/A452091E/p/d/shared/Microsoft.NETCore.App/7.0.0/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
603603
[PlatformSpecificTheory(TestPlatforms.Any & ~TestPlatforms.OSX)]
604604
[MemberData(nameof(Net6Plus), MemberType = typeof(PublishTestUtils))]
605605
public void ILLink_analysis_warnings_are_enabled_by_default(string targetFramework)
@@ -1780,7 +1780,7 @@ public void Build_respects_IsTrimmable_property(string targetFramework, bool isE
17801780
var runtimeConfigPath = Path.Combine(outputDirectory, $"{projectName}.runtimeconfig.json");
17811781

17821782
// injects the IsTrimmable attribute
1783-
AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("IsTrimmable:True");
1783+
AssemblyInfo.Get(assemblyPath).Should().Contain(("AssemblyMetadataAttribute", "IsTrimmable:True"));
17841784

17851785
// just setting IsTrimmable doesn't enable feature settings
17861786
// (these only affect apps, and wouldn't make sense for libraries either)
@@ -1823,7 +1823,7 @@ public void Build_respects_PublishTrimmed_property(string targetFramework)
18231823
configProperties["System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault"].Value<bool>().Should().BeFalse();
18241824

18251825
// just setting PublishTrimmed doesn't inject the IsTrimmable attribute
1826-
AssemblyInfo.Get(assemblyPath).ContainsKey("AssemblyMetadataAttribute").Should().BeFalse();
1826+
AssemblyInfo.Get(assemblyPath).Should().NotContain(i => i.Key == "AssemblyMetadataAttribute");
18271827
}
18281828
}
18291829

0 commit comments

Comments
 (0)