Handle framework identifiers comparison (WIP) #1127
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FrameworkIdentifier
instances were compared structurally before but it was problematic in some cases as>= net45
matchedsl40
that wasn't in the same framework.This PR add new operators (
.>
,.>=
,.<
,.<=
) and methods (Min
,Max
,IsSameFramework
) toFrameworkIdentifier
that do the comparison with the expected semantic.Fixes #1124
Questions
This PR is a work in progress because I have a few questions about the way I did the change.
Structural Equality
The original problem come from the fact that structural comparison was used for
FrameworkIdentifier
.But in fact no comparison (that could be used for ordering) could ever be correct for this type because
net40 > sl40
should returnfalse
butnet40 < sl40
should returnfalse
too.Problem with that is that Sets are used over
FrameworkIndentifier
and due to their implementation require comparison... and I don't see any clean easy way out. Solutions that came to mind are :FrameworkIdentifier
instead of the built-in oneIn the end I applied 3 as the rest of the changes were too big (
Set
is used pretty often andFrameworkIdentifier
is part of other types that are themselves used in Sets) but I wonder if it's the correct decision.isTargetMatchingRestrictions
I extracted this method to be able to test it but it's behavior relative to portable profiles is pretty specific and I don't know if the name is specific enough.