Skip to content

Commit ff34726

Browse files
committed
Tests and examples updated
1 parent 13c2412 commit ff34726

File tree

24 files changed

+132
-71
lines changed

24 files changed

+132
-71
lines changed

Core/Writers/CommentWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public virtual void Write(ICodeFragment fragment, IOutputCache output)
1919

2020
protected string[] SplitLines(string text)
2121
{
22-
return text.Replace("\r", string.Empty).Split('\n');
22+
return text.TrimStart('\r').TrimStart('\n').Replace("\r", string.Empty).Split('\n');
2323
}
2424
}
2525
}

Examples/Angular/ModelFromAssembly/ModelFromAssembly.csproj

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

88
<ItemGroup>
9-
<PackageReference Include="KY.Generator" Version="6.3.0" />
10-
<PackageReference Include="KY.Generator.Annotations" Version="6.3.0" />
9+
<PackageReference Include="KY.Generator" Version="6.4.0" />
10+
<PackageReference Include="KY.Generator.Annotations" Version="6.4.0" />
1111
</ItemGroup>
1212

1313
</Project>

Examples/Angular/ModelFromAssembly/Output/another-type.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ModelFromAssembly/Output/type-to-read.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ServiceFromAspNetCoreAnnotation/ClientApp/src/app/models/weather-forecast.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ServiceFromAspNetCoreAnnotation/ClientApp/src/app/services/weather-forecast.service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ServiceFromAspNetCoreAnnotation/ServiceFromAspNetCoreAnnotation.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="KY.Generator" Version="6.3.0" />
18-
<PackageReference Include="KY.Generator.Annotations" Version="6.3.0" />
17+
<PackageReference Include="KY.Generator" Version="6.4.0" />
18+
<PackageReference Include="KY.Generator.Annotations" Version="6.4.0" />
1919
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.7" />
2020
</ItemGroup>
2121

Examples/Angular/ServiceFromAspNetCoreSignalRHub/ClientApp/package-lock.json

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Angular/ServiceFromAspNetCoreSignalRHub/ClientApp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@angular/platform-server": "8.2.12",
2323
"@angular/router": "8.2.12",
2424
"@aspnet/signalr": "^1.1.4",
25+
"@microsoft/signalr": "^5.0.2",
2526
"@nguniversal/module-map-ngfactory-loader": "8.1.1",
2627
"aspnet-prerendering": "^3.0.1",
2728
"bootstrap": "^4.3.1",

Examples/Angular/ServiceFromAspNetCoreSignalRHub/ClientApp/src/app/models/connection-status.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ServiceFromAspNetCoreSignalRHub/ClientApp/src/app/models/weather-forecast.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ServiceFromAspNetCoreSignalRHub/ClientApp/src/app/services/weather-hub.service.ts

+37-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>
@@ -12,10 +13,11 @@ import { WeatherForecast } from "../models/weather-forecast";
1213
import { Injectable } from "@angular/core";
1314
import { HubConnection } from "@microsoft/signalr";
1415
import { HubConnectionBuilder } from "@microsoft/signalr";
15-
import { HubConnectionState } from "@microsoft/signalr";
1616
import { Observable } from "rxjs";
17-
import { of } from "rxjs";
18-
import { flatMap } from "rxjs/operators";
17+
import { filter } from "rxjs/operators";
18+
import { map } from "rxjs/operators";
19+
import { mergeMap } from "rxjs/operators";
20+
import { take } from "rxjs/operators";
1921
import { ReplaySubject } from "rxjs";
2022
import { Subject } from "rxjs";
2123

@@ -24,7 +26,7 @@ import { Subject } from "rxjs";
2426
})
2527
export class WeatherHubService {
2628
public serviceUrl: string = "";
27-
private connection: HubConnection;
29+
private connection: ReplaySubject<HubConnection>;
2830
private readonly timeouts: number[] = [0, 0, 1000, 2000, 5000];
2931
private readonly statusSubject: ReplaySubject<ConnectionStatus> = new ReplaySubject<ConnectionStatus>(1);
3032
public readonly status$: Observable<ConnectionStatus> = this.statusSubject.asObservable();
@@ -35,40 +37,44 @@ export class WeatherHubService {
3537
if (! this.serviceUrl) {
3638
throw new Error("serviceUrl can not be empty. Set it via service.serviceUrl.")
3739
}
38-
if (! this.connection) {
39-
this.connection = new HubConnectionBuilder().withUrl(this.serviceUrl).build();
40-
this.connection.onclose(() => {
41-
this.statusSubject.next(ConnectionStatus.connecting);
42-
this.connect()
43-
});
44-
this.connection.on("Updated", (forecast: WeatherForecast[]) => {
45-
this.updatedSubject.next(forecast);
46-
});
47-
}
48-
if (this.connection.state === HubConnectionState.Connected) {
49-
return of(undefined);
40+
if (this.connection) {
41+
return this.status$.pipe(filter((status) => status === ConnectionStatus.connected), take(1), map(() => {
42+
}));
5043
}
51-
this.statusSubject.next(ConnectionStatus.connecting);
52-
let subject = new Subject<void>();
53-
this.connection.start().then(() => {
54-
subject.next();
55-
subject.complete();
56-
this.statusSubject.next(ConnectionStatus.connected);
57-
}).catch((error) => {
58-
this.statusSubject.next(ConnectionStatus.disconnected);
59-
let timeout: number = this.timeouts[trial];
60-
timeout = timeout || this.timeouts[this.timeouts.length - 1] || 0;
61-
setTimeout(() => this.connect(trial + 1).subscribe(() => {
44+
this.connection = new ReplaySubject<HubConnection>(1);
45+
let hubConnection: HubConnection = new HubConnectionBuilder().withUrl(this.serviceUrl).build();
46+
let startConnection: () => Observable<void> = () => {
47+
this.statusSubject.next(ConnectionStatus.connecting);
48+
let subject = new Subject<void>();
49+
hubConnection.start().then(() => {
6250
subject.next();
6351
subject.complete();
64-
}, (innerError) => subject.error(innerError)), timeout);
52+
this.statusSubject.next(ConnectionStatus.connected);
53+
}).catch((error) => {
54+
this.statusSubject.next(ConnectionStatus.disconnected);
55+
let timeout: number = this.timeouts[trial];
56+
trial++;
57+
timeout = timeout || this.timeouts[this.timeouts.length - 1] || 0;
58+
setTimeout(() => startConnection().subscribe(() => {
59+
subject.next();
60+
subject.complete();
61+
}, (innerError) => subject.error(innerError)), timeout);
62+
});
63+
return subject;
64+
};
65+
hubConnection.on("Updated", (forecast: WeatherForecast[]) => {
66+
this.updatedSubject.next(forecast);
6567
});
66-
return subject;
68+
hubConnection.onclose(() => {
69+
startConnection();
70+
});
71+
this.connection.next(hubConnection);
72+
return startConnection();
6773
}
6874

6975
public fetch(): Observable<void> {
7076
let subject = new Subject<void>();
71-
this.connect().pipe(flatMap(() => this.connection.send("Fetch"))).subscribe(() => {
77+
this.connect().pipe(mergeMap(() => this.connection), take(1), mergeMap((connection) => connection.send("Fetch"))).subscribe(() => {
7278
subject.next();
7379
subject.complete();
7480
}, (error) => subject.error(error));

Examples/Angular/ServiceFromAspNetCoreSignalRHub/ServiceFromAspNetCoreSignalRHub.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="KY.Generator" Version="6.3.0" />
18-
<PackageReference Include="KY.Generator.Annotations" Version="6.3.0" />
17+
<PackageReference Include="KY.Generator" Version="6.4.0" />
18+
<PackageReference Include="KY.Generator.Annotations" Version="6.4.0" />
1919
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
2020
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.7" />
2121
</ItemGroup>

Examples/Angular/ServiceFromAspNetCoreViaFluentApi/Generator/Generator.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="KY.Generator" Version="6.3.0" />
9-
<PackageReference Include="KY.Generator.Angular" Version="6.3.0" />
10-
<PackageReference Include="KY.Generator.AspDotNet" Version="6.3.0" />
11-
<PackageReference Include="KY.Generator.Fluent" Version="6.3.0" />
12-
<PackageReference Include="KY.Generator.Reflection" Version="6.3.0" />
8+
<PackageReference Include="KY.Generator" Version="6.4.0" />
9+
<PackageReference Include="KY.Generator.Angular" Version="6.4.0" />
10+
<PackageReference Include="KY.Generator.AspDotNet" Version="6.4.0" />
11+
<PackageReference Include="KY.Generator.Fluent" Version="6.4.0" />
12+
<PackageReference Include="KY.Generator.Reflection" Version="6.4.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

Examples/Angular/ServiceFromAspNetCoreViaFluentApi/Service/ClientApp/src/app/models/weather-forecast.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ServiceFromAspNetCoreViaFluentApi/Service/ClientApp/src/app/services/weather-forecast.service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated with KY.Generator 6.3.0.0
3+
// This code was generated with KY.Generator 6.4.0.0
4+
//
45
// Manual changes to this file may cause unexpected behavior in your application.
56
// Manual changes to this file will be overwritten if the code is regenerated.
67
// </auto-generated>

Examples/Angular/ServiceFromSignalRViaFluentApi/ServiceFromSignalRViaFluentApi.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="KY.Generator" Version="6.3.0" />
17-
<PackageReference Include="KY.Generator.Angular" Version="6.3.0" />
18-
<PackageReference Include="KY.Generator.Fluent" Version="6.3.0" />
19-
<PackageReference Include="KY.Generator.Reflection" Version="6.3.0" />
16+
<PackageReference Include="KY.Generator" Version="6.4.0" />
17+
<PackageReference Include="KY.Generator.Angular" Version="6.4.0" />
18+
<PackageReference Include="KY.Generator.Fluent" Version="6.4.0" />
19+
<PackageReference Include="KY.Generator.Reflection" Version="6.4.0" />
2020
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.1" />
2121
</ItemGroup>
2222

Tests/AnnotationAsync/AnnotationAsync.csproj

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

99
<ItemGroup>
10-
<PackageReference Include="KY.Generator" Version="6.3.0" />
11-
<PackageReference Include="KY.Generator.Annotations" Version="6.3.0" />
10+
<PackageReference Include="KY.Generator" Version="6.4.0" />
11+
<PackageReference Include="KY.Generator.Annotations" Version="6.4.0" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

Tests/AnnotationAsyncAssembly/AnnotationAsyncAssembly.csproj

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

88
<ItemGroup>
9-
<PackageReference Include="KY.Generator" Version="6.3.0" />
10-
<PackageReference Include="KY.Generator.Annotations" Version="6.3.0" />
9+
<PackageReference Include="KY.Generator" Version="6.4.0" />
10+
<PackageReference Include="KY.Generator.Annotations" Version="6.4.0" />
1111
</ItemGroup>
1212

1313
</Project>

Tests/AnnotationInNestedClass/AnnotationInNestedClass.csproj

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

88
<ItemGroup>
9-
<PackageReference Include="KY.Generator" Version="6.3.0" />
10-
<PackageReference Include="KY.Generator.Annotations" Version="6.3.0" />
9+
<PackageReference Include="KY.Generator" Version="6.4.0" />
10+
<PackageReference Include="KY.Generator.Annotations" Version="6.4.0" />
1111
</ItemGroup>
1212

1313
</Project>

Tests/AnnotationsWithMultipleOutputs/AnnotationsWithMultipleOutputs.csproj

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

88
<ItemGroup>
9-
<PackageReference Include="KY.Generator" Version="6.3.0" />
10-
<PackageReference Include="KY.Generator.Annotations" Version="6.3.0" />
9+
<PackageReference Include="KY.Generator" Version="6.4.0" />
10+
<PackageReference Include="KY.Generator.Annotations" Version="6.4.0" />
1111
</ItemGroup>
1212

1313
</Project>

Tests/Fluent/Fluent.Generator/Fluent.Generator.csproj

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

88
<ItemGroup>
9-
<PackageReference Include="KY.Generator" Version="6.3.0" />
10-
<PackageReference Include="KY.Generator.Angular" Version="6.3.0" />
11-
<PackageReference Include="KY.Generator.Fluent" Version="6.3.0" />
12-
<PackageReference Include="KY.Generator.Reflection" Version="6.3.0" />
9+
<PackageReference Include="KY.Generator" Version="6.4.0" />
10+
<PackageReference Include="KY.Generator.Angular" Version="6.4.0" />
11+
<PackageReference Include="KY.Generator.Fluent" Version="6.4.0" />
12+
<PackageReference Include="KY.Generator.Reflection" Version="6.4.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

0 commit comments

Comments
 (0)