diff --git a/src/Beef.Core/InvokerBase.cs b/src/Beef.Core/InvokerBase.cs index c68891f19..e251f5419 100644 --- a/src/Beef.Core/InvokerBase.cs +++ b/src/Beef.Core/InvokerBase.cs @@ -25,7 +25,7 @@ public abstract class InvokerBase : Invoker /// The method or property name of the caller to the method. /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. - public void Invoke(object caller, Action action, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + public void Invoke(object caller, Action action, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) => WrapInvoke(caller, action, param, memberName, filePath, lineNumber); /// @@ -37,7 +37,7 @@ public void Invoke(object caller, Action action, TParam param = default, [Caller /// The method or property name of the caller to the method. /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. - protected virtual void WrapInvoke(object caller, Action action, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + protected virtual void WrapInvoke(object caller, Action action, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) => Check.NotNull(action, nameof(action)).Invoke(); /// @@ -49,7 +49,7 @@ protected virtual void WrapInvoke(object caller, Action action, TParam param = d /// The method or property name of the caller to the method. /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. - public async Task InvokeAsync(object caller, Func func, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + public async Task InvokeAsync(object caller, Func func, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) => await WrapInvokeAsync(caller, func, param, memberName, filePath, lineNumber).ConfigureAwait(false); /// @@ -61,7 +61,7 @@ public async Task InvokeAsync(object caller, Func func, TParam param = def /// The method or property name of the caller to the method. /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. - protected virtual async Task WrapInvokeAsync(object caller, Func func, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + protected virtual async Task WrapInvokeAsync(object caller, Func func, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) { Check.NotNull(func, nameof(func)); await func.Invoke().ConfigureAwait(false); @@ -82,7 +82,7 @@ protected virtual async Task WrapInvokeAsync(object caller, Func func, TPa /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. /// The result. - public TResult Invoke(object caller, Func func, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + public TResult Invoke(object caller, Func func, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) => WrapInvoke(caller, func, param, memberName, filePath, lineNumber); /// @@ -96,7 +96,7 @@ public TResult Invoke(object caller, Func func, TParam param = /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. /// The result. - protected virtual TResult WrapInvoke(object caller, Func func, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + protected virtual TResult WrapInvoke(object caller, Func func, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) => Check.NotNull(func, nameof(func)).Invoke(); /// @@ -110,7 +110,7 @@ protected virtual TResult WrapInvoke(object caller, Func func, /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. /// The result. - public Task InvokeAsync(object caller, Func> func, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + public Task InvokeAsync(object caller, Func> func, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) => WrapInvokeAsync(caller, func, param, memberName, filePath, lineNumber); /// @@ -124,7 +124,7 @@ public Task InvokeAsync(object caller, Func> fun /// The full path of the source file that contains the caller. /// The line number in the source file at which the method is called. /// The result. - protected virtual Task WrapInvokeAsync(object caller, Func> func, TParam param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) + protected virtual Task WrapInvokeAsync(object caller, Func> func, TParam? param = default, [CallerMemberName] string? memberName = null, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = 0) => Check.NotNull(func, nameof(func)).Invoke(); #endregion diff --git a/src/Beef.Data.Database/DatabaseWildcard.cs b/src/Beef.Data.Database/DatabaseWildcard.cs index c0e53636a..0056735fa 100644 --- a/src/Beef.Data.Database/DatabaseWildcard.cs +++ b/src/Beef.Data.Database/DatabaseWildcard.cs @@ -41,7 +41,9 @@ public class DatabaseWildcard /// The database single wildcard character. /// The list of characters that are to be escaped (defaults to ). /// The escaping format string when one of the is found (defaults to ). +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Somehow the compiler thinks CharactersToEscape can be null; so not true. public DatabaseWildcard(Wildcard? wildcard = null, char multiWildcard = MultiWildcardCharacter, char singleWildcard = SingleWildcardCharacter, +#pragma warning restore CS8618 char[]? charactersToEscape = null, string? escapeFormat = null) { Wildcard = wildcard ?? Wildcard.Default ?? Wildcard.MultiAll; diff --git a/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj b/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj index d6429ec87..d700c861f 100644 --- a/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj +++ b/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj @@ -4,7 +4,7 @@ Exe netcoreapp3.1 Beef.CodeGen - 4.1.11 + 4.1.12 false diff --git a/tools/Beef.CodeGen.Core/CHANGELOG.md b/tools/Beef.CodeGen.Core/CHANGELOG.md index 76b3846ea..46d6e17fb 100644 --- a/tools/Beef.CodeGen.Core/CHANGELOG.md +++ b/tools/Beef.CodeGen.Core/CHANGELOG.md @@ -2,6 +2,9 @@ Represents the **NuGet** versions. +## v4.1.12 +- *Fixed:* Issue [93](https://github.com/Avanade/Beef/issues/93) fixed. The `XxxServiceCollectionExtensions.cs` classes were errantly being generated where there are no corresponding operations that would require. + ## v4.1.11 - *Fixed:* Issue [91](https://github.com/Avanade/Beef/issues/91) fixed. `WebApiAuthorize` attribute code-gen output reverted back to pre-_Handlebars_ behaviour. Controller-level will only output where specified; will no longer default to `AllowAnonymous`. Method-level will only output where specified; will no longer default to parent (entity) value. diff --git a/tools/Beef.CodeGen.Core/Generators/EntitySceDataCodeGenerator.cs b/tools/Beef.CodeGen.Core/Generators/EntitySceDataCodeGenerator.cs new file mode 100644 index 000000000..526ab895f --- /dev/null +++ b/tools/Beef.CodeGen.Core/Generators/EntitySceDataCodeGenerator.cs @@ -0,0 +1,21 @@ +// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef + +using System.Collections.Generic; +using System.Linq; + +namespace Beef.CodeGen.Generators +{ + /// + /// Represents the Data Service Collection Extensions code generator; where not excluded and at least one operation exists. + /// + public class EntitySceDataCodeGenerator : CodeGeneratorBase + { + /// + /// + /// + /// + /// + protected override IEnumerable SelectGenConfig(Config.Entity.CodeGenConfig config) + => Check.NotNull(config, nameof(config)).Entities.Any(x => x.ExcludeData != "Yes" && x.Operations!.Count > 0) ? new Config.Entity.CodeGenConfig[] { config } : System.Array.Empty(); + } +} \ No newline at end of file diff --git a/tools/Beef.CodeGen.Core/Generators/EntitySceDataSvcCodeGenerator.cs b/tools/Beef.CodeGen.Core/Generators/EntitySceDataSvcCodeGenerator.cs new file mode 100644 index 000000000..bd5740a6a --- /dev/null +++ b/tools/Beef.CodeGen.Core/Generators/EntitySceDataSvcCodeGenerator.cs @@ -0,0 +1,21 @@ +// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef + +using System.Collections.Generic; +using System.Linq; + +namespace Beef.CodeGen.Generators +{ + /// + /// Represents the DataSvc Service Collection Extensions code generator; where not excluded and at least one operation exists. + /// + public class EntitySceDataSvcCodeGenerator : CodeGeneratorBase + { + /// + /// + /// + /// + /// + protected override IEnumerable SelectGenConfig(Config.Entity.CodeGenConfig config) + => Check.NotNull(config, nameof(config)).Entities.Any(x => IsFalse(x.ExcludeDataSvc) && x.Operations!.Count > 0) ? new Config.Entity.CodeGenConfig[] { config } : System.Array.Empty(); + } +} \ No newline at end of file diff --git a/tools/Beef.CodeGen.Core/Generators/EntitySceManagerCodeGenerator .cs b/tools/Beef.CodeGen.Core/Generators/EntitySceManagerCodeGenerator .cs new file mode 100644 index 000000000..78f2dfd98 --- /dev/null +++ b/tools/Beef.CodeGen.Core/Generators/EntitySceManagerCodeGenerator .cs @@ -0,0 +1,21 @@ +// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef + +using System.Collections.Generic; +using System.Linq; + +namespace Beef.CodeGen.Generators +{ + /// + /// Represents the Manager Service Collection Extensions code generator; where not excluded and at least one operation exists. + /// + public class EntitySceManagerCodeGenerator : CodeGeneratorBase + { + /// + /// + /// + /// + /// + protected override IEnumerable SelectGenConfig(Config.Entity.CodeGenConfig config) + => Check.NotNull(config, nameof(config)).Entities.Any(x => IsFalse(x.ExcludeManager) && x.Operations!.Count > 0) ? new Config.Entity.CodeGenConfig[] { config } : System.Array.Empty(); + } +} \ No newline at end of file diff --git a/tools/Beef.CodeGen.Core/Scripts/EntityBusiness.xml b/tools/Beef.CodeGen.Core/Scripts/EntityBusiness.xml index 851e4e414..f39316caf 100644 --- a/tools/Beef.CodeGen.Core/Scripts/EntityBusiness.xml +++ b/tools/Beef.CodeGen.Core/Scripts/EntityBusiness.xml @@ -14,7 +14,7 @@ - - - - + + + + \ No newline at end of file diff --git a/tools/Beef.CodeGen.Core/Scripts/EntityWebApiCoreAgent.xml b/tools/Beef.CodeGen.Core/Scripts/EntityWebApiCoreAgent.xml index 96e7b614d..fbb95749b 100644 --- a/tools/Beef.CodeGen.Core/Scripts/EntityWebApiCoreAgent.xml +++ b/tools/Beef.CodeGen.Core/Scripts/EntityWebApiCoreAgent.xml @@ -14,9 +14,9 @@ - - - + + +