From f9d9bf83e675d7c70403245a17c7d072428c3aba Mon Sep 17 00:00:00 2001 From: Neal Gafter Date: Fri, 27 Feb 2015 15:32:01 -0800 Subject: [PATCH] Emit anonymous types in deterministic order Fixes #223 --- .../Symbols/AnonymousTypes/AnonymousTypeManager.Templates.cs | 3 ++- .../Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs | 1 - .../Symbols/AnonymousTypes/AnonymousTypeManager_Templates.vb | 2 +- .../VisualBasic/Test/Emit/Emit/EditAndContinueTests.vb | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.Templates.cs b/src/Compilers/CSharp/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.Templates.cs index 893d569552ed4..1afe1786f6a25 100644 --- a/src/Compilers/CSharp/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.Templates.cs +++ b/src/Compilers/CSharp/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.Templates.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; +using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.Collections; using Microsoft.CodeAnalysis.CSharp.Emit; @@ -275,7 +276,7 @@ public void AssignTemplatesNamesAndCompile(MethodCompiler compiler, PEModuleBuil var anonymousTypes = _lazyAnonymousTypeTemplates; if (anonymousTypes != null) { - foreach (var template in anonymousTypes.Values) + foreach (var template in from kv in anonymousTypes orderby kv.Key select kv.Value) { // NOTE: in interactive scenarios the cache may contain templates // from other compilation, those should be discarded here diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs index c235bda4b0458..5ba57904ebbc5 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs @@ -3775,7 +3775,6 @@ .locals init ([unchanged] V_0, /// Reuse existing anonymous types. /// [WorkItem(825903, "DevDiv")] - [ConditionalFact(typeof(x86))] public void AnonymousTypes() { var source0 = diff --git a/src/Compilers/VisualBasic/Portable/Symbols/AnonymousTypes/AnonymousTypeManager_Templates.vb b/src/Compilers/VisualBasic/Portable/Symbols/AnonymousTypes/AnonymousTypeManager_Templates.vb index 3d3165225fea2..d0b67ad780660 100644 --- a/src/Compilers/VisualBasic/Portable/Symbols/AnonymousTypes/AnonymousTypeManager_Templates.vb +++ b/src/Compilers/VisualBasic/Portable/Symbols/AnonymousTypes/AnonymousTypeManager_Templates.vb @@ -149,7 +149,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols cache As ConcurrentDictionary(Of String, T)) If cache IsNot Nothing Then - For Each template In cache.Values + For Each template In From kv In cache Order By kv.Key Select kv.Value If template.Manager Is Me Then builder.Add(template) End If diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinueTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinueTests.vb index e6b98fb376f2b..3e65c6bbc9f94 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinueTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinueTests.vb @@ -3276,7 +3276,6 @@ End Class ]]>.Value) End Sub - Public Sub AnonymousTypes() Dim sources0 =