Skip to content

Commit

Permalink
Fix parsing -preview versions in the registry when installed via Vi…
Browse files Browse the repository at this point in the history
…sual Studio (#1914)

* remove -preview from the version parsing to prevent trying to cast it to a number

* fix nullabilty check
  • Loading branch information
nagilson authored Aug 13, 2024
1 parent cc797df commit 76d021e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export class VersionResolver implements IVersionResolver {
*/
private getPatchVersionString(fullySpecifiedVersion : string) : string
{
const patch : string | undefined = fullySpecifiedVersion.split('.')?.at(2)?.substring(1);
const patch : string | undefined = fullySpecifiedVersion.split('.')?.at(2)?.substring(1)?.split('-')?.at(0);
if(patch === undefined || !this.isNumber(patch))
{
const event = new DotnetFeatureBandDoesNotExistError(new EventCancellationError('DotnetFeatureBandDoesNotExistError',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ suite('VersionResolver Unit Tests', () => {
assert.equal(resolver.getFeatureBandPatchVersion(twoDigitPatchVersion), '21');
});

test('Get Patch from SDK Preview Version', async () => {
assert.equal(resolver.getFeatureBandPatchVersion('8.0.400-preview.0.24324.5'), '0');
});

test('Detects Unspecified Patch Version', async () => {
assert.equal(resolver.isNonSpecificFeatureBandedVersion(fullySpecifiedVersion), false, 'It detects versions with patches');
assert.equal(resolver.isNonSpecificFeatureBandedVersion(featureBandVersion), true, 'It detects versions with xx');
Expand Down

0 comments on commit 76d021e

Please sign in to comment.