Merge pull request #3311 from henryju/feature/feed_diagnostic_code

Feed VSCode diagnostic code to Roslyn diagnostic id
This commit is contained in:
Joey Robichaud 2019-10-29 13:21:55 -07:00 коммит произвёл GitHub
Родитель fa0ba87162 cf383f9acc
Коммит fe9a2f86bd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -335,6 +335,8 @@ class DiagnosticsProvider extends AbstractSupport {
let message = `${quickFix.Text} [${quickFix.Projects.map(n => this._asProjectLabel(n)).join(', ')}]`; let message = `${quickFix.Text} [${quickFix.Projects.map(n => this._asProjectLabel(n)).join(', ')}]`;
let diagnostic = new vscode.Diagnostic(toRange(quickFix), message, display.severity); let diagnostic = new vscode.Diagnostic(toRange(quickFix), message, display.severity);
diagnostic.source = 'csharp';
diagnostic.code = quickFix.Id;
if (display.isFadeout) { if (display.isFadeout) {
diagnostic.tags = [vscode.DiagnosticTag.Unnecessary]; diagnostic.tags = [vscode.DiagnosticTag.Unnecessary];

Просмотреть файл

@ -44,7 +44,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
test("Return unnecessary tag in case of unnesessary using", async function () { test("Return unnecessary tag in case of unnesessary using", async function () {
let result = await poll(() => vscode.languages.getDiagnostics(fileUri), 15*1000, 500); let result = await poll(() => vscode.languages.getDiagnostics(fileUri), 15*1000, 500);
let cs8019 = result.find(x => x.message.includes("CS8019")); let cs8019 = result.find(x => x.source == "csharp" && x.code == "CS8019");
expect(cs8019).to.not.be.undefined; expect(cs8019).to.not.be.undefined;
expect(cs8019.tags).to.include(vscode.DiagnosticTag.Unnecessary); expect(cs8019.tags).to.include(vscode.DiagnosticTag.Unnecessary);
}); });
@ -53,8 +53,8 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
this.skip(); // Remove this once https://github.com/OmniSharp/omnisharp-roslyn/issues/1458 is resolved. this.skip(); // Remove this once https://github.com/OmniSharp/omnisharp-roslyn/issues/1458 is resolved.
let result = await poll(() => vscode.languages.getDiagnostics(fileUri), 15*1000, 500); let result = await poll(() => vscode.languages.getDiagnostics(fileUri), 15*1000, 500);
let ide0005 = result.find(x => x.message.includes("IDE0005")); let ide0005 = result.find(x => x.source == "csharp" && x.code == "IDE0005");
expect(ide0005).to.not.be(undefined); expect(ide0005).to.not.be.undefined;
expect(ide0005.tags).to.include(vscode.DiagnosticTag.Unnecessary); expect(ide0005.tags).to.include(vscode.DiagnosticTag.Unnecessary);
}); });
}); });