Skip to content

Commit 2376a46

Browse files
committed
Separate code-gen from runtime.
1 parent fc5a3f3 commit 2376a46

File tree

77 files changed

+264
-217
lines changed

Some content is hidden

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

77 files changed

+264
-217
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Represents the **NuGet** versions.
44

5+
## v2.3.0
6+
- *Enhancement:* Separated the code-generation tooling logic out into a separate package `NTangle.CodeGen` as this is not required to be deployed with the underlying runtime logic. This is a **breaking change**, in that previous references will need to be updated to the new package.
7+
- *Fixed:* Entity code-generation now correctly references the actual underlying table name versus the alias.
8+
59
## v2.2.3
610
- *Fixed:* Joins without `IdentifierMapping` were incorrectly generated with mapping code where the root table has mapping, and the joined table did not. The `GlobalId` JSON name can now also be renamed.
711

Common.targets

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Version>2.3.0</Version>
4+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
5+
<Authors>NTangle Developers</Authors>
6+
<Company>Avanade</Company>
7+
<LangVersion>preview</LangVersion>
8+
<Copyright>Avanade (c)</Copyright>
9+
<PackageProjectUrl>https://github.com/Avanade/NTangle</PackageProjectUrl>
10+
<RepositoryUrl>https://github.com/Avanade/NTangle</RepositoryUrl>
11+
<Product>NTangle</Product>
12+
<SignAssembly>true</SignAssembly>
13+
<DelaySign>false</DelaySign>
14+
<AssemblyOriginatorKeyFile>strong-name-key.snk</AssemblyOriginatorKeyFile>
15+
<PackageIconUrl>https://github.com/Avanade/NTangle/raw/main/images/Logo256x256.png</PackageIconUrl>
16+
<PackageIcon>Logo256x256.png</PackageIcon>
17+
<RepositoryType>git</RepositoryType>
18+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
19+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
20+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
21+
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
22+
<Nullable>enable</Nullable>
23+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
24+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
25+
<IncludeSymbols>true</IncludeSymbols>
26+
<EmbedAllSources>true</EmbedAllSources>
27+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
28+
</PropertyGroup>
29+
30+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
31+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
32+
<WarningsAsErrors />
33+
</PropertyGroup>
34+
35+
<ItemGroup>
36+
<None Include="..\..\images\Logo256x256.png" Link="Logo256x256.png">
37+
<PackagePath>\</PackagePath>
38+
<Pack>true</Pack>
39+
</None>
40+
</ItemGroup>
41+
</Project>

NTangle.sln

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
.gitignore = .gitignore
1313
CHANGELOG.md = CHANGELOG.md
1414
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
15+
Common.targets = Common.targets
1516
CONTRIBUTING.md = CONTRIBUTING.md
1617
LICENSE = LICENSE
1718
nuget-publish.ps1 = nuget-publish.ps1
@@ -90,6 +91,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7596959A-8
9091
samples\ContactSync\docs\old-app-setup.md = samples\ContactSync\docs\old-app-setup.md
9192
EndProjectSection
9293
EndProject
94+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTangle.CodeGen", "tools\NTangle.CodeGen\NTangle.CodeGen.csproj", "{BB87378A-0444-4BDC-8530-20F25D852C77}"
95+
EndProject
9396
Global
9497
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9598
Debug|Any CPU = Debug|Any CPU
@@ -148,6 +151,10 @@ Global
148151
{D6364CFB-DAAA-41E7-996F-8F1654EECF10}.Debug|Any CPU.Build.0 = Debug|Any CPU
149152
{D6364CFB-DAAA-41E7-996F-8F1654EECF10}.Release|Any CPU.ActiveCfg = Release|Any CPU
150153
{D6364CFB-DAAA-41E7-996F-8F1654EECF10}.Release|Any CPU.Build.0 = Release|Any CPU
154+
{BB87378A-0444-4BDC-8530-20F25D852C77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
155+
{BB87378A-0444-4BDC-8530-20F25D852C77}.Debug|Any CPU.Build.0 = Debug|Any CPU
156+
{BB87378A-0444-4BDC-8530-20F25D852C77}.Release|Any CPU.ActiveCfg = Release|Any CPU
157+
{BB87378A-0444-4BDC-8530-20F25D852C77}.Release|Any CPU.Build.0 = Release|Any CPU
151158
EndGlobalSection
152159
GlobalSection(SolutionProperties) = preSolution
153160
HideSolutionNode = FALSE
@@ -171,6 +178,7 @@ Global
171178
{4BADE51C-EA1C-4A68-B591-8F148F5FF975} = {6855FFC2-39E7-48D4-AB5D-079D406390FC}
172179
{D6364CFB-DAAA-41E7-996F-8F1654EECF10} = {6855FFC2-39E7-48D4-AB5D-079D406390FC}
173180
{7596959A-8A5E-409D-BED5-006950299A4E} = {240EFA31-7366-47BD-8A56-B3312D06BB13}
181+
{BB87378A-0444-4BDC-8530-20F25D852C77} = {780B69CA-D467-45CF-B115-A3FEB0B88BD1}
174182
EndGlobalSection
175183
GlobalSection(ExtensibilityGlobals) = postSolution
176184
SolutionGuid = {B97E5639-3430-4AD7-9942-D35EF26F263B}

nuget-publish.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ param(
4949
[string]$NugetCacheFolder = "$($env:USERPROFILE)\.nuget\packages",
5050
[String[]]$ProjectsToPublish = @(
5151
"src\NTangle",
52+
"tools\NTangle.CodeGen",
5253
"tools\NTangle.Template")
5354
)
5455

samples/ContactSync/ContactSync.OldApp/ContactSync.OldApp.CodeGen/ContactSync.OldApp.CodeGen.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Nullable>enable</Nullable>
66
</PropertyGroup>
77
<ItemGroup>
8-
<ProjectReference Include="..\..\..\..\src\NTangle\NTangle.csproj" />
8+
<ProjectReference Include="..\..\..\..\tools\NTangle.CodeGen\NTangle.CodeGen.csproj" />
99
</ItemGroup>
1010
<ItemGroup>
1111
<None Update="ntangle.yaml">

samples/ContactSync/ContactSync.OldApp/ContactSync.OldApp.CodeGen/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NTangle.Console;
1+
using NTangle.CodeGen;
22
using System.Threading.Tasks;
33

44
namespace ContactSync.OldApp.CodeGen;

samples/ContactSync/ContactSync.OldApp/ContactSync.OldApp.Database/ContactSync.OldApp.Database.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<ProjectReference Include="..\..\..\..\src\NTangle\NTangle.csproj" />
16+
<PackageReference Include="DbEx.SqlServer" Version="2.3.7" />
1717
</ItemGroup>
1818

1919
</Project>

samples/ContactSync/ContactSync.OldApp/ContactSync.OldApp.Publisher/Entities/Generated/ContactCdc.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,48 @@
55
namespace ContactSync.OldApp.Publisher.Entities;
66

77
/// <summary>
8-
/// Represents the CDC model for the root (parent) database table '[old].[Contact]'.
8+
/// Represents the CDC model for the root (parent) database table '[old].[contact]'.
99
/// </summary>
1010
public partial class ContactCdc : IEntity
1111
{
1212
/// <summary>
13-
/// Gets or sets the Id '[old].[Contact].[contact_id]' column value.
13+
/// Gets or sets the Id '[old].[contact].[contact_id]' column value.
1414
/// </summary>
1515
[JsonPropertyName("id")]
1616
public int Id { get; set; }
1717

1818
/// <summary>
19-
/// Gets or sets the Name '[old].[Contact].[contact_name]' column value.
19+
/// Gets or sets the Name '[old].[contact].[contact_name]' column value.
2020
/// </summary>
2121
[JsonPropertyName("name")]
2222
public string? Name { get; set; }
2323

2424
/// <summary>
25-
/// Gets or sets the Phone '[old].[Contact].[contact_phone]' column value.
25+
/// Gets or sets the Phone '[old].[contact].[contact_phone]' column value.
2626
/// </summary>
2727
[JsonPropertyName("phone")]
2828
public string? Phone { get; set; }
2929

3030
/// <summary>
31-
/// Gets or sets the Email '[old].[Contact].[contact_email]' column value.
31+
/// Gets or sets the Email '[old].[contact].[contact_email]' column value.
3232
/// </summary>
3333
[JsonPropertyName("email")]
3434
public string? Email { get; set; }
3535

3636
/// <summary>
37-
/// Gets or sets the Is Active '[old].[Contact].[contact_active]' column value.
37+
/// Gets or sets the Is Active '[old].[contact].[contact_active]' column value.
3838
/// </summary>
3939
[JsonPropertyName("isActive")]
4040
public bool? IsActive { get; set; }
4141

4242
/// <summary>
43-
/// Gets or sets the No Call List '[old].[Contact].[contact_no_calling]' column value.
43+
/// Gets or sets the No Call List '[old].[contact].[contact_no_calling]' column value.
4444
/// </summary>
4545
[JsonPropertyName("noCallList")]
4646
public bool? NoCallList { get; set; }
4747

4848
/// <summary>
49-
/// Gets or sets the Contact Addressid '[old].[Contact].[contact_addressid]' column value.
49+
/// Gets or sets the Contact Addressid '[old].[contact].[contact_addressid]' column value.
5050
/// </summary>
5151
[JsonIgnore]
5252
public int? ContactAddressid { get; set; }
@@ -73,19 +73,19 @@ public partial class ContactCdc : IEntity
7373
public partial class AddressCdc : IPrimaryKey
7474
{
7575
/// <summary>
76-
/// Gets or sets the Id '[old].[Address].[contact_address_id]' column value. This column is used within the join.
76+
/// Gets or sets the Id '[old].[contact_address].[contact_address_id]' column value. This column is used within the join.
7777
/// </summary>
7878
[JsonIgnore]
7979
public int Id { get; set; }
8080

8181
/// <summary>
82-
/// Gets or sets the Street1 '[old].[Address].[address_street_1]' column value.
82+
/// Gets or sets the Street1 '[old].[contact_address].[address_street_1]' column value.
8383
/// </summary>
8484
[JsonPropertyName("street1")]
8585
public string? Street1 { get; set; }
8686

8787
/// <summary>
88-
/// Gets or sets the Street2 '[old].[Address].[address_street_2]' column value.
88+
/// Gets or sets the Street2 '[old].[contact_address].[address_street_2]' column value.
8989
/// </summary>
9090
[JsonPropertyName("street2")]
9191
public string? Street2 { get; set; }
@@ -96,7 +96,7 @@ public partial class AddressCdc : IPrimaryKey
9696
}
9797

9898
/// <summary>
99-
/// Represents the CDC model collection for the related (child) database table '[old].[Address]'.
99+
/// Represents the CDC model collection for the related (child) database table '[old].[contact_address]'.
100100
/// </summary>
101101
public partial class AddressCdcCollection : List<AddressCdc> { }
102102

samples/SqlServerDemo/SqlServerDemo.CodeGen/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NTangle.Console;
1+
using NTangle.CodeGen;
22
using System.Threading.Tasks;
33

44
namespace SqlServerDemo.CodeGen;

samples/SqlServerDemo/SqlServerDemo.CodeGen/SqlServerDemo.CodeGen.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<ProjectReference Include="..\..\..\src\NTangle\NTangle.csproj" />
9+
<ProjectReference Include="..\..\..\tools\NTangle.CodeGen\NTangle.CodeGen.csproj" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

samples/SqlServerDemo/SqlServerDemo.Database/SqlServerDemo.Database.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\..\..\src\NTangle\NTangle.csproj" />
20+
<PackageReference Include="DbEx.SqlServer" Version="2.3.7" />
2121
</ItemGroup>
2222

2323
</Project>

samples/SqlServerDemo/SqlServerDemo.Publisher/Entities/Generated/CustomerCdc.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55
namespace SqlServerDemo.Publisher.Entities;
66

77
/// <summary>
8-
/// Represents the CDC model for the root (parent) database table '[Legacy].[Customer]'.
8+
/// Represents the CDC model for the root (parent) database table '[Legacy].[Cust]'.
99
/// </summary>
1010
public partial class CustomerCdc : IEntity, ILogicallyDeletedExtended
1111
{
1212
/// <summary>
13-
/// Gets or sets the Id '[Legacy].[Customer].[CustId]' column value.
13+
/// Gets or sets the Id '[Legacy].[Cust].[CustId]' column value.
1414
/// </summary>
1515
[JsonPropertyName("id")]
1616
public int Id { get; set; }
1717

1818
/// <summary>
19-
/// Gets or sets the Name '[Legacy].[Customer].[Name]' column value.
19+
/// Gets or sets the Name '[Legacy].[Cust].[Name]' column value.
2020
/// </summary>
2121
[JsonPropertyName("name")]
2222
public string? Name { get; set; }
2323

2424
/// <summary>
25-
/// Gets or sets the Email '[Legacy].[Customer].[Email]' column value.
25+
/// Gets or sets the Email '[Legacy].[Cust].[Email]' column value.
2626
/// </summary>
2727
[JsonPropertyName("email")]
2828
public string? Email { get; set; }
2929

3030
/// <summary>
31-
/// Gets or sets the Is Deleted '[Legacy].[Customer].[is-deleted]' column value.
31+
/// Gets or sets the Is Deleted '[Legacy].[Cust].[is-deleted]' column value.
3232
/// </summary>
3333
[JsonPropertyName("isDeleted")]
3434
public bool? IsDeleted { get; set; }
3535

3636
/// <summary>
37-
/// Gets or sets the Row Version '[Legacy].[Customer].[RowVersion]' column value.
37+
/// Gets or sets the Row Version '[Legacy].[Cust].[RowVersion]' column value.
3838
/// </summary>
3939
[JsonPropertyName("rowVersion")]
4040
public byte[]? RowVersion { get; set; }

samples/SqlServerDemo/SqlServerDemo.Publisher/Entities/Generated/PostCdc.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,25 @@ public partial class CommentCdcCollection : List<CommentCdc> { }
104104
public partial class CommentsTagsCdc : IPrimaryKey
105105
{
106106
/// <summary>
107-
/// Gets or sets the Tags Id '[Legacy].[CommentsTags].[TagsId]' column value.
107+
/// Gets or sets the Tags Id '[Legacy].[Tags].[TagsId]' column value.
108108
/// </summary>
109109
[JsonPropertyName("tagsId")]
110110
public int TagsId { get; set; }
111111

112112
/// <summary>
113-
/// Gets or sets the Parent Type '[Legacy].[CommentsTags].[ParentType]' column value. This column is used within the join.
113+
/// Gets or sets the Parent Type '[Legacy].[Tags].[ParentType]' column value. This column is used within the join.
114114
/// </summary>
115115
[JsonIgnore]
116116
public string? ParentType { get; set; }
117117

118118
/// <summary>
119-
/// Gets or sets the Parent Id '[Legacy].[CommentsTags].[ParentId]' column value. This column is used within the join.
119+
/// Gets or sets the Parent Id '[Legacy].[Tags].[ParentId]' column value. This column is used within the join.
120120
/// </summary>
121121
[JsonIgnore]
122122
public int ParentId { get; set; }
123123

124124
/// <summary>
125-
/// Gets or sets the Text '[Legacy].[CommentsTags].[Text]' column value.
125+
/// Gets or sets the Text '[Legacy].[Tags].[Text]' column value.
126126
/// </summary>
127127
[JsonPropertyName("text")]
128128
public string? Text { get; set; }
@@ -139,7 +139,7 @@ public partial class CommentsTagsCdc : IPrimaryKey
139139
}
140140

141141
/// <summary>
142-
/// Represents the CDC model collection for the related (child) database table '[Legacy].[CommentsTags]'.
142+
/// Represents the CDC model collection for the related (child) database table '[Legacy].[Tags]'.
143143
/// </summary>
144144
public partial class CommentsTagsCdcCollection : List<CommentsTagsCdc> { }
145145

@@ -153,25 +153,25 @@ public partial class CommentsTagsCdcCollection : List<CommentsTagsCdc> { }
153153
public partial class PostsTagsCdc : IPrimaryKey
154154
{
155155
/// <summary>
156-
/// Gets or sets the Tags Id '[Legacy].[PostsTags].[TagsId]' column value.
156+
/// Gets or sets the Tags Id '[Legacy].[Tags].[TagsId]' column value.
157157
/// </summary>
158158
[JsonPropertyName("tagsId")]
159159
public int TagsId { get; set; }
160160

161161
/// <summary>
162-
/// Gets or sets the Parent Type '[Legacy].[PostsTags].[ParentType]' column value. This column is used within the join.
162+
/// Gets or sets the Parent Type '[Legacy].[Tags].[ParentType]' column value. This column is used within the join.
163163
/// </summary>
164164
[JsonIgnore]
165165
public string? ParentType { get; set; }
166166

167167
/// <summary>
168-
/// Gets or sets the Posts Id '[Legacy].[PostsTags].[ParentId]' column value. This column is used within the join.
168+
/// Gets or sets the Posts Id '[Legacy].[Tags].[ParentId]' column value. This column is used within the join.
169169
/// </summary>
170170
[JsonIgnore]
171171
public int PostsId { get; set; }
172172

173173
/// <summary>
174-
/// Gets or sets the Text '[Legacy].[PostsTags].[Text]' column value.
174+
/// Gets or sets the Text '[Legacy].[Tags].[Text]' column value.
175175
/// </summary>
176176
[JsonPropertyName("text")]
177177
public string? Text { get; set; }
@@ -182,7 +182,7 @@ public partial class PostsTagsCdc : IPrimaryKey
182182
}
183183

184184
/// <summary>
185-
/// Represents the CDC model collection for the related (child) database table '[Legacy].[PostsTags]'.
185+
/// Represents the CDC model collection for the related (child) database table '[Legacy].[Tags]'.
186186
/// </summary>
187187
public partial class PostsTagsCdcCollection : List<PostsTagsCdc> { }
188188

samples/SqlServerDemo/SqlServerDemo.Test/SqlServerDemo.Test.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="DbEx.SqlServer" Version="2.3.7" />
1011
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
1112
<PackageReference Include="NUnit" Version="3.13.3" />
1213
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />

0 commit comments

Comments
 (0)