JasonBock / InlineMapping

Using the Compiler API for object mapping
MIT License
63 stars 11 forks source link

A few updates #21

Closed IEvangelist closed 3 years ago

IEvangelist commented 3 years ago

A few minor tweaks, new() syntax, pattern matching, and minor optimization of filtering to attribute

JasonBock commented 3 years ago

I appreciate the help, but....these changes aren't what I'm looking for :). I'd rather not use new() and get rid of var in those cases.

IEvangelist commented 3 years ago

No worries. There are a few other changes though that don't go against the rules you have in place.

For example:

public Destination MapUsingInline() => new Destination(); // this.source.MapToDestination();

vs the proposed:

public Destination MapUsingInline() => new(); // this.source.MapToDestination();

This

var candidateTypeSymbol = model.GetDeclaredSymbol(candidateTypeNode) as ITypeSymbol;
if (candidateTypeSymbol is not null)

vs the proposed:

if (model.GetDeclaredSymbol(candidateTypeNode) is ITypeSymbol candidateTypeSymbol)

Or

public List<TypeDeclarationSyntax> Candidates { get; } = new List<TypeDeclarationSyntax>();

vs

public List<TypeDeclarationSyntax> Candidates { get; } = new();

Also, some of the pattern matching stuff maps.Count == 0 vs maps is { Count: 0 }. Oh, and the filtering with LINQ is an improvement in that it's not a nested foreach loop and it doesn't call .ToString() twice. Take care