├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE ├── README.md ├── media ├── fluent-api-logo-128.jpg ├── fluent-api-logo-256.jpg └── fluent-api.gif └── src ├── ExampleProject ├── DockerFile.cs ├── Employee.cs ├── ExampleProject.csproj ├── ExchangeStudent.cs ├── HashCode.cs ├── HttpRequest.cs ├── Node.cs ├── Order.cs ├── OrderArbitrarySteps.cs ├── Person.cs ├── Program.cs └── Student.cs ├── M31.FluentApi.Generator ├── .editorconfig ├── AnalyzerReleases.Shipped.md ├── AnalyzerReleases.Unshipped.md ├── CodeBuilding │ ├── Class.cs │ ├── CodeBuilder.cs │ ├── CodeExtensions.cs │ ├── CodeFile.cs │ ├── Field.cs │ ├── GenericConstraintClause.cs │ ├── GenericConstraints.cs │ ├── GenericParameters.cs │ ├── Generics.cs │ ├── ICode.cs │ ├── Interface.cs │ ├── Method.cs │ ├── MethodBody.cs │ ├── MethodSignature.cs │ ├── Modifiers.cs │ ├── Parameter.cs │ ├── ParameterAnnotations.cs │ ├── ParameterKinds.cs │ ├── Parameters.cs │ └── Property.cs ├── CodeGeneration │ ├── CodeBoardActors │ │ ├── BuilderMethodsGeneration │ │ │ ├── BaseInterface.cs │ │ │ ├── BuilderGenerator.cs │ │ │ ├── BuilderInterface.cs │ │ │ ├── BuilderMethods.cs │ │ │ ├── BuilderMethodsCreator.cs │ │ │ ├── BuilderStepMethod.cs │ │ │ ├── InterfaceBuilderMethod.cs │ │ │ ├── InterjacentBuilderMethod.cs │ │ │ ├── LastStepBuilderMethod.cs │ │ │ ├── LoopHandling │ │ │ │ ├── DependencyLoop.cs │ │ │ │ ├── LoopDetector.cs │ │ │ │ ├── LoopHandler.cs │ │ │ │ └── TarjansSccAlgorithm.cs │ │ │ ├── StaticBuilderMethod.cs │ │ │ └── StaticSingleStepBuilderMethod.cs │ │ ├── Commons │ │ │ ├── BuildBodyCode.cs │ │ │ ├── BuilderMethod.cs │ │ │ ├── BuilderMethodFactory.cs │ │ │ └── ComputeValueCode.cs │ │ ├── ConstructorGenerator.cs │ │ ├── DuplicateMethodsChecking │ │ │ ├── BuilderMethodIdentity.cs │ │ │ ├── DuplicateMethods.cs │ │ │ ├── DuplicateMethodsChecker.cs │ │ │ └── DuplicateMethodsFinder.cs │ │ ├── EntityFieldGenerator.cs │ │ ├── ICodeBoardActor.cs │ │ ├── InitialStepMethodGenerator.cs │ │ ├── InnerBodyGeneration │ │ │ ├── InnerBodyCreator.cs │ │ │ ├── InnerBodyForMemberGenerator.cs │ │ │ ├── InnerBodyForMethodGenerator.cs │ │ │ └── InnerBodyGeneratorBase.cs │ │ └── MethodCreation │ │ │ ├── BuilderMethodCreator.cs │ │ │ ├── BuilderMethods.cs │ │ │ ├── Collections │ │ │ ├── ArrayCreator.cs │ │ │ ├── CollectionMethodCreator.cs │ │ │ ├── CollectionMethods.cs │ │ │ ├── GeneratedCollection.cs │ │ │ ├── HashSetCreator.cs │ │ │ └── ListCreator.cs │ │ │ ├── CompoundMethods.cs │ │ │ ├── CompoundPart.cs │ │ │ ├── DefaultMethod.cs │ │ │ ├── FluentMethods.cs │ │ │ ├── Forks │ │ │ ├── Fork.cs │ │ │ ├── ForkBuilderMethod.cs │ │ │ ├── ForkCreator.cs │ │ │ └── ForkUnderConstruction.cs │ │ │ ├── IBuilderMethodCreator.cs │ │ │ ├── LambdaMethod.cs │ │ │ ├── MemberMethod.cs │ │ │ ├── MethodCreator.cs │ │ │ ├── NullableMethod.cs │ │ │ └── PredicateMethods.cs │ ├── CodeBoardElements │ │ ├── BuildCallMethodCode.cs │ │ ├── BuilderAndTargetInfo.cs │ │ ├── CallMethodCode.cs │ │ ├── CodeBoard.cs │ │ ├── CodeTypeExtractor.cs │ │ ├── FluentApiSymbolInfo.cs │ │ ├── InnerBodyCreationDelegates.cs │ │ ├── MemberSymbolInfo.cs │ │ ├── MethodIdentity.cs │ │ ├── MethodSymbolInfo.cs │ │ ├── ParameterIdentity.cs │ │ ├── ParameterSymbolInfo.cs │ │ ├── ReservedVariableNames.cs │ │ └── SetMemberCode.cs │ ├── CodeGenerator.cs │ └── CodeGeneratorResult.cs ├── Commons │ ├── DeclaredAccessibilityExtensions.cs │ ├── EnumerableExtensions.cs │ ├── GenerationException.cs │ ├── HashCode.cs │ ├── ListDictionary.cs │ ├── StringBuilderExtensions.cs │ ├── StringExtensions.cs │ └── SyntaxNodeExtensions.cs ├── M31.FluentApi.Generator.csproj ├── SourceAnalyzers │ ├── DiagnosticExtensions.cs │ ├── FluentApiAnalyzer.cs │ ├── FluentApiCodeFixProvider.cs │ └── FluentApiDiagnostics.cs └── SourceGenerators │ ├── AttributeElements │ ├── AttributeDataExtended.cs │ ├── AttributeDataExtensions.cs │ ├── AttributeDataExtractor.cs │ ├── Attributes.cs │ └── FluentApiAttributeData.cs │ ├── AttributeInfo │ ├── AttributeInfoBase.cs │ ├── ControlAttributeInfoBase.cs │ ├── FluentApiAttributeInfo.cs │ ├── FluentBreakAttributeInfo.cs │ ├── FluentCollectionAttributeInfo.cs │ ├── FluentContinueWithAttributeInfo.cs │ ├── FluentDefaultAttributeInfo.cs │ ├── FluentLambdaAttributeInfo.cs │ ├── FluentMemberAttributeInfo.cs │ ├── FluentMethodAttributeInfo.cs │ ├── FluentNullableAttributeInfo.cs │ ├── FluentPredicateAttributeInfo.cs │ ├── FluentReturnAttributeInfo.cs │ ├── FluentSkippableAttributeInfo.cs │ ├── LambdaBuilderInfo.cs │ └── OrthogonalAttributeInfoBase.cs │ ├── ClassInfoAnalyzer.cs │ ├── ClassInfoFactory.cs │ ├── ClassInfoReport.cs │ ├── ClassInfoResult.cs │ ├── Collections │ ├── CollectionInference.cs │ └── CollectionType.cs │ ├── ConstructorInfo.cs │ ├── FluentApiAdditionalInfo.cs │ ├── FluentApiClassAdditionalInfo.cs │ ├── FluentApiClassInfo.cs │ ├── FluentApiInfo.cs │ ├── FluentApiInfoCreator.cs │ ├── FluentApiInfoGroup.cs │ ├── FluentApiInfoGroupCreator.cs │ ├── Generics │ ├── GenericInfo.cs │ ├── GenericTypeConstraints.cs │ └── GenericTypeParameter.cs │ ├── NameCreator.cs │ ├── SourceGenerator.cs │ ├── SourceGeneratorConfig.cs │ ├── Step.cs │ ├── SymbolExtensions.cs │ ├── SymbolInfoCreator.cs │ ├── TypeData.cs │ └── TypeDataCreator.cs ├── M31.FluentApi.Storybook ├── 01_Basics.cs ├── 02_ControlAttributes.cs ├── M31.FluentApi.Storybook.csproj └── Program.cs ├── M31.FluentApi.Tests ├── AnalyzerAndCodeFixes │ ├── AnalyzerAndCodeFixTests.cs │ ├── DiagnosticsDuringGenerationTests.cs │ ├── Helpers │ │ ├── AnalyzerAndCodeFixVerifier.cs │ │ ├── SourceWithFix.cs │ │ └── TestSourceCodeReader.cs │ └── TestClasses │ │ ├── AmbiguousConstructorsClass │ │ └── Student.cs │ │ ├── ConflictingControlAttributesClass1 │ │ └── Student.cs │ │ ├── ConflictingControlAttributesClass2 │ │ └── Student.cs │ │ ├── ConflictingControlAttributesClass3 │ │ └── Student.cs │ │ ├── DuplicateMainAttributeClass │ │ └── Student.cs │ │ ├── DuplicateMethodClass1 │ │ └── Student.cs │ │ ├── DuplicateMethodClass2 │ │ └── Student.cs │ │ ├── DuplicateMethodClass3 │ │ └── Student.cs │ │ ├── DuplicateMethodClass4 │ │ └── Student.cs │ │ ├── DuplicateMethodClass5 │ │ └── Student.cs │ │ ├── DuplicateMethodPartialClass │ │ ├── Student1.cs │ │ └── Student2.cs │ │ ├── FluentLambdaMemberWithoutFluentApiClass │ │ └── Student.cs │ │ ├── GetMissingSetClass │ │ ├── Student.cs │ │ └── Student.fixed.txt │ │ ├── GetMissingSetRecord │ │ ├── Student.cs │ │ └── Student.fixed.txt │ │ ├── GetMissingSetRecordStruct │ │ ├── Student.cs │ │ └── Student.fixed.txt │ │ ├── GetMissingSetStruct │ │ ├── Student.cs │ │ └── Student.fixed.txt │ │ ├── InvalidCollectionTypeClass │ │ └── Student.cs │ │ ├── InvalidFluentMethodReturnTypeClass │ │ ├── Student.cs │ │ └── Student.fixed.illustration.txt │ │ ├── InvalidFluentPredicateTypeClass │ │ └── Student.cs │ │ ├── InvalidNullableTypeClass │ │ └── Student.cs │ │ ├── MissingBuilderStepClass │ │ └── Student.cs │ │ ├── NullableTypeNoNullableAnnotationClass │ │ └── Student.cs │ │ ├── OrthogonalAttributeInCompoundClass │ │ └── Student.cs │ │ ├── OrthogonalAttributeWithoutMainAttributeClass │ │ └── Student.cs │ │ ├── PartialClass │ │ ├── Student1.cs │ │ └── Student2.cs │ │ ├── PrivateGetMissingSetClass │ │ ├── Student.cs │ │ └── Student.fixed.txt │ │ ├── PublicGetMissingSetClass │ │ ├── Student.cs │ │ └── Student.fixed.txt │ │ ├── ReservedMethodClass1 │ │ └── Student.cs │ │ ├── ReservedMethodClass2 │ │ └── Student.cs │ │ ├── SkippableLastStepClass1 │ │ └── Student.cs │ │ └── SkippableLastStepClass2 │ │ └── Student.cs ├── CodeGeneration │ ├── CodeGenerationExecutionTests.cs │ ├── CodeGenerationTests.cs │ ├── EqualityTests.cs │ ├── Helpers │ │ └── ListAndDictionary.cs │ ├── MethodIdentityTests.cs │ ├── TestClasses │ │ ├── Abstract │ │ │ ├── AliasNamespaceClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── CollectionInterfaceMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── CollectionMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── CollectionMemberClassWithSuppression │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── CollectionNullableArrayClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ContinueWithAfterCompoundClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ContinueWithInForkClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ContinueWithOfOverloadedMethodClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ContinueWithSelfClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── CustomFluentMethodNameClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── DefaultFluentMethodNameClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── EmptyClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentDefaultMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaClassInDifferentNamespace │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaCollectionClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaCompoundClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreatePhone.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ ├── Phone.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaCompoundOfSameTypeClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaManyCollectionsClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaManyPrivateCollectionsClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaNullablePropertyClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaRecursiveClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentLambdaSingleStepClass │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentMethodClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentMethodDefaultValuesClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentMethodParameterModifiersClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentNullableClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentNullableNoNullableAnnotationClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentNullableNoNullableAnnotationPrivateSetClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentReturnMultiStepClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentReturnMultiStepPrivateMethodsClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentReturnSingleStepClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FluentReturnSingleStepPrivateMethodsClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ForkClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── FullyQualifiedTypeClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericClassPrivateConstructor │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericClassPrivateDefaultConstructor │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericClassWithConstraints │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericClassWithGenericMethods │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericClassWithPrivateGenericMethods │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericMethodWithConstraintsClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericOverloadedMethodClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GenericOverloadedPrivateMethodClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GetInitPropertyClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GetPrivateInitPropertyClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── GetPrivateSetPropertyClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── InheritedClass │ │ │ │ ├── CreatePerson.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ ├── Person.cs │ │ │ │ └── Student.cs │ │ │ ├── InheritedClassPrivateSetters │ │ │ │ ├── CreatePerson.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ ├── Person.cs │ │ │ │ └── Student.cs │ │ │ ├── InheritedClassProtectedMembers │ │ │ │ ├── CreatePerson.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ ├── Person.cs │ │ │ │ └── Student.cs │ │ │ ├── InheritedClassProtectedSetters │ │ │ │ ├── CreatePerson.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ ├── Person.cs │ │ │ │ └── Student.cs │ │ │ ├── InheritedRecord │ │ │ │ ├── CreatePerson.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ ├── Person.cs │ │ │ │ └── Student.cs │ │ │ ├── InternalClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── InternalPropertyClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── NonGenericCollectionMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── NullablePredicateAndCollectionClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── OneMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── OverloadedMethodClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PartialClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ ├── Student1.cs │ │ │ │ └── Student2.cs │ │ │ ├── PredicateClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PredicatePrivateFieldClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PrivateConstructorClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PrivateFieldClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PrivateFluentMethodClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PrivateFluentMethodNullableParameterClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PrivateFluentMethodParameterModifiersClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PrivateReadonlyFieldClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PrivateUnderscoreFieldClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PublicFieldClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── PublicReadonlyFieldClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SameNameMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SkippableFirstMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SkippableFirstTwoMembersClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SkippableForkMembersClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SkippableLoopClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SkippableMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SkippableSeveralMembersClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── SkippableTwoLoopsClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ThreeMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ThreeMemberRecord │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ThreeMemberRecordPrimaryConstructor │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ThreeMemberRecordStruct │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ThreeMemberStruct │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── ThreePrivateMembersClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── TryBreakFluentApiClass1 │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── TryBreakFluentApiClass2 │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── TryBreakFluentApiClass3 │ │ │ │ ├── Address.cs │ │ │ │ ├── CreateAddress.g.cs │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── TwoMemberClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ ├── TwoParameterCompoundClass │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ │ └── TwoParameterCompoundClassReversedParameters │ │ │ │ ├── CreateStudent.expected.txt │ │ │ │ ├── CreateStudent.g.cs │ │ │ │ └── Student.cs │ │ ├── PersonClass │ │ │ ├── CreatePerson.expected.txt │ │ │ ├── CreatePerson.g.cs │ │ │ └── Person.cs │ │ └── StudentClass │ │ │ ├── CreateStudent.expected.txt │ │ │ ├── CreateStudent.g.cs │ │ │ └── Student.cs │ └── TestDataProvider.cs ├── Components │ ├── CodeBuilding │ │ ├── CodeBuildingTests.cs │ │ ├── Robots.expected.txt │ │ └── Robots.g.cs │ ├── CodeTypeExtractorTests.cs │ ├── CollectionInferenceTests.cs │ ├── Helpers │ │ └── TypeSymbolProvider.cs │ └── TarjansSccAlgorithmTests.cs ├── Helpers │ ├── GeneratorOutput.cs │ ├── GeneratorOutputs.cs │ ├── ManualGenerator.cs │ ├── SyntaxExtensions.cs │ └── TestClassCodeGenerator.cs └── M31.FluentApi.Tests.csproj ├── M31.FluentApi.sln ├── M31.FluentApi.sln.DotSettings ├── M31.FluentApi ├── Attributes │ ├── FluentApiAttribute.cs │ ├── FluentBreakAttribute.cs │ ├── FluentCollectionAttribute.cs │ ├── FluentContinueWithAttribute.cs │ ├── FluentDefaultAttribute.cs │ ├── FluentLambdaAttribute.cs │ ├── FluentMemberAttribute.cs │ ├── FluentMethodAttribute.cs │ ├── FluentNullableAttribute.cs │ ├── FluentPredicateAttribute.cs │ ├── FluentReturnAttribute.cs │ └── FluentSkippableAttribute.cs └── M31.FluentApi.csproj ├── delete-generated-files.sh └── find-generated-files.sh /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | pull_request: 8 | branches: [ main ] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v3 17 | - name: Setup .NET 18 | uses: actions/setup-dotnet@v3 19 | with: 20 | dotnet-version: 6.0.x 21 | - name: Restore dependencies 22 | run: dotnet restore 23 | working-directory: src 24 | - name: Build 25 | run: dotnet build --no-restore --maxcpucount:1 26 | working-directory: src 27 | - name: Test 28 | run: dotnet test --no-build --verbosity normal 29 | working-directory: src 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Kevin Schaal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /media/fluent-api-logo-128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m31coding/M31.FluentAPI/a8b2133e95adfa8123cc879706b74a569b489dec/media/fluent-api-logo-128.jpg -------------------------------------------------------------------------------- /media/fluent-api-logo-256.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m31coding/M31.FluentAPI/a8b2133e95adfa8123cc879706b74a569b489dec/media/fluent-api-logo-256.jpg -------------------------------------------------------------------------------- /media/fluent-api.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m31coding/M31.FluentAPI/a8b2133e95adfa8123cc879706b74a569b489dec/media/fluent-api.gif -------------------------------------------------------------------------------- /src/ExampleProject/Employee.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | // Example from https://stackoverflow.com/questions/59021513/using-fluent-interface-with-builder-pattern. 6 | 7 | using M31.FluentApi.Attributes; 8 | 9 | namespace ExampleProject; 10 | 11 | [FluentApi] 12 | public class Employee 13 | { 14 | [FluentMember(0)] 15 | public string Name { get; private set; } 16 | 17 | [FluentCollection(1, "Phone")] 18 | public List Phones { get; private set; } 19 | 20 | [FluentCollection(2, "Job")] 21 | public List Jobs { get; private set; } 22 | } 23 | 24 | [FluentApi] 25 | public class Phone 26 | { 27 | [FluentMember(0)] 28 | public string Number { get; private set; } 29 | 30 | [FluentMember(1)] 31 | public string Usage { get; private set; } 32 | } 33 | 34 | [FluentApi] 35 | public class Job 36 | { 37 | [FluentMember(0)] 38 | public string CompanyName { get; private set; } 39 | 40 | [FluentMember(1)] 41 | public int Salary { get; private set; } 42 | } -------------------------------------------------------------------------------- /src/ExampleProject/ExampleProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | $(BaseIntermediateOutputPath)Generated 17 | true 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/ExampleProject/ExchangeStudent.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace ExampleProject; 8 | 9 | [FluentApi] 10 | public class ExchangeStudent : Student 11 | { 12 | [FluentMember(6)] 13 | public string HomeCountry { get; private set; } 14 | } -------------------------------------------------------------------------------- /src/ExampleProject/Order.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | // Example from https://youtu.be/qCIr30WxJQw?si=FRALafrpA1zWACA8. 6 | // Implementation with forced steps. 7 | 8 | using M31.FluentApi.Attributes; 9 | 10 | namespace ExampleProject; 11 | 12 | [FluentApi] 13 | public class Order 14 | { 15 | [FluentMember(0)] 16 | public int Number { get; private set; } 17 | 18 | [FluentMember(1, "{Name}")] 19 | public DateTime CreatedOn { get; private set; } 20 | 21 | [FluentMember(2, "ShippedTo")] 22 | public Address ShippingAddress { get; private set; } 23 | } 24 | 25 | [FluentApi] 26 | public class Address 27 | { 28 | [FluentMember(0, "{Name}")] 29 | public string Street { get; private set; } 30 | 31 | [FluentMember(1, "{Name}")] 32 | public string City { get; private set; } 33 | 34 | [FluentMember(2, "{Name}")] 35 | public string Zip { get; private set; } 36 | 37 | [FluentMember(3, "{Name}")] 38 | [FluentDefault("Default{Name}")] 39 | public string State { get; private set; } = "N/A"; 40 | 41 | [FluentMember(4, "{Name}")] 42 | public string Country { get; private set; } 43 | } -------------------------------------------------------------------------------- /src/ExampleProject/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace ExampleProject; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "Named", 0)] 13 | public string FirstName { get; private set; } 14 | 15 | [FluentMember(0, "Named", 1)] 16 | public string LastName { get; private set; } 17 | 18 | [FluentMember(1, "OfAge")] 19 | public int Age { get; private set; } 20 | 21 | [FluentMethod(1)] 22 | private void BornOn(DateOnly dateOfBirth) 23 | { 24 | DateOnly today = DateOnly.FromDateTime(DateTime.Today); 25 | int age = today.Year - dateOfBirth.Year; 26 | if (dateOfBirth > today.AddYears(-age)) age--; 27 | Age = age; 28 | } 29 | 30 | [FluentMember(2, "InSemester")] 31 | [FluentDefault("WhoStartsUniversity")] 32 | public int Semester { get; private set; } = 0; 33 | 34 | [FluentMember(3, "LivingIn")] 35 | [FluentDefault("LivingInBoston")] 36 | [FluentNullable("InUnknownCity")] 37 | public string? City { get; private set; } = "Boston"; 38 | 39 | [FluentPredicate(4, "WhoIsHappy", "WhoIsSad")] 40 | [FluentNullable("WithUnknownMood")] 41 | public bool? IsHappy { get; private set; } 42 | 43 | [FluentCollection(5, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 44 | public IReadOnlyCollection Friends { get; private set; } 45 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://EditorConfig.org 2 | 3 | # C Sharp styles 4 | [*.cs] 5 | 6 | # Additional StyleCop Analyzer rules for M31.FluentApi.Generator 7 | # 8 | 9 | # SA1600: Elements should be documented 10 | dotnet_diagnostic.SA1600.severity = none 11 | 12 | # SA1602: Enumeration items should be documented 13 | dotnet_diagnostic.SA1602.severity = none 14 | 15 | # SA1516: Elements should be separated by blank line 16 | dotnet_diagnostic.SA1516.severity = none 17 | 18 | # SA1311: Static readonly fields should begin with upper-case letter 19 | dotnet_diagnostic.SA1311.severity = none 20 | 21 | # SA1204: Static members should appear before non-static members 22 | dotnet_diagnostic.SA1204.severity = none -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/AnalyzerReleases.Unshipped.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m31coding/M31.FluentAPI/a8b2133e95adfa8123cc879706b74a569b489dec/src/M31.FluentApi.Generator/AnalyzerReleases.Unshipped.md -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/CodeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace M31.FluentApi.Generator.CodeBuilding; 4 | 5 | internal static class CodeExtensions 6 | { 7 | internal static string ToString(this ICode code, string newLineString) 8 | { 9 | CodeBuilder codeBuilder = new CodeBuilder(newLineString); 10 | code.AppendCode(codeBuilder); 11 | return codeBuilder.ToString(); 12 | } 13 | 14 | internal static void AddGeneratedAtConstant(this Class @class) 15 | { 16 | Property property = new Property("string", "GeneratedAt"); 17 | property.AddRightHandSide($"= \"{DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)}\";"); 18 | property.AddModifiers("public const"); 19 | @class.AddProperty(property); 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/Field.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class Field : ICode 4 | { 5 | internal Field(string type, string name) 6 | { 7 | Type = type; 8 | Name = name; 9 | Modifiers = new Modifiers(); 10 | GenericParameters = new GenericParameters(); 11 | } 12 | 13 | internal string Type { get; } 14 | internal string Name { get; } 15 | 16 | internal GenericParameters GenericParameters { get; } 17 | internal Modifiers Modifiers { get; } 18 | 19 | internal void AddModifiers(params string[] modifiers) 20 | { 21 | Modifiers.Add(modifiers); 22 | } 23 | 24 | internal void AddModifiers(IEnumerable modifiers) 25 | { 26 | Modifiers.Add(modifiers); 27 | } 28 | 29 | internal void AddGenericParameters(params string[] parameters) 30 | { 31 | GenericParameters.Add(parameters); 32 | } 33 | 34 | internal void AddGenericParameters(IEnumerable parameters) 35 | { 36 | GenericParameters.Add(parameters); 37 | } 38 | 39 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 40 | { 41 | return codeBuilder 42 | .StartLine() 43 | .Append(Modifiers) 44 | .Append(Type) 45 | .Append(GenericParameters) 46 | .Append($" {Name};") 47 | .EndLine(); 48 | } 49 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/GenericConstraintClause.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class GenericConstraintClause : ICode 4 | { 5 | internal GenericConstraintClause(string parameter, IReadOnlyCollection constraints) 6 | { 7 | Parameter = parameter; 8 | Constraints = constraints; 9 | } 10 | 11 | internal string Parameter { get; } 12 | internal IReadOnlyCollection Constraints { get; } 13 | 14 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 15 | { 16 | return codeBuilder.Append($"where {Parameter} : {string.Join(", ", Constraints)}"); 17 | } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/GenericConstraints.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class GenericConstraints : ICode 4 | { 5 | private readonly List genericConstraintClauses; 6 | 7 | internal GenericConstraints() 8 | { 9 | genericConstraintClauses = new List(); 10 | } 11 | 12 | internal GenericConstraints(GenericConstraints constraints) 13 | { 14 | genericConstraintClauses = constraints.genericConstraintClauses.ToList(); 15 | } 16 | 17 | internal IReadOnlyCollection GenericConstraintClauses => genericConstraintClauses; 18 | internal int Count => genericConstraintClauses.Count; 19 | 20 | internal void Add(string parameter, IReadOnlyCollection constraints) 21 | { 22 | genericConstraintClauses.Add(new GenericConstraintClause(parameter, constraints)); 23 | } 24 | 25 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 26 | { 27 | return codeBuilder.AppendNewLineSeparated(genericConstraintClauses); 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/GenericParameters.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class GenericParameters : ICode 4 | { 5 | private readonly List values; 6 | 7 | internal GenericParameters(params string[] parameters) 8 | { 9 | values = parameters.ToList(); 10 | } 11 | 12 | internal GenericParameters(GenericParameters parameters) 13 | { 14 | values = parameters.values.ToList(); 15 | } 16 | 17 | internal IReadOnlyCollection Values => values; 18 | 19 | internal void Add(string parameter) 20 | { 21 | values.Add(parameter); 22 | } 23 | 24 | internal void Add(params string[] parameters) 25 | { 26 | values.AddRange(parameters); 27 | } 28 | 29 | internal void Add(IEnumerable parameters) 30 | { 31 | values.AddRange(parameters); 32 | } 33 | 34 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 35 | { 36 | return codeBuilder.Append(() => $"<{string.Join(", ", values)}>", values.Count > 0); 37 | } 38 | 39 | public override string ToString() 40 | { 41 | return Values.Count == 0 ? string.Empty : $"<{string.Join(", ", values)}>"; 42 | } 43 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/Generics.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class Generics 4 | { 5 | internal Generics() 6 | { 7 | Parameters = new GenericParameters(); 8 | Constraints = new GenericConstraints(); 9 | } 10 | 11 | internal Generics(Generics generics) 12 | { 13 | Parameters = new GenericParameters(generics.Parameters); 14 | Constraints = new GenericConstraints(generics.Constraints); 15 | } 16 | 17 | internal GenericParameters Parameters { get; } 18 | internal GenericConstraints Constraints { get; } 19 | 20 | internal void AddGenericParameter(string parameter, IEnumerable constraints) 21 | { 22 | Parameters.Add(parameter); 23 | IReadOnlyCollection constraintsCollection = constraints.ToArray(); 24 | if (constraintsCollection.Count > 0) 25 | { 26 | Constraints.Add(parameter, constraintsCollection); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/ICode.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal interface ICode 4 | { 5 | CodeBuilder AppendCode(CodeBuilder codeBuilder); 6 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/Method.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class Method : ICode 4 | { 5 | internal Method(MethodSignature methodSignature) 6 | { 7 | MethodSignature = methodSignature; 8 | MethodBody = new MethodBody(); 9 | } 10 | 11 | internal MethodSignature MethodSignature { get; } 12 | internal MethodBody MethodBody { get; } 13 | 14 | internal void AppendBodyLine(string line) 15 | { 16 | MethodBody.AppendLine(line); 17 | } 18 | 19 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 20 | { 21 | return codeBuilder 22 | .Append(MethodSignature) 23 | .Append(MethodBody); 24 | } 25 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/MethodBody.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class MethodBody : ICode 4 | { 5 | private readonly List lines; 6 | 7 | internal MethodBody() 8 | { 9 | lines = new List(); 10 | } 11 | 12 | internal void AppendLine(string line) 13 | { 14 | lines.Add(line); 15 | } 16 | 17 | internal IReadOnlyCollection Lines => lines; 18 | 19 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 20 | { 21 | return codeBuilder 22 | .OpenBlock() 23 | .AppendLines(lines) 24 | .CloseBlock(); 25 | } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/Modifiers.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class Modifiers : ICode 4 | { 5 | private readonly List values; 6 | 7 | internal Modifiers() 8 | { 9 | values = new List(); 10 | } 11 | 12 | internal Modifiers(params string[] values) 13 | { 14 | this.values = values.ToList(); 15 | } 16 | 17 | internal Modifiers(Modifiers modifiers) 18 | { 19 | values = modifiers.values.ToList(); 20 | } 21 | 22 | internal IReadOnlyCollection Values => values; 23 | 24 | internal void Add(params string[] modifiers) 25 | { 26 | values.AddRange(modifiers); 27 | } 28 | 29 | internal void Add(IEnumerable modifiers) 30 | { 31 | values.AddRange(modifiers); 32 | } 33 | 34 | internal bool Contains(string modifier) 35 | { 36 | return Values.Contains(modifier); 37 | } 38 | 39 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 40 | { 41 | return codeBuilder.Append(ToString()); 42 | } 43 | 44 | public override string ToString() 45 | { 46 | return Values.Count == 0 ? string.Empty : $"{string.Join(" ", Values)} "; 47 | } 48 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/ParameterAnnotations.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using M31.FluentApi.Generator.Commons; 3 | 4 | namespace M31.FluentApi.Generator.CodeBuilding; 5 | 6 | internal class ParameterAnnotations : ICode 7 | { 8 | internal ParameterAnnotations(ParameterKinds parameterKinds) 9 | { 10 | ParameterKinds = parameterKinds; 11 | } 12 | 13 | internal ParameterKinds ParameterKinds { get; } 14 | 15 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 16 | { 17 | return codeBuilder 18 | .Append("params ", Contains(ParameterKinds.Params)) 19 | .Append("ref ", Contains(ParameterKinds.Ref)) 20 | .Append("in ", Contains(ParameterKinds.In)) 21 | .Append("out ", Contains(ParameterKinds.Out)); 22 | } 23 | 24 | internal bool Contains(ParameterKinds parameterKinds) 25 | { 26 | return ParameterKinds.HasFlag(parameterKinds); 27 | } 28 | 29 | internal string ToCallsiteAnnotations() 30 | { 31 | if (ParameterKinds == ParameterKinds.None) 32 | { 33 | return string.Empty; 34 | } 35 | 36 | return new StringBuilder() 37 | .Append("ref ", Contains(ParameterKinds.Ref)) 38 | .Append("in ", Contains(ParameterKinds.In)) 39 | .Append("out ", Contains(ParameterKinds.Out)).ToString(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/ParameterKinds.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | [Flags] 4 | internal enum ParameterKinds 5 | { 6 | None = 0, 7 | Params = 1 << 0, 8 | Ref = 1 << 1, 9 | In = 1 << 2, 10 | Out = 1 << 3, 11 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeBuilding/Parameters.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeBuilding; 2 | 3 | internal class Parameters : ICode 4 | { 5 | private readonly List values; 6 | 7 | private Parameters(List parameters) 8 | { 9 | values = parameters; 10 | } 11 | 12 | internal Parameters() 13 | { 14 | values = new List(); 15 | } 16 | 17 | internal Parameters(Parameters parameters) 18 | { 19 | values = parameters.values.ToList(); 20 | } 21 | 22 | internal Parameters WithoutDefaultValues() 23 | { 24 | return new Parameters(values.Select(v => v.WithoutDefaultValue()).ToList()); 25 | } 26 | 27 | internal IReadOnlyCollection Values => values; 28 | 29 | internal void AddParameter(Parameter parameter) 30 | { 31 | values.Add(parameter); 32 | } 33 | 34 | public CodeBuilder AppendCode(CodeBuilder codeBuilder) 35 | { 36 | return codeBuilder.Append("(").Append(values, ", ").Append(")"); 37 | } 38 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/BuilderMethodsGeneration/BaseInterface.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.BuilderMethodsGeneration; 2 | 3 | internal class BaseInterface 4 | { 5 | public BaseInterface(string name, int step) 6 | { 7 | Name = name; 8 | Step = step; 9 | } 10 | 11 | public string Name { get; } 12 | public int Step { get; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/BuilderMethodsGeneration/BuilderInterface.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.BuilderMethodsGeneration; 2 | 3 | internal class BuilderInterface 4 | { 5 | internal BuilderInterface( 6 | string interfaceName, 7 | IReadOnlyCollection baseInterfaces, 8 | IReadOnlyCollection methods) 9 | { 10 | InterfaceName = interfaceName; 11 | BaseInterfaces = baseInterfaces; 12 | Methods = methods; 13 | } 14 | 15 | public string InterfaceName { get; } 16 | public IReadOnlyCollection BaseInterfaces { get; } 17 | public IReadOnlyCollection Methods { get; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/BuilderMethodsGeneration/InterfaceBuilderMethod.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.BuilderMethodsGeneration; 4 | 5 | internal abstract class InterfaceBuilderMethod : BuilderStepMethod 6 | { 7 | public InterfaceBuilderMethod( 8 | BuilderMethod builderMethod, 9 | string interfaceName, 10 | BaseInterface? baseInterface) 11 | : base(builderMethod) 12 | { 13 | InterfaceName = interfaceName; 14 | BaseInterface = baseInterface; 15 | } 16 | 17 | internal string InterfaceName { get; } 18 | internal BaseInterface? BaseInterface { get; } 19 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/BuilderMethodsGeneration/InterjacentBuilderMethod.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 3 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 4 | 5 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.BuilderMethodsGeneration; 6 | 7 | // code generation comments are with respect to the unit test ThreeMemberClass.Student 8 | internal class InterjacentBuilderMethod : InterfaceBuilderMethod 9 | { 10 | internal InterjacentBuilderMethod( 11 | BuilderMethod builderMethod, 12 | string returnType, 13 | string interfaceName, 14 | BaseInterface? baseInterface) 15 | : base(builderMethod, interfaceName, baseInterface) 16 | { 17 | ReturnType = returnType; 18 | } 19 | 20 | internal string ReturnType { get; } 21 | 22 | internal override Method BuildMethodCode(BuilderAndTargetInfo info, ReservedVariableNames reservedVariableNames) 23 | { 24 | // public IInSemester BornOn(System.DateOnly dateOfBirth) 25 | Method method = CreateInterfaceMethod(InterfaceName, ReturnType, "public"); 26 | 27 | // student.DateOfBirth = dateOfBirth; 28 | CreateBody(method, string.Empty, reservedVariableNames); 29 | 30 | // return this; 31 | CreateReturnStatement(method, "return this;"); 32 | 33 | return method; 34 | } 35 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/BuilderMethodsGeneration/LastStepBuilderMethod.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 3 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 4 | 5 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.BuilderMethodsGeneration; 6 | 7 | // code generation comments are with respect to the unit test ThreeMemberClass.Student 8 | internal class LastStepBuilderMethod : InterfaceBuilderMethod 9 | { 10 | internal LastStepBuilderMethod( 11 | BuilderMethod builderMethod, 12 | string interfaceName) 13 | : base(builderMethod, interfaceName, null) 14 | { 15 | } 16 | 17 | internal override Method BuildMethodCode(BuilderAndTargetInfo info, ReservedVariableNames reservedVariableNames) 18 | { 19 | // public Student InSemester(int semester) 20 | Method method = CreateInterfaceMethod( 21 | InterfaceName, info.FluentApiClassNameWithTypeParameters, "public"); 22 | 23 | // student.Semester = semester; 24 | CreateBody(method, string.Empty, reservedVariableNames); 25 | 26 | // return student; 27 | CreateReturnStatement(method, $"return {info.ClassInstanceName};"); 28 | 29 | return method; 30 | } 31 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/BuilderMethodsGeneration/LoopHandling/DependencyLoop.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.BuilderMethodsGeneration.LoopHandling; 2 | 3 | /// 4 | /// Interfaces that form a circular dependency. 5 | /// 6 | internal class DependencyLoop 7 | { 8 | private DependencyLoop(IReadOnlyCollection interfaces, string commonInterfaceName) 9 | { 10 | Interfaces = interfaces; 11 | CommonInterfaceName = commonInterfaceName; 12 | } 13 | 14 | internal IReadOnlyCollection Interfaces { get; } 15 | internal string CommonInterfaceName { get; } 16 | 17 | internal static DependencyLoop Create(IReadOnlyCollection interfaces) 18 | { 19 | string commonInterfaceName = GetCommonInterfaceName(interfaces.SelectMany(i => i.Methods).ToArray()); 20 | return new DependencyLoop(interfaces, commonInterfaceName); 21 | } 22 | 23 | private static string GetCommonInterfaceName(IReadOnlyCollection methods) 24 | { 25 | return $"I{string.Join(string.Empty, methods.Select(m => m.InterfaceName).Distinct().Select(RemoveCapitalI))}"; 26 | 27 | static string RemoveCapitalI(string interfaceName) 28 | { 29 | return interfaceName.Substring(1, interfaceName.Length - 1); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/Commons/BuildBodyCode.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 4 | 5 | internal delegate List BuildBodyCode( 6 | string instancePrefix, 7 | ReservedVariableNames reservedVariableNames, 8 | string? returnType); -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/Commons/BuilderMethod.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | using M31.FluentApi.Generator.SourceGenerators.Generics; 3 | 4 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 5 | 6 | internal class BuilderMethod 7 | { 8 | internal string MethodName { get; } 9 | internal GenericInfo? GenericInfo { get; } 10 | internal IReadOnlyCollection Parameters { get; } 11 | internal string? ReturnTypeToRespect { get; } 12 | internal BuildBodyCode BuildBodyCode { get; } 13 | 14 | internal BuilderMethod( 15 | string methodName, 16 | GenericInfo? genericInfo, 17 | IReadOnlyCollection parameters, 18 | string? returnTypeToRespect, 19 | BuildBodyCode buildBodyCode) 20 | { 21 | MethodName = methodName; 22 | GenericInfo = genericInfo; 23 | Parameters = parameters; 24 | ReturnTypeToRespect = returnTypeToRespect; 25 | BuildBodyCode = buildBodyCode; 26 | } 27 | 28 | internal BuilderMethod(BuilderMethod builderMethod) 29 | { 30 | MethodName = builderMethod.MethodName; 31 | GenericInfo = builderMethod.GenericInfo; 32 | Parameters = builderMethod.Parameters; 33 | ReturnTypeToRespect = builderMethod.ReturnTypeToRespect; 34 | BuildBodyCode = builderMethod.BuildBodyCode; 35 | } 36 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/Commons/ComputeValueCode.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 4 | 5 | internal class ComputeValueCode 6 | { 7 | private ComputeValueCode(string targetMember, Parameter? parameter, string code) 8 | { 9 | TargetMember = targetMember; 10 | Parameter = parameter; 11 | Code = code; 12 | } 13 | 14 | internal string TargetMember { get; } 15 | internal Parameter? Parameter { get; } 16 | internal string Code { get; } 17 | 18 | internal static ComputeValueCode Create( 19 | string targetMember, 20 | Parameter parameter, 21 | Func buildCodeWithParameter) 22 | { 23 | return new ComputeValueCode(targetMember, parameter, buildCodeWithParameter(parameter.Name)); 24 | } 25 | 26 | internal static ComputeValueCode Create(string targetMember, Parameter parameter) 27 | { 28 | return Create(targetMember, parameter, p => p); 29 | } 30 | 31 | internal static ComputeValueCode Create(string targetMember, string valueCode) 32 | { 33 | return new ComputeValueCode(targetMember, null, valueCode); 34 | } 35 | 36 | public override string ToString() => Code; 37 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/DuplicateMethodsChecking/BuilderMethodIdentity.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 3 | 4 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.DuplicateMethodsChecking; 5 | 6 | internal class BuilderMethodIdentity : IEquatable 7 | { 8 | internal BuilderMethodIdentity(BuilderMethod builderMethod, MethodIdentity methodIdentity) 9 | { 10 | BuilderMethod = builderMethod; 11 | MethodIdentity = methodIdentity; 12 | } 13 | 14 | internal BuilderMethod BuilderMethod { get; } 15 | internal MethodIdentity MethodIdentity { get; } 16 | 17 | public bool Equals(BuilderMethodIdentity? other) 18 | { 19 | if (other == null) 20 | { 21 | return false; 22 | } 23 | 24 | return MethodIdentity.Equals(other.MethodIdentity); 25 | } 26 | 27 | public override bool Equals(object? obj) 28 | { 29 | if (obj is not BuilderMethodIdentity other) 30 | { 31 | return false; 32 | } 33 | 34 | return Equals(other); 35 | } 36 | 37 | public override int GetHashCode() 38 | { 39 | return MethodIdentity.GetHashCode(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/DuplicateMethodsChecking/DuplicateMethods.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.DuplicateMethodsChecking; 2 | 3 | internal class DuplicateMethods 4 | { 5 | private readonly BuilderMethodIdentity[] duplicates; 6 | 7 | internal DuplicateMethods(string methodName, BuilderMethodIdentity[] duplicates) 8 | { 9 | MethodName = methodName; 10 | this.duplicates = duplicates; 11 | } 12 | 13 | internal string MethodName { get; } 14 | internal IReadOnlyCollection Duplicates => duplicates; 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/EntityFieldGenerator.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 3 | 4 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors; 5 | 6 | internal class EntityFieldGenerator : ICodeBoardActor 7 | { 8 | public void Modify(CodeBoard codeBoard) 9 | { 10 | string fieldName = codeBoard.ReservedVariableNames.GetNewGlobalVariableName(codeBoard.Info.ClassInstanceName); 11 | 12 | // private readonly Student student; 13 | Field field = new Field(codeBoard.Info.FluentApiClassName, fieldName); 14 | 15 | if (codeBoard.Info.GenericInfo != null) 16 | { 17 | field.AddGenericParameters(codeBoard.Info.GenericInfo.ParameterStrings); 18 | } 19 | 20 | field.AddModifiers("private"); 21 | 22 | if (!codeBoard.Info.FluentApiTypeIsStruct) 23 | { 24 | field.AddModifiers("readonly"); 25 | } 26 | 27 | codeBoard.BuilderClass.AddField(field); 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/ICodeBoardActor.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors; 4 | 5 | internal interface ICodeBoardActor 6 | { 7 | void Modify(CodeBoard codeBoard); 8 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/InitialStepMethodGenerator.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 3 | 4 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors; 5 | 6 | internal class InitialStepMethodGenerator : ICodeBoardActor 7 | { 8 | public void Modify(CodeBoard codeBoard) 9 | { 10 | // public static ICreateStudent InitialStep() 11 | // { 12 | // return new CreateStudent(); 13 | // } 14 | string methodName = "InitialStep"; 15 | MethodSignature methodSignature = MethodSignature.Create( 16 | codeBoard.Info.InitialStepInterfaceName, 17 | methodName, 18 | null, 19 | false); 20 | methodSignature.AddModifiers(codeBoard.Info.DefaultAccessModifier, "static"); 21 | Method method = new Method(methodSignature); 22 | string parameterListInAngleBrackets = codeBoard.Info.GenericInfo?.ParameterListInAngleBrackets ?? string.Empty; 23 | method.AppendBodyLine($"return new {codeBoard.Info.BuilderClassName}{parameterListInAngleBrackets}();"); 24 | codeBoard.BuilderClass.AddMethod(method); 25 | } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/BuilderMethods.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation; 4 | 5 | internal class BuilderMethods 6 | { 7 | private readonly List methods; 8 | private readonly HashSet requiredUsings; 9 | 10 | internal BuilderMethods(List methods, HashSet requiredUsings) 11 | { 12 | this.methods = methods; 13 | this.requiredUsings = requiredUsings; 14 | } 15 | 16 | internal BuilderMethods() 17 | { 18 | methods = new List(); 19 | requiredUsings = new HashSet(); 20 | } 21 | 22 | internal BuilderMethods(BuilderMethod builderMethod) 23 | { 24 | methods = new List() { builderMethod }; 25 | requiredUsings = new HashSet(); 26 | } 27 | 28 | internal void Add(BuilderMethods builderMethods) 29 | { 30 | methods.AddRange(builderMethods.Methods); 31 | 32 | foreach (string @using in builderMethods.RequiredUsings) 33 | { 34 | requiredUsings.Add(@using); 35 | } 36 | } 37 | 38 | internal IReadOnlyCollection Methods => methods; 39 | internal IReadOnlyCollection RequiredUsings => requiredUsings; 40 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/Collections/ArrayCreator.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 2 | using M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 3 | 4 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation.Collections; 5 | 6 | internal class ArrayCreator : CollectionMethodCreator 7 | { 8 | internal ArrayCreator( 9 | FluentCollectionAttributeInfo collectionAttributeInfo, 10 | string genericTypeArgument, 11 | MemberSymbolInfo symbolInfo) 12 | : base(collectionAttributeInfo, genericTypeArgument, symbolInfo) 13 | { 14 | } 15 | 16 | protected override string CreateCollectionFromArray(string genericTypeArgument, string arrayParameter) 17 | { 18 | return arrayParameter; 19 | } 20 | 21 | protected override string CreateCollectionFromEnumerable(string genericTypeArgument, string enumerableParameter) 22 | { 23 | RequiredUsings.Add("System.Linq"); 24 | return $"{enumerableParameter}.ToArray()"; 25 | } 26 | 27 | protected override string CreateCollectionFromSingleItem(string genericTypeArgument, string itemParameter) 28 | { 29 | return $"new {genericTypeArgument}[1]{{ {itemParameter} }}"; 30 | } 31 | 32 | protected override string CreateCollectionWithZeroItems(string genericTypeArgument) 33 | { 34 | return $"new {genericTypeArgument}[0]"; 35 | } 36 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/Collections/GeneratedCollection.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation.Collections; 2 | 3 | internal enum GeneratedCollection 4 | { 5 | List, 6 | Array, 7 | HashSet, 8 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/CompoundPart.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 2 | using M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 3 | 4 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation; 5 | 6 | internal class CompoundPart 7 | { 8 | internal CompoundPart(MemberSymbolInfo symbolInfo, FluentMemberAttributeInfo attributeInfo) 9 | { 10 | SymbolInfo = symbolInfo; 11 | AttributeInfo = attributeInfo; 12 | } 13 | 14 | internal MemberSymbolInfo SymbolInfo { get; } 15 | internal FluentMemberAttributeInfo AttributeInfo { get; } 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/DefaultMethod.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 2 | using M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 3 | 4 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation; 5 | 6 | internal class DefaultMethod : IBuilderMethodCreator 7 | { 8 | internal DefaultMethod(MemberSymbolInfo symbolInfo, FluentDefaultAttributeInfo defaultAttributeInfo) 9 | { 10 | SymbolInfo = symbolInfo; 11 | DefaultAttributeInfo = defaultAttributeInfo; 12 | } 13 | 14 | internal MemberSymbolInfo SymbolInfo { get; } 15 | internal FluentDefaultAttributeInfo DefaultAttributeInfo { get; } 16 | 17 | public BuilderMethods CreateBuilderMethods(MethodCreator methodCreator) 18 | { 19 | return new BuilderMethods(methodCreator.CreateMethodThatDoesNothing(DefaultAttributeInfo.Method)); 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/FluentMethods.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 3 | using M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 4 | 5 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation; 6 | 7 | internal class FluentMethods : IBuilderMethodCreator 8 | { 9 | internal MethodSymbolInfo SymbolInfo { get; } 10 | internal FluentMethodAttributeInfo MethodAttributeInfo { get; } 11 | internal FluentReturnAttributeInfo? ReturnAttributeInfo { get; } 12 | 13 | internal FluentMethods( 14 | MethodSymbolInfo symbolInfo, 15 | FluentMethodAttributeInfo methodAttributeInfo, 16 | FluentReturnAttributeInfo? returnAttributeInfo) 17 | { 18 | SymbolInfo = symbolInfo; 19 | MethodAttributeInfo = methodAttributeInfo; 20 | ReturnAttributeInfo = returnAttributeInfo; 21 | } 22 | 23 | public BuilderMethods CreateBuilderMethods(MethodCreator methodCreator) 24 | { 25 | BuilderMethod builderMethod = 26 | methodCreator.BuilderMethodFactory.CreateBuilderMethod( 27 | SymbolInfo, 28 | MethodAttributeInfo.FluentMethodName, 29 | ReturnAttributeInfo != null); 30 | return new BuilderMethods(builderMethod); 31 | } 32 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/Forks/Fork.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation.Forks; 2 | 3 | internal class Fork 4 | { 5 | internal Fork(int builderStep, string interfaceName, IReadOnlyList builderMethods) 6 | { 7 | BuilderStep = builderStep; 8 | InterfaceName = interfaceName; 9 | BuilderMethods = builderMethods; 10 | } 11 | 12 | internal int BuilderStep { get; } 13 | internal string InterfaceName { get; } 14 | internal IReadOnlyList BuilderMethods { get; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/Forks/ForkBuilderMethod.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation.Forks; 4 | 5 | internal class ForkBuilderMethod 6 | { 7 | public ForkBuilderMethod(BuilderMethod builderMethod, int? nextBuilderStep, bool isSkippable) 8 | { 9 | Value = builderMethod; 10 | NextBuilderStep = nextBuilderStep; 11 | IsSkippable = isSkippable; 12 | } 13 | 14 | internal BuilderMethod Value { get; } 15 | internal int? NextBuilderStep { get; } 16 | internal bool IsSkippable { get; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/Forks/ForkUnderConstruction.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation.Forks; 2 | 3 | internal class ForkUnderConstruction 4 | { 5 | internal int BuilderStep { get; private set; } 6 | internal string InterfaceName { get; private set; } 7 | internal List BuilderMethods { get; } 8 | 9 | internal ForkUnderConstruction(int builderStep) 10 | { 11 | BuilderStep = builderStep; 12 | InterfaceName = "I"; 13 | BuilderMethods = new List(); 14 | } 15 | 16 | internal void AddBuilderMethods(string interfacePartialName, IEnumerable builderMethods) 17 | { 18 | InterfaceName += interfacePartialName; 19 | BuilderMethods.AddRange(builderMethods); 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/IBuilderMethodCreator.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation; 2 | 3 | internal interface IBuilderMethodCreator 4 | { 5 | BuilderMethods CreateBuilderMethods(MethodCreator methodCreator); 6 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/NullableMethod.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 3 | using M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 4 | 5 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation; 6 | 7 | internal class NullableMethod : IBuilderMethodCreator 8 | { 9 | internal NullableMethod(MemberSymbolInfo symbolInfo, FluentNullableAttributeInfo nullableAttributeInfo) 10 | { 11 | SymbolInfo = symbolInfo; 12 | NullableAttributeInfo = nullableAttributeInfo; 13 | } 14 | 15 | internal MemberSymbolInfo SymbolInfo { get; } 16 | internal FluentNullableAttributeInfo NullableAttributeInfo { get; } 17 | 18 | public BuilderMethods CreateBuilderMethods(MethodCreator methodCreator) 19 | { 20 | BuilderMethod builderMethod = 21 | methodCreator.CreateMethodWithFixedValue(SymbolInfo, NullableAttributeInfo.Method, "null"); 22 | return new BuilderMethods(builderMethod); 23 | } 24 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardActors/MethodCreation/PredicateMethods.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.Commons; 2 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 3 | using M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 4 | 5 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation; 6 | 7 | internal class PredicateMethods : IBuilderMethodCreator 8 | { 9 | internal PredicateMethods(MemberSymbolInfo symbolInfo, FluentPredicateAttributeInfo predicateAttributeInfo) 10 | { 11 | SymbolInfo = symbolInfo; 12 | PredicateAttributeInfo = predicateAttributeInfo; 13 | } 14 | 15 | internal MemberSymbolInfo SymbolInfo { get; } 16 | internal FluentPredicateAttributeInfo PredicateAttributeInfo { get; } 17 | 18 | public BuilderMethods CreateBuilderMethods(MethodCreator methodCreator) 19 | { 20 | BuilderMethod builderMethod1 = 21 | methodCreator.CreateMethodWithDefaultValue(SymbolInfo, PredicateAttributeInfo.Method, "true"); 22 | BuilderMethod builderMethod2 = 23 | methodCreator.CreateMethodWithFixedValue(SymbolInfo, PredicateAttributeInfo.NegatedMethod, "false"); 24 | 25 | return new BuilderMethods(new List { builderMethod1, builderMethod2 }, new HashSet()); 26 | } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardElements/BuildCallMethodCode.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 4 | 5 | internal delegate List BuildCallMethodCode( 6 | string instancePrefix, 7 | IReadOnlyCollection outerMethodParameters, 8 | ReservedVariableNames reservedVariableNames, 9 | string? returnType); -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardElements/CallMethodCode.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeBuilding; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 4 | 5 | internal class CallMethodCode 6 | { 7 | private readonly BuildCallMethodCode buildCallMethodCode; 8 | private readonly string newLineString; 9 | 10 | internal CallMethodCode(BuildCallMethodCode buildCallMethodCode, string newLineString) 11 | { 12 | this.buildCallMethodCode = buildCallMethodCode; 13 | this.newLineString = newLineString; 14 | } 15 | 16 | internal List BuildCode( 17 | string instancePrefix, 18 | IReadOnlyCollection outerMethodParameters, 19 | ReservedVariableNames reservedVariableNames, 20 | string? returnType) 21 | { 22 | return buildCallMethodCode(instancePrefix, outerMethodParameters, reservedVariableNames, returnType); 23 | } 24 | 25 | public override string ToString() 26 | { 27 | return string.Join( 28 | newLineString, 29 | buildCallMethodCode(string.Empty, Array.Empty(), new ReservedVariableNames(), null)); 30 | } 31 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardElements/CodeTypeExtractor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 4 | 5 | internal static class CodeTypeExtractor 6 | { 7 | internal static string GetTypeForCodeGeneration(ITypeSymbol typeSymbol) 8 | { 9 | SymbolDisplayMiscellaneousOptions miscellaneousOptions = 10 | SymbolDisplayMiscellaneousOptions.UseSpecialTypes | 11 | SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier; 12 | 13 | SymbolDisplayFormat format = 14 | new SymbolDisplayFormat( 15 | typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, 16 | genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, 17 | miscellaneousOptions: miscellaneousOptions); 18 | 19 | return typeSymbol.ToDisplayString(format); 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/CodeGeneration/CodeBoardElements/SetMemberCode.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.CodeGeneration.CodeBoardElements; 2 | 3 | internal class SetMemberCode 4 | { 5 | private readonly Func buildCodeWithInstancePrefixAndValue; 6 | 7 | internal SetMemberCode(Func buildCodeWithInstancePrefixAndValue) 8 | { 9 | this.buildCodeWithInstancePrefixAndValue = buildCodeWithInstancePrefixAndValue; 10 | } 11 | 12 | internal string BuildCode(string instancePrefix, string value) 13 | { 14 | return buildCodeWithInstancePrefixAndValue(instancePrefix, value); 15 | } 16 | 17 | public override string ToString() 18 | { 19 | return buildCodeWithInstancePrefixAndValue("{prefix}", "{value}"); 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/Commons/DeclaredAccessibilityExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace M31.FluentApi.Generator.Commons; 4 | 5 | internal static class DeclaredAccessibilityExtensions 6 | { 7 | internal static bool IsPublicOrInternal(this Accessibility accessibility) 8 | { 9 | return accessibility is Accessibility.Public or Accessibility.Internal; 10 | } 11 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/Commons/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.Commons; 2 | 3 | internal static class EnumerableExtensions 4 | { 5 | internal static IEnumerable DistinctBy( 6 | this IEnumerable source, 7 | Func keySelector) 8 | { 9 | HashSet knownKeys = new HashSet(); 10 | 11 | foreach (TSource element in source) 12 | { 13 | if (knownKeys.Add(keySelector(element))) 14 | { 15 | yield return element; 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/Commons/GenerationException.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.Commons; 2 | 3 | internal class GenerationException : Exception 4 | { 5 | /// 6 | /// Initializes a new instance of the class. Throw this exception only for errors 7 | /// that should not occur because they were already handled with diagnostics. Therefore, if this exception is 8 | /// actually thrown, the diagnostics need to be improved. 9 | /// 10 | /// The exception message. 11 | internal GenerationException(string message) 12 | : base($"Unable to generate fluent API source code: {message}") 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/Commons/StringBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace M31.FluentApi.Generator.Commons; 4 | 5 | internal static class StringBuilderExtensions 6 | { 7 | internal static StringBuilder Append(this StringBuilder stringBuilder, string? value, bool condition) 8 | { 9 | if (condition) 10 | { 11 | stringBuilder.Append(value); 12 | } 13 | 14 | return stringBuilder; 15 | } 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/Commons/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.Commons; 2 | 3 | internal static class StringExtensions 4 | { 5 | internal static string FirstCharToLower(this string str) 6 | { 7 | if (str == string.Empty) return str; 8 | char[] chars = str.ToCharArray(); 9 | chars[0] = char.ToLower(chars[0]); 10 | return new string(chars); 11 | } 12 | 13 | internal static string FirstCharToUpper(this string str) 14 | { 15 | if (str == string.Empty) return str; 16 | char[] chars = str.ToCharArray(); 17 | chars[0] = char.ToUpper(chars[0]); 18 | return new string(chars); 19 | } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceAnalyzers/DiagnosticExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace M31.FluentApi.Generator.SourceAnalyzers; 4 | 5 | internal static class DiagnosticExtensions 6 | { 7 | internal static bool HaveErrors(this IEnumerable diagnostics) 8 | { 9 | return diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error); 10 | } 11 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeElements/AttributeDataExtended.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeElements; 4 | 5 | internal class AttributeDataExtended 6 | { 7 | internal AttributeDataExtended(AttributeData attributeData, string fullName, string shortName) 8 | { 9 | AttributeData = attributeData; 10 | FullName = fullName; 11 | ShortName = shortName; 12 | } 13 | 14 | internal AttributeData AttributeData { get; } 15 | internal string FullName { get; } 16 | internal string ShortName { get; } 17 | 18 | internal static AttributeDataExtended? Create(AttributeData attributeData) 19 | { 20 | if (attributeData.AttributeClass == null) 21 | { 22 | return null; 23 | } 24 | 25 | string fullName = attributeData.AttributeClass.ToDefaultDisplayString(); 26 | 27 | string shortName = attributeData.AttributeClass.ToDisplayString(new SymbolDisplayFormat( 28 | typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly)); 29 | 30 | if (shortName.EndsWith("Attribute")) 31 | { 32 | shortName = shortName.Substring(0, shortName.Length - "Attribute".Length); 33 | } 34 | 35 | return new AttributeDataExtended(attributeData, fullName, shortName); 36 | } 37 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeElements/FluentApiAttributeData.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | 3 | internal class FluentApiAttributeData 4 | { 5 | internal FluentApiAttributeData( 6 | AttributeDataExtended mainAttributeData, 7 | IReadOnlyCollection orthogonalAttributeData, 8 | IReadOnlyCollection controlAttributeData) 9 | { 10 | MainAttributeData = mainAttributeData; 11 | OrthogonalAttributeData = orthogonalAttributeData; 12 | ControlAttributeData = controlAttributeData; 13 | } 14 | 15 | internal AttributeDataExtended MainAttributeData { get; } 16 | internal IReadOnlyCollection OrthogonalAttributeData { get; } 17 | internal IReadOnlyCollection ControlAttributeData { get; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/AttributeInfoBase.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 2 | 3 | internal abstract record AttributeInfoBase 4 | { 5 | protected AttributeInfoBase(int builderStep) 6 | { 7 | BuilderStep = builderStep; 8 | } 9 | 10 | internal int BuilderStep { get; } 11 | internal abstract string FluentMethodName { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/ControlAttributeInfoBase.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 2 | 3 | internal abstract record ControlAttributeInfoBase; -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentApiAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentApiAttributeInfo 7 | { 8 | private FluentApiAttributeInfo(string builderClassName) 9 | { 10 | BuilderClassName = builderClassName; 11 | } 12 | 13 | internal string BuilderClassName { get; } 14 | 15 | internal static FluentApiAttributeInfo Create(AttributeData attributeData, string className) 16 | { 17 | string builderClassName = attributeData.GetConstructorArguments(); 18 | builderClassName = NameCreator.CreateName(builderClassName, className); 19 | return new FluentApiAttributeInfo(builderClassName); 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentBreakAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 2 | 3 | internal record FluentBreakAttributeInfo : ControlAttributeInfoBase 4 | { 5 | internal static FluentBreakAttributeInfo Create() 6 | { 7 | return new FluentBreakAttributeInfo(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentContinueWithAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentContinueWithAttributeInfo : ControlAttributeInfoBase 7 | { 8 | private FluentContinueWithAttributeInfo(int continueWithBuilderStep) 9 | { 10 | ContinueWithBuilderStep = continueWithBuilderStep; 11 | } 12 | 13 | internal int ContinueWithBuilderStep { get; } 14 | 15 | internal static FluentContinueWithAttributeInfo Create(AttributeData attributeData) 16 | { 17 | int builderStep = attributeData.GetConstructorArguments(); 18 | return new FluentContinueWithAttributeInfo(builderStep); 19 | } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentDefaultAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentDefaultAttributeInfo : OrthogonalAttributeInfoBase 7 | { 8 | private FluentDefaultAttributeInfo(string method) 9 | { 10 | Method = method; 11 | } 12 | 13 | internal string Method { get; } 14 | 15 | internal override IReadOnlyCollection MethodNames() 16 | { 17 | return new string[] { Method }; 18 | } 19 | 20 | internal static FluentDefaultAttributeInfo Create(AttributeData attributeData, string memberName) 21 | { 22 | string method = attributeData.GetConstructorArguments(); 23 | method = NameCreator.CreateName(method, memberName); 24 | return new FluentDefaultAttributeInfo(method); 25 | } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentLambdaAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentLambdaAttributeInfo : AttributeInfoBase 7 | { 8 | private FluentLambdaAttributeInfo(int builderStep, string method, LambdaBuilderInfo builderInfo) 9 | : base(builderStep) 10 | { 11 | Method = method; 12 | BuilderInfo = builderInfo; 13 | } 14 | 15 | internal string Method { get; } 16 | internal LambdaBuilderInfo BuilderInfo { get; } 17 | internal override string FluentMethodName => Method; 18 | 19 | internal static FluentLambdaAttributeInfo Create( 20 | AttributeData attributeData, 21 | string memberName, 22 | LambdaBuilderInfo lambdaBuilderInfo) 23 | { 24 | (int builderStep, string method) = attributeData.GetConstructorArguments(); 25 | method = NameCreator.CreateName(method, memberName); 26 | return new FluentLambdaAttributeInfo(builderStep, method, lambdaBuilderInfo); 27 | } 28 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentMemberAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentMemberAttributeInfo : AttributeInfoBase 7 | { 8 | private FluentMemberAttributeInfo( 9 | int builderStep, 10 | string method, 11 | int parameterPosition, 12 | LambdaBuilderInfo? lambdaBuilderInfo) 13 | : base(builderStep) 14 | { 15 | Method = method; 16 | ParameterPosition = parameterPosition; 17 | LambdaBuilderInfo = lambdaBuilderInfo; 18 | } 19 | 20 | internal string Method { get; } 21 | internal int ParameterPosition { get; } 22 | internal override string FluentMethodName => Method; 23 | internal LambdaBuilderInfo? LambdaBuilderInfo { get; } 24 | 25 | internal static FluentMemberAttributeInfo Create( 26 | AttributeData attributeData, 27 | string memberName, 28 | LambdaBuilderInfo? lambdaBuilderInfo) 29 | { 30 | (int builderStep, string method, int parameter) = attributeData.GetConstructorArguments(); 31 | method = NameCreator.CreateName(method, memberName); 32 | return new FluentMemberAttributeInfo(builderStep, method, parameter, lambdaBuilderInfo); 33 | } 34 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentMethodAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentMethodAttributeInfo : AttributeInfoBase 7 | { 8 | private FluentMethodAttributeInfo(int builderStep, string method) 9 | : base(builderStep) 10 | { 11 | Method = method; 12 | } 13 | 14 | internal string Method { get; } 15 | internal override string FluentMethodName => Method; 16 | 17 | internal static FluentMethodAttributeInfo Create(AttributeData attributeData, string memberName) 18 | { 19 | (int builderStep, string method) = attributeData.GetConstructorArguments(); 20 | method = NameCreator.CreateName(method, memberName); 21 | return new FluentMethodAttributeInfo(builderStep, method); 22 | } 23 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentNullableAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentNullableAttributeInfo : OrthogonalAttributeInfoBase 7 | { 8 | private FluentNullableAttributeInfo(string method) 9 | { 10 | Method = method; 11 | } 12 | 13 | internal string Method { get; } 14 | 15 | internal override IReadOnlyCollection MethodNames() 16 | { 17 | return new string[] { Method }; 18 | } 19 | 20 | internal static FluentNullableAttributeInfo Create(AttributeData attributeData, string memberName) 21 | { 22 | string method = attributeData.GetConstructorArguments(); 23 | method = NameCreator.CreateName(method, memberName); 24 | return new FluentNullableAttributeInfo(method); 25 | } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentPredicateAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 5 | 6 | internal record FluentPredicateAttributeInfo : AttributeInfoBase 7 | { 8 | private FluentPredicateAttributeInfo(int builderStep, string method, string negatedMethod) 9 | : base(builderStep) 10 | { 11 | Method = method; 12 | NegatedMethod = negatedMethod; 13 | } 14 | 15 | internal string Method { get; } 16 | internal string NegatedMethod { get; } 17 | internal override string FluentMethodName => Method; 18 | 19 | internal static FluentPredicateAttributeInfo Create(AttributeData attributeData, string memberName) 20 | { 21 | (int builderStep, string method, string negatedMethod) = attributeData.GetConstructorArguments(); 22 | method = NameCreator.CreateName(method, memberName); 23 | negatedMethod = NameCreator.CreateName(negatedMethod, memberName); 24 | return new FluentPredicateAttributeInfo(builderStep, method, negatedMethod); 25 | } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentReturnAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 4 | 5 | internal record FluentReturnAttributeInfo : ControlAttributeInfoBase 6 | { 7 | internal static FluentReturnAttributeInfo Create(AttributeData attributeData) 8 | { 9 | return new FluentReturnAttributeInfo(); 10 | } 11 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/FluentSkippableAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 2 | 3 | internal record FluentSkippableAttributeInfo : ControlAttributeInfoBase 4 | { 5 | internal static FluentSkippableAttributeInfo Create() 6 | { 7 | return new FluentSkippableAttributeInfo(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/LambdaBuilderInfo.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.Commons; 2 | 3 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 4 | 5 | internal record LambdaBuilderInfo 6 | { 7 | internal LambdaBuilderInfo(string builderClassName, string builderTypeForCodeGeneration) 8 | { 9 | BuilderClassName = builderClassName; // "CreateAddress" 10 | BuilderTypeForCodeGeneration = builderTypeForCodeGeneration; // Namespace.CreateAddress 11 | BuilderInstanceName = builderClassName.FirstCharToLower(); // createAddress 12 | InitialStepInterfaceName = $"I{BuilderClassName}"; // ICreateAddress 13 | } 14 | 15 | internal string BuilderClassName { get; } 16 | internal string BuilderTypeForCodeGeneration { get; } 17 | internal string BuilderInstanceName { get; } 18 | internal string InitialStepInterfaceName { get; } 19 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/AttributeInfo/OrthogonalAttributeInfoBase.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo; 2 | 3 | internal abstract record OrthogonalAttributeInfoBase 4 | { 5 | internal abstract IReadOnlyCollection MethodNames(); 6 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/ClassInfoResult.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators; 2 | 3 | internal class ClassInfoResult 4 | { 5 | internal ClassInfoResult( 6 | FluentApiClassInfo? classInfo, 7 | ClassInfoReport classInfoReport) 8 | { 9 | ClassInfo = classInfo; 10 | ClassInfoReport = classInfoReport; 11 | } 12 | 13 | internal ClassInfoResult(ClassInfoReport classInfoReport) 14 | { 15 | ClassInfo = null; 16 | ClassInfoReport = classInfoReport; 17 | } 18 | 19 | internal FluentApiClassInfo? ClassInfo { get; } 20 | internal ClassInfoReport ClassInfoReport { get; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/Collections/CollectionType.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.CodeGeneration.CodeBoardActors.MethodCreation.Collections; 2 | using M31.FluentApi.Generator.Commons; 3 | using Microsoft.CodeAnalysis; 4 | 5 | namespace M31.FluentApi.Generator.SourceGenerators.Collections; 6 | 7 | internal class CollectionType 8 | { 9 | internal CollectionType(GeneratedCollection collection, string genericTypeArgument, ITypeSymbol? genericTypeSymbol) 10 | { 11 | Collection = collection; 12 | GenericTypeArgument = genericTypeArgument; 13 | GenericTypeSymbol = genericTypeSymbol; 14 | } 15 | 16 | internal GeneratedCollection Collection { get; } 17 | internal string GenericTypeArgument { get; } 18 | internal ITypeSymbol? GenericTypeSymbol { get; } 19 | 20 | protected bool Equals(CollectionType other) 21 | { 22 | // Exclude GenericTypeSymbol from the comparison, it is unstable additional information. 23 | return Collection == other.Collection && GenericTypeArgument == other.GenericTypeArgument; 24 | } 25 | 26 | public override bool Equals(object? obj) 27 | { 28 | if (ReferenceEquals(null, obj)) return false; 29 | if (ReferenceEquals(this, obj)) return true; 30 | if (obj.GetType() != this.GetType()) return false; 31 | return Equals((CollectionType)obj); 32 | } 33 | 34 | public override int GetHashCode() 35 | { 36 | return new HashCode().Add(Collection, GenericTypeArgument); 37 | } 38 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/ConstructorInfo.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators; 2 | 3 | internal record ConstructorInfo 4 | { 5 | public ConstructorInfo(int numberOfParameters, bool constructorIsNonPublic) 6 | { 7 | NumberOfParameters = numberOfParameters; 8 | ConstructorIsNonPublic = constructorIsNonPublic; 9 | } 10 | 11 | internal int NumberOfParameters { get; } 12 | internal bool ConstructorIsNonPublic { get; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/FluentApiClassAdditionalInfo.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators; 2 | 3 | internal class FluentApiClassAdditionalInfo 4 | { 5 | internal FluentApiClassAdditionalInfo(IReadOnlyCollection fluentApiInfoGroups) 6 | { 7 | FluentApiInfoGroups = fluentApiInfoGroups; 8 | } 9 | 10 | internal IReadOnlyCollection FluentApiInfoGroups { get; } 11 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/FluentApiInfoGroup.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators; 2 | 3 | internal class FluentApiInfoGroup 4 | { 5 | internal FluentApiInfoGroup( 6 | int builderStep, 7 | int? nextBuilderStep, 8 | bool isSkippable, 9 | string fluentMethodName, 10 | Type attributeInfoType, 11 | IReadOnlyCollection fluentApiInfos) 12 | { 13 | BuilderStep = builderStep; 14 | NextBuilderStep = nextBuilderStep; 15 | IsSkippable = isSkippable; 16 | FluentMethodName = fluentMethodName; 17 | AttributeInfoType = attributeInfoType; 18 | FluentApiInfos = fluentApiInfos; 19 | } 20 | 21 | internal int BuilderStep { get; } 22 | internal int? NextBuilderStep { get; } 23 | internal bool IsSkippable { get; } 24 | internal string FluentMethodName { get; } 25 | internal Type AttributeInfoType { get; } 26 | internal IReadOnlyCollection FluentApiInfos { get; } 27 | internal bool IsCompoundGroup => FluentApiInfos.Count > 1; 28 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/NameCreator.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators; 2 | 3 | internal static class NameCreator 4 | { 5 | internal static string CreateName(string template, string name) 6 | { 7 | return template.Replace("{Name}", name); 8 | } 9 | 10 | internal static string CreateName(string template, string name, string singularName) 11 | { 12 | return template.Replace("{Name}", name).Replace("{SingularName}", singularName); 13 | } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/SourceGeneratorConfig.cs: -------------------------------------------------------------------------------- 1 | // The symbol 'Environment' is banned for use by analyzers 2 | #pragma warning disable RS1035 3 | 4 | namespace M31.FluentApi.Generator.SourceGenerators; 5 | 6 | internal class SourceGeneratorConfig 7 | { 8 | internal string NewLineString { get; set; } = Environment.NewLine; 9 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/Step.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Generator.SourceGenerators; 2 | 3 | internal record Step 4 | { 5 | public Step(int? value, string mode) 6 | { 7 | Value = value; 8 | Mode = mode; 9 | } 10 | 11 | internal int? Value { get; } 12 | internal string Mode { get; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/SymbolExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace M31.FluentApi.Generator.SourceGenerators; 4 | 5 | internal static class SymbolExtensions 6 | { 7 | private static readonly SymbolDisplayFormat defaultFormat = 8 | new SymbolDisplayFormat( 9 | typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces); 10 | 11 | internal static bool HasAttribute(this ISymbol symbol, string fullyQualifiedAttributeName) 12 | { 13 | return symbol.GetAttributes() 14 | .Any(a => a?.AttributeClass?.ToDefaultDisplayString() == fullyQualifiedAttributeName); 15 | } 16 | 17 | internal static bool HasAnyAttribute(this ISymbol symbol, params string[] fullyQualifiedAttributeNames) 18 | { 19 | return symbol.GetAttributes() 20 | .Any(a => fullyQualifiedAttributeNames.Any(n => a?.AttributeClass?.ToDefaultDisplayString() == n)); 21 | } 22 | 23 | internal static string ToDefaultDisplayString(this ISymbol symbol) 24 | { 25 | return symbol.ToDisplayString(defaultFormat); 26 | } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Generator/SourceGenerators/TypeData.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Generator.SourceGenerators.AttributeElements; 2 | using M31.FluentApi.Generator.SourceGenerators.Generics; 3 | using Microsoft.CodeAnalysis; 4 | 5 | namespace M31.FluentApi.Generator.SourceGenerators; 6 | 7 | internal class TypeData 8 | { 9 | internal TypeData( 10 | INamedTypeSymbol type, 11 | GenericInfo? genericInfo, 12 | AttributeDataExtended attributeDataExtended, 13 | IReadOnlyCollection usingStatements) 14 | { 15 | Type = type; 16 | GenericInfo = genericInfo; 17 | AttributeDataExtended = attributeDataExtended; 18 | UsingStatements = usingStatements; 19 | } 20 | 21 | internal INamedTypeSymbol Type { get; } 22 | internal GenericInfo? GenericInfo { get; } 23 | internal AttributeDataExtended AttributeDataExtended { get; } 24 | internal IReadOnlyCollection UsingStatements { get; } 25 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Storybook/M31.FluentApi.Storybook.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | false 9 | $(BaseIntermediateOutputPath)Generated 10 | true 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/M31.FluentApi.Storybook/Program.cs: -------------------------------------------------------------------------------- 1 | // 01_Basics 2 | // 3 | 4 | BasicExample.Usage.UseTheGeneratedFluentApi(); 5 | CustomNamesExample.Usage.UseTheGeneratedFluentApi(); 6 | CompoundExample.Usage.UseTheGeneratedFluentApi(); 7 | ForkExample.Usage.UseTheGeneratedFluentApi(); 8 | SpecialMembersExample.Usage.UseTheGeneratedFluentApi(); 9 | OrthogonalAttributesExample.Usage.UseTheGeneratedFluentApi(); 10 | FluentMethodExample.Usage.UseTheGeneratedFluentApi(); 11 | FullExample.Usage.UseTheGeneratedFluentApi(); 12 | 13 | // 02_ControlAttributes 14 | // 15 | 16 | PersonExample2.Usage.UseTheGeneratedFluentApi(); 17 | PersonExample3.Usage.UseTheGeneratedFluentApi(); 18 | PersonExample4.Usage.UseTheGeneratedFluentApi(); 19 | PersonExample5.Usage.UseTheGeneratedFluentApi(); -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/Helpers/SourceWithFix.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.Helpers; 2 | 3 | internal record SourceWithFix(string Source, string? FixedSource); -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/Helpers/TestSourceCodeReader.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.Helpers; 4 | 5 | internal static class TestSourceCodeReader 6 | { 7 | internal static SourceWithFix ReadSource(string testClassFolder, string @class) 8 | { 9 | string source = ReadTestClassCode(testClassFolder, $"{@class}.cs"); 10 | string fixedSource = TryReadTestClassCode(testClassFolder, $"{@class}.fixed.txt") ?? source; 11 | return new SourceWithFix(source, fixedSource); 12 | } 13 | 14 | private static string ReadTestClassCode(string testClassFolder, string file) 15 | { 16 | return File.ReadAllText(GetFilePath(testClassFolder, file)); 17 | } 18 | 19 | private static string? TryReadTestClassCode(string testClassFolder, string file) 20 | { 21 | string filePath = GetFilePath(testClassFolder, file); 22 | return File.Exists(filePath) ? File.ReadAllText(filePath) : null; 23 | } 24 | 25 | private static string GetFilePath(string testClassFolder, string file) 26 | { 27 | return Path.Join("..", "..", "..", "AnalyzerAndCodeFixes", "TestClasses", testClassFolder, file); 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/AmbiguousConstructorsClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.AmbiguousConstructorsClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | public Student(int semester) 11 | { 12 | Semester = semester; 13 | } 14 | 15 | public Student(string semester) 16 | { 17 | Semester = int.Parse(semester); 18 | } 19 | 20 | [FluentMember(0)] 21 | public int Semester { get; set; } 22 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/ConflictingControlAttributesClass1/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.ConflictingControlAttributesClass1; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentBreak] 14 | [FluentContinueWith(1)] 15 | public string Name { get; set; } 16 | 17 | [FluentMember(1, "InSemester")] 18 | public int Semester { get; private set; } 19 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/ConflictingControlAttributesClass2/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.ConflictingControlAttributesClass2; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "Named", 0)] 13 | [FluentContinueWith(1)] 14 | public string FirstName { get; private set; } 15 | 16 | [FluentMember(0, "Named", 1)] 17 | [FluentContinueWith(0)] 18 | public string LastName { get; private set; } 19 | 20 | [FluentMember(1, "InSemester")] 21 | public int Semester { get; private set; } 22 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/ConflictingControlAttributesClass3/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.ConflictingControlAttributesClass3; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public string Name { get; private set; } 14 | 15 | [FluentMethod(1)] 16 | [FluentBreak] 17 | [FluentReturn] 18 | public void Method1() 19 | { 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMainAttributeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMainAttributeClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | [FluentPredicate(0)] 12 | public bool IsHappy { get; private set; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMethodClass1/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMethodClass1; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "WithName")] 13 | public string FirstName { get; set; } 14 | 15 | [FluentMember(1, "WithName")] 16 | public string LastName { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMethodClass2/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMethodClass2; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0, "WithFriend")] 14 | public string Friend { get; set; } 15 | 16 | [FluentCollection(0, "Friend")] 17 | public IReadOnlyCollection Friends { get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMethodClass3/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMethodClass3; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | public string FirstName { get; private set; } 13 | public string LastName { get; private set; } 14 | 15 | [FluentMethod(0, "WithName")] 16 | public void WithFirstName(string firstName) 17 | { 18 | FirstName = firstName; 19 | } 20 | 21 | [FluentMethod(1, "WithName")] 22 | public void WithLastName(string lastName) 23 | { 24 | LastName = lastName; 25 | } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMethodClass4/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMethodClass4; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMethod(0, "Method1")] 13 | private void Method2(int p1, ref string p2) 14 | { 15 | } 16 | 17 | [FluentMethod(0, "Method1")] 18 | private void Method3(int p1, in string p2) 19 | { 20 | } 21 | 22 | [FluentMethod(0, "Method1")] 23 | private void Method4(int p1, out string p2) 24 | { 25 | p2 = string.Empty; 26 | } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMethodClass5/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMethodClass5; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMethod(0, "Method1")] 13 | private void Method2(S p1) 14 | { 15 | } 16 | 17 | [FluentMethod(0, "Method1")] 18 | private void Method3(T p1) 19 | { 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMethodPartialClass/Student1.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMethodPartialClass; 8 | 9 | [FluentApi] 10 | public partial class Student 11 | { 12 | [FluentMember(0, "WithName")] 13 | public string FirstName { get; set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/DuplicateMethodPartialClass/Student2.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.DuplicateMethodPartialClass; 8 | 9 | public partial class Student 10 | { 11 | [FluentMember(1, "WithName")] 12 | public string LastName { get; set; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/FluentLambdaMemberWithoutFluentApiClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // Type or member is obsolete 4 | #pragma warning disable CS0618 5 | // ReSharper disable All 6 | 7 | using M31.FluentApi.Attributes; 8 | 9 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.FluentLambdaMemberWithoutFluentApiClass; 10 | 11 | [FluentApi] 12 | public class Student 13 | { 14 | [FluentMember(0)] 15 | public string Name { get; set; } 16 | 17 | [FluentLambda(1)] 18 | public Address Address { get; set; } 19 | } 20 | 21 | public class Address 22 | { 23 | public string Street { get; set; } 24 | 25 | public string HouseNumber { get; set; } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetClass/Student.fixed.txt: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetRecord/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetRecord; 6 | 7 | [FluentApi] 8 | public record Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetRecord/Student.fixed.txt: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetRecord; 6 | 7 | [FluentApi] 8 | public record Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetRecordStruct/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetRecordStruct; 6 | 7 | [FluentApi] 8 | public record struct Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetRecordStruct/Student.fixed.txt: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetRecordStruct; 6 | 7 | [FluentApi] 8 | public record struct Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetStruct/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetStruct; 6 | 7 | [FluentApi] 8 | public struct Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/GetMissingSetStruct/Student.fixed.txt: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.GetMissingSetStruct; 6 | 7 | [FluentApi] 8 | public struct Student 9 | { 10 | [FluentMember(0)] 11 | int Semester { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/InvalidCollectionTypeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.InvalidCollectionTypeClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentCollection(0, "Friend")] 13 | public string Friends { get; private set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/InvalidFluentMethodReturnTypeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.InvalidFluentMethodReturnTypeClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | public string Name { get; private set; } 13 | 14 | [FluentMethod(0)] 15 | public int WithName(string name) 16 | { 17 | Name = name; 18 | return 0; 19 | } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/InvalidFluentMethodReturnTypeClass/Student.fixed.illustration.txt: -------------------------------------------------------------------------------- 1 | // NOTE: File does not compile due to an error (void method returns int). The file will not be used in the unit test. 2 | 3 | // Non-nullable member is uninitialized 4 | #pragma warning disable CS8618 5 | 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.InvalidFluentMethodReturnTypeClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | public string Name { get; private set; } 14 | 15 | [FluentMethod(0)] 16 | public void WithName(string name) 17 | { 18 | Name = name; 19 | return 0; 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/InvalidFluentPredicateTypeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.InvalidFluentPredicateTypeClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentPredicate(0)] 13 | public string IsHappy { get; private set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/InvalidNullableTypeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.InvalidNullableTypeClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | [FluentNullable] 12 | public int Semester { get; set; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/MissingBuilderStepClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.MissingBuilderStepClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentContinueWith(99)] 14 | public string FirstName { get; set; } 15 | 16 | [FluentMember(1)] 17 | public string LastName { get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/NullableTypeNoNullableAnnotationClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.NullableTypeNoNullableAnnotationClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentNullable] 14 | public string Name { get; set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/OrthogonalAttributeInCompoundClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.OrthogonalAttributeInCompoundClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "Named", 0)] 13 | public string FirstName { get; private set; } 14 | 15 | [FluentMember(0, "Named", 1)] 16 | [FluentDefault] 17 | public string LastName { get; private set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/OrthogonalAttributeWithoutMainAttributeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.OrthogonalAttributeWithoutMainAttributeClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentDefault] 11 | public int Semester { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/PartialClass/Student1.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.PartialClass; 8 | 9 | [FluentApi] 10 | public partial class Student 11 | { 12 | [FluentMember(0)] 13 | public string FirstName { get; private set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/PartialClass/Student2.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.PartialClass; 8 | 9 | public partial class Student 10 | { 11 | [FluentMember(1)] 12 | public string LastName { get; private set; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/PrivateGetMissingSetClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.PrivateGetMissingSetClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | private int Semester { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/PrivateGetMissingSetClass/Student.fixed.txt: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.PrivateGetMissingSetClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | private int Semester { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/PublicGetMissingSetClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.PublicGetMissingSetClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | public int Semester { get; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/PublicGetMissingSetClass/Student.fixed.txt: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.PublicGetMissingSetClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0)] 11 | public int Semester { get; private set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/ReservedMethodClass1/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.ReservedMethodClass1; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMethod(0)] 13 | public void InitialStep() 14 | { 15 | 16 | } 17 | 18 | [FluentMethod(1, "InitialStep")] 19 | public void Method1() 20 | { 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/ReservedMethodClass2/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.ReservedMethodClass2; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "InitialStep")] 13 | public string InitialStep { get; private set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/SkippableLastStepClass1/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.SkippableLastStepClass1; 8 | 9 | [FluentApi] 10 | public partial class Student 11 | { 12 | [FluentMember(0)] 13 | public string FirstName { get; private set; } 14 | 15 | [FluentMember(1)] 16 | [FluentSkippable] 17 | public string LastName { get; private set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/AnalyzerAndCodeFixes/TestClasses/SkippableLastStepClass2/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.AnalyzerAndCodeFixes.TestClasses.SkippableLastStepClass2; 8 | 9 | [FluentApi] 10 | public partial class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentSkippable] 14 | public string FirstName { get; private set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/CodeGenerationTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using M31.FluentApi.Tests.Helpers; 3 | using Xunit; 4 | using Xunit.Priority; 5 | 6 | namespace M31.FluentApi.Tests.CodeGeneration; 7 | 8 | [TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)] 9 | public partial class CodeGenerationTests 10 | { 11 | [Theory, Priority(0)] 12 | [ClassData(typeof(TestDataProvider))] 13 | public void CanGenerateBuilderForAbstractTestClasses(params string[] testClassPathAndName) 14 | { 15 | Array.Reverse(testClassPathAndName); 16 | TestClassCodeGenerator testClassCodeGenerator = TestClassCodeGenerator.Create(testClassPathAndName); 17 | GeneratorOutputs generatorOutputs = testClassCodeGenerator.RunGenerators(); 18 | Assert.NotNull(generatorOutputs.MainOutput); 19 | 20 | foreach (GeneratorOutput generatorOutput in generatorOutputs.Outputs) 21 | { 22 | testClassCodeGenerator.WriteGeneratedCodeIfChanged(generatorOutput); 23 | } 24 | 25 | // testClassCodeGenerator.WriteGeneratedCodeAsExpectedCode(generatorOutputs.MainOutput!); 26 | string expectedCode = testClassCodeGenerator.ReadExpectedCode(generatorOutputs.MainOutput!.ClassName); 27 | Assert.Equal(expectedCode, generatorOutputs.MainOutput.Code); 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/AliasNamespaceClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | using MyList = System.Collections.Generic.IList; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.AliasNamespaceClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentCollection(0, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 14 | public MyList Friends { get; set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/CollectionInterfaceMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.CollectionInterfaceMemberClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentCollection(0, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 14 | public IList Friends { get; set; } 15 | 16 | [FluentCollection(1, "Pet")] 17 | public IReadOnlyCollection Pets { get; set; } 18 | 19 | [FluentCollection(2, "BackpackContent", "WithBackpackContent", "WithBackpackContent", "WithNoBackpackContent")] 20 | public ISet BackpackContent { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/CollectionMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.CollectionMemberClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentCollection(0, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 14 | public List Friends { get; set; } 15 | 16 | [FluentCollection(1, "Pet")] 17 | public string[] Pets { get; set; } 18 | 19 | [FluentCollection(2, "BackpackContent", "WithBackpackContent", "WithBackpackContent", "WithNoBackpackContent")] 20 | public HashSet BackpackContent { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/CollectionMemberClassWithSuppression/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.CollectionMemberClassWithSuppression; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentCollection(0, "Friend", "WhoseFriendsAre", null, null)] 14 | public List Friends { get; set; } 15 | 16 | [FluentCollection(1, "Pet", withItem: null, withZeroItems: null)] 17 | public string[] Pets { get; set; } 18 | 19 | [FluentCollection(2, "BackpackContent", "WithBackpackContent", null, null)] 20 | public HashSet BackpackContent { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/CollectionNullableArrayClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.CollectionNullableArrayClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentCollection(0, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 13 | public string[]? Friends { get; private set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ContinueWithAfterCompoundClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ContinueWithAfterCompoundClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "WithName")] 13 | [FluentContinueWith(2)] 14 | public string FirstName { get; private set; } 15 | 16 | [FluentMember(0, "WithName")] 17 | [FluentContinueWith(2)] 18 | public string LastName { get; private set; } 19 | 20 | [FluentMember(1)] 21 | public string Property1 { get; private set; } 22 | 23 | [FluentMember(2)] 24 | public string Property2 { get; private set; } 25 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ContinueWithInForkClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ContinueWithInForkClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(1)] 13 | public string Member1 { get; set; } 14 | 15 | [FluentMember(2)] 16 | [FluentContinueWith(3)] 17 | public string? Member2A { get; set; } 18 | 19 | [FluentMember(2)] 20 | [FluentContinueWith(4)] 21 | public string? Member2B { get; set; } 22 | 23 | [FluentMember(3)] 24 | public string? Member3 { get; set; } 25 | 26 | [FluentMember(4)] 27 | public string Member4 { get; set; } 28 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ContinueWithOfOverloadedMethodClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ContinueWithOfOverloadedMethodClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMethod(0)] 13 | [FluentContinueWith(1)] 14 | public void Method1() 15 | { 16 | } 17 | 18 | [FluentMethod(0)] 19 | [FluentContinueWith(2)] 20 | public void Method1(int p1) 21 | { 22 | } 23 | 24 | [FluentMember(1)] 25 | public string Property1 { get; private set; } 26 | 27 | [FluentMember(2)] 28 | public string Property2 { get; private set; } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ContinueWithSelfClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ContinueWithSelfClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public string FirstName { get; private set; } 14 | 15 | [FluentMember(1)] 16 | [FluentContinueWith(1)] 17 | public string? MiddleName { get; private set; } 18 | 19 | [FluentMember(1)] public string LastName { get; private set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/CustomFluentMethodNameClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.CustomFluentMethodNameClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | public string Name { get; set; } 14 | 15 | [FluentPredicate(1, "WhoIsHappy", "WhoIsSad")] 16 | public bool IsHappy { get; set; } 17 | 18 | [FluentMember(2, "InSemester")] 19 | public int Semester { get; set; } 20 | 21 | [FluentCollection(3, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 22 | public IReadOnlyCollection Friends { get; set; } 23 | 24 | [FluentMethod(0, "WithName")] 25 | public void SetNameFromFirstNameAndLastName(string firstName, string lastName) 26 | { 27 | Name = $"{lastName}, {firstName}"; 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/DefaultFluentMethodNameClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.DefaultFluentMethodNameClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | public string Name { get; set; } 14 | 15 | [FluentPredicate(1)] 16 | public bool IsHappy { get; set; } 17 | 18 | [FluentMember(2)] 19 | public int Semester { get; set; } 20 | 21 | [FluentCollection(3, "Friend")] 22 | public IReadOnlyCollection Friends { get; set; } 23 | 24 | [FluentMethod(0)] 25 | public void WithName(string firstName, string lastName) 26 | { 27 | Name = $"{lastName}, {firstName}"; 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/EmptyClass/CreateStudent.expected.txt: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.EmptyClass; 9 | 10 | public class CreateStudent : CreateStudent.ICreateStudent 11 | { 12 | private readonly Student student; 13 | 14 | private CreateStudent() 15 | { 16 | student = new Student(); 17 | } 18 | 19 | public static ICreateStudent InitialStep() 20 | { 21 | return new CreateStudent(); 22 | } 23 | 24 | public interface ICreateStudent 25 | { 26 | } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/EmptyClass/CreateStudent.g.cs: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.EmptyClass; 9 | 10 | public class CreateStudent : CreateStudent.ICreateStudent 11 | { 12 | private readonly Student student; 13 | 14 | private CreateStudent() 15 | { 16 | student = new Student(); 17 | } 18 | 19 | public static ICreateStudent InitialStep() 20 | { 21 | return new CreateStudent(); 22 | } 23 | 24 | public interface ICreateStudent 25 | { 26 | } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/EmptyClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.EmptyClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentDefaultMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using System; 4 | using M31.FluentApi.Attributes; 5 | 6 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentDefaultMemberClass; 7 | 8 | [FluentApi] 9 | public class Student 10 | { 11 | [FluentMember(0, "WithName")] 12 | [FluentDefault("WithUnknownName")] 13 | public string Name { get; set; } = "unknown"; 14 | 15 | [FluentMember(1, "BornOn")] 16 | [FluentDefault] 17 | public DateOnly DateOfBirth { get; set; } = new DateOnly(); 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public string Name { get; set; } 14 | 15 | [FluentMember(1)] 16 | public Address Address { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaClassInDifferentNamespace/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace SomeOtherNamespace; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaClassInDifferentNamespace/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | using SomeOtherNamespace; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaClassInDifferentNamespace; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0)] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1)] 17 | public Address Address { get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaCollectionClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaCollectionClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaCollectionClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaCollectionClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0)] 14 | public string Name { get; set; } 15 | 16 | [FluentCollection(1, "Address")] 17 | public List
Addresses { get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaCompoundClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaCompoundClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaCompoundClass/Phone.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaCompoundClass; 8 | 9 | [FluentApi] 10 | public class Phone 11 | { 12 | [FluentMember(0)] 13 | public string Number { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Usage { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaCompoundClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaCompoundClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public string Name { get; set; } 14 | 15 | [FluentMember(1, "WithDetails")] 16 | public Address Address { get; set; } 17 | 18 | [FluentMember(1, "WithDetails")] 19 | public Phone Phone { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaCompoundOfSameTypeClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaCompoundOfSameTypeClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaCompoundOfSameTypeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaCompoundOfSameTypeClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public string Name { get; set; } 14 | 15 | [FluentMember(1, "WithDetails")] 16 | public Address Address1 { get; set; } 17 | 18 | [FluentMember(1, "WithDetails")] 19 | public Address Address2 { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaManyCollectionsClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaManyCollectionsClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaManyCollectionsClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaManyCollectionsClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0)] 14 | public string Name { get; set; } 15 | 16 | [FluentCollection(1, "AddressA")] 17 | public List
AddressesA { get; set; } 18 | 19 | [FluentCollection(1, "AddressB")] 20 | public IReadOnlyCollection
AddressesB { get; set; } 21 | 22 | [FluentCollection(1, "AddressC")] 23 | public Address[] AddressesC { get; set; } 24 | 25 | [FluentCollection(1, "AddressD")] 26 | public HashSet
AddressesD { get; set; } 27 | 28 | [FluentCollection(1, "AddressE")] 29 | public Address[]? AddressesE { get; set; } 30 | 31 | [FluentCollection(1, "AddressF")] 32 | public Address?[] AddressesF { get; set; } 33 | 34 | [FluentCollection(1, "AddressG")] 35 | public Address?[]? AddressesG { get; set; } 36 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaManyPrivateCollectionsClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaManyPrivateCollectionsClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaManyPrivateCollectionsClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaManyPrivateCollectionsClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0)] 14 | public string Name { get; private set; } 15 | 16 | [FluentCollection(1, "AddressA")] 17 | public List
AddressesA { get; private set; } 18 | 19 | [FluentCollection(1, "AddressB")] 20 | public IReadOnlyCollection
AddressesB { get; private set; } 21 | 22 | [FluentCollection(1, "AddressC")] 23 | public Address[] AddressesC { get; private set; } 24 | 25 | [FluentCollection(1, "AddressD")] 26 | public HashSet
AddressesD { get; private set; } 27 | 28 | [FluentCollection(1, "AddressE")] 29 | public Address[]? AddressesE { get; private set; } 30 | 31 | [FluentCollection(1, "AddressF")] 32 | public Address?[] AddressesF { get; private set; } 33 | 34 | [FluentCollection(1, "AddressG")] 35 | public Address?[]? AddressesG { get; private set; } 36 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaNullablePropertyClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaNullablePropertyClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaNullablePropertyClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaNullablePropertyClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public string Name { get; set; } 14 | 15 | [FluentMember(1)] 16 | [FluentNullable] 17 | public Address? Address { get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaRecursiveClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaRecursiveClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public string Name { get; set; } 14 | 15 | [FluentMember(1)] 16 | [FluentNullable] 17 | public Student? Friend { get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaSingleStepClass/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaSingleStepClass; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentLambdaSingleStepClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentLambdaSingleStepClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public Address Address { get; set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentMethodClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentMethodClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | public string Name { get; set; } 14 | public DateOnly DateOfBirth{ get; set; } 15 | public int Semester { get; set; } 16 | 17 | [FluentMethod(0)] 18 | public void WithName(string name) 19 | { 20 | Name = name; 21 | } 22 | 23 | [FluentMethod(1)] 24 | public void BornOn(DateOnly date) 25 | { 26 | DateOfBirth = date; 27 | } 28 | 29 | [FluentMethod(2)] 30 | public void InSemester(int semester) 31 | { 32 | Semester = semester; 33 | } 34 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentMethodParameterModifiersClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentMethodParameterModifiersClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | public int[] Numbers { get; set; } 13 | public int N1 { get; set; } 14 | public int N2 { get; set; } 15 | public int N3 { get; set; } 16 | public int N4 { get; set; } 17 | public int N5 { get; set; } 18 | public int N6 { get; set; } 19 | 20 | [FluentMethod(0)] 21 | public void MethodWithParams(params int[] numbers) 22 | { 23 | Numbers = numbers; 24 | } 25 | 26 | [FluentMethod(1)] 27 | public void MethodWithRefParameter(ref int n1) 28 | { 29 | n1 *= 2; 30 | N1 = n1; 31 | } 32 | 33 | [FluentMethod(2)] 34 | public void MethodWithInParameter(in int n2) 35 | { 36 | N2 = n2; 37 | } 38 | 39 | [FluentMethod(3)] 40 | public void MethodWithOutParameter(out int n3) 41 | { 42 | n3 = 3; 43 | N3 = n3; 44 | } 45 | 46 | [FluentMethod(4)] 47 | public void MethodWithRefInAndOutParameter(ref int n4, in int n5, out int n6) 48 | { 49 | n4 *= 2; 50 | N4 = n4; 51 | N5 = n5; 52 | n6 = 6; 53 | N6 = n6; 54 | } 55 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentNullableClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using System; 4 | using M31.FluentApi.Attributes; 5 | 6 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentNullableClass; 7 | 8 | [FluentApi] 9 | public class Student 10 | { 11 | [FluentMember(0, "WithName")] 12 | [FluentNullable("WhoseNameIsUnknown")] 13 | public string? Name { get; set; } 14 | 15 | [FluentMember(1, "BornOn")] 16 | [FluentNullable()] 17 | public DateOnly? DateOfBirth{ get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentNullableNoNullableAnnotationClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentNullableNoNullableAnnotationClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "WithName")] 13 | [FluentNullable("WhoseNameIsUnknown")] 14 | public string Name { get; set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentNullableNoNullableAnnotationPrivateSetClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentNullableNoNullableAnnotationPrivateSetClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "WithName")] 13 | [FluentNullable("WhoseNameIsUnknown")] 14 | public string Name { get; private set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentReturnMultiStepClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentReturnMultiStepClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0)] 14 | public string Name { get; private set; } 15 | 16 | [FluentMethod(1)] 17 | [FluentReturn] 18 | public void ReturnVoidMethod() 19 | { 20 | return; 21 | } 22 | 23 | [FluentMethod(1)] 24 | [FluentReturn] 25 | public int ReturnIntMethod() 26 | { 27 | return 24; 28 | } 29 | 30 | [FluentMethod(1)] 31 | [FluentReturn] 32 | public List ReturnListMethod() 33 | { 34 | return new List() { 1, 2, 3 }; 35 | } 36 | 37 | [FluentMethod(1)] 38 | [FluentReturn] 39 | public int ReturnIntMethodWithRefParameter(ref string s) 40 | { 41 | return 28; 42 | } 43 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentReturnMultiStepPrivateMethodsClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentReturnMultiStepPrivateMethodsClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0)] 14 | public string Name { get; private set; } 15 | 16 | [FluentMethod(1)] 17 | [FluentReturn] 18 | private void ReturnVoidMethod() 19 | { 20 | return; 21 | } 22 | 23 | [FluentMethod(1)] 24 | [FluentReturn] 25 | private int ReturnIntMethod() 26 | { 27 | return 24; 28 | } 29 | 30 | [FluentMethod(1)] 31 | [FluentReturn] 32 | private List ReturnListMethod() 33 | { 34 | return new List() { 1, 2, 3 }; 35 | } 36 | 37 | [FluentMethod(1)] 38 | [FluentReturn] 39 | private int ReturnIntMethodWithRefParameter(ref string s) 40 | { 41 | return 28; 42 | } 43 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentReturnSingleStepClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentReturnSingleStepClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMethod(0)] 14 | [FluentReturn] 15 | public void ReturnVoidMethod() 16 | { 17 | return; 18 | } 19 | 20 | [FluentMethod(0)] 21 | [FluentReturn] 22 | public int ReturnIntMethod() 23 | { 24 | return 24; 25 | } 26 | 27 | [FluentMethod(0)] 28 | [FluentReturn] 29 | public List ReturnListMethod() 30 | { 31 | return new List() { 1, 2, 3 }; 32 | } 33 | 34 | [FluentMethod(0)] 35 | [FluentReturn] 36 | public int ReturnIntMethodWithRefParameter(ref string s) 37 | { 38 | return 28; 39 | } 40 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FluentReturnSingleStepPrivateMethodsClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FluentReturnSingleStepPrivateMethodsClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMethod(0)] 14 | [FluentReturn] 15 | private void ReturnVoidMethod() 16 | { 17 | return; 18 | } 19 | 20 | [FluentMethod(0)] 21 | [FluentReturn] 22 | private int ReturnIntMethod() 23 | { 24 | return 24; 25 | } 26 | 27 | [FluentMethod(0)] 28 | [FluentReturn] 29 | private List ReturnListMethod() 30 | { 31 | return new List() { 1, 2, 3 }; 32 | } 33 | 34 | [FluentMethod(0)] 35 | [FluentReturn] 36 | private int ReturnIntMethodWithRefParameter(ref string s) 37 | { 38 | return 28; 39 | } 40 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ForkClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using System; 4 | using M31.FluentApi.Attributes; 5 | 6 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ForkClass; 7 | 8 | [FluentApi] 9 | public class Student 10 | { 11 | [FluentMember(0, "OfAge")] 12 | public int Age { get; set; } 13 | 14 | [FluentMember(0, "BornOn")] 15 | public DateOnly DateOfBirth { get; set; } 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/FullyQualifiedTypeClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.FullyQualifiedTypeClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "BornOn")] 13 | public System.DateOnly DateOfBirth{ get; set; } 14 | 15 | [FluentCollection(0, "Friend")] 16 | public System.Collections.Generic.List Friends { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GenericClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GenericClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | public T1 Property1 { get; set; } 14 | 15 | [FluentMember(0)] 16 | public T2 Property2 { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GenericClassPrivateConstructor/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GenericClassPrivateConstructor; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | private Student(T1 property1, T2 property2) 13 | { 14 | Property1 = property1; 15 | Property2 = property2; 16 | } 17 | 18 | [FluentMember(0)] 19 | public T1 Property1 { get; set; } 20 | 21 | [FluentMember(0)] 22 | public T2 Property2 { get; set; } 23 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GenericClassPrivateDefaultConstructor/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GenericClassPrivateDefaultConstructor; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | private Student() 13 | { 14 | 15 | } 16 | 17 | [FluentMember(0)] 18 | public T1 Property1 { get; set; } 19 | 20 | [FluentMember(0)] 21 | public T2 Property2 { get; set; } 22 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GenericClassWithConstraints/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GenericClassWithConstraints; 9 | 10 | [FluentApi] 11 | public class Student 12 | where T1 : class 13 | where T2 : class? 14 | where T3 : struct 15 | where T4 : notnull 16 | where T5 : new() 17 | where T6 : unmanaged 18 | where T7 : List, IDictionary 19 | where T8 : class, IDictionary 20 | where T9 : List, new() 21 | { 22 | [FluentMember(1)] 23 | public T1 Property1 { get; set; } 24 | 25 | [FluentMember(2)] 26 | public T2 Property2 { get; set; } 27 | 28 | [FluentMember(3)] 29 | public T3 Property3 { get; set; } 30 | 31 | [FluentMember(4)] 32 | public T4 Property4 { get; set; } 33 | 34 | [FluentMember(5)] 35 | public T5 Property5 { get; set; } 36 | 37 | [FluentMember(6)] 38 | public T6 Property6 { get; set; } 39 | 40 | [FluentMember(7)] 41 | public T7 Property7 { get; set; } 42 | 43 | [FluentMember(8)] 44 | public T8 Property8 { get; set; } 45 | 46 | [FluentMember(9)] 47 | public T9 Property9 { get; set; } 48 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GenericMethodWithConstraintsClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections.Generic; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GenericMethodWithConstraintsClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMethod(1)] 14 | public void Method1( 15 | T1 p1, 16 | T2 p2, 17 | T3 p3, 18 | T4 p4, 19 | T5 p5, 20 | T6 p6, 21 | T7 p7, 22 | T8 p8, 23 | T9 p9) 24 | where T1 : class 25 | where T2 : class? 26 | where T3 : struct 27 | where T4 : notnull 28 | where T5 : new() 29 | where T6 : unmanaged 30 | where T7 : List, IDictionary 31 | where T8 : class, IDictionary 32 | where T9 : List, new() 33 | { 34 | } 35 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GetInitPropertyClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GetInitPropertyClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0, "InSemester")] 11 | public int Semester { get; init; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GetPrivateInitPropertyClass/Student.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Attributes; 2 | // ReSharper disable All 3 | 4 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GetPrivateInitPropertyClass; 5 | 6 | [FluentApi] 7 | public class Student 8 | { 9 | [FluentMember(0, "InSemester")] 10 | public int Semester { get; private init; } 11 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/GetPrivateSetPropertyClass/Student.cs: -------------------------------------------------------------------------------- 1 | using M31.FluentApi.Attributes; 2 | // ReSharper disable All 3 | 4 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.GetPrivateSetPropertyClass; 5 | 6 | [FluentApi] 7 | public class Student 8 | { 9 | [FluentMember(0, "InSemester")] 10 | public int Semester { get; private set; } 11 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClass/Person.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClass; 9 | 10 | [FluentApi] 11 | public class Person 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClass; 9 | 10 | [FluentApi] 11 | public class Student : Person 12 | { 13 | [FluentMember(2, "InSemester")] 14 | public int Semester { get; set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClassPrivateSetters/Person.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClassPrivateSetters; 9 | 10 | [FluentApi] 11 | public class Person 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; private set; } 15 | 16 | [FluentMember(1, "OfAge")] 17 | public int Age { get; private set; } 18 | 19 | [FluentMethod(1)] 20 | private void BornOn(DateOnly dateOfBirth) 21 | { 22 | DateOnly today = new DateOnly(2024, 9, 26); 23 | int age = today.Year - dateOfBirth.Year; 24 | if (dateOfBirth > today.AddYears(-age)) age--; 25 | Age = age; 26 | } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClassPrivateSetters/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClassPrivateSetters; 9 | 10 | [FluentApi] 11 | public class Student : Person 12 | { 13 | [FluentMember(2, "InSemester")] 14 | public int Semester { get; private set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClassProtectedMembers/Person.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClassProtectedMembers; 9 | 10 | [FluentApi] 11 | public class Person 12 | { 13 | [FluentMember(0, "WithName")] 14 | protected string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | protected DateOnly DateOfBirth{ get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClassProtectedMembers/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClassProtectedMembers; 9 | 10 | [FluentApi] 11 | public class Student : Person 12 | { 13 | [FluentMember(2, "InSemester")] 14 | protected int Semester { get; set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClassProtectedSetters/Person.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClassProtectedSetters; 9 | 10 | [FluentApi] 11 | public class Person 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; protected set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; protected set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedClassProtectedSetters/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedClassProtectedSetters; 9 | 10 | [FluentApi] 11 | public class Student : Person 12 | { 13 | [FluentMember(2, "InSemester")] 14 | public int Semester { get; protected set; } 15 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedRecord/Person.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedRecord; 9 | 10 | [FluentApi] 11 | public record Person( 12 | [property: FluentMember(0, "WithName")] string Name, 13 | [property: FluentMember(1, "BornOn")] DateOnly DateOfBirth); -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InheritedRecord/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InheritedRecord; 9 | 10 | [FluentApi] 11 | public record Student( 12 | string Name, 13 | DateOnly DateOfBirth, 14 | [property: FluentMember(2, "InSemester")] int Semester) 15 | : Person(Name, DateOfBirth); -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InternalClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InternalClass; 9 | 10 | [FluentApi] 11 | internal class Student 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; set; } 18 | 19 | [FluentMember(2, "InSemester")] 20 | public int Semester { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InternalPropertyClass/CreateStudent.expected.txt: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InternalPropertyClass; 9 | 10 | public class CreateStudent : 11 | CreateStudent.ICreateStudent, 12 | CreateStudent.IInSemester 13 | { 14 | private readonly Student student; 15 | 16 | private CreateStudent() 17 | { 18 | student = new Student(); 19 | } 20 | 21 | public static ICreateStudent InitialStep() 22 | { 23 | return new CreateStudent(); 24 | } 25 | 26 | public static Student InSemester(int semester) 27 | { 28 | CreateStudent createStudent = new CreateStudent(); 29 | createStudent.student.Semester = semester; 30 | return createStudent.student; 31 | } 32 | 33 | Student IInSemester.InSemester(int semester) 34 | { 35 | student.Semester = semester; 36 | return student; 37 | } 38 | 39 | public interface ICreateStudent : IInSemester 40 | { 41 | } 42 | 43 | public interface IInSemester 44 | { 45 | Student InSemester(int semester); 46 | } 47 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InternalPropertyClass/CreateStudent.g.cs: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InternalPropertyClass; 9 | 10 | public class CreateStudent : 11 | CreateStudent.ICreateStudent, 12 | CreateStudent.IInSemester 13 | { 14 | private readonly Student student; 15 | 16 | private CreateStudent() 17 | { 18 | student = new Student(); 19 | } 20 | 21 | public static ICreateStudent InitialStep() 22 | { 23 | return new CreateStudent(); 24 | } 25 | 26 | public static Student InSemester(int semester) 27 | { 28 | CreateStudent createStudent = new CreateStudent(); 29 | createStudent.student.Semester = semester; 30 | return createStudent.student; 31 | } 32 | 33 | Student IInSemester.InSemester(int semester) 34 | { 35 | student.Semester = semester; 36 | return student; 37 | } 38 | 39 | public interface ICreateStudent : IInSemester 40 | { 41 | } 42 | 43 | public interface IInSemester 44 | { 45 | Student InSemester(int semester); 46 | } 47 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/InternalPropertyClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.InternalPropertyClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0, "InSemester")] 11 | internal int Semester { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/NonGenericCollectionMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System.Collections; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.NonGenericCollectionMemberClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentCollection(0, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 14 | public IEnumerable Friends { get; set; } 15 | 16 | [FluentCollection(1, "Pet")] 17 | public IList Pets { get; set; } 18 | 19 | [FluentCollection(2, "BackpackContent", "WithBackpackContent", "WithBackpackContent", "WithNoBackpackContent")] 20 | public ICollection BackpackContent { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/NullablePredicateAndCollectionClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using System.Collections.Generic; 4 | using M31.FluentApi.Attributes; 5 | 6 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.NullablePredicateAndCollectionClass; 7 | 8 | [FluentApi] 9 | public class Student 10 | { 11 | [FluentCollection(0, "Friend", "WhoseFriendsAre", "WhoseFriendIs", "WhoHasNoFriends")] 12 | [FluentNullable("WhoseFriendsAreUnknown")] 13 | public IReadOnlyCollection? Friends { get; set; } 14 | 15 | [FluentPredicate(1, "WhoIsHappy", "WhoIsSad")] 16 | [FluentNullable("WithUnknownMood")] 17 | public bool? IsHappy { get; private set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/OneMemberClass/CreateStudent.expected.txt: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.OneMemberClass; 9 | 10 | public class CreateStudent : 11 | CreateStudent.ICreateStudent, 12 | CreateStudent.IInSemester 13 | { 14 | private readonly Student student; 15 | 16 | private CreateStudent() 17 | { 18 | student = new Student(); 19 | } 20 | 21 | public static ICreateStudent InitialStep() 22 | { 23 | return new CreateStudent(); 24 | } 25 | 26 | public static Student InSemester(int semester) 27 | { 28 | CreateStudent createStudent = new CreateStudent(); 29 | createStudent.student.Semester = semester; 30 | return createStudent.student; 31 | } 32 | 33 | Student IInSemester.InSemester(int semester) 34 | { 35 | student.Semester = semester; 36 | return student; 37 | } 38 | 39 | public interface ICreateStudent : IInSemester 40 | { 41 | } 42 | 43 | public interface IInSemester 44 | { 45 | Student InSemester(int semester); 46 | } 47 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/OneMemberClass/CreateStudent.g.cs: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.OneMemberClass; 9 | 10 | public class CreateStudent : 11 | CreateStudent.ICreateStudent, 12 | CreateStudent.IInSemester 13 | { 14 | private readonly Student student; 15 | 16 | private CreateStudent() 17 | { 18 | student = new Student(); 19 | } 20 | 21 | public static ICreateStudent InitialStep() 22 | { 23 | return new CreateStudent(); 24 | } 25 | 26 | public static Student InSemester(int semester) 27 | { 28 | CreateStudent createStudent = new CreateStudent(); 29 | createStudent.student.Semester = semester; 30 | return createStudent.student; 31 | } 32 | 33 | Student IInSemester.InSemester(int semester) 34 | { 35 | student.Semester = semester; 36 | return student; 37 | } 38 | 39 | public interface ICreateStudent : IInSemester 40 | { 41 | } 42 | 43 | public interface IInSemester 44 | { 45 | Student InSemester(int semester); 46 | } 47 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/OneMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.OneMemberClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0, "InSemester")] 11 | public int Semester { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/OverloadedMethodClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.OverloadedMethodClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | public string? FirstName { get; private set; } 13 | public string LastName { get; private set; } 14 | 15 | [FluentMethod(0)] 16 | private void Named(string firstName, string lastName) 17 | { 18 | FirstName = firstName; 19 | LastName = lastName; 20 | } 21 | 22 | [FluentMethod(0)] 23 | private void Named(string lastName) 24 | { 25 | LastName = lastName; 26 | } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PartialClass/Student1.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PartialClass; 8 | 9 | [FluentApi] 10 | public partial class Student 11 | { 12 | [FluentMember(0)] 13 | public string FirstName { get; private set; } 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PartialClass/Student2.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PartialClass; 8 | 9 | public partial class Student 10 | { 11 | [FluentMember(1)] 12 | public string LastName { get; private set; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PredicateClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PredicateClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentPredicate(0, "WhoIsHappy", "WhoIsSad")] 11 | public bool IsHappy { get; set; } 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PredicatePrivateFieldClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Field is never used 2 | #pragma warning disable CS0169 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PredicatePrivateFieldClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentPredicate(0, "WhoIsHappy", "WhoIsSad")] 13 | private bool isHappy; 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateConstructorClass/CreateStudent.expected.txt: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | using System; 9 | 10 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateConstructorClass; 11 | 12 | public class CreateStudent : 13 | CreateStudent.ICreateStudent, 14 | CreateStudent.IInSemester 15 | { 16 | private readonly Student student; 17 | 18 | private CreateStudent() 19 | { 20 | student = (Student) Activator.CreateInstance(typeof(Student), true)!; 21 | } 22 | 23 | public static ICreateStudent InitialStep() 24 | { 25 | return new CreateStudent(); 26 | } 27 | 28 | public static Student InSemester(int semester) 29 | { 30 | CreateStudent createStudent = new CreateStudent(); 31 | createStudent.student.Semester = semester; 32 | return createStudent.student; 33 | } 34 | 35 | Student IInSemester.InSemester(int semester) 36 | { 37 | student.Semester = semester; 38 | return student; 39 | } 40 | 41 | public interface ICreateStudent : IInSemester 42 | { 43 | } 44 | 45 | public interface IInSemester 46 | { 47 | Student InSemester(int semester); 48 | } 49 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateConstructorClass/CreateStudent.g.cs: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | using System; 9 | 10 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateConstructorClass; 11 | 12 | public class CreateStudent : 13 | CreateStudent.ICreateStudent, 14 | CreateStudent.IInSemester 15 | { 16 | private readonly Student student; 17 | 18 | private CreateStudent() 19 | { 20 | student = (Student) Activator.CreateInstance(typeof(Student), true)!; 21 | } 22 | 23 | public static ICreateStudent InitialStep() 24 | { 25 | return new CreateStudent(); 26 | } 27 | 28 | public static Student InSemester(int semester) 29 | { 30 | CreateStudent createStudent = new CreateStudent(); 31 | createStudent.student.Semester = semester; 32 | return createStudent.student; 33 | } 34 | 35 | Student IInSemester.InSemester(int semester) 36 | { 37 | student.Semester = semester; 38 | return student; 39 | } 40 | 41 | public interface ICreateStudent : IInSemester 42 | { 43 | } 44 | 45 | public interface IInSemester 46 | { 47 | Student InSemester(int semester); 48 | } 49 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateConstructorClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateConstructorClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | private Student() 11 | { 12 | 13 | } 14 | 15 | [FluentMember(0, "InSemester")] 16 | public int Semester { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateFieldClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Field is never assigned to, and will always have its default value 2 | #pragma warning disable CS0649 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateFieldClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "InSemester")] 13 | private int semester; 14 | 15 | public int Semester => semester; 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateFluentMethodClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateFluentMethodClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | public string Name { get; set; } 14 | public DateOnly DateOfBirth { get; set; } 15 | public int Semester { get; set; } 16 | 17 | [FluentMethod(0)] 18 | private void WithName(string name) 19 | { 20 | Name = name; 21 | } 22 | 23 | [FluentMethod(1)] 24 | private void BornOn(DateOnly date) 25 | { 26 | DateOfBirth = date; 27 | } 28 | 29 | [FluentMethod(2)] 30 | private void InSemester(int semester) 31 | { 32 | Semester = semester; 33 | } 34 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateFluentMethodNullableParameterClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateFluentMethodNullableParameterClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | public string? Name { get; set; } 14 | public DateOnly? DateOfBirth { get; set; } 15 | public int? Semester { get; set; } 16 | 17 | [FluentMethod(0)] 18 | private void WithName(string? name) 19 | { 20 | Name = name; 21 | } 22 | 23 | [FluentMethod(1)] 24 | private void BornOn(DateOnly? date) 25 | { 26 | DateOfBirth = date; 27 | } 28 | 29 | [FluentMethod(2)] 30 | private void InSemester(int? semester) 31 | { 32 | Semester = semester; 33 | } 34 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateFluentMethodParameterModifiersClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateFluentMethodParameterModifiersClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | public int[] Numbers { get; set; } 13 | public int N1 { get; set; } 14 | public int N2 { get; set; } 15 | public int N3 { get; set; } 16 | public int N4 { get; set; } 17 | public int N5 { get; set; } 18 | public int N6 { get; set; } 19 | 20 | [FluentMethod(0)] 21 | private void MethodWithParams(params int[] numbers) 22 | { 23 | Numbers = numbers; 24 | } 25 | 26 | [FluentMethod(1)] 27 | private void MethodWithRefParameter(ref int n1) 28 | { 29 | n1 *= 2; 30 | N1 = n1; 31 | } 32 | 33 | [FluentMethod(2)] 34 | private void MethodWithInParameter(in int n2) 35 | { 36 | N2 = n2; 37 | } 38 | 39 | [FluentMethod(3)] 40 | private void MethodWithOutParameter(out int n3) 41 | { 42 | n3 = 3; 43 | N3 = n3; 44 | } 45 | 46 | [FluentMethod(4)] 47 | private void MethodWithRefInAndOutParameter(ref int n4, in int n5, out int n6) 48 | { 49 | n4 *= 2; 50 | N4 = n4; 51 | N5 = n5; 52 | n6 = 6; 53 | N6 = n6; 54 | } 55 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateReadonlyFieldClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Field is never used 2 | #pragma warning disable CS0169 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateReadonlyFieldClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "InSemester")] 13 | private readonly int semester; 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PrivateUnderscoreFieldClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Field is never used 2 | #pragma warning disable CS0169 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PrivateUnderscoreFieldClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "InSemester")] 13 | private readonly int _semester; 14 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PublicFieldClass/CreateStudent.expected.txt: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PublicFieldClass; 9 | 10 | public class CreateStudent : 11 | CreateStudent.ICreateStudent, 12 | CreateStudent.IInSemester 13 | { 14 | private readonly Student student; 15 | 16 | private CreateStudent() 17 | { 18 | student = new Student(); 19 | } 20 | 21 | public static ICreateStudent InitialStep() 22 | { 23 | return new CreateStudent(); 24 | } 25 | 26 | public static Student InSemester(int semester) 27 | { 28 | CreateStudent createStudent = new CreateStudent(); 29 | createStudent.student.Semester = semester; 30 | return createStudent.student; 31 | } 32 | 33 | Student IInSemester.InSemester(int semester) 34 | { 35 | student.Semester = semester; 36 | return student; 37 | } 38 | 39 | public interface ICreateStudent : IInSemester 40 | { 41 | } 42 | 43 | public interface IInSemester 44 | { 45 | Student InSemester(int semester); 46 | } 47 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PublicFieldClass/CreateStudent.g.cs: -------------------------------------------------------------------------------- 1 | // 2 | // This code was generated by the library M31.FluentAPI. 3 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 4 | 5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 6 | #nullable enable 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PublicFieldClass; 9 | 10 | public class CreateStudent : 11 | CreateStudent.ICreateStudent, 12 | CreateStudent.IInSemester 13 | { 14 | private readonly Student student; 15 | 16 | private CreateStudent() 17 | { 18 | student = new Student(); 19 | } 20 | 21 | public static ICreateStudent InitialStep() 22 | { 23 | return new CreateStudent(); 24 | } 25 | 26 | public static Student InSemester(int semester) 27 | { 28 | CreateStudent createStudent = new CreateStudent(); 29 | createStudent.student.Semester = semester; 30 | return createStudent.student; 31 | } 32 | 33 | Student IInSemester.InSemester(int semester) 34 | { 35 | student.Semester = semester; 36 | return student; 37 | } 38 | 39 | public interface ICreateStudent : IInSemester 40 | { 41 | } 42 | 43 | public interface IInSemester 44 | { 45 | Student InSemester(int semester); 46 | } 47 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PublicFieldClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PublicFieldClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0, "InSemester")] 11 | public int Semester; 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/PublicReadonlyFieldClass/Student.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | 3 | using M31.FluentApi.Attributes; 4 | 5 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.PublicReadonlyFieldClass; 6 | 7 | [FluentApi] 8 | public class Student 9 | { 10 | [FluentMember(0, "InSemester")] 11 | public readonly int Semester; 12 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SameNameMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // Field is never used 4 | #pragma warning disable CS0169 5 | // ReSharper disable All 6 | 7 | using M31.FluentApi.Attributes; 8 | 9 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SameNameMemberClass; 10 | 11 | [FluentApi] 12 | public class Student 13 | { 14 | [FluentMember(0, "InSemester")] 15 | public int Semester { get; private set; } 16 | 17 | [FluentMember(1, "WithName")] 18 | public char Initial { get; private set; } 19 | 20 | [FluentMember(2, "WithName")] 21 | public string LastName { get; private set; } 22 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SkippableFirstMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SkippableFirstMemberClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentSkippable] 14 | public string? FirstName { get; set; } 15 | 16 | [FluentMember(1)] 17 | public string LastName { get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SkippableFirstTwoMembersClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SkippableFirstTwoMembersClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentSkippable] 14 | public string? FirstName { get; set; } 15 | 16 | [FluentMember(1)] 17 | [FluentSkippable] 18 | public string? MiddleName { get; set; } 19 | 20 | [FluentMember(2)] 21 | public string LastName { get; set; } 22 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SkippableForkMembersClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SkippableForkMembersClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentSkippable] 14 | public string? Member0 { get; set; } 15 | 16 | [FluentMember(1)] 17 | [FluentSkippable] 18 | public string? Member1A { get; set; } 19 | 20 | [FluentMember(1)] 21 | [FluentSkippable] 22 | [FluentContinueWith(0)] 23 | public string? Member1B { get; set; } 24 | 25 | [FluentMember(2)] 26 | public string? Member2 { get; set; } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SkippableLoopClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SkippableLoopClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(1)] 13 | [FluentSkippable] 14 | public string? Member1 { get; set; } 15 | 16 | [FluentMember(2)] 17 | [FluentSkippable] 18 | public string? Member2 { get; set; } 19 | 20 | [FluentMember(3)] 21 | [FluentSkippable] 22 | [FluentContinueWith(1)] 23 | public string? Member3 { get; set; } 24 | 25 | [FluentMember(3)] 26 | public string Member4 { get; set; } 27 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SkippableMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SkippableMemberClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] public string FirstName { get; set; } 13 | 14 | [FluentMember(1)] 15 | [FluentSkippable] 16 | public string? MiddleName { get; set; } 17 | 18 | [FluentMember(2)] public string LastName { get; set; } 19 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SkippableSeveralMembersClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SkippableSeveralMembersClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(1)] 13 | [FluentSkippable] 14 | public string? Member1 { get; set; } 15 | 16 | [FluentMember(2)] 17 | [FluentSkippable] 18 | public string? Member2 { get; set; } 19 | 20 | [FluentMember(3)] 21 | [FluentSkippable] 22 | public string? Member3 { get; set; } 23 | 24 | [FluentMember(4)] 25 | public string Member4 { get; set; } 26 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/SkippableTwoLoopsClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.SkippableTwoLoopsClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0)] 13 | [FluentSkippable] 14 | public string? Member0 { get; set; } 15 | 16 | [FluentMember(1)] 17 | [FluentSkippable] 18 | [FluentContinueWith(0)] 19 | public string? Member1 { get; set; } 20 | 21 | [FluentMember(1)] 22 | public string? Member1B { get; set; } 23 | 24 | [FluentMember(2)] 25 | public string? Member2 { get; set; } 26 | 27 | [FluentMember(3)] 28 | [FluentSkippable] 29 | public string? Member3 { get; set; } 30 | 31 | [FluentMember(4)] 32 | [FluentSkippable] 33 | [FluentContinueWith(3)] 34 | public string? Member4 { get; set; } 35 | 36 | [FluentMember(4)] 37 | public string? Member4B { get; set; } 38 | 39 | [FluentMember(5)] 40 | public string? Member5 { get; set; } 41 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ThreeMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ThreeMemberClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; set; } 18 | 19 | [FluentMember(2, "InSemester")] 20 | public int Semester { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ThreeMemberRecord/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ThreeMemberRecord; 9 | 10 | [FluentApi] 11 | public record Student 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; set; } 18 | 19 | [FluentMember(2, "InSemester")] 20 | public int Semester { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ThreeMemberRecordPrimaryConstructor/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using System.Reflection.Metadata; 7 | using M31.FluentApi.Attributes; 8 | 9 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ThreeMemberRecordPrimaryConstructor; 10 | 11 | [FluentApi] 12 | public record Student( 13 | [property: FluentMember(0, "WithName")] string name, 14 | [property: FluentMember(1, "BornOn")] DateOnly dateOfBirth, 15 | [property: FluentMember(2, "InSemester")] int semester) 16 | { 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ThreeMemberRecordStruct/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ThreeMemberRecordStruct; 9 | 10 | [FluentApi] 11 | public record struct Student 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; set; } 18 | 19 | [FluentMember(2, "InSemester")] 20 | public int Semester { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ThreeMemberStruct/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ThreeMemberStruct; 9 | 10 | [FluentApi] 11 | public struct Student 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; set; } 18 | 19 | [FluentMember(2, "InSemester")] 20 | public int Semester { get; set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/ThreePrivateMembersClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.ThreePrivateMembersClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; private set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; private set; } 18 | 19 | [FluentMember(2, "InSemester")] 20 | public int Semester { get; private set; } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/TryBreakFluentApiClass1/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.TryBreakFluentApiClass1; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMethod(0)] 13 | private void SomeMethod(string someMethodMethodInfo) 14 | { 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/TryBreakFluentApiClass2/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.TryBreakFluentApiClass2; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMethod(0)] 13 | private void SomeMethod(string createStudent) 14 | { 15 | } 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/TryBreakFluentApiClass3/Address.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable all 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.TryBreakFluentApiClass3; 8 | 9 | [FluentApi] 10 | public class Address 11 | { 12 | [FluentMember(0)] 13 | public string HouseNumber { get; set; } 14 | 15 | [FluentMember(1)] 16 | public string Street { get; set; } 17 | 18 | [FluentMember(2, "InCity")] 19 | public string City { get; set; } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/TryBreakFluentApiClass3/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.TryBreakFluentApiClass3; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "WithDetails")] 13 | public string CreateAddress { get; set; } 14 | 15 | [FluentMember(0, "WithDetails")] 16 | public Address Address { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/TwoMemberClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using System; 6 | using M31.FluentApi.Attributes; 7 | 8 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.TwoMemberClass; 9 | 10 | [FluentApi] 11 | public class Student 12 | { 13 | [FluentMember(0, "WithName")] 14 | public string Name { get; set; } 15 | 16 | [FluentMember(1, "BornOn")] 17 | public DateOnly DateOfBirth{ get; set; } 18 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/TwoParameterCompoundClass/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.TwoParameterCompoundClass; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "WithName")] 13 | public string FirstName { get; set; } 14 | 15 | [FluentMember(0, "WithName")] 16 | public string LastName { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/CodeGeneration/TestClasses/Abstract/TwoParameterCompoundClassReversedParameters/Student.cs: -------------------------------------------------------------------------------- 1 | // Non-nullable member is uninitialized 2 | #pragma warning disable CS8618 3 | // ReSharper disable All 4 | 5 | using M31.FluentApi.Attributes; 6 | 7 | namespace M31.FluentApi.Tests.CodeGeneration.TestClasses.Abstract.TwoParameterCompoundClassReversedParameters; 8 | 9 | [FluentApi] 10 | public class Student 11 | { 12 | [FluentMember(0, "WithName", 1)] 13 | public string FirstName { get; set; } 14 | 15 | [FluentMember(0, "WithName", 0)] 16 | public string LastName { get; set; } 17 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/Components/CodeBuilding/Robots.expected.txt: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace M31.FluentApi.Tests.Components; 4 | 5 | public class Robot : IMove 6 | { 7 | private readonly List tasks; 8 | 9 | public string Name { get; } 10 | public int YearOfManufacture { get; } 11 | public double PosX { get; private set; } 12 | public double PosY { get; private set; } 13 | public IReadOnlyCollection Tasks => tasks; 14 | 15 | public Robot(string name, int yearOfManufacture, double posX = 0, double posY = 0) 16 | { 17 | Name = name; 18 | YearOfManufacture = yearOfManufacture; 19 | tasks = new List(); 20 | PosX = posX; 21 | PosY = posY; 22 | } 23 | 24 | public void Move(double deltaX, double deltaY) 25 | { 26 | PosX += deltaX; 27 | PosY += deltaY; 28 | } 29 | 30 | public void AssignTask(string task) 31 | { 32 | tasks.Add(task); 33 | } 34 | } 35 | 36 | public interface IMove 37 | { 38 | void Move(double deltaX, double deltaY); 39 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/Components/CodeBuilding/Robots.g.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace M31.FluentApi.Tests.Components; 4 | 5 | public class Robot : IMove 6 | { 7 | private readonly List tasks; 8 | 9 | public string Name { get; } 10 | public int YearOfManufacture { get; } 11 | public double PosX { get; private set; } 12 | public double PosY { get; private set; } 13 | public IReadOnlyCollection Tasks => tasks; 14 | 15 | public Robot(string name, int yearOfManufacture, double posX = 0, double posY = 0) 16 | { 17 | Name = name; 18 | YearOfManufacture = yearOfManufacture; 19 | tasks = new List(); 20 | PosX = posX; 21 | PosY = posY; 22 | } 23 | 24 | public void Move(double deltaX, double deltaY) 25 | { 26 | PosX += deltaX; 27 | PosY += deltaY; 28 | } 29 | 30 | public void AssignTask(string task) 31 | { 32 | tasks.Add(task); 33 | } 34 | } 35 | 36 | public interface IMove 37 | { 38 | void Move(double deltaX, double deltaY); 39 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/Helpers/GeneratorOutput.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Tests.Helpers; 2 | 3 | internal class GeneratorOutput 4 | { 5 | internal GeneratorOutput(string code, string className) 6 | { 7 | Code = code; 8 | ClassName = className; 9 | } 10 | 11 | internal string Code { get; } 12 | internal string ClassName { get; } 13 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/Helpers/GeneratorOutputs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace M31.FluentApi.Tests.Helpers; 5 | 6 | internal class GeneratorOutputs 7 | { 8 | internal GeneratorOutputs(IReadOnlyCollection outputs) 9 | { 10 | Outputs = outputs; 11 | } 12 | 13 | internal IReadOnlyCollection Outputs { get; } 14 | internal GeneratorOutput? MainOutput => Outputs.Count > 0 ? Outputs.First() : null; 15 | internal IEnumerable OtherOutputs => Outputs.Skip(1); 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.Tests/Helpers/SyntaxExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using M31.FluentApi.Generator.Commons; 3 | using Microsoft.CodeAnalysis; 4 | using Microsoft.CodeAnalysis.CSharp.Syntax; 5 | 6 | namespace M31.FluentApi.Tests.Helpers; 7 | 8 | internal static class SyntaxExtensions 9 | { 10 | internal static TypeDeclarationSyntax? GetFluentApiTypeDeclaration(this SyntaxTree syntaxTree) 11 | { 12 | SyntaxNode root = syntaxTree.GetRoot(); 13 | TypeDeclarationSyntax? typeDeclaration = (TypeDeclarationSyntax?)root.Find(n => n.IsClassStructOrRecordSyntax()); 14 | return typeDeclaration; 15 | } 16 | 17 | internal static SyntaxNode? Find(this SyntaxNode tree, Predicate predicate) 18 | { 19 | if (predicate(tree)) 20 | { 21 | return tree; 22 | } 23 | 24 | foreach (SyntaxNode child in tree.ChildNodes()) 25 | { 26 | SyntaxNode? found = Find(child, predicate); 27 | 28 | if (found != null) 29 | { 30 | return found; 31 | } 32 | } 33 | 34 | return null; 35 | } 36 | } -------------------------------------------------------------------------------- /src/M31.FluentApi.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True 4 | True 5 | True -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentApiAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates a fluent API for the target class, struct or record. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] 9 | public class FluentApiAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The name of the generated builder class. 15 | public FluentApiAttribute(string builderClassName = "Create{Name}") 16 | { 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentBreakAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Attributes; 2 | 3 | /// 4 | /// After calling the builder method, the builder stops and the created instance is returned. 5 | /// 6 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] 7 | public class FluentBreakAttribute : Attribute 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public FluentBreakAttribute() 13 | { 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentCollectionAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates builder methods for a collection. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 9 | public class FluentCollectionAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The builder step in which the collection can be set. 15 | /// The singular of the collection name. 16 | /// The name of the builder method that sets multiple items. 17 | /// The name of the builder method that sets a single item. 18 | /// If set to null, the builder method will not be generated. 19 | /// The name of the builder method that sets zero items. 20 | /// If set to null, the builder method will not be generated. 21 | public FluentCollectionAttribute( 22 | int builderStep, 23 | string singularName, 24 | string withItems = "With{Name}", 25 | string? withItem = "With{SingularName}", 26 | string? withZeroItems = "WithZero{Name}") 27 | { 28 | } 29 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentContinueWithAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// After calling the builder method, the fluent API continues with the given step. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] 9 | public class FluentContinueWithAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The builder step to continue with. 15 | public FluentContinueWithAttribute(int builderStep) 16 | { 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentDefaultAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates a builder method for the initial value of a member. Can be used in combination with other attributes. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 9 | public class FluentDefaultAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The name of the generated builder method. When called the member will keep its initial 15 | /// value. 16 | /// 17 | public FluentDefaultAttribute(string method = "WithDefault{Name}") 18 | { 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentLambdaAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates a builder method that accepts a lambda expression for creating the target field or property with its 7 | /// Fluent API. 8 | /// 9 | [Obsolete( 10 | "Use FluentMember instead. Lambda methods are generated by default if the decorated member has a Fluent API.", 11 | false)] 12 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 13 | public class FluentLambdaAttribute : Attribute 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The builder step in which the member can be set. 19 | /// The name of the generated builder method. 20 | public FluentLambdaAttribute(int builderStep, string method = "With{Name}") 21 | { 22 | } 23 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentMemberAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates a builder method for the target field or property. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 9 | public class FluentMemberAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The builder step in which the member can be set. 15 | /// The name of the generated builder method. 16 | /// The parameter position of the member in the builder method; only relevant for 17 | /// compound builder methods. 18 | public FluentMemberAttribute(int builderStep, string method = "With{Name}", int parameterPosition = 0) 19 | { 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates a builder method that calls the target method. 7 | /// 8 | [AttributeUsage(AttributeTargets.Method)] 9 | public class FluentMethodAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The builder step in which the method can be called. 15 | /// The name of the generated builder method. The builder method calls the decorated method. 16 | /// 17 | public FluentMethodAttribute(int builderStep, string method = "{Name}") 18 | { 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentNullableAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates a builder method for a nullable member. Can be used in combination with other attributes. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 9 | public class FluentNullableAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The name of the generated builder method. The builder method sets the member's value to 15 | /// 'null'. 16 | public FluentNullableAttribute(string method = "Without{Name}") 17 | { 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentPredicateAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedParameter.Local 2 | 3 | namespace M31.FluentApi.Attributes; 4 | 5 | /// 6 | /// Generates builder methods for a boolean member. 7 | /// 8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] 9 | public class FluentPredicateAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The builder step in which the member can be set. 15 | /// The name of the builder method that sets the member's value to 'true'. 16 | /// 17 | /// The name of the builder method that sets the member's value to 18 | /// 'false'. 19 | public FluentPredicateAttribute(int builderStep, string method = "{Name}", string negatedMethod = "Not{Name}") 20 | { 21 | } 22 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentReturnAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Attributes; 2 | 3 | /// 4 | /// The builder stops and the return value of the builder method is returned. 5 | /// 6 | [AttributeUsage(AttributeTargets.Method)] 7 | public class FluentReturnAttribute : Attribute 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public FluentReturnAttribute() 13 | { 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /src/M31.FluentApi/Attributes/FluentSkippableAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace M31.FluentApi.Attributes; 2 | 3 | /// 4 | /// The builder method can be skipped. 5 | /// 6 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] 7 | public class FluentSkippableAttribute : Attribute 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public FluentSkippableAttribute() 13 | { 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /src/delete-generated-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find . -name "*.g.cs" -type f -delete 4 | -------------------------------------------------------------------------------- /src/find-generated-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find . -name "*.g.cs" -type f 4 | --------------------------------------------------------------------------------