-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unskip cohosting diagnostics tests (#11541)
Step one of The Great Unskippening!™ Part of #10693 It is no longer simply possible to use string manipulation to get a generated C# document path from a Razor document path. The alternative options for what is available differ depending on which process code is running in. Yay! :)
- Loading branch information
Showing
11 changed files
with
101 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...or/src/Microsoft.VisualStudio.LanguageServices.Razor/Extensions/TextDocumentExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.NET.Sdk.Razor.SourceGenerators; | ||
|
||
namespace Microsoft.VisualStudio.Razor.Extensions; | ||
|
||
internal static class TextDocumentExtensions | ||
{ | ||
/// <summary> | ||
/// This method tries to compute the source generated hint name for a Razor document using only string manipulation | ||
/// </summary> | ||
/// <remarks> | ||
/// This should only be used in the devenv process. In OOP we can look at the actual generated run result to find this | ||
/// information. | ||
/// </remarks> | ||
public static bool TryComputeHintNameFromRazorDocument(this TextDocument razorDocument, [NotNullWhen(true)] out string? hintName) | ||
{ | ||
if (razorDocument.FilePath is null) | ||
{ | ||
hintName = null; | ||
return false; | ||
} | ||
|
||
var projectBasePath = Path.GetDirectoryName(razorDocument.Project.FilePath); | ||
var relativeDocumentPath = razorDocument.FilePath[projectBasePath.Length..].TrimStart('/', '\\'); | ||
hintName = RazorSourceGenerator.GetIdentifierFromPath(relativeDocumentPath); | ||
|
||
return hintName is not null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters