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

Non deterministic ordering of preSolution, postSolution and folder items #251

Closed
ViktorHofer opened this issue Aug 16, 2021 · 3 comments · Fixed by #265
Closed

Non deterministic ordering of preSolution, postSolution and folder items #251

ViktorHofer opened this issue Aug 16, 2021 · 3 comments · Fixed by #265
Assignees
Labels
bug Something isn't working

Comments

@ViktorHofer
Copy link
Member

Using the latest version of slngen results in this diff when using to update the Microsoft.Extensions.Options.DataAnnotations solution file:

diff --git a/src/libraries/Microsoft.Extensions.Options.DataAnnotations/Microsoft.Extensions.Options.DataAnnotations.sln b/src/libraries/Microsoft.Extensions.Options.DataAnnotations/Microsoft.Extensions.Options.DataAnnotations.sln
index 5e83d843a59..81111c8e00e 100644
--- a/src/libraries/Microsoft.Extensions.Options.DataAnnotations/Microsoft.Extensions.Options.DataAnnotations.sln
+++ b/src/libraries/Microsoft.Extensions.Options.DataAnnotations/Microsoft.Extensions.Options.DataAnnotations.sln
@@ -41,10 +41,10 @@ Global
 		{9022313F-BEEA-426E-8185-096E0516D1B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9022313F-BEEA-426E-8185-096E0516D1B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{9022313F-BEEA-426E-8185-096E0516D1B6}.Release|Any CPU.Build.0 = Release|Any CPU
-		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D158597C-16FF-4911-A214-C265C09F4AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D158597C-16FF-4911-A214-C265C09F4AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D158597C-16FF-4911-A214-C265C09F4AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D158597C-16FF-4911-A214-C265C09F4AE4}.Release|Any CPU.Build.0 = Release|Any CPU
 		{2DB8E45F-D3EF-47A7-847E-0311AE734314}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{2DB8E45F-D3EF-47A7-847E-0311AE734314}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{2DB8E45F-D3EF-47A7-847E-0311AE734314}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -53,14 +53,14 @@ Global
 		{8F8A5D2D-A829-4E0E-9DCC-57FF2C89C544}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{8F8A5D2D-A829-4E0E-9DCC-57FF2C89C544}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{8F8A5D2D-A829-4E0E-9DCC-57FF2C89C544}.Release|Any CPU.Build.0 = Release|Any CPU
-		{D158597C-16FF-4911-A214-C265C09F4AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{D158597C-16FF-4911-A214-C265C09F4AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{D158597C-16FF-4911-A214-C265C09F4AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{D158597C-16FF-4911-A214-C265C09F4AE4}.Release|Any CPU.Build.0 = Release|Any CPU
-		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Release|Any CPU.Build.0 = Release|Any CPU
 		{0E60E743-56C9-466D-A428-232FEAEEF41E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{0E60E743-56C9-466D-A428-232FEAEEF41E}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{0E60E743-56C9-466D-A428-232FEAEEF41E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -69,10 +69,10 @@ Global
 		{065B4B16-B618-41D8-B1DE-F31AFC9E6C84}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{065B4B16-B618-41D8-B1DE-F31AFC9E6C84}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{065B4B16-B618-41D8-B1DE-F31AFC9E6C84}.Release|Any CPU.Build.0 = Release|Any CPU
-		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{6E609137-B1A4-44D7-B733-611FB5FD228E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C68DD6AF-7125-4FD6-A90D-25A82824780D}.Release|Any CPU.Build.0 = Release|Any CPU
 		{DAEC9B39-32E0-481A-972B-087755C49502}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{DAEC9B39-32E0-481A-972B-087755C49502}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{DAEC9B39-32E0-481A-972B-087755C49502}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -87,16 +87,16 @@ Global
 	EndGlobalSection
 	GlobalSection(NestedProjects) = preSolution
 		{D1140557-6F25-44E9-9497-E354DC2576A1} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
-		{8F8A5D2D-A829-4E0E-9DCC-57FF2C89C544} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
 		{D158597C-16FF-4911-A214-C265C09F4AE4} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
-		{0E60E743-56C9-466D-A428-232FEAEEF41E} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
+		{8F8A5D2D-A829-4E0E-9DCC-57FF2C89C544} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
 		{6E609137-B1A4-44D7-B733-611FB5FD228E} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
+		{0E60E743-56C9-466D-A428-232FEAEEF41E} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
 		{176D75D6-80A3-4B87-A2A1-316AFA637F3B} = {DE5517CB-9721-49A0-9ECB-BC08460946AC}
 		{9022313F-BEEA-426E-8185-096E0516D1B6} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
-		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
 		{2DB8E45F-D3EF-47A7-847E-0311AE734314} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
-		{C68DD6AF-7125-4FD6-A90D-25A82824780D} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
+		{72D4F48A-A93B-471F-B9C7-64BC9BF22A09} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
 		{065B4B16-B618-41D8-B1DE-F31AFC9E6C84} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
+		{C68DD6AF-7125-4FD6-A90D-25A82824780D} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
 		{DAEC9B39-32E0-481A-972B-087755C49502} = {A3B06CF1-069F-41FF-89BB-9BAEEC5B0FF6}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution

Would it be possible to not reorder elements that haven't changed? From looking into multiple diffs I notice this often happening with the following elements:

  • preSolution
  • postSolution
  • folder

cc @jeffkl

@ViktorHofer ViktorHofer changed the title No deterministic ordering of preSolution, postSolution and folder items Non deterministic ordering of preSolution, postSolution and folder items Aug 16, 2021
@jeffkl
Copy link
Collaborator

jeffkl commented Aug 16, 2021

Yes I'd like to keep the generation deterministic and in line with what Visual Studio would do. Does VS re-order anything when you open it?

I recently moved to the NuGet team and am a little swamped at the moment, any contributions are welcome!

@jeffkl jeffkl added feature request New feature or enhancement help wanted Looking for community contributions! labels Aug 16, 2021
@ViktorHofer
Copy link
Member Author

I recently moved to the NuGet team and am a little swamped at the moment, any contributions are welcome!

Congrats Jeff 🎉🎉🎉

@ViktorHofer
Copy link
Member Author

Yes I'd like to keep the generation deterministic and in line with what Visual Studio would do. Does VS re-order anything when you open it?

VS doesn't update the solution file unless you explicitly save it. Using System.CodeDom.sln as an example, here's the diff that VS produces when explicitly saving the solution file: https://www.diffchecker.com/oNirSFSA.

jeffkl added a commit to jeffkl/SlnGen that referenced this issue Sep 1, 2021
Project ordering is replicated in the ProjectConfigurationPlatforms section by Visual Studio.  But SlnGen uses a diffrent ordering for them. This change uses the same ordering for both sections.

Fixes microsoft#251
@jeffkl jeffkl added bug Something isn't working and removed help wanted Looking for community contributions! feature request New feature or enhancement labels Sep 1, 2021
@jeffkl jeffkl self-assigned this Sep 1, 2021
jeffkl added a commit that referenced this issue Sep 1, 2021
Project ordering is replicated in the ProjectConfigurationPlatforms section by Visual Studio.  But SlnGen uses a diffrent ordering for them. This change uses the same ordering for both sections.

Fixes #251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants