Skip to content

Commit dcb6077

Browse files
committed
Angular
- undefined optional service parameters fixed Core - beforeBuild added - treat empty files like not existing files on overwriting
1 parent ffcb390 commit dcb6077

Some content is hidden

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

42 files changed

+152
-116
lines changed

Angular/KY.Generator.Angular.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Authors>KY-Programming</Authors>
66
<Company>KY-Programming</Company>
77
<Product>KY.Generator</Product>
8-
<Version>3.1.0</Version>
8+
<Version>3.2.0</Version>
99
<Copyright>2019 - KY-Programming</Copyright>
1010
<Description>Angular Module for KY-Generator
1111
Download KY.Generator.CLI to use this module</Description>

Angular/Writers/AngularServiceWriter.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public virtual void Write(AngularWriteConfiguration configuration, List<ITransfe
4040
string controllerName = controller.Name.TrimEnd("Controller");
4141
FileTemplate file = files.AddFile(configuration.Service.RelativePath, configuration.AddHeader, configuration.CheckOnOverwrite);
4242
ClassTemplate classTemplate = file.AddNamespace(string.Empty)
43-
.AddClass(configuration.Service.Name?.Replace("{0}", controllerName) ?? controllerName + "Service")
44-
.FormatName(configuration)
45-
.WithUsing(httpClient, httpClientImport)
46-
.WithUsing("Injectable", "@angular/core")
47-
.WithUsing("Observable", "rxjs")
48-
.WithUsing("Subject", "rxjs")
49-
.WithAttribute("Injectable", Code.AnonymousObject().WithProperty("providedIn", Code.String("root")));
43+
.AddClass(configuration.Service.Name?.Replace("{0}", controllerName) ?? controllerName + "Service")
44+
.FormatName(configuration)
45+
.WithUsing(httpClient, httpClientImport)
46+
.WithUsing("Injectable", "@angular/core")
47+
.WithUsing("Observable", "rxjs")
48+
.WithUsing("Subject", "rxjs")
49+
.WithAttribute("Injectable", Code.AnonymousObject().WithProperty("providedIn", Code.String("root")));
5050
FieldTemplate httpField = classTemplate.AddField("http", Code.Type(httpClient)).Readonly().FormatName(configuration);
5151
FieldTemplate serviceUrlField = classTemplate.AddField("serviceUrl", Code.Type("string")).Public().FormatName(configuration).Default(Code.String(string.Empty));
5252
classTemplate.AddConstructor().WithParameter(Code.Type(httpClient), "http")
@@ -109,7 +109,7 @@ public virtual void Write(AngularWriteConfiguration configuration, List<ITransfe
109109
}
110110
foreach (HttpServiceActionParameterTransferObject parameter in inlineParameters)
111111
{
112-
string[] chunks = uri.Split(new [] {$"{{{parameter.Name}}}"}, StringSplitOptions.RemoveEmptyEntries);
112+
string[] chunks = uri.Split(new[] { $"{{{parameter.Name}}}" }, StringSplitOptions.RemoveEmptyEntries);
113113
parameterUrl = parameterUrl.Append(Code.String(chunks[0])).Append(Code.Local(parameter.Name));
114114
uri = chunks.Length == 1 ? string.Empty : chunks[1];
115115
}
@@ -128,25 +128,23 @@ public virtual void Write(AngularWriteConfiguration configuration, List<ITransfe
128128
}
129129
foreach (HttpServiceActionParameterTransferObject parameter in urlParameters)
130130
{
131-
if (isFirst)
132-
{
133-
isFirst = false;
134-
parameterUrl = parameterUrl.Append(Code.Local(mapping[parameter]));
135-
}
136-
else
131+
string name = mapping[parameter].Name;
132+
if (!isFirst)
137133
{
138-
parameterUrl = parameterUrl.Append(Code.String($"&{parameter.Name}=")).Append(Code.Local(mapping[parameter]));
134+
parameterUrl = parameterUrl.Append(Code.String($"&{parameter.Name}="));
139135
}
136+
isFirst = false;
137+
parameterUrl = parameterUrl.Append(Code.TypeScript($"({name} === undefined ? \"\" : {name})"));
140138
}
141139

142140
methodTemplate.WithCode(
143141
Code.This()
144142
.Field(httpField)
145-
.Method(action.Type.ToString().ToLowerInvariant(),
146-
parameterUrl,
143+
.Method(action.Type.ToString().ToLowerInvariant(),
144+
parameterUrl,
147145
action.RequireBodyParameter ? Code.Local(action.Parameters.Single(x => x.FromBody).Name) : null,
148146
Code.Local("httpOptions")
149-
)
147+
)
150148
.Method("subscribe", Code.Lambda(hasReturnType ? "result" : null, code), errorCode).Close()
151149
);
152150
methodTemplate.WithCode(Code.Return(Code.Local("subject")));

AspDotNet/KY.Generator.AspDotNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Company>KY-Programming</Company>
66
<Authors>KY-Programming</Authors>
7-
<Version>3.1.0</Version>
7+
<Version>3.2.0</Version>
88
<Product>KY.Generator</Product>
99
<Description>ASP.net Module for KY-Generator
1010
Download KY.Generator.CLI to use this module</Description>

CLI.Core.Full/KY.Generator.CLI.Core.Full.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp2.2</TargetFramework>
6-
<Version>3.1.0</Version>
6+
<Version>3.2.0</Version>
77
<Authors>KY-Programming</Authors>
88
<Product>KY.Generator</Product>
99
<Copyright>2019 - KY-Programming</Copyright>

CLI.Core.Full/nuget.nuspec

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<metadata>
44
<id>KY.Generator.CLI.Core.Full</id>
55
<!-- Ensure nuget.targets version is also updated -->
6-
<version>3.1.0</version>
6+
<version>3.2.0</version>
77
<title>KY.Generator.CLI.Core.Full</title>
88
<authors>KY-Programming</authors>
99
<owners>KY-Programming</owners>
@@ -17,17 +17,17 @@ Generate classes from oData, .NET assembly, JSON or TSQL to C# or TypeScript. Su
1717
<copyright>Copyright 2019</copyright>
1818
<tags>KY-Generator KY Generator .netCore CLI</tags>
1919
<dependencies>
20-
<dependency id="KY.Generator.Angular" version="3.1.0" />
21-
<dependency id="KY.Generator.AspDotNet" version="3.1.0" />
22-
<dependency id="KY.Generator.Core" version="3.1.0" />
23-
<dependency id="KY.Generator.Csharp" version="3.1.0" />
24-
<dependency id="KY.Generator.EntityFramework" version="3.1.0" />
25-
<dependency id="KY.Generator.Json" version="3.1.0" />
26-
<dependency id="KY.Generator.OData" version="3.1.0" />
27-
<dependency id="KY.Generator.OpenApi" version="3.1.0" />
28-
<dependency id="KY.Generator.Reflection" version="3.1.0" />
29-
<dependency id="KY.Generator.Tsql" version="3.1.0" />
30-
<dependency id="KY.Generator.TypeScript" version="3.1.0" />
20+
<dependency id="KY.Generator.Angular" version="3.2.0" />
21+
<dependency id="KY.Generator.AspDotNet" version="3.2.0" />
22+
<dependency id="KY.Generator.Core" version="3.2.0" />
23+
<dependency id="KY.Generator.Csharp" version="3.2.0" />
24+
<dependency id="KY.Generator.EntityFramework" version="3.2.0" />
25+
<dependency id="KY.Generator.Json" version="3.2.0" />
26+
<dependency id="KY.Generator.OData" version="3.2.0" />
27+
<dependency id="KY.Generator.OpenApi" version="3.2.0" />
28+
<dependency id="KY.Generator.Reflection" version="3.2.0" />
29+
<dependency id="KY.Generator.Tsql" version="3.2.0" />
30+
<dependency id="KY.Generator.TypeScript" version="3.2.0" />
3131
</dependencies>
3232
</metadata>
3333
<files>

CLI.Core.Full/nuget.targets

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Target Name="KYGeneratorCLITarget" AfterTargets="Build">
4-
<Exec Command="dotnet %22%25USERPROFILE%25\.nuget\packages\ky.generator.cli.core.full\3.1.0\tools\KY.Generator.dll%22 %22$(ProjectDir)generator.json%22 %22$(ProjectDir)\%22 msbuild"
3+
<Target Name="KYGeneratorCLICoreFullBeforeTarget" BeforeTargets="Compile">
4+
<Exec Command="dotnet %22%25USERPROFILE%25\.nuget\packages\ky.generator.cli.core.full\3.2.0\tools\KY.Generator.dll%22 %22$(ProjectDir)generator.json%22 %22$(ProjectDir)\%22 msbuild"
55
CustomErrorRegularExpression="^Error:"
6-
CustomWarningRegularExpression="^Warning:"
7-
></Exec>
6+
CustomWarningRegularExpression="^Warning:"></Exec>
7+
</Target>
8+
<Target Name="KYGeneratorCLICoreFullTarget" AfterTargets="Build">
9+
<Exec Command="dotnet %22%25USERPROFILE%25\.nuget\packages\ky.generator.cli.core.full\3.2.0\tools\KY.Generator.dll%22 %22$(ProjectDir)generator.json%22 %22$(ProjectDir)\%22 msbuild"
10+
CustomErrorRegularExpression="^Error:"
11+
CustomWarningRegularExpression="^Warning:"></Exec>
812
</Target>
913
</Project>

CLI.Core.Minimal/KY.Generator.CLI.Core.Minimal.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp2.2</TargetFramework>
6-
<Version>3.1.0</Version>
6+
<Version>3.2.0</Version>
77
<Authors>KY-Programming</Authors>
88
<Product>KY.Generator</Product>
99
<Copyright>2019 - KY-Programming</Copyright>

CLI.Core.Minimal/nuget.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<metadata>
44
<id>KY.Generator.CLI.Core.Minimal</id>
55
<!-- Ensure nuget.targets version is also updated -->
6-
<version>3.1.0</version>
6+
<version>3.2.0</version>
77
<title>KY.Generator.CLI.Core.Minimal</title>
88
<authors>KY-Programming</authors>
99
<owners>KY-Programming</owners>

CLI.Core.Minimal/nuget.targets

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Target Name="KYGeneratorCLITarget" AfterTargets="Build">
4-
<Exec Command="dotnet %22%25USERPROFILE%25\.nuget\packages\ky.generator.cli.core.minimal\3.1.0\tools\KY.Generator.dll%22 %22$(ProjectDir)generator.json%22 %22$(ProjectDir)\%22 msbuild"
3+
<Target Name="KYGeneratorCLICoreMinimalBeforeTarget" BeforeTargets="Compile">
4+
<Exec Command="dotnet %22%25USERPROFILE%25\.nuget\packages\ky.generator.cli.core.minimal\3.2.0\tools\KY.Generator.dll%22 %22$(ProjectDir)generator.json%22 %22$(ProjectDir)\%22 msbuild"
55
CustomErrorRegularExpression="^Error:"
6-
CustomWarningRegularExpression="^Warning:"
7-
></Exec>
6+
CustomWarningRegularExpression="^Warning:"></Exec>
7+
</Target>
8+
<Target Name="KYGeneratorCLICoreMinimalAfterTarget" AfterTargets="Build">
9+
<Exec Command="dotnet %22%25USERPROFILE%25\.nuget\packages\ky.generator.cli.core.minimal\3.2.0\tools\KY.Generator.dll%22 %22$(ProjectDir)generator.json%22 %22$(ProjectDir)\%22 msbuild"
10+
CustomErrorRegularExpression="^Error:"
11+
CustomWarningRegularExpression="^Warning:"></Exec>
812
</Target>
913
</Project>

CLI.Core.Standalone/KY.Generator.CLI.Core.Standalone.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp2.2</TargetFramework>
6-
<Version>3.1.0</Version>
6+
<Version>3.2.0</Version>
77
<Authors>KY-Programming</Authors>
88
<Product>KY.Generator</Product>
99
<Copyright>2019 - KY-Programming</Copyright>

0 commit comments

Comments
 (0)