Skip to content

Commit

Permalink
Added omnisharp.enableMsBuildLoadProjectsOnDemand to allow enabling f…
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgonch committed Dec 17, 2018
1 parent 80bf9ae commit 67b4173
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@
"default": false,
"description": "Specifies whether notifications should be shown if OmniSharp encounters warnings or errors loading a project. Note that these warnings/errors are always emitted to the OmniSharp log"
},
"omnisharp.enableMsBuildLoadProjectsOnDemand": {
"type": "boolean",
"default": false,
"description": "If true, MSBuild project system will only be loading projects for files that were opened in the editor. This setting is useful for big C# codebases and allows for faster initialization of code navigation features only for projects that are relevant to code that is being edited. The downside of enabling this setting is that potentially a limited semantic information is available to OmniSharp extension which for example can manifest itself in incomplete number of references shown for a symbol."
},
"razor.plugin.path": {
"type": [
"string",
Expand Down
1 change: 1 addition & 0 deletions src/observers/OptionChangeObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export function ShowOmniSharpConfigChangePrompt(optionObservable: Observable<Opt
function hasChanged(oldOptions: Options, newOptions: Options): boolean {
return (oldOptions.path != newOptions.path ||
oldOptions.useGlobalMono != newOptions.useGlobalMono ||
oldOptions.enableMsBuildLoadProjectsOnDemand != newOptions.enableMsBuildLoadProjectsOnDemand ||
oldOptions.waitForDebugger != newOptions.waitForDebugger);
}
4 changes: 4 additions & 0 deletions src/omnisharp/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class Options {
public maxFindSymbolsItems: number,
public razorDisabled: boolean,
public razorDevMode: boolean,
public enableMsBuildLoadProjectsOnDemand: boolean,
public razorPluginPath?: string,
public defaultLaunchSolution?: string,
public monoPath?: string,
Expand Down Expand Up @@ -73,6 +74,8 @@ export class Options {
const minFindSymbolsFilterLength = omnisharpConfig.get<number>('minFindSymbolsFilterLength', 0);
const maxFindSymbolsItems = omnisharpConfig.get<number>('maxFindSymbolsItems', 1000); // The limit is applied only when this setting is set to a number greater than zero

const enableMsBuildLoadProjectsOnDemand = omnisharpConfig.get<boolean>('enableMsBuildLoadProjectsOnDemand', false);

const razorDisabled = !!razorConfig && razorConfig.get<boolean>('disabled', false);
const razorDevMode = !!razorConfig && razorConfig.get<boolean>('devmode', false);
const razorPluginPath = razorConfig ? razorConfig.get<string>('plugin.path', undefined) : undefined;
Expand All @@ -97,6 +100,7 @@ export class Options {
maxFindSymbolsItems,
razorDisabled,
razorDevMode,
enableMsBuildLoadProjectsOnDemand,
razorPluginPath,
defaultLaunchSolution,
monoPath,
Expand Down
4 changes: 4 additions & 0 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ export class OmniSharpServer {
args.push('--debug');
}

if (options.enableMsBuildLoadProjectsOnDemand === true) {
args.push('MsBuild:LoadProjectsOnDemand=true');
}

let launchInfo: LaunchInfo;
try {
launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this.packageJSON.defaults.omniSharp, options.path, serverUrl, latestVersionFileServerPath, installPath, this.extensionPath);
Expand Down
2 changes: 1 addition & 1 deletion test/unitTests/Fakes/FakeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
import { Options } from "../../../src/omnisharp/options";

export function getEmptyOptions(): Options {
return new Options("", "", false, "", false, 0, 0, false, false, false, false, false, false, 0, 0, false, false, undefined, "", "");
return new Options("", "", false, "", false, 0, 0, false, false, false, false, false, false, 0, 0, false, false, false, undefined, "", "");
}
1 change: 1 addition & 0 deletions test/unitTests/OptionObserver/OptionChangeObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ suite("OmniSharpConfigChangeObserver", () => {
[
{ config: "omnisharp", section: "path", value: "somePath" },
{ config: "omnisharp", section: "waitForDebugger", value: true },
{ config: "omnisharp", section: "enableMsBuildLoadProjectsOnDemand", value: true },
{ config: "omnisharp", section: "useGlobalMono", value: "always" }

].forEach(elem => {
Expand Down
3 changes: 2 additions & 1 deletion test/unitTests/optionStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ suite('OptionStream', () => {
options.disableCodeActions.should.equal(false);
options.minFindSymbolsFilterLength.should.equal(0);
options.maxFindSymbolsItems.should.equal(1000);
expect(options.defaultLaunchSolution).to.be.undefined;
options.enableMsBuildLoadProjectsOnDemand.should.equal(false);
expect(options.defaultLaunchSolution).to.be.undefined;
});

test('Gives the changed option when the omnisharp config changes', () => {
Expand Down
1 change: 1 addition & 0 deletions test/unitTests/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ suite("Options tests", () => {
options.disableCodeActions.should.equal(false);
options.minFindSymbolsFilterLength.should.equal(0);
options.maxFindSymbolsItems.should.equal(1000);
options.enableMsBuildLoadProjectsOnDemand.should.equal(false);
expect(options.defaultLaunchSolution).to.be.undefined;
});

Expand Down

0 comments on commit 67b4173

Please sign in to comment.