-
Notifications
You must be signed in to change notification settings - Fork 0
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 #7 from raffaeler/ImplementInterface
Implement interface
- Loading branch information
Showing
29 changed files
with
2,469 additions
and
1,470 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# SpeedyGenerators | ||
|
||
C# code generators are new to C# version 9. | ||
SpeedyGenerators is a collection of C# Code Generators (available since C# 9) which generate C# code to *augment* the code written by the developer. | ||
|
||
Apart from straightforward cases, the greatest majority of the code is generated using the Roslyn (C# compiler) API. | ||
### List of generators | ||
|
||
All the code in the NuGet package is only used at development time. There is no run-time dependency, therefore you don't need to deploy the binaries for this package. | ||
* `MakePropertyAttribute` is applied to a field and generates (in the partial class) a property implementing the `INotifyPropertyChanged` interface. | ||
* (new in version 1.1.0) `MakeConcreteAttribute` is applied to a partial class and generated (in the partial class) all the properties belonging to the interface specified in the attribute (full qualified name of the interface). The interface may or not be implemented by the class. | ||
|
||
Please visit https://github.com/raffaeler/SpeedyGenerators for more details. | ||
|
||
The generation process happens thanks to the C# compiler. This means it works even if the build is done on the command line. In other word there is no dependency from Visual Studio or other IDEs. | ||
|
||
Once the package is referenced in the application, just start coding as shown in the examples. The generated code can be examined by expanding the Analyzers tree. See the repository readme for details. | ||
|
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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using SpeedyGenerators; | ||
|
||
namespace LibraryTest | ||
{ | ||
namespace Abc | ||
{ | ||
interface IMyInterface | ||
{ | ||
string Name { get; } | ||
StringBuilder Other { get; } | ||
int Age { get; } | ||
} | ||
} | ||
|
||
[MakeConcrete( | ||
interfaceFullTypeName: "LibraryTest.Abc.IMyInterface", | ||
generateInitializingConstructor: true, | ||
makeSettersPrivate: false, | ||
implementInterface: false, | ||
makeReferenceTypesNullable: true, | ||
makeValueTypesNullable: false)] | ||
partial class MyClass | ||
{ | ||
} | ||
|
||
partial record class MyRecord { } | ||
|
||
partial struct MyStruct { } | ||
|
||
partial record struct MyRecordStruct { } | ||
|
||
} |
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.