Skip to content

Commit d50a024

Browse files
committed
project system errors
1 parent 90a24bd commit d50a024

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/lsptoolshost/buildDiagnosticsService.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,14 @@ export class BuildDiagnosticsService {
9494
const buildOnlyDiagnostics: vscode.Diagnostic[] = [];
9595
diagnosticList.forEach((d) => {
9696
if (d.code) {
97-
// If it is a "build-only"diagnostics (e.g. it can only be found by building)
98-
// the diagnostic will always be included
99-
if (buildOnlyIds.find((b_id) => b_id === d.code)) {
97+
// If it is a project system diagnostic (e.g. "Target framework out of support")
98+
// then always show it. It cannot be reported by live.
99+
if (this.isProjectSystemDiagnostic(d)) {
100+
buildOnlyDiagnostics.push(d);
101+
}
102+
// If it is a "build-only"diagnostics (i.e. it can only be found by building)
103+
// then always show it. It cannot be reported by live.
104+
else if (buildOnlyIds.find((b_id) => b_id === d.code)) {
100105
buildOnlyDiagnostics.push(d);
101106
} else {
102107
const isAnalyzerDiagnostic = BuildDiagnosticsService.isAnalyzerDiagnostic(d);
@@ -134,4 +139,8 @@ export class BuildDiagnosticsService {
134139
private static isAnalyzerDiagnostic(d: vscode.Diagnostic): boolean {
135140
return d.code ? !d.code.toString().startsWith('CS') : false;
136141
}
142+
143+
private static isProjectSystemDiagnostic(d: vscode.Diagnostic): boolean {
144+
return d.code ? d.code.toString().startsWith('NETSDK') : false;
145+
}
137146
}

test/integrationTests/buildDiagnostics.integration.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ describe(`Build and live diagnostics dedupe ${testAssetWorkspace.description}`,
119119
expect(displayedBuildResults.length).toEqual(2);
120120
expect(displayedBuildResults).toContain(diagnostics[0]);
121121
});
122+
123+
test('Project system diagnostics', async () => {
124+
await setBackgroundAnalysisSetting(
125+
/*analyzer*/ AnalysisSetting.OpenFiles,
126+
/*compiler*/ AnalysisSetting.OpenFiles
127+
);
128+
129+
const buildOnlyIds = ['CS1001'];
130+
const diagnostics = [getTestDiagnostic('NETSDK3001')];
131+
132+
const displayedBuildResults = BuildDiagnosticsService.filerDiagnosticsFromBuild(
133+
diagnostics,
134+
buildOnlyIds,
135+
true
136+
);
137+
138+
expect(displayedBuildResults.length).toEqual(1);
139+
});
122140
});
123141

124142
function getTestDiagnostic(code: string): vscode.Diagnostic {

0 commit comments

Comments
 (0)