Skip to content

Commit 8a52d03

Browse files
committed
code cleanup
1 parent e6c8bbc commit 8a52d03

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/DarkConfig/Internal/ReflectionCache.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ TypeInfo CacheTypeInfo(Type type) {
276276

277277
// if type is a union, register it with its base type
278278
if (typeUnionKey != null) {
279-
if (type.BaseType == typeof(Object) || type.BaseType == null) {
279+
if (type.BaseType == typeof(object) || type.BaseType == null) {
280280
throw new Exception($"Type {type.Name} has ConfigUnion but is not a child type");
281281
}
282-
TypeInfo parentInfo = GetTypeInfo(type.BaseType);
283-
parentInfo.UnionKeys ??= new MultiCaseDictionary<Type>();
282+
var parentInfo = GetTypeInfo(type.BaseType);
283+
parentInfo.UnionKeys ??= new();
284284

285285
if (!parentInfo.UnionKeys.TryAdd(typeUnionKey, type)) {
286286
throw new Exception($"Type {type.Name} has ConfigUnion with duplicate key {typeUnionKey}");

src/DarkConfig/Internal/TypeReifier.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public TypeReifier() {
2020
RegisteredFromDocs[typeof(TimeSpan)] = BuiltInTypeReifiers.FromTimeSpan;
2121
}
2222

23-
internal class ReificationResult {
23+
class ReificationResult {
2424
internal bool ShouldVerifyMemberHashes;
2525
internal readonly List<int> SetMemberHashes = new List<int>();
2626

@@ -122,7 +122,7 @@ public void SetStaticMembers(Type type, DocNode doc, ReificationOptions options)
122122
}
123123

124124
// Check whether any required members in the type were not set.
125-
if (missingRequiredMemberNames != null && missingRequiredMemberNames.Count > 0) {
125+
if (missingRequiredMemberNames is {Count: > 0}) {
126126
throw new MissingFieldsException(type, doc, $"Missing doc fields: {JoinList(missingRequiredMemberNames, ", ")}");
127127
}
128128

@@ -280,7 +280,7 @@ public bool SetFieldOnStruct<T>(ref T obj, string fieldName, DocNode doc, Reific
280280
}
281281

282282
// Figure out the size of each dimension the array.
283-
var lengths = new int[rank];
283+
int[] lengths = new int[rank];
284284
var currentArray = doc;
285285
for (int dimensionIndex = 0; dimensionIndex < rank; ++dimensionIndex) {
286286
lengths[dimensionIndex] = currentArray.Count;
@@ -327,8 +327,8 @@ void ReadArray(DocNode current, int currentRank) {
327327
for (int i = 0; i < current.Count; ++i) {
328328
currentIndex[currentRank] = i;
329329
if (currentRank == rank - 1) {
330-
var existingElement = arrayValue.GetValue(currentIndex);
331-
var updatedElement = ReadValueOfType(elementType, existingElement, current[i], options);
330+
object? existingElement = arrayValue.GetValue(currentIndex);
331+
object? updatedElement = ReadValueOfType(elementType, existingElement, current[i], options);
332332
arrayValue.SetValue(updatedElement, currentIndex);
333333
} else {
334334
ReadArray(current[i], currentRank + 1);

0 commit comments

Comments
 (0)