Skip to content

Commit 6494d1e

Browse files
Merge pull request #24 from TheEightBot/develop
2 parents 665eb77 + c3723b7 commit 6494d1e

File tree

9 files changed

+411
-83
lines changed

9 files changed

+411
-83
lines changed

.github/workflows/nuget.yml

Lines changed: 46 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,57 @@
33

44
name: .NET
55

6-
on:
6+
on:
77
push:
88
tags:
99
- 'v**'
1010

1111
jobs:
1212
build:
13-
1413
runs-on: macos-14
15-
14+
strategy:
15+
matrix:
16+
include:
17+
- name: Stellar
18+
project: Stellar/Stellar.csproj
19+
output: Stellar/bin/Release
20+
- name: Stellar.Maui
21+
project: Stellar.Maui/Stellar.Maui.csproj
22+
output: Stellar.Maui/bin/Release
23+
- name: Stellar.Maui.PopUp
24+
project: Stellar.Maui.PopUp/Stellar.Maui.PopUp.csproj
25+
output: Stellar.Maui.PopUp/bin/Release
26+
- name: Stellar.Blazor
27+
project: Stellar.Blazor/Stellar.Blazor.csproj
28+
output: Stellar.Blazor/bin/Release
29+
- name: Stellar.Avalonia
30+
project: Stellar.Avalonia/Stellar.Avalonia.csproj
31+
output: Stellar.Avalonia/bin/Release
32+
- name: Stellar.FluentValidation
33+
project: Stellar.FluentValidation/Stellar.FluentValidation.csproj
34+
output: Stellar.FluentValidation/bin/Release
35+
- name: Stellar.DiskDataCache
36+
project: Stellar.DiskDataCache/Stellar.DiskDataCache.csproj
37+
output: Stellar.DiskDataCache/bin/Release
38+
- name: Stellar.SourceGenerators
39+
project: Stellar.SourceGenerators/Stellar.SourceGenerators.csproj
40+
output: Stellar.SourceGenerators/bin/Release
1641
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-dotnet@v3
19-
with:
20-
dotnet-version: '9.x'
21-
22-
- uses: maxim-lobanov/setup-xcode@v1
23-
with:
24-
xcode-version: latest-stable
25-
26-
- name: Install MAUI Workloads
27-
run: dotnet workload install maui --ignore-failed-sources
28-
29-
- name: Semver Parse
30-
id: version
31-
uses: release-kit/semver@v1.0.10
32-
33-
- name: Build Stellar
34-
run: dotnet build Stellar/Stellar.csproj
35-
- name: Create the package
36-
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Stellar/Stellar.csproj
37-
- name: Publish the package to NuGet
38-
run: dotnet nuget push Stellar/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
39-
env:
40-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
41-
42-
- name: Build Stellar.Maui
43-
run: dotnet build Stellar.Maui/Stellar.Maui.csproj
44-
- name: Create the package
45-
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Stellar.Maui/Stellar.Maui.csproj
46-
- name: Publish the package to NuGet
47-
run: dotnet nuget push Stellar.Maui/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
48-
env:
49-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
50-
51-
- name: Build Stellar.Maui.PopUp
52-
run: dotnet build Stellar.Maui.PopUp/Stellar.Maui.PopUp.csproj
53-
- name: Create the package
54-
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Stellar.Maui.PopUp/Stellar.Maui.PopUp.csproj
55-
- name: Publish the package to NuGet
56-
run: dotnet nuget push Stellar.Maui.PopUp/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
57-
env:
58-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
59-
60-
- name: Build Stellar.Blazor
61-
run: dotnet build Stellar.Blazor/Stellar.Blazor.csproj
62-
- name: Create the package
63-
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Stellar.Blazor/Stellar.Blazor.csproj
64-
- name: Publish the package to NuGet
65-
run: dotnet nuget push Stellar.Blazor/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
66-
env:
67-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
68-
69-
- name: Build Stellar.Avalonia
70-
run: dotnet build Stellar.Avalonia/Stellar.Avalonia.csproj
71-
- name: Create the package
72-
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Stellar.Avalonia/Stellar.Avalonia.csproj
73-
- name: Publish the package to NuGet
74-
run: dotnet nuget push Stellar.Avalonia/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
75-
env:
76-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
77-
78-
- name: Build Stellar.FluentValidation
79-
run: dotnet build Stellar.FluentValidation/Stellar.FluentValidation.csproj
80-
- name: Create the package
81-
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Stellar.FluentValidation/Stellar.FluentValidation.csproj
82-
- name: Publish the package to NuGet
83-
run: dotnet nuget push Stellar.FluentValidation/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
84-
env:
85-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
86-
87-
- name: Build Stellar.DiskDataCache
88-
run: dotnet build Stellar.DiskDataCache/Stellar.DiskDataCache.csproj
89-
- name: Create the package
90-
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} Stellar.DiskDataCache/Stellar.DiskDataCache.csproj
91-
- name: Publish the package to NuGet
92-
run: dotnet nuget push Stellar.DiskDataCache/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
93-
env:
94-
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
42+
- uses: actions/checkout@v3
43+
- uses: actions/setup-dotnet@v3
44+
with:
45+
dotnet-version: '9.x'
46+
- uses: maxim-lobanov/setup-xcode@v1
47+
with:
48+
xcode-version: latest-stable
49+
- name: Install MAUI Workloads
50+
run: dotnet workload install maui --ignore-failed-sources
51+
- name: Semver Parse
52+
id: version
53+
uses: release-kit/semver@v1.0.10
54+
- name: Build ${{ matrix.name }}
55+
run: dotnet build ${{ matrix.project }}
56+
- name: Pack ${{ matrix.name }}
57+
run: dotnet pack --configuration Release /p:AssemblyVersion=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} /p:Version=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }} ${{ matrix.project }}
58+
- name: Publish ${{ matrix.name }}
59+
run: dotnet nuget push ${{ matrix.output }}/*.nupkg -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,29 @@ public partial class SampleViewModel : ViewModelBase
247247
}
248248
```
249249

250+
251+
#### Compile-Time Service Registration with Source Generator
252+
253+
StellarUI includes a Roslyn source generator that emits a strongly-typed registration extension based on your assembly, eliminating runtime reflection.
254+
255+
1. Add the generator package to your project via NuGet:
256+
257+
```bash
258+
dotnet add package Stellar.SourceGenerators --version <latest-version>
259+
```
260+
261+
2. Rebuild your project to produce `AddRegisteredServicesFor{YourAssemblyName}.g.cs` in `obj/<TFM>/generated`.
262+
263+
3. In your startup code (e.g., `MauiProgram.cs` or `Program.cs`), call the generated extension:
264+
265+
```csharp
266+
using Stellar; // namespace of generated code
267+
268+
builder.Services.AddRegisteredServicesForMyApp(); // replace MyApp with your project's AssemblyName
269+
```
270+
271+
All `[ServiceRegistration]` attributed types will be registered at compile time.
272+
250273
### Lifecycle Management
251274
252275
StellarUI provides a consistent set of lifecycle events across all platforms:

Stellar.MauiSample/MauiProgram.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Text;
22
using CommunityToolkit.Maui;
33
using Microsoft.Extensions.Logging;
4+
using Stellar;
45

56
namespace Stellar.MauiSample;
67

@@ -25,6 +26,8 @@ public static MauiApp CreateMauiApp()
2526
#endif
2627
.UseStellarComponents<App>();
2728

29+
appBuilder.Services.AddRegisteredServicesForStellarMauiSample();
30+
2831
/*
2932
We can add individual service registrations or all at once
3033
.RegisterServices<App>()

Stellar.MauiSample/Stellar.MauiSample.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
5757
</ItemGroup>
5858
<ItemGroup>
59+
<ProjectReference Include="..\Stellar.SourceGenerators\Stellar.SourceGenerators.csproj"
60+
OutputItemType="Analyzer"
61+
ReferenceOutputAssembly="false" />
5962
<ProjectReference Include="..\Stellar\Stellar.csproj" />
6063
<ProjectReference Include="..\Stellar.Maui.PopUp\Stellar.Maui.PopUp.csproj" />
6164
<ProjectReference Include="..\Stellar.Maui\Stellar.Maui.csproj" />
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
3+
namespace Stellar;
4+
5+
[AttributeUsage(AttributeTargets.Class)]
6+
public class ServiceRegistrationAttribute : Attribute
7+
{
8+
public Lifetime ServiceRegistrationType { get; set; }
9+
10+
public bool RegisterInterfaces { get; set; }
11+
12+
public ServiceRegistrationAttribute()
13+
{
14+
ServiceRegistrationType = Lifetime.Transient;
15+
}
16+
17+
public ServiceRegistrationAttribute(Lifetime serviceRegistrationType)
18+
{
19+
ServiceRegistrationType = serviceRegistrationType;
20+
}
21+
22+
public ServiceRegistrationAttribute(Lifetime serviceRegistrationType = Lifetime.Transient, bool registerInterfaces = false)
23+
{
24+
ServiceRegistrationType = serviceRegistrationType;
25+
RegisterInterfaces = registerInterfaces;
26+
}
27+
}
28+
29+
public enum Lifetime
30+
{
31+
Transient = 0,
32+
Scoped = 1,
33+
Singleton = 2,
34+
}

0 commit comments

Comments
 (0)