Skip to content

Conversation

davidwengier
Copy link
Member

Part of dotnet/vscode-csharp#8512
Tracked by dotnet/razor#9519 and dotnet/razor#11833

This removes the isRazor hackiness in misc files, and allows Razor to provide a source generator reference to the project. Needs work on Razor not just to implement the service, which is trivial, but because the source generator doesn't actually support misc files at the moment :)

@davidwengier davidwengier requested a review from a team as a code owner August 15, 2025 04:56
@davidwengier
Copy link
Member Author

davidwengier commented Aug 15, 2025

lol whoops. Have to rebase onto main-vs-deps to test locally, didn't mean to push. Apologies force push :D

@davidwengier davidwengier force-pushed the RazorGeneratorForMiscFiles branch from 52ae0f1 to 86c426e Compare August 15, 2025 06:06
@davidwengier davidwengier removed the request for review from a team August 15, 2025 06:07
@@ -11,7 +11,7 @@

namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;

[ExportWorkspaceService(typeof(IAnalyzerAssemblyLoaderProvider), [WorkspaceKind.Host]), Shared]
[ExportWorkspaceService(typeof(IAnalyzerAssemblyLoaderProvider), [WorkspaceKind.Host, WorkspaceKind.MiscellaneousFiles]), Shared]
Copy link
Member Author

Choose a reason for hiding this comment

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

Just bringing your attention to this change @dibarbet because it was added after your review. Hopefully it's okay because without it we're in a world of ALC pain and suffering :)

Copy link
Member

Choose a reason for hiding this comment

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

seems... fine? mostly just the default loader, except also knows about the extension context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, thats all it is. We need the source gen to come from the extension, because otherwise types are different in Razor when we try to actually get out generator bits, because of course all of the handlers come from the extension.

@@ -11,7 +11,7 @@

namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;

[ExportWorkspaceService(typeof(IAnalyzerAssemblyLoaderProvider), [WorkspaceKind.Host]), Shared]
[ExportWorkspaceService(typeof(IAnalyzerAssemblyLoaderProvider), [WorkspaceKind.Host, WorkspaceKind.MiscellaneousFiles]), Shared]
Copy link
Member

Choose a reason for hiding this comment

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

seems... fine? mostly just the default loader, except also knows about the extension context.

@davidwengier davidwengier merged commit b7353b8 into dotnet:main Aug 18, 2025
25 checks passed
@davidwengier davidwengier deleted the RazorGeneratorForMiscFiles branch August 18, 2025 21:59
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 18, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
davidwengier added a commit to dotnet/razor that referenced this pull request Aug 20, 2025
…#12106)

The Razor side of dotnet/vscode-csharp#8512
Needs dotnet/roslyn#79891 for the interface
definition, and to hook things up in the misc files project
Fixes #9519
Fixes #11833

This could be done as its own PR without the source generator locator
service, and it would all be the same, but also impossible to hit in
real life, so I just bundled it all together.

namespace Microsoft.CodeAnalysis.Features.Workspaces;

internal interface IMiscellaneousProjectInfoService : ILanguageService
Copy link
Member

Choose a reason for hiding this comment

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

Do you imagine this also being used in VS for Windows?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was hoping to, yes. Did I put something in the wrong place for that to happen?

@@ -178,8 +183,10 @@ void M()
[Theory, CombinatorialData]
public async Task TestLooseFile_RazorFile(bool mutatingLspWorkspace)
{
var composition = Composition.AddParts(typeof(TestRazorMiscellaneousProjectInfoService));
Copy link
Member

Choose a reason for hiding this comment

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

Should this just be applied to all tests in this file?

JoeRobich added a commit to dotnet/roslyn-tools that referenced this pull request Aug 29, 2025
46 PRs before and 36 after
```diff
+    * [Cache diagnostic analyzer computation](dotnet/roslyn#80045)
+    * [Remove parameter always passed the same value](dotnet/roslyn#80042)
     * [Update doc for IMethodSymbol.IsExtensionMethod](dotnet/roslyn#80016)
     * [Don't cache known-broken compositions](dotnet/roslyn#80021)
     * [Cleanup methods in DiagAnalyzerService](dotnet/roslyn#80013)
     * [Simplify processing of errors reported by the build](dotnet/roslyn#79964)
     * [Additional cleanup of the DiagnosticAnalyzerServier](dotnet/roslyn#80005)
     * [Fix Code Lens around source generated files](dotnet/roslyn#79992)
     * [Remove superflous DiagService api that can be achieved with existing apis](dotnet/roslyn#80007)
     * [Generate `init` accessor for required properties inside `readonly struct`s](dotnet/roslyn#80004)
     * [Remove existing low level diag oop code now that it's all handled at higher levels.](dotnet/roslyn#79994)
     * [Allow large InlineHint ArrayBuilder pooling](dotnet/roslyn#79857)
     * [Reduce allocations obtaining classified spans in ClassifierHelper](dotnet/roslyn#79856)
     * [Compute span diagnostics in oop](dotnet/roslyn#79991)
     * [Allow Razor cohosting to work with non-Razor SDK projects](dotnet/roslyn#79953)
     * [Move computation of deprioritized analyzers to oop](dotnet/roslyn#79989)
     * [EnC: Fix symbol mapping of delegates with indexed name](dotnet/roslyn#79837)
     * [Emit telemetry 'durations' with known radix point '.'](dotnet/roslyn#79988)
     * [Move logic up into DiagService](dotnet/roslyn#79985)
     * [Move the StateManager type up to the DiagnosticService from the DiagnosticIncrementalANalyzer](dotnet/roslyn#79984)
     * [Immediately remote diagnostics call to OOP](dotnet/roslyn#79983)
     * [Build Microsoft.CodeAnalysis.SemanticSearch.Extension ref assembly for use in semantic search queries](dotnet/roslyn#79972)
     * [Only cache compilation if we have the same set of analyzers](dotnet/roslyn#79978)
     * [Delete unused property](dotnet/roslyn#79963)
     * [Update 'use expr body' to be a purely syntactic analyzer](dotnet/roslyn#79979)
     * [Mark 'Use expr body' as a syntax-only fixer](dotnet/roslyn#79971)
     * [♻️ MSBuildWorkspaceDirectory - Fallback to AppContext.BaseDirectory when Assembly Location is empty](dotnet/roslyn#79934)
     * [Merge runtime async support into main](dotnet/roslyn#79833)
     * [Implement "Simplify property accessor" feature](dotnet/roslyn#79754)
-    * Merge main to runtime async branch (PR: [#79961](dotnet/roslyn#79961))
     * [Redo how and when we report source generator telemetry](dotnet/roslyn#79951)
     * [Allow MEF components to supply assembly path resolvers](dotnet/roslyn#79218)
     * [Allow Razor to hook up the source generator in misc files](dotnet/roslyn#79891)
     * [Block ENC for extension blocks](dotnet/roslyn#79883)
     * [Upgrade servicehub.client to fix test source discovery](dotnet/roslyn#79899)
     * [Update package restore error message.](dotnet/roslyn#79876)
-    * Merge main (PR: [#79834](dotnet/roslyn#79834))
-    * Merge main (PR: [#79830](dotnet/roslyn#79830))
     * [Baseline struct lifting tests](dotnet/roslyn#79505)
-    * Merge main to runtime async branch (PR: [#79582](dotnet/roslyn#79582))
-    * Merge main (PR: [#79424](dotnet/roslyn#79424))
-    * Merge main (PR: [#78994](dotnet/roslyn#78994))
-    * Merge main to runtime async branch (PR: [#78740](dotnet/roslyn#78740))
-    * Merge main to runtime async branch (PR: [#78517](dotnet/roslyn#78517))
-    * Merge main to runtime async branch (PR: [#78114](dotnet/roslyn#78114))
-    * Merge main to runtime async branch (PR: [#77700](dotnet/roslyn#77700))
-    * Merge main to runtime async branch (PR: [#77533](dotnet/roslyn#77533))
-    * Merge main to runtime async branch (PR: [#77265](dotnet/roslyn#77265))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants