From dba3493e372746ea8e8b0ad2161a28cbe1ce3121 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 17:11:24 +0000 Subject: [PATCH 1/4] Initial plan From e348f991577c7349b472e5bcc6a64fb83c97f08e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 17:21:41 +0000 Subject: [PATCH 2/4] Only disable StartupHookSupport in non-Debug builds and remove MetadataUpdaterSupport from ILLink.targets; add tests Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/64db1ca8-95d8-47be-90ab-be736ed09ab0 Co-authored-by: tmat <41759+tmat@users.noreply.github.com> --- .../build/Microsoft.NET.ILLink.targets | 3 +- .../ILLink.Tasks.Tests.csproj | 1 + .../ILLink.Tasks.Tests/ILinkTargetsTests.cs | 91 +++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs diff --git a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets index 25b31b223fe16f..565c3c60ea65ca 100644 --- a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets +++ b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets @@ -36,8 +36,7 @@ Copyright (c) .NET Foundation. All rights reserved. by default since they may require assemblies, types or members that could be removed by the ILLink, causing a trimmed app to crash. --> - false - false + false false false false diff --git a/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj b/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj index 5f3daab5629a06..7893830c767eff 100644 --- a/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj +++ b/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj @@ -1,6 +1,7 @@ + diff --git a/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs b/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs new file mode 100644 index 00000000000000..49334f2539fe58 --- /dev/null +++ b/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs @@ -0,0 +1,91 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; +using Microsoft.Build.Evaluation; +using Xunit; + +namespace ILLink.Tasks.Tests +{ + public class ILinkTargetsTests + { + private static string TargetsFilePath => + Path.Combine( + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, + "build", + "Microsoft.NET.ILLink.targets"); + + private static string EvaluateProperty(string propertyName, Dictionary globalProperties) + { + string projectXml = $""" + + + + """; + + using var reader = XmlReader.Create(new StringReader(projectXml)); + using var collection = new ProjectCollection(); + var project = collection.LoadProject(reader, globalProperties, toolsVersion: null); + return project.GetPropertyValue(propertyName); + } + + [Theory] + [InlineData("Release", "false")] + [InlineData("Debug", "")] + public void StartupHookSupport_IsDisabledOnlyForNonDebug(string configuration, string expectedValue) + { + var properties = new Dictionary + { + ["PublishTrimmed"] = "true", + ["Configuration"] = configuration, + }; + + Assert.Equal(expectedValue, EvaluateProperty("StartupHookSupport", properties)); + } + + [Fact] + public void StartupHookSupport_IsNotSetWhenPublishTrimmedIsFalse() + { + var properties = new Dictionary + { + ["PublishTrimmed"] = "false", + ["Configuration"] = "Release", + }; + + Assert.Equal("", EvaluateProperty("StartupHookSupport", properties)); + } + + [Fact] + public void StartupHookSupport_RespectExplicitValue() + { + var properties = new Dictionary + { + ["PublishTrimmed"] = "true", + ["Configuration"] = "Release", + ["StartupHookSupport"] = "true", + }; + + Assert.Equal("true", EvaluateProperty("StartupHookSupport", properties)); + } + + [Theory] + [InlineData("Release")] + [InlineData("Debug")] + public void MetadataUpdaterSupport_IsNotSetByILLinkTargets(string configuration) + { + var properties = new Dictionary + { + ["PublishTrimmed"] = "true", + ["Configuration"] = configuration, + }; + + // MetadataUpdaterSupport should not be set by Microsoft.NET.ILLink.targets; + // it is handled by the SDK (Microsoft.NET.Sdk.targets) which only disables + // it for non-Debug builds. + Assert.Equal("", EvaluateProperty("MetadataUpdaterSupport", properties)); + } + } +} From 9e0ba3d8c9030b545a455dcd700065e4e11066e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 17:22:24 +0000 Subject: [PATCH 3/4] Fix test method name: RespectExplicitValue -> RespectsExplicitValue Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/64db1ca8-95d8-47be-90ab-be736ed09ab0 Co-authored-by: tmat <41759+tmat@users.noreply.github.com> --- src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs b/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs index 49334f2539fe58..459290169ed956 100644 --- a/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs +++ b/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs @@ -59,7 +59,7 @@ public void StartupHookSupport_IsNotSetWhenPublishTrimmedIsFalse() } [Fact] - public void StartupHookSupport_RespectExplicitValue() + public void StartupHookSupport_RespectsExplicitValue() { var properties = new Dictionary { From 437bc81a4648e9ff0e423de9caeb802546a2af09 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:28:42 +0000 Subject: [PATCH 4/4] Remove tests from ILLink.Tasks.Tests (this kind of testing belongs in SDK repo) Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/cd190b57-5e06-418f-8965-c8029d4efe8a Co-authored-by: tmat <41759+tmat@users.noreply.github.com> --- .../ILLink.Tasks.Tests.csproj | 1 - .../ILLink.Tasks.Tests/ILinkTargetsTests.cs | 91 ------------------- 2 files changed, 92 deletions(-) delete mode 100644 src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs diff --git a/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj b/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj index 7893830c767eff..5f3daab5629a06 100644 --- a/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj +++ b/src/tools/illink/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.csproj @@ -1,7 +1,6 @@ - diff --git a/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs b/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs deleted file mode 100644 index 459290169ed956..00000000000000 --- a/src/tools/illink/test/ILLink.Tasks.Tests/ILinkTargetsTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Xml; -using Microsoft.Build.Evaluation; -using Xunit; - -namespace ILLink.Tasks.Tests -{ - public class ILinkTargetsTests - { - private static string TargetsFilePath => - Path.Combine( - Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, - "build", - "Microsoft.NET.ILLink.targets"); - - private static string EvaluateProperty(string propertyName, Dictionary globalProperties) - { - string projectXml = $""" - - - - """; - - using var reader = XmlReader.Create(new StringReader(projectXml)); - using var collection = new ProjectCollection(); - var project = collection.LoadProject(reader, globalProperties, toolsVersion: null); - return project.GetPropertyValue(propertyName); - } - - [Theory] - [InlineData("Release", "false")] - [InlineData("Debug", "")] - public void StartupHookSupport_IsDisabledOnlyForNonDebug(string configuration, string expectedValue) - { - var properties = new Dictionary - { - ["PublishTrimmed"] = "true", - ["Configuration"] = configuration, - }; - - Assert.Equal(expectedValue, EvaluateProperty("StartupHookSupport", properties)); - } - - [Fact] - public void StartupHookSupport_IsNotSetWhenPublishTrimmedIsFalse() - { - var properties = new Dictionary - { - ["PublishTrimmed"] = "false", - ["Configuration"] = "Release", - }; - - Assert.Equal("", EvaluateProperty("StartupHookSupport", properties)); - } - - [Fact] - public void StartupHookSupport_RespectsExplicitValue() - { - var properties = new Dictionary - { - ["PublishTrimmed"] = "true", - ["Configuration"] = "Release", - ["StartupHookSupport"] = "true", - }; - - Assert.Equal("true", EvaluateProperty("StartupHookSupport", properties)); - } - - [Theory] - [InlineData("Release")] - [InlineData("Debug")] - public void MetadataUpdaterSupport_IsNotSetByILLinkTargets(string configuration) - { - var properties = new Dictionary - { - ["PublishTrimmed"] = "true", - ["Configuration"] = configuration, - }; - - // MetadataUpdaterSupport should not be set by Microsoft.NET.ILLink.targets; - // it is handled by the SDK (Microsoft.NET.Sdk.targets) which only disables - // it for non-Debug builds. - Assert.Equal("", EvaluateProperty("MetadataUpdaterSupport", properties)); - } - } -}