From 0997c1379c72d82e933e098a704c9870479e5c0c Mon Sep 17 00:00:00 2001 From: Thorsten Thiel Date: Tue, 1 Oct 2024 23:56:37 +0200 Subject: [PATCH] Add Crud Generation --- src/Benchmark/Bench.cs | 2 +- src/Fluss.Regen/AnalyzerReleases.Shipped.md | 0 src/Fluss.Regen/AnalyzerReleases.Unshipped.md | 12 + src/Fluss.Regen/Attributes/CrudAttribute.cs | 20 + src/Fluss.Regen/Attributes/IRegenAttribute.cs | 1 - .../Attributes/SelectorAttribute.cs | 6 +- .../FileBuilders/CrudFileBuilder.cs | 405 ++++++++++++++++++ .../FileBuilders/SelectorFileBuilder.cs | 20 +- src/Fluss.Regen/Fluss.Regen.csproj | 4 + src/Fluss.Regen/Generators/CrudGenerator.cs | 201 +++++++++ .../Generators/RegistrationGenerator.cs | 13 +- .../Generators/SelectorGenerator.cs | 94 +++- src/Fluss.Regen/Helpers/CodeWriter.cs | 36 +- src/Fluss.Regen/Inspectors/CrudInspector.cs | 258 +++++++++++ src/Fluss.Regen/Models/CrudInfo.cs | 78 ++++ .../RepetitiveEventsourcingCodeGenerator.cs | 23 +- .../Core/UnitOfWork/UnitOfWorkTest.cs | 1 + src/Fluss.UnitTest/Fluss.UnitTest.csproj | 4 - src/Fluss.UnitTest/Regen/CrudTests.cs | 228 ++++++++++ src/Fluss.UnitTest/Regen/RegenTests.cs | 22 +- ...Partial.DotNet8_0#Attributes.g.verified.cs | 18 + ...sIsNotPartial.DotNet8_0#Crud.g.verified.cs | 7 + ...rtial.DotNet8_0#Registration.g.verified.cs | 15 + ...tPartial.DotNet8_0#Selectors.g.verified.cs | 50 +++ ...IfClassIsNotPartial.DotNet8_0.verified.txt | 14 + ...Partial.DotNet9_0#Attributes.g.verified.cs | 18 + ...sIsNotPartial.DotNet9_0#Crud.g.verified.cs | 7 + ...rtial.DotNet9_0#Registration.g.verified.cs | 15 + ...tPartial.DotNet9_0#Selectors.g.verified.cs | 50 +++ ...IfClassIsNotPartial.DotNet9_0.verified.txt | 14 + ...Partial.DotNet8_0#Attributes.g.verified.cs | 18 + ...sIsNotPartial.DotNet8_0#Crud.g.verified.cs | 7 + ...rtial.DotNet8_0#Registration.g.verified.cs | 15 + ...tPartial.DotNet8_0#Selectors.g.verified.cs | 77 ++++ ...enClassIsNotPartial.DotNet8_0.verified.txt | 14 + ...Partial.DotNet9_0#Attributes.g.verified.cs | 18 + ...sIsNotPartial.DotNet9_0#Crud.g.verified.cs | 7 + ...rtial.DotNet9_0#Registration.g.verified.cs | 15 + ...tPartial.DotNet9_0#Selectors.g.verified.cs | 77 ++++ ...enClassIsNotPartial.DotNet9_0.verified.txt | 14 + ...rtyName.DotNet8_0#Attributes.g.verified.cs | 18 + ...ePropertyName.DotNet8_0#Crud.g.verified.cs | 7 + ...yName.DotNet8_0#Registration.g.verified.cs | 15 + ...ertyName.DotNet8_0#Selectors.g.verified.cs | 50 +++ ...plicatePropertyName.DotNet8_0.verified.txt | 14 + ...rtyName.DotNet9_0#Attributes.g.verified.cs | 18 + ...ePropertyName.DotNet9_0#Crud.g.verified.cs | 7 + ...yName.DotNet9_0#Registration.g.verified.cs | 15 + ...ertyName.DotNet9_0#Selectors.g.verified.cs | 50 +++ ...plicatePropertyName.DotNet9_0.verified.txt | 14 + ...pported.DotNet8_0#Attributes.g.verified.cs | 18 + ...sNotSupported.DotNet8_0#Crud.g.verified.cs | 7 + ...orted.DotNet8_0#Registration.g.verified.cs | 15 + ...upported.DotNet8_0#Selectors.g.verified.cs | 77 ++++ ...yTypeIsNotSupported.DotNet8_0.verified.txt | 14 + ...pported.DotNet9_0#Attributes.g.verified.cs | 18 + ...sNotSupported.DotNet9_0#Crud.g.verified.cs | 7 + ...orted.DotNet9_0#Registration.g.verified.cs | 15 + ...upported.DotNet9_0#Selectors.g.verified.cs | 77 ++++ ...yTypeIsNotSupported.DotNet9_0.verified.txt | 14 + ...ritance.DotNet8_0#Attributes.g.verified.cs | 18 + ...idInheritance.DotNet8_0#Crud.g.verified.cs | 7 + ...tance.DotNet8_0#Registration.g.verified.cs | 15 + ...eritance.DotNet8_0#Selectors.g.verified.cs | 77 ++++ ...nInvalidInheritance.DotNet8_0.verified.txt | 14 + ...ritance.DotNet9_0#Attributes.g.verified.cs | 18 + ...idInheritance.DotNet9_0#Crud.g.verified.cs | 7 + ...tance.DotNet9_0#Registration.g.verified.cs | 15 + ...eritance.DotNet9_0#Selectors.g.verified.cs | 77 ++++ ...nInvalidInheritance.DotNet9_0.verified.txt | 14 + ...Missing.DotNet8_0#Attributes.g.verified.cs | 18 + ...espaceMissing.DotNet8_0#Crud.g.verified.cs | 7 + ...ssing.DotNet8_0#Registration.g.verified.cs | 15 + ...eMissing.DotNet8_0#Selectors.g.verified.cs | 77 ++++ ...henNamespaceMissing.DotNet8_0.verified.txt | 14 + ...Missing.DotNet9_0#Attributes.g.verified.cs | 18 + ...espaceMissing.DotNet9_0#Crud.g.verified.cs | 7 + ...ssing.DotNet9_0#Registration.g.verified.cs | 15 + ...eMissing.DotNet9_0#Selectors.g.verified.cs | 77 ++++ ...henNamespaceMissing.DotNet9_0.verified.txt | 14 + ...onflict.DotNet8_0#Attributes.g.verified.cs | 18 + ...amingConflict.DotNet8_0#Crud.g.verified.cs | 7 + ...flict.DotNet8_0#Registration.g.verified.cs | 15 + ...Conflict.DotNet8_0#Selectors.g.verified.cs | 77 ++++ ...cWhenNamingConflict.DotNet8_0.verified.txt | 14 + ...onflict.DotNet9_0#Attributes.g.verified.cs | 18 + ...amingConflict.DotNet9_0#Crud.g.verified.cs | 7 + ...flict.DotNet9_0#Registration.g.verified.cs | 15 + ...Conflict.DotNet9_0#Selectors.g.verified.cs | 77 ++++ ...cWhenNamingConflict.DotNet9_0.verified.txt | 14 + ...rtyName.DotNet8_0#Attributes.g.verified.cs | 18 + ...dPropertyName.DotNet8_0#Crud.g.verified.cs | 7 + ...yName.DotNet8_0#Registration.g.verified.cs | 15 + ...ertyName.DotNet8_0#Selectors.g.verified.cs | 50 +++ ...eservedPropertyName.DotNet8_0.verified.txt | 14 + ...rtyName.DotNet9_0#Attributes.g.verified.cs | 18 + ...dPropertyName.DotNet9_0#Crud.g.verified.cs | 7 + ...yName.DotNet9_0#Registration.g.verified.cs | 15 + ...ertyName.DotNet9_0#Selectors.g.verified.cs | 50 +++ ...eservedPropertyName.DotNet9_0.verified.txt | 14 + ...rtyType.DotNet8_0#Attributes.g.verified.cs | 18 + ...dPropertyType.DotNet8_0#Crud.g.verified.cs | 7 + ...yType.DotNet8_0#Registration.g.verified.cs | 15 + ...ertyType.DotNet8_0#Selectors.g.verified.cs | 50 +++ ...pportedPropertyType.DotNet8_0.verified.txt | 14 + ...rtyType.DotNet9_0#Attributes.g.verified.cs | 18 + ...dPropertyType.DotNet9_0#Crud.g.verified.cs | 7 + ...yType.DotNet9_0#Registration.g.verified.cs | 15 + ...ertyType.DotNet9_0#Selectors.g.verified.cs | 50 +++ ...pportedPropertyType.DotNet9_0.verified.txt | 14 + ...endWhen.DotNet8_0#Attributes.g.verified.cs | 18 + ...ateExtendWhen.DotNet8_0#Crud.g.verified.cs | 108 +++++ ...dWhen.DotNet8_0#Registration.g.verified.cs | 15 + ...tendWhen.DotNet8_0#Selectors.g.verified.cs | 77 ++++ ...endWhen.DotNet9_0#Attributes.g.verified.cs | 18 + ...ateExtendWhen.DotNet9_0#Crud.g.verified.cs | 108 +++++ ...dWhen.DotNet9_0#Registration.g.verified.cs | 15 + ...tendWhen.DotNet9_0#Selectors.g.verified.cs | 77 ++++ ...pleCase.DotNet8_0#Attributes.g.verified.cs | 18 + ...ForSimpleCase.DotNet8_0#Crud.g.verified.cs | 81 ++++ ...eCase.DotNet8_0#Registration.g.verified.cs | 15 + ...mpleCase.DotNet8_0#Selectors.g.verified.cs | 50 +++ ...pleCase.DotNet9_0#Attributes.g.verified.cs | 18 + ...ForSimpleCase.DotNet9_0#Crud.g.verified.cs | 81 ++++ ...eCase.DotNet9_0#Registration.g.verified.cs | 15 + ...mpleCase.DotNet9_0#Selectors.g.verified.cs | 50 +++ ...eWithId.DotNet8_0#Attributes.g.verified.cs | 18 + ...pleCaseWithId.DotNet8_0#Crud.g.verified.cs | 143 +++++++ ...ithId.DotNet8_0#Registration.g.verified.cs | 15 + ...seWithId.DotNet8_0#Selectors.g.verified.cs | 77 ++++ ...eWithId.DotNet9_0#Attributes.g.verified.cs | 18 + ...pleCaseWithId.DotNet9_0#Crud.g.verified.cs | 143 +++++++ ...ithId.DotNet9_0#Registration.g.verified.cs | 15 + ...seWithId.DotNet9_0#Selectors.g.verified.cs | 77 ++++ ...lidator.DotNet8_0#Attributes.g.verified.cs | 18 + ...ventValidator.DotNet8_0#Crud.g.verified.cs | 7 + ...dator.DotNet8_0#Registration.g.verified.cs | 8 +- ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...alidator.DotNet8_0#Selectors.g.verified.cs | 2 +- ...lidator.DotNet9_0#Attributes.g.verified.cs | 18 + ...ventValidator.DotNet9_0#Crud.g.verified.cs | 7 + ...dator.DotNet9_0#Registration.g.verified.cs | 8 +- ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...alidator.DotNet9_0#Selectors.g.verified.cs | 2 +- ...rPolicy.DotNet8_0#Attributes.g.verified.cs | 18 + ...rateForPolicy.DotNet8_0#Crud.g.verified.cs | 7 + ...olicy.DotNet8_0#Registration.g.verified.cs | 8 +- ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...orPolicy.DotNet8_0#Selectors.g.verified.cs | 2 +- ...rPolicy.DotNet9_0#Attributes.g.verified.cs | 18 + ...rateForPolicy.DotNet9_0#Crud.g.verified.cs | 7 + ...olicy.DotNet9_0#Registration.g.verified.cs | 8 +- ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...orPolicy.DotNet9_0#Selectors.g.verified.cs | 2 +- ...eEffect.DotNet8_0#Attributes.g.verified.cs | 18 + ...ForSideEffect.DotNet8_0#Crud.g.verified.cs | 7 + ...ffect.DotNet8_0#Registration.g.verified.cs | 8 +- ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...deEffect.DotNet8_0#Selectors.g.verified.cs | 2 +- ...eEffect.DotNet9_0#Attributes.g.verified.cs | 18 + ...ForSideEffect.DotNet9_0#Crud.g.verified.cs | 7 + ...ffect.DotNet9_0#Registration.g.verified.cs | 8 +- ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...deEffect.DotNet9_0#Selectors.g.verified.cs | 2 +- ...pcaster.DotNet8_0#Attributes.g.verified.cs | 18 + ...teForUpcaster.DotNet8_0#Crud.g.verified.cs | 7 + ...aster.DotNet8_0#Registration.g.verified.cs | 8 +- ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...Upcaster.DotNet8_0#Selectors.g.verified.cs | 2 +- ...pcaster.DotNet9_0#Attributes.g.verified.cs | 18 + ...teForUpcaster.DotNet9_0#Crud.g.verified.cs | 7 + ...aster.DotNet9_0#Registration.g.verified.cs | 8 +- ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...Upcaster.DotNet9_0#Selectors.g.verified.cs | 2 +- ...lidator.DotNet8_0#Attributes.g.verified.cs | 18 + ...gateValidator.DotNet8_0#Crud.g.verified.cs | 7 + ...dator.DotNet8_0#Registration.g.verified.cs | 8 +- ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...alidator.DotNet8_0#Selectors.g.verified.cs | 2 +- ...lidator.DotNet9_0#Attributes.g.verified.cs | 18 + ...gateValidator.DotNet9_0#Crud.g.verified.cs | 7 + ...dator.DotNet9_0#Registration.g.verified.cs | 8 +- ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...alidator.DotNet9_0#Selectors.g.verified.cs | 2 +- ...elector.DotNet8_0#Attributes.g.verified.cs | 18 + ...AsyncSelector.DotNet8_0#Crud.g.verified.cs | 7 + ...ector.DotNet8_0#Registration.g.verified.cs | 15 + ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...Selector.DotNet8_0#Selectors.g.verified.cs | 6 +- ...elector.DotNet9_0#Attributes.g.verified.cs | 18 + ...AsyncSelector.DotNet9_0#Crud.g.verified.cs | 7 + ...ector.DotNet9_0#Registration.g.verified.cs | 15 + ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...Selector.DotNet9_0#Selectors.g.verified.cs | 6 +- ...elector.DotNet8_0#Attributes.g.verified.cs | 18 + ...AsyncSelector.DotNet8_0#Crud.g.verified.cs | 7 + ...ector.DotNet8_0#Registration.g.verified.cs | 15 + ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...Selector.DotNet8_0#Selectors.g.verified.cs | 4 +- ...elector.DotNet9_0#Attributes.g.verified.cs | 18 + ...AsyncSelector.DotNet9_0#Crud.g.verified.cs | 7 + ...ector.DotNet9_0#Registration.g.verified.cs | 15 + ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...Selector.DotNet9_0#Selectors.g.verified.cs | 4 +- ...elector.DotNet8_0#Attributes.g.verified.cs | 18 + ...fWorkSelector.DotNet8_0#Crud.g.verified.cs | 7 + ...ector.DotNet8_0#Registration.g.verified.cs | 15 + ....DotNet8_0#SelectorAttribute.g.verified.cs | 10 - ...Selector.DotNet8_0#Selectors.g.verified.cs | 4 +- ...elector.DotNet9_0#Attributes.g.verified.cs | 18 + ...fWorkSelector.DotNet9_0#Crud.g.verified.cs | 7 + ...ector.DotNet9_0#Registration.g.verified.cs | 15 + ....DotNet9_0#SelectorAttribute.g.verified.cs | 10 - ...Selector.DotNet9_0#Selectors.g.verified.cs | 4 +- ...Classes.DotNet8_0#Attributes.g.verified.cs | 18 + ...estingClasses.DotNet8_0#Crud.g.verified.cs | 7 + ...gClasses.DotNet8_0#Selectors.g.verified.cs | 26 ++ ...Classes.DotNet9_0#Attributes.g.verified.cs | 18 + ...estingClasses.DotNet9_0#Crud.g.verified.cs | 7 + ...gClasses.DotNet9_0#Selectors.g.verified.cs | 26 ++ src/Fluss/UnitOfWork/UnitOfWork.ReadModels.cs | 9 +- 221 files changed, 5443 insertions(+), 286 deletions(-) create mode 100644 src/Fluss.Regen/AnalyzerReleases.Shipped.md create mode 100644 src/Fluss.Regen/AnalyzerReleases.Unshipped.md create mode 100644 src/Fluss.Regen/Attributes/CrudAttribute.cs create mode 100644 src/Fluss.Regen/FileBuilders/CrudFileBuilder.cs create mode 100644 src/Fluss.Regen/Generators/CrudGenerator.cs create mode 100644 src/Fluss.Regen/Inspectors/CrudInspector.cs create mode 100644 src/Fluss.Regen/Models/CrudInfo.cs create mode 100644 src/Fluss.UnitTest/Regen/CrudTests.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0.verified.txt create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Registration.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Crud.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Registration.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Registration.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Registration.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Registration.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Registration.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Registration.g.verified.cs delete mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#SelectorAttribute.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Selectors.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Attributes.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Crud.g.verified.cs create mode 100644 src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Selectors.g.verified.cs diff --git a/src/Benchmark/Bench.cs b/src/Benchmark/Bench.cs index efc0f49..4574084 100644 --- a/src/Benchmark/Bench.cs +++ b/src/Benchmark/Bench.cs @@ -18,7 +18,7 @@ namespace Benchmark; public class Bench { [Params("postgres", "in-memory")] - public string StorageType { get; set; } + public string StorageType { get; set; } = "in-memory"; [IterationSetup] public void Setup() diff --git a/src/Fluss.Regen/AnalyzerReleases.Shipped.md b/src/Fluss.Regen/AnalyzerReleases.Shipped.md new file mode 100644 index 0000000..e69de29 diff --git a/src/Fluss.Regen/AnalyzerReleases.Unshipped.md b/src/Fluss.Regen/AnalyzerReleases.Unshipped.md new file mode 100644 index 0000000..aaeb5b6 --- /dev/null +++ b/src/Fluss.Regen/AnalyzerReleases.Unshipped.md @@ -0,0 +1,12 @@ +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +FLUSS0001 | Fluss.Regen | Error | CrudInspector +FLUSS0002 | Fluss.Regen | Error | CrudInspector +FLUSS0003 | Fluss.Regen | Error | CrudInspector +FLUSS0004 | Fluss.Regen | Error | CrudInspector +FLUSS0005 | Fluss.Regen | Error | CrudInspector +FLUSS0006 | Fluss.Regen | Error | CrudInspector +FLUSS0007 | Fluss.Regen | Error | CrudInspector +FLUSS0008 | Fluss.Regen | Error | CrudInspector \ No newline at end of file diff --git a/src/Fluss.Regen/Attributes/CrudAttribute.cs b/src/Fluss.Regen/Attributes/CrudAttribute.cs new file mode 100644 index 0000000..d5a47c5 --- /dev/null +++ b/src/Fluss.Regen/Attributes/CrudAttribute.cs @@ -0,0 +1,20 @@ +namespace Fluss.Regen.Attributes; + +public sealed class CrudAttribute : IRegenAttribute +{ + private const string Namespace = "Fluss.Regen"; + private const string AttributeName = "CrudAttribute"; + + public static string FullName => $"{Namespace}.{AttributeName}"; + + public string FileName => $"{AttributeName}.g.cs"; + public string SourceCode => $$""" + namespace {{Namespace}} + { + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class {{AttributeName}} : System.Attribute + { + } + } + """; +} \ No newline at end of file diff --git a/src/Fluss.Regen/Attributes/IRegenAttribute.cs b/src/Fluss.Regen/Attributes/IRegenAttribute.cs index d3fb344..371e83e 100644 --- a/src/Fluss.Regen/Attributes/IRegenAttribute.cs +++ b/src/Fluss.Regen/Attributes/IRegenAttribute.cs @@ -2,6 +2,5 @@ public interface IRegenAttribute { - string FileName { get; } string SourceCode { get; } } \ No newline at end of file diff --git a/src/Fluss.Regen/Attributes/SelectorAttribute.cs b/src/Fluss.Regen/Attributes/SelectorAttribute.cs index b3da9ee..0a77b23 100644 --- a/src/Fluss.Regen/Attributes/SelectorAttribute.cs +++ b/src/Fluss.Regen/Attributes/SelectorAttribute.cs @@ -6,14 +6,12 @@ public sealed class SelectorAttribute : IRegenAttribute private const string AttributeName = "SelectorAttribute"; public static string FullName => $"{Namespace}.{AttributeName}"; - + public string FileName => $"{AttributeName}.g.cs"; public string SourceCode => $$""" - // - namespace {{Namespace}} { - [System.AttributeUsage(System.AttributeTargets.Method)] + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] public class {{AttributeName}} : System.Attribute { } diff --git a/src/Fluss.Regen/FileBuilders/CrudFileBuilder.cs b/src/Fluss.Regen/FileBuilders/CrudFileBuilder.cs new file mode 100644 index 0000000..9df31fe --- /dev/null +++ b/src/Fluss.Regen/FileBuilders/CrudFileBuilder.cs @@ -0,0 +1,405 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Fluss.Regen.Generators; +using Fluss.Regen.Helpers; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; + +namespace Fluss.Regen.FileBuilders; + +public sealed class CrudFileBuilder : IDisposable +{ + private StringBuilder _sb; + private CodeWriter _writer; + private bool _disposed; + + public CrudFileBuilder() + { + _sb = StringBuilderPool.Get(); + _writer = new CodeWriter(_sb); + } + + public void WriteHeader() + { + _writer.WriteFileHeader(); + } + + public void WriteCrudClassStart(string @namespace, string className) + { + _writer.WriteLine(); + _writer.WriteIndentedLine($"namespace {@namespace}"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + _writer.WriteIndentedLine($"public partial class {className}"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteAggregateRootClassStart() + { + _writer.WriteIndentedLine("public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteAggregateRootWithKeyClassStart(string keyTypeName) + { + _writer.WriteIndentedLine("public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot<{0}>", keyTypeName); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteReadModelClassStart() + { + _writer.WriteLine(); + _writer.WriteIndentedLine("public partial record ReadModel : global::Fluss.ReadModel.RootReadModel"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteReadModelWithKeyClassStart(string keyTypeName) + { + _writer.WriteLine(); + _writer.WriteIndentedLine("public partial record ReadModel : global::Fluss.ReadModel.ReadModelWithKey<{0}>", keyTypeName); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteProperty(string propertyName, string typeName, string? initializer = null) + { + if (initializer != null) + { + _writer.WriteIndentedLine("public {0} {1} {{ get; init; }} = {2};", typeName, propertyName, initializer); + } + else + { + _writer.WriteIndentedLine("public {0} {1} {{ get; init; }}", typeName, propertyName); + } + } + + public void WriteCreateMethod(string crudName, IPropertySymbol idProperty, IEnumerable properties) + { + _writer.WriteLine(); + _writer.WriteIndentedLine($"public static async global::System.Threading.Tasks.Task Create(global::Fluss.IWriteUnitOfWork unitOfWork, Commands.{crudName}Create command)"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + _writer.WriteIndentedLine("var id = {0};", GetTypeInitializer(idProperty.Type)); + _writer.WriteIndentedLine($"var aggregate = await unitOfWork.GetAggregate(id);"); + _writer.WriteIndentedLine($"await aggregate.Apply(new Events.{crudName}Created("); + + using (var commaSeparated = _writer.CommaSeparatedIndented()) + { + commaSeparated.Write("id"); + + foreach (var property in properties) + { + commaSeparated.Write($"command.{property.Name}"); + } + } + + _writer.WriteIndentedLine("));"); + _writer.WriteIndentedLine("return aggregate;"); + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteChangeMethod(string crudName, IPropertySymbol? idProperty, IEnumerable properties) + { + _writer.WriteLine(); + _writer.WriteIndentedLine($"public async global::System.Threading.Tasks.Task Change(Commands.{crudName}Change command)"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + foreach (var property in properties) + { + _writer.WriteIndentedLine($"if (this.{property.Name} != command.{property.Name})"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + if (idProperty != null) + { + _writer.WriteIndentedLine($"await Apply(new Events.{crudName}{property.Name}Changed({idProperty.Name}, command.{property.Name}));"); + } + else + { + _writer.WriteIndentedLine($"await Apply(new Events.{crudName}{property.Name}Changed(command.{property.Name}));"); + } + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteAggregateWhenMethodStart(bool withCallToExtendWhen) + { + _writer.WriteLine(); + _writer.WriteIndentedLine("protected override Aggregate When(global::Fluss.Events.EventEnvelope envelope)"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + + if (withCallToExtendWhen) + { + _writer.WriteIndentedLine("return (envelope.Event switch"); + } + else + { + _writer.WriteIndentedLine("return envelope.Event switch"); + } + + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteReadModelWhenMethodStart(bool withCallToExtendWhen) + { + _writer.WriteLine(); + _writer.WriteIndentedLine("protected override ReadModel When(global::Fluss.Events.EventEnvelope envelope)"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + + if (withCallToExtendWhen) + { + _writer.WriteIndentedLine("return (envelope.Event switch"); + } + else + { + _writer.WriteIndentedLine("return envelope.Event switch"); + } + + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteWhenPropertyChanged(string crudName, string propertyName, string? idPropertyName) + { + var eventName = $"{crudName}{propertyName}Changed"; + var recordName = char.ToLower(eventName[0]) + eventName.Substring(1); + + if (idPropertyName != null) + { + _writer.WriteIndentedLine($"Events.{eventName} {recordName} when {recordName}.{idPropertyName} == {idPropertyName} => this with {{ {propertyName} = {recordName}.{propertyName} }},"); + } + else + { + _writer.WriteIndentedLine($"Events.{eventName} {recordName} => this with {{ {propertyName} = {recordName}.{propertyName} }},"); + } + } + + public void WriteWhenCreated(string crudName, string idPropertyName, IEnumerable propertyNames) + { + var createEventName = $"{crudName}Created"; + _writer.WriteIndentedLine($"Events.{createEventName} created when created.{idPropertyName} == {idPropertyName} => this with {{"); + + using (var commaSeparated = _writer.CommaSeparatedIndented()) + { + foreach (var propertyName in propertyNames) + { + commaSeparated.Write($"{propertyName} = created.{propertyName}"); + } + + commaSeparated.Write("Exists = true"); + } + + _writer.WriteIndentedLine("},"); + } + + public void WriteWhenDeleted(string crudName, string idPropertyName) + { + var deleteEventName = $"{crudName}Deleted"; + _writer.WriteIndentedLine($"Events.{deleteEventName} deleted when deleted.{idPropertyName} == {idPropertyName} => this with {{ Exists = false }},"); + } + + public void WriteWhenMethodEnd(bool withCallToExtendWhen) + { + _writer.WriteIndentedLine("_ => this,"); + _writer.DecreaseIndent(); + + if (withCallToExtendWhen) + { + _writer.WriteIndentedLine("}).ExtendWhen(envelope);"); + } + else + { + _writer.WriteIndentedLine("};"); + } + + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteAggregateOrReadModelEnd() + { + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteIdsReadModelStart(string idTypeName) + { + _writer.WriteLine(); + _writer.WriteIndentedLine("public partial record AllIds : global::Fluss.ReadModel.RootReadModel"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + _writer.WriteIndentedLine($"public global::System.Collections.Immutable.ImmutableHashSet<{idTypeName}> Ids {{ get; init; }} = global::System.Collections.Immutable.ImmutableHashSet<{idTypeName}>.Empty;"); + _writer.WriteLine(); + } + + public void WriteIdsReadModelWhenMethod(string crudName) + { + _writer.WriteIndentedLine("protected override AllIds When(global::Fluss.Events.EventEnvelope envelope)"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + _writer.WriteIndentedLine("return envelope.Event switch"); + _writer.WriteIndentedLine("{"); + + using (var commaSeparated = _writer.CommaSeparatedIndented()) + { + commaSeparated.Write($"Events.{crudName}Created created => this with {{ Ids = Ids.Add(created.Id) }}"); + commaSeparated.Write($"Events.{crudName}Deleted deleted => this with {{ Ids = Ids.Remove(deleted.Id) }}"); + commaSeparated.Write("_ => this"); + } + + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("};"); + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteSingleItemSelector(string crudName, string idType, string idPropertyName) + { + _writer.WriteLine(); + _writer.WriteIndentedLine("[global::Fluss.Regen.Selector]"); + _writer.WriteIndentedLine($"public static global::System.Threading.Tasks.ValueTask Get{crudName}(global::Fluss.IUnitOfWork unitOfWork, {idType} {idPropertyName.ToLowerInvariant()})"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + _writer.WriteIndentedLine($"return unitOfWork.GetReadModel({idPropertyName.ToLowerInvariant()});"); + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteAllItemsSelector(string crudName, string idType) + { + _writer.WriteLine(); + _writer.WriteIndentedLine("[global::Fluss.Regen.Selector]"); + _writer.WriteIndentedLine($"public static async global::System.Threading.Tasks.ValueTask> GetAll{crudName}s(global::Fluss.IUnitOfWork unitOfWork)"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + _writer.WriteIndentedLine("var allIds = await unitOfWork.GetReadModel();"); + _writer.WriteIndentedLine($"return await unitOfWork.GetMultipleReadModels(allIds.Ids);"); + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteGlobalSelector(string crudName) + { + _writer.WriteLine(); + _writer.WriteIndentedLine($"[global::Fluss.Regen.Selector]"); + _writer.WriteIndentedLine($"public static global::System.Threading.Tasks.ValueTask Get{crudName}(global::Fluss.IUnitOfWork unitOfWork)"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + _writer.WriteIndentedLine($"return unitOfWork.GetReadModel();"); + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteCrudClassEnd() + { + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteCommandsClassStart() + { + _writer.WriteLine(); + _writer.WriteIndentedLine("public static partial class Commands"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteCommandRecord(string name, List<(string Type, string Name)> properties) + { + _writer.WriteIndentedLine($"public record {name}("); + + using (var commaSeparated = _writer.CommaSeparatedIndented()) + { + foreach (var property in properties) + { + commaSeparated.Write($"{property.Type} {property.Name}"); + } + } + + _writer.WriteIndentedLine(");"); + } + + public void WriteCommandsClassEnd() + { + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public void WriteEventsClassStart() + { + _writer.WriteLine(); + _writer.WriteIndentedLine("public static partial class Events"); + _writer.WriteIndentedLine("{"); + _writer.IncreaseIndent(); + } + + public void WriteEventRecord(string name, List<(string Type, string Name)> properties) + { + _writer.WriteIndentedLine($"public record {name}("); + + using (var commaSeparated = _writer.CommaSeparatedIndented()) + { + foreach (var property in properties) + { + commaSeparated.Write($"{property.Type} {property.Name}"); + } + } + + _writer.WriteIndentedLine(") : global::Fluss.Events.Event;"); + } + + public void WriteEventsClassEnd() + { + _writer.DecreaseIndent(); + _writer.WriteIndentedLine("}"); + } + + public override string ToString() + => _sb.ToString(); + + public SourceText ToSourceText() + => SourceText.From(ToString(), Encoding.UTF8); + + public void Dispose() + { + if (_disposed) + { + return; + } + + StringBuilderPool.Return(_sb); + _sb = default!; + _writer = default!; + _disposed = true; + } + + public static string? GetTypeInitializer(ITypeSymbol idPropertyType) + { + if (idPropertyType.ToFullyQualified() == "global::System.Guid") + { + return "global::System.Guid.NewGuid()"; + } + + // Supports StronglyTypedIds + if (idPropertyType.TypeKind == TypeKind.Struct) + { + return $"new {idPropertyType.ToFullyQualified()}(global::System.Guid.NewGuid())"; + } + + return null; + } +} diff --git a/src/Fluss.Regen/FileBuilders/SelectorFileBuilder.cs b/src/Fluss.Regen/FileBuilders/SelectorFileBuilder.cs index fdb13a6..5910c81 100644 --- a/src/Fluss.Regen/FileBuilders/SelectorFileBuilder.cs +++ b/src/Fluss.Regen/FileBuilders/SelectorFileBuilder.cs @@ -39,7 +39,7 @@ public void WriteClassHeader() public void WriteEndNamespace() { - _writer.WriteIndentedLine("private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners);"); + _writer.WriteIndentedLine("private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners);"); _writer.WriteLine(); _writer.WriteIndented("private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) "); using (_writer.WriteBraces()) @@ -64,23 +64,23 @@ public void WriteEndNamespace() _writer.WriteLine(); } - public void WriteMethodSignatureStart(string methodName, ITypeSymbol returnType, bool noParameters) + public void WriteMethodSignatureStart(string methodName, string returnType, bool noParameters) { _writer.WriteLine(); _writer.WriteIndentedLine( "public static async global::{0}<{1}> Select{2}(this global::Fluss.IUnitOfWork unitOfWork{3}", typeof(ValueTask).FullName, - returnType.ToFullyQualified(), + returnType, methodName, noParameters ? "" : ", "); _writer.IncreaseIndent(); } - public void WriteMethodSignatureParameter(ITypeSymbol parameterType, string parameterName, bool isLast) + public void WriteMethodSignatureParameter(string parameterType, string parameterName, bool isLast) { _writer.WriteIndentedLine( "{0} {1}{2}", - parameterType.ToFullyQualified(), + parameterType, parameterName, isLast ? "" : "," ); @@ -118,19 +118,19 @@ public void WriteKeyEnd() _writer.WriteLine(); } - public void WriteMethodCacheHit(ITypeSymbol returnType) + public void WriteMethodCacheHit(string returnType) { _writer.WriteIndented("if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) "); using (_writer.WriteBraces()) { - _writer.WriteIndentedLine("return ({0})entryValue.Value;", returnType.ToFullyQualified()); + _writer.WriteIndentedLine("return ({0})entryValue.Value;", returnType); } _writer.WriteLine(); } public void WriteMethodCall(string containingType, string methodName, bool isAsync) { - _writer.WriteIndentedLine("result = {0}global::{1}.{2}(", isAsync ? "await " : "", containingType, methodName); + _writer.WriteIndentedLine("result = {0}{1}.{2}(", isAsync ? "await " : "", containingType, methodName); _writer.IncreaseIndent(); } @@ -146,7 +146,7 @@ public void WriteMethodCallEnd(bool isAsync) _writer.WriteLine(); } - public void WriteMethodCacheMiss(ITypeSymbol returnType) + public void WriteMethodCacheMiss(string returnType) { _writer.WriteIndented("using (var entry = _cache.CreateEntry(key)) "); @@ -157,7 +157,7 @@ public void WriteMethodCacheMiss(ITypeSymbol returnType) } _writer.WriteLine(); - _writer.WriteIndentedLine("return ({0})result;", returnType.ToFullyQualified()); + _writer.WriteIndentedLine("return ({0})result;", returnType); } public void WriteMethodEnd() diff --git a/src/Fluss.Regen/Fluss.Regen.csproj b/src/Fluss.Regen/Fluss.Regen.csproj index 273bd74..1464f7c 100644 --- a/src/Fluss.Regen/Fluss.Regen.csproj +++ b/src/Fluss.Regen/Fluss.Regen.csproj @@ -37,4 +37,8 @@ + + + + diff --git a/src/Fluss.Regen/Generators/CrudGenerator.cs b/src/Fluss.Regen/Generators/CrudGenerator.cs new file mode 100644 index 0000000..42ee920 --- /dev/null +++ b/src/Fluss.Regen/Generators/CrudGenerator.cs @@ -0,0 +1,201 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using Fluss.Regen.FileBuilders; +using Fluss.Regen.Helpers; +using Fluss.Regen.Inspectors; +using Fluss.Regen.Models; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Fluss.Regen.Generators; + +// TODO: Add way to extend the when method of aggregate / readmodel + +public class CrudGenerator : ISyntaxGenerator +{ + public void Generate(SourceProductionContext context, Compilation compilation, ImmutableArray syntaxInfos) + { + using var fileBuilder = new CrudFileBuilder(); + fileBuilder.WriteHeader(); + + foreach (var crudInfo in syntaxInfos.OfType()) + { + if (!crudInfo.Diagnostics.IsEmpty) + { + continue; + } + + fileBuilder.WriteCrudClassStart(crudInfo.Namespace, crudInfo.Name); + + if (crudInfo.IdProperty == null) + { + fileBuilder.WriteAggregateRootClassStart(); + } + else + { + fileBuilder.WriteAggregateRootWithKeyClassStart(GetKeyTypeName(crudInfo.IdProperty)); + } + + WriteProperties(fileBuilder, crudInfo, true); + + if (crudInfo.IdProperty != null) + { + fileBuilder.WriteCreateMethod(crudInfo.Name, crudInfo.IdProperty, crudInfo.Properties); + } + + fileBuilder.WriteChangeMethod(crudInfo.Name, crudInfo.IdProperty, crudInfo.Properties); + + WriteWhenMethod(fileBuilder, crudInfo, true); + fileBuilder.WriteAggregateOrReadModelEnd(); + + if (crudInfo.IdProperty == null) + { + fileBuilder.WriteReadModelClassStart(); + } + else + { + fileBuilder.WriteReadModelWithKeyClassStart(GetKeyTypeName(crudInfo.IdProperty)); + } + + WriteProperties(fileBuilder, crudInfo, false); + WriteWhenMethod(fileBuilder, crudInfo, false); + fileBuilder.WriteAggregateOrReadModelEnd(); + + WriteIdsReadModel(fileBuilder, crudInfo); + WriteSelectors(fileBuilder, crudInfo); + WriteCommands(fileBuilder, crudInfo); + WriteEvents(fileBuilder, crudInfo); + + fileBuilder.WriteCrudClassEnd(); + } + + context.AddSource("Crud.g.cs", fileBuilder.ToSourceText()); + } + + private static string GetKeyTypeName(IPropertySymbol idProperty) + { + return idProperty.Type.ToFullyQualified(); + } + + private void WriteProperties(CrudFileBuilder fileBuilder, CrudInfo crudInfo, bool isAggregate) + { + foreach (var property in crudInfo.Properties) + { + var initializer = property.DeclaringSyntaxReferences.Select(dsr => (dsr.GetSyntax() as PropertyDeclarationSyntax)?.Initializer?.Value.ToString()).FirstOrDefault(); + fileBuilder.WriteProperty(property.Name, property.Type.ToFullyQualified(), initializer); + } + + if (crudInfo.IdProperty != null && !isAggregate) + { + fileBuilder.WriteProperty("Exists", "bool"); + } + } + + private void WriteWhenMethod(CrudFileBuilder fileBuilder, CrudInfo crudInfo, bool isAggregate) + { + bool withCallToExtendWhen; + if (isAggregate) + { + withCallToExtendWhen = crudInfo.ClassSymbol.GetMembers("Aggregate").Any(member => + member is ITypeSymbol typeSymbol && typeSymbol.GetMembers("ExtendWhen").Length > 0); + fileBuilder.WriteAggregateWhenMethodStart(withCallToExtendWhen); + } + else + { + withCallToExtendWhen = crudInfo.ClassSymbol.GetMembers("ReadModel").Any(member => + member is ITypeSymbol typeSymbol && typeSymbol.GetMembers("ExtendWhen").Length > 0); + fileBuilder.WriteReadModelWhenMethodStart(withCallToExtendWhen); + } + + foreach (var property in crudInfo.Properties) + { + fileBuilder.WriteWhenPropertyChanged(crudInfo.Name, property.Name, crudInfo.IdProperty?.Name); + } + + if (crudInfo.IdProperty != null) + { + fileBuilder.WriteWhenCreated(crudInfo.Name, crudInfo.IdProperty.Name, crudInfo.Properties.Select(p => p.Name)); + fileBuilder.WriteWhenDeleted(crudInfo.Name, crudInfo.IdProperty.Name); + } + fileBuilder.WriteWhenMethodEnd(withCallToExtendWhen); + } + + private void WriteIdsReadModel(CrudFileBuilder fileBuilder, CrudInfo crudInfo) + { + if (crudInfo.IdProperty == null) + { + return; + } + + fileBuilder.WriteIdsReadModelStart(GetKeyTypeName(crudInfo.IdProperty)); + fileBuilder.WriteIdsReadModelWhenMethod(crudInfo.Name); + fileBuilder.WriteAggregateOrReadModelEnd(); + } + + private void WriteSelectors(CrudFileBuilder fileBuilder, CrudInfo crudInfo) + { + if (crudInfo.IdProperty != null) + { + fileBuilder.WriteSingleItemSelector(crudInfo.Name, crudInfo.IdProperty.Type.ToFullyQualified(), crudInfo.IdProperty.Name); + fileBuilder.WriteAllItemsSelector(crudInfo.Name, crudInfo.IdProperty.Type.ToFullyQualified()); + } + else + { + fileBuilder.WriteGlobalSelector(crudInfo.Name); + } + } + + private void WriteCommands(CrudFileBuilder fileBuilder, CrudInfo crudInfo) + { + fileBuilder.WriteCommandsClassStart(); + + if (crudInfo.IdProperty != null) + { + var createProperties = crudInfo.Properties.Select(p => (p.Type.ToFullyQualified(), p.Name)).ToList(); + fileBuilder.WriteCommandRecord($"{crudInfo.Name}Create", createProperties); + + // Replace individual change commands with a single Change command + var changeProperties = new List<(string, string)> { (crudInfo.IdProperty.Type.ToFullyQualified(), crudInfo.IdProperty.Name) }; + changeProperties.AddRange(crudInfo.Properties.Select(p => (p.Type.ToFullyQualified(), p.Name))); + fileBuilder.WriteCommandRecord($"{crudInfo.Name}Change", changeProperties); + } + else + { + // For global entities, we only need a single Change command + var changeProperties = crudInfo.Properties.Select(p => (p.Type.ToFullyQualified(), p.Name)).ToList(); + fileBuilder.WriteCommandRecord($"{crudInfo.Name}Change", changeProperties); + } + + fileBuilder.WriteCommandsClassEnd(); + } + + private void WriteEvents(CrudFileBuilder fileBuilder, CrudInfo crudInfo) + { + fileBuilder.WriteEventsClassStart(); + + if (crudInfo.IdProperty != null) + { + var createProperties = crudInfo.AllProperties.Select(p => (p.Type.ToFullyQualified(), p.Name)).ToList(); + fileBuilder.WriteEventRecord($"{crudInfo.Name}Created", createProperties); + + foreach (var property in crudInfo.Properties) + { + fileBuilder.WriteEventRecord($"{crudInfo.Name}{property.Name}Changed", + new List<(string, string)> { (crudInfo.IdProperty.Type.ToFullyQualified(), crudInfo.IdProperty.Name), (property.Type.ToFullyQualified(), property.Name) }); + } + + fileBuilder.WriteEventRecord($"{crudInfo.Name}Deleted", new List<(string, string)> { (crudInfo.IdProperty.Type.ToFullyQualified(), crudInfo.IdProperty.Name) }); + } + else + { + foreach (var property in crudInfo.Properties) + { + fileBuilder.WriteEventRecord($"{crudInfo.Name}{property.Name}Changed", + new List<(string, string)> { (property.Type.ToFullyQualified(), property.Name) }); + } + } + + fileBuilder.WriteCommandsClassEnd(); + } +} \ No newline at end of file diff --git a/src/Fluss.Regen/Generators/RegistrationGenerator.cs b/src/Fluss.Regen/Generators/RegistrationGenerator.cs index 6c1ef75..c88affe 100644 --- a/src/Fluss.Regen/Generators/RegistrationGenerator.cs +++ b/src/Fluss.Regen/Generators/RegistrationGenerator.cs @@ -17,7 +17,7 @@ public void Generate(SourceProductionContext context, Compilation compilation, I return; } - var moduleName = (compilation.AssemblyName ?? "Assembly").Split('.').Last() + "ESComponents"; + var moduleName = (compilation.AssemblyName ?? "Assembly").Split('.').Last() + "ES"; using var generator = new RegistrationFileBuilder(moduleName, "Microsoft.Extensions.DependencyInjection"); @@ -25,8 +25,6 @@ public void Generate(SourceProductionContext context, Compilation compilation, I generator.WriteBeginNamespace(); generator.WriteBeginClass(); - var foundInfo = false; - var aggregateValidators = syntaxInfos.OfType().ToImmutableHashSet(); var eventValidators = syntaxInfos.OfType().ToImmutableHashSet(); if (aggregateValidators.Any() || eventValidators.Any()) @@ -43,7 +41,6 @@ public void Generate(SourceProductionContext context, Compilation compilation, I } generator.WriteEndRegistrationMethod(); - foundInfo = true; } var policies = syntaxInfos.OfType().ToImmutableHashSet(); @@ -55,7 +52,6 @@ public void Generate(SourceProductionContext context, Compilation compilation, I generator.WritePolicyRegistration(policy.Type.ToFullyQualified()); } generator.WriteEndRegistrationMethod(); - foundInfo = true; } var sideEffects = syntaxInfos.OfType().ToImmutableHashSet(); @@ -67,7 +63,6 @@ public void Generate(SourceProductionContext context, Compilation compilation, I generator.WriteSideEffectRegistration(sideEffect.Type.ToFullyQualified()); } generator.WriteEndRegistrationMethod(); - foundInfo = true; } var upcasters = syntaxInfos.OfType().ToImmutableHashSet(); @@ -79,7 +74,6 @@ public void Generate(SourceProductionContext context, Compilation compilation, I generator.WriteUpcasterRegistration(upcaster.Type.ToFullyQualified()); } generator.WriteEndRegistrationMethod(); - foundInfo = true; } generator.WriteBeginRegistrationMethod("Components"); @@ -107,9 +101,6 @@ public void Generate(SourceProductionContext context, Compilation compilation, I generator.WriteEndClass(); generator.WriteEndNamespace(); - if (foundInfo) - { - context.AddSource("Registration.g.cs", generator.ToSourceText()); - } + context.AddSource("Registration.g.cs", generator.ToSourceText()); } } \ No newline at end of file diff --git a/src/Fluss.Regen/Generators/SelectorGenerator.cs b/src/Fluss.Regen/Generators/SelectorGenerator.cs index 2d3752f..b30454a 100644 --- a/src/Fluss.Regen/Generators/SelectorGenerator.cs +++ b/src/Fluss.Regen/Generators/SelectorGenerator.cs @@ -2,6 +2,7 @@ using System.Collections.Immutable; using System.Threading.Tasks; using Fluss.Regen.FileBuilders; +using Fluss.Regen.Helpers; using Fluss.Regen.Inspectors; using Fluss.Regen.Models; using Microsoft.CodeAnalysis; @@ -12,23 +13,11 @@ public class SelectorGenerator : ISyntaxGenerator { public void Generate(SourceProductionContext context, Compilation compilation, ImmutableArray syntaxInfos) { - var selectors = new List(); - - foreach (var syntaxInfo in syntaxInfos) - { - if (syntaxInfo is not SelectorInfo selector) - { - continue; - } - - selectors.Add(selector); - } - using var generator = new SelectorFileBuilder(); generator.WriteHeader(); generator.WriteClassHeader(); - foreach (var selector in selectors) + foreach (var selector in syntaxInfos.OfType()) { var parametersWithoutUnitOfWork = new List(); @@ -46,12 +35,12 @@ public void Generate(SourceProductionContext context, Compilation compilation, I var returnType = ExtractValueType(selector.MethodSymbol.ReturnType); - generator.WriteMethodSignatureStart(selector.Name, returnType, parametersWithoutUnitOfWork.Count == 0); + generator.WriteMethodSignatureStart(selector.Name, returnType.ToFullyQualified(), parametersWithoutUnitOfWork.Count == 0); for (var index = 0; index < parametersWithoutUnitOfWork.Count; index++) { var parameter = parametersWithoutUnitOfWork[index]; - generator.WriteMethodSignatureParameter(parameter.Type, parameter.Name, parametersWithoutUnitOfWork.Count - 1 == index); + generator.WriteMethodSignatureParameter(parameter.Type.ToFullyQualified(), parameter.Name, parametersWithoutUnitOfWork.Count - 1 == index); } generator.WriteMethodSignatureEnd(); @@ -70,7 +59,7 @@ public void Generate(SourceProductionContext context, Compilation compilation, I } generator.WriteKeyEnd(); - generator.WriteMethodCacheHit(returnType); + generator.WriteMethodCacheHit(returnType.ToFullyQualified()); generator.WriteMethodCall(selector.ContainingType, selector.Name, isAsync); for (var index = 0; index < selector.MethodSymbol.Parameters.Length; index++) @@ -89,17 +78,84 @@ public void Generate(SourceProductionContext context, Compilation compilation, I generator.WriteMethodCallEnd(isAsync); - generator.WriteMethodCacheMiss(returnType); + generator.WriteMethodCacheMiss(returnType.ToFullyQualified()); generator.WriteMethodEnd(); } + foreach (var crudInfo in syntaxInfos.OfType()) + { + if (crudInfo.IdProperty != null) + { + // Generate single item selector + var singleSelectorName = $"Get{crudInfo.Name}"; + var idType = crudInfo.IdProperty.Type.ToFullyQualified(); + var idName = crudInfo.IdProperty.Name.ToLowerInvariant(); + + generator.WriteMethodSignatureStart(crudInfo.Name, crudInfo.ClassSymbol.ToFullyQualified() + ".ReadModel", false); + generator.WriteMethodSignatureParameter(idType, idName, true); + generator.WriteMethodSignatureEnd(); + + generator.WriteRecordingUnitOfWork(); + generator.WriteKeyStart(crudInfo.ClassSymbol.ToFullyQualified(), singleSelectorName, false); + generator.WriteKeyParameter(idName, true); + generator.WriteKeyEnd(); + generator.WriteMethodCacheHit(crudInfo.ClassSymbol.ToFullyQualified() + ".ReadModel"); + + generator.WriteMethodCall(crudInfo.ClassSymbol.ToFullyQualified(), singleSelectorName, true); + generator.WriteMethodCallParameter("recordingUnitOfWork", false); + generator.WriteMethodCallParameter(idName, true); + generator.WriteMethodCallEnd(true); + + generator.WriteMethodCacheMiss(crudInfo.ClassSymbol.ToFullyQualified() + ".ReadModel"); + generator.WriteMethodEnd(); + + // Generate all items selector + var allSelectorName = $"GetAll{crudInfo.Name}s"; + + generator.WriteMethodSignatureStart($"All{crudInfo.Name}s", $"global::System.Collections.Generic.IReadOnlyList<{crudInfo.ClassSymbol.ToFullyQualified()}.ReadModel>", true); + generator.WriteMethodSignatureEnd(); + + generator.WriteRecordingUnitOfWork(); + generator.WriteKeyStart(crudInfo.ClassSymbol.ToFullyQualified(), allSelectorName, true); + generator.WriteKeyEnd(); + generator.WriteMethodCacheHit($"global::System.Collections.Generic.IReadOnlyList<{crudInfo.ClassSymbol.ToFullyQualified()}.ReadModel>"); + + generator.WriteMethodCall(crudInfo.ClassSymbol.ToFullyQualified(), allSelectorName, true); + generator.WriteMethodCallParameter("recordingUnitOfWork", true); + generator.WriteMethodCallEnd(true); + + generator.WriteMethodCacheMiss($"global::System.Collections.Generic.IReadOnlyList<{crudInfo.ClassSymbol.ToFullyQualified()}.ReadModel>"); + generator.WriteMethodEnd(); + } + else + { + // Generate global selector + var globalSelectorName = $"Get{crudInfo.Name}"; + + generator.WriteMethodSignatureStart(crudInfo.Name, crudInfo.ClassSymbol.ToFullyQualified() + ".ReadModel", true); + generator.WriteMethodSignatureEnd(); + + generator.WriteRecordingUnitOfWork(); + generator.WriteKeyStart(crudInfo.ClassSymbol.ToFullyQualified(), globalSelectorName, true); + generator.WriteKeyEnd(); + generator.WriteMethodCacheHit(crudInfo.ClassSymbol.ToFullyQualified() + ".ReadModel"); + + generator.WriteMethodCall(crudInfo.ClassSymbol.ToFullyQualified(), globalSelectorName, true); + generator.WriteMethodCallParameter("recordingUnitOfWork", true); + generator.WriteMethodCallEnd(true); + + generator.WriteMethodCacheMiss(crudInfo.ClassSymbol.ToFullyQualified() + ".ReadModel"); + generator.WriteMethodEnd(); + } + } + generator.WriteEndNamespace(); context.AddSource("Selectors.g.cs", generator.ToSourceText()); } - - + + private static ITypeSymbol ExtractValueType(ITypeSymbol returnType) { if (returnType is INamedTypeSymbol namedTypeSymbol && (ToTypeNameNoGenerics(returnType) == typeof(ValueTask).FullName || diff --git a/src/Fluss.Regen/Helpers/CodeWriter.cs b/src/Fluss.Regen/Helpers/CodeWriter.cs index 858ba12..d66c0a4 100644 --- a/src/Fluss.Regen/Helpers/CodeWriter.cs +++ b/src/Fluss.Regen/Helpers/CodeWriter.cs @@ -121,6 +121,12 @@ protected override void Dispose(bool disposing) } } + internal CommaSeparatedWriter CommaSeparatedIndented() + { + return new CommaSeparatedWriter(this); + } + + private sealed class Block : IDisposable { private readonly Action _decrease; @@ -132,4 +138,32 @@ public Block(Action close) public void Dispose() => _decrease(); } -} \ No newline at end of file + + public sealed class CommaSeparatedWriter : IDisposable + { + private readonly CodeWriter _writer; + private bool _first = true; + public CommaSeparatedWriter(CodeWriter writer) + { + _writer = writer; + _writer.IncreaseIndent(); + } + + public void Write(string value) + { + if (!_first) + { + _writer.Write(","); + _writer.WriteLine(); + } + _first = false; + _writer.WriteIndented(value); + } + + public void Dispose() + { + _writer.DecreaseIndent(); + _writer.WriteLine(); + } + } +} diff --git a/src/Fluss.Regen/Inspectors/CrudInspector.cs b/src/Fluss.Regen/Inspectors/CrudInspector.cs new file mode 100644 index 0000000..2176bcb --- /dev/null +++ b/src/Fluss.Regen/Inspectors/CrudInspector.cs @@ -0,0 +1,258 @@ +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Collections.Generic; +using Fluss.Regen.Attributes; +using Fluss.Regen.Helpers; +using Fluss.Regen.Models; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Fluss.Regen.Inspectors; + +public sealed class CrudInspector : ISyntaxInspector +{ + private static readonly DiagnosticDescriptor ClassMustBePartial = new( + "FLUSS0001", + "Class must be partial", + "Class '{0}' must be partial", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + private static readonly DiagnosticDescriptor IdPropertyTypeMustBeSupported = new( + "FLUSS0002", + "ID property type must be supported", + "The ID property '{0}' must be of type Guid or a struct that could be a strongly-typed ID", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + private static readonly DiagnosticDescriptor DuplicatePropertyName = new( + "FLUSS0003", + "Duplicate property name", + "Duplicate property name '{0}' found in CRUD class '{1}'", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + private static readonly DiagnosticDescriptor ReservedPropertyName = new( + "FLUSS0004", + "Reserved property name", + "The property name 'Exists' is reserved for internal use in CRUD classes", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + private static readonly DiagnosticDescriptor NamespaceMissing = new( + "FLUSS0005", + "Namespace missing", + "CRUD classes must be defined within a namespace", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + private static readonly DiagnosticDescriptor UnsupportedPropertyType = new( + "FLUSS0006", + "Unsupported property type", + "Property '{0}' has an unsupported type '{1}' for CRUD operations", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + private static readonly DiagnosticDescriptor NamingConflict = new( + "FLUSS0007", + "Naming conflict", + "The name '{0}' conflicts with a generated command or event name", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + private static readonly DiagnosticDescriptor InvalidInheritance = new( + "FLUSS0008", + "Invalid inheritance", + "CRUD classes should not inherit from other classes as they will inherit from AggregateRoot", + "Fluss.Regen", + DiagnosticSeverity.Error, + true + ); + + public bool TryHandle( + GeneratorSyntaxContext context, + [NotNullWhen(true)] out SyntaxInfo? syntaxInfo) + { + if (context.Node is ClassDeclarationSyntax classSyntax) + { + var symbol = ModelExtensions.GetDeclaredSymbol(context.SemanticModel, classSyntax); + if (symbol is INamedTypeSymbol classSymbol && + classSymbol.GetAttributes().Any(i => i.AttributeClass?.ToFullyQualified() == "global::" + CrudAttribute.FullName)) + { + var crudInfo = new CrudInfo(classSymbol, classSyntax); + syntaxInfo = crudInfo; + + CheckIfClassIsPartial(crudInfo, classSyntax, classSymbol); + CheckIdPropertyType(crudInfo, classSymbol); + CheckPropertyUniqueness(crudInfo, classSymbol); + CheckReservedPropertyNames(crudInfo, classSymbol); + CheckNamespace(crudInfo, classSymbol); + CheckPropertyTypes(crudInfo, classSymbol); + CheckNamingConflicts(crudInfo, classSymbol); + CheckInheritance(crudInfo, classSymbol); + + return true; + } + } + + syntaxInfo = null; + return false; + } + + private void CheckIfClassIsPartial(CrudInfo syntaxInfo, ClassDeclarationSyntax classSyntax, INamedTypeSymbol classSymbol) + { + if (!classSyntax.Modifiers.Any(i => i.IsKind(SyntaxKind.PartialKeyword))) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + ClassMustBePartial, + classSyntax.GetLocation(), + classSymbol.Name + ) + ); + } + } + + private void CheckIdPropertyType(CrudInfo syntaxInfo, INamedTypeSymbol classSymbol) + { + var idProperty = classSymbol.GetMembers().OfType().FirstOrDefault(p => p.Name == "Id"); + if (idProperty != null) + { + var idType = idProperty.Type; + if (idType.ToFullyQualified() != "global::System.Guid" && idType.TypeKind != TypeKind.Struct) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + IdPropertyTypeMustBeSupported, + idProperty.Locations.FirstOrDefault(), + idProperty.Name + ) + ); + } + } + } + + private void CheckPropertyUniqueness(CrudInfo syntaxInfo, INamedTypeSymbol classSymbol) + { + var propertyNames = new HashSet(); + foreach (var member in classSymbol.GetMembers().OfType()) + { + if (!propertyNames.Add(member.Name)) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + DuplicatePropertyName, + member.Locations.FirstOrDefault(), + member.Name, + classSymbol.Name + ) + ); + } + } + } + + private void CheckReservedPropertyNames(CrudInfo syntaxInfo, INamedTypeSymbol classSymbol) + { + var existsProperty = classSymbol.GetMembers().OfType().FirstOrDefault(p => p.Name == "Exists"); + if (existsProperty != null) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + ReservedPropertyName, + existsProperty.Locations.FirstOrDefault() + ) + ); + } + } + + private void CheckNamespace(CrudInfo syntaxInfo, INamedTypeSymbol classSymbol) + { + if (classSymbol.ContainingNamespace.IsGlobalNamespace) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + NamespaceMissing, + classSymbol.Locations.FirstOrDefault() + ) + ); + } + } + + private void CheckPropertyTypes(CrudInfo syntaxInfo, INamedTypeSymbol classSymbol) + { + foreach (var property in classSymbol.GetMembers().OfType()) + { + if (!IsSupportedType(property.Type)) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + UnsupportedPropertyType, + property.Locations.FirstOrDefault(), + property.Name, + property.Type.ToDisplayString() + ) + ); + } + } + } + + private bool IsSupportedType(ITypeSymbol type) + { + return type.IsValueType || type.SpecialType == SpecialType.System_String; + } + + private void CheckNamingConflicts(CrudInfo syntaxInfo, INamedTypeSymbol classSymbol) + { + var reservedNames = new[] + { + $"{classSymbol.Name}Create", + $"{classSymbol.Name}Change", + $"{classSymbol.Name}Delete", + $"{classSymbol.Name}Created", + $"{classSymbol.Name}Changed", + $"{classSymbol.Name}Deleted" + }; + + foreach (var member in classSymbol.GetMembers()) + { + if (reservedNames.Contains(member.Name)) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + NamingConflict, + member.Locations.FirstOrDefault(), + member.Name + ) + ); + } + } + } + + private void CheckInheritance(CrudInfo syntaxInfo, INamedTypeSymbol classSymbol) + { + if (classSymbol.BaseType != null && classSymbol.BaseType.SpecialType != SpecialType.System_Object) + { + syntaxInfo.AddDiagnostic( + Diagnostic.Create( + InvalidInheritance, + classSymbol.Locations.FirstOrDefault() + ) + ); + } + } +} \ No newline at end of file diff --git a/src/Fluss.Regen/Models/CrudInfo.cs b/src/Fluss.Regen/Models/CrudInfo.cs new file mode 100644 index 0000000..60570cd --- /dev/null +++ b/src/Fluss.Regen/Models/CrudInfo.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Immutable; +using System.Linq; +using Fluss.Regen.Inspectors; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Fluss.Regen.Models; + +public sealed class CrudInfo : SyntaxInfo +{ + public INamedTypeSymbol ClassSymbol { get; } + private ClassDeclarationSyntax ClassSyntax { get; } + public string Name { get; } + public string Namespace { get; } + + public readonly ImmutableArray AllProperties; + + public readonly IPropertySymbol? IdProperty; + + public readonly ImmutableArray Properties; + + public CrudInfo(INamedTypeSymbol classSymbol, + ClassDeclarationSyntax classSyntax) + { + ClassSymbol = classSymbol; + ClassSyntax = classSyntax; + Name = classSymbol.Name; + Namespace = classSymbol.ContainingNamespace.ToDisplayString(); + + var allProperties = classSymbol.GetMembers().OfType().ToImmutableArray(); + + AllProperties = allProperties; + IdProperty = allProperties.FirstOrDefault(m => m.Name == "Id"); + Properties = [.. allProperties.Where(m => m.Name != "Id")]; + } + + public bool Equals(CrudInfo? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return ClassSyntax.Equals(other.ClassSyntax); + } + + public override bool Equals(SyntaxInfo other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return other is CrudInfo info && Equals(info); + } + + public override bool Equals(object? obj) + { + return ReferenceEquals(this, obj) + || obj is CrudInfo other && Equals(other); + } + + public override int GetHashCode() + { + return ClassSyntax.GetHashCode(); + } +} \ No newline at end of file diff --git a/src/Fluss.Regen/RepetitiveEventsourcingCodeGenerator.cs b/src/Fluss.Regen/RepetitiveEventsourcingCodeGenerator.cs index 1dc1644..d47cd77 100644 --- a/src/Fluss.Regen/RepetitiveEventsourcingCodeGenerator.cs +++ b/src/Fluss.Regen/RepetitiveEventsourcingCodeGenerator.cs @@ -25,30 +25,39 @@ public class RepetitiveEventsourcingCodeGenerator : IIncrementalGenerator new SelectorInspector(), new SideEffectInspector(), new UpcasterInspector(), + new CrudInspector(), ]; private static readonly ISyntaxGenerator[] Generators = [ new SelectorGenerator(), - new RegistrationGenerator() + new RegistrationGenerator(), + new CrudGenerator() ]; - + private static readonly IRegenAttribute[] Attributes = [ - new SelectorAttribute() + new SelectorAttribute(), + new CrudAttribute() ]; public void Initialize(IncrementalGeneratorInitializationContext context) { context.RegisterPostInitializationOutput(ctx => { + var sb = StringBuilderPool.Get(); + + sb.AppendLine("// "); + foreach (var attribute in Attributes) { - ctx.AddSource( - attribute.FileName, - SourceText.From(attribute.SourceCode, Encoding.UTF8) - ); + sb.AppendLine(); + sb.AppendLine(attribute.SourceCode); } + + ctx.AddSource("Attributes.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8)); + + StringBuilderPool.Return(sb); }); var syntaxInfos = context.SyntaxProvider diff --git a/src/Fluss.UnitTest/Core/UnitOfWork/UnitOfWorkTest.cs b/src/Fluss.UnitTest/Core/UnitOfWork/UnitOfWorkTest.cs index 725745b..d43f7e7 100644 --- a/src/Fluss.UnitTest/Core/UnitOfWork/UnitOfWorkTest.cs +++ b/src/Fluss.UnitTest/Core/UnitOfWork/UnitOfWorkTest.cs @@ -177,6 +177,7 @@ public async Task CanGetReadModelByType() var readModel = await unitOfWork.GetReadModel(typeof(TestReadModel), 1); Assert.IsType(readModel); + Assert.Equal(2, ((TestReadModel)readModel).GotEvents); } [Fact] diff --git a/src/Fluss.UnitTest/Fluss.UnitTest.csproj b/src/Fluss.UnitTest/Fluss.UnitTest.csproj index cd88321..5f97bcd 100644 --- a/src/Fluss.UnitTest/Fluss.UnitTest.csproj +++ b/src/Fluss.UnitTest/Fluss.UnitTest.csproj @@ -35,8 +35,4 @@ - - - - diff --git a/src/Fluss.UnitTest/Regen/CrudTests.cs b/src/Fluss.UnitTest/Regen/CrudTests.cs new file mode 100644 index 0000000..75680f9 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/CrudTests.cs @@ -0,0 +1,228 @@ +namespace Fluss.UnitTest.Regen; + +public class CrudTests +{ + [Fact] + public Task GeneratesForSimpleCase() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud { + public int Test { get; set; } + public int Test2 { get; set; } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task GeneratesForSimpleCaseWithId() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud { + public int Id { get; set; } + public int Test { get; set; } = 23; + public int Test2 { get; set; } = 42; + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task GeneratesCallToGivenAggregateExtendWhen() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud + { + public global::System.Guid Id { get; set; } + + public partial record Aggregate : AggregateRoot + { + public Aggregate ExtendWhen(EventEnvelope envelope) + { + return this; + } + } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenClassIsNotPartial() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public class TestCrud { + public int Id { get; set; } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenIdPropertyTypeIsNotSupported() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud { + public string Id { get; set; } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenDuplicatePropertyName() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud { + public int Test { get; set; } + public string Test { get; set; } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenReservedPropertyName() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud { + public bool Exists { get; set; } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenNamespaceMissing() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + [Crud] + public partial class TestCrud { + public int Id { get; set; } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenUnsupportedPropertyType() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + using System.Collections.Generic; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud { + public List Test { get; set; } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenNamingConflict() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + [Crud] + public partial class TestCrud { + public int Id { get; set; } + public void TestCrudCreate() { } + } + """ + ); + + return Verify(runResult); + } + + [Fact] + public Task DiagnosticWhenInvalidInheritance() + { + var runResult = RegenTests.GenerateFor( + """ + using Fluss.Regen; + + namespace TestNamespace; + + public class BaseClass { } + + [Crud] + public partial class TestCrud : BaseClass { + public int Id { get; set; } + } + """ + ); + + return Verify(runResult); + } +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/RegenTests.cs b/src/Fluss.UnitTest/Regen/RegenTests.cs index 48522d9..5465e55 100644 --- a/src/Fluss.UnitTest/Regen/RegenTests.cs +++ b/src/Fluss.UnitTest/Regen/RegenTests.cs @@ -12,7 +12,6 @@ public Task GeneratesForAsyncSelector() { var runResult = GenerateFor( """ - using Fluss.Regen; using System.Threading.Tasks; @@ -195,7 +194,26 @@ public class TestUpcaster : IUpcaster { return Verify(runResult); } - private GeneratorDriverRunResult GenerateFor(string source) + [Fact] + public Task GeneratesNothingForUninterestingClasses() + { + var runResult = GenerateFor( + """ + using Fluss; + using Fluss.Upcasting; + + namespace TestNamespace; + + public class Uninteresting { + + } + """ + ); + + return Verify(runResult); + } + + public static GeneratorDriverRunResult GenerateFor(string source) { var generator = new RepetitiveEventsourcingCodeGenerator(); diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0.verified.txt new file mode 100644 index 0000000..b5a007a --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0001, + Title: Class must be partial, + Severity: Error, + WarningLevel: 0, + Location: : (4,0)-(6,1), + MessageFormat: Class '{0}' must be partial, + Message: Class 'TestCrud' must be partial, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0.verified.txt new file mode 100644 index 0000000..b5a007a --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.AddsDiagnosticIfClassIsNotPartial.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0001, + Title: Class must be partial, + Severity: Error, + WarningLevel: 0, + Location: : (4,0)-(6,1), + MessageFormat: Class '{0}' must be partial, + Message: Class 'TestCrud' must be partial, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0.verified.txt new file mode 100644 index 0000000..f517cfa --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0001, + Title: Class must be partial, + Severity: Error, + WarningLevel: 0, + Location: : (4,0)-(7,1), + MessageFormat: Class '{0}' must be partial, + Message: Class 'TestCrud' must be partial, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0.verified.txt new file mode 100644 index 0000000..f517cfa --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenClassIsNotPartial.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0001, + Title: Class must be partial, + Severity: Error, + WarningLevel: 0, + Location: : (4,0)-(7,1), + MessageFormat: Class '{0}' must be partial, + Message: Class 'TestCrud' must be partial, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0.verified.txt new file mode 100644 index 0000000..a14e1d6 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0003, + Title: Duplicate property name, + Severity: Error, + WarningLevel: 0, + Location: : (7,18)-(7,22), + MessageFormat: Duplicate property name '{0}' found in CRUD class '{1}', + Message: Duplicate property name 'Test' found in CRUD class 'TestCrud', + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0.verified.txt new file mode 100644 index 0000000..a14e1d6 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenDuplicatePropertyName.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0003, + Title: Duplicate property name, + Severity: Error, + WarningLevel: 0, + Location: : (7,18)-(7,22), + MessageFormat: Duplicate property name '{0}' found in CRUD class '{1}', + Message: Duplicate property name 'Test' found in CRUD class 'TestCrud', + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..460f03b --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + string id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0.verified.txt new file mode 100644 index 0000000..2aa3e3b --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0002, + Title: ID property type must be supported, + Severity: Error, + WarningLevel: 0, + Location: : (6,18)-(6,20), + MessageFormat: The ID property '{0}' must be of type Guid or a struct that could be a strongly-typed ID, + Message: The ID property 'Id' must be of type Guid or a struct that could be a strongly-typed ID, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..460f03b --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + string id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0.verified.txt new file mode 100644 index 0000000..2aa3e3b --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenIdPropertyTypeIsNotSupported.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0002, + Title: ID property type must be supported, + Severity: Error, + WarningLevel: 0, + Location: : (6,18)-(6,20), + MessageFormat: The ID property '{0}' must be of type Guid or a struct that could be a strongly-typed ID, + Message: The ID property 'Id' must be of type Guid or a struct that could be a strongly-typed ID, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0.verified.txt new file mode 100644 index 0000000..95c1367 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0008, + Title: Invalid inheritance, + Severity: Error, + WarningLevel: 0, + Location: : (7,21)-(7,29), + MessageFormat: CRUD classes should not inherit from other classes as they will inherit from AggregateRoot, + Message: CRUD classes should not inherit from other classes as they will inherit from AggregateRoot, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0.verified.txt new file mode 100644 index 0000000..95c1367 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenInvalidInheritance.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0008, + Title: Invalid inheritance, + Severity: Error, + WarningLevel: 0, + Location: : (7,21)-(7,29), + MessageFormat: CRUD classes should not inherit from other classes as they will inherit from AggregateRoot, + Message: CRUD classes should not inherit from other classes as they will inherit from AggregateRoot, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f30a604 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0.verified.txt new file mode 100644 index 0000000..9009d44 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0005, + Title: Namespace missing, + Severity: Error, + WarningLevel: 0, + Location: : (3,21)-(3,29), + MessageFormat: CRUD classes must be defined within a namespace, + Message: CRUD classes must be defined within a namespace, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f30a604 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0.verified.txt new file mode 100644 index 0000000..9009d44 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamespaceMissing.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0005, + Title: Namespace missing, + Severity: Error, + WarningLevel: 0, + Location: : (3,21)-(3,29), + MessageFormat: CRUD classes must be defined within a namespace, + Message: CRUD classes must be defined within a namespace, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0.verified.txt new file mode 100644 index 0000000..38e9ef4 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0007, + Title: Naming conflict, + Severity: Error, + WarningLevel: 0, + Location: : (7,16)-(7,30), + MessageFormat: The name '{0}' conflicts with a generated command or event name, + Message: The name 'TestCrudCreate' conflicts with a generated command or event name, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0.verified.txt new file mode 100644 index 0000000..38e9ef4 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenNamingConflict.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0007, + Title: Naming conflict, + Severity: Error, + WarningLevel: 0, + Location: : (7,16)-(7,30), + MessageFormat: The name '{0}' conflicts with a generated command or event name, + Message: The name 'TestCrudCreate' conflicts with a generated command or event name, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0.verified.txt new file mode 100644 index 0000000..4092b9d --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0004, + Title: Reserved property name, + Severity: Error, + WarningLevel: 0, + Location: : (6,16)-(6,22), + MessageFormat: The property name 'Exists' is reserved for internal use in CRUD classes, + Message: The property name 'Exists' is reserved for internal use in CRUD classes, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0.verified.txt new file mode 100644 index 0000000..4092b9d --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenReservedPropertyName.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0004, + Title: Reserved property name, + Severity: Error, + WarningLevel: 0, + Location: : (6,16)-(6,22), + MessageFormat: The property name 'Exists' is reserved for internal use in CRUD classes, + Message: The property name 'Exists' is reserved for internal use in CRUD classes, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0.verified.txt new file mode 100644 index 0000000..bf8ac28 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet8_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0006, + Title: Unsupported property type, + Severity: Error, + WarningLevel: 0, + Location: : (7,21)-(7,25), + MessageFormat: Property '{0}' has an unsupported type '{1}' for CRUD operations, + Message: Property 'Test' has an unsupported type 'System.Collections.Generic.List' for CRUD operations, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0.verified.txt b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0.verified.txt new file mode 100644 index 0000000..bf8ac28 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.DiagnosticWhenUnsupportedPropertyType.DotNet9_0.verified.txt @@ -0,0 +1,14 @@ +{ + Diagnostics: [ + { + Id: FLUSS0006, + Title: Unsupported property type, + Severity: Error, + WarningLevel: 0, + Location: : (7,21)-(7,25), + MessageFormat: Property '{0}' has an unsupported type '{1}' for CRUD operations, + Message: Property 'Test' has an unsupported type 'System.Collections.Generic.List' for CRUD operations, + Category: Fluss.Regen + } + ] +} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..24eb619 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,108 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace TestNamespace +{ + public partial class TestCrud + { + public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot + { + + public static async global::System.Threading.Tasks.Task Create(global::Fluss.IWriteUnitOfWork unitOfWork, Commands.TestCrudCreate command) + { + var id = global::System.Guid.NewGuid(); + var aggregate = await unitOfWork.GetAggregate(id); + await aggregate.Apply(new Events.TestCrudCreated( + id + )); + return aggregate; + } + + public async global::System.Threading.Tasks.Task Change(Commands.TestCrudChange command) + { + } + + protected override Aggregate When(global::Fluss.Events.EventEnvelope envelope) + { + return (envelope.Event switch + { + Events.TestCrudCreated created when created.Id == Id => this with { + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }).ExtendWhen(envelope); + } + } + + public partial record ReadModel : global::Fluss.ReadModel.ReadModelWithKey + { + public bool Exists { get; init; } + + protected override ReadModel When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudCreated created when created.Id == Id => this with { + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }; + } + } + + public partial record AllIds : global::Fluss.ReadModel.RootReadModel + { + public global::System.Collections.Immutable.ImmutableHashSet Ids { get; init; } = global::System.Collections.Immutable.ImmutableHashSet.Empty; + + protected override AllIds When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudCreated created => this with { Ids = Ids.Add(created.Id) }, + Events.TestCrudDeleted deleted => this with { Ids = Ids.Remove(deleted.Id) }, + _ => this + }; + } + } + + [global::Fluss.Regen.Selector] + public static global::System.Threading.Tasks.ValueTask GetTestCrud(global::Fluss.IUnitOfWork unitOfWork, global::System.Guid id) + { + return unitOfWork.GetReadModel(id); + } + + [global::Fluss.Regen.Selector] + public static async global::System.Threading.Tasks.ValueTask> GetAllTestCruds(global::Fluss.IUnitOfWork unitOfWork) + { + var allIds = await unitOfWork.GetReadModel(); + return await unitOfWork.GetMultipleReadModels(allIds.Ids); + } + + public static partial class Commands + { + public record TestCrudCreate( + + ); + public record TestCrudChange( + global::System.Guid Id + ); + } + + public static partial class Events + { + public record TestCrudCreated( + global::System.Guid Id + ) : global::Fluss.Events.Event; + public record TestCrudDeleted( + global::System.Guid Id + ) : global::Fluss.Events.Event; + } +} +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8716dce --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + global::System.Guid id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..24eb619 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,108 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace TestNamespace +{ + public partial class TestCrud + { + public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot + { + + public static async global::System.Threading.Tasks.Task Create(global::Fluss.IWriteUnitOfWork unitOfWork, Commands.TestCrudCreate command) + { + var id = global::System.Guid.NewGuid(); + var aggregate = await unitOfWork.GetAggregate(id); + await aggregate.Apply(new Events.TestCrudCreated( + id + )); + return aggregate; + } + + public async global::System.Threading.Tasks.Task Change(Commands.TestCrudChange command) + { + } + + protected override Aggregate When(global::Fluss.Events.EventEnvelope envelope) + { + return (envelope.Event switch + { + Events.TestCrudCreated created when created.Id == Id => this with { + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }).ExtendWhen(envelope); + } + } + + public partial record ReadModel : global::Fluss.ReadModel.ReadModelWithKey + { + public bool Exists { get; init; } + + protected override ReadModel When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudCreated created when created.Id == Id => this with { + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }; + } + } + + public partial record AllIds : global::Fluss.ReadModel.RootReadModel + { + public global::System.Collections.Immutable.ImmutableHashSet Ids { get; init; } = global::System.Collections.Immutable.ImmutableHashSet.Empty; + + protected override AllIds When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudCreated created => this with { Ids = Ids.Add(created.Id) }, + Events.TestCrudDeleted deleted => this with { Ids = Ids.Remove(deleted.Id) }, + _ => this + }; + } + } + + [global::Fluss.Regen.Selector] + public static global::System.Threading.Tasks.ValueTask GetTestCrud(global::Fluss.IUnitOfWork unitOfWork, global::System.Guid id) + { + return unitOfWork.GetReadModel(id); + } + + [global::Fluss.Regen.Selector] + public static async global::System.Threading.Tasks.ValueTask> GetAllTestCruds(global::Fluss.IUnitOfWork unitOfWork) + { + var allIds = await unitOfWork.GetReadModel(); + return await unitOfWork.GetMultipleReadModels(allIds.Ids); + } + + public static partial class Commands + { + public record TestCrudCreate( + + ); + public record TestCrudChange( + global::System.Guid Id + ); + } + + public static partial class Events + { + public record TestCrudCreated( + global::System.Guid Id + ) : global::Fluss.Events.Event; + public record TestCrudDeleted( + global::System.Guid Id + ) : global::Fluss.Events.Event; + } +} +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8716dce --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesCallToGivenAggregateExtendWhen.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + global::System.Guid id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..09c8280 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,81 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace TestNamespace +{ + public partial class TestCrud + { + public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot + { + public int Test { get; init; } + public int Test2 { get; init; } + + public async global::System.Threading.Tasks.Task Change(Commands.TestCrudChange command) + { + if (this.Test != command.Test) + { + await Apply(new Events.TestCrudTestChanged(command.Test)); + } + if (this.Test2 != command.Test2) + { + await Apply(new Events.TestCrudTest2Changed(command.Test2)); + } + } + + protected override Aggregate When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed => this with { Test2 = testCrudTest2Changed.Test2 }, + _ => this, + }; + } + } + + public partial record ReadModel : global::Fluss.ReadModel.RootReadModel + { + public int Test { get; init; } + public int Test2 { get; init; } + + protected override ReadModel When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed => this with { Test2 = testCrudTest2Changed.Test2 }, + _ => this, + }; + } + } + + [global::Fluss.Regen.Selector] + public static global::System.Threading.Tasks.ValueTask GetTestCrud(global::Fluss.IUnitOfWork unitOfWork) + { + return unitOfWork.GetReadModel(); + } + + public static partial class Commands + { + public record TestCrudChange( + int Test, + int Test2 + ); + } + + public static partial class Events + { + public record TestCrudTestChanged( + int Test + ) : global::Fluss.Events.Event; + public record TestCrudTest2Changed( + int Test2 + ) : global::Fluss.Events.Event; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..09c8280 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,81 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace TestNamespace +{ + public partial class TestCrud + { + public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot + { + public int Test { get; init; } + public int Test2 { get; init; } + + public async global::System.Threading.Tasks.Task Change(Commands.TestCrudChange command) + { + if (this.Test != command.Test) + { + await Apply(new Events.TestCrudTestChanged(command.Test)); + } + if (this.Test2 != command.Test2) + { + await Apply(new Events.TestCrudTest2Changed(command.Test2)); + } + } + + protected override Aggregate When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed => this with { Test2 = testCrudTest2Changed.Test2 }, + _ => this, + }; + } + } + + public partial record ReadModel : global::Fluss.ReadModel.RootReadModel + { + public int Test { get; init; } + public int Test2 { get; init; } + + protected override ReadModel When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed => this with { Test2 = testCrudTest2Changed.Test2 }, + _ => this, + }; + } + } + + [global::Fluss.Regen.Selector] + public static global::System.Threading.Tasks.ValueTask GetTestCrud(global::Fluss.IUnitOfWork unitOfWork) + { + return unitOfWork.GetReadModel(); + } + + public static partial class Commands + { + public record TestCrudChange( + int Test, + int Test2 + ); + } + + public static partial class Events + { + public record TestCrudTestChanged( + int Test + ) : global::Fluss.Events.Event; + public record TestCrudTest2Changed( + int Test2 + ) : global::Fluss.Events.Event; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..8a91310 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCase.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,50 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..f04bd15 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,143 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace TestNamespace +{ + public partial class TestCrud + { + public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot + { + public int Test { get; init; } = 23; + public int Test2 { get; init; } = 42; + + public static async global::System.Threading.Tasks.Task Create(global::Fluss.IWriteUnitOfWork unitOfWork, Commands.TestCrudCreate command) + { + var id = new int(global::System.Guid.NewGuid()); + var aggregate = await unitOfWork.GetAggregate(id); + await aggregate.Apply(new Events.TestCrudCreated( + id, + command.Test, + command.Test2 + )); + return aggregate; + } + + public async global::System.Threading.Tasks.Task Change(Commands.TestCrudChange command) + { + if (this.Test != command.Test) + { + await Apply(new Events.TestCrudTestChanged(Id, command.Test)); + } + if (this.Test2 != command.Test2) + { + await Apply(new Events.TestCrudTest2Changed(Id, command.Test2)); + } + } + + protected override Aggregate When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged when testCrudTestChanged.Id == Id => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed when testCrudTest2Changed.Id == Id => this with { Test2 = testCrudTest2Changed.Test2 }, + Events.TestCrudCreated created when created.Id == Id => this with { + Test = created.Test, + Test2 = created.Test2, + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }; + } + } + + public partial record ReadModel : global::Fluss.ReadModel.ReadModelWithKey + { + public int Test { get; init; } = 23; + public int Test2 { get; init; } = 42; + public bool Exists { get; init; } + + protected override ReadModel When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged when testCrudTestChanged.Id == Id => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed when testCrudTest2Changed.Id == Id => this with { Test2 = testCrudTest2Changed.Test2 }, + Events.TestCrudCreated created when created.Id == Id => this with { + Test = created.Test, + Test2 = created.Test2, + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }; + } + } + + public partial record AllIds : global::Fluss.ReadModel.RootReadModel + { + public global::System.Collections.Immutable.ImmutableHashSet Ids { get; init; } = global::System.Collections.Immutable.ImmutableHashSet.Empty; + + protected override AllIds When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudCreated created => this with { Ids = Ids.Add(created.Id) }, + Events.TestCrudDeleted deleted => this with { Ids = Ids.Remove(deleted.Id) }, + _ => this + }; + } + } + + [global::Fluss.Regen.Selector] + public static global::System.Threading.Tasks.ValueTask GetTestCrud(global::Fluss.IUnitOfWork unitOfWork, int id) + { + return unitOfWork.GetReadModel(id); + } + + [global::Fluss.Regen.Selector] + public static async global::System.Threading.Tasks.ValueTask> GetAllTestCruds(global::Fluss.IUnitOfWork unitOfWork) + { + var allIds = await unitOfWork.GetReadModel(); + return await unitOfWork.GetMultipleReadModels(allIds.Ids); + } + + public static partial class Commands + { + public record TestCrudCreate( + int Test, + int Test2 + ); + public record TestCrudChange( + int Id, + int Test, + int Test2 + ); + } + + public static partial class Events + { + public record TestCrudCreated( + int Id, + int Test, + int Test2 + ) : global::Fluss.Events.Event; + public record TestCrudTestChanged( + int Id, + int Test + ) : global::Fluss.Events.Event; + public record TestCrudTest2Changed( + int Id, + int Test2 + ) : global::Fluss.Events.Event; + public record TestCrudDeleted( + int Id + ) : global::Fluss.Events.Event; + } +} +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..f04bd15 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,143 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace TestNamespace +{ + public partial class TestCrud + { + public partial record Aggregate : global::Fluss.Aggregates.AggregateRoot + { + public int Test { get; init; } = 23; + public int Test2 { get; init; } = 42; + + public static async global::System.Threading.Tasks.Task Create(global::Fluss.IWriteUnitOfWork unitOfWork, Commands.TestCrudCreate command) + { + var id = new int(global::System.Guid.NewGuid()); + var aggregate = await unitOfWork.GetAggregate(id); + await aggregate.Apply(new Events.TestCrudCreated( + id, + command.Test, + command.Test2 + )); + return aggregate; + } + + public async global::System.Threading.Tasks.Task Change(Commands.TestCrudChange command) + { + if (this.Test != command.Test) + { + await Apply(new Events.TestCrudTestChanged(Id, command.Test)); + } + if (this.Test2 != command.Test2) + { + await Apply(new Events.TestCrudTest2Changed(Id, command.Test2)); + } + } + + protected override Aggregate When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged when testCrudTestChanged.Id == Id => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed when testCrudTest2Changed.Id == Id => this with { Test2 = testCrudTest2Changed.Test2 }, + Events.TestCrudCreated created when created.Id == Id => this with { + Test = created.Test, + Test2 = created.Test2, + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }; + } + } + + public partial record ReadModel : global::Fluss.ReadModel.ReadModelWithKey + { + public int Test { get; init; } = 23; + public int Test2 { get; init; } = 42; + public bool Exists { get; init; } + + protected override ReadModel When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudTestChanged testCrudTestChanged when testCrudTestChanged.Id == Id => this with { Test = testCrudTestChanged.Test }, + Events.TestCrudTest2Changed testCrudTest2Changed when testCrudTest2Changed.Id == Id => this with { Test2 = testCrudTest2Changed.Test2 }, + Events.TestCrudCreated created when created.Id == Id => this with { + Test = created.Test, + Test2 = created.Test2, + Exists = true + }, + Events.TestCrudDeleted deleted when deleted.Id == Id => this with { Exists = false }, + _ => this, + }; + } + } + + public partial record AllIds : global::Fluss.ReadModel.RootReadModel + { + public global::System.Collections.Immutable.ImmutableHashSet Ids { get; init; } = global::System.Collections.Immutable.ImmutableHashSet.Empty; + + protected override AllIds When(global::Fluss.Events.EventEnvelope envelope) + { + return envelope.Event switch + { + Events.TestCrudCreated created => this with { Ids = Ids.Add(created.Id) }, + Events.TestCrudDeleted deleted => this with { Ids = Ids.Remove(deleted.Id) }, + _ => this + }; + } + } + + [global::Fluss.Regen.Selector] + public static global::System.Threading.Tasks.ValueTask GetTestCrud(global::Fluss.IUnitOfWork unitOfWork, int id) + { + return unitOfWork.GetReadModel(id); + } + + [global::Fluss.Regen.Selector] + public static async global::System.Threading.Tasks.ValueTask> GetAllTestCruds(global::Fluss.IUnitOfWork unitOfWork) + { + var allIds = await unitOfWork.GetReadModel(); + return await unitOfWork.GetMultipleReadModels(allIds.Ids); + } + + public static partial class Commands + { + public record TestCrudCreate( + int Test, + int Test2 + ); + public record TestCrudChange( + int Id, + int Test, + int Test2 + ); + } + + public static partial class Events + { + public record TestCrudCreated( + int Id, + int Test, + int Test2 + ) : global::Fluss.Events.Event; + public record TestCrudTestChanged( + int Id, + int Test + ) : global::Fluss.Events.Event; + public record TestCrudTest2Changed( + int Id, + int Test2 + ) : global::Fluss.Events.Event; + public record TestCrudDeleted( + int Id + ) : global::Fluss.Events.Event; + } +} +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..f1e14a5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/CrudTests.GeneratesForSimpleCaseWithId.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,77 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + + public static async global::System.Threading.Tasks.ValueTask SelectTestCrud(this global::Fluss.IUnitOfWork unitOfWork, + int id + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetTestCrud", + id + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::TestNamespace.TestCrud.ReadModel)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetTestCrud( + recordingUnitOfWork, + id + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::TestNamespace.TestCrud.ReadModel)result; + } + + public static async global::System.Threading.Tasks.ValueTask> SelectAllTestCruds(this global::Fluss.IUnitOfWork unitOfWork + ) + { + var recordingUnitOfWork = new global::Fluss.UnitOfWorkRecordingProxy(unitOfWork); + var key = ( + "global::TestNamespace.TestCrud.GetAllTestCruds" + ); + + if (_cache.TryGetValue(key, out var result) && result is CacheEntryValue entryValue && await MatchesEventListenerState(unitOfWork, entryValue)) { + return (global::System.Collections.Generic.IReadOnlyList)entryValue.Value; + } + + result = await global::TestNamespace.TestCrud.GetAllTestCruds( + recordingUnitOfWork + ).ConfigureAwait(false); + + using (var entry = _cache.CreateEntry(key)) { + entry.Value = new CacheEntryValue(result, recordingUnitOfWork.GetRecordedListeners()); + entry.Size = 1; + } + + return (global::System.Collections.Generic.IReadOnlyList)result; + } + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Registration.g.verified.cs index 6a1050e..6261438 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.Validation.ValidationServiceCollectionExtension.AddEventValidator(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsValidators(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESValidators(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet8_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Registration.g.verified.cs index 6a1050e..6261438 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.Validation.ValidationServiceCollectionExtension.AddEventValidator(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsValidators(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESValidators(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForEventValidator.DotNet9_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Registration.g.verified.cs index 488266b..ee88d4a 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsPolicies(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESPolicies(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.Authentication.ServiceCollectionExtensions.AddPolicy(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsPolicies(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESPolicies(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet8_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Registration.g.verified.cs index 488266b..ee88d4a 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsPolicies(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESPolicies(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.Authentication.ServiceCollectionExtensions.AddPolicy(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsPolicies(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESPolicies(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForPolicy.DotNet9_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Registration.g.verified.cs index 5c34d8e..8ffb51c 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsSideEffects(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESSideEffects(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.SideEffects.SideEffectsServiceCollectionExtension.AddSideEffect(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsSideEffects(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESSideEffects(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet8_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Registration.g.verified.cs index 5c34d8e..8ffb51c 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsSideEffects(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESSideEffects(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.SideEffects.SideEffectsServiceCollectionExtension.AddSideEffect(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsSideEffects(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESSideEffects(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForSideEffect.DotNet9_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Registration.g.verified.cs index 524dae2..aa6a3d9 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsUpcasters(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESUpcasters(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.ServiceCollectionExtensions.AddUpcaster(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsUpcasters(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESUpcasters(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet8_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Registration.g.verified.cs index 524dae2..aa6a3d9 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsUpcasters(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESUpcasters(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.ServiceCollectionExtensions.AddUpcaster(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsUpcasters(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESUpcasters(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GenerateForUpcaster.DotNet9_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Registration.g.verified.cs index 124c5a7..c7c31b9 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.Validation.ValidationServiceCollectionExtension.AddAggregateValidator(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsValidators(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESValidators(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet8_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Registration.g.verified.cs index 124c5a7..c7c31b9 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Registration.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Registration.g.verified.cs @@ -7,14 +7,14 @@ using System.Runtime.CompilerServices; namespace Microsoft.Extensions.DependencyInjection { - public static partial class RegenTestsESComponentsComponentsServiceCollectionExtensions { - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESValidators(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { global::Fluss.Validation.ValidationServiceCollectionExtension.AddAggregateValidator(sc); return sc; } - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponentsComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { - AddRegenTestsESComponentsValidators(sc); + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + AddRegenTestsESValidators(sc); return sc; } } diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Selectors.g.verified.cs index 6ec1378..57e97e5 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAggregateValidator.DotNet9_0#Selectors.g.verified.cs @@ -11,7 +11,7 @@ namespace Fluss public static class UnitOfWorkSelectors { private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Selectors.g.verified.cs index 8c55f72..71ae573 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet8_0#Selectors.g.verified.cs @@ -27,7 +27,7 @@ int b return (int)entryValue.Value; } - result = await global::TestNamespace.Test.Add( + result = await TestNamespace.Test.Add( a, b ).ConfigureAwait(false); @@ -55,7 +55,7 @@ int b return (int)entryValue.Value; } - result = await global::TestNamespace.Test.Add2( + result = await TestNamespace.Test.Add2( a, b ).ConfigureAwait(false); @@ -67,7 +67,7 @@ int b return (int)result; } - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Selectors.g.verified.cs index 8c55f72..71ae573 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForAsyncSelector.DotNet9_0#Selectors.g.verified.cs @@ -27,7 +27,7 @@ int b return (int)entryValue.Value; } - result = await global::TestNamespace.Test.Add( + result = await TestNamespace.Test.Add( a, b ).ConfigureAwait(false); @@ -55,7 +55,7 @@ int b return (int)entryValue.Value; } - result = await global::TestNamespace.Test.Add2( + result = await TestNamespace.Test.Add2( a, b ).ConfigureAwait(false); @@ -67,7 +67,7 @@ int b return (int)result; } - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Selectors.g.verified.cs index f0a615e..acdf20c 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet8_0#Selectors.g.verified.cs @@ -27,7 +27,7 @@ int b return (int)entryValue.Value; } - result = global::TestNamespace.Test.Add( + result = TestNamespace.Test.Add( a, b ); @@ -39,7 +39,7 @@ int b return (int)result; } - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Selectors.g.verified.cs index f0a615e..acdf20c 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForNonAsyncSelector.DotNet9_0#Selectors.g.verified.cs @@ -27,7 +27,7 @@ int b return (int)entryValue.Value; } - result = global::TestNamespace.Test.Add( + result = TestNamespace.Test.Add( a, b ); @@ -39,7 +39,7 @@ int b return (int)result; } - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Selectors.g.verified.cs index 1a21ae5..b7707fa 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet8_0#Selectors.g.verified.cs @@ -28,7 +28,7 @@ int b return (int)entryValue.Value; } - result = global::TestNamespace.Test.Add( + result = TestNamespace.Test.Add( recordingUnitOfWork, a, b @@ -41,7 +41,7 @@ int b return (int)result; } - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Registration.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Registration.g.verified.cs new file mode 100644 index 0000000..e63f6fb --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Registration.g.verified.cs @@ -0,0 +1,15 @@ +//HintName: Registration.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.DependencyInjection { + public static partial class RegenTestsESComponentsServiceCollectionExtensions { + public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddRegenTestsESComponents(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection sc) { + return sc; + } + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#SelectorAttribute.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#SelectorAttribute.g.verified.cs deleted file mode 100644 index 6b9ec56..0000000 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#SelectorAttribute.g.verified.cs +++ /dev/null @@ -1,10 +0,0 @@ -//HintName: SelectorAttribute.g.cs -// - -namespace Fluss.Regen -{ - [System.AttributeUsage(System.AttributeTargets.Method)] - public class SelectorAttribute : System.Attribute - { - } -} \ No newline at end of file diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Selectors.g.verified.cs index 1a21ae5..b7707fa 100644 --- a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Selectors.g.verified.cs +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesForUnitOfWorkSelector.DotNet9_0#Selectors.g.verified.cs @@ -28,7 +28,7 @@ int b return (int)entryValue.Value; } - result = global::TestNamespace.Test.Add( + result = TestNamespace.Test.Add( recordingUnitOfWork, a, b @@ -41,7 +41,7 @@ int b return (int)result; } - private record CacheEntryValue(object? Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Selectors.g.verified.cs new file mode 100644 index 0000000..57e97e5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet8_0#Selectors.g.verified.cs @@ -0,0 +1,26 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Attributes.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Attributes.g.verified.cs new file mode 100644 index 0000000..3a5fadd --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Attributes.g.verified.cs @@ -0,0 +1,18 @@ +//HintName: Attributes.g.cs +// + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Method)] + public class SelectorAttribute : System.Attribute + { + } +} + +namespace Fluss.Regen +{ + [global::System.AttributeUsage(global::System.AttributeTargets.Class)] + public class CrudAttribute : System.Attribute + { + } +} diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Crud.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Crud.g.verified.cs new file mode 100644 index 0000000..a3eae42 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Crud.g.verified.cs @@ -0,0 +1,7 @@ +//HintName: Crud.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; diff --git a/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Selectors.g.verified.cs b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Selectors.g.verified.cs new file mode 100644 index 0000000..57e97e5 --- /dev/null +++ b/src/Fluss.UnitTest/Regen/Snapshots/RegenTests.GeneratesNothingForUninterestingClasses.DotNet9_0#Selectors.g.verified.cs @@ -0,0 +1,26 @@ +//HintName: Selectors.g.cs +// + +#nullable enable + +using System; +using System.Runtime.CompilerServices; + +namespace Fluss +{ + public static class UnitOfWorkSelectors + { + private static global::Microsoft.Extensions.Caching.Memory.MemoryCache _cache = new (new global::Microsoft.Extensions.Caching.Memory.MemoryCacheOptions { SizeLimit = 1024 }); + private record CacheEntryValue(object Value, global::System.Collections.Generic.IReadOnlyList? EventListeners); + + private static async global::System.Threading.Tasks.ValueTask MatchesEventListenerState(global::Fluss.IUnitOfWork unitOfWork, CacheEntryValue value) { + foreach (var eventListenerData in value.EventListeners ?? global::System.Array.Empty()) { + if (!await eventListenerData.IsStillUpToDate(unitOfWork)) { + return false; + } + } + return true; + } + } +} + diff --git a/src/Fluss/UnitOfWork/UnitOfWork.ReadModels.cs b/src/Fluss/UnitOfWork/UnitOfWork.ReadModels.cs index 296d82e..25fa4d7 100644 --- a/src/Fluss/UnitOfWork/UnitOfWork.ReadModels.cs +++ b/src/Fluss/UnitOfWork/UnitOfWork.ReadModels.cs @@ -34,7 +34,12 @@ public async ValueTask GetReadModel([DynamicallyAccessedMembers(Dyna eventListener = await UpdateAndApplyPublished(eventListener, at); - if (!await AuthorizeUsage(readModel)) + if (eventListener is not IReadModel newReadModel) + { + throw new InvalidOperationException("Type " + tReadModel.FullName + " is not a read model."); + } + + if (!await AuthorizeUsage(newReadModel)) { throw new UnauthorizedAccessException($"Cannot read {eventListener.GetType()} as the current user."); } @@ -44,7 +49,7 @@ public async ValueTask GetReadModel([DynamicallyAccessedMembers(Dyna RegisterReadModel(eventListener); } - return readModel; + return newReadModel; } public async ValueTask GetReadModel(long? at = null)