Skip to content

Fix .NET Version Parsing for FindPath API#2000

Merged
nagilson merged 8 commits into
dotnet:mainfrom
nagilson:nagilson-fix-version-compare
Oct 25, 2024
Merged

Fix .NET Version Parsing for FindPath API#2000
nagilson merged 8 commits into
dotnet:mainfrom
nagilson:nagilson-fix-version-compare

Conversation

@nagilson

@nagilson nagilson commented Oct 23, 2024

Copy link
Copy Markdown
Member

The old comparison used string comparison which is fine for versions of dotnet until dotnet 10. '10.0' < '9.0'. 😂

This fixes that. I suppose it's a bit clunky and we could dedupe / share the compare logic but it's not being used elsewhere in this same form, so I don't plan to do that right now. There are also places that depend on the output versions being strings, so that's a problem to change that now too. It probably should have been a class from the beginning but unfortunately that just isn't how it was initially done, which is understandable because the scope at that time was much more limited.

The old comparison used string comparison which is fine for versions of dotnet until dotnet 10. '10.0' < '9.0'. 😂 This fixes that. I suppose it's a bit clunky and we could dedupe / share the compare logic but it's not being used elsewhere in this same form, so I don't plan to do that right now. There are also places that depend on the output versions being strings, so that's a problem to change that now too. It probably should have been a class from the beginning but unfortunately that just isn't how it was initially done, which is understandable because the scope at that time was much more limited.
@nagilson
nagilson marked this pull request as draft October 23, 2024 22:36
@nagilson
nagilson marked this pull request as ready for review October 23, 2024 23:55
@nagilson
nagilson requested a review from a team October 23, 2024 23:57
@nagilson
nagilson requested a review from smitpatel October 24, 2024 22:23

private stringVersionMeetsRequirement(foundVersion : string, requiredVersion : string, requirement : DotnetVersionSpecRequirement) : boolean
private stringVersionMeetsRequirement(availableVersion : string, requestedVersion : string, requirement : DotnetVersionSpecRequirement) : boolean
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use semver for comparison?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good suggestion, semver is a good option. I hadn't considered that, thank you. I wish we were using semver in the code a lot earlier in many places.

Going forward I will use that. I do want to get this merged quickly though, so I'm not sure about making that change now considering this is already written and tested 🤔

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file an issue to use semver rather than parsing versions ourselves?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea 👀 #2003

@nagilson nagilson mentioned this pull request Oct 25, 2024
@nagilson
nagilson merged commit c269248 into dotnet:main Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants