Sitelet https://github.com/DragonBox/uplift/pull/70
Skip to content

Correct update package function to prevent error in First method - #70

Merged
lacostej merged 3 commits into
DragonBox:masterfrom
scassard:fix/proper_UpdatePackage_function
May 20, 2019
Merged

lacostej merged 3 commits into
DragonBox:masterfrom
scassard:fix/proper_UpdatePackage_function

Conversation

@scassard

@scassard scassard commented May 14, 2019 •

Copy link
Copy Markdown
Contributor

There was an error happening sometimes when updating package :
System.InvalidOperationException: Operation is not valid due to the current state of the object

It seemed to occurred when uplift tries to update a package which is not listed in the "UPFILE DEPENDENCIES" listed in Upfile.lock. Thus the search for the package definition failed.

Small fix which solve problem while updating a package was to set the package definition to null in that case by using FirstOrDefault instead of First method.

NOTE : This PR depends on this PR

I had a little trouble opening this pull request, but it should be fine by now.

@scassard scassard closed this May 14, 2019
@scassard scassard reopened this May 14, 2019
@scassard
scassard force-pushed the fix/proper_UpdatePackage_function branch from e5e7c00 to 6d473e5 Compare May 14, 2019 14:22
@lacostej

Copy link
Copy Markdown
Member

Great if you can explain why this is happening in the first place.

Tip: look at the internal commit guidelines :)

WRT to the issue I wonder if the solution is to avoid passing a null DependencyDefinition and do something similar to

DependencyDefinition def = upfile.Dependencies.Any(d => d.Name == pr.Package.PackageName) ?
upfile.Dependencies.First(d => d.Name == pr.Package.PackageName) :
new DependencyDefinition() { Name = pr.Package.PackageName, Version = pr.Package.PackageVersion };
instead

@scassard

Copy link
Copy Markdown
Contributor Author

I've just updated my first comment to explain clearly why this was happening and how I fixed it.

@scassard
scassard force-pushed the fix/proper_UpdatePackage_function branch from 72a2009 to c895db1 Compare May 20, 2019 15:00
@lacostej
lacostej merged commit 1b6b0c1 into DragonBox:master May 20, 2019
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.

3 participants