Skip to content

Commit e0240cf

Browse files
committed
Respond to API obsoletion
1 parent 29093b7 commit e0240cf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ProjectExtensions.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
1515
using Microsoft.CodeAnalysis.Razor;
1616
using Microsoft.CodeAnalysis.Razor.Telemetry;
17+
using Microsoft.NET.Sdk.Razor.SourceGenerators;
1718

1819
namespace Microsoft.CodeAnalysis;
1920

@@ -114,7 +115,16 @@ public static bool TryGetHintNameFromGeneratedDocumentUri(this Project project,
114115
return false;
115116
}
116117

117-
hintName = RazorUri.GetHintNameFromGeneratedDocumentUri(project.Solution, generatedDocumentUri);
118+
var identity = RazorUri.GetIdentityOfGeneratedDocument(project.Solution, generatedDocumentUri);
119+
120+
if (identity.GeneratorTypeName != typeof(RazorSourceGenerator).FullName)
121+
{
122+
// This is not a Razor source generated document, so we don't know the hint name.
123+
hintName = null;
124+
return false;
125+
}
126+
127+
hintName = identity.HintName;
118128
return true;
119129
}
120130
}

0 commit comments

Comments
 (0)