diff --git a/src-examples/BuilderConsumer/Content.cs b/src-examples/BuilderConsumer/Content.cs new file mode 100644 index 0000000..186f143 --- /dev/null +++ b/src-examples/BuilderConsumer/Content.cs @@ -0,0 +1,7 @@ +namespace BuilderConsumer +{ + public class Content + { + public string Id { get; set; } + } +} \ No newline at end of file diff --git a/src-examples/BuilderConsumer/ContentBuilder.cs b/src-examples/BuilderConsumer/ContentBuilder.cs new file mode 100644 index 0000000..cfbee58 --- /dev/null +++ b/src-examples/BuilderConsumer/ContentBuilder.cs @@ -0,0 +1,9 @@ +using FluentBuilder; + +namespace BuilderConsumer +{ + [AutoGenerateBuilder(typeof(Content))] + public partial class ContentBuilder + { + } +} \ No newline at end of file diff --git a/src-examples/BuilderConsumer/Program.cs b/src-examples/BuilderConsumer/Program.cs index cced883..ba3f695 100644 --- a/src-examples/BuilderConsumer/Program.cs +++ b/src-examples/BuilderConsumer/Program.cs @@ -15,6 +15,16 @@ class Program static void Main(string[] args) { + var settings = new SettingsBuilder() + // .WithContents(new[] { new Content { Id = "a"} }) + .WithContents(x => x + .Add(cb => cb.WithId("b") + ) + ) + // .WithContents(Array.Empty) + .Build() + ; + var t1 = new ThingWithOnlyParameterizedConstructorsBuilder() .UsingConstructor(1, 2, "drie") .WithL(444444) diff --git a/src-examples/BuilderConsumer/Settings.cs b/src-examples/BuilderConsumer/Settings.cs new file mode 100644 index 0000000..3f0e3d1 --- /dev/null +++ b/src-examples/BuilderConsumer/Settings.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace BuilderConsumer +{ + public class Settings + { + public IReadOnlyCollection Contents { get; set; } + } +} \ No newline at end of file diff --git a/src-examples/BuilderConsumer/SettingsBuilder.cs b/src-examples/BuilderConsumer/SettingsBuilder.cs new file mode 100644 index 0000000..2159355 --- /dev/null +++ b/src-examples/BuilderConsumer/SettingsBuilder.cs @@ -0,0 +1,9 @@ +using FluentBuilder; + +namespace BuilderConsumer +{ + [AutoGenerateBuilder(typeof(Settings))] + public partial class SettingsBuilder + { + } +} \ No newline at end of file diff --git a/src/FluentBuilderGenerator/Extensions/EnumExtensions.cs b/src/FluentBuilderGenerator/Extensions/EnumExtensions.cs index 840b96f..17b7e94 100644 --- a/src/FluentBuilderGenerator/Extensions/EnumExtensions.cs +++ b/src/FluentBuilderGenerator/Extensions/EnumExtensions.cs @@ -10,8 +10,9 @@ internal static class EnumExtensions { FluentTypeKind.Array, FileDataType.ArrayBuilder }, { FluentTypeKind.IEnumerable, FileDataType.IEnumerableBuilder }, { FluentTypeKind.ICollection, FileDataType.ICollectionBuilder }, + { FluentTypeKind.IList, FileDataType.IListBuilder }, { FluentTypeKind.IReadOnlyCollection, FileDataType.IReadOnlyCollectionBuilder }, - { FluentTypeKind.IList, FileDataType.IListBuilder } + { FluentTypeKind.IReadOnlyList, FileDataType.IReadOnlyListBuilder }, }; private static readonly IDictionary FileToKind = KindToFile.ToDictionary(x => x.Value, x => x.Key); diff --git a/src/FluentBuilderGenerator/Extensions/PropertySymbolExtensions.cs b/src/FluentBuilderGenerator/Extensions/PropertySymbolExtensions.cs index bd3277f..e82114b 100644 --- a/src/FluentBuilderGenerator/Extensions/PropertySymbolExtensions.cs +++ b/src/FluentBuilderGenerator/Extensions/PropertySymbolExtensions.cs @@ -8,9 +8,11 @@ internal static class PropertySymbolExtensions // ReSharper disable once InconsistentNaming private static readonly FluentTypeKind[] IEnumerableKinds = { + FluentTypeKind.ICollection, FluentTypeKind.IEnumerable, FluentTypeKind.IList, - FluentTypeKind.ICollection + FluentTypeKind.IReadOnlyCollection, + FluentTypeKind.IReadOnlyList }; internal static bool IsPrivateSettable(this IPropertySymbol property) diff --git a/src/FluentBuilderGenerator/Extensions/TypeSymbolExtensions.cs b/src/FluentBuilderGenerator/Extensions/TypeSymbolExtensions.cs index eecbe4a..9f480a1 100644 --- a/src/FluentBuilderGenerator/Extensions/TypeSymbolExtensions.cs +++ b/src/FluentBuilderGenerator/Extensions/TypeSymbolExtensions.cs @@ -39,6 +39,11 @@ public static FluentTypeKind GetFluentTypeKind(this ITypeSymbol typeSymbol) return FluentTypeKind.IList; } + if (typeSymbol.ImplementsInterfaceOrBaseClass(typeof(IReadOnlyList<>))) + { + return FluentTypeKind.IReadOnlyList; + } + if (typeSymbol.ImplementsInterfaceOrBaseClass(typeof(IReadOnlyCollection<>))) { return FluentTypeKind.IReadOnlyCollection; diff --git a/src/FluentBuilderGenerator/FileGenerators/FluentBuilderClassesGenerator.cs b/src/FluentBuilderGenerator/FileGenerators/FluentBuilderClassesGenerator.cs index 6fcbb7c..8c306f7 100644 --- a/src/FluentBuilderGenerator/FileGenerators/FluentBuilderClassesGenerator.cs +++ b/src/FluentBuilderGenerator/FileGenerators/FluentBuilderClassesGenerator.cs @@ -31,9 +31,11 @@ internal partial class FluentBuilderClassesGenerator : IFilesGenerator private static readonly FileDataType[] ExtraBuilders = { FileDataType.ArrayBuilder, + FileDataType.ICollectionBuilder, FileDataType.IEnumerableBuilder, FileDataType.IListBuilder, - FileDataType.ICollectionBuilder + FileDataType.IReadOnlyCollectionBuilder, + FileDataType.IReadOnlyListBuilder }; private readonly IGeneratorExecutionContextWrapper _context; diff --git a/src/FluentBuilderGenerator/FluentBuilderGenerator.csproj b/src/FluentBuilderGenerator/FluentBuilderGenerator.csproj index 39647a1..3ee72c4 100644 --- a/src/FluentBuilderGenerator/FluentBuilderGenerator.csproj +++ b/src/FluentBuilderGenerator/FluentBuilderGenerator.csproj @@ -1,9 +1,9 @@ - 0.9.0 + 0.9.1 netstandard2.0 - 11 + latest true enable {12344228-91F4-4502-9595-39584E5A9944} diff --git a/src/FluentBuilderGenerator/FluentBuilderSourceGenerator.cs b/src/FluentBuilderGenerator/FluentBuilderSourceGenerator.cs index 5b7cee3..fa9ec1c 100644 --- a/src/FluentBuilderGenerator/FluentBuilderSourceGenerator.cs +++ b/src/FluentBuilderGenerator/FluentBuilderSourceGenerator.cs @@ -55,14 +55,18 @@ private static void InjectGeneratedClasses(IGeneratorExecutionContextWrapper con { var generators = new IFileGenerator[] { - new ExtraFilesGenerator(context.AssemblyName, context.SupportsNullable), new BaseBuilderGenerator(context.AssemblyName, context.SupportsNullable), + + new ExtraFilesGenerator(context.AssemblyName, context.SupportsNullable), + + new IDictionaryBuilderGenerator(context.AssemblyName, context.SupportsNullable), + new IEnumerableBuilderGenerator(context.AssemblyName, FileDataType.ArrayBuilder, context.SupportsNullable), + new IEnumerableBuilderGenerator(context.AssemblyName, FileDataType.ICollectionBuilder, context.SupportsNullable), new IEnumerableBuilderGenerator(context.AssemblyName, FileDataType.IEnumerableBuilder, context.SupportsNullable), new IEnumerableBuilderGenerator(context.AssemblyName, FileDataType.IListBuilder, context.SupportsNullable), new IEnumerableBuilderGenerator(context.AssemblyName, FileDataType.IReadOnlyCollectionBuilder, context.SupportsNullable), - new IEnumerableBuilderGenerator(context.AssemblyName, FileDataType.ICollectionBuilder, context.SupportsNullable), - new IDictionaryBuilderGenerator(context.AssemblyName, context.SupportsNullable) + new IEnumerableBuilderGenerator(context.AssemblyName, FileDataType.IReadOnlyListBuilder, context.SupportsNullable), }; foreach (var generator in generators) diff --git a/src/FluentBuilderGenerator/Helpers/IEnumerableBuilderHelper.cs b/src/FluentBuilderGenerator/Helpers/IEnumerableBuilderHelper.cs index d65cbd3..05576cb 100644 --- a/src/FluentBuilderGenerator/Helpers/IEnumerableBuilderHelper.cs +++ b/src/FluentBuilderGenerator/Helpers/IEnumerableBuilderHelper.cs @@ -10,10 +10,11 @@ public static (string GenericType, string ToArray) GetGenericTypeAndToArray(File return dataType switch { FileDataType.ArrayBuilder => ($"{t}[]", ".ToArray()"), - FileDataType.IEnumerableBuilder => ($"IEnumerable<{t}>", string.Empty), - FileDataType.IReadOnlyCollectionBuilder => ($"IReadOnlyCollection<{t}>", string.Empty), FileDataType.ICollectionBuilder => ($"ICollection<{t}>", string.Empty), + FileDataType.IEnumerableBuilder => ($"IEnumerable<{t}>", string.Empty), FileDataType.IListBuilder => ($"IList<{t}>", string.Empty), + FileDataType.IReadOnlyCollectionBuilder => ($"IReadOnlyCollection<{t}>", string.Empty), + FileDataType.IReadOnlyListBuilder => ($"IReadOnlyList<{t}>", string.Empty), _ => throw new ArgumentException() }; } diff --git a/src/FluentBuilderGenerator/Types/FileDataType.cs b/src/FluentBuilderGenerator/Types/FileDataType.cs index 04d4bd2..dbae84d 100644 --- a/src/FluentBuilderGenerator/Types/FileDataType.cs +++ b/src/FluentBuilderGenerator/Types/FileDataType.cs @@ -5,21 +5,23 @@ internal enum FileDataType : byte { None, + ArrayBuilder, + Attribute, Base, Builder, - ArrayBuilder, + ICollectionBuilder, + + IDictionaryBuilder, IEnumerableBuilder, IListBuilder, - ICollectionBuilder, - IReadOnlyCollectionBuilder, - IDictionaryBuilder + IReadOnlyListBuilder, } \ No newline at end of file diff --git a/src/FluentBuilderGenerator/Types/FluentTypeKind.cs b/src/FluentBuilderGenerator/Types/FluentTypeKind.cs index f81dbe0..ea7f22b 100644 --- a/src/FluentBuilderGenerator/Types/FluentTypeKind.cs +++ b/src/FluentBuilderGenerator/Types/FluentTypeKind.cs @@ -5,21 +5,23 @@ internal enum FluentTypeKind : byte { None, - String, - Array, - IEnumerable, - ICollection, - IReadOnlyCollection, - + IDictionary, + + IEnumerable, + IList, - IDictionary, + IReadOnlyCollection, + IReadOnlyList, + ReadOnlyCollection, + String, + Other } \ No newline at end of file diff --git a/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespaceBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespaceBuilder.g.cs index 11459a5..acc7492 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespaceBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespaceBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespace_IListBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespace_IListBuilder.g.cs index 5b6e3fc..9fb6015 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespace_IListBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/AbcTest.OtherNamespace.ClassOnOtherNamespace_IListBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/Address.cs b/tests/FluentBuilderGeneratorTests/DTO/Address.cs index 71a039b..d0a4153 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/Address.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/Address.cs @@ -29,8 +29,16 @@ public class Address public IReadOnlyCollection IReadOnlyCollection { get; set; } + public IReadOnlyCollection IReadOnlyCollectionThing { get; set; } + + public IReadOnlyCollection
IReadOnlyCollectionAddress { get; set; } + public ReadOnlyCollection ReadOnlyCollection { get; set; } + public IReadOnlyList IReadOnlyList { get; set; } + + public IReadOnlyList
IReadOnlyListAddress { get; set; } + public IEnumerable Enumerable { get; set; } public IEnumerable
Enumerable2 { get; set; } diff --git a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.AddressBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.AddressBuilder.g.cs index 930d84e..e167e73 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.AddressBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.AddressBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -138,6 +138,42 @@ public AddressBuilder WithIReadOnlyCollection(Func> action, bool useObjectInitializer = true) => WithIReadOnlyCollection(() => + { + var builder = new FluentBuilderGeneratorTests.FluentBuilder.IReadOnlyCollectionBuilder(); + action(builder); + return builder.Build(useObjectInitializer); + }); + private bool _iReadOnlyCollectionThingIsSet; + private Lazy> _iReadOnlyCollectionThing = new Lazy>(() => new List()); + public AddressBuilder WithIReadOnlyCollectionThing(System.Collections.Generic.IReadOnlyCollection value) => WithIReadOnlyCollectionThing(() => value); + public AddressBuilder WithIReadOnlyCollectionThing(Func> func) + { + _iReadOnlyCollectionThing = new Lazy>(func); + _iReadOnlyCollectionThingIsSet = true; + return this; + } + public AddressBuilder WithIReadOnlyCollectionThing(Action> action, bool useObjectInitializer = true) => WithIReadOnlyCollectionThing(() => + { + var builder = new FluentBuilderGeneratorTests.FluentBuilder.IReadOnlyCollectionBuilder(); + action(builder); + return builder.Build(useObjectInitializer); + }); + private bool _iReadOnlyCollectionAddressIsSet; + private Lazy> _iReadOnlyCollectionAddress = new Lazy>(() => new List()); + public AddressBuilder WithIReadOnlyCollectionAddress(System.Collections.Generic.IReadOnlyCollection value) => WithIReadOnlyCollectionAddress(() => value); + public AddressBuilder WithIReadOnlyCollectionAddress(Func> func) + { + _iReadOnlyCollectionAddress = new Lazy>(func); + _iReadOnlyCollectionAddressIsSet = true; + return this; + } + public AddressBuilder WithIReadOnlyCollectionAddress(Action action, bool useObjectInitializer = true) => WithIReadOnlyCollectionAddress(() => + { + var builder = new FluentBuilderGeneratorTests.DTO.IReadOnlyCollectionAddressBuilder(); + action(builder); + return builder.Build(useObjectInitializer); + }); private bool _readOnlyCollectionIsSet; private Lazy> _readOnlyCollection = new Lazy>(() => new System.Collections.ObjectModel.ReadOnlyCollection(new List())); public AddressBuilder WithReadOnlyCollection(System.Collections.ObjectModel.ReadOnlyCollection value) => WithReadOnlyCollection(() => value); @@ -147,6 +183,36 @@ public AddressBuilder WithReadOnlyCollection(Func> _iReadOnlyList = new Lazy>(() => default(System.Collections.Generic.IReadOnlyList)); + public AddressBuilder WithIReadOnlyList(System.Collections.Generic.IReadOnlyList value) => WithIReadOnlyList(() => value); + public AddressBuilder WithIReadOnlyList(Func> func) + { + _iReadOnlyList = new Lazy>(func); + _iReadOnlyListIsSet = true; + return this; + } + public AddressBuilder WithIReadOnlyList(Action> action, bool useObjectInitializer = true) => WithIReadOnlyList(() => + { + var builder = new FluentBuilderGeneratorTests.FluentBuilder.IReadOnlyListBuilder(); + action(builder); + return builder.Build(useObjectInitializer); + }); + private bool _iReadOnlyListAddressIsSet; + private Lazy> _iReadOnlyListAddress = new Lazy>(() => default(System.Collections.Generic.IReadOnlyList)); + public AddressBuilder WithIReadOnlyListAddress(System.Collections.Generic.IReadOnlyList value) => WithIReadOnlyListAddress(() => value); + public AddressBuilder WithIReadOnlyListAddress(Func> func) + { + _iReadOnlyListAddress = new Lazy>(func); + _iReadOnlyListAddressIsSet = true; + return this; + } + public AddressBuilder WithIReadOnlyListAddress(Action action, bool useObjectInitializer = true) => WithIReadOnlyListAddress(() => + { + var builder = new FluentBuilderGeneratorTests.DTO.IReadOnlyListAddressBuilder(); + action(builder); + return builder.Build(useObjectInitializer); + }); private bool _enumerableIsSet; private Lazy> _enumerable = new Lazy>(() => new byte[0]); public AddressBuilder WithEnumerable(System.Collections.Generic.IEnumerable value) => WithEnumerable(() => value); @@ -326,7 +392,11 @@ public override Address Build(bool useObjectInitializer) Thing = _thing.Value, ThingIsStruct = _thingIsStruct.Value, IReadOnlyCollection = _iReadOnlyCollection.Value, + IReadOnlyCollectionThing = _iReadOnlyCollectionThing.Value, + IReadOnlyCollectionAddress = _iReadOnlyCollectionAddress.Value, ReadOnlyCollection = _readOnlyCollection.Value, + IReadOnlyList = _iReadOnlyList.Value, + IReadOnlyListAddress = _iReadOnlyListAddress.Value, Enumerable = _enumerable.Value, Enumerable2 = _enumerable2.Value, List = _list.Value, @@ -359,7 +429,11 @@ public override Address Build(bool useObjectInitializer) if (_thingIsSet) { Instance.Value.Thing = _thing.Value; } if (_thingIsStructIsSet) { Instance.Value.ThingIsStruct = _thingIsStruct.Value; } if (_iReadOnlyCollectionIsSet) { Instance.Value.IReadOnlyCollection = _iReadOnlyCollection.Value; } + if (_iReadOnlyCollectionThingIsSet) { Instance.Value.IReadOnlyCollectionThing = _iReadOnlyCollectionThing.Value; } + if (_iReadOnlyCollectionAddressIsSet) { Instance.Value.IReadOnlyCollectionAddress = _iReadOnlyCollectionAddress.Value; } if (_readOnlyCollectionIsSet) { Instance.Value.ReadOnlyCollection = _readOnlyCollection.Value; } + if (_iReadOnlyListIsSet) { Instance.Value.IReadOnlyList = _iReadOnlyList.Value; } + if (_iReadOnlyListAddressIsSet) { Instance.Value.IReadOnlyListAddress = _iReadOnlyListAddress.Value; } if (_enumerableIsSet) { Instance.Value.Enumerable = _enumerable.Value; } if (_enumerable2IsSet) { Instance.Value.Enumerable2 = _enumerable2.Value; } if (_listIsSet) { Instance.Value.List = _list.Value; } diff --git a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ArrayBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ArrayBuilder.g.cs index af7511f..349d07e 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ArrayBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ArrayBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ICollectionBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ICollectionBuilder.g.cs index 492dbbe..4d0fe8e 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ICollectionBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_ICollectionBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IEnumerableBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IEnumerableBuilder.g.cs index bedce9b..c138e32 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IEnumerableBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IEnumerableBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IListBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IListBuilder.g.cs index a1b7db0..e0f90dd 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IListBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IListBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IReadOnlyCollectionBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IReadOnlyCollectionBuilder.g.cs new file mode 100644 index 0000000..86109ee --- /dev/null +++ b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IReadOnlyCollectionBuilder.g.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +#nullable enable +using System; +using System.Collections; +using System.Collections.Generic; +using FluentBuilderGeneratorTests.FluentBuilder; +using FluentBuilderGeneratorTests.DTO; + +namespace FluentBuilderGeneratorTests.DTO +{ + public partial class IReadOnlyCollectionAddressBuilder : Builder> + { + private readonly Lazy> _list = new Lazy>(() => new List()); + public IReadOnlyCollectionAddressBuilder Add(Address item) => Add(() => item); + public IReadOnlyCollectionAddressBuilder Add(Func
func) + { + _list.Value.Add(func()); + return this; + } + public IReadOnlyCollectionAddressBuilder Add(Action action, bool useObjectInitializer = true) + { + var builder = new FluentBuilderGeneratorTests.DTO.AddressBuilder(); + action(builder); + Add(() => builder.Build(useObjectInitializer)); + return this; + } + + + public override IReadOnlyCollection Build() => Build(true); + + public override IReadOnlyCollection Build(bool useObjectInitializer) + { + if (Instance?.IsValueCreated != true) + { + Instance = new Lazy>(() => + { + return _list.Value; + }); + } + + PostBuild(Instance.Value); + + return Instance.Value; + } + + } +} +#nullable disable \ No newline at end of file diff --git a/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IReadOnlyListBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IReadOnlyListBuilder.g.cs new file mode 100644 index 0000000..a092ce3 --- /dev/null +++ b/tests/FluentBuilderGeneratorTests/DTO/BuilderGeneratorTests.DTO.Address_IReadOnlyListBuilder.g.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +#nullable enable +using System; +using System.Collections; +using System.Collections.Generic; +using FluentBuilderGeneratorTests.FluentBuilder; +using FluentBuilderGeneratorTests.DTO; + +namespace FluentBuilderGeneratorTests.DTO +{ + public partial class IReadOnlyListAddressBuilder : Builder> + { + private readonly Lazy> _list = new Lazy>(() => new List()); + public IReadOnlyListAddressBuilder Add(Address item) => Add(() => item); + public IReadOnlyListAddressBuilder Add(Func
func) + { + _list.Value.Add(func()); + return this; + } + public IReadOnlyListAddressBuilder Add(Action action, bool useObjectInitializer = true) + { + var builder = new FluentBuilderGeneratorTests.DTO.AddressBuilder(); + action(builder); + Add(() => builder.Build(useObjectInitializer)); + return this; + } + + + public override IReadOnlyList Build() => Build(true); + + public override IReadOnlyList Build(bool useObjectInitializer) + { + if (Instance?.IsValueCreated != true) + { + Instance = new Lazy>(() => + { + return _list.Value; + }); + } + + PostBuild(Instance.Value); + + return Instance.Value; + } + + } +} +#nullable disable \ No newline at end of file diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ArrayBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ArrayBuilder.g.cs index 033377f..b21f9d8 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ArrayBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ArrayBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.BaseBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.BaseBuilder.g.cs index f61a0aa..95a512f 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.BaseBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.BaseBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.Extra.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.Extra.g.cs index aead85e..1e6bf56 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.Extra.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.Extra.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ICollectionBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ICollectionBuilder.g.cs index eeabb2f..9271b2f 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ICollectionBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.ICollectionBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IDictionaryBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IDictionaryBuilder.g.cs index 338bcb4..fc2fc63 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IDictionaryBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IDictionaryBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IEnumerableBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IEnumerableBuilder.g.cs index 4d8e258..6308986 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IEnumerableBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IEnumerableBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IListBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IListBuilder.g.cs index 38464d9..2f48c0b 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IListBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IListBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IReadOnlyCollectionBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IReadOnlyCollectionBuilder.g.cs index c059dcc..375495c 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IReadOnlyCollectionBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IReadOnlyCollectionBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IReadOnlyListBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IReadOnlyListBuilder.g.cs new file mode 100644 index 0000000..c51bb0c --- /dev/null +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilder.IReadOnlyListBuilder.g.cs @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +#nullable enable +using System; +using System.Collections.Generic; + +namespace FluentBuilderGeneratorTests.FluentBuilder +{ + public partial class IReadOnlyListBuilder : Builder> + { + private readonly Lazy> _list = new Lazy>(() => new List()); + + public IReadOnlyListBuilder Add(T item) => Add(() => item); + public IReadOnlyListBuilder Add(Func func) + { + _list.Value.Add(func()); + + return this; + } + + public override IReadOnlyList Build() => Build(true); + + public override IReadOnlyList Build(bool useObjectInitializer) + { + if (Instance?.IsValueCreated != true) + { + Instance = new Lazy>(() => + { + return _list.Value; + }); + } + + PostBuild(Instance.Value); + + return Instance.Value; + } + } +} +#nullable disable \ No newline at end of file diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressBuilder_T_.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressBuilder_T_.g.cs index 0e7560c..ae325d2 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressBuilder_T_.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressBuilder_T_.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressTTBuilder_T1_T2_.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressTTBuilder_T1_T2_.g.cs index 0f2c68d..709f1c5 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressTTBuilder_T1_T2_.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.AddressTTBuilder_T1_T2_.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithFuncAndActionBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithFuncAndActionBuilder.g.cs index a7cc20c..a78787e 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithFuncAndActionBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithFuncAndActionBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithInitBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithInitBuilder.g.cs index 4bc9c99..2843b74 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithInitBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithInitBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter1Builder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter1Builder.g.cs index f7e2314..314304a 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter1Builder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter1Builder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter2Builder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter2Builder.g.cs index 9579833..09b303d 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter2Builder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPrivateSetter2Builder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPropertyValueSetBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPropertyValueSetBuilder.g.cs index 5a392cb..bc2b305 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPropertyValueSetBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ClassWithPropertyValueSetBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.MyDummyClassBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.MyDummyClassBuilder.g.cs index 7ba6ae0..e76e307 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.MyDummyClassBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.MyDummyClassBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.TestBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.TestBuilder.g.cs index fd481d0..1851326 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.TestBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.TestBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ThingBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ThingBuilder.g.cs index 8e57b87..2fc36d9 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ThingBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.ThingBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserBuilder.g.cs index af5db73..9d49892 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTBuilder_T_.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTBuilder_T_.g.cs index fdfa51d..0029819 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTBuilder_T_.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTBuilder_T_.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressAndConstructorBuilder_T_.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressAndConstructorBuilder_T_.g.cs index e3bb631..495f066 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressAndConstructorBuilder_T_.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressAndConstructorBuilder_T_.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressTBuilder_T_.g.cs b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressTBuilder_T_.g.cs index a436623..6067af0 100644 --- a/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressTBuilder_T_.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO/FluentBuilderGeneratorTests.DTO.UserTWithAddressTBuilder_T_.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO.Option_IListBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO.Option_IListBuilder.g.cs index f2a8695..9c6c33e 100644 --- a/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO.Option_IListBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO.Option_IListBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO2.MyOptionBuilder.g.cs b/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO2.MyOptionBuilder.g.cs index 5f4ce62..49a296c 100644 --- a/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO2.MyOptionBuilder.g.cs +++ b/tests/FluentBuilderGeneratorTests/DTO2/FluentBuilderGeneratorTests.DTO2.MyOptionBuilder.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/FluentBuilderGeneratorTests/FluentBuilderGeneratorTests.csproj b/tests/FluentBuilderGeneratorTests/FluentBuilderGeneratorTests.csproj index e857ddb..3458862 100644 --- a/tests/FluentBuilderGeneratorTests/FluentBuilderGeneratorTests.csproj +++ b/tests/FluentBuilderGeneratorTests/FluentBuilderGeneratorTests.csproj @@ -1,9 +1,8 @@ - net6.0 + net8.0 false - 10.0 enable Debug;Release;DebugAttach diff --git a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ClassWithFluentBuilderIgnore_Should_GenerateCorrectFiles.verified.txt b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ClassWithFluentBuilderIgnore_Should_GenerateCorrectFiles.verified.txt index c0c78b7..10a5c2c 100644 --- a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ClassWithFluentBuilderIgnore_Should_GenerateCorrectFiles.verified.txt +++ b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ClassWithFluentBuilderIgnore_Should_GenerateCorrectFiles.verified.txt @@ -1,9 +1,9 @@ { - HintName: FluentBuilderGeneratorTests.DTO.ClassWithFluentBuilderIgnoreBuilder.g.cs, + HintName: FluentBuilder.IReadOnlyListBuilder.g.cs, Source: //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,94 +12,38 @@ #nullable enable using System; -using System.Collections; using System.Collections.Generic; -using System.Reflection; -using FluentBuilderGeneratorTests.FluentBuilder; -using FluentBuilderGeneratorTests.DTO; -namespace FluentBuilderGeneratorTests.DTO +namespace FluentBuilderGeneratorTests.FluentBuilder { - public static partial class ClassWithFluentBuilderIgnoreBuilderExtensions + public partial class IReadOnlyListBuilder : Builder> { - public static ClassWithFluentBuilderIgnoreBuilder AsBuilder(this FluentBuilderGeneratorTests.DTO.ClassWithFluentBuilderIgnore instance) - { - return new ClassWithFluentBuilderIgnoreBuilder().UsingInstance(instance); - } - } + private readonly Lazy> _list = new Lazy>(() => new List()); - public partial class ClassWithFluentBuilderIgnoreBuilder : Builder - { - private bool _idIsSet; - private Lazy _id = new Lazy(() => default(int)); - public ClassWithFluentBuilderIgnoreBuilder WithId(int value) => WithId(() => value); - public ClassWithFluentBuilderIgnoreBuilder WithId(Func func) + public IReadOnlyListBuilder Add(T item) => Add(() => item); + public IReadOnlyListBuilder Add(Func func) { - _id = new Lazy(func); - _idIsSet = true; - return this; - } - - private bool _Constructor1291238155_IsSet; - private Lazy _Constructor1291238155 = new Lazy(() => new FluentBuilderGeneratorTests.DTO.ClassWithFluentBuilderIgnore()); - public ClassWithFluentBuilderIgnoreBuilder UsingConstructor() - { - _Constructor1291238155 = new Lazy(() => - { - return new FluentBuilderGeneratorTests.DTO.ClassWithFluentBuilderIgnore - ( - - ); - }); - _Constructor1291238155_IsSet = true; - - return this; - } - + _list.Value.Add(func()); - public ClassWithFluentBuilderIgnoreBuilder UsingInstance(ClassWithFluentBuilderIgnore value) => UsingInstance(() => value); - - public ClassWithFluentBuilderIgnoreBuilder UsingInstance(Func func) - { - Instance = new Lazy(func); return this; } - public override ClassWithFluentBuilderIgnore Build() => Build(true); + public override IReadOnlyList Build() => Build(true); - public override ClassWithFluentBuilderIgnore Build(bool useObjectInitializer) + public override IReadOnlyList Build(bool useObjectInitializer) { - if (Instance is null) + if (Instance?.IsValueCreated != true) { - Instance = new Lazy(() => + Instance = new Lazy>(() => { - ClassWithFluentBuilderIgnore instance; - if (useObjectInitializer) - { - instance = new ClassWithFluentBuilderIgnore - { - Id = _id.Value - }; - - return instance; - } - - if (_Constructor1291238155_IsSet) { instance = _Constructor1291238155.Value; } - else { instance = Default(); } - - return instance; + return _list.Value; }); } - if (_idIsSet) { Instance.Value.Id = _id.Value; } - PostBuild(Instance.Value); return Instance.Value; } - - public static ClassWithFluentBuilderIgnore Default() => new ClassWithFluentBuilderIgnore(); - } } #nullable disable diff --git a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForAClassWithoutAPublicConstructor_Should_Create_ErrorFile.verified.txt b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForAClassWithoutAPublicConstructor_Should_Create_ErrorFile.verified.txt index a98000b..31d9337 100644 --- a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForAClassWithoutAPublicConstructor_Should_Create_ErrorFile.verified.txt +++ b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForAClassWithoutAPublicConstructor_Should_Create_ErrorFile.verified.txt @@ -6,26 +6,24 @@ FluentBuilderSourceGenerator [Exception] System.NotSupportedException: Unable to generate a FluentBuilder for the class 'System.AppDomain' because no public constructor is defined. - at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.CreateClassBuilderCode(FluentData fluentData, ClassSymbol classSymbol, List`1 allClassSymbols) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 82 - at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.<>c__DisplayClass6_0.b__1(ValueTuple`2 classSymbol) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 53 + at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.CreateClassBuilderCode(FluentData fluentData, ClassSymbol classSymbol, List`1 allClassSymbols) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 84 + at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.<>c__DisplayClass6_0.b__1(ValueTuple`2 classSymbol) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 55 at System.Linq.Enumerable.SelectListIterator`2.MoveNext() at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other) at System.Linq.Enumerable.UnionIterator`1.FillSet() at System.Linq.Enumerable.UnionIterator`1.ToList() - at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) - at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.GenerateFiles() in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 71 - at FluentBuilderGenerator.FluentBuilderSourceGenerator.InjectFluentBuilderClasses(IGeneratorExecutionContextWrapper context, IAutoGenerateBuilderSyntaxReceiver receiver) in {SolutionDirectory}src\FluentBuilderGenerator\FluentBuilderSourceGenerator.cs:line 79 + at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.GenerateFiles() in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 73 + at FluentBuilderGenerator.FluentBuilderSourceGenerator.InjectFluentBuilderClasses(IGeneratorExecutionContextWrapper context, IAutoGenerateBuilderSyntaxReceiver receiver) in {SolutionDirectory}src\FluentBuilderGenerator\FluentBuilderSourceGenerator.cs:line 83 at FluentBuilderGenerator.FluentBuilderSourceGenerator.Execute(GeneratorExecutionContext context) in {SolutionDirectory}src\FluentBuilderGenerator\FluentBuilderSourceGenerator.cs:line 40 [StackTrace] - at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.CreateClassBuilderCode(FluentData fluentData, ClassSymbol classSymbol, List`1 allClassSymbols) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 82 - at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.<>c__DisplayClass6_0.b__1(ValueTuple`2 classSymbol) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 53 + at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.CreateClassBuilderCode(FluentData fluentData, ClassSymbol classSymbol, List`1 allClassSymbols) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 84 + at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.<>c__DisplayClass6_0.b__1(ValueTuple`2 classSymbol) in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 55 at System.Linq.Enumerable.SelectListIterator`2.MoveNext() at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other) at System.Linq.Enumerable.UnionIterator`1.FillSet() at System.Linq.Enumerable.UnionIterator`1.ToList() - at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) - at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.GenerateFiles() in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 71 - at FluentBuilderGenerator.FluentBuilderSourceGenerator.InjectFluentBuilderClasses(IGeneratorExecutionContextWrapper context, IAutoGenerateBuilderSyntaxReceiver receiver) in {SolutionDirectory}src\FluentBuilderGenerator\FluentBuilderSourceGenerator.cs:line 79 + at FluentBuilderGenerator.FileGenerators.FluentBuilderClassesGenerator.GenerateFiles() in {SolutionDirectory}src\FluentBuilderGenerator\FileGenerators\FluentBuilderClassesGenerator.cs:line 73 + at FluentBuilderGenerator.FluentBuilderSourceGenerator.InjectFluentBuilderClasses(IGeneratorExecutionContextWrapper context, IAutoGenerateBuilderSyntaxReceiver receiver) in {SolutionDirectory}src\FluentBuilderGenerator\FluentBuilderSourceGenerator.cs:line 83 at FluentBuilderGenerator.FluentBuilderSourceGenerator.Execute(GeneratorExecutionContext context) in {SolutionDirectory}src\FluentBuilderGenerator\FluentBuilderSourceGenerator.cs:line 40*/ } \ No newline at end of file diff --git a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithAndWithout_Should_GenerateCorrectFiles.verified.txt b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithAndWithout_Should_GenerateCorrectFiles.verified.txt index fe2863e..5338e62 100644 --- a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithAndWithout_Should_GenerateCorrectFiles.verified.txt +++ b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithAndWithout_Should_GenerateCorrectFiles.verified.txt @@ -1,9 +1,9 @@ { - HintName: FluentBuilderGeneratorTests.DTO.SimpleClassBuilder.g.cs, + HintName: FluentBuilder.IReadOnlyListBuilder.g.cs, Source: //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,101 +12,38 @@ #nullable enable using System; -using System.Collections; using System.Collections.Generic; -using System.Reflection; -using FluentBuilderGeneratorTests.FluentBuilder; -using FluentBuilderGeneratorTests.DTO; -namespace FluentBuilderGeneratorTests.DTO +namespace FluentBuilderGeneratorTests.FluentBuilder { - public static partial class SimpleClassBuilderExtensions + public partial class IReadOnlyListBuilder : Builder> { - public static SimpleClassBuilder AsBuilder(this FluentBuilderGeneratorTests.DTO.SimpleClass instance) - { - return new SimpleClassBuilder().UsingInstance(instance); - } - } + private readonly Lazy> _list = new Lazy>(() => new List()); - public partial class SimpleClassBuilder : Builder - { - private bool _idIsSet; - private Lazy _id = new Lazy(() => default(int)); - public SimpleClassBuilder WithId(int value) => WithId(() => value); - public SimpleClassBuilder WithId(Func func) - { - _id = new Lazy(func); - _idIsSet = true; - return this; - } - public SimpleClassBuilder WithoutId() + public IReadOnlyListBuilder Add(T item) => Add(() => item); + public IReadOnlyListBuilder Add(Func func) { - WithId(() => default(int)); - _idIsSet = false; - return this; - } - - - private bool _Constructor538961215_IsSet; - private Lazy _Constructor538961215 = new Lazy(() => new FluentBuilderGeneratorTests.DTO.SimpleClass()); - public SimpleClassBuilder UsingConstructor() - { - _Constructor538961215 = new Lazy(() => - { - return new FluentBuilderGeneratorTests.DTO.SimpleClass - ( + _list.Value.Add(func()); - ); - }); - _Constructor538961215_IsSet = true; - - return this; - } - - - public SimpleClassBuilder UsingInstance(SimpleClass value) => UsingInstance(() => value); - - public SimpleClassBuilder UsingInstance(Func func) - { - Instance = new Lazy(func); return this; } - public override SimpleClass Build() => Build(true); + public override IReadOnlyList Build() => Build(true); - public override SimpleClass Build(bool useObjectInitializer) + public override IReadOnlyList Build(bool useObjectInitializer) { - if (Instance is null) + if (Instance?.IsValueCreated != true) { - Instance = new Lazy(() => + Instance = new Lazy>(() => { - SimpleClass instance; - if (useObjectInitializer) - { - instance = new SimpleClass - { - Id = _id.Value - }; - - return instance; - } - - if (_Constructor538961215_IsSet) { instance = _Constructor538961215.Value; } - else { instance = Default(); } - - return instance; + return _list.Value; }); } - if (_idIsSet) { Instance.Value.Id = _id.Value; } - PostBuild(Instance.Value); return Instance.Value; } - - public static SimpleClass Default() => new SimpleClass(); - } } #nullable disable diff --git a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithOnly_Should_GenerateCorrectFiles.verified.txt b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithOnly_Should_GenerateCorrectFiles.verified.txt index 25ddb0e..5338e62 100644 --- a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithOnly_Should_GenerateCorrectFiles.verified.txt +++ b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_MethodsIsWithOnly_Should_GenerateCorrectFiles.verified.txt @@ -1,9 +1,9 @@ { - HintName: FluentBuilderGeneratorTests.DTO.SimpleClassBuilder.g.cs, + HintName: FluentBuilder.IReadOnlyListBuilder.g.cs, Source: //------------------------------------------------------------------------------ // -// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.0.0 +// This code was generated by https://github.com/StefH/FluentBuilder version 0.9.1.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,94 +12,38 @@ #nullable enable using System; -using System.Collections; using System.Collections.Generic; -using System.Reflection; -using FluentBuilderGeneratorTests.FluentBuilder; -using FluentBuilderGeneratorTests.DTO; -namespace FluentBuilderGeneratorTests.DTO +namespace FluentBuilderGeneratorTests.FluentBuilder { - public static partial class SimpleClassBuilderExtensions + public partial class IReadOnlyListBuilder : Builder> { - public static SimpleClassBuilder AsBuilder(this FluentBuilderGeneratorTests.DTO.SimpleClass instance) - { - return new SimpleClassBuilder().UsingInstance(instance); - } - } + private readonly Lazy> _list = new Lazy>(() => new List()); - public partial class SimpleClassBuilder : Builder - { - private bool _idIsSet; - private Lazy _id = new Lazy(() => default(int)); - public SimpleClassBuilder WithId(int value) => WithId(() => value); - public SimpleClassBuilder WithId(Func func) + public IReadOnlyListBuilder Add(T item) => Add(() => item); + public IReadOnlyListBuilder Add(Func func) { - _id = new Lazy(func); - _idIsSet = true; - return this; - } - - private bool _Constructor538961215_IsSet; - private Lazy _Constructor538961215 = new Lazy(() => new FluentBuilderGeneratorTests.DTO.SimpleClass()); - public SimpleClassBuilder UsingConstructor() - { - _Constructor538961215 = new Lazy(() => - { - return new FluentBuilderGeneratorTests.DTO.SimpleClass - ( - - ); - }); - _Constructor538961215_IsSet = true; - - return this; - } - + _list.Value.Add(func()); - public SimpleClassBuilder UsingInstance(SimpleClass value) => UsingInstance(() => value); - - public SimpleClassBuilder UsingInstance(Func func) - { - Instance = new Lazy(func); return this; } - public override SimpleClass Build() => Build(true); + public override IReadOnlyList Build() => Build(true); - public override SimpleClass Build(bool useObjectInitializer) + public override IReadOnlyList Build(bool useObjectInitializer) { - if (Instance is null) + if (Instance?.IsValueCreated != true) { - Instance = new Lazy(() => + Instance = new Lazy>(() => { - SimpleClass instance; - if (useObjectInitializer) - { - instance = new SimpleClass - { - Id = _id.Value - }; - - return instance; - } - - if (_Constructor538961215_IsSet) { instance = _Constructor538961215.Value; } - else { instance = Default(); } - - return instance; + return _list.Value; }); } - if (_idIsSet) { Instance.Value.Id = _id.Value; } - PostBuild(Instance.Value); return Instance.Value; } - - public static SimpleClass Default() => new SimpleClass(); - } } #nullable disable diff --git a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.cs b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.cs index 8827240..39cad10 100644 --- a/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.cs +++ b/tests/FluentBuilderGeneratorTests/FluentBuilderSourceGeneratorTests.cs @@ -16,6 +16,7 @@ namespace FluentBuilderGeneratorTests; [UsesVerify] public class FluentBuilderSourceGeneratorTests { + private const int NumFiles = 10; private const string Namespace = "FluentBuilderGeneratorTests"; private const bool Write = true; @@ -50,8 +51,8 @@ public Task GenerateFiles_ForAClassWithoutAPublicConstructor_Should_Create_Error var result = _sut.Execute(Namespace, new[] { sourceFile }); // Assert - result.Files.Should().HaveCount(9); - result.Files[8].Path.Should().EndWith("Error.g.cs"); + result.Files.Should().HaveCount(NumFiles); + result.Files[NumFiles - 1].Path.Should().EndWith("Error.g.cs"); // Verify var errorResult = result.GeneratorDriver.GetRunResult().Results.First().GeneratedSources.First(s => s.HintName.Contains("Error.g.cs")); @@ -75,7 +76,7 @@ public void GenerateFiles_ForAClassWithPublicParameterlessConstructors_Should_Ge // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); result.Files.Should().NotContain(r => r.Path.EndsWith("Error.g.cs")); for (int i = 8; i < 9; i++) @@ -106,7 +107,7 @@ public void GenerateFiles_ForAClassWithOnlyParameterizedConstructors_Should_Gene // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); result.Files.Should().NotContain(r => r.Path.EndsWith("Error.g.cs")); for (int i = 8; i < 9; i++) @@ -181,9 +182,9 @@ public void GenerateFiles_For2Classes_Should_GenerateCorrectFiles() // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(10); + result.Files.Should().HaveCount(NumFiles + 1); - for (int i = 8; i < 10; i++) + for (int i = NumFiles - 2; i < NumFiles + 1; i++) { var builder = result.Files[i]; @@ -215,9 +216,9 @@ public void GenerateFiles_ClassWithPrivateSetter_And_AccessibilityPublicAndPriva // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var fileResult = result.Files[8]; + var fileResult = result.Files[NumFiles - 1]; var filename = Path.GetFileName(fileResult.Path); File.WriteAllText($"../../../DTO/{filename}", fileResult.Text); @@ -252,9 +253,9 @@ public void GenerateFiles_ClassWithPrivateSetter_And_AccessibilityPublic_Should_ // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var fileResult = result.Files[8]; + var fileResult = result.Files[NumFiles - 1]; var filename = Path.GetFileName(fileResult.Path); fileResult.Text.Should().NotContain("InstanceType.GetProperty"); @@ -286,7 +287,7 @@ public Task GenerateFiles_ClassWithFluentBuilderIgnore_Should_GenerateCorrectFil // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); // Verify var errorResult = result.GeneratorDriver.GetRunResult().Results.First().GeneratedSources[8]; @@ -310,7 +311,7 @@ public Task GenerateFiles_ForSimpleClass_MethodsIsWithOnly_Should_GenerateCorrec // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); // Verify var errorResult = result.GeneratorDriver.GetRunResult().Results.First().GeneratedSources[8]; @@ -338,7 +339,7 @@ public Task GenerateFiles_ForSimpleClass_MethodsIsWithAndWithout_Should_Generate // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); // Verify var errorResult = result.GeneratorDriver.GetRunResult().Results.First().GeneratedSources[8]; @@ -351,22 +352,26 @@ public void GenerateFiles_ForClassWithArrayAndDictionaryProperty_Should_Generate // Arrange var fileNames = new[] { - "FluentBuilder.Extra.g.cs", "FluentBuilder.BaseBuilder.g.cs", + "FluentBuilder.Extra.g.cs", + + "FluentBuilder.IDictionaryBuilder.g.cs", "FluentBuilder.ArrayBuilder.g.cs", + "FluentBuilder.ICollectionBuilder.g.cs", "FluentBuilder.IEnumerableBuilder.g.cs", "FluentBuilder.IListBuilder.g.cs", "FluentBuilder.IReadOnlyCollectionBuilder.g.cs", - "FluentBuilder.ICollectionBuilder.g.cs", - "FluentBuilder.IDictionaryBuilder.g.cs", + "FluentBuilder.IReadOnlyListBuilder.g.cs", "BuilderGeneratorTests.DTO.AddressBuilder.g.cs", + "BuilderGeneratorTests.DTO.Address_ArrayBuilder.g.cs", + "BuilderGeneratorTests.DTO.Address_ICollectionBuilder.g.cs", "BuilderGeneratorTests.DTO.Address_IEnumerableBuilder.g.cs", "BuilderGeneratorTests.DTO.Address_IListBuilder.g.cs", - - "BuilderGeneratorTests.DTO.Address_ICollectionBuilder.g.cs", + "BuilderGeneratorTests.DTO.Address_IReadOnlyCollectionBuilder.g.cs", + "BuilderGeneratorTests.DTO.Address_IReadOnlyListBuilder.g.cs" }; var path = "./DTO/Address.cs"; @@ -414,9 +419,9 @@ public void GenerateFiles_For1GenericClass_Should_GenerateCorrectFiles() // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var builder = result.Files[8]; + var builder = result.Files[NumFiles - 1]; builder.Path.Should().EndWith(builderFileName); if (Write) File.WriteAllText($"../../../DTO/{builderFileName}", builder.Text); @@ -444,9 +449,9 @@ public void GenerateFiles_For1GenericClassTT_Should_GenerateCorrectFiles() // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var builder = result.Files[8]; + var builder = result.Files[NumFiles - 1]; builder.Path.Should().EndWith(builderFileName); if (Write) File.WriteAllText($"../../../DTO/{builderFileName}", builder.Text); @@ -484,9 +489,9 @@ public void GenerateFiles_For2GenericClasses_Should_GenerateCorrectFiles() // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(10); + result.Files.Should().HaveCount(NumFiles + 1); - for (int i = 8; i < 10; i++) + for (int i = NumFiles - 2; i < NumFiles + 1; i++) { var builder = result.Files[i]; //builder.Path.Should().EndWith(x.fileName); @@ -530,9 +535,9 @@ public void GenerateFiles_For2GenericClasses_WithDefaultConstructor_Should_Gener // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(10); + result.Files.Should().HaveCount(NumFiles + 1); - var builderForUserTWithAddressAndConstructor = result.Files[8]; + var builderForUserTWithAddressAndConstructor = result.Files[NumFiles - 1]; builderForUserTWithAddressAndConstructor.Path.Should().EndWith(builder1FileName); if (Write) File.WriteAllText($"../../../DTO/{builder1FileName}", builderForUserTWithAddressAndConstructor.Text); @@ -560,9 +565,9 @@ public void GenerateFiles_ClassWithReferenceToItself_Should_GenerateCorrectFiles // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var builder = result.Files[8]; + var builder = result.Files[NumFiles - 1]; builder.Path.Should().EndWith(builderFileName); if (Write) File.WriteAllText($"../../../DTO/{builderFileName}", builder.Text); @@ -590,9 +595,9 @@ public void GenerateFiles_ClassWithFuncAndAction_Should_GenerateCorrectFiles() // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var builder = result.Files[8]; + var builder = result.Files[NumFiles - 1]; builder.Path.Should().EndWith(builderFileName); if (Write) File.WriteAllText($"../../../DTO/{builderFileName}", builder.Text); @@ -620,9 +625,9 @@ public void GenerateFiles_ClassWithInit_Should_GenerateCorrectFiles() // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var builder = result.Files[8]; + var builder = result.Files[NumFiles - 1]; builder.Path.Should().EndWith(builderFileName); if (Write) File.WriteAllText($"../../../DTO/{builderFileName}", builder.Text); @@ -650,9 +655,9 @@ public void GenerateFiles_ClassWithPropertyWhichHasAValue_Should_GenerateCorrect // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(9); + result.Files.Should().HaveCount(NumFiles); - var builder = result.Files[8]; + var builder = result.Files[NumFiles - 1]; builder.Path.Should().EndWith(builderFileName); if (Write) File.WriteAllText($"../../../DTO/{builderFileName}", builder.Text); @@ -695,9 +700,9 @@ public void GenerateFiles_ForFluentBuilders_Should_GenerateCorrectFiles() // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(11); + result.Files.Should().HaveCount(NumFiles + 2); - for (int i = 8; i < result.Files.Count; i++) + for (int i = result.Files.Count - 2; i < result.Files.Count; i++) { var builder = result.Files[i]; //builder.Path.Should().EndWith(x.fileName); @@ -734,9 +739,9 @@ public void GenerateFiles_For2ClassesWithListBuilder_Should_GenerateCorrectFiles // Assert result.Valid.Should().BeTrue(); - result.Files.Should().HaveCount(11); + result.Files.Should().HaveCount(NumFiles + 2); - for (int i = 8; i < result.Files.Count; i++) + for (int i = result.Files.Count - 3; i < result.Files.Count; i++) { var builder = result.Files[i];