Skip to content

Commit

Permalink
Merge pull request #155 from tintoy/dev/remove-config-update
Browse files Browse the repository at this point in the history
Remove functionality for updating configuration
  • Loading branch information
DoctorKrolic authored Jul 14, 2024
2 parents c41c87e + a0d7c2f commit 821c865
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 141 deletions.
4 changes: 1 addition & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Trace } from 'vscode-jsonrpc/lib/node/main';
import * as dotnet from './dotnet';
import { handleBusyNotifications } from './notifications';
import { registerInternalCommands } from './internal-commands';
import { Settings, upgradeConfigurationSchema, readVSCodeSettings } from './settings';
import { Settings, readVSCodeSettings } from './settings';

let configuration: Settings;
let languageClient: LanguageClient;
Expand Down Expand Up @@ -95,8 +95,6 @@ export async function deactivate(): Promise<void> {
*/
async function loadConfiguration(): Promise<void> {
configuration = vscode.workspace.getConfiguration().get('msbuildProjectTools');

await upgradeConfigurationSchema(configuration);

configuration = readVSCodeSettings(configuration);

Expand Down
138 changes: 0 additions & 138 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as objectpath from 'object-path';
import * as vscode from 'vscode';

// TODO: Use dotted setting names to populated nested structure copied from defaultSettings.

Expand Down Expand Up @@ -157,140 +156,3 @@ export interface NuGetSettings {
*/
disablePreFetch?: boolean;
}

/**
* Update the configuration schema to the current version, if required.
*
* @param configuration The current configuration.
* @param workspaceConfiguration VS Code's global configuration.
* @returns The updated configuration
*/
export async function upgradeConfigurationSchema(configuration: any): Promise<any> {
if (!configuration.schemaVersion)
return;

let modified = false;

const workspaceConfiguration = vscode.workspace.getConfiguration();

const legacyExperimentalFeatureConfiguration = configuration.experimentalFeatures;
if (legacyExperimentalFeatureConfiguration) {
await workspaceConfiguration.update('msbuildProjectTools.experimentalFeatures',
legacyExperimentalFeatureConfiguration || [],
true // global
);

modified = true;
}

const legacyLanguageConfiguration = configuration.language;
if (legacyLanguageConfiguration) {
if (legacyLanguageConfiguration.disableHover) {
await workspaceConfiguration.update('msbuildProjectTools.language.disableHover',
legacyLanguageConfiguration.disableHover,
true // global
);

modified = true;
}
}

const legacyNugetConfiguration = configuration.nuget as NuGetSettings;
if (legacyNugetConfiguration) {
if (legacyNugetConfiguration.disablePreFetch) {
await workspaceConfiguration.update('msbuildProjectTools.nuget.disablePreFetch',
legacyNugetConfiguration.disablePreFetch,
true // global
);

modified = true;
}
if (legacyNugetConfiguration.includePreRelease) {
await workspaceConfiguration.update('msbuildProjectTools.nuget.includePreRelease',
legacyNugetConfiguration.includePreRelease,
true // global
);

modified = true;
}
if (legacyNugetConfiguration.newestVersionsFirst) {
await workspaceConfiguration.update('msbuildProjectTools.nuget.newestVersionsFirst',
legacyNugetConfiguration.newestVersionsFirst,
true // global
);

modified = true;
}
}

const legacyLoggingConfiguration = configuration.logging;
if (legacyLoggingConfiguration) {
if (legacyLoggingConfiguration.logLevel) {
await workspaceConfiguration.update('msbuildProjectTools.nuget.newestVersionsFirst',
legacyLoggingConfiguration.logLevel,
true // global
);

modified = true;
}
if (legacyLoggingConfiguration.file) {
await workspaceConfiguration.update('msbuildProjectTools.nuget.newestVersionsFirst',
legacyLoggingConfiguration.file,
true // global
);

modified = true;
}
if (legacyLoggingConfiguration.trace) {
await workspaceConfiguration.update('msbuildProjectTools.nuget.newestVersionsFirst',
legacyLoggingConfiguration.trace,
true // global
);

modified = true;
}

const legacySeqLoggingConfiguration = legacyLoggingConfiguration.seq;
if (legacySeqLoggingConfiguration) {
if (legacySeqLoggingConfiguration.level) {
await workspaceConfiguration.update('msbuildProjectTools.logging.seq.level',
legacySeqLoggingConfiguration.level,
true // global
);

modified = true;
}
if (legacySeqLoggingConfiguration.url) {
await workspaceConfiguration.update('msbuildProjectTools.logging.seq.url',
legacySeqLoggingConfiguration.url,
true // global
);

modified = true;
}
if (legacySeqLoggingConfiguration.apiKey) {
await workspaceConfiguration.update('msbuildProjectTools.logging.seq.apiKey',
legacySeqLoggingConfiguration.apiKey,
true // global
);

modified = true;
}
}

configuration.logging = null;

modified = true;
}

if (configuration.schemaVersion) {
configuration.schemaVersion = null;

modified = true;
}

if (modified) {
// TODO: Show notification indicating that old settings key should be deleted.
await vscode.window.showInformationMessage('MSBuild project tools settings have been upgraded to the latest version; please manually remove the old key ("msbuildProjectTools") from settings.json.');
}
}

0 comments on commit 821c865

Please sign in to comment.