Skip to content

Commit

Permalink
fix: relax dotnet version check
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-chew committed Oct 10, 2023
1 parent 768c1c3 commit 8b231a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export namespace ConfigurationConstants {

export namespace DotnetConstants {
export const ExecutableName = 'dotnet';
export const SupportedRuntimesPattern = /Microsoft\.AspNetCore\.App\s*[56]\.0/i;
export const SupportedRuntimesPattern = /Microsoft\.NETCore\.App\s*((\d+)\.\d+\.\d+)/ig;
export const SupportedRuntimesMinVersion = 5;
}

export namespace LanguageServerConstants {
Expand Down
15 changes: 13 additions & 2 deletions src/dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ export async function checkSupportedDotnetVersion(): Promise<string | undefined>
return dotnetExecutable + Messages.Dotnet.IsNotAnExecutableFile;
}
const { stdout } = await execFileAsync(dotnetExecutable, [ ListRuntimesArg ]);
return DotnetConstants.SupportedRuntimesPattern.test(stdout) ? undefined
: dotnetExecutable + Messages.Dotnet.NotASupportedDotnetInstallation + stdout;
const runtimeVersions = [...stdout.matchAll(DotnetConstants.SupportedRuntimesPattern)]

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 23 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'
.map(match => {
const version = match[1];
const major = parseInt(match[2], 10);
return [major, version] as [number, string];

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 27 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'
});
if (runtimeVersions.find(([major, _]) => major >= DotnetConstants.SupportedRuntimesMinVersion) !== undefined) {

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected space(s) after "if"

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

'_' is defined but never used

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected space(s) after "if"

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

'_' is defined but never used

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected space(s) after "if"

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

'_' is defined but never used

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected space(s) after "if"

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

'_' is defined but never used

Check warning on line 29 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required before ']'
return undefined;
}
const runtimeVersionsStr = runtimeVersions.length === 0
? " no installed versions"

Check warning on line 33 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

Check warning on line 33 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

Check warning on line 33 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

Check warning on line 33 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
: runtimeVersions.map(([_, version]) => version).join(", ");

Check warning on line 34 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 34 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 34 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['

Check warning on line 34 in src/dotnet.ts

View workflow job for this annotation

GitHub Actions / build

A space is required after '['
return dotnetExecutable + Messages.Dotnet.NotASupportedDotnetInstallation + runtimeVersionsStr;
} catch(error: unknown) {
const errorMsg = `Error invoking ${dotnetExecutable} ${ListRuntimesArg}: ${error}`;
console.error(errorMsg);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export namespace Messages {

export namespace Dotnet {
export const IsNotAnExecutableFile = ' is not an executable dotnet file.';
export const NotASupportedDotnetInstallation = ' is not a compatible dotnet file. Dafny requires the ASP.NET Core Runtime 5.0 or 6.0, got ';
export const FailedDotnetExecution = 'Failed to execute dotnet. Dafny requires the ASP.NET Core Runtime 5.0 or 6.0.';
export const NoCompatibleInstallation = 'No compatible dotnet runtime found. Dafny requires the ASP.NET Core Runtime 5.0 or 6.0.';
export const NotASupportedDotnetInstallation = ' is not a compatible dotnet file. Dafny requires the .NET Runtime 5.0 or greater, found ';
export const FailedDotnetExecution = 'Failed to execute dotnet. Dafny requires the .NET Runtime 5.0 or greater.';
export const NoCompatibleInstallation = 'No compatible dotnet runtime found. Dafny requires the .NET Runtime 5.0 or greater.';
export const ChangeConfiguration = 'Configure the absolute path to dotnet';
export const VisitDownload = 'Get .NET SDK';
export const DownloadUri = 'https://dotnet.microsoft.com/download/dotnet/6.0';
Expand Down

0 comments on commit 8b231a6

Please sign in to comment.