Skip to content

Commit 283eada

Browse files
committed
Compile accessor for multiple target frameworks to get rid of deprecated System.Data.SqlClient reference
1 parent a295a3f commit 283eada

58 files changed

Lines changed: 451 additions & 124 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ updates:
2626
interval: daily
2727
open-pull-requests-limit: 999
2828
rebase-strategy: disabled
29-
ignore:
30-
- dependency-name: System.Data.SqlClient # See reason in Directory.Packages.props
3129
groups:
3230
dotnet-packages-aligned-with-sdk-version:
3331
patterns:

Directory.Packages.props

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@
4444
<PackageVersion Include="Newtonsoft.Json.Schema" Version="4.0.1" />
4545
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
4646
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
47-
<!--
48-
Be careful to update this package, because the latest and last version makes the usage obsolete,
49-
recommending to use Microsoft.Data.SqlClient, which is perfectly reasonable.
50-
However, we currently compile artifacts using only one target framework (.NETStandard).
51-
Therefore we can't easily switch to Microsoft.Data.SqlClient, because the consumer might not be able to migrate easily.
52-
If the consumer compiles for .NET Framework, there is nothing to worry about, because System.Data is still supported,
53-
and the .NETStandard framework simply serves the purpose of API compatibility, the NuGet package itself will not be used.
54-
If the consumer compiles for .NET 8, he will use Microsoft.Data.SqlClient, because of compilation symbols.
55-
-->
56-
<PackageVersion Include="System.Data.SqlClient" Version="4.8.6" />
5747
<PackageVersion Include="System.Diagnostics.EventLog" Version="10.0.6" />
5848
<PackageVersion Include="System.IO.Packaging" Version="10.0.6" />
5949
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />

build/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ try
5151
'Dibix.Sdk.CodeGeneration'
5252
'Dibix.Sdk'
5353
'Dibix.Sdk.Cli'
54-
'Dibix.Testing'
5554
'Dibix.Testing.Generators'
55+
'Dibix.Testing'
5656
'Dibix.Worker.Abstractions'
5757
)
5858

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
using Microsoft.CodeAnalysis;
1+
using System.Reflection;
2+
using Microsoft.CodeAnalysis;
23

34
namespace Dibix
45
{
56
internal static class MetadataReferenceFactory
67
{
7-
public static MetadataReference FromType<T>() => MetadataReference.CreateFromFile(typeof(T).Assembly.Location);
8+
public static MetadataReference FromType<T>() => FromAssembly(typeof(T).Assembly);
9+
10+
public static MetadataReference FromAssembly(Assembly assembly) => MetadataReference.CreateFromFile(assembly.Location);
811
}
912
}

src/Dibix.Dapper/Dibix.Dapper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>
4+
<TargetFrameworks>net10.0;net48</TargetFrameworks>
55
<SignAssembly>true</SignAssembly>
66
</PropertyGroup>
77

src/Dibix.Http.Server.AspNet/Dibix.Http.Server.AspNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>net48</TargetFrameworks>
55
<SignAssembly>true</SignAssembly>
66
</PropertyGroup>
77

src/Dibix.Http.Server/Dibix.Http.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>
4+
<TargetFrameworks>net10.0;net48</TargetFrameworks>
55
<SignAssembly>true</SignAssembly>
66
</PropertyGroup>
77

src/Dibix.Sdk.CodeGeneration/Output/AccessorCodeGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ protected override IEnumerable<ArtifactWriterBase> SelectWriters(CodeGenerationM
2323
yield return new ApiControllerClassWriter(model);
2424
}
2525

26-
protected override IEnumerable<CSharpAnnotation> CollectGlobalAnnotations(CodeGenerationModel model)
26+
protected override IEnumerable<CSharpGlobalAnnotation> CollectGlobalAnnotations(CodeGenerationModel model)
2727
{
28-
yield return new CSharpAnnotation("ArtifactAssembly");
28+
yield return new CSharpGlobalAnnotation("ArtifactAssembly");
2929
}
3030

3131
protected override void OnContextCreated(CodeGenerationContext context)

src/Dibix.Sdk.CodeGeneration/Output/ApiClientWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override void Write(CodeGenerationContext context)
3030

3131
IDictionary<string, SecurityScheme> securitySchemeMap = context.Model.SecuritySchemes.ToDictionary(x => x.SchemeName);
3232

33-
CSharpStatementScope output = context.CreateOutputScope();
33+
CSharpStatementScope output = context.Namespace();
3434
for (int i = 0; i < controllers.Count; i++)
3535
{
3636
ControllerDefinition controller = controllers[i];

src/Dibix.Sdk.CodeGeneration/Output/ApiControllerClassWriter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public override void Write(CodeGenerationContext context)
3434
{
3535
context.AddUsing("Dibix");
3636

37-
CSharpStatementScope scope = context.CreateOutputScope();
37+
CSharpStatementScope scope = context.PreProcessorDirective(PreprocessorDirective.IfNetFramework)
38+
.Namespace(context.CurrentNamespace);
39+
3840
foreach (KeyValuePair<string, IList<ReflectionActionDescriptor>> entry in _map)
3941
{
4042
string className = $"{entry.Key}Base";

0 commit comments

Comments
 (0)