Skip to content

Commit ce854ff

Browse files
author
Robert Holt
committed
Allow case-sensitive type data collection
1 parent 23a18f6 commit ce854ff

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

PSCompatibilityAnalyzer/Microsoft.PowerShell.CrossCompatibility/Data/Types/AssemblyData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class AssemblyData : ICloneable
2424
/// and then type name.
2525
/// </summary>
2626
[DataMember(EmitDefaultValue = false)]
27-
public JsonCaseInsensitiveStringDictionary<JsonCaseInsensitiveStringDictionary<TypeData>> Types { get; set; }
27+
public JsonDictionary<string, JsonDictionary<string, TypeData>> Types { get; set; }
2828

2929
/// <summary>
3030
/// Create a deep clone of the assembly data object.
@@ -34,7 +34,7 @@ public object Clone()
3434
return new AssemblyData()
3535
{
3636
AssemblyName = (AssemblyNameData)AssemblyName.Clone(),
37-
Types = (JsonCaseInsensitiveStringDictionary<JsonCaseInsensitiveStringDictionary<TypeData>>)Types?.Clone()
37+
Types = (JsonDictionary<string, JsonDictionary<string, TypeData>>)Types?.Clone()
3838
};
3939
}
4040
}

PSCompatibilityAnalyzer/Microsoft.PowerShell.CrossCompatibility/Data/Types/AvailableTypeData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class AvailableTypeData : ICloneable
2626
/// keyed by simple assembly name.
2727
/// </summary>
2828
[DataMember]
29-
public JsonCaseInsensitiveStringDictionary<AssemblyData> Assemblies { get; set; }
29+
public JsonDictionary<string, AssemblyData> Assemblies { get; set; }
3030

3131
/// <summary>
3232
/// Create a deep clone of the available type data object.

PSCompatibilityAnalyzer/Microsoft.PowerShell.CrossCompatibility/Query/Types/AssemblyData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public AssemblyData(Data.Types.AssemblyData assemblyData)
3838
/// </summary>
3939
public IReadOnlyDictionary<string, IReadOnlyDictionary<string, TypeData>> Types => _types?.Value;
4040

41-
private static IReadOnlyDictionary<string, IReadOnlyDictionary<string, TypeData>> CreateTypeDictionary(IReadOnlyDictionary<string, JsonCaseInsensitiveStringDictionary<Data.Types.TypeData>> typeData)
41+
private static IReadOnlyDictionary<string, IReadOnlyDictionary<string, TypeData>> CreateTypeDictionary(IReadOnlyDictionary<string, JsonDictionary<string, Data.Types.TypeData>> typeData)
4242
{
4343
var namespaceDict = new Dictionary<string, IReadOnlyDictionary<string, TypeData>>(typeData.Count, StringComparer.OrdinalIgnoreCase);
44-
foreach (KeyValuePair<string, JsonCaseInsensitiveStringDictionary<Data.Types.TypeData>> nspace in typeData)
44+
foreach (KeyValuePair<string, JsonDictionary<string, Data.Types.TypeData>> nspace in typeData)
4545
{
4646
var typeDict = new Dictionary<string, TypeData>(nspace.Value.Count, StringComparer.OrdinalIgnoreCase);
4747
foreach (KeyValuePair<string, Data.Types.TypeData> type in nspace.Value)

PSCompatibilityAnalyzer/Microsoft.PowerShell.CrossCompatibility/Utility/ProfileCombination.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private static object Union(ParameterSetData thisParameterSet, ParameterSetData
122122

123123
private static object Union(AvailableTypeData thisTypes, AvailableTypeData thatTypes)
124124
{
125-
thisTypes.Assemblies = StringDictionaryUnion(thisTypes.Assemblies, thatTypes.Assemblies, Union);
125+
thisTypes.Assemblies = DictionaryUnion(thisTypes.Assemblies, thatTypes.Assemblies, Union);
126126
thisTypes.TypeAccelerators = StringDictionaryUnion(thisTypes.TypeAccelerators, thatTypes.TypeAccelerators);
127127

128128
return thisTypes;
@@ -136,18 +136,18 @@ private static object Union(AssemblyData thisAssembly, AssemblyData thatAssembly
136136
{
137137
if (thisAssembly.Types == null)
138138
{
139-
thisAssembly.Types = new JsonCaseInsensitiveStringDictionary<JsonCaseInsensitiveStringDictionary<TypeData>>();
139+
thisAssembly.Types = new JsonDictionary<string, JsonDictionary<string, TypeData>>();
140140
}
141141

142-
foreach (KeyValuePair<string, JsonCaseInsensitiveStringDictionary<TypeData>> nspace in thatAssembly.Types)
142+
foreach (KeyValuePair<string, JsonDictionary<string, TypeData>> nspace in thatAssembly.Types)
143143
{
144144
if (!thisAssembly.Types.ContainsKey(nspace.Key))
145145
{
146146
thisAssembly.Types.Add(nspace.Key, nspace.Value);
147147
continue;
148148
}
149149

150-
thisAssembly.Types[nspace.Key] = StringDictionaryUnion(thisAssembly.Types[nspace.Key], nspace.Value, Union);
150+
thisAssembly.Types[nspace.Key] = DictionaryUnion(thisAssembly.Types[nspace.Key], nspace.Value, Union);
151151
}
152152
}
153153

PSCompatibilityAnalyzer/Microsoft.PowerShell.CrossCompatibility/Utility/TypeDataConversion.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static AvailableTypeData AssembleAvailableTypes(
5050
typeAcceleratorDict.Add(typeAccelerator.Key, ta);
5151
}
5252

53-
var asms = new JsonCaseInsensitiveStringDictionary<AssemblyData>();
53+
var asms = new JsonDictionary<string, AssemblyData>();
5454
foreach (Assembly asm in assemblies)
5555
{
5656
// Don't want to include this module or assembly in the output
@@ -96,10 +96,10 @@ public static KeyValuePair<string, AssemblyData> AssembleAssembly(Assembly asm)
9696
};
9797

9898
Type[] types = asm.GetTypes();
99-
JsonCaseInsensitiveStringDictionary<JsonCaseInsensitiveStringDictionary<TypeData>> namespacedTypes = null;
99+
JsonDictionary<string, JsonDictionary<string, TypeData>> namespacedTypes = null;
100100
if (types.Any())
101101
{
102-
namespacedTypes = new JsonCaseInsensitiveStringDictionary<JsonCaseInsensitiveStringDictionary<TypeData>>();
102+
namespacedTypes = new JsonDictionary<string, JsonDictionary<string, TypeData>>();
103103
foreach (Type type in asm.GetTypes())
104104
{
105105
if (!type.IsPublic)
@@ -110,14 +110,14 @@ public static KeyValuePair<string, AssemblyData> AssembleAssembly(Assembly asm)
110110
// Some types don't have a namespace, but we still want to file them
111111
string typeNamespace = type.Namespace ?? "";
112112

113-
if (!namespacedTypes.ContainsKey(typeNamespace))
113+
if (!namespacedTypes.TryGetValue(typeNamespace, out JsonDictionary<string, TypeData> typeDictionary))
114114
{
115-
namespacedTypes.Add(typeNamespace, new JsonCaseInsensitiveStringDictionary<TypeData>());
115+
typeDictionary = new JsonDictionary<string, TypeData>();
116116
}
117117

118118
TypeData typeData = AssembleType(type);
119119

120-
namespacedTypes[typeNamespace][type.Name] = typeData;
120+
typeDictionary[type.Name] = typeData;
121121
}
122122
}
123123

@@ -271,12 +271,12 @@ private static MemberData AssembleMembers(Type type, BindingFlags memberBinding)
271271
return new MemberData()
272272
{
273273
Constructors = constructors.Any() ? constructors.Select(c => AssembleConstructor(c)).ToArray() : null,
274-
Events = events.Any() ? new JsonCaseInsensitiveStringDictionary<EventData>(events.ToDictionary(e => e.Name, e => AssembleEvent(e), StringComparer.OrdinalIgnoreCase)) : null,
275-
Fields = fields.Any() ? new JsonCaseInsensitiveStringDictionary<FieldData>(fields.ToDictionary(f => f.Name, f => AssembleField(f), StringComparer.OrdinalIgnoreCase)) : null,
274+
Events = events.Any() ? new JsonCaseInsensitiveStringDictionary<EventData>(events.ToDictionary(e => e.Name, e => AssembleEvent(e))) : null,
275+
Fields = fields.Any() ? new JsonCaseInsensitiveStringDictionary<FieldData>(fields.ToDictionary(f => f.Name, f => AssembleField(f))) : null,
276276
Indexers = indexers.Any() ? indexers.Select(i => AssembleIndexer(i)).ToArray() : null,
277-
Methods = methods.Any() ? new JsonCaseInsensitiveStringDictionary<MethodData>(methods.ToDictionary(m => m.Key, m => AssembleMethod(m.Value), StringComparer.OrdinalIgnoreCase)) : null,
278-
NestedTypes = nestedTypes.Any() ? new JsonCaseInsensitiveStringDictionary<TypeData>(nestedTypes.ToDictionary(t => t.Name, t => AssembleType(t), StringComparer.OrdinalIgnoreCase)) : null,
279-
Properties = properties.Any() ? new JsonCaseInsensitiveStringDictionary<PropertyData>(properties.ToDictionary(p => p.Name, p => AssembleProperty(p), StringComparer.OrdinalIgnoreCase)) : null
277+
Methods = methods.Any() ? new JsonCaseInsensitiveStringDictionary<MethodData>(methods.ToDictionary(m => m.Key, m => AssembleMethod(m.Value))) : null,
278+
NestedTypes = nestedTypes.Any() ? new JsonCaseInsensitiveStringDictionary<TypeData>(nestedTypes.ToDictionary(t => t.Name, t => AssembleType(t))) : null,
279+
Properties = properties.Any() ? new JsonCaseInsensitiveStringDictionary<PropertyData>(properties.ToDictionary(p => p.Name, p => AssembleProperty(p))) : null
280280
};
281281
}
282282

0 commit comments

Comments
 (0)