Skip to content

Commit 7851c08

Browse files
committed
update packages, add generic attribute
1 parent 8b23b77 commit 7851c08

File tree

16 files changed

+118
-38
lines changed

16 files changed

+118
-38
lines changed

src/FluentCommand.Batch/FluentCommand.Batch.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
13-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
13+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

src/FluentCommand.Dapper/FluentCommand.Dapper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Dapper" Version="2.0.123" />
9+
<PackageReference Include="Dapper" Version="2.0.143" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

src/FluentCommand.Generators/DataReaderFactoryGenerator.cs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System;
12
using System.Collections.Immutable;
3+
using System.Reflection;
24

35
using FluentCommand.Generators.Internal;
46
using FluentCommand.Generators.Models;
@@ -143,10 +145,13 @@ private static EntityContext SemanticTransform(GeneratorAttributeSyntaxContext c
143145

144146
private static EntityProperty CreateProperty(IPropertySymbol propertySymbol, string parameterName = null)
145147
{
148+
var propertyType = propertySymbol.Type.ToDisplayString();
149+
var propertyName = propertySymbol.Name;
150+
146151
// look for custom field converter
147152
var attributes = propertySymbol.GetAttributes();
148153
if (attributes == null || attributes.Length == 0)
149-
return new EntityProperty(propertySymbol.Name, propertySymbol.Type.ToDisplayString(), parameterName);
154+
return new EntityProperty(propertyName, propertyType, parameterName);
150155

151156
var converter = attributes
152157
.FirstOrDefault(a => a.AttributeClass is
@@ -156,17 +161,39 @@ private static EntityProperty CreateProperty(IPropertySymbol propertySymbol, str
156161
});
157162

158163
if (converter == null)
159-
return new EntityProperty(propertySymbol.Name, propertySymbol.Type.ToDisplayString(), parameterName);
164+
return new EntityProperty(propertyName, propertyType, parameterName);
160165

161-
var converterType = converter.ConstructorArguments.Single();
166+
// attribute contructor
167+
var converterType = converter.ConstructorArguments.FirstOrDefault();
162168
if (converterType.Value is INamedTypeSymbol converterSymbol)
169+
{
163170
return new EntityProperty(
164-
propertySymbol.Name,
165-
propertySymbol.Type.ToDisplayString(),
171+
propertyName,
172+
propertyType,
166173
parameterName,
167174
converterSymbol.ToDisplayString());
175+
}
176+
177+
// generic attribute
178+
var attributeClass = converter.AttributeClass;
179+
if (attributeClass is { IsGenericType: true }
180+
&& attributeClass.TypeArguments.Length == attributeClass.TypeParameters.Length
181+
&& attributeClass.TypeArguments.Length == 1)
182+
{
183+
var typeArgument = attributeClass.TypeArguments[0];
184+
var converterString = typeArgument.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
185+
186+
return new EntityProperty(
187+
propertyName,
188+
propertyType,
189+
parameterName,
190+
converterString);
191+
}
168192

169-
return new EntityProperty(propertySymbol.Name, propertySymbol.Type.ToDisplayString(), parameterName);
193+
return new EntityProperty(
194+
propertyName,
195+
propertyType,
196+
parameterName);
170197
}
171198

172199
private static bool IsIncluded(IPropertySymbol propertySymbol)

src/FluentCommand.Generators/FluentCommand.Generators.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" PrivateAssets="all" />
20-
<PackageReference Include="ThisAssembly" Version="1.2.9" PrivateAssets="all" />
20+
<PackageReference Include="ThisAssembly" Version="1.3.0" PrivateAssets="all" />
2121
</ItemGroup>
2222

2323
</Project>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"profiles": {
3-
"FluentCommand.Entities": {
3+
"FluentCommand.Tests": {
44
"commandName": "DebugRoslynComponent",
5-
"targetProject": "..\\..\\test\\FluentCommand.Entities\\FluentCommand.Entities.csproj"
5+
"targetProject": "..\\..\\test\\FluentCommand.Tests\\FluentCommand.Tests.csproj"
66
}
77
}
88
}

src/FluentCommand.Json/FluentCommand.Json.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="System.Text.Json" Version="7.0.2" />
12+
<PackageReference Include="System.Text.Json" Version="7.0.3" />
1313
</ItemGroup>
1414

1515
</Project>

src/FluentCommand.SqlServer/FluentCommand.SqlServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="MicroSoft.Data.SqlClient" Version="5.1.0" />
12+
<PackageReference Include="MicroSoft.Data.SqlClient" Version="5.1.1" />
1313
</ItemGroup>
1414

1515
</Project>

src/FluentCommand/DataFieldConverterAttribute.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,19 @@ public DataFieldConverterAttribute(Type converterType)
2424
/// </value>
2525
public Type ConverterType { get; }
2626
}
27+
28+
#if NET7_0_OR_GREATER
29+
/// <summary>
30+
/// Attribute to enable source generation of data reader factory
31+
/// </summary>
32+
/// <typeparam name="TConverter">
33+
/// The type of the converter
34+
/// </typeparam>
35+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
36+
public class DataFieldConverterAttribute<TConverter> : DataFieldConverterAttribute
37+
{
38+
public DataFieldConverterAttribute() : base(typeof(TConverter))
39+
{
40+
}
41+
}
42+
#endif

test/FluentCommand.Batch.Tests/FluentCommand.Batch.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="coverlet.collector" Version="3.2.0">
9+
<PackageReference Include="coverlet.collector" Version="6.0.0">
1010
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1111
<PrivateAssets>all</PrivateAssets>
1212
</PackageReference>
1313
<PackageReference Include="DataGenerator" Version="5.0.0.178" />
1414
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
1515
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
1717
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2020
</PackageReference>
2121
<PackageReference Include="xunit" Version="2.4.2" />
22-
<PackageReference Include="FluentAssertions" Version="6.10.0" />
22+
<PackageReference Include="FluentAssertions" Version="6.11.0" />
2323
</ItemGroup>
2424

2525
<ItemGroup>

test/FluentCommand.Generators.Tests/FluentCommand.Generators.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="coverlet.collector" Version="3.2.0">
11+
<PackageReference Include="coverlet.collector" Version="6.0.0">
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
<PrivateAssets>all</PrivateAssets>
1414
</PackageReference>
15-
<PackageReference Include="FluentAssertions" Version="6.10.0" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
17-
<PackageReference Include="Verify.Xunit" Version="19.11.1" />
15+
<PackageReference Include="FluentAssertions" Version="6.11.0" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
17+
<PackageReference Include="Verify.Xunit" Version="20.4.0" />
1818
<PackageReference Include="xunit" Version="2.4.2" />
1919
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)