From 74460c41f6522454742a50ee48ddcc339a55f491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Mon, 1 Oct 2018 21:45:41 +0200 Subject: [PATCH 1/7] Add option to configure huge project limits --- package.json | 5 +++++ src/features/diagnosticsProvider.ts | 22 +++++++++++++--------- src/omnisharp/extension.ts | 2 +- src/omnisharp/options.ts | 12 ++++++++---- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index e707ab242..5dc96e18f 100644 --- a/package.json +++ b/package.json @@ -566,6 +566,11 @@ "default": true, "description": "Specifies whether the run and debug test CodeLens should be show be shown." }, + "csharp.maxProjectFileCountForDiagnosticAnalysis": { + "type": "number", + "default": 1000, + "description": "Specifies the maximum number of files for which diagnostics are reported for the whole workspace. If this limit is exceeded, diagnostics will be shown for currently opened files only. Specify 0 or less to disable the limit completely." + }, "omnisharp.path": { "type": [ "string", diff --git a/src/features/diagnosticsProvider.ts b/src/features/diagnosticsProvider.ts index feacb7236..51c4a8cba 100644 --- a/src/features/diagnosticsProvider.ts +++ b/src/features/diagnosticsProvider.ts @@ -13,6 +13,7 @@ import CompositeDisposable from '../CompositeDisposable'; import { IDisposable } from '../Disposable'; import { isVirtualCSharpDocument } from './virtualDocumentTracker'; import { TextDocument } from '../vscodeAdapter'; +import OptionProvider from '../observers/OptionProvider'; export class Advisor { @@ -21,7 +22,7 @@ export class Advisor { private _packageRestoreCounter: number = 0; private _projectSourceFileCounts: { [path: string]: number } = Object.create(null); - constructor(server: OmniSharpServer) { + constructor(server: OmniSharpServer, private optionProvider: OptionProvider) { this._server = server; let d1 = server.onProjectChange(this._onProjectChange, this); @@ -100,16 +101,19 @@ export class Advisor { } private _isHugeProject(): boolean { - let sourceFileCount = 0; - for (let key in this._projectSourceFileCounts) { - sourceFileCount += this._projectSourceFileCounts[key]; - if (sourceFileCount > 1000) { - return true; + let opts = this.optionProvider.GetLatestOptions(); + let fileLimit = opts.maxProjectFileCountForDiagnosticAnalysis; + if (fileLimit > 0) { + let sourceFileCount = 0; + for (let key in this._projectSourceFileCounts) { + sourceFileCount += this._projectSourceFileCounts[key]; + if (sourceFileCount > fileLimit) { + return true; + } } } - - return false; - } + return false; + } } export default function reportDiagnostics(server: OmniSharpServer, advisor: Advisor): IDisposable { diff --git a/src/omnisharp/extension.ts b/src/omnisharp/extension.ts index d5b39006a..74bb8df6c 100644 --- a/src/omnisharp/extension.ts +++ b/src/omnisharp/extension.ts @@ -50,7 +50,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an let omnisharpMonoResolver = new OmniSharpMonoResolver(getMonoVersion); const server = new OmniSharpServer(vscode, provider, packageJSON, platformInfo, eventStream, optionProvider, extensionPath, omnisharpMonoResolver); omnisharp = server; - const advisor = new Advisor(server); // create before server is started + const advisor = new Advisor(server, optionProvider); // create before server is started const disposables = new CompositeDisposable(); let localDisposables: CompositeDisposable; diff --git a/src/omnisharp/options.ts b/src/omnisharp/options.ts index a42ef0254..d5f5430a4 100644 --- a/src/omnisharp/options.ts +++ b/src/omnisharp/options.ts @@ -26,7 +26,8 @@ export class Options { public razorDevMode: boolean, public razorPluginPath?: string, public defaultLaunchSolution?: string, - public monoPath?: string) { } + public monoPath?: string, + public maxProjectFileCountForDiagnosticAnalysis?: number | null) { } public static Read(vscode: vscode): Options { @@ -76,9 +77,11 @@ export class Options { const razorDevMode = !!razorConfig && razorConfig.get('devmode', false); const razorPluginPath = razorConfig ? razorConfig.get('plugin.path', undefined) : undefined; + const maxProjectFileCountForDiagnosticAnalysis = csharpConfig.get('maxProjectFileCountForDiagnosticAnalysis', 1000); + return new Options( - path, - useGlobalMono, + path, + useGlobalMono, waitForDebugger, loggingLevel, autoStart, @@ -97,6 +100,7 @@ export class Options { razorPluginPath, defaultLaunchSolution, monoPath, + maxProjectFileCountForDiagnosticAnalysis, ); } @@ -130,7 +134,7 @@ export class Options { return toUseGlobalMonoValue(omnisharpConfig.get('useMono')); } else if (csharpConfig.has('omnisharpUsesMono')) { - // BACKCOMPAT: If 'csharp.omnisharpUsesMono' setting was found, true maps to "always" and false maps to "auto" + // BACKCOMPAT: If 'csharp.omnisharpUsesMono' setting was found, true maps to "always" and false maps to "auto" return toUseGlobalMonoValue(csharpConfig.get('omnisharpUsesMono')); } else { From 8582556cfcc7856dbbc20ccd9ae4112a8c29c985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Thu, 25 Oct 2018 00:03:10 +0200 Subject: [PATCH 2/7] Integration-test Advisor project analysis file limit --- src/features/diagnosticsProvider.ts | 8 +- src/omnisharp/extension.ts | 3 +- .../diagnostics.integration.test.ts | 74 +++++++++++++++++++ .../slnWithCsproj/.vscode/settings.json | 1 + 4 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 test/integrationTests/diagnostics.integration.test.ts diff --git a/src/features/diagnosticsProvider.ts b/src/features/diagnosticsProvider.ts index 51c4a8cba..ccb7a8f10 100644 --- a/src/features/diagnosticsProvider.ts +++ b/src/features/diagnosticsProvider.ts @@ -45,7 +45,7 @@ export class Advisor { public shouldValidateProject(): boolean { return this._isServerStarted() && !this._isRestoringPackages() - && !this._isHugeProject(); + && !this._isOverFileLimit(); } private _updateProjectFileCount(path: string, fileCount: number): void { @@ -100,7 +100,7 @@ export class Advisor { return this._server.isRunning(); } - private _isHugeProject(): boolean { + private _isOverFileLimit(): boolean { let opts = this.optionProvider.GetLatestOptions(); let fileLimit = opts.maxProjectFileCountForDiagnosticAnalysis; if (fileLimit > 0) { @@ -112,8 +112,8 @@ export class Advisor { } } } - return false; - } + return false; + } } export default function reportDiagnostics(server: OmniSharpServer, advisor: Advisor): IDisposable { diff --git a/src/omnisharp/extension.ts b/src/omnisharp/extension.ts index 74bb8df6c..de2443995 100644 --- a/src/omnisharp/extension.ts +++ b/src/omnisharp/extension.ts @@ -40,6 +40,7 @@ import { OmniSharpMonoResolver } from './OmniSharpMonoResolver'; import { getMonoVersion } from '../utils/getMonoVersion'; export let omnisharp: OmniSharpServer; +export let advisor: Advisor; export async function activate(context: vscode.ExtensionContext, packageJSON: any, platformInfo: PlatformInformation, provider: NetworkSettingsProvider, eventStream: EventStream, optionProvider: OptionProvider, extensionPath: string) { const documentSelector: vscode.DocumentSelector = { @@ -50,7 +51,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an let omnisharpMonoResolver = new OmniSharpMonoResolver(getMonoVersion); const server = new OmniSharpServer(vscode, provider, packageJSON, platformInfo, eventStream, optionProvider, extensionPath, omnisharpMonoResolver); omnisharp = server; - const advisor = new Advisor(server, optionProvider); // create before server is started + advisor = new Advisor(server, optionProvider); // create before server is started const disposables = new CompositeDisposable(); let localDisposables: CompositeDisposable; diff --git a/test/integrationTests/diagnostics.integration.test.ts b/test/integrationTests/diagnostics.integration.test.ts new file mode 100644 index 000000000..d10715d92 --- /dev/null +++ b/test/integrationTests/diagnostics.integration.test.ts @@ -0,0 +1,74 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as vscode from 'vscode'; + +import { expect } from 'chai'; +import * as path from 'path'; +import { activateCSharpExtension } from './integrationHelpers'; +import testAssetWorkspace from './testAssets/testAssetWorkspace'; + +import { advisor } from "../../src/omnisharp/extension"; + +const chai = require('chai'); +chai.use(require('chai-arrays')); +chai.use(require('chai-fs')); + +function setLimit(to: number | null) { + let csharpConfig = vscode.workspace.getConfiguration('csharp'); + return csharpConfig.update('maxProjectFileCountForDiagnosticAnalysis', to); +} + +suite(`Diagnostics Provider ${testAssetWorkspace.description}`, function () { + suiteSetup(async function () { + await testAssetWorkspace.restore(); + await activateCSharpExtension(); + + let fileName = 'completion.cs'; + let dir = testAssetWorkspace.projects[0].projectDirectoryPath; + let fileUri = vscode.Uri.file(path.join(dir, fileName)); + await vscode.commands.executeCommand('vscode.open', fileUri); + }); + + suiteTeardown(async () => { + await testAssetWorkspace.cleanupWorkspace(); + }); + + test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { + await setLimit(1000); + + expect(advisor.shouldValidateProject()).to.be.true; + }); + + test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { + await setLimit(1000); + + expect(advisor.shouldValidateFiles()).to.be.true; + }); + + test('Does not report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { + await setLimit(1); + + expect(advisor.shouldValidateProject()).to.be.false; + }); + + test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { + await setLimit(1); + + expect(advisor.shouldValidateFiles()).to.be.true; + }); + + test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is null', async () => { + await setLimit(null); + + expect(advisor.shouldValidateProject()).to.be.true; + }); + + test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is null', async () => { + await setLimit(null); + + expect(advisor.shouldValidateFiles()).to.be.true; + }); +}); \ No newline at end of file diff --git a/test/integrationTests/testAssets/slnWithCsproj/.vscode/settings.json b/test/integrationTests/testAssets/slnWithCsproj/.vscode/settings.json index 887970772..c80abf42f 100644 --- a/test/integrationTests/testAssets/slnWithCsproj/.vscode/settings.json +++ b/test/integrationTests/testAssets/slnWithCsproj/.vscode/settings.json @@ -1,4 +1,5 @@ { "omnisharp.defaultLaunchSolution": "b_SecondInOrder_SlnFile.sln", "omnisharp.path": "latest", + "csharp.maxProjectFileCountForDiagnosticAnalysis": 1000, } \ No newline at end of file From ec9d19426627500fa3b1dd22caee3ca847b07992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Thu, 25 Oct 2018 00:56:53 +0200 Subject: [PATCH 3/7] Change how the `advisor` object is imported in tests --- src/omnisharp/options.ts | 2 +- .../diagnostics.integration.test.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/omnisharp/options.ts b/src/omnisharp/options.ts index d5f5430a4..a7d6e0cf5 100644 --- a/src/omnisharp/options.ts +++ b/src/omnisharp/options.ts @@ -77,7 +77,7 @@ export class Options { const razorDevMode = !!razorConfig && razorConfig.get('devmode', false); const razorPluginPath = razorConfig ? razorConfig.get('plugin.path', undefined) : undefined; - const maxProjectFileCountForDiagnosticAnalysis = csharpConfig.get('maxProjectFileCountForDiagnosticAnalysis', 1000); + const maxProjectFileCountForDiagnosticAnalysis = csharpConfig.get('maxProjectFileCountForDiagnosticAnalysis', 1000); return new Options( path, diff --git a/test/integrationTests/diagnostics.integration.test.ts b/test/integrationTests/diagnostics.integration.test.ts index d10715d92..f5534b805 100644 --- a/test/integrationTests/diagnostics.integration.test.ts +++ b/test/integrationTests/diagnostics.integration.test.ts @@ -10,7 +10,7 @@ import * as path from 'path'; import { activateCSharpExtension } from './integrationHelpers'; import testAssetWorkspace from './testAssets/testAssetWorkspace'; -import { advisor } from "../../src/omnisharp/extension"; +import * as OmniSharp from "../../src/omnisharp/extension"; const chai = require('chai'); chai.use(require('chai-arrays')); @@ -39,36 +39,36 @@ suite(`Diagnostics Provider ${testAssetWorkspace.description}`, function () { test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); - expect(advisor.shouldValidateProject()).to.be.true; + expect(OmniSharp.advisor.shouldValidateProject()).to.be.true; }); test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); - expect(advisor.shouldValidateFiles()).to.be.true; + expect(OmniSharp.advisor.shouldValidateFiles()).to.be.true; }); test('Does not report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); - expect(advisor.shouldValidateProject()).to.be.false; + expect(OmniSharp.advisor.shouldValidateProject()).to.be.false; }); test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); - expect(advisor.shouldValidateFiles()).to.be.true; + expect(OmniSharp.advisor.shouldValidateFiles()).to.be.true; }); test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); - expect(advisor.shouldValidateProject()).to.be.true; + expect(OmniSharp.advisor.shouldValidateProject()).to.be.true; }); test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); - expect(advisor.shouldValidateFiles()).to.be.true; + expect(OmniSharp.advisor.shouldValidateFiles()).to.be.true; }); }); \ No newline at end of file From 461542c60010ff76cbe304b6b763388692e202e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Thu, 25 Oct 2018 19:19:23 +0200 Subject: [PATCH 4/7] Change the Advisor global var to Advisor returned from CSharpExtensionExports --- src/CSharpExtensionExports.ts | 4 ++++ src/main.ts | 14 +++++++---- src/omnisharp/extension.ts | 13 ++++++----- .../diagnostics.integration.test.ts | 23 ++++++++++++------- test/integrationTests/integrationHelpers.ts | 11 +++++++-- 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/CSharpExtensionExports.ts b/src/CSharpExtensionExports.ts index f5eefaf41..51f992acb 100644 --- a/src/CSharpExtensionExports.ts +++ b/src/CSharpExtensionExports.ts @@ -3,6 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { Advisor } from "./features/diagnosticsProvider"; + export default interface CSharpExtensionExports { initializationFinished: () => Promise; + + getAdvisor: () => Promise; } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 6b5e7ba52..08fb6f193 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,7 +30,7 @@ import { ProjectStatusBarObserver } from './observers/ProjectStatusBarObserver'; import CSharpExtensionExports from './CSharpExtensionExports'; import { vscodeNetworkSettingsProvider, NetworkSettingsProvider } from './NetworkSettings'; import { ErrorMessageObserver } from './observers/ErrorMessageObserver'; -import OptionProvider from './observers/OptionProvider'; +import OptionProvider from './observers/OptionProvider'; import DotNetTestChannelObserver from './observers/DotnetTestChannelObserver'; import DotNetTestLoggerObserver from './observers/DotnetTestLoggerObserver'; import { ShowOmniSharpConfigChangePrompt } from './observers/OptionChangeObserver'; @@ -65,7 +65,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { - let omniSharp = await omniSharpPromise; - await omniSharp.waitForEmptyEventQueue(); + let langService = await langServicePromise; + await langService.server.waitForEmptyEventQueue(); await coreClrDebugPromise; + }, + getAdvisor: async () => { + let langService = await langServicePromise; + return langService.advisor; } }; } diff --git a/src/omnisharp/extension.ts b/src/omnisharp/extension.ts index de2443995..3e4559c97 100644 --- a/src/omnisharp/extension.ts +++ b/src/omnisharp/extension.ts @@ -39,8 +39,10 @@ import { StructureProvider } from '../features/structureProvider'; import { OmniSharpMonoResolver } from './OmniSharpMonoResolver'; import { getMonoVersion } from '../utils/getMonoVersion'; -export let omnisharp: OmniSharpServer; -export let advisor: Advisor; +export interface ActivationResult { + readonly server: OmniSharpServer; + readonly advisor: Advisor; +} export async function activate(context: vscode.ExtensionContext, packageJSON: any, platformInfo: PlatformInformation, provider: NetworkSettingsProvider, eventStream: EventStream, optionProvider: OptionProvider, extensionPath: string) { const documentSelector: vscode.DocumentSelector = { @@ -50,8 +52,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an const options = optionProvider.GetLatestOptions(); let omnisharpMonoResolver = new OmniSharpMonoResolver(getMonoVersion); const server = new OmniSharpServer(vscode, provider, packageJSON, platformInfo, eventStream, optionProvider, extensionPath, omnisharpMonoResolver); - omnisharp = server; - advisor = new Advisor(server, optionProvider); // create before server is started + const advisor = new Advisor(server, optionProvider); // create before server is started const disposables = new CompositeDisposable(); let localDisposables: CompositeDisposable; @@ -177,7 +178,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an context.subscriptions.push(disposables); - return new Promise(resolve => + return new Promise(resolve => server.onServerStart(e => - resolve(server))); + resolve({ server, advisor }))); } \ No newline at end of file diff --git a/test/integrationTests/diagnostics.integration.test.ts b/test/integrationTests/diagnostics.integration.test.ts index f5534b805..ffef306d4 100644 --- a/test/integrationTests/diagnostics.integration.test.ts +++ b/test/integrationTests/diagnostics.integration.test.ts @@ -10,7 +10,7 @@ import * as path from 'path'; import { activateCSharpExtension } from './integrationHelpers'; import testAssetWorkspace from './testAssets/testAssetWorkspace'; -import * as OmniSharp from "../../src/omnisharp/extension"; +import { Advisor } from '../../src/features/diagnosticsProvider'; const chai = require('chai'); chai.use(require('chai-arrays')); @@ -22,9 +22,16 @@ function setLimit(to: number | null) { } suite(`Diagnostics Provider ${testAssetWorkspace.description}`, function () { + let advisor: Advisor; + suiteSetup(async function () { await testAssetWorkspace.restore(); - await activateCSharpExtension(); + let activationResult = await activateCSharpExtension(); + if (!activationResult) { + throw new Error('Cannot activate extension.'); + } else { + advisor = activationResult.advisor; + } let fileName = 'completion.cs'; let dir = testAssetWorkspace.projects[0].projectDirectoryPath; @@ -39,36 +46,36 @@ suite(`Diagnostics Provider ${testAssetWorkspace.description}`, function () { test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); - expect(OmniSharp.advisor.shouldValidateProject()).to.be.true; + expect(advisor.shouldValidateProject()).to.be.true; }); test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); - expect(OmniSharp.advisor.shouldValidateFiles()).to.be.true; + expect(advisor.shouldValidateFiles()).to.be.true; }); test('Does not report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); - expect(OmniSharp.advisor.shouldValidateProject()).to.be.false; + expect(advisor.shouldValidateProject()).to.be.false; }); test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); - expect(OmniSharp.advisor.shouldValidateFiles()).to.be.true; + expect(advisor.shouldValidateFiles()).to.be.true; }); test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); - expect(OmniSharp.advisor.shouldValidateProject()).to.be.true; + expect(advisor.shouldValidateProject()).to.be.true; }); test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); - expect(OmniSharp.advisor.shouldValidateFiles()).to.be.true; + expect(advisor.shouldValidateFiles()).to.be.true; }); }); \ No newline at end of file diff --git a/test/integrationTests/integrationHelpers.ts b/test/integrationTests/integrationHelpers.ts index 382e5eb66..510172857 100644 --- a/test/integrationTests/integrationHelpers.ts +++ b/test/integrationTests/integrationHelpers.ts @@ -5,8 +5,13 @@ import * as vscode from 'vscode'; import CSharpExtensionExports from '../../src/CSharpExtensionExports'; +import { Advisor } from '../../src/features/diagnosticsProvider'; -export async function activateCSharpExtension(): Promise { +export interface ActivationResult { + readonly advisor: Advisor; +} + +export async function activateCSharpExtension(): Promise { const csharpExtension = vscode.extensions.getExtension("ms-vscode.csharp"); if (!csharpExtension.isActive) { @@ -16,8 +21,10 @@ export async function activateCSharpExtension(): Promise { try { await csharpExtension.exports.initializationFinished(); console.log("ms-vscode.csharp activated"); + return { advisor: await csharpExtension.exports.getAdvisor() }; } catch (err) { console.log(JSON.stringify(err)); + return undefined; } -} \ No newline at end of file +} From 9acabc02e92c8f85a8fa9f42db34cbbb4d7e75d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 31 Oct 2018 18:32:11 +0100 Subject: [PATCH 5/7] Rename `diagnostics` integration tests to `advisor` --- ...gration.test.ts => advisor.integration.test.ts} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename test/integrationTests/{diagnostics.integration.test.ts => advisor.integration.test.ts} (71%) diff --git a/test/integrationTests/diagnostics.integration.test.ts b/test/integrationTests/advisor.integration.test.ts similarity index 71% rename from test/integrationTests/diagnostics.integration.test.ts rename to test/integrationTests/advisor.integration.test.ts index ffef306d4..e8ef4d86e 100644 --- a/test/integrationTests/diagnostics.integration.test.ts +++ b/test/integrationTests/advisor.integration.test.ts @@ -21,7 +21,7 @@ function setLimit(to: number | null) { return csharpConfig.update('maxProjectFileCountForDiagnosticAnalysis', to); } -suite(`Diagnostics Provider ${testAssetWorkspace.description}`, function () { +suite(`Advisor ${testAssetWorkspace.description}`, function () { let advisor: Advisor; suiteSetup(async function () { @@ -43,37 +43,37 @@ suite(`Diagnostics Provider ${testAssetWorkspace.description}`, function () { await testAssetWorkspace.cleanupWorkspace(); }); - test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { + test('Allows to report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); expect(advisor.shouldValidateProject()).to.be.true; }); - test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { + test('Allows to report errors from individual files when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); expect(advisor.shouldValidateFiles()).to.be.true; }); - test('Does not report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { + test('Does not allow to report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); expect(advisor.shouldValidateProject()).to.be.false; }); - test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { + test('Allows to errors from individual files when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); expect(advisor.shouldValidateFiles()).to.be.true; }); - test('Reports errors from whole project when maxProjectFileCountForDiagnosticAnalysis is null', async () => { + test('Allows to errors from whole project when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); expect(advisor.shouldValidateProject()).to.be.true; }); - test('Reports errors from individual files when maxProjectFileCountForDiagnosticAnalysis is null', async () => { + test('Allows to errors from individual files when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); expect(advisor.shouldValidateFiles()).to.be.true; From 7341793a1f90f950d7a3f81ea3237c1106ece9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 31 Oct 2018 18:38:22 +0100 Subject: [PATCH 6/7] Cleanup test names --- test/integrationTests/advisor.integration.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/integrationTests/advisor.integration.test.ts b/test/integrationTests/advisor.integration.test.ts index e8ef4d86e..02633495a 100644 --- a/test/integrationTests/advisor.integration.test.ts +++ b/test/integrationTests/advisor.integration.test.ts @@ -43,37 +43,37 @@ suite(`Advisor ${testAssetWorkspace.description}`, function () { await testAssetWorkspace.cleanupWorkspace(); }); - test('Allows to report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { + test('Advisor.shouldValidateProject returns true when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); expect(advisor.shouldValidateProject()).to.be.true; }); - test('Allows to report errors from individual files when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { + test('Advisor.shouldValidateFiles returns true when maxProjectFileCountForDiagnosticAnalysis is higher than the file count', async () => { await setLimit(1000); expect(advisor.shouldValidateFiles()).to.be.true; }); - test('Does not allow to report errors from whole project when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { + test('Advisor.shouldValidateProject returns false when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); expect(advisor.shouldValidateProject()).to.be.false; }); - test('Allows to errors from individual files when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { + test('Advisor.shouldValidateFiles returns true when maxProjectFileCountForDiagnosticAnalysis is lower than the file count', async () => { await setLimit(1); expect(advisor.shouldValidateFiles()).to.be.true; }); - test('Allows to errors from whole project when maxProjectFileCountForDiagnosticAnalysis is null', async () => { + test('Advisor.shouldValidateProject returns true when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); expect(advisor.shouldValidateProject()).to.be.true; }); - test('Allows to errors from individual files when maxProjectFileCountForDiagnosticAnalysis is null', async () => { + test('Advisor.shouldValidateFiles returns true when maxProjectFileCountForDiagnosticAnalysis is null', async () => { await setLimit(null); expect(advisor.shouldValidateFiles()).to.be.true; From 5a97194d1bf58a561ee1a67a6ce8ce0c41bef224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Mon, 5 Nov 2018 21:59:24 +0100 Subject: [PATCH 7/7] Add entry to the CHANGELOG --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb0ebec93..cceb21606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Added preview Razor (cshtml) language service with support for C# completions and diagnostics in ASP.NET Core projects. Please report issues with the preview Razor tooling on the [aspnet/Razor.VSCode](https://github.com/aspnet/Razor.VSCode/issues) repo. To disable the preview Razor tooling set the "razor.disabled" setting to `true`. (PR: [2554](https://github.com/OmniSharp/omnisharp-vscode/pull/2554)) * Added omnisharp.minFindSymbolsFilterLength setting to configure the number of characters a user must type in for "Go to Symbol in Workspace" command to return any results (default is 0 to preserve existing behavior). Additionally added omnisharp.maxFindSymbolsItems for configuring maximum number of items returned by "Go to Symbol in Workspace" command. The default is 1000. (PR: [#2487](https://github.com/OmniSharp/omnisharp-vscode/pull/2487)) * Added a command - "CSharp: Start authoring a new issue on GitHub" to enable the users to file issues on github from within the extension with helpful config information from their system.(PR: [#2503](https://github.com/OmniSharp/omnisharp-vscode/pull/2503)) +* Added a `csharp.maxProjectFileCountForDiagnosticAnalysis` setting to configure the file limit when the extension stops reporting errors for whole workspace. When this threshold is reached, the diagnostics are reported for currently opened files only. This mechanism was available in previous versions, but now can be configured. The default is 1000. (PR: [#1877](https://github.com/OmniSharp/omnisharp-vscode/pull/1877)) #### Debugger * Fixed crash at the end of debug sessions on Linux ([#2439](https://github.com/OmniSharp/omnisharp-vscode/issues/2439)) @@ -38,7 +39,7 @@ * Modified the "Unresolved dependencies" prompt to restore the all the projects in the currently selected solution or workspace. (PR: [#2323](https://github.com/OmniSharp/omnisharp-vscode/pull/2323)) -* Added support to configure the default *.sln file loaded when opening a project with multiple *.sln files in the root. _(Contributed by [@janaka](https://github.com/janaka))_ (PR: [#2053](https://github.com/OmniSharp/omnisharp-vscode/pull/2053)) +* Added support to configure the default *.sln file loaded when opening a project with multiple *.sln files in the root. _(Contributed by [@janaka](https://github.com/janaka))_ (PR: [#2053](https://github.com/OmniSharp/omnisharp-vscode/pull/2053)) * Added support for tracking opening, closing and changing of virtual documents that don't exist on disk. (PR: [#2436](https://github.com/OmniSharp/omnisharp-vscode/pull/2436)) _(Contributed by [@NTaylorMullen](https://github.com/NTaylorMullen))_ @@ -57,7 +58,7 @@ #### Testing * Added test execution output to the output of the Run/Debug Test CodeLens. (PR: [#2337](https://github.com/OmniSharp/omnisharp-vscode/pull/2337), [#2343](https://github.com/OmniSharp/omnisharp-vscode/pull/2343), [omnisharp-roslyn#1203](https://github.com/OmniSharp/omnisharp-roslyn/pull/1203)) -* Fixed a bug where a debug session could not be started and duplicate logs were displayed after a previous one failed due to build failure. (PR: [#2405](https://github.com/OmniSharp/omnisharp-vscode/pull/2405), [omnisharp-roslyn#1239](https://github.com/OmniSharp/omnisharp-roslyn/pull/1239)) +* Fixed a bug where a debug session could not be started and duplicate logs were displayed after a previous one failed due to build failure. (PR: [#2405](https://github.com/OmniSharp/omnisharp-vscode/pull/2405), [omnisharp-roslyn#1239](https://github.com/OmniSharp/omnisharp-roslyn/pull/1239)) #### Options