-
Notifications
You must be signed in to change notification settings - Fork 378
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
Workload + Sdk version Constraints #4753
Conversation
/// <summary> | ||
/// Set of installed workloads. | ||
/// </summary> | ||
public IEnumerable<WorkloadInfo> InstalledWorkloads { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will you be implementing this in the CLI host? Does the Template Locator have an API surface that we can call from VS to pass this to the template engine? Currently VS knows nothing about installed SDK workloads, we only grab the list of packages from installed workloads from the template locator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to open PR in SDK during today/tomorrw and I'll link it here. dotnet/sdk#25505
SDK has VisualStudioWorkloads.GetInstalledWorkloads
that does this (and I'll be utilizing it in my helper) - however it is used only for Windows platform. I was hoping to get from you some knowledge or PoCs with knowledge about situation on Mac.
Another question is how to handle VS instances with other older SDK versions:
a) backport the utility code (not sure if it's a good idea at all)
b) inject custom provider that utilizes sdk workload list
or any available API
c) not support the Workload constraints (same will happen by simply not passig the provider from host)
Let's have a discussion about this topic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly questions, some concerns around namespaces, imo constraints logic may be simplified.
Consider Async
for new components.
src/Microsoft.TemplateEngine.Abstractions/Constraints/ISdkInfoProvider.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Abstractions/Constraints/IWorkloadsInfoProvider.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Abstractions/Constraints/TemplateConstraintInfo.cs
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Abstractions/Constraints/WorkloadInfo.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Edge/Constraints/SdkVersionConstraintFactory.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Edge/Constraints/SdkVersionConstraintFactory.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Edge/Constraints/SdkVersionConstraintFactory.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Edge/Constraints/WorkloadConstraintFactory.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review CTAs as the seems not be applicable to Visual Studio (or potentially other host).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple of comments inline.
src/Microsoft.TemplateEngine.Edge/Constraints/ConstraintsExtensions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Edge/Constraints/HostConstraint.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Edge/Constraints/SdkVersionConstraintFactory.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Edge/Constraints/SdkVersionConstraintFactory.cs
Outdated
Show resolved
Hide resolved
string version = await providers[0].GetCurrentVersionAsync(cancellationToken).ConfigureAwait(false); | ||
NuGetVersionSpecification currentSdkVersion = ParseVersion(version); | ||
|
||
cancellationToken.ThrowIfCancellationRequested(); | ||
IEnumerable<NuGetVersionSpecification> versions = (await providers[0].GetInstalledVersionsAsync(cancellationToken).ConfigureAwait(false)).Select(ParseVersion); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be done in parallel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to targetting netstandard 2.0 we do not have IAsyncEnumerable
here, but rather Task<IEnumerable<string>>
(and just a single call to single provider) - so there is no space for further paralelization. (calling ParseVersion
on each version string in enumeration in parallel would have more overhead that doing it serially - as we likely cannot expect this to return more than few elements)
src/Microsoft.TemplateEngine.Edge/Constraints/WorkloadConstraintFactory.cs
Outdated
Show resolved
Hide resolved
|
||
// This is a workaround in a weird bug with FakeItEasy, when using: | ||
// ISdkInfoProvider sdkInfoProvider = A.Fake<ISdkInfoProvider>(); | ||
// A.CallTo(() => sdkInfoProvider.GetVersionAsync(A<CancellationToken>._)).Returns(Task.FromResult(sdkVersion)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you also try A.CallTo(() => sdkInfoProvider.GetVersionAsync(default)).Returns(sdkVersion)
https://fakeiteasy.readthedocs.io/en/stable/faking-async-methods/
I think the issue might be in trying to "fake" cancellation token, but badly reported; I'm not sure if faking structs is supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - unfortunately didn't help. CancellationToken
is not actually being faked here - the Task
is. In some random cases the Task was returning empty string within the tested method (not happening if I create mock manually)
Problem
#3107
Complement SDK changes: dotnet/sdk#25505
Solution
TBD:
Checks:
#nullable enable
to all the modified files ?