Skip to content

Commit d5f8835

Browse files
authored
Add Build scripts (#5)
* Add Build scripts * Use dotnet build * Update Readme * use sln file
1 parent 2c02287 commit d5f8835

File tree

5 files changed

+184
-10
lines changed

5 files changed

+184
-10
lines changed

.github/workflows/ci-build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
productNamespacePrefix: "SourceGenerators"
11+
12+
jobs:
13+
build:
14+
uses: reactiveui/actions-common/.github/workflows/workflow-common-setup-and-build.yml@main
15+
with:
16+
configuration: Release
17+
productNamespacePrefix: "SourceGenerators"
18+
useVisualStudioPreview: false
19+
useMauiCheckDotNetTool: false
20+
installWorkflows: false
21+
dotNetBuild: true

.github/workflows/lock.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Lock Threads'
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
12+
concurrency:
13+
group: lock
14+
15+
jobs:
16+
action:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: dessant/lock-threads@v5
20+
with:
21+
github-token: ${{ github.token }}
22+
issue-inactive-days: '14'
23+
pr-inactive-days: '14'
24+
issue-comment: >
25+
This issue has been automatically locked since there
26+
has not been any recent activity after it was closed.
27+
Please open a new issue for related bugs.
28+
pr-comment: >
29+
This pull request has been automatically locked since there
30+
has not been any recent activity after it was closed.
31+
Please open a new issue for related bugs.

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
env:
8+
productNamespacePrefix: "SourceGenerators"
9+
10+
jobs:
11+
release:
12+
uses: reactiveui/actions-common/.github/workflows/workflow-common-release.yml@main
13+
with:
14+
configuration: Release
15+
productNamespacePrefix: "SourceGenerators"
16+
useVisualStudioPreview: false
17+
useMauiCheckDotNetTool: false
18+
installWorkflows: false
19+
dotNetBuild: true
20+
secrets:
21+
SIGN_CLIENT_USER_ID: ${{ secrets.SIGN_CLIENT_USER_ID }}
22+
SIGN_CLIENT_SECRET: ${{ secrets.SIGN_CLIENT_SECRET }}
23+
SIGN_CLIENT_CONFIG: ${{ secrets.SIGN_CLIENT_CONFIG }}
24+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

README.md

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,73 @@
11
# ReactiveUI.SourceGenerators
22
Use source generators to generate ReactiveUI objects.
33

4-
Not taking public contributions at this time
4+
Not taking public contributions at this time
5+
6+
These Source Generators were designed to work in full with ReactiveUI V19.5.31 and newer supporting all features, currently:
7+
- [Reactive]
8+
- [ObservableAsProperty]
9+
- [ReactiveCommand]
10+
11+
Versions older than V19.5.31 to this:
12+
- [Reactive] fully supported,
13+
- [ObservableAsProperty] fully supported,
14+
- [ReactiveCommand] all supported except Cancellation Token asnyc methods.
15+
16+
# Historical ways
17+
## Read-write properties
18+
Typically properties are declared like this:
19+
20+
```csharp
21+
private string _name;
22+
public string Name
23+
{
24+
get => _name;
25+
set => this.RaiseAndSetIfChanged(ref _name, value);
26+
}
27+
```
28+
29+
Before these Source Generators were avaliable we used ReactiveUI.Fody.
30+
With ReactiveUI.Fody the `[Reactive]` Attribute was placed on a Public Property with Auto get / set properties, the generated code from the Source Generator and the Injected code using Fody are very similar with the exception of the Attributes.
31+
```csharp
32+
[Reactive]
33+
public string Name { get; set; }
34+
```
35+
36+
## ObservableAsPropertyHelper properties
37+
Similarly, to declare output properties, the code looks like this:
38+
```csharp
39+
public partial class MyReactiveClass : ReactiveObject
40+
{
41+
ObservableAsPropertyHelper<string> _firstName;
42+
43+
public MyReactiveClass()
44+
{
45+
_firstName = firstNameObservable
46+
.ToProperty(this, x => x.FirstName);
47+
}
48+
49+
public string FirstName => _firstName.Value;
50+
51+
private IObservable<string> firstNameObservable() => Observable.Return("Test");
52+
}
53+
```
54+
55+
With ReactiveUI.Fody, you can simply declare a read-only property using the [ObservableAsProperty] attribute, using either option of the two options shown below.
56+
```csharp
57+
[ObservableAsProperty]
58+
public string FirstName { get; }
59+
```
60+
61+
# Welcome to a new way - Source Generators
562

663
## Usage Reactive property `[Reactive]`
764
```csharp
865
using ReactiveUI.SourceGenerators;
966

1067
public partial class MyReactiveClass : ReactiveObject
1168
{
12-
[Reactive] private string _myProperty;
69+
[Reactive]
70+
private string _myProperty;
1371
}
1472
```
1573

@@ -19,7 +77,8 @@ using ReactiveUI.SourceGenerators;
1977

2078
public partial class MyReactiveClass : ReactiveObject
2179
{
22-
[ObservableAsProperty] private string _myProperty;
80+
[ObservableAsProperty]
81+
private string _myProperty;
2382
}
2483
```
2584

@@ -31,7 +90,7 @@ using ReactiveUI.SourceGenerators;
3190

3291
public partial class MyReactiveClass
3392
{
34-
public MyReactiveCommand()
93+
public MyReactiveClass()
3594
{
3695
InitializeCommands();
3796
}
@@ -47,7 +106,7 @@ using ReactiveUI.SourceGenerators;
47106

48107
public partial class MyReactiveClass
49108
{
50-
public MyReactiveCommand()
109+
public MyReactiveClass()
51110
{
52111
InitializeCommands();
53112
}
@@ -63,7 +122,7 @@ using ReactiveUI.SourceGenerators;
63122

64123
public partial class MyReactiveClass
65124
{
66-
public MyReactiveCommand()
125+
public MyReactiveClass()
67126
{
68127
InitializeCommands();
69128
}
@@ -79,7 +138,7 @@ using ReactiveUI.SourceGenerators;
79138

80139
public partial class MyReactiveClass
81140
{
82-
public MyReactiveCommand()
141+
public MyReactiveClass()
83142
{
84143
InitializeCommands();
85144
}
@@ -95,7 +154,7 @@ using ReactiveUI.SourceGenerators;
95154

96155
public partial class MyReactiveClass
97156
{
98-
public MyReactiveCommand()
157+
public MyReactiveClass()
99158
{
100159
InitializeCommands();
101160
}
@@ -111,7 +170,7 @@ using ReactiveUI.SourceGenerators;
111170

112171
public partial class MyReactiveClass
113172
{
114-
public MyReactiveCommand()
173+
public MyReactiveClass()
115174
{
116175
InitializeCommands();
117176
}
@@ -127,7 +186,7 @@ using ReactiveUI.SourceGenerators;
127186

128187
public partial class MyReactiveClass
129188
{
130-
public MyReactiveCommand()
189+
public MyReactiveClass()
131190
{
132191
InitializeCommands();
133192
}

src/ReactiveUI.SourceGenerators.sln

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.10.35027.167
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionConfig", "SolutionConfig", "{F29AF2F3-DEC8-58BC-043A-1447862C832D}"
6+
ProjectSection(SolutionItems) = preProject
7+
..\.editorconfig = ..\.editorconfig
8+
..\.gitignore = ..\.gitignore
9+
..\LICENSE = ..\LICENSE
10+
..\README.md = ..\README.md
11+
..\version.json = ..\version.json
12+
Directory.build.props = Directory.build.props
13+
Directory.Packages.props = Directory.Packages.props
14+
stylecop.json = stylecop.json
15+
EndProjectSection
16+
EndProject
17+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.SourceGenerators.Execute", "ReactiveUI.SourceGenerators.Execute\ReactiveUI.SourceGenerators.Execute.csproj", "{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}"
18+
EndProject
19+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.SourceGenerators", "ReactiveUI.SourceGenerators\ReactiveUI.SourceGenerators.csproj", "{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}"
20+
EndProject
21+
Global
22+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
23+
Debug|Any CPU = Debug|Any CPU
24+
Release|Any CPU = Release|Any CPU
25+
EndGlobalSection
26+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
27+
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Release|Any CPU.Build.0 = Release|Any CPU
35+
EndGlobalSection
36+
GlobalSection(SolutionProperties) = preSolution
37+
HideSolutionNode = FALSE
38+
EndGlobalSection
39+
EndGlobal

0 commit comments

Comments
 (0)