diff --git a/Beef.sln b/Beef.sln index a10824e6d..5a0431518 100644 --- a/Beef.sln +++ b/Beef.sln @@ -175,6 +175,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{FDBFD331-A docs\Sample-SqlServer-EF-GettingStarted.md = docs\Sample-SqlServer-EF-GettingStarted.md docs\Sample-SqlServer-StoredProcs-GettingStarted.md = docs\Sample-SqlServer-StoredProcs-GettingStarted.md docs\Solution-Structure.md = docs\Solution-Structure.md + docs\Upgrade-v4-to-v5.md = docs\Upgrade-v4-to-v5.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "images", "images", "{6739CF51-CAB1-4DD9-A98B-6E1EDED5BFE1}" diff --git a/CHANGELOG.md b/CHANGELOG.md index b45dac797..c8b472197 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,14 @@ Represents the **NuGet** versions. -## v5.1.1 +## v5.1.2 +- *Fixed:* The `CodeGenConfig.WarnWhereDeprecated` was checking some incorrectly cased property names. +- *Fixed:* The `AgentTester` has been updated to allow a parameterless `CreateWaf`, as well as exposing the internal `Parent` property. +## v5.1.1 - *Fixed:* Upgraded `CoreEx`, `DbEx` and `UnitTestEx` to latest packages to include all related fixes. Template solution updated to leverage `app.UseReferenceDataOrchestrator()` to specifically include. ## v5.1.0 - Represents the initial commit for _Beef_ version 5.x. All assemblies/packages now share the same version and change log; i.e. they are now published as a set versus individually versioned (prior releases). This version is a _major_ refactoring from the prior; to achieve largely the same outcomes, in a modernized decoupled manner. As stated in the [README](./README.md), _Beef_ is _now_ (as of version 5.x) ostensibly the code-generation engine, and solution orchestration, that ultimately takes dependencies on the following capabilities to enable the end-to-functionality and testing thereof in a standardized (albeit somewhat opinionated) manner: diff --git a/Common.targets b/Common.targets index 4baaa1022..ba26e0c4d 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@ - 5.1.1 + 5.1.2 preview Avanade Avanade diff --git a/README.md b/README.md index 338d05289..fbeba112a 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,20 @@ _Beef_ framework has been primarily created to support the **industralisation** The key industralisation goals are: 1. **Value** – focus on business value, not on boilerplate 2. **Acceleration** – improve velocity; reduce costs and time to market -3. **Simplicity** – increase effective usage and minimise learning -4. **Standardised** – increase knowledgeable resource pool +3. **Simplicity** – increase effective usage and minimize learning +4. **Standardized** – increase knowledgeable resource pool 5. **Consistency** – improve overall quality and maintainability 6. **Flexibility** – enable innovation and evolution easily over time 7. **Confidence** – reduced delivery timeframes and risk
+## Version 5 + +> **NOTE:** A new major version of _Beef_, **verison 5** (https://github.com/Avanade/Beef/tree/version-5), was released on [26-Jan-2023](https://en.wikipedia.org/wiki/Australia_Day). The samples have been updated accordingly, as has the related documentation. As such, development on the previous version (v4.x) will for the most part halt; only significant issues will now be addressed (for a period of time). The new version is a major refactoring (improvement and simplification) with respect to the underlying runtime primarily, and although effort was made to minimize impacts on upgrading from v4, this was unfortunately unavoidable. Guidance is provided to assist with [upgrading from v4.2.x to v5.x](./docs/Upgrade-v4-to-v5.md) where applicable. + +
+ ## Composition _Beef_ is ostensibly the code-generation engine, and solution orchestration, that ultimately takes dependencies on the following capabilities to enable the end-to-functionality and testing thereof in a standardized (albiet somewhat opinionated) manner: @@ -29,27 +35,27 @@ _Beef_ is ostensibly the code-generation engine, and solution orchestration, tha - [DbEx](https://github.com/Avanade/DbEx) - provides extended database management capabilties; - [OnRamp](https://github.com/Avanade/OnRamp) - provides the underlying code-generation engine functionality. -Prior to version 5.x, _Beef_ was all encompassing. These capabilities have been extracted, simplified and refactored to be first class frameworks in their own right, and made into the repos listed above. This allows them to be used and maintained independently to _Beef_; therefore, offering greater opportunities for reuse versus all-or-nothing. +Prior to version 5.x, _Beef_ was all encompassing. These capabilities have been extracted, simplified and refactored to be first class frameworks in their own right, and made into the repos listed above. This allows them to be used and maintained independently to _Beef_; therefore, offering greater opportunities for reuse versus all-or-nothing.
## Rapid enterprise-grade API development -As a result of the _Beef_ [Architecture](#Architecture), supporting [Framework](#Framework) and included [Code Generation](#Code-generation) capabilities, enterprise-grade APIs can be developed in a matter of hours, not days, in a standardised and consistent manner. +As a result of the _Beef_ [Architecture](#Architecture), supporting [Framework](#Framework) and included [Code Generation](#Code-generation) capabilities, enterprise-grade APIs can be developed in a matter of hours, not days, in a standardized and consistent manner. The APIs created will have the following capabilities out-of-the-box with limited developer effort, so the developer can focus on the key business value: - Rich [Entity](./docs/Layer-Entity.md) (DTO) functionality including [`INotifyPropertyChanged`](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged), [`IEditableObject`](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.ieditableobject), [`IEquatable`](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1), [`ICopyFrom`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Entities/ICopyFrom.cs), [`ICleanUp`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Entities/ICleanUp.cs), [`IPrimaryKey`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Entities/IPrimaryKey.cs), etc. -- Rich [Reference data](./docs/Reference-Data.md) capabilities, including caching, optimised serialisation, and enriched API endpoints. +- Rich [Reference data](./docs/Reference-Data.md) capabilities, including caching, optimized serialisation, and enriched API endpoints. - Rich [Validation](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Validation) capability to simplify and ensure data integrity and consistency. -- CRUD (Create, Read, Update and Delete) for Database ([Stored procedures](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Database) and [Entity Framework](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.EntityFrameworkCore)), [Cosmos DB](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Cosmos) and [HttpAgent](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx/Http) in a standardised manner. -- An approach and tooling to automate and manage database using [DbEx](https://github.com/Avanade/DbEx) set up, configuration, and deployment. +- CRUD (Create, Read, Update and Delete) for Database ([Stored procedures](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Database) and [Entity Framework](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.EntityFrameworkCore)), [Cosmos DB](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Cosmos) and [HttpAgent](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx/Http) in a standardized manner. - [Paging](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Entities/PagingArgs.cs) (skip and top) and resulting total count, that flows from API through to the underlying data source in a consistent and seamless manner. - [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) (concurrency) and `If-Match`/`If-None-Match` handling. -- JSON response field [filtering (include/exclude)](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Text/Json/JsonFilterer.cs) to minimise resulting payload size (e.g. `$fields=firstname,lastname`) +- JSON response field [filtering (include/exclude)](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Text/Json/JsonFilterer.cs) to minimize resulting payload size (e.g. `$fields=firstname,lastname`) - [HTTP Patch](./docs/Http-Patch.md) support, where required, in a simplified and consistent manner. - An end-to-end intra-domain [integration testing](./tools/Beef.Test.NUnit/README.md) approach enables effective tests to be built easily and quickly. - [Event](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx/Events) publishing (and subscribing) to enable an event-driven architecture. - Runtime capabilities can be added, where applicable, using the out-of-the-box .NET framework [Dependency Injection (DI)](./docs/Dependency-Injection.md) capabilites. +- An approach and tooling to automate and manage database using [DbEx](https://github.com/Avanade/DbEx) set up, configuration, and deployment. To implement these included capabilities would literally take months/years to build and test; these are available for developers to use immediately, and contribute back if so inclined. The capabilities and implementations have been influenced by _Microsoft's best practices for cloud applications_; specifically: - [RESTful web API design](https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-design) @@ -89,7 +95,7 @@ An architectural pattern for creating domain-based APIs: - Is a software architecture style in which complex applications are composed of small, independent processes communicating with each other using language-agnostic APIs. - These services are small, highly decoupled and focus on doing a small task, facilitating a modular approach to system-building. - Implementation independence: - - **Loose coupling** – should have its own persistence repository; data is duplicated (synchronised), not shared; eventual consistency; no distributed transactions. + - **Loose coupling** – should have its own persistence repository; data is duplicated (synchronized), not shared; eventual consistency; no distributed transactions. - **Polyglot persistence / programming** – use the best persistence repository to support the storage requirements; use a mix of programming languages (fit-for-purpose). Note: _Beef_ provides a C# / .NET implementation approach as one option. - **Eventual consistency** - for the most part, eventual consistency is good enough; real-time distributed transactional integrity is rarely required (although generally desired). An asynchronous messaging system, such as Queues or a Service Bus, can be leveraged to orchestrate cross domain data (eventual) consistency. @@ -107,7 +113,7 @@ The following represents the prescribed tiering and layering of the architecture Given this architecture, the .NET Solution you create using _Beef_ should adhere to the prescribed [solution structure](./docs/Solution-Structure.md). -Each of the key layers / components above are further detailed (`Xxx` denotes the entity name): +Each of the key layers / components above are further detailed (`Xxx` denotes the entity name); further documentation for each is available via the provided links: - [Entity (DTO)](./docs/Layer-Entity.md) - `Xxx` - [Service agent](./docs/Layer-ServiceAgent.md) - `XxxAgent` - [Service interface](./docs/Layer-ServiceInterface.md) - `XxxController` @@ -133,12 +139,12 @@ Additionally, _Beef_ has capabilities to support (and generate) the [Transaction ## Framework -A comprehensive [*framework*](https://github.com/Avanade/CoreEx) has been created to support the defined architecture, to encapsulate and standardise capabilities, to achieve the desired code-generation outcomes and improve the overall developer experience. +A comprehensive [*framework*](https://github.com/Avanade/CoreEx) has been created to support the defined architecture, to encapsulate and standardize capabilities, to achieve the desired code-generation outcomes and improve the overall developer experience. -Standardised approach, ensures consistency of implementation: +Standardized approach, ensures consistency of implementation: - Reduction in development effort. - Higher quality of output; reduced defects. -- Greater confidence in adherence to architectural vision; minimised deviation. +- Greater confidence in adherence to architectural vision; minimized deviation. - Generation and alike enables the solution to evolve more quickly and effectively over time. A key accelerator for _Beef_ is achieved using a flexible [code generation](./tools/Beef.CodeGen.Core/README.md) approach leveraging [_OnRamp_](https://github.com/Avanade/onramp). @@ -188,6 +194,7 @@ The following are references to additional documentation (these are all accessib - [Validation](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Validation) - [HTTP PATCH](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Http/HttpPatchOption.cs) - [Authentication](./docs/Authentication.md) +- [Upgrading from v4 to v5](./docs/Upgrade-v4-to-v5.md) ### Solution @@ -258,6 +265,7 @@ Otherwise, follow along with the following sample tutorials that will provide a
## Contributing + One of the easiest ways to contribute is to participate in discussions on GitHub issues. You can also contribute by submitting pull requests (PR) with code changes.
@@ -279,15 +287,13 @@ For further guidance see ASP.NET Core [Engineering guidelines](https://github.co ### Tests -We use [`NUnit`](https://github.com/nunit/nunit) for all unit testing. +[_NUnit_](https://github.com/nunit/nunit) is used for unit testing. - Tests need to be provided for every bug/feature that is completed. - Tests only need to be present for issues that need to be verified by QA (for example, not tasks). - If there is a scenario that is far too hard to test there does not need to be a test for it. - "Too hard" is determined by the team as a whole. -We understand there is more work to be performed in generating a higher level of code coverage; this technical debt is on the backlog. -
### Code reviews and checkins diff --git a/docs/Upgrade-v4-to-v5.md b/docs/Upgrade-v4-to-v5.md new file mode 100644 index 000000000..71094fbbd --- /dev/null +++ b/docs/Upgrade-v4-to-v5.md @@ -0,0 +1,452 @@ +# Upgrade Beef version 4.x to 5.x + +_Beef_, as of version 5.x, is ostensibly the code-generation engine, and solution orchestration, that ultimately takes dependencies on the following capabilities to enable the end-to-functionality and testing thereof in a standardized (albiet somewhat opinionated) manner: +- [CoreEx](https://github.com/Avanade/CoreEx) - provides the core runtime capabilties (extends .NET core); +- [UnitTestEx](https://github.com/Avanade/UnitTestEx) - provides extended unit and intra-domain integration testing; +- [DbEx](https://github.com/Avanade/DbEx) - provides extended database management capabilties; +- [OnRamp](https://github.com/Avanade/OnRamp) - provides the underlying code-generation engine functionality. + +Prior to version 5.x, _Beef_ was all encompassing. These capabilities have been extracted, simplified and refactored to be first class frameworks in their own right, and made into the repos listed above. This allows them to be used and maintained independently to _Beef_; therefore, offering greater opportunities for reuse versus all-or-nothing. + +
+ +## Breaking changes + +Version 5.x is a major refactoring (improvement and simplification) with respect to the underlying runtime primarily, and although effort was made to minimize impacts on upgrading from version 4.x, this was unfortunately unavoidable. + +
+ +### YAML-only code-generation configuration + +The XML-based code-generation configuration has been deprecated; the XML _will_ have to be converted to YAML **before** attempting to upgrade. The 4.2.x code-generation console supports `-x2y|--xml-to-yaml` to perform this action. + +
+ +### Autonomous entity scope + +In version 4.2.x an `entityScope` property was added to the entity code-generation configuration. Where this was not explicitly defined it would have defaulted to `Common`, that indicated that the rich entities (inheriting from `EntityBase`) were to be generated in the `Common` project. Alternatively, a value of `Business` would indicate that the rich entities were to be generated in the `Business` project. + +A further `Autonomous` option was available that generated two contractually-identical entities, the rich entities (inheriting from `EntityBase`) generated in the `Business` project, and corresponding basic entities (no `EntityBase` inheritance) generated in the `Common` project. This was intended to simplify usage, and remove dependencies related to the rich Reference Data, within `Common` where leveraging the `Agent` to invoke the APIs. + +The `entityScope` property has been _deprecated_ in 5.x as `Autonomous` is now the **one-and-only** behavior. Additional code-generation properties such as `internalOnly` and `omitEntityBase` further drive how the entity-based artefacts are generated. + +
+ +### JSON serialization + +Previously, _Beef_ leveraged _Newtonsoft_ exclusively for JSON serialization. _CoreEx_ is [JSON serializer](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Json/README.md) implementation agnostic; however, `System.Text.Json` is considered the preferred (default). + +From a code-generation perspective a new YAML [`jsonSerializer`](./Entity-CodeGeneration-Config.md#Entity) property can be used to specify preferred; defaults to `SystemText`; otherwise, specify `Newtonsoft`. + +
+ +### Reference data + +There has been a significant refactoring of the existing `ReferenceDataManager`; this functionality is now enabled by the _CoreEx_ [`ReferenceDataOrchestrator`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/RefData/ReferenceDataOrchestrator.cs). This new class now fully encapsulates the [reference data](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/RefData/README.md) access, caching, and loading. The v5.x reference data code generation has been updated accordingly. + +
+ +### Object-property mapping + +Where previously leveraging the likes of Entity Framework (EF) object-property mapping between types was managed leveraging _AutoMapper_ to enable. _CoreEx_ provides a flexible implementation agnostic approach to enable [mapping](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Mapping/README.md); however, for _Beef_ the code-generation exclusively leverages the new simpler in-built [`Mapper`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Mapping/README.md#mapper-implementation) functionality. + +
+ +### Async cancellation token + +All _CoreEx_ `Async` methods include a [`CancellationToken`](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken) as the final parameter to support the recommended .NET asynchronous programming [pattern](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1068). + +Where overridding previous `Async`-related methods these will need to be updated to include this new parameter. Generally, where invoking the method the `CancellationToken` will be optional; i.e. will default where not specified. + +
+ +### Check class + +_Beef_ previously contained a `Check` class that was used to check method parameters and throw a corresponding `ArgumentNullException` or `ArgumentException`; this class does not exist in _CoreEx_. The code that previously leveraged will need to be refactored, or the developer will need to re-implement the `Check` class. + +It is recommended that the developer consider using [`ArgumentNullException.ThrowIfNull`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception.throwifnull) and [`ArgumentException.ThrowIfNullOrEmpty`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception.throwifnullorempty) (.NET 6+). + +
+ +## Package mapping + +Following represents the high-level mapping between the existing _Beef_ packages and the corresponding new (where applicable). Not all packages are functionally equivalent, some capabilities may have been deprecated. + +Existing | New +-|- +`Beef.Abstractions` | `CoreEx` +`Beef.AspNetCore.WebApi` | `CoreEx` +`Beef.Core` | `CoreEx`, `CoreEx.Validation`, `CoreEx.Newtonsoft`, `CoreEx.AutoMapper` +`Beef.Data.Database` | `CoreEx.Database.SqlServer` includes `CoreEx.Database` +`Beef.Data.Database.Cdc` | `CoreEx.Database.SqlServer` +`Beef.Data.EntityFrameworkCore` | `CoreEx.EntityFrameworkCore` +`Beef.Data.Cosmos` | `CoreEx.Cosmos` +`Beef.Data.OData` | None (on roadmap) +`Beef.Events` | `CoreEx` (`CoreEx.Events` namespace) +`Beef.Events.EventHubs` | None (on roadmap) +`Beef.Events.ServiceBus` | `CoreEx.Azure` (publishing only) +`Beef.Grpc` | None (consider [Dapr sidecar](https://docs.dapr.io/developing-applications/integrations/grpc-integration/)) +- | - +`Beef.CodeGen.Core` | `Beef.CodeGen.Core` upgraded (leverages `OnRamp`) +`Beef.Database.Core` | `Beef.Database.SqlServer` includes `Beef.Database.Core` (leverages `DbEx`) +`Beef.Test.NUnit` | `UnitTestEx`, [`Beef.Test.NUnit`](../tools/Beef.Test.NUnit/README.md) (backwards compatibility) +`Beef.Template.Solution` | `Beef.Template.Solution` + +
+ +## Upgrade guidance approach + +This documentation was developed by upgrading the `My.Hr` solution and recording the steps. This attempts to capture the how, and sometimes the why, logically project-by-project. + +Section | Project +-|- +[CodeGen](#CodeGen) | [My.Hr.CodeGen](../samples/My.Hr/My.Hr.CodeGen) +[Database](#Database) | [My.Hr.Database](../samples/My.Hr/My.Hr.Database) +[Common](#Common) | [My.Hr.Common](../samples/My.Hr/My.Hr.Common) +[Business](#Business) | [My.Hr.Business](../samples/My.Hr/My.Hr.Business) +[Api](#Api) | [My.Hr.Api](../samples/My.Hr/My.Hr.Api) +[Test](#Test) | [My.Hr.Test](../samples/My.Hr/My.Hr.Test) + +
+ +## CodeGen + +The code-generation capabilities continue to leverage _OnRamp_ to provide the code-generation scripting, templating and orchestration. All underlying templates have been updated where applicable to output code supporting the _Beef_ 5.x changes. Update the `Beef.CodeGen.Core` package dependency to the latest 5.x version. The underlying [`Program.cs`](../samples/My.Hr/My.Hr.CodeGen/Program.cs) logic should require no further changes and should compile successfully. + +The `*.beef.yaml` configuration files _must_ be renamed to `*.beef-5.yaml`. This is to support new features and ensure the underlying schema validation (intellisense) is targeting version `5.x`. + +Within _CoreEx_ the existing `IUniqueKey` interface has been replaced with the [`IPrimaryKey`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Entities/IPrimaryKey.cs), as such all references to the code-generation `uniqueKey` property must be renamed to `primaryKey`. + +
+ +### Clean + +A new `Clean` command has been added to the code-generator. Where executed the code-generator will recursively discover all `Generated` folders and will delete all files within (including generated [Database](#Database) artefacts where applicable). This will ensure a clean baseline as not all previously generated artefacts will be generated in the new version. + +From the command-line execute the clean command. + +``` +dotnet run clean +``` + +
+ +### Re-generate + +Re-generate all the existing artefacts leveraging the `All` command. + +``` +dotnet run all +``` + +Error messages similar to the following may appear and will need to be corrected for the code-generation to complete successfully. + +``` +Config '.\My.Hr\My.Hr.CodeGen\entity.beef-5.yaml' is invalid: [Entity(Name='EmployeeBase').Property(Name='Id').uniqueKey] The 'uniqueKey' configuration has been renamed to 'primaryKey'; please update the configuration accordingly. +``` + +Warning messages similar to the following may appear to indicate where previous configuration has been deprecated, etc. Generally, it is advisable to correct the configuration to remove all the warnings. + +``` +Warning: Config [entityScope] has been deprecated and will be ignored. +Warning: Config [Entity(Name='EmployeeBase').iValidator] has been deprecated and will be ignored. +``` + +
+ +## Database + +The database capabilities have been extended within _DbEx_ to support multiple relational database providers, as such `Beef.Database.SqlServer` now encapsulates the SQL Server database migration logic. As such, remove all previous `Beef.*` package dependencies and add the latest `Beef.Database.SqlServer` package version. + +The underlying [`Program.cs`](../samples/My.Hr/My.Hr.Database/Program.cs) logic has been updated such that a new `ConfigureMigrationArgs` method has been exposed that the `My.Hr.Test` can invoke to minimize duplication of any [`MigrationArgs`](../tools/Beef.Database.Core/MigrationArgs.cs) configuration. + +``` csharp +public class Program +{ + /// + /// Main startup. + /// + /// The startup arguments. + /// The status code whereby zero indicates success. + static Task Main(string[] args) => SqlServerMigrationConsole + .Create("Data Source =.; Initial Catalog = My.Hr; Integrated Security = True; TrustServerCertificate = true", "My", "Hr") + .Configure(c => ConfigureMigrationArgs(c.Args)) + .RunAsync(args); + + /// + /// Configure the . + /// + /// The . + /// The . + public static MigrationArgs ConfigureMigrationArgs(MigrationArgs args) => args.AddAssembly().UseBeefSchema(); +} +``` + +The `database.beef.yaml` configuration file _must_ also be renamed to `database.beef-5.yaml`. This is to support new features and ensure the underlying schema validation (intellisense) is targeting version `5.x`. + +Finally, recompile and execute. There may have been some minor changes to the generated output from the previous version. + +``` +dotnet run all +``` + +Warning messages similar to the following may appear to indicate where previous configuration has been deprecated, etc. Generally, it is advisable to correct the configuration to remove warnings. + +``` +Warning: Config [entityScope] has been deprecated and will be ignored. +``` + +
+ +## Common + +Generally remove/update the package dependencies as follows; check any other dependencies to ensure need and update version accordingly. + +Remove | Instructions +-|- +`Beef.*` | Add the latest `CoreEx` package. +`Newtonsoft.Json` | By default `System.Text.Json` is used and is included within `CoreEx`; where `Newtonsoft` is still required add the `CoreEx.Newtonsoft` package. + +This project should require no further changes and compile successfully. + +The generated `Common` project output has been changed as follows. + +Folder | Leverages | Additional information +-|-|- +`Entities` | [`CoreEx.Entities`](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx/Entities) | See [documentation](./Layer-Entity.md). +`Agents` | [`CoreEx.Http`](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx/Http) | See [documentation](./Layer-ServiceAgent.md). Note that the existing `IXxxWebApiAgentArgs` and `XxxWebApiAgentArgs` have been deprecated. + +
+ +## Business + +Generally remove/update the package dependencies as follows; check any other dependencies to ensure need and update version accordingly. + +Remove | Instructions +-|- +`Beef.Core` | Add the latest `CoreEx` and `CoreEx.Validation` packages. +`Beef.Data.Database` | Add the latest `CoreEx.Database.SqlServer` package. +`Beef.Data.EntityFrameworkCore` | Add the latest `CoreEx.EntityFrameworkCore` package. +`Beef.*` | Other `Beef` dependencies; see [package mapping](#Package-mapping). +`Newtonsoft.Json` | By default `System.Text.Json` is used and is included within `CoreEx`; where `Newtonsoft` is still required add the `CoreEx.Newtonsoft` package (includes `Newtonsoft.Json`). + +
+ +### Namespaces + +C# 10 as part of .NET 6 introduced the concept of [global and implicit usings](https://devblogs.microsoft.com/dotnet/welcome-to-csharp-10/). This feature is leveraged in the code generation, in that the namespace `using` statements are no longer output. + +To leverage update the .NET project configuration as follows: + +``` xml + + net6.0 + enable + true +``` + +A file similar to this [`GlobalUsings`](../samples/My.Hr/My.Hr.Business/GlobalUsings.cs) must be added to the project, with adjustments within to the `Company.AppName.` namespaces specific to the solution being upgraded. + +Any custom, non-generated, classes _can_ remove duplicate `using` statements to simplify code if desired. For the most part, all existing `using` statements can be removed, and the `ImplictUsings` file updated to add any additional as required. + +
+ +### Configuration settings + +The [`CoreEx.Configuration`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Configuration/README.md) namespace provides the new [`SettingsBase`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Configuration/SettingsBase.cs) class that provides a flexible, centralized, means to manage `IConfiguration`. + +A new settings class, similar to [`HrSettings`](../samples/My.Hr/My.Hr.Business/HrSettings.cs), must be created. The underlying `SettingsBase` contains a number of pre-configured settings that are leveraged by _CoreEx_ at runtime. Any additional settings, for example connection strings, should be moved to this class where applicable. + +
+ +### Manager-layer logic + +See [documentation](./Layer-Manager.md) for details on this specific layer. + +
+ +### DataSvcs-layer + +See [documentation](./Layer-DataSvc.md) for details on this specific layer. + +
+ +### Data-layer logic + +See [documentation](./Layer-Data.md) for details on this specific layer. The following are some of the key changes to the data-layer logic that may be encounted. + +Existing | Change required +-|- +`XxxDb` | The existing custom database class that previously inherited from `DatabaseBase` must be updated to inherit from [`SqlServerDatabase`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx.Database.SqlServer/SqlServerDatabase.cs). The underlying implementation has changed; see sample [`HrDb`](../samples/My.Hr/My.Hr.Business/Data/HrDb.cs) as a guide. +`XxxEfDb` | Where also leveraging Entity Framework (EF) the equivalent [`HrEfDb`](../samples/My.Hr/My.Hr.Business/Data/HrEfDb.cs) and [`HrEfDbContext`](../samples/My.Hr/My.Hr.Business/Data/HrEfDbContext.cs) will need amending. The `Microsoft.EntityFrameworkCore.SqlServer` package dependency will also need to be added explicitly. +`DatabaseArgs` | Previously, this class was instantiated within the code-generated `partial` class, then passed into the corresponding customized `partial` class. This previously had limited usage and as such has been moved as a property into the owning `Database` class. Therefore, this parameter will need to be removed from the customized non-generated `partial` class. +`StoredProcedure` | The `StoredProcedure` property is no longer included within the `DatabaseArgs`, it is now the primary method (explicitly specified) to be able to perform an operation on the database; for example `_db.StoredProcedure(storedProcedureName).Xxx`. +`GetParamName` | This has been renamed to `GetParameterName`. A developer could choose to implement this as an extension method to enable, this would then minimize changes to existing code where applicable. +`SelectQueryMultiSetAsync` | This has been renamed to `SelectMultiSetAsync`. A developer could choose to implement this as an extension method to enable, this would then minimize changes to existing code where applicable. +`CreateTableValuedParameter` | This now requires the database to be passed as the first paramater; for example `CreateTableValuedParameter(_db, collection)`. + +
+ +### Validation logic + +The [`CoreEx.Validation`](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Validation) is essentially a port of the existing `Beef.Validation` implementation. There have been some minor changes/rationalizations; however, for the most part this should be largely identical in feature and underlying API. + +Where inheriting from `Validator` the `OnValidateAsync(ValidationContext context)` method signature has been changed to `OnValidateAsync(ValidationContext context, CancellationToken cancellation)` and will be need to be updated accordingly. + +
+ +## API + +See [documentation](./Layer-ServiceInterface.md) for details on this specific layer. + +Remove `Beef.*` packages and replace with `CoreEx` package (will be automatically included given reference to `Business` project); check any other dependencies to ensure need and update version accordingly. + +
+ +### Namespaces + +C# 10 as part of .NET 6 introduced the concept of [global and implicit usings](https://devblogs.microsoft.com/dotnet/welcome-to-csharp-10/). This feature is leveraged in the code generation, in that the namespace `using` statements are no longer output. + +To leverage update the .NET project configuration as follows: + +``` xml + + net6.0 + enable + true +``` + +A file similar to this [`GlobalUsings`](../samples/My.Hr/My.Hr.Api/GlobalUsings.cs) must be added to the project, with adjustments within to the `Company.AppName.` namespaces specific to the solution being upgraded. + +
+ +### Dependency injection + +There have been significant changes related to _CoreEx_ and the requirements for Dependency Injection (DI); see [documentation](./Dependency-Injection.md) for further details. + +The [event publishing/sending](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Events/README.md) approach has seen sigificant change within _CoreEx_ and will need to be refactored accordingly. Where leveraging a cloud native [Microsoft Azure messaging capability](https://learn.microsoft.com/en-us/azure/event-grid/compare-messaging-services) review [`CoreEx.Azure`](https://github.com/Avanade/CoreEx/tree/main/src/CoreEx.Azure) to determine whether a solution exists; if not, this could be an awesome opportunity to contribute. + +See [`Startup.cs`](../samples/My.Hr/My.Hr.Api/Startup.cs) for an example implementation. + +
+ +### Application builder configuration + +The underlying ASP.NET [`IApplicationBuilder`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.iapplicationbuilder) logic should largely remain unchanged. + +The existing `UseWebApiExceptionHandler` no longer supports parameters; these are now loaded internally leveraging Dependency Injection; see underlying [`WebApiExceptionHandlerMiddleware`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/WebApis/WebApiExceptionHandlerMiddleware.cs). + +After the existing `UseExecutionContext`, an additional `UseReferenceDataOrchestrator` must be added for the `ReferenceDataOrchestrator` to function correctly. Example code is as follows. + +``` csharp +app.UseExecutionContext(); +app.UseReferenceDataOrchestrator(); +``` + +
+ +### Program host + +Within the existing `Program` class there was a reference to an existing _Beef_ `WebApiStartup` class; this has been deprecated. During the port to _CoreEx_ it was decided that the set up should be explicitly managed by the developer, and that _Beef_ should not impose any particular approach, etc. including the usage of embedded configuration files. + +The embedded resource usage was needed to support the existing unit testing capabilities; this is no longer required as _UnitTestEx_ has improved functionality to leverage the API as-is without any specific constraints. It is recommended that the developer review the existing embedded configuration file usage and amend/remove where applicable. + +See [`Program.cs`](../samples/My.Hr/My.Hr.Api/Program.cs) for an example implementation. + +
+ +## Test + +The _Beef v5.x_ testing has **now** been replaced by the functionality available within [UnitTestEx](https://github.com/Avanade/unittestex). Any functionality available within [`Beef.Test.NUnit`](../tools/Beef.Test.NUnit/README.md) is intended to assist with the upgrading from _Beef v4.x_; contains a subset of the previous functionality. This assembly will likely be deprecated at the next major version. + +To use update the `Beef.Test.NUnit` package dependency to the latest 5.x version. + +
+ +### Namespaces + +C# 10 as part of .NET 6 introduced the concept of [global and implicit usings](https://devblogs.microsoft.com/dotnet/welcome-to-csharp-10/). To leverage update the .NET project configuration as follows: + +``` xml + + net6.0 + enable + true +``` + +A file similar to this [`GlobalUsings`](../samples/My.Hr/My.Hr.Test/GlobalUsings.cs) must be added to the project, with adjustments within to the `Company.AppName.` namespaces specific to the solution being upgraded. + +_Note_: The `Entities` namespaces should _not_ be included with the `GlobalUsings`; these should be specified per file otherwise an ambiguious name reference will occur. + +Any custom, non-generated, classes _can_ remove duplicate `using` statements to simplify code if desired. For the most part, all existing `using` statements can be removed, and the `ImplictUsings` file updated to add any additional as required. + +
+ +### Fixture one-time set-up + +The existing `FixtureSetUp.OneTimeSetUp` approach has been updated as a result of `UnitTestEx`. See [`FixtureSetUp.cs`](../samples/My.Hr/My.Hr.Test/Apis/FixtureSetUp.cs) for an example implementation. + +
+ +### API testing + +The existing `TestSetUpAttribute` and `AgentTester` have been deprecated during the port to _UnitTestEx_; however, basic proxies have been created for these within the `Beef.Test.NUnit` package. To enable add `using Beef.Test.NUnit`; or, alternatively update to test exclusively using _UnitTestEx_. + +See following examples: +- [`PersonTest.cs`](../samples/Demo/Beef.Demo.Test/PersonTest.cs) for `Beef.Test.NUnit` implementation. +- [`EmployeeTest.cs`](../samples/My.Hr/My.Hr.Test/Apis/EmployeeTest.cs) for _UnitTestEx_ exclusive implementation. + +Other challenges may include: +- Make sure the `using Company.AppName.Common.Entities;` is declared; otherwise, the entity will not match that returned by the executing _agent_ and an obscure compile error will occur. Note that the common entities do not contain any transformation logic within, so if this was previously assumed then this will need to be manually accounted for; i.e. `DateTimeTransform.DateOnly`. +- The existing `CollectionResult.Result` has been renamed `CollectionResult.Items`; as such any references to the preivous `Result` property will need to be updated to `Items`. +- The `ExpectUniqueKey` method has been deprecated; replace with either `ExpectIdentifier` or `ExpectPrimaryKey` depending on underlying entity implementation. +- The `WebApiRequestOptions` class has been deprecated; replace with `HttpRequestOptions`. The `IncludeRefDataText` property has been renamed to `IncludeText`. +- The `WebApiPatchOption` class has been deprecated; replace with `HttpPatchOption`. +- The `TestSetUp.ConcurrencyErrorETag` has been deprecated; replace with `TestSetUp.Default.ConcurrencyErrorETag`. +- The `ExpectEvent` contract has changed, with `ExpectEventValue`, `ExpectDestinationEvent` and `ExpectDestinationEventValue` also added for more advanced scenarios. + +
+ +### Reference data API testing + +For tests that return `IReferenceData` results the _reference data_-specifc serializer (see [`ReferenceDataContentJsonSerializer`](https://github.com/Avanade/CoreEx/blob/main/src/CoreEx/Text/Json/ReferenceDataContentJsonSerializer.cs)) must be used to effectively deserialize. This must be set before the test executes. + +See [`ReferenceDataTest.cs`](../samples/My.Hr/My.Hr.Test/Apis/ReferenceDataTest.cs) for an example implementation. + +Where using the `Beef.Test.NUnit` package see follows. + +``` csharp +// Existing +using var agentTester = AgentTester.CreateWaf(); + +// New +using var agentTester = AgentTester.CreateWaf(configureTester: t => t.UseJsonSerializer(new CoreEx.Text.Json.ReferenceDataContentJsonSerializer())); +``` + +
+ +### Validation testing + +The existing `ValidationTester.Test` with corresponding `CreateAndRunAsync` pattern has been deprecated within _UnitTestEx_. The `ValidationTester` must be explicitly created using the `Create` method and finally disposed as it implements `IDisposable`. + +``` csharp +// Existing +await ValidationTester.Test() + .Xxx() + .CreateAndRunAsync, Xxx>(value); + +// New +using var test = ValidationTester.Create(); + +await test.Xxx() + .RunAsync, Xxx>(value); +``` + +Other challenges may include: +- Where `ConfigureServices` is leveraged this now only supports a parameter with `Action`, and as such the invoking code will need to be updated accordingly. +- The `AddGeneratedValidationServices()` for the `IServiceCollection` has been deprecated; the validators are now added using the new `AddValidators()`. The `AddValidationTextProvider()` will also need to be added to ensure the validation message text provider is registered. +- The `AddJsonSerializer` and `AddReferenceDataOrchestrator` for the `IServiceCollection` will be required to enable JSON serialization and underlying reference data orchestration. +- The `ValidationTester.Messages` method has been deprecated and replaced with `ValidationTester.Errors` which is functionally equivalent. +- The `ValidationTester.AddScopedService` method has been deprecated and replaced with `ValidationTester.MockScoped` which is functionally equivalent. + +See [`EmployeeValidatorTest.cs`](../samples/My.Hr/My.Hr.Test/Validators/EmployeeValidatorTest.cs) for an example implementation. \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Api/ImplicitUsings.cs b/samples/Cdr.Banking/Cdr.Banking.Api/GlobalUsings.cs similarity index 100% rename from samples/Cdr.Banking/Cdr.Banking.Api/ImplicitUsings.cs rename to samples/Cdr.Banking/Cdr.Banking.Api/GlobalUsings.cs diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/ImplicitUsings.cs b/samples/Cdr.Banking/Cdr.Banking.Business/GlobalUsings.cs similarity index 100% rename from samples/Cdr.Banking/Cdr.Banking.Business/ImplicitUsings.cs rename to samples/Cdr.Banking/Cdr.Banking.Business/GlobalUsings.cs diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj index 7334f439e..20a66208c 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj @@ -35,7 +35,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/Demo/Beef.Demo.Api/ImplicitUsings.cs b/samples/Demo/Beef.Demo.Api/GlobalUsings.cs similarity index 100% rename from samples/Demo/Beef.Demo.Api/ImplicitUsings.cs rename to samples/Demo/Beef.Demo.Api/GlobalUsings.cs diff --git a/samples/Demo/Beef.Demo.Business/ImplicitUsings.cs b/samples/Demo/Beef.Demo.Business/GlobalUsings.cs similarity index 100% rename from samples/Demo/Beef.Demo.Business/ImplicitUsings.cs rename to samples/Demo/Beef.Demo.Business/GlobalUsings.cs diff --git a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj index 1e023c138..9b7e4cd5d 100644 --- a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj +++ b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj @@ -57,7 +57,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/My.Hr/My.Hr.Api/ImplicitUsings.cs b/samples/My.Hr/My.Hr.Api/GlobalUsings.cs similarity index 100% rename from samples/My.Hr/My.Hr.Api/ImplicitUsings.cs rename to samples/My.Hr/My.Hr.Api/GlobalUsings.cs diff --git a/samples/My.Hr/My.Hr.Business/ImplicitUsings.cs b/samples/My.Hr/My.Hr.Business/GlobalUsings.cs similarity index 100% rename from samples/My.Hr/My.Hr.Business/ImplicitUsings.cs rename to samples/My.Hr/My.Hr.Business/GlobalUsings.cs diff --git a/samples/My.Hr/My.Hr.Test/Apis/EmployeeTest.cs b/samples/My.Hr/My.Hr.Test/Apis/EmployeeTest.cs index eb431619c..d8108e324 100644 --- a/samples/My.Hr/My.Hr.Test/Apis/EmployeeTest.cs +++ b/samples/My.Hr/My.Hr.Test/Apis/EmployeeTest.cs @@ -252,7 +252,7 @@ public void B110_Create() .ExpectETag() .ExpectIdentifier() .ExpectValue(_ => v) - .ExpectEvent("my.hr.employee", "created") + .ExpectEventValue(v, "my.hr.employee", "created", "Id", "ETag", "ChangeLog") .Run(a => a.CreateAsync(v)).Value!; // Check the value was created properly. diff --git a/samples/My.Hr/My.Hr.Test/ImplicitUsing.cs b/samples/My.Hr/My.Hr.Test/GlobalUsings.cs similarity index 100% rename from samples/My.Hr/My.Hr.Test/ImplicitUsing.cs rename to samples/My.Hr/My.Hr.Test/GlobalUsings.cs diff --git a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj index 2d3bee824..b7aeafb3f 100644 --- a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj +++ b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj @@ -38,7 +38,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -47,7 +47,7 @@ - + contentFiles\any\any\Schema\ true true diff --git a/samples/My.Hr/docs/Employee-Api.md b/samples/My.Hr/docs/Employee-Api.md index 60aacaed9..ab22fb5c6 100644 --- a/samples/My.Hr/docs/Employee-Api.md +++ b/samples/My.Hr/docs/Employee-Api.md @@ -257,7 +257,7 @@ public partial class EmployeeData } ``` -After pasting the code above there will be some compile errors that need to be resolved as the required namespaces have not been defined. Open `My.Hr.Business/ImplicitUsings.cs` and add in the following two lines of code: +After pasting the code above there will be some compile errors that need to be resolved as the required namespaces have not been defined. Open `My.Hr.Business/GlobalUsings.cs` and add in the following two lines of code: ``` csharp global using CoreEx.Database.Extended; diff --git a/samples/My.Hr/docs/Employee-Test.md b/samples/My.Hr/docs/Employee-Test.md index 606d2c878..424e3e7ac 100644 --- a/samples/My.Hr/docs/Employee-Test.md +++ b/samples/My.Hr/docs/Employee-Test.md @@ -20,7 +20,7 @@ The overall `My.Hr.Test` solution was created with the following; the existing ` └── A270_GetByArgs_RefDataText-Response.json <- remove └── Validators └── PersonValidatorTest.cs <- remove -└── ImplicitUsings.cs <- leave; contains all the requisite global using statements +└── GlobalUsings.cs <- leave; contains all the requisite global using statements ```
diff --git a/samples/MyEf.Hr/MyEf.Hr.Api/ImplicitUsings.cs b/samples/MyEf.Hr/MyEf.Hr.Api/GlobalUsings.cs similarity index 100% rename from samples/MyEf.Hr/MyEf.Hr.Api/ImplicitUsings.cs rename to samples/MyEf.Hr/MyEf.Hr.Api/GlobalUsings.cs diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/ImplicitUsings.cs b/samples/MyEf.Hr/MyEf.Hr.Business/GlobalUsings.cs similarity index 100% rename from samples/MyEf.Hr/MyEf.Hr.Business/ImplicitUsings.cs rename to samples/MyEf.Hr/MyEf.Hr.Business/GlobalUsings.cs diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/Apis/EmployeeTest.cs b/samples/MyEf.Hr/MyEf.Hr.Test/Apis/EmployeeTest.cs index 15bcdd28b..c477b77ce 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/Apis/EmployeeTest.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Test/Apis/EmployeeTest.cs @@ -252,7 +252,7 @@ public void B110_Create() .ExpectETag() .ExpectIdentifier() .ExpectValue(_ => v) - .ExpectEvent("myef.hr.employee", "created") + .ExpectEventValue(v, "myef.hr.employee", "created", "Id", "ETag", "ChangeLog") .Run(a => a.CreateAsync(v)).Value!; // Check the value was created properly. diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/ImplicitUsing.cs b/samples/MyEf.Hr/MyEf.Hr.Test/GlobalUsings.cs similarity index 100% rename from samples/MyEf.Hr/MyEf.Hr.Test/ImplicitUsing.cs rename to samples/MyEf.Hr/MyEf.Hr.Test/GlobalUsings.cs diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj index d2205e45b..d83aa1bb9 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj @@ -38,7 +38,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive
- + @@ -47,7 +47,7 @@ - + contentFiles\any\any\Schema\ true true diff --git a/samples/MyEf.Hr/docs/Employee-Test.md b/samples/MyEf.Hr/docs/Employee-Test.md index 0738707ef..940db69d5 100644 --- a/samples/MyEf.Hr/docs/Employee-Test.md +++ b/samples/MyEf.Hr/docs/Employee-Test.md @@ -20,7 +20,7 @@ The overall `MyEf.Hr.Test` solution was created with the following; the existing └── A270_GetByArgs_RefDataText-Response.json <- remove └── Validators └── PersonValidatorTest.cs <- remove -└── ImplicitUsings.cs <- leave; contains all the requisite global using statements +└── GlobalUsings.cs <- leave; contains all the requisite global using statements ```
diff --git a/templates/Beef.Template.Solution/content/.template.config/template.json b/templates/Beef.Template.Solution/content/.template.config/template.json index 39fb2b077..8d41c5cc1 100644 --- a/templates/Beef.Template.Solution/content/.template.config/template.json +++ b/templates/Beef.Template.Solution/content/.template.config/template.json @@ -73,7 +73,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "2.1.2" + "value": "2.1.3" }, "replaces": "UnitTestExVersion" }, @@ -81,7 +81,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "5.1.1" + "value": "5.1.2" }, "replaces": "BeefVersion" }, diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Api/ImplicitUsings.cs b/templates/Beef.Template.Solution/content/Company.AppName.Api/GlobalUsings.cs similarity index 100% rename from templates/Beef.Template.Solution/content/Company.AppName.Api/ImplicitUsings.cs rename to templates/Beef.Template.Solution/content/Company.AppName.Api/GlobalUsings.cs diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Business/ImplicitUsings.cs b/templates/Beef.Template.Solution/content/Company.AppName.Business/GlobalUsings.cs similarity index 100% rename from templates/Beef.Template.Solution/content/Company.AppName.Business/ImplicitUsings.cs rename to templates/Beef.Template.Solution/content/Company.AppName.Business/GlobalUsings.cs diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Test/ImplicitUsing.cs b/templates/Beef.Template.Solution/content/Company.AppName.Test/GlobalUsings.cs similarity index 100% rename from templates/Beef.Template.Solution/content/Company.AppName.Test/ImplicitUsing.cs rename to templates/Beef.Template.Solution/content/Company.AppName.Test/GlobalUsings.cs diff --git a/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs b/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs index dd2f42c2d..fb3b42766 100644 --- a/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs +++ b/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs @@ -407,12 +407,12 @@ protected override async Task PrepareAsync() "cdcIdentifierMappingTableName", "cdcIdentifierMappingStoredProcedureName", "cdcExcludeColumnsFromETag", - "EventSubjectRoot", - "EventSubjectFormat", - "EventActionFormat", - "EventSourceRoot", - "EventSourceKind", - "EventSourceFormat", + "eventSubjectRoot", + "eventSubjectFormat", + "eventActionFormat", + "eventSourceRoot", + "eventSourceKind", + "eventSourceFormat", "PathCdcPublisher", "jsonSerializer", "pluralizeCollectionProperties", @@ -420,7 +420,7 @@ protected override async Task PrepareAsync() "entityScope", "eventOutbox", "eventOutboxTableName", - "NamespaceCdcPublisher", + "namespaceCdcPublisher", "entityScope"); } diff --git a/tools/Beef.Test.NUnit/AgentTester.cs b/tools/Beef.Test.NUnit/AgentTester.cs index 46c3e219f..48a3b0cca 100644 --- a/tools/Beef.Test.NUnit/AgentTester.cs +++ b/tools/Beef.Test.NUnit/AgentTester.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using System; using UnitTestEx.NUnit; +using UnitTestEx.NUnit.Internal; namespace Beef.Test.NUnit { @@ -14,11 +15,15 @@ public static class AgentTester /// Creates an to support agent-initiated API testing. /// /// The API startup . + /// Provides an opportunity to configure the . + /// Provides an opportunity to configure the owning /// The . /// It is recommended that usage is upgraded to the new as this will eventually be deprecated. - public static AgentTester CreateWaf(Action? configureServices) where TEntryPoint : class + public static AgentTester CreateWaf(Action? configureServices = null, Action>? configureTester = null) where TEntryPoint : class { var tester = ApiTester.Create(); + configureTester?.Invoke(tester); + if (configureServices != null) tester.ConfigureServices(configureServices); diff --git a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj index 66843aa0f..5b34a0927 100644 --- a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj +++ b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj @@ -8,7 +8,7 @@
- + diff --git a/tools/Beef.Test.NUnit/TestSetUpAttribute.cs b/tools/Beef.Test.NUnit/TestSetUpAttribute.cs index 6cfa84c8b..72c5d200a 100644 --- a/tools/Beef.Test.NUnit/TestSetUpAttribute.cs +++ b/tools/Beef.Test.NUnit/TestSetUpAttribute.cs @@ -17,8 +17,9 @@ namespace Beef.Test.NUnit /// /// Provided to support backwards compatibility to earlier Beef versions. It is recommended that usage is upgraded to the new as this will eventually be deprecated. /// As the attribute is executed by the NUnit runtime outside of the context of the method itself only the is able to be referenced. This, and the challenge of achieving consistency between - /// MSUnit, NUnit and Xunit is why this feature is being deprecated. + /// MSTest, NUnit and Xunit is why this feature is being deprecated. [DebuggerStepThrough] + [AttributeUsage(AttributeTargets.Method)] public class TestSetUpAttribute : PropertyAttribute, IWrapSetUpTearDown, ICommandWrapper { private static readonly AsyncLocal _username = new();