Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Razor;
[Export(typeof(IAnalyzerAssemblyRedirector)), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class RazorAnalyzerAssemblyRedirector([Import(AllowDefault = true)] RazorAnalyzerAssemblyRedirector.IRazorAnalyzerAssemblyRedirector? razorRedirector = null) : IAnalyzerAssemblyRedirector
internal sealed class RazorAnalyzerAssemblyRedirector([Import(AllowDefault = true)] Lazy<RazorAnalyzerAssemblyRedirector.IRazorAnalyzerAssemblyRedirector>? razorRedirector) : IAnalyzerAssemblyRedirector
{
public string? RedirectPath(string fullPath) => razorRedirector?.RedirectPath(fullPath);
public string? RedirectPath(string fullPath)
{
// Simple heuristic so we don't load razor unnecessarily.
if (fullPath.IndexOf("razor", StringComparison.OrdinalIgnoreCase) >= 0)
Copy link
Member

@phil-allen-msft phil-allen-msft Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you check for cshtml here as well?

If it's the path of a file in the loaded project, seems like 'yes'. If it's the path to a source generator, seems like 'no'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path to source generator and related assemblies.

{
return razorRedirector?.Value.RedirectPath(fullPath);
}
return null;
}

internal interface IRazorAnalyzerAssemblyRedirector
{
Expand Down
Loading