MCPcopy
hub / github.com/dotnet/vscode-csharp / migrateSingleDotnetPathValue

Function migrateSingleDotnetPathValue

src/shared/migrateOptions.ts:191–220  ·  view source on GitHub ↗
(
    oldOptionName: string,
    oldValue: string,
    newOptionName: string,
    currentNewValue: IDotnetAcquisitionExistingPaths[] | undefined,
    configuration: WorkspaceConfiguration,
    configurationTarget: ConfigurationTarget
)

Source from the content-addressed store, hash-verified

189}
190
191async function migrateSingleDotnetPathValue(
192 oldOptionName: string,
193 oldValue: string,
194 newOptionName: string,
195 currentNewValue: IDotnetAcquisitionExistingPaths[] | undefined,
196 configuration: WorkspaceConfiguration,
197 configurationTarget: ConfigurationTarget
198): Promise<void> {
199 // Migrate to .NET install tool specific option.
200 // This requires some adjustments as the .NET install tool expects the full path to the exe and can already have a value set (e.g. a diff extension).
201 const extension = process.platform === 'win32' ? '.exe' : '';
202 const newValue = path.join(oldValue, `dotnet${extension}`);
203
204 if (!fs.existsSync(newValue)) {
205 // If the existing option points to a location that doesn't exist, we'll just remove the old value.
206 configuration.update(oldOptionName, undefined, configurationTarget);
207 return;
208 }
209
210 currentNewValue = currentNewValue ?? [];
211 if (currentNewValue && currentNewValue.filter((p) => p.extensionId === CSharpExtensionId).length !== 0) {
212 // There's already a dotnet path set for this extension, we don't want to overwrite it. Just delete the old one.
213 await configuration.update(oldOptionName, undefined, configurationTarget);
214 return;
215 }
216
217 currentNewValue.push({ extensionId: CSharpExtensionId, path: newValue });
218 await configuration.update(newOptionName, currentNewValue, configurationTarget);
219 await configuration.update(oldOptionName, undefined, configurationTarget);
220}
221
222function shouldMove(newOptionValue: unknown, defaultInspectValueOfNewOption: unknown): boolean {
223 if (newOptionValue == defaultInspectValueOfNewOption) {

Callers 1

migrateDotnetPathOptionFunction · 0.85

Calls 2

existsSyncMethod · 0.80
updateMethod · 0.65

Tested by

no test coverage detected