Avoid workload gc failure due to 4-part version in ReleaseVersion used to find a max#45263
Conversation
| return comparison; | ||
| } | ||
|
|
||
| var modifiedFirst = "1.1.1" + (firstDash == first.Length ? string.Empty : first.Substring(firstDash)); |
There was a problem hiding this comment.
You could just call the ctor overload for ReleaseVersion: ReleaseVersion(int major, int minor, int patch, string prerelease = null, string buildMetadata = null), you'll have a proper value to compare and avoid creating two strings and then creating versions to compare.
There was a problem hiding this comment.
I cannot use that overload because it doesn't handle 4-part version numbers. The error this is trying to address is due to trying to create a ReleaseVersion from the original string where it happens to be 9.0.100.1.
There was a problem hiding this comment.
I'm suggesting that you do the following. Right now you're creating a string and passing that to ReleaseVersion constructor, so you have something that will parse correctly.
modifiedFirst = new ReleaseVersion(1, 1, 1, (firstDash == first.Length ? string.Empty : first.Substring(firstDash));
return modifiedFirst.CompareTo(modifiedSecond)
There was a problem hiding this comment.
Ah, I misunderstood. Yeah; that should work and will save a couple allocations 🙂 Happy to make that change.
| { | ||
| internal static int VersionCompare(string first, string second) | ||
| { | ||
| if (first.Equals(second)) |
There was a problem hiding this comment.
If the versions are strings, what about case sensitivity? Like, 1.0.0.0-preview vs 1.0.0.0-PREVIEW? Or can these version number strings not contain anything other than numerics and dots?
There was a problem hiding this comment.
This first check isn't actually necessary; it's just for performance. If they aren't equal, we start turning parts into versions, and then we use previously built checks. (I think anything after the - is fair game.)
| { | ||
| internal class WorkloadUtilities | ||
| { | ||
| internal static int VersionCompare(string first, string second) |
There was a problem hiding this comment.
Is there a reason this is a separate utility instead of being the comparison operator for ReleaseVersion directly? It is a bit confusing because this method seems to directly (and only) work with strings that represent ReleaseVersion, but the method itself doesn't indicate that without reading the code.
There was a problem hiding this comment.
I was actually pretty annoyed about this.
ReleaseVersion can't handle 4-part versions like 9.0.100.1. Version can't handle prerelease bits like 9.0.100-preview.1. That means there isn't actually anything that can handle workload set versions that might have 4-part versions and might have prerelease bits.
The gc failure was actually directly because ReleaseVersion doesn't work.
There was a problem hiding this comment.
So, that makes it sound like this is a separate type, such as a WorkloadVersion since it has different constraints compared to both ReleaseVersion and Version. My general confusion was what each string parameter contains, and it sounds like it is a "new" version type, at least in the context of what version types we already have.
There was a problem hiding this comment.
In some sense, yes, and maybe it should be. I think that would be a good refactor, actually, but I'd rather have a bunch of other things in that somehow touch on it before trying to make it.
|
/backport to release/9.0.1xx |
|
Started backporting to release/9.0.1xx: https://github.com/dotnet/sdk/actions/runs/13442547774 |
|
/backport to release/9.0.1xx |
|
Started backporting to release/9.0.1xx: https://github.com/dotnet/sdk/actions/runs/13640141941 |
No description provided.