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

Include PackageSpec in assets (lock) file #1025

Merged
merged 8 commits into from
Nov 21, 2016
Merged

Include PackageSpec in assets (lock) file #1025

merged 8 commits into from
Nov 21, 2016

Conversation

joelverhagen
Copy link
Member

During the commit step of a restore operation, we write out a project.lock.json file or a project.assets.json file. I have added a property to this JSON object "packageSpec". The value is the input package spec.

The .dg file already has serialized PackageSpec instances.

Notable accomplishments:

  • Added new PackageSpec property to the lock file model, serialization, and deserialization
  • Added Equals and GetHashCode implementations to PackageSpec and all of its child models
    • When comparing two PackageSpec instances, I did not take the Name and FilePath properties into account. These are not serialized so I figured anything that did not round trip should not be considered part of the equality logic. Additionally the file path that your read a PackageSpec from should not matter.
  • Added equality helpers to EqualityUtility and hash code helpers to HashCodeCombiner
  • Added GetJObject method to JsonObjectWriter to avoid unnecessary serialization
  • Removed unused Properties property from PackageSpec
  • Removed duplicate HashCodeCombiner implementation
  • Update PackageSpecReferenceDependencyProvider to clone LibraryDependency instances.
    • This was causing round-tripping issues.
    • These are originals from package spec and should not be mutated in this case.

Completes the second item in NuGet/Home#3891 (comment).

/cc @emgarten @alpaix @dtivel

@@ -20,7 +19,7 @@ public static PackageSpec GetSpec(string projectFilePath, string id, VersionRang
{
var name = $"{id}-{Guid.NewGuid().ToString()}";

return new PackageSpec(new JObject())
return new PackageSpec()
Copy link
Member

Choose a reason for hiding this comment

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

👍


namespace NuGet.LibraryModel
{
public class ToolDependency
public class ToolDependency : IEquatable<ToolDependency>
Copy link
Member

Choose a reason for hiding this comment

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

This could be removed from PackageSpec instead, I must have missed it when removing the rest of the XProj support.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Decided to do this as a separate item:
NuGet/Home#3986

@@ -46,6 +47,7 @@ public class LockFileFormat
private const string ToolsProperty = "tools";
private const string ProjectFileToolGroupsProperty = "projectFileToolGroups";
private const string PackageFoldersProperty = "packageFolders";
private const string PackageSpecProperty = "packageSpec";
Copy link
Member

Choose a reason for hiding this comment

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

Should this have a different name? packageSpec is a bit confusing already, maybe: restoreSpec, project, or projectMetadata, thoughts?

Internally the PackageSpec name makes sense, just not for anyone else viewing this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

project is best, I think. Good idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

This reverts commit 81491a5.

# Conflicts:
#	test/NuGet.Core.FuncTests/NuGet.Commands.FuncTest/compiler/resources/uwpBlankAppV2.json
#	test/NuGet.Core.Tests/NuGet.ProjectModel.Test/LockFileFormatTests.cs
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