diff --git a/src/ProtocolBuffers/EnumLite.cs b/src/ProtocolBuffers/EnumLite.cs index 527a29d81a..4234483582 100644 --- a/src/ProtocolBuffers/EnumLite.cs +++ b/src/ProtocolBuffers/EnumLite.cs @@ -93,11 +93,11 @@ namespace Google.ProtocolBuffers } } - private readonly Dictionary items; + private readonly SortedList items; public EnumLiteMap() { - items = new Dictionary(); + items = new SortedList(); #if SILVERLIGHT2 // Silverlight doesn't support Enum.GetValues // TODO(jonskeet): Validate that this reflection is permitted, e.g. in Windows Phone 7 diff --git a/src/ProtocolBuffers/FieldSet.cs b/src/ProtocolBuffers/FieldSet.cs index 2769977154..f3c08cf57e 100644 --- a/src/ProtocolBuffers/FieldSet.cs +++ b/src/ProtocolBuffers/FieldSet.cs @@ -87,12 +87,8 @@ namespace Google.ProtocolBuffers public static FieldSet CreateInstance() { -#if SILVERLIGHT2 - return new FieldSet(new Dictionary()); -#else // Use SortedList to keep fields in the canonical order return new FieldSet(new SortedList()); -#endif } /// @@ -313,16 +309,7 @@ namespace Google.ProtocolBuffers /// internal IEnumerator> GetEnumerator() { -#if SILVERLIGHT2 - List> result = new List>(fields); - result.Sort( - delegate(KeyValuePair a, KeyValuePair b) - { return a.Key.CompareTo(b.Key); } - ); - return result.GetEnumerator(); -#else return fields.GetEnumerator(); -#endif } /// @@ -474,12 +461,9 @@ namespace Google.ProtocolBuffers /// public void WriteTo(ICodedOutputStream output) { - using (IEnumerator> e = GetEnumerator()) + foreach (KeyValuePair entry in fields) { - while (e.MoveNext()) - { - WriteField(e.Current.Key, e.Current.Value, output); - } + WriteField(entry.Key, entry.Value, output); } } diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.csproj b/src/ProtocolBuffers/ProtocolBuffersLite.csproj index 66edab75c7..bc58bf1145 100644 --- a/src/ProtocolBuffers/ProtocolBuffersLite.csproj +++ b/src/ProtocolBuffers/ProtocolBuffersLite.csproj @@ -110,6 +110,7 @@ Code +