From d8b4c1f6f86080048e8b34e2265ae3078170cfad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 1 Sep 2026 18:46:24 +0000 Subject: [PATCH 1/7] Add developer settings tests Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com> --- .../DeveloperSettingsTests.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs diff --git a/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs new file mode 100644 index 0000000000000..812e6ef3e6b4f --- /dev/null +++ b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using Microsoft.Win32; +using Roslyn.Test.Utilities; +using Xunit; + +namespace Microsoft.CodeAnalysis.UnitTests; + +public sealed class DeveloperSettingsTests +{ + [ConditionalFact(typeof(WindowsOnly))] + public void LongPathsAreEnabledOnWindows() + { + using var fileSystemKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\FileSystem"); + + Assert.Equal(1, fileSystemKey?.GetValue("LongPathsEnabled")); + } + + [Fact] + public void LineEndingsAreConfiguredForGitNormalization() + { + var gitAttributes = File.ReadAllLines(GetRepositoryFilePath(".gitattributes")); + + Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*", "text=auto", "encoding=UTF-8")); + Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*.sh", "text", "eol=lf")); + Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*.cs", "diff=csharp", "text")); + Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*.vb", "text")); + } + + private static bool HasGitAttributes(string line, string pattern, params string[] expectedAttributes) + { + var parts = line.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); + + return parts.Length == expectedAttributes.Length + 1 && + parts[0] == pattern && + expectedAttributes.All(attribute => parts.Contains(attribute, StringComparer.Ordinal)); + } + + private static string GetRepositoryFilePath(string fileName, [CallerFilePath] string sourceFilePath = "") + => Path.Combine(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(sourceFilePath)!, "..", "..", "..", "..")), fileName); +} From 718c8a47c0a4efff7b385976c0cf95eb6db9de50 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 1 Sep 2026 19:51:12 +0000 Subject: [PATCH 2/7] Check source file line endings Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com> --- .../DeveloperSettingsTests.cs | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs index 812e6ef3e6b4f..f0edd557943c8 100644 --- a/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs +++ b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs @@ -4,7 +4,6 @@ using System; using System.IO; -using System.Linq; using System.Runtime.CompilerServices; using Microsoft.Win32; using Roslyn.Test.Utilities; @@ -23,25 +22,35 @@ public void LongPathsAreEnabledOnWindows() } [Fact] - public void LineEndingsAreConfiguredForGitNormalization() + public void SourceFileLineEndingsMatchPlatform() { - var gitAttributes = File.ReadAllLines(GetRepositoryFilePath(".gitattributes")); - - Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*", "text=auto", "encoding=UTF-8")); - Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*.sh", "text", "eol=lf")); - Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*.cs", "diff=csharp", "text")); - Assert.Contains(gitAttributes, line => HasGitAttributes(line, "*.vb", "text")); + var sourceText = File.ReadAllText(GetThisSourceFilePath()); + + if (Path.DirectorySeparatorChar == '\\') + { + Assert.Contains("\r\n", sourceText); + Assert.False(ContainsBareLineFeed(sourceText)); + } + else + { + Assert.Contains("\n", sourceText); + Assert.DoesNotContain("\r\n", sourceText); + } } - private static bool HasGitAttributes(string line, string pattern, params string[] expectedAttributes) + private static bool ContainsBareLineFeed(string text) { - var parts = line.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); - - return parts.Length == expectedAttributes.Length + 1 && - parts[0] == pattern && - expectedAttributes.All(attribute => parts.Contains(attribute, StringComparer.Ordinal)); + for (var i = 0; i < text.Length; i++) + { + if (text[i] == '\n' && (i == 0 || text[i - 1] != '\r')) + { + return true; + } + } + + return false; } - private static string GetRepositoryFilePath(string fileName, [CallerFilePath] string sourceFilePath = "") - => Path.Combine(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(sourceFilePath)!, "..", "..", "..", "..")), fileName); + private static string GetThisSourceFilePath([CallerFilePath] string sourceFilePath = "") + => sourceFilePath; } From f610a6b45971bd31aab10d0f5faaa72ac6a8b762 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:51:44 +0000 Subject: [PATCH 3/7] Use PlatformInformation.IsWindows guard and int value in long paths test Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com> --- .../Core/CodeAnalysisTest/DeveloperSettingsTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs index f0edd557943c8..e1d3bc26aeac4 100644 --- a/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs +++ b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs @@ -3,10 +3,12 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using Microsoft.Win32; using Roslyn.Test.Utilities; +using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.UnitTests; @@ -16,9 +18,12 @@ public sealed class DeveloperSettingsTests [ConditionalFact(typeof(WindowsOnly))] public void LongPathsAreEnabledOnWindows() { + Debug.Assert(PlatformInformation.IsWindows); + using var fileSystemKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\FileSystem"); + var longPathsEnabled = fileSystemKey?.GetValue("LongPathsEnabled") as int? ?? 0; - Assert.Equal(1, fileSystemKey?.GetValue("LongPathsEnabled")); + Assert.Equal(1, longPathsEnabled); } [Fact] From 664a991563f47b234db0c399a21e6d7ede569ba9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:52:22 +0000 Subject: [PATCH 4/7] Changes before error encountered Agent-Logs-Url: https://github.com/dotnet/roslyn/sessions/33d2d0a5-12ce-4863-9c99-dedc7192bee6 Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com> --- .../DeveloperSettingsTests.cs | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs index e1d3bc26aeac4..da055b059f1b8 100644 --- a/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs +++ b/src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs @@ -4,8 +4,6 @@ using System; using System.Diagnostics; -using System.IO; -using System.Runtime.CompilerServices; using Microsoft.Win32; using Roslyn.Test.Utilities; using Roslyn.Utilities; @@ -29,33 +27,15 @@ public void LongPathsAreEnabledOnWindows() [Fact] public void SourceFileLineEndingsMatchPlatform() { - var sourceText = File.ReadAllText(GetThisSourceFilePath()); - - if (Path.DirectorySeparatorChar == '\\') - { - Assert.Contains("\r\n", sourceText); - Assert.False(ContainsBareLineFeed(sourceText)); - } - else - { - Assert.Contains("\n", sourceText); - Assert.DoesNotContain("\r\n", sourceText); - } - } + // The line break inside this literal is taken verbatim from this source file, so it + // reflects the line endings the file was checked out with. + const string twoLines = """ + first + second + """; - private static bool ContainsBareLineFeed(string text) - { - for (var i = 0; i < text.Length; i++) - { - if (text[i] == '\n' && (i == 0 || text[i - 1] != '\r')) - { - return true; - } - } - - return false; - } + var lineEnding = twoLines["first".Length..^"second".Length]; - private static string GetThisSourceFilePath([CallerFilePath] string sourceFilePath = "") - => sourceFilePath; + Assert.Equal(Environment.NewLine, lineEnding); + } } From 98bf8bf4b2596e9af6010d7675a330108350bc4e Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Tue, 8 Sep 2026 13:49:02 -0700 Subject: [PATCH 5/7] Replace xUnit tests with `dotnet restore` checks --- eng/targets/Imports.targets | 31 +++++++++++--- .../DeveloperSettingsTests.cs | 41 ------------------- 2 files changed, 26 insertions(+), 46 deletions(-) delete mode 100644 src/Compilers/Core/CodeAnalysisTest/DeveloperSettingsTests.cs diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets index f3dd6a232b286..ffb2b7ffb570c 100644 --- a/eng/targets/Imports.targets +++ b/eng/targets/Imports.targets @@ -185,13 +185,34 @@ Condition="$(_VersionComparisonResult) < 0"/> - + + + + <_RoslynDeveloperSettingsValidationCacheFile>$(MSBuildThisFileDirectory)..\..\artifacts\developer-settings-validated.txt + + + - <_RoslynLongPathsEnabled>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled', null, RegistryView.Registry64, RegistryView.Registry32)) + <_RoslynBuildRunsOnWindows>$([MSBuild]::IsOSPlatform('Windows')) + <_RoslynSourceHasCarriageReturns>$([System.IO.File]::ReadAllText('$(MSBuildThisFileFullPath)').Contains($([System.Char]::ConvertFromUtf32(13)))) + <_RoslynLongPathsEnabled Condition="'$(_RoslynBuildRunsOnWindows)' == 'True'">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled', null, RegistryView.Registry64, RegistryView.Registry32)) - - - + + + + + + + + + + + + + <_RoslynDeveloperSettingsValidationCacheFile>$(MSBuildThisFileDirectory)..\..\artifacts\developer-settings-validated.txt + + + + + <_RoslynBuildRunsOnWindows>$([MSBuild]::IsOSPlatform('Windows')) + <_RoslynSourceHasCarriageReturns>$([System.IO.File]::ReadAllText('$(MSBuildThisFileFullPath)').Contains($([System.Char]::ConvertFromUtf32(13)))) + <_RoslynLongPathsEnabled Condition="'$(_RoslynBuildRunsOnWindows)' == 'True'">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled', null, RegistryView.Registry64, RegistryView.Registry32)) + + + + + + + + + + diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets index ffb2b7ffb570c..f8c1447555cf3 100644 --- a/eng/targets/Imports.targets +++ b/eng/targets/Imports.targets @@ -185,34 +185,7 @@ Condition="$(_VersionComparisonResult) < 0"/> - - - - <_RoslynDeveloperSettingsValidationCacheFile>$(MSBuildThisFileDirectory)..\..\artifacts\developer-settings-validated.txt - - - - - <_RoslynBuildRunsOnWindows>$([MSBuild]::IsOSPlatform('Windows')) - <_RoslynSourceHasCarriageReturns>$([System.IO.File]::ReadAllText('$(MSBuildThisFileFullPath)').Contains($([System.Char]::ConvertFromUtf32(13)))) - <_RoslynLongPathsEnabled Condition="'$(_RoslynBuildRunsOnWindows)' == 'True'">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled', null, RegistryView.Registry64, RegistryView.Registry32)) - - - - - - - - - +