https://github.com/ufcpp/recordconstructorgenerator
Roslyn Code Fix for a record (immutable class/struct) constructor generated from get-only properties.
https://github.com/ufcpp/recordconstructorgenerator
Last synced: 6 months ago
JSON representation
Roslyn Code Fix for a record (immutable class/struct) constructor generated from get-only properties.
- Host: GitHub
- URL: https://github.com/ufcpp/recordconstructorgenerator
- Owner: ufcpp
- License: mit
- Created: 2015-06-05T05:02:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T02:02:46.000Z (over 3 years ago)
- Last Synced: 2024-11-07T07:52:31.625Z (about 1 year ago)
- Language: C#
- Size: 74.2 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RecordConstructorGenerator
A Code Fix for a record (immutable class/struct) constructor generated from get-only properties.
This inlcudes VSIX and NuGet packages of an analyzer created by using .NET Compiler Platform (Roslyn).
- VSIX: https://visualstudiogallery.msdn.microsoft.com/941ef3c4-a523-4d77-8bcd-fdfeebb15853
- NuGet: http://www.nuget.org/packages/RecordConstructorGenerator/
## Usage
- Insert a get-only auto property without a property initializer
- Use 'Quick Action' (Lightbulb) to fix the code
## Sample
original source:
```cs
class Point
{
public string Name { get; }
///
/// x coordinate.
///
public int X { get; }
///
/// x coordinate.
///
public int Y { get; }
public int A => X * Y;
}
```
the generated result:
```cs
class Point
{
public string Name { get; }
///
/// x coordinate.
///
public int X { get; }
///
/// x coordinate.
///
public int Y { get; }
public int A => X * Y;
/// Record Constructor
///
///
///
public Point(string name = default(string), int x = default(int), int y = default(int))
{
Name = name;
X = x;
Y = y;
}
}
```