Skip to content

Commit c720215

Browse files
committed
Include C# in Razor issues
1 parent 51e9e82 commit c720215

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

l10n/bundle.l10n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"Non Razor file as active document": "Non Razor file as active document",
110110
"Could not determine CSharp content": "Could not determine CSharp content",
111111
"Could not determine Html content": "Could not determine Html content",
112-
"Cohosting is on, client has no access to CSharp content": "Cohosting is on, client has no access to CSharp content",
112+
"Could not determine CSharp content: {0}": "Could not determine CSharp content: {0}",
113113
"A valid dotnet installation could not be found: {0}": "A valid dotnet installation could not be found: {0}",
114114
"Is this a Bug or Feature request?": "Is this a Bug or Feature request?",
115115
"Bug": "Bug",

src/razor/src/diagnostics/reportIssueCommand.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { HtmlDocumentManager } from '../../../lsptoolshost/razor/htmlDocumentManager';
7+
import { RoslynLanguageServer } from '../../../lsptoolshost/server/roslynLanguageServer';
78
import { RazorDocumentManager } from '../document/razorDocumentManager';
89
import { RazorLogger } from '../razorLogger';
910
import { api } from '../vscodeAdapter';
@@ -21,10 +22,16 @@ export class ReportIssueCommand {
2122
private readonly vscodeApi: api,
2223
documentManager: RazorDocumentManager | undefined,
2324
cohostingDocumentManager: HtmlDocumentManager | undefined,
25+
roslynLanguageServer: RoslynLanguageServer | undefined,
2426
logger: RazorLogger
2527
) {
2628
this.dataCollectorFactory = new ReportIssueDataCollectorFactory(logger);
27-
this.issueCreator = new ReportIssueCreator(this.vscodeApi, documentManager, cohostingDocumentManager);
29+
this.issueCreator = new ReportIssueCreator(
30+
this.vscodeApi,
31+
documentManager,
32+
cohostingDocumentManager,
33+
roslynLanguageServer
34+
);
2835
this.issuePanel = new ReportIssuePanel(this.dataCollectorFactory, this.issueCreator, logger);
2936
}
3037

src/razor/src/diagnostics/reportIssueCreator.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ import { IRazorDocumentManager } from '../document/IRazorDocumentManager';
1212
import { razorExtensionId } from '../razorExtensionId';
1313
import { IReportIssueDataCollectionResult } from './IReportIssueDataCollectionResult';
1414
import { HtmlDocumentManager } from '../../../lsptoolshost/razor/htmlDocumentManager';
15+
import { ShowGeneratedDocumentCommand } from '../../../lsptoolshost/razor/showGeneratedDocumentCommand';
16+
import { GeneratedDocumentKind } from '../../../lsptoolshost/razor/generatedDocumentKind';
17+
import { RoslynLanguageServer } from '../../../lsptoolshost/server/roslynLanguageServer';
1518

1619
export class ReportIssueCreator {
1720
constructor(
1821
private readonly vscodeApi: vscodeAdapter.api,
1922
private readonly documentManager?: IRazorDocumentManager,
20-
private readonly cohostingDocumentManager?: HtmlDocumentManager
23+
private readonly cohostingDocumentManager?: HtmlDocumentManager,
24+
private readonly roslynLanguageServer?: RoslynLanguageServer
2125
) {}
2226

2327
public async create(collectionResult: IReportIssueDataCollectionResult) {
@@ -37,7 +41,15 @@ export class ReportIssueCreator {
3741
csharpContent = await this.getProjectedCSharp(razorDocument);
3842
htmlContent = await this.getProjectedHtml(razorDocument);
3943
} else if (this.cohostingDocumentManager) {
40-
csharpContent = vscode.l10n.t('Cohosting is on, client has no access to CSharp content');
44+
try {
45+
csharpContent = await ShowGeneratedDocumentCommand.getGeneratedDocumentContent(
46+
collectionResult.document.uri,
47+
GeneratedDocumentKind.CSharp,
48+
this.roslynLanguageServer!
49+
);
50+
} catch (e: any) {
51+
csharpContent = vscode.l10n.t('Could not determine CSharp content: {0}', e.toString());
52+
}
4153

4254
const htmlDocument = await this.cohostingDocumentManager.getDocument(collectionResult.document.uri);
4355
if (htmlDocument) {

src/razor/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export async function activate(
139139
const csharpFeature = new RazorCSharpFeature(documentManager, eventEmitterFactory, logger);
140140
const htmlFeature = new RazorHtmlFeature(documentManager, languageServiceClient, eventEmitterFactory, logger);
141141
const localRegistrations: vscode.Disposable[] = [];
142-
const reportIssueCommand = new ReportIssueCommand(vscodeType, documentManager, undefined, logger);
142+
const reportIssueCommand = new ReportIssueCommand(vscodeType, documentManager, undefined, undefined, logger);
143143
const razorCodeActionRunner = new RazorCodeActionRunner(languageServerClient, logger);
144144
const codeActionsHandler = new CodeActionsHandler(
145145
documentManager,

0 commit comments

Comments
 (0)