Skip to content

Commit

Permalink
Add Build scripts (#5)
Browse files Browse the repository at this point in the history
* Add Build scripts

* Use dotnet build

* Update Readme

* use sln file
  • Loading branch information
ChrisPulman authored Jul 18, 2024
1 parent 2c02287 commit d5f8835
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 10 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
productNamespacePrefix: "SourceGenerators"

jobs:
build:
uses: reactiveui/actions-common/.github/workflows/workflow-common-setup-and-build.yml@main
with:
configuration: Release
productNamespacePrefix: "SourceGenerators"
useVisualStudioPreview: false
useMauiCheckDotNetTool: false
installWorkflows: false
dotNetBuild: true
31 changes: 31 additions & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Lock Threads'

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

permissions:
issues: write
pull-requests: write

concurrency:
group: lock

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
with:
github-token: ${{ github.token }}
issue-inactive-days: '14'
pr-inactive-days: '14'
issue-comment: >
This issue has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
pr-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release

on:
push:
branches: [ main ]

env:
productNamespacePrefix: "SourceGenerators"

jobs:
release:
uses: reactiveui/actions-common/.github/workflows/workflow-common-release.yml@main
with:
configuration: Release
productNamespacePrefix: "SourceGenerators"
useVisualStudioPreview: false
useMauiCheckDotNetTool: false
installWorkflows: false
dotNetBuild: true
secrets:
SIGN_CLIENT_USER_ID: ${{ secrets.SIGN_CLIENT_USER_ID }}
SIGN_CLIENT_SECRET: ${{ secrets.SIGN_CLIENT_SECRET }}
SIGN_CLIENT_CONFIG: ${{ secrets.SIGN_CLIENT_CONFIG }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
79 changes: 69 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,73 @@
# ReactiveUI.SourceGenerators
Use source generators to generate ReactiveUI objects.

Not taking public contributions at this time
Not taking public contributions at this time

These Source Generators were designed to work in full with ReactiveUI V19.5.31 and newer supporting all features, currently:
- [Reactive]
- [ObservableAsProperty]
- [ReactiveCommand]

Versions older than V19.5.31 to this:
- [Reactive] fully supported,
- [ObservableAsProperty] fully supported,
- [ReactiveCommand] all supported except Cancellation Token asnyc methods.

# Historical ways
## Read-write properties
Typically properties are declared like this:

```csharp
private string _name;
public string Name
{
get => _name;
set => this.RaiseAndSetIfChanged(ref _name, value);
}
```

Before these Source Generators were avaliable we used ReactiveUI.Fody.
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.
```csharp
[Reactive]
public string Name { get; set; }
```

## ObservableAsPropertyHelper properties
Similarly, to declare output properties, the code looks like this:
```csharp
public partial class MyReactiveClass : ReactiveObject
{
ObservableAsPropertyHelper<string> _firstName;

public MyReactiveClass()
{
_firstName = firstNameObservable
.ToProperty(this, x => x.FirstName);
}

public string FirstName => _firstName.Value;

private IObservable<string> firstNameObservable() => Observable.Return("Test");
}
```

With ReactiveUI.Fody, you can simply declare a read-only property using the [ObservableAsProperty] attribute, using either option of the two options shown below.
```csharp
[ObservableAsProperty]
public string FirstName { get; }
```

# Welcome to a new way - Source Generators

## Usage Reactive property `[Reactive]`
```csharp
using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass : ReactiveObject
{
[Reactive] private string _myProperty;
[Reactive]
private string _myProperty;
}
```

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

public partial class MyReactiveClass : ReactiveObject
{
[ObservableAsProperty] private string _myProperty;
[ObservableAsProperty]
private string _myProperty;
}
```

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

public partial class MyReactiveClass
{
public MyReactiveCommand()
public MyReactiveClass()
{
InitializeCommands();
}
Expand All @@ -47,7 +106,7 @@ using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass
{
public MyReactiveCommand()
public MyReactiveClass()
{
InitializeCommands();
}
Expand All @@ -63,7 +122,7 @@ using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass
{
public MyReactiveCommand()
public MyReactiveClass()
{
InitializeCommands();
}
Expand All @@ -79,7 +138,7 @@ using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass
{
public MyReactiveCommand()
public MyReactiveClass()
{
InitializeCommands();
}
Expand All @@ -95,7 +154,7 @@ using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass
{
public MyReactiveCommand()
public MyReactiveClass()
{
InitializeCommands();
}
Expand All @@ -111,7 +170,7 @@ using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass
{
public MyReactiveCommand()
public MyReactiveClass()
{
InitializeCommands();
}
Expand All @@ -127,7 +186,7 @@ using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass
{
public MyReactiveCommand()
public MyReactiveClass()
{
InitializeCommands();
}
Expand Down
39 changes: 39 additions & 0 deletions src/ReactiveUI.SourceGenerators.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionConfig", "SolutionConfig", "{F29AF2F3-DEC8-58BC-043A-1447862C832D}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
..\.gitignore = ..\.gitignore
..\LICENSE = ..\LICENSE
..\README.md = ..\README.md
..\version.json = ..\version.json
Directory.build.props = Directory.build.props
Directory.Packages.props = Directory.Packages.props
stylecop.json = stylecop.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.SourceGenerators.Execute", "ReactiveUI.SourceGenerators.Execute\ReactiveUI.SourceGenerators.Execute.csproj", "{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.SourceGenerators", "ReactiveUI.SourceGenerators\ReactiveUI.SourceGenerators.csproj", "{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76D5AC8C-4935-3E4B-BD12-71FAEC2B9A9D}.Release|Any CPU.Build.0 = Release|Any CPU
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8CE4CD8-F858-67F2-E50D-86C5C17C6BE6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

0 comments on commit d5f8835

Please sign in to comment.