Skip to content

Commit 05e142e

Browse files
Revert "Some random clean up and improvements (#11095) (#11169)
Revert "Some random clean up and improvements (#11095) for dev17.13
2 parents 9b2adb4 + 594c89a commit 05e142e

File tree

36 files changed

+131
-273
lines changed

36 files changed

+131
-273
lines changed

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DesignTimeNodeWriterTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ Render Children
493493
ignoreLineEndingDifferences: true);
494494
}
495495

496-
[ConditionalTheory(Is.Windows)]
496+
[OSSkipConditionTheory(new[] { "Linux", "OSX" })]
497497
[InlineData(@"test.cshtml", @"test.cshtml")]
498498
[InlineData(@"pages/test.cshtml", @"pages\test.cshtml")]
499499
[InlineData(@"pages\test.cshtml", @"pages\test.cshtml")]
@@ -540,7 +540,7 @@ public void LinePragma_Is_Adjusted_On_Windows(string fileName, string expectedFi
540540
ignoreLineEndingDifferences: true);
541541
}
542542

543-
[ConditionalTheory(Is.Windows)]
543+
[OSSkipConditionTheory(new[] { "Linux", "OSX" })]
544544
[InlineData(@"test.cshtml", @"test.cshtml")]
545545
[InlineData(@"pages/test.cshtml", @"pages\test.cshtml")]
546546
[InlineData(@"pages\test.cshtml", @"pages\test.cshtml")]

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectFileSystemTest.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.IO;
88
using System.Linq;
9+
using System.Runtime.InteropServices;
910
using Xunit;
1011

1112
namespace Microsoft.AspNetCore.Razor.Language;
@@ -260,10 +261,15 @@ public void GetItem_ReturnsFileFromDisk()
260261
Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath);
261262
}
262263

263-
// "This test does not makes sense for case sensitive Operating Systems."
264-
[ConditionalFact(Is.Windows)]
264+
[Fact]
265265
public void GetItem_MismatchedCase_ReturnsFileFromDisk()
266266
{
267+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
268+
{
269+
// "This test does not makes sense for case sensitive Operating Systems."
270+
return;
271+
}
272+
267273
// Arrange
268274
var filePath = "/Views/About/About.cshtml";
269275
var lowerCaseTestFolder = TestFolder.ToLowerInvariant();

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Microsoft.AspNetCore.Razor.Language.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<Compile Include="..\..\shared\JsonReaderExtensions.cs" LinkBase="Shared" />
3131
<Compile Include="..\..\shared\RazorDiagnosticJsonConverter.cs" LinkBase="Shared" />
3232
<Compile Include="..\..\shared\TagHelperDescriptorJsonConverter.cs" LinkBase="Shared" />
33+
<Compile Include="..\..\..\Razor\test\OSSkipConditionFactAttribute.cs" LinkBase="Shared" />
3334
</ItemGroup>
3435

3536
<ItemGroup>

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/CSharp/FilePathComparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
using Microsoft.AspNetCore.Razor.Utilities;
5+
using System.Runtime.InteropServices;
66

77
namespace Microsoft.CodeAnalysis.Razor;
88

@@ -14,7 +14,7 @@ public static StringComparer Instance
1414
{
1515
get
1616
{
17-
return _instance ??= PlatformInformation.IsLinux
17+
return _instance ??= RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
1818
? StringComparer.Ordinal
1919
: StringComparer.OrdinalIgnoreCase;
2020
}

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/CSharp/FilePathComparison.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
using Microsoft.AspNetCore.Razor.Utilities;
5+
using System.Runtime.InteropServices;
66

77
namespace Microsoft.CodeAnalysis.Razor;
88

@@ -14,7 +14,7 @@ public static StringComparison Instance
1414
{
1515
get
1616
{
17-
return _instance ??= PlatformInformation.IsLinux
17+
return _instance ??= RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
1818
? StringComparison.Ordinal
1919
: StringComparison.OrdinalIgnoreCase;
2020
}

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/CodeWriterExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
using System.Diagnostics;
99
using System.Globalization;
1010
using System.Linq;
11+
using System.Runtime.InteropServices;
1112
using Microsoft.AspNetCore.Razor.Language.Intermediate;
12-
using Microsoft.AspNetCore.Razor.Utilities;
1313

1414
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration;
1515

@@ -661,7 +661,7 @@ public static IDisposable BuildEnhancedLinePragma(this CodeWriter writer, Source
661661

662662
private static SourceSpan RemapFilePathIfNecessary(SourceSpan sourceSpan, CodeRenderingContext context)
663663
{
664-
if (context.Options.RemapLinePragmaPathsOnWindows && PlatformInformation.IsWindows)
664+
if (context.Options.RemapLinePragmaPathsOnWindows && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
665665
{
666666
// ISSUE: https://github.com/dotnet/razor/issues/9108
667667
// The razor tooling normalizes paths to be forward slash based, regardless of OS.

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultLanguageServerFeatureOptions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT license. See License.txt in the project root for license information.
33

4-
using Microsoft.AspNetCore.Razor.Utilities;
4+
using System.Runtime.InteropServices;
55
using Microsoft.CodeAnalysis.Razor.Workspaces;
66

77
namespace Microsoft.AspNetCore.Razor.LanguageServer;
@@ -25,7 +25,8 @@ internal class DefaultLanguageServerFeatureOptions : LanguageServerFeatureOption
2525

2626
// Code action and rename paths in Windows VS Code need to be prefixed with '/':
2727
// https://github.com/dotnet/razor/issues/8131
28-
public override bool ReturnCodeActionAndRenamePathsWithPrefixedSlash => PlatformInformation.IsWindows;
28+
public override bool ReturnCodeActionAndRenamePathsWithPrefixedSlash
29+
=> RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
2930

3031
public override bool ShowAllCSharpCodeActions => false;
3132

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteRazorProjectFileSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.Runtime.InteropServices;
78
using Microsoft.AspNetCore.Razor.Language;
89
using Microsoft.AspNetCore.Razor.Utilities;
910
using Microsoft.CodeAnalysis.Razor;
@@ -81,7 +82,7 @@ protected override string NormalizeAndEnsureValidPath(string path)
8182

8283
static bool IsPathRootedForPlatform(string path)
8384
{
84-
if (PlatformInformation.IsWindows && path == "/")
85+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && path == "/")
8586
{
8687
// We have to special case windows and "/" because for some reason Path.IsPathRooted returns true on windows for a single "/" path.
8788
return false;

src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Utilities/FilePathNormalizer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Utilities;
1212

1313
internal static class FilePathNormalizer
1414
{
15-
private static readonly Func<char, char> s_charConverter = PlatformInformation.IsLinux
15+
private static readonly Func<char, char> s_charConverter = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
1616
? c => c
1717
: char.ToLowerInvariant;
1818

@@ -223,7 +223,7 @@ private static (int start, int length) NormalizeCore(ReadOnlySpan<char> source,
223223
// Replace slashes in our normalized span.
224224
NormalizeAndDedupeSlashes(destination, ref charsWritten);
225225

226-
if (PlatformInformation.IsWindows &&
226+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
227227
charsWritten > 1 &&
228228
destination is ['/', ..] and not ['/', '/', ..])
229229
{

src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Utilities/RazorProjectInfoFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Immutable;
66
using System.Diagnostics.CodeAnalysis;
77
using System.IO;
8+
using System.Runtime.InteropServices;
89
using System.Threading;
910
using System.Threading.Tasks;
1011
using Microsoft.AspNetCore.Razor.Language;
@@ -27,7 +28,7 @@ internal static class RazorProjectInfoFactory
2728

2829
static RazorProjectInfoFactory()
2930
{
30-
s_stringComparison = PlatformInformation.IsLinux
31+
s_stringComparison = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
3132
? StringComparison.Ordinal
3233
: StringComparison.OrdinalIgnoreCase;
3334
}

0 commit comments

Comments
 (0)