SourceKit.Generators.Builder
1.2.35
Prefix Reserved
See the version list below for details.
dotnet add package SourceKit.Generators.Builder --version 1.2.35
NuGet\Install-Package SourceKit.Generators.Builder -Version 1.2.35
<PackageReference Include="SourceKit.Generators.Builder" Version="1.2.35" />
paket add SourceKit.Generators.Builder --version 1.2.35
#r "nuget: SourceKit.Generators.Builder, 1.2.35"
// Install SourceKit.Generators.Builder as a Cake Addin #addin nuget:?package=SourceKit.Generators.Builder&version=1.2.35 // Install SourceKit.Generators.Builder as a Cake Tool #tool nuget:?package=SourceKit.Generators.Builder&version=1.2.35
SourceKit.Generators.Builder
Use [GenerateBuilder]
attribute to generate builder.
- Only
record
orrecord struct
types are supported - Builder is a nested class
Builder
- For collection properties field of type
List<>
will be generated - For collection properties, methods
With{PropName}
andWith{PropName}s
will be generated - If collection element type is
IComparable
orIComparable<TSelf>
the.Distinct
LINQ method would be called on.Build
method - If collection property is
List<>
orHashSet<>
then it will be converted to this collection respectively, otherwise,ToArray
method will be called
You can use SomeType.Build()
static method to shorthand create type instance using generated builder
[GenerateBuilder]
public partial record SomeQuery(IReadOnlyCollection<Guid> Ids, int Count = 10);
...
var query = SomeQuery.Build(x => x.WithCount(2).WithId(Guid.NewGuid());
Default values for record properties are supported
Required properties
You can annotate property with [RequiredValue]
attribute to force compile time error
when it is not initialized withing Build
method of model.
[GenerateBuilder]
public partial record SomeQuery(long[] Ids, [RequiredValue] int PageSize);
The following code will produce an error.
var query = SomeQuery.Build(x => x.WithId(1));
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- FluentChaining (>= 1.0.4)
- Humanizer.Core (>= 2.14.1)
- Humanizer.Core.uk (>= 2.14.1)
- Microsoft.CodeAnalysis.Common (>= 4.9.2)
- Microsoft.CodeAnalysis.CSharp (>= 4.9.2)
- Microsoft.CodeAnalysis.Workspaces.Common (>= 4.9.2)
- Microsoft.Extensions.DependencyInjection (>= 3.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.0.0)
- SourceKit (>= 1.1.35)
- SourceKit.Generators.Builder.Annotations (>= 1.1.35)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SourceKit.Generators.Builder:
Package | Downloads |
---|---|
Itmo.Dev.Platform.BackgroundTasks
Package Description |
|
Itmo.Dev.Platform.MessagePersistence
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.36 | 71 | 11/18/2024 |
1.2.35 | 119 | 10/11/2024 |
1.2.34 | 206 | 5/4/2024 |
1.2.33 | 92 | 5/1/2024 |
1.2.31 | 120 | 4/27/2024 |
1.2.30 | 167 | 4/6/2024 |
1.1.29 | 158 | 4/3/2024 |
1.1.27 | 118 | 4/3/2024 |
1.1.26 | 136 | 4/3/2024 |
1.1.24 | 3,105 | 12/19/2023 |
1.1.23 | 222 | 12/6/2023 |
1.1.22 | 360 | 11/22/2023 |
1.1.21 | 627 | 11/11/2023 |
1.1.20 | 101 | 11/11/2023 |
1.1.19 | 172 | 11/11/2023 |
1.1.18 | 128 | 11/11/2023 |
1.1.16 | 109 | 11/11/2023 |
1.1.15 | 121 | 11/11/2023 |
1.1.14 | 134 | 11/11/2023 |
1.1.13 | 162 | 11/11/2023 |
1.1.11 | 123 | 11/11/2023 |
1.1.10 | 217 | 9/16/2023 |
1.1.4 | 258 | 9/10/2023 |
1.0.4 | 1,280 | 6/11/2023 |
1.0.3 | 180 | 6/10/2023 |
1.0.2 | 142 | 6/10/2023 |
1.0.1 | 374 | 5/14/2023 |
1.0.0 | 169 | 5/13/2023 |
Added default values support