Skip to content

Standard VS scenarios should not load NuGet.VisualStudio.Internal.Contracts assembly - #3330

Merged
nkolev92 merged 5 commits into
devfrom
dev-nkolev92-avoidLoadingInternals
Apr 6, 2020
Merged

nkolev92 merged 5 commits into
devfrom
dev-nkolev92-avoidLoadingInternals

Conversation

@nkolev92

@nkolev92 nkolev92 commented Apr 6, 2020

Copy link
Copy Markdown
Member

Bug

Fixes: https://github.com/nuget/client.engineering/issues/253
Regression: Yes

  • Last working version: 6927689
  • How are we preventing it in future: This was caught by a test, so the correct medium

Fix

Details:
The RestoreManagerPackage is loaded on solution load/solution build and when it registers the by calling InitializeAsync https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/NuGet.SolutionRestoreManager/RestoreManagerPackage.cs#L41

This leads to loading the contracts assembly because of referring to NuGetServices.NuGetSolutionService which triggers the load.

Testing/Validation

Tests Added: No
Reason for not adding tests: We don't have any tests that will capture this.
Validation: Manual, inspected that the assembly is not loaded.

@dominoFire dominoFire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for helping unblock tests.

{
public static string NuGetSolutionServiceName = "NuGetSolutionService";
public static string NuGetSolutionServiceVersion = "1.0.0";
internal static string NuGetSolutionServiceName = "NuGetSolutionService";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add an unit test to compare these constants with their equivalents in BrokeredServicesUtility .

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

More of an integration test I guess.
I can do that. In the interest of time, I might do that in a future PR, but I'll see.
The builds seem to be failing for some reason.

@nkolev92
nkolev92 requested a review from dominoFire April 6, 2020 18:35
{
// It is very important that these names and versions are kept the same as the ones in NuGet.VisualStudio.Internal.Contracts.NuGetServices.
internal static const string NuGetSolutionServiceName = "NuGetSolutionService";
internal static string NuGetSolutionServiceVersion = "1.0.0";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these candidates for a constant to put in the Common project?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

They are only relevant for the service declaring assembly.
And we do not want the contracts assembly to have any additional NuGet dependencies.

So my thought is no, because no one else should care about these values.

@donnie-msft donnie-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just some suggestions/questions.

Comment on lines +11 to +12
private const string NuGetSolutionServiceName = "NuGetSolutionService";
private const string NuGetSolutionServiceVersion = "1.0.0";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: add a comment saying that if these are changed, then src/NuGet.Clients/NuGet.SolutionRestoreManager/BrokeredServicesUtility.cs should be updated too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@dominoFire recommended adding a test, would you prefer that over a comment?
Thoughts on adding the test in the first place? (might do a different PR, don't want to complicate things here).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A comment or a test (or both) is fine in another PR, as long as we have something to remember us to sync these values.

@nkolev92
nkolev92 merged commit 863fc6b into dev Apr 6, 2020
@nkolev92
nkolev92 deleted the dev-nkolev92-avoidLoadingInternals branch April 6, 2020 21:57
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.

4 participants