Skip to content

Commit a04e3c2

Browse files
committed
Remove redundant struct
1 parent 50cc823 commit a04e3c2

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

src/DynamoDBGenerator.SourceGenerator/Types/MarshallerOptions.cs

+8-26
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public readonly struct MarshallerOptions
1616
private readonly string _converterFullPath;
1717

1818
private MarshallerOptions(INamedTypeSymbol convertersType,
19-
IEnumerable<KeyValuePair<string, Converter>> converters, int enumStrategy)
19+
IEnumerable<KeyValuePair<string, ITypeSymbol>> converters, int enumStrategy)
2020
{
21-
Converters = converters.ToDictionary(x => x.Value.T, x => x, SymbolEqualityComparer.Default);
21+
Converters = converters.ToDictionary(x => x.Value, x => x, SymbolEqualityComparer.Default);
2222
_convertersType = convertersType;
2323
_enumStrategy = enumStrategy;
2424
_converterFullPath = _convertersType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
@@ -86,8 +86,7 @@ public bool IsConvertable(ITypeSymbol typeSymbol)
8686
return typeSymbol.TypeKind is TypeKind.Enum || Converters.ContainsKey(typeSymbol);
8787
}
8888

89-
private Dictionary<ISymbol?, KeyValuePair<string, Converter>> Converters { get; }
90-
89+
private Dictionary<ISymbol?, KeyValuePair<string, ITypeSymbol>> Converters { get; }
9190

9291
public IEnumerable<string> ClassDeclaration
9392
{
@@ -112,15 +111,15 @@ public static MarshallerOptions Create(INamedTypeSymbol typeSymbol, int enumStra
112111
return new MarshallerOptions(typeSymbol, keyValuePairs, enumStrategy);
113112
}
114113

115-
private static KeyValuePair<string, Converter>? ConverterDataMemberOrNull(ISymbol symbol)
114+
private static KeyValuePair<string, ITypeSymbol>? ConverterDataMemberOrNull(ISymbol symbol)
116115
{
117116
return symbol switch
118117
{
119118
{ DeclaredAccessibility: not (Accessibility.Public or Accessibility.Internal) } => null,
120-
IFieldSymbol x when Predicate(x.Type) => new KeyValuePair<string, Converter>(x.Name, new Converter(x.Type, (INamedTypeSymbol)x.Type)),
121-
IPropertySymbol x when Predicate(x.Type) => new KeyValuePair<string, Converter>(x.Name, new Converter(x.Type, (INamedTypeSymbol)x.Type)),
122-
IFieldSymbol x when x.Type.Interfaces.FirstOrDefault(Predicate) is { } y => new KeyValuePair<string, Converter>(x.Name, new Converter(x.Type, y)),
123-
IPropertySymbol x when x.Type.Interfaces.FirstOrDefault(Predicate) is { } y => new KeyValuePair<string, Converter>(x.Name, new Converter(x.Type, y)),
119+
IFieldSymbol x when Predicate(x.Type) => new KeyValuePair<string, ITypeSymbol>(x.Name, ((INamedTypeSymbol)x.Type).TypeArguments[0]),
120+
IPropertySymbol x when Predicate(x.Type) => new KeyValuePair<string, ITypeSymbol>(x.Name, ((INamedTypeSymbol)x.Type).TypeArguments[0]),
121+
IFieldSymbol x when x.Type.Interfaces.FirstOrDefault(Predicate) is { } y => new KeyValuePair<string, ITypeSymbol>(x.Name, y.TypeArguments[0]),
122+
IPropertySymbol x when x.Type.Interfaces.FirstOrDefault(Predicate) is { } y => new KeyValuePair<string, ITypeSymbol>(x.Name, y.TypeArguments[0]),
124123
_ => null
125124
};
126125

@@ -138,21 +137,4 @@ static bool Predicate(ITypeSymbol x)
138137
};
139138
}
140139
}
141-
142-
public readonly struct Converter
143-
{
144-
public Converter(ITypeSymbol originalType, INamedTypeSymbol converterType)
145-
{
146-
OriginalType = originalType;
147-
ConverterType = converterType;
148-
T = converterType.TypeArguments[0];
149-
PropertyAccess = OriginalType.Name;
150-
}
151-
152-
153-
public ITypeSymbol OriginalType { get; }
154-
public INamedTypeSymbol ConverterType { get; }
155-
public ITypeSymbol T { get; }
156-
public string PropertyAccess { get; }
157-
}
158140
}

0 commit comments

Comments
 (0)