Skip to content

Commit

Permalink
chore(deps): Bump csharpier from 0.28.2 to 0.29.1 (#1469)
Browse files Browse the repository at this point in the history
* chore(deps): Bump csharpier from 0.28.2 to 0.29.1

Bumps [csharpier](https://github.com/belav/csharpier) from 0.28.2 to 0.29.1.
- [Release notes](https://github.com/belav/csharpier/releases)
- [Changelog](https://github.com/belav/csharpier/blob/main/CHANGELOG.md)
- [Commits](belav/csharpier@0.28.2...0.29.1)

---
updated-dependencies:
- dependency-name: csharpier
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* csharpier format

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: latonz <[email protected]>
  • Loading branch information
dependabot[bot] and latonz authored Aug 28, 2024
1 parent c7a3b95 commit 17ba733
Show file tree
Hide file tree
Showing 77 changed files with 349 additions and 349 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]
},
"csharpier": {
"version": "0.28.2",
"version": "0.29.1",
"commands": [
"dotnet-csharpier"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static string GetDirectoryRelativePath(string projectPath, [CallerFilePa

var generator = new MapperGenerator().AsSourceGenerator();

var driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: (CSharpParseOptions)project.ParseOptions!);
var driver = CSharpGeneratorDriver.Create([generator], parseOptions: (CSharpParseOptions)project.ParseOptions!);

return (compilation, driver);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/Riok.Mapperly.Sample/Car.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Car

public Manufacturer? Manufacturer { get; set; }

public List<Tire> Tires { get; } = new List<Tire>();
public List<Tire> Tires { get; } = [];
}

public enum CarColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public enum PropertyNameMappingStrategy
/// <summary>
/// Matches a property by its name in case insensitive manner.
/// </summary>
CaseInsensitive
CaseInsensitive,
}
2 changes: 1 addition & 1 deletion src/Riok.Mapperly.Abstractions/RequiredMappingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ public enum RequiredMappingStrategy
/// <summary>
/// Warnings are emitted for unmapped target members but not for source members.
/// </summary>
Target = 1 << 1
Target = 1 << 1,
}
13 changes: 7 additions & 6 deletions src/Riok.Mapperly/Configuration/AttributeDataAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,19 @@ IReadOnlyList<AttributeArgumentSyntax> argumentSyntax
{
return arg.Kind switch
{
_ when (targetType == typeof(AttributeValue?) || targetType == typeof(AttributeValue)) && syntax != null
=> new AttributeValue(arg, syntax.Expression),
_ when (targetType == typeof(AttributeValue?) || targetType == typeof(AttributeValue)) && syntax != null => new AttributeValue(
arg,
syntax.Expression
),
_ when arg.IsNull => null,
_ when targetType == typeof(StringMemberPath) => CreateMemberPath(arg, syntax),
TypedConstantKind.Enum => GetEnumValue(arg, targetType),
TypedConstantKind.Array => BuildArrayValue(arg, targetType),
TypedConstantKind.Primitive => arg.Value,
TypedConstantKind.Type when targetType == typeof(ITypeSymbol) => arg.Value,
_
=> throw new ArgumentOutOfRangeException(
$"{nameof(AttributeDataAccessor)} does not support constructor arguments of kind {arg.Kind.ToString()} or cannot convert it to {targetType}"
),
_ => throw new ArgumentOutOfRangeException(
$"{nameof(AttributeDataAccessor)} does not support constructor arguments of kind {arg.Kind.ToString()} or cannot convert it to {targetType}"
),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public IEnumerable<string> GetMembersWithExplicitConfigurations(MappingSourceTar
var members = sourceTarget switch
{
MappingSourceTarget.Source => ExplicitMappings.Where(x => x.Source.Path.Count > 0).Select(x => x.Source.Path[0]),
MappingSourceTarget.Target
=> ExplicitMappings.Select(x => x.Target.Path[0]).Concat(ValueMappings.Select(x => x.Target.Path[0])),
MappingSourceTarget.Target => ExplicitMappings
.Select(x => x.Target.Path[0])
.Concat(ValueMappings.Select(x => x.Target.Path[0])),
_ => throw new ArgumentOutOfRangeException(nameof(sourceTarget), sourceTarget, "Neither source or target"),
};
return members.Distinct();
Expand Down
191 changes: 89 additions & 102 deletions src/Riok.Mapperly/Descriptors/Enumerables/CollectionInfoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ private readonly record struct CollectionTypeInfo(

private static readonly CollectionTypeInfo _collectionTypeInfoArray = new(CollectionType.Array);

private static readonly IReadOnlyCollection<CollectionTypeInfo> _collectionTypeInfos = new[]
{
private static readonly IReadOnlyCollection<CollectionTypeInfo> _collectionTypeInfos =
[
new CollectionTypeInfo(CollectionType.IEnumerable, typeof(IEnumerable<>)),
new CollectionTypeInfo(CollectionType.List, typeof(List<>), nameof(List<object>.Add)),
new CollectionTypeInfo(CollectionType.Stack, typeof(Stack<>), nameof(Stack<object>.Push)),
Expand Down Expand Up @@ -64,7 +64,7 @@ private readonly record struct CollectionTypeInfo(
new CollectionTypeInfo(CollectionType.ReadOnlySpan, typeof(ReadOnlySpan<>)),
new CollectionTypeInfo(CollectionType.Memory, typeof(Memory<>)),
new CollectionTypeInfo(CollectionType.ReadOnlyMemory, typeof(ReadOnlyMemory<>)),
};
];

private static readonly IReadOnlyDictionary<CollectionType, Type> _collectionClrTypeByType = _collectionTypeInfos
.Where(x => x.ReflectionType != null)
Expand Down Expand Up @@ -267,128 +267,115 @@ private static CollectionType GetImplementedCollectionTypes(WellKnownTypes types
// when collectionType is None then manually check for implemented types with IterateImplementedTypes
return collectionType switch
{
CollectionType.Array
=> CollectionType.Array
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.Array => CollectionType.Array
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.IEnumerable => CollectionType.IEnumerable,
CollectionType.List
=> CollectionType.List
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.List => CollectionType.List
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.Stack => CollectionType.Stack | CollectionType.IReadOnlyCollection | CollectionType.IEnumerable,
CollectionType.Queue => CollectionType.Queue | CollectionType.IReadOnlyCollection | CollectionType.IEnumerable,
CollectionType.IReadOnlyCollection => CollectionType.IReadOnlyCollection | CollectionType.IEnumerable,
CollectionType.IList => CollectionType.IList | CollectionType.ICollection | CollectionType.IEnumerable,
CollectionType.IReadOnlyList => CollectionType.IReadOnlyList | CollectionType.IReadOnlyCollection | CollectionType.IEnumerable,
CollectionType.ICollection => CollectionType.ICollection | CollectionType.IEnumerable,
CollectionType.HashSet
=> CollectionType.HashSet
| CollectionType.ISet
| CollectionType.IReadOnlySet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.SortedSet
=> CollectionType.SortedSet
| CollectionType.ISet
| CollectionType.IReadOnlySet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.HashSet => CollectionType.HashSet
| CollectionType.ISet
| CollectionType.IReadOnlySet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.SortedSet => CollectionType.SortedSet
| CollectionType.ISet
| CollectionType.IReadOnlySet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ISet => CollectionType.ISet | CollectionType.ICollection | CollectionType.IEnumerable,
CollectionType.IReadOnlySet => CollectionType.IReadOnlySet | CollectionType.IReadOnlyCollection | CollectionType.IEnumerable,
CollectionType.IDictionary => CollectionType.IDictionary | CollectionType.ICollection | CollectionType.IEnumerable,
CollectionType.IReadOnlyDictionary
=> CollectionType.IReadOnlyDictionary | CollectionType.IReadOnlyCollection | CollectionType.IEnumerable,
CollectionType.Dictionary
=> CollectionType.Dictionary
| CollectionType.IDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,

CollectionType.ImmutableArray
=> CollectionType.ImmutableArray
| CollectionType.IImmutableList
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableList
=> CollectionType.ImmutableList
| CollectionType.IImmutableList
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.IImmutableList
=> CollectionType.IImmutableList
| CollectionType.IReadOnlyList
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableHashSet
=> CollectionType.ImmutableHashSet
| CollectionType.IImmutableSet
| CollectionType.IReadOnlySet
| CollectionType.ISet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.IReadOnlyDictionary => CollectionType.IReadOnlyDictionary
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.Dictionary => CollectionType.Dictionary
| CollectionType.IDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,

CollectionType.ImmutableArray => CollectionType.ImmutableArray
| CollectionType.IImmutableList
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableList => CollectionType.ImmutableList
| CollectionType.IImmutableList
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.IImmutableList => CollectionType.IImmutableList
| CollectionType.IReadOnlyList
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableHashSet => CollectionType.ImmutableHashSet
| CollectionType.IImmutableSet
| CollectionType.IReadOnlySet
| CollectionType.ISet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.IImmutableSet => CollectionType.IImmutableSet | CollectionType.IReadOnlyCollection | CollectionType.IEnumerable,
CollectionType.ImmutableSortedSet
=> CollectionType.ImmutableSortedSet
| CollectionType.IImmutableSet
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ISet
| CollectionType.IReadOnlySet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableSortedSet => CollectionType.ImmutableSortedSet
| CollectionType.IImmutableSet
| CollectionType.IList
| CollectionType.IReadOnlyList
| CollectionType.ISet
| CollectionType.IReadOnlySet
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableQueue => CollectionType.ImmutableQueue | CollectionType.IImmutableQueue | CollectionType.IEnumerable,
CollectionType.IImmutableQueue => CollectionType.IImmutableQueue | CollectionType.IEnumerable,
CollectionType.ImmutableStack => CollectionType.ImmutableStack | CollectionType.IImmutableStack | CollectionType.IEnumerable,
CollectionType.IImmutableStack => CollectionType.IImmutableStack | CollectionType.IEnumerable,
CollectionType.ImmutableDictionary
=> CollectionType.ImmutableDictionary
| CollectionType.IImmutableDictionary
| CollectionType.IDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.IImmutableDictionary
=> CollectionType.IImmutableDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableSortedDictionary
=> CollectionType.ImmutableSortedDictionary
| CollectionType.IImmutableDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableDictionary => CollectionType.ImmutableDictionary
| CollectionType.IImmutableDictionary
| CollectionType.IDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.ICollection
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.IImmutableDictionary => CollectionType.IImmutableDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.ImmutableSortedDictionary => CollectionType.ImmutableSortedDictionary
| CollectionType.IImmutableDictionary
| CollectionType.IReadOnlyDictionary
| CollectionType.IReadOnlyCollection
| CollectionType.IEnumerable,
CollectionType.Span => CollectionType.Span,
CollectionType.ReadOnlySpan => CollectionType.ReadOnlySpan,
CollectionType.Memory => CollectionType.Memory,
CollectionType.ReadOnlyMemory => CollectionType.ReadOnlyMemory,

// check for if the type is a string, returning IEnumerable
CollectionType.None when type.SpecialType == SpecialType.System_String
=> CollectionType.IEnumerable,
CollectionType.None when type.SpecialType == SpecialType.System_String => CollectionType.IEnumerable,

// fallback for CollectionType.None, manually checking for known implemented types
_ => IterateImplementedTypes(type, types)
_ => IterateImplementedTypes(type, types),
};

static CollectionType IterateImplementedTypes(ITypeSymbol type, WellKnownTypes types)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ private static IEnumerable<IUserMapping> ValidateAndExtractExternalInstanceMappi
};

if (type == null)
return Enumerable.Empty<IUserMapping>();
return [];

if (nullableAnnotation != NullableAnnotation.Annotated)
return UserMethodMappingExtractor.ExtractUserImplementedMappings(ctx, type, name, isStatic: false, isExternal: true);

ctx.ReportDiagnostic(DiagnosticDescriptors.ExternalMapperMemberCannotBeNullable, symbol, symbol.ToDisplayString());
return Enumerable.Empty<IUserMapping>();
return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,16 @@ private INewInstanceMapping TryInlineMapping(INewInstanceMapping mapping)
return mapping switch
{
// inline existing mapping
UserImplementedMethodMapping implementedMapping
=> InlineExpressionMappingBuilder.TryBuildMapping(this, implementedMapping) ?? implementedMapping,
UserImplementedMethodMapping implementedMapping => InlineExpressionMappingBuilder.TryBuildMapping(this, implementedMapping)
?? implementedMapping,

// build an inlined version
IUserMapping userMapping
=> BuildMapping(
userMapping,
new TypeMappingKey(userMapping),
MappingBuildingOptions.Default,
userMapping.Method.GetSyntaxLocation()
) ?? mapping,
IUserMapping userMapping => BuildMapping(
userMapping,
new TypeMappingKey(userMapping),
MappingBuildingOptions.Default,
userMapping.Method.GetSyntaxLocation()
) ?? mapping,

_ => mapping,
};
Expand Down
4 changes: 2 additions & 2 deletions src/Riok.Mapperly/Descriptors/MapperDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class MapperDescriptor
private const string AccessorClassName = "UnsafeAccessor";

private readonly MapperDeclaration _declaration;
private readonly List<MethodMapping> _methodMappings = new();
private readonly List<IUnsafeAccessor> _unsafeAccessors = new();
private readonly List<MethodMapping> _methodMappings = [];
private readonly List<IUnsafeAccessor> _unsafeAccessors = [];

public bool Static { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class MembersContainerBuilderContext<T>(MappingBuilderContext builderCont
where T : IMemberAssignmentTypeMapping
{
private readonly Dictionary<MemberPath, MemberNullDelegateAssignmentMapping> _nullDelegateMappings = new();
private readonly HashSet<MemberPath> _initializedNullableTargetPaths = new();
private readonly HashSet<MemberPath> _initializedNullableTargetPaths = [];

public void AddMemberAssignmentMapping(IMemberAssignmentMapping memberMapping) => AddMemberAssignmentMapping(Mapping, memberMapping);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static class MemberMappingBuilder
public enum CodeStyle
{
Expression,
Statement
Statement,
}

public static bool TryBuildContainerAssignment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static bool TryBuildConstructorMapping(
[NotNullWhen(true)] out List<ConstructorParameterMapping>? constructorParameterMappings
)
{
constructorParameterMappings = new List<ConstructorParameterMapping>();
constructorParameterMappings = [];

var skippedOptionalParam = false;
foreach (var parameter in ctor.Parameters)
Expand Down
Loading

0 comments on commit 17ba733

Please sign in to comment.