Skip to content

Commit c8b7900

Browse files
authored
Allow the source generator to produce results for miscellaneous files (#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.
2 parents 0a52b46 + fc59236 commit c8b7900

File tree

51 files changed

+1053
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1053
-256
lines changed

eng/Version.Details.props

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ This file should be imported by eng/Versions.props
77
<Project>
88
<PropertyGroup>
99
<!-- dotnet/roslyn dependencies -->
10-
<MicrosoftCodeAnalysisAnalyzersPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisAnalyzersPackageVersion>
11-
<MicrosoftCodeAnalysisCommonPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCommonPackageVersion>
12-
<MicrosoftCodeAnalysisCSharpPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpPackageVersion>
13-
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
14-
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
15-
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
16-
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
17-
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
18-
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
19-
<MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>
20-
<MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>
21-
<MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>
22-
<MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>
23-
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
24-
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
25-
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
26-
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
27-
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
28-
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>5.0.0-2.25406.1</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
29-
<MicrosoftNetCompilersToolsetPackageVersion>5.0.0-2.25406.1</MicrosoftNetCompilersToolsetPackageVersion>
30-
<MicrosoftVisualStudioLanguageServicesPackageVersion>5.0.0-2.25406.1</MicrosoftVisualStudioLanguageServicesPackageVersion>
10+
<MicrosoftCodeAnalysisAnalyzersPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisAnalyzersPackageVersion>
11+
<MicrosoftCodeAnalysisCommonPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisCommonPackageVersion>
12+
<MicrosoftCodeAnalysisCSharpPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisCSharpPackageVersion>
13+
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
14+
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
15+
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
16+
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
17+
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
18+
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
19+
<MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>
20+
<MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>
21+
<MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>
22+
<MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>
23+
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
24+
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
25+
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
26+
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
27+
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>5.0.0-2.25418.8</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
28+
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>5.0.0-2.25418.8</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
29+
<MicrosoftNetCompilersToolsetPackageVersion>5.0.0-2.25418.8</MicrosoftNetCompilersToolsetPackageVersion>
30+
<MicrosoftVisualStudioLanguageServicesPackageVersion>5.0.0-2.25418.8</MicrosoftVisualStudioLanguageServicesPackageVersion>
3131
<!-- dotnet/arcade dependencies -->
3232
<MicrosoftDotNetArcadeSdkPackageVersion>9.0.0-beta.25255.5</MicrosoftDotNetArcadeSdkPackageVersion>
3333
<!-- dotnet/aspnetcore dependencies -->

eng/Version.Details.xml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,89 +2,89 @@
22
<Dependencies>
33
<Source Uri="https://github.com/dotnet/dotnet" Mapping="razor" Sha="7f2a07b481a3d24677ebcf6a45e7e27c8ff95a4e" BarId="279809" />
44
<ProductDependencies>
5-
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="5.0.0-2.25406.1">
5+
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="5.0.0-2.25418.8">
66
<Uri>https://github.com/dotnet/roslyn</Uri>
7-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
7+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
88
</Dependency>
9-
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="5.0.0-2.25406.1">
9+
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="5.0.0-2.25418.8">
1010
<Uri>https://github.com/dotnet/roslyn</Uri>
11-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
11+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
1212
</Dependency>
13-
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="5.0.0-2.25406.1">
13+
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="5.0.0-2.25418.8">
1414
<Uri>https://github.com/dotnet/roslyn</Uri>
15-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
15+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
1616
</Dependency>
17-
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="5.0.0-2.25406.1">
17+
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="5.0.0-2.25418.8">
1818
<Uri>https://github.com/dotnet/roslyn</Uri>
19-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
19+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
2020
</Dependency>
21-
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="5.0.0-2.25406.1">
21+
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="5.0.0-2.25418.8">
2222
<Uri>https://github.com/dotnet/roslyn</Uri>
23-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
23+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
2424
</Dependency>
25-
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="5.0.0-2.25406.1">
25+
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="5.0.0-2.25418.8">
2626
<Uri>https://github.com/dotnet/roslyn</Uri>
27-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
27+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
2828
</Dependency>
29-
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0-2.25406.1">
29+
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0-2.25418.8">
3030
<Uri>https://github.com/dotnet/roslyn</Uri>
31-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
31+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
3232
</Dependency>
33-
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="5.0.0-2.25406.1">
33+
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="5.0.0-2.25418.8">
3434
<Uri>https://github.com/dotnet/roslyn</Uri>
35-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
35+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
3636
</Dependency>
37-
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="5.0.0-2.25406.1">
37+
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="5.0.0-2.25418.8">
3838
<Uri>https://github.com/dotnet/roslyn</Uri>
39-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
39+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
4040
</Dependency>
41-
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="5.0.0-2.25406.1">
41+
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="5.0.0-2.25418.8">
4242
<Uri>https://github.com/dotnet/roslyn</Uri>
43-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
43+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
4444
</Dependency>
45-
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="5.0.0-2.25406.1">
45+
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="5.0.0-2.25418.8">
4646
<Uri>https://github.com/dotnet/roslyn</Uri>
47-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
47+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
4848
</Dependency>
49-
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="5.0.0-2.25406.1">
49+
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="5.0.0-2.25418.8">
5050
<Uri>https://github.com/dotnet/roslyn</Uri>
51-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
51+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
5252
</Dependency>
53-
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.0.0-2.25406.1">
53+
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.0.0-2.25418.8">
5454
<Uri>https://github.com/dotnet/roslyn</Uri>
55-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
55+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
5656
</Dependency>
57-
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0-2.25406.1">
57+
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0-2.25418.8">
5858
<Uri>https://github.com/dotnet/roslyn</Uri>
59-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
59+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
6060
</Dependency>
61-
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="5.0.0-2.25406.1">
61+
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="5.0.0-2.25418.8">
6262
<Uri>https://github.com/dotnet/roslyn</Uri>
63-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
63+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
6464
</Dependency>
65-
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="5.0.0-2.25406.1">
65+
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="5.0.0-2.25418.8">
6666
<Uri>https://github.com/dotnet/roslyn</Uri>
67-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
67+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
6868
</Dependency>
69-
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features" Version="5.0.0-2.25406.1">
69+
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features" Version="5.0.0-2.25418.8">
7070
<Uri>https://github.com/dotnet/roslyn</Uri>
71-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
71+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
7272
</Dependency>
73-
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.EditorFeatures" Version="5.0.0-2.25406.1">
73+
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.EditorFeatures" Version="5.0.0-2.25418.8">
7474
<Uri>https://github.com/dotnet/roslyn</Uri>
75-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
75+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
7676
</Dependency>
77-
<Dependency Name="Microsoft.CodeAnalysis.LanguageServer.Protocol" Version="5.0.0-2.25406.1">
77+
<Dependency Name="Microsoft.CodeAnalysis.LanguageServer.Protocol" Version="5.0.0-2.25418.8">
7878
<Uri>https://github.com/dotnet/roslyn</Uri>
79-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
79+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
8080
</Dependency>
81-
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.FSharp" Version="5.0.0-2.25406.1">
81+
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.FSharp" Version="5.0.0-2.25418.8">
8282
<Uri>https://github.com/dotnet/roslyn</Uri>
83-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
83+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
8484
</Dependency>
85-
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="5.0.0-2.25406.1">
85+
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="5.0.0-2.25418.8">
8686
<Uri>https://github.com/dotnet/roslyn</Uri>
87-
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
87+
<Sha>8405da69a543a680aab32ede20062e22602d3aef</Sha>
8888
</Dependency>
8989
</ProductDependencies>
9090
<ToolsetDependencies>

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/DefaultRazorTagHelperRewritePhase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Collections.Immutable;
45
using System.Threading;
56
using Microsoft.AspNetCore.Razor.Language.Legacy;
67

@@ -14,7 +15,9 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, Cancellation
1415
!codeDocument.TryGetTagHelperContext(out var context) ||
1516
context.TagHelpers is [])
1617
{
17-
// No descriptors, no-op.
18+
// No descriptors, so no need to see if any are used. Without setting this though,
19+
// we trigger an Assert in the ProcessRemaining method in the source generator.
20+
codeDocument.SetReferencedTagHelpers(ImmutableHashSet<TagHelperDescriptor>.Empty);
1821
return;
1922
}
2023

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/SourceGenerators/RazorSourceGenerator.RazorProviders.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,28 @@ private static (SourceGeneratorProjectItem?, Diagnostic?) ComputeProjectItems((A
7777
var (additionalText, globalOptions) = pair;
7878
var options = globalOptions.GetOptions(additionalText);
7979

80-
if (!options.TryGetValue("build_metadata.AdditionalFiles.TargetPath", out var encodedRelativePath) ||
81-
string.IsNullOrWhiteSpace(encodedRelativePath))
80+
string relativePath;
81+
if (options.TryGetValue("build_metadata.AdditionalFiles.TargetPath", out var encodedRelativePath))
8282
{
83-
var diagnostic = Diagnostic.Create(
84-
RazorDiagnostics.TargetPathNotProvided,
85-
Location.None,
86-
additionalText.Path);
87-
return (null, diagnostic);
83+
// TargetPath is optional, but must have a value if provided.
84+
if (string.IsNullOrWhiteSpace(encodedRelativePath))
85+
{
86+
var diagnostic = Diagnostic.Create(
87+
RazorDiagnostics.TargetPathNotProvided,
88+
Location.None,
89+
additionalText.Path);
90+
return (null, diagnostic);
91+
}
92+
93+
relativePath = Encoding.UTF8.GetString(Convert.FromBase64String(encodedRelativePath));
94+
}
95+
else
96+
{
97+
// If the TargetPath is not provided, we effectively assume its in the root of the project.
98+
relativePath = Path.GetFileName(additionalText.Path);
8899
}
89100

90101
options.TryGetValue("build_metadata.AdditionalFiles.CssScope", out var cssScope);
91-
var relativePath = Encoding.UTF8.GetString(Convert.FromBase64String(encodedRelativePath));
92102

93103
var projectItem = new SourceGeneratorProjectItem(
94104
basePath: "/",

src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/IncompatibleProjectService.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,10 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
1616
[method: ImportingConstructor]
1717
internal sealed class IncompatibleProjectService(IIncompatibleProjectNotifier incompatibleProjectNotifier) : IIncompatibleProjectService
1818
{
19-
private static readonly ProjectId s_miscFilesProject = ProjectId.CreateNewId();
20-
2119
private readonly IIncompatibleProjectNotifier _incompatibleProjectNotifier = incompatibleProjectNotifier;
2220

2321
private ImmutableHashSet<ProjectId> _incompatibleProjectIds = [];
2422

25-
public void HandleMiscFilesDocument(TextDocument textDocument)
26-
{
27-
if (ImmutableInterlocked.Update(ref _incompatibleProjectIds, static set => set.Add(s_miscFilesProject)))
28-
{
29-
_incompatibleProjectNotifier.NotifyMiscFilesDocument(textDocument);
30-
}
31-
}
32-
3323
public void HandleMissingDocument(RazorTextDocumentIdentifier? textDocumentIdentifier, RazorCohostRequestContext context)
3424
{
3525
if (context.Solution is null)

src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/Microsoft.CodeAnalysis.Razor.CohostingShared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<Compile Include="$(MSBuildThisFileDirectory)OnAutoInsert\CohostOnAutoInsertTriggerCharacterProviders.cs" />
3939
<Compile Include="$(MSBuildThisFileDirectory)RazorAnalyzerAssemblyRedirector.cs" />
4040
<Compile Include="$(MSBuildThisFileDirectory)RazorSourceGeneratedDocumentSpanMappingService.cs" />
41+
<Compile Include="$(MSBuildThisFileDirectory)RazorSourceGeneratorLocator.cs" />
4142
<Compile Include="$(MSBuildThisFileDirectory)Rename\CohostRenameEndpoint.cs" />
4243
<Compile Include="$(MSBuildThisFileDirectory)SignatureHelp\CohostSignatureHelpEndpoint.cs" />
4344
<Compile Include="$(MSBuildThisFileDirectory)FoldingRange\CohostFoldingRangeEndpoint.cs" />
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.ComponentModel.Composition;
5+
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;
6+
using Microsoft.NET.Sdk.Razor.SourceGenerators;
7+
8+
namespace Microsoft.CodeAnalysis.Razor.CohostingShared;
9+
10+
[Export(typeof(IRazorSourceGeneratorLocator))]
11+
[method: ImportingConstructor]
12+
internal sealed class RazorSourceGeneratorLocator() : IRazorSourceGeneratorLocator
13+
{
14+
public string GetGeneratorFilePath()
15+
{
16+
return typeof(RazorSourceGenerator).Assembly.Location;
17+
}
18+
}

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Cohost/AbstractCohostDocumentEndpoint.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ internal abstract class AbstractCohostDocumentEndpoint<TRequest, TResponse>(
2222
return SpecializedTasks.Default<TResponse>();
2323
}
2424

25-
if (context.TextDocument.Project.FilePath is null)
26-
{
27-
// If the project file path is null, we can't compute the hint name, so we can't handle the request.
28-
// This is likely a file in the misc files project, which we don't support yet anyway.
29-
// TODO: Expose context.TextDocument.Project.Solution.WorkspaceKind through our EA to confirm?
30-
_incompatibleProjectService.HandleMiscFilesDocument(context.TextDocument);
31-
return SpecializedTasks.Default<TResponse>();
32-
}
33-
3425
return HandleRequestAsync(request, context, context.TextDocument, cancellationToken);
3526
}
3627

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Cohost/IIncompatibleProjectNotifier.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ namespace Microsoft.CodeAnalysis.Razor.Cohost;
55

66
internal interface IIncompatibleProjectNotifier
77
{
8-
void NotifyMiscFilesDocument(TextDocument textDocument);
98
void NotifyMissingDocument(Project project, string filePath);
109
}

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Cohost/IIncompatibleProjectService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ namespace Microsoft.CodeAnalysis.Razor.Cohost;
77

88
internal interface IIncompatibleProjectService
99
{
10-
void HandleMiscFilesDocument(TextDocument textDocument);
1110
void HandleMissingDocument(RazorTextDocumentIdentifier? textDocumentIdentifier, RazorCohostRequestContext context);
1211
}

0 commit comments

Comments
 (0)