-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from wieslawsoltes/InitRefReturnSupport
Add support for init properties
- Loading branch information
Showing
10 changed files
with
375 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
ReactiveGenerator.Tests/Snapshots/ReactiveGeneratorTests.InitAccessorTest.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
Sources: [ | ||
{ | ||
FileName: IgnoreReactiveAttribute.g.cs, | ||
Source: | ||
// <auto-generated/> | ||
using System; | ||
|
||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, Inherited = false, AllowMultiple = false)] | ||
sealed class IgnoreReactiveAttribute : Attribute | ||
{ | ||
public IgnoreReactiveAttribute() { } | ||
} | ||
}, | ||
{ | ||
FileName: Person.INPC.g.cs, | ||
Source: | ||
// <auto-generated/> | ||
#nullable enable | ||
|
||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
public partial class Person : INotifyPropertyChanged | ||
{ | ||
public event PropertyChangedEventHandler? PropertyChanged; | ||
|
||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args) | ||
{ | ||
PropertyChanged?.Invoke(this, args); | ||
} | ||
} | ||
|
||
}, | ||
{ | ||
FileName: Person.ReactiveProperties.g.cs, | ||
Source: | ||
// <auto-generated/> | ||
#nullable enable | ||
|
||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
/// <summary> | ||
/// A partial class implementation for Person. | ||
/// </summary> | ||
public partial class Person | ||
{ | ||
private static readonly PropertyChangedEventArgs _nameChangedEventArgs = new PropertyChangedEventArgs(nameof(Name)); | ||
private static readonly PropertyChangedEventArgs _idChangedEventArgs = new PropertyChangedEventArgs(nameof(Id)); | ||
|
||
public partial string Name | ||
{ | ||
get => field; | ||
init | ||
{ | ||
if (!Equals(field, value)) | ||
{ | ||
field = value; | ||
OnPropertyChanged(_nameChangedEventArgs); | ||
} | ||
} | ||
} | ||
|
||
public required partial string Id | ||
{ | ||
get => field; | ||
init | ||
{ | ||
if (!Equals(field, value)) | ||
{ | ||
field = value; | ||
OnPropertyChanged(_idChangedEventArgs); | ||
} | ||
} | ||
} | ||
} | ||
|
||
}, | ||
{ | ||
FileName: ReactiveAttribute.g.cs, | ||
Source: | ||
// <auto-generated/> | ||
using System; | ||
|
||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, Inherited = true, AllowMultiple = false)] | ||
sealed class ReactiveAttribute : Attribute | ||
{ | ||
public ReactiveAttribute() { } | ||
} | ||
} | ||
], | ||
Diagnostics: null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.