Skip to content

Adding test hook for SDK resolver end to end tests#5640

Merged
Forgind merged 3 commits into
dotnet:masterfrom
sfoslund:ResolverTestHook
Aug 21, 2020
Merged

Adding test hook for SDK resolver end to end tests#5640
Forgind merged 3 commits into
dotnet:masterfrom
sfoslund:ResolverTestHook

Conversation

@sfoslund
Copy link
Copy Markdown
Member

Fixes #5618

@benvillalobos
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

@benvillalobos
Copy link
Copy Markdown
Member

This was closed/reopened because it ran into #5646.

@sfoslund
Copy link
Copy Markdown
Member Author

@dsplaisted I've updated this PR so it now uses the resolvers from RootFolder unless there is one with a matching name under the directory pointed to by the new environment variable, in which case the resolver from the environment variable wins.

Copy link
Copy Markdown
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

If it is not obvious what the type of a variable is, do not use var. That just makes it harder to read.

Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
@sfoslund
Copy link
Copy Markdown
Member Author

If it is not obvious what the type of a variable is, do not use var. That just makes it harder to read.

@Forgind is there anywhere in particular you'd prefer I not use var?

@Forgind
Copy link
Copy Markdown
Contributor

Forgind commented Aug 11, 2020

My preference is to never use var unless you actually don't know the type of the variable. Most people are a little more lax and say you can/should use var if the right side of the equation is "new ___", since that's pretty obvious. If you assign a new variable to the return value of a function, and you know the type, I can't think of any reason to use var.

@dsplaisted
Copy link
Copy Markdown
Member

I think there are strong opinions on both side of the var debate. I tend to like using it, especially for generic types which can get long.

@sfoslund
Copy link
Copy Markdown
Member Author

@Forgind personally I'm with Daniel, I like using it pretty universally. That also seems to be the pattern in this file (there are very few places where it's not used) so I was trying to stick with precedence.

@sfoslund
Copy link
Copy Markdown
Member Author

@dsplaisted does any of your current resolver work depend on this? In case it does, I've pushed the SDK side of this change (dotnet/sdk#12875) which should work once this flows. That way you won't be blocked in case this doesn't go in this week (as I'll be OOF mon-weds next week).

@dsplaisted
Copy link
Copy Markdown
Member

@dsplaisted does any of your current resolver work depend on this? In case it does, I've pushed the SDK side of this change (dotnet/sdk#12875) which should work once this flows. That way you won't be blocked in case this doesn't go in this week (as I'll be OOF mon-weds next week).

It will be helpful to have this for my resolver work. I need the test hook for automated tests on full Framework MSBuild, and the code to locate workloads is different on Full Framework, so it would be very good to be able to test it.

Copy link
Copy Markdown
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Can we compromise on type vs. var in the places I pointed to? I selected 4/21 as the most potentially confusing, whereas others (like the environment variables) aren't at all confusing; they just look weird to me.

Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs
Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
Comment thread src/Build.UnitTests/BackEnd/SdkResolverLoader_Tests.cs Outdated
Comment thread src/Build.UnitTests/BackEnd/SdkResolverLoader_Tests.cs Outdated
Copy link
Copy Markdown
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.

For the record I'm anti-var (outside of longer type names) 😁 I had to "go to definition" a few times to make sure I knew what was being returned. Consider the var changes as nits from me.

Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
@cdmihai
Copy link
Copy Markdown
Contributor

cdmihai commented Aug 13, 2020

There already exists an environment variable based way of specifying sdk resolver paths: https://github.com/cdmihai/msbuild/blob/ba9a1d64a7abf15a8505827c00413156a3eb7f62/src/Shared/BuildEnvironmentHelper.cs#L580

Why add additional mechanisms instead of reusing / enhancing the existing one? (for enhancing it, we could change the existing env var to contain a semicolon delimited list of paths)

@dsplaisted
Copy link
Copy Markdown
Member

There already exists an environment variable based way of specifying sdk resolver paths: https://github.com/cdmihai/msbuild/blob/ba9a1d64a7abf15a8505827c00413156a3eb7f62/src/Shared/BuildEnvironmentHelper.cs#L580

Why add additional mechanisms instead of reusing / enhancing the existing one? (for enhancing it, we could change the existing env var to contain a semicolon delimited list of paths)

The existing mechanism lets you set a path for SDKs. We want to be able to override an individual SDK Resolver so that we can specifically test the resolver behavior. For example, see dotnet/sdk#12875, and we'd also like to use the test hook to test the workload resolver.

Comment thread src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs Outdated
@sfoslund
Copy link
Copy Markdown
Member Author

@benvillalobos @Forgind I've updated with your feedback, thanks!

Copy link
Copy Markdown
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
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.

LGTM!

@Forgind Forgind merged commit 36e73fb into dotnet:master Aug 21, 2020
@sfoslund sfoslund deleted the ResolverTestHook branch August 21, 2020 15:52
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.

Add test hook for SDK resolvers

5 participants