-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Don't load the razor redirector unless it could actually be a razor assembly #79154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.