Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding accepted SDK name match pattern to SDK manifests. #7597

Merged
merged 20 commits into from
May 25, 2022

Conversation

AR-May
Copy link
Member

@AR-May AR-May commented May 4, 2022

Fixes #7293

Context

Previously all SDK resolvers were loaded and then ordered by priority. The resolvers are tried one after one until one of them succeeds. In order to decrease the number of assemblies to be load we change the behavior since ChangeWave 17.4. Now the resolvers might specify the name pattern for sdks they intend to resolve. If sdk name does not match, we would not unnecessary load the resolver.

Changes Made

  • The manifest file now could have NamePattern of the resolvers specified. The change is backward but not forward compatible.
  • The resolving algorithm works in two passes. On the first pass all the specific resolvers that match the given sdk name would be loaded (if needed), ordered by priority and tried one after one. If the sdk is not found, on the second pass all general resolvers would be loaded (if needed), ordered by priority and tried one after one. This change is under the ChangeWave 17.4.

This change of algorithm might lead to a change in sdk resolution in the following situation:

  • we have two resolvers A and B, priority of A is higher than priority of B, but A is general and B is specific.
  • the sdk of the project might be resolved by two resolvers, A and B.

Then before the change the project is resolved by resolver A and after with resolver B.

Testing

  • Old & new unit tests
  • Manual tests.
  • DDRITs

@AR-May AR-May force-pushed the add-name-match-pattern-to-sdk-resolvers branch from 5855d66 to 330e3c6 Compare May 9, 2022 18:29
@AR-May AR-May force-pushed the add-name-match-pattern-to-sdk-resolvers branch from 9a51caf to 0f3fa49 Compare May 10, 2022 14:20
@AR-May AR-May marked this pull request as ready for review May 10, 2022 14:30
@AR-May AR-May force-pushed the add-name-match-pattern-to-sdk-resolvers branch from c26cde0 to 1f894c1 Compare May 11, 2022 14:15
Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Overall looking very nice. This is mostly style/perf nits.

documentation/specs/sdk-resolvers-algorithm.md Outdated Show resolved Hide resolved
src/Build.UnitTests/BackEnd/SdkResolverService_Tests.cs Outdated Show resolved Hide resolved
documentation/specs/sdk-resolvers-algorithm.md Outdated Show resolved Hide resolved
}
catch (RegexMatchTimeoutException ex)
{
ErrorUtilities.ThrowInternalError("Regular expression parsing exceeds timeout for manifest {0}. Error message: {1}", manifest.Name, ex.Message);
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't feel like an internal error to me.

Copy link
Member

Choose a reason for hiding this comment

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

I was also torn but the only real alternative is InvalidProjectFileException and since this is a problem with the SDK resolver I think InternalError is a better choice.

Copy link
Member

Choose a reason for hiding this comment

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

I agree Internal > InvalidProjectFile, but why are those the only options? Internal makes it sound like it's a bug in MSBuild. It might be a bug in one of our SDK resolvers, but it might not be, and in fact, since we've tested ours, it presumably isn't. It's a fix-your-own-build problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it is not fix-your-own-build, rather fix-your-own-msbuild-cause-you-broke-it. I do not know a way to do that out of the project files. There is an option to specify additional folder for sdk resolvers and where customer's resolvers could be in theory located, but it is my understanding that it is a non-documented env variables.

documentation/specs/sdk-resolvers-algorithm.md Outdated Show resolved Hide resolved
src/Shared/BuildEnvironmentHelper.cs Show resolved Hide resolved
}
catch (RegexMatchTimeoutException ex)
{
ErrorUtilities.ThrowInternalError("Regular expression parsing exceeds timeout for manifest {0}. Error message: {1}", manifest.Name, ex.Message);
Copy link
Member

Choose a reason for hiding this comment

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

I was also torn but the only real alternative is InvalidProjectFileException and since this is a problem with the SDK resolver I think InternalError is a better choice.

Copy link
Member

@benvillalobos benvillalobos left a comment

Choose a reason for hiding this comment

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

First pass, everything's looking good 👍

Going to give it another pass, but don't block on it if things move smoothly.

@AR-May AR-May added this to the VS 17.3 milestone May 25, 2022
@AR-May AR-May added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding "accepted SDK name match pattern" to SDK manifests
6 participants