-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Set extension method that supports setting properties with inac…
…cessible setters (#202) * Support for setting properties with inaccessible setters * Added null parameter unit tests Co-authored-by: Andy <andrew.berman@rxpservices.com>
- Loading branch information
Showing
5 changed files
with
296 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// the following namespace/class is required to be able to use init setters with framework versions lower than 5.0: | ||
// https://www.mking.net/blog/error-cs0518-isexternalinit-not-defined | ||
namespace System.Runtime.CompilerServices | ||
{ | ||
using System.ComponentModel; | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal static class IsExternalInit { } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace ModelBuilder.UnitTests.Models | ||
{ | ||
using System; | ||
|
||
public class PropertySetters | ||
{ | ||
public Guid AutoPublic { get; set; } | ||
|
||
public string? AutoReadonly { get; } = string.Empty; | ||
|
||
public int AutoPrivate { get; private set; } | ||
|
||
public decimal AutoProtected { get; protected set; } | ||
|
||
public Uri? AutoProtectedInternal { get; protected internal set; } | ||
|
||
public DateTimeOffset AutoInternal { get; internal set; } | ||
|
||
public PropertySetters? AutoPrivateInternal { get; private protected set; } | ||
|
||
public ConsoleColor AutoInit { get; init; } | ||
|
||
internal float _backingField; | ||
public float BackingFieldMethod() => _backingField; | ||
|
||
public float PublicBackingField { get => _backingField; set => _backingField = value; } | ||
public float BackingField { get => _backingField; set => _backingField = value; } | ||
|
||
public float PrivateBackingField { get => _backingField; private set => _backingField = value; } | ||
|
||
public char? Readonly => default; | ||
} | ||
} |
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