From c5f7392aed7c546ee1f2de0fb956d980ef93bcbd Mon Sep 17 00:00:00 2001 From: Marc Gravell Date: Mon, 25 Sep 2023 20:29:17 +0100 Subject: [PATCH] fixup remaining tests (#58) * - fault handling - DAP037 (needs test+docs) * DAP037 tests; docs are no longer optional * args * fix rowcount change --- docs/rules/DAP037.md | 11 + .../DapperAnalyzer.Diagnostics.cs | 58 ++-- .../CodeAnalysis/DapperAnalyzer.cs | 73 +++-- .../DapperInterceptorGenerator.Diagnostics.cs | 12 +- .../DapperInterceptorGenerator.cs | 86 +++--- .../CodeAnalysis/Diagnostics.cs | 26 +- .../Internal/Inspection.cs | 21 +- .../Internal/MemberMap.cs | 37 ++- .../Interceptors/BaseCommandFactory.input.cs | 4 +- .../Interceptors/BaseCommandFactory.output.cs | 2 +- .../BaseCommandFactory.output.netfx.cs | 2 +- .../BaseCommandFactory.output.netfx.txt | 14 - .../BaseCommandFactory.output.txt | 14 - .../Interceptors/CacheCommand.output.cs | 8 +- .../Interceptors/CacheCommand.output.netfx.cs | 8 +- .../Interceptors/CommandProperties.output.cs | 10 +- .../CommandProperties.output.netfx.cs | 10 +- .../Interceptors/Execute.output.cs | 4 +- .../Interceptors/Execute.output.netfx.cs | 4 +- .../Interceptors/ExecuteBatch.output.cs | 18 +- .../Interceptors/ExecuteBatch.output.netfx.cs | 18 +- .../Interceptors/ExecuteScalar.output.cs | 8 +- .../ExecuteScalar.output.netfx.cs | 8 +- .../Interceptors/GlobalFetchSize.output.cs | 2 +- .../GlobalFetchSize.output.netfx.cs | 2 +- .../Interceptors/MappedSqlDetection.output.cs | 74 +---- .../MappedSqlDetection.output.netfx.cs | 74 +---- .../MappedSqlDetection.output.netfx.txt | 15 +- .../MappedSqlDetection.output.txt | 15 +- .../Interceptors/MiscDiagnostics.output.cs | 6 +- .../MiscDiagnostics.output.netfx.cs | 6 +- .../Interceptors/NonConstant.output.cs | 4 +- .../Interceptors/NonConstant.output.netfx.cs | 4 +- .../Interceptors/Query.output.cs | 10 +- .../Interceptors/Query.output.netfx.cs | 8 +- .../QueryCustomConstruction.output.cs | 262 +++++++++++++++++- .../QueryCustomConstruction.output.netfx.cs | 262 +++++++++++++++++- .../QueryCustomConstruction.output.netfx.txt | 16 -- .../QueryCustomConstruction.output.txt | 16 -- .../Interceptors/QueryDetection.output.cs | 6 +- .../QueryDetection.output.netfx.cs | 6 +- .../Interceptors/QueryNonGeneric.output.cs | 22 +- .../QueryNonGeneric.output.netfx.cs | 20 +- .../Interceptors/QueryUntyped.output.cs | 28 +- .../Interceptors/QueryUntyped.output.netfx.cs | 24 +- .../Interceptors/RowCountHint.output.cs | 4 +- .../Interceptors/RowCountHint.output.netfx.cs | 4 +- .../Interceptors/Single.output.cs | 12 +- .../Interceptors/Single.output.netfx.cs | 12 +- .../Interceptors/SqlDetection.output.cs | 8 +- .../Interceptors/SqlDetection.output.netfx.cs | 8 +- .../Interceptors/SqlParse.output.cs | 4 +- .../Interceptors/SqlParse.output.netfx.cs | 4 +- .../Interceptors/TsqlTips.output.cs | 6 +- .../Interceptors/TsqlTips.output.netfx.cs | 6 +- test/Dapper.AOT.Test/Verifiers/DAP017.cs | 9 +- test/Dapper.AOT.Test/Verifiers/DAP027.cs | 2 +- test/Dapper.AOT.Test/Verifiers/DAP028.cs | 2 +- test/Dapper.AOT.Test/Verifiers/DAP035.cs | 5 +- test/Dapper.AOT.Test/Verifiers/DAP036.cs | 6 +- test/Dapper.AOT.Test/Verifiers/DAP037.cs | 81 ++++++ test/Dapper.AOT.Test/Verifiers/DAP038.cs | 4 +- 62 files changed, 967 insertions(+), 548 deletions(-) create mode 100644 docs/rules/DAP037.md create mode 100644 test/Dapper.AOT.Test/Verifiers/DAP037.cs diff --git a/docs/rules/DAP037.md b/docs/rules/DAP037.md new file mode 100644 index 00000000..013ffa85 --- /dev/null +++ b/docs/rules/DAP037.md @@ -0,0 +1,11 @@ +# DAP037 + +When materializing results, Dapper needs to be able to assign values. It can do this in a range +of ways, including: + +- accessible fields that are not `readonly` +- accessible `set` accessors +- accessible `init` accessors +- constructors (using `[ExplicitConstructor]` to select if ambiguous) + +If there are *no* accessible members: you're not going to get very interesting results, hence this warning! \ No newline at end of file diff --git a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.Diagnostics.cs b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.Diagnostics.cs index f21eeb45..06b8735b 100644 --- a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.Diagnostics.cs +++ b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.Diagnostics.cs @@ -9,44 +9,44 @@ internal sealed class Diagnostics : DiagnosticsBase public static readonly DiagnosticDescriptor // general usage // 000: InterceptorsGenerated - UnsupportedMethod = LibraryInfo("DAP001", "Unsupported method", "The Dapper method '{0}' is not currently supported by Dapper.AOT", true), + UnsupportedMethod = LibraryInfo("DAP001", "Unsupported method", "The Dapper method '{0}' is not currently supported by Dapper.AOT"), // unused: DAP002 // 003: InterceptorsNotEnabled // 004: LanguageVersionTooLow - DapperAotNotEnabled = LibraryInfo("DAP005", "Dapper.AOT not enabled", "{0} candidate Dapper methods detected, but none have Dapper.AOT enabled", true), - DapperLegacyTupleParameter = LibraryWarning("DAP006", "Dapper tuple-type parameter", "Dapper (original) does not work well with tuple-type parameters as name information is inaccessible", true), - UnexpectedCommandType = LibraryInfo("DAP007", "Unexpected command type", "The command type specified is not understood", true), + DapperAotNotEnabled = LibraryInfo("DAP005", "Dapper.AOT not enabled", "{0} candidate Dapper methods detected, but none have Dapper.AOT enabled"), + DapperLegacyTupleParameter = LibraryWarning("DAP006", "Dapper tuple-type parameter", "Dapper (original) does not work well with tuple-type parameters as name information is inaccessible"), + UnexpectedCommandType = LibraryInfo("DAP007", "Unexpected command type", "The command type specified is not understood"), // unused: DAP008 - UnexpectedArgument = LibraryInfo("DAP009", "Unexpected parameter", "The parameter '{0}' is not understood", true), + UnexpectedArgument = LibraryInfo("DAP009", "Unexpected parameter", "The parameter '{0}' is not understood"), // unused: DAP010 - DapperLegacyBindNameTupleResults = LibraryWarning("DAP011", "Named-tuple results", "Dapper (original) does not support tuple results with bind-by-name semantics", true), - DapperAotAddBindTupleByName = LibraryWarning("DAP012", "Add BindTupleByName", "Because of differences in how Dapper and Dapper.AOT can process tuple-types, please add '[BindTupleByName({true|false})]' to clarify your intent", true), - DapperAotTupleResults = LibraryInfo("DAP013", "Tuple-type results", "Tuple-type results are not currently supported", true), - DapperAotTupleParameter = LibraryInfo("DAP014", "Tuple-type parameter", "Tuple-type parameters are not currently supported", true), - UntypedParameter = LibraryInfo("DAP015", "Untyped parameter", "The parameter type could not be resolved", true), - GenericTypeParameter = LibraryInfo("DAP016", "Generic type parameter", "Generic type parameters ({0}) are not currently supported", true), - NonPublicType = LibraryInfo("DAP017", "Non-accessible type", "Type '{0}' is not accessible; {1} types are not currently supported", true), - SqlParametersNotDetected = SqlWarning("DAP018", "SQL parameters not detected", "Parameters are being supplied, but no parameters were detected in the command", true), + DapperLegacyBindNameTupleResults = LibraryWarning("DAP011", "Named-tuple results", "Dapper (original) does not support tuple results with bind-by-name semantics"), + DapperAotAddBindTupleByName = LibraryWarning("DAP012", "Add BindTupleByName", "Because of differences in how Dapper and Dapper.AOT can process tuple-types, please add '[BindTupleByName({true|false})]' to clarify your intent"), + DapperAotTupleResults = LibraryInfo("DAP013", "Tuple-type results", "Tuple-type results are not currently supported"), + DapperAotTupleParameter = LibraryInfo("DAP014", "Tuple-type parameter", "Tuple-type parameters are not currently supported"), + UntypedParameter = LibraryInfo("DAP015", "Untyped parameter", "The parameter type could not be resolved"), + GenericTypeParameter = LibraryInfo("DAP016", "Generic type parameter", "Generic type parameters ({0}) are not currently supported"), + NonPublicType = LibraryInfo("DAP017", "Non-accessible type", "Type '{0}' is not accessible; {1} types are not currently supported"), + SqlParametersNotDetected = SqlWarning("DAP018", "SQL parameters not detected", "Parameters are being supplied, but no parameters were detected in the command"), // unused: DAP019 // unused: DAP020 - DuplicateParameter = LibraryWarning("DAP021", "Duplicate parameter", "Members '{0}' and '{1}' both have the database name '{2}'; '{1}' will be ignored", true), - DuplicateReturn = LibraryWarning("DAP022", "Duplicate return parameter", "Members '{0}' and '{1}' are both designated as return values; '{1}' will be ignored", true), - DuplicateRowCount = LibraryWarning("DAP023", "Duplicate row-count member", "Members '{0}' and '{1}' are both marked [RowCount]", true), - RowCountDbValue = LibraryWarning("DAP024", "Member is both row-count and mapped value", "Member '{0}' is marked both [RowCount] and [DbValue]; [DbValue] will be ignored", true), - ExecuteCommandWithQuery = SqlWarning("DAP025", "Execute command with query", "The command has a query that will be ignored", true), - QueryCommandMissingQuery = SqlError("DAP026", "Query/scalar command lacks query", "The command lacks a query", true), - UseSingleRowQuery = PerformanceWarning("DAP027", "Use single-row query", "Use {0}() instead of Query(...).{1}()", true), - UseQueryAsList = PerformanceWarning("DAP028", "Use AsList instead of ToList", "Use Query(...).AsList() instead of Query(...).ToList()", true), - RowCountHintRedundant = LibraryInfo("DAP029", "Row-count hint redundant", "The method-level [RowCountHint] will be ignored due to parameter member '{0}'", true), - RowCountHintInvalidValue = LibraryError("DAP030", "Row-count hint invalid value", "The [RowCountHint] parameters are invalid; a positive integer must be supplied", true), - RowCountHintShouldNotSpecifyValue = LibraryError("DAP031", "Row-count hint should not specify value", "The [RowCountHint] parameters are invalid; no parameter should be supplied", true), - RowCountHintDuplicated = LibraryError("DAP032", "Row-count hint duplicated", "Only a single member or parameter should be marked [RowCountHint]; '{0} will be ignored", true), + DuplicateParameter = LibraryWarning("DAP021", "Duplicate parameter", "Members '{0}' and '{1}' both have the database name '{2}'; '{1}' will be ignored"), + DuplicateReturn = LibraryWarning("DAP022", "Duplicate return parameter", "Members '{0}' and '{1}' are both designated as return values; '{1}' will be ignored"), + DuplicateRowCount = LibraryWarning("DAP023", "Duplicate row-count member", "Members '{0}' and '{1}' are both marked [RowCount]"), + RowCountDbValue = LibraryWarning("DAP024", "Member is both row-count and mapped value", "Member '{0}' is marked both [RowCount] and [DbValue]; [DbValue] will be ignored"), + ExecuteCommandWithQuery = SqlWarning("DAP025", "Execute command with query", "The command has a query that will be ignored"), + QueryCommandMissingQuery = SqlError("DAP026", "Query/scalar command lacks query", "The command lacks a query"), + UseSingleRowQuery = PerformanceWarning("DAP027", "Use single-row query", "Use {0}() instead of Query(...).{1}()"), + UseQueryAsList = PerformanceWarning("DAP028", "Use AsList instead of ToList", "Use Query(...).AsList() instead of Query(...).ToList()"), + RowCountHintRedundant = LibraryInfo("DAP029", "Row-count hint redundant", "The method-level [RowCountHint] will be ignored due to parameter member '{0}'"), + RowCountHintInvalidValue = LibraryError("DAP030", "Row-count hint invalid value", "The [RowCountHint] parameters are invalid; a positive integer must be supplied"), + RowCountHintShouldNotSpecifyValue = LibraryError("DAP031", "Row-count hint should not specify value", "The [RowCountHint] parameters are invalid; no parameter should be supplied"), + RowCountHintDuplicated = LibraryError("DAP032", "Row-count hint duplicated", "Only a single member or parameter should be marked [RowCountHint]; '{0} will be ignored"), // 033: CommandPropertyNotFound // 034: CommandPropertyReserved - ConstructorMultipleExplicit = LibraryError("DAP035", "Multiple explicit constructors", "Only one constructor should be marked [ExplicitConstructor] for type '{0}'", true), - ConstructorAmbiguous = LibraryError("DAP036", "Ambiguous constructors", "Type '{0}' has more than 1 constructor; mark one constructor with [ExplicitConstructor] or reduce constructors", true), - // 037: UserTypeNoSettableMembersFound - ValueTypeSingleFirstOrDefaultUsage = LibraryWarning("DAP038", "Value-type single row 'OrDefault' usage", "Type '{0}' is a value-type; it will not be trivial to identify missing rows from {1}", true), + ConstructorMultipleExplicit = LibraryError("DAP035", "Multiple explicit constructors", "Only one constructor should be marked [ExplicitConstructor] for type '{0}'"), + ConstructorAmbiguous = LibraryError("DAP036", "Ambiguous constructors", "Type '{0}' has more than 1 constructor; mark one constructor with [ExplicitConstructor] or reduce constructors"), + UserTypeNoSettableMembersFound = LibraryError("DAP037", "No settable members exist for user type", "Type '{0}' has no settable fields or properties"), + ValueTypeSingleFirstOrDefaultUsage = LibraryWarning("DAP038", "Value-type single row 'OrDefault' usage", "Type '{0}' is a value-type; it will not be trivial to identify missing rows from {1}"), // SQL parse specific GeneralSqlError = SqlWarning("DAP200", "SQL error", "SQL error: {0}"), diff --git a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.cs b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.cs index 05f45740..477c42b2 100644 --- a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.cs +++ b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.cs @@ -83,21 +83,28 @@ private void OnDapperAotMiss(Location location) internal void OnCompilationEndAction(CompilationAnalysisContext ctx) { - lock (_missedOpportunities) + try { - var count = _missedOpportunities.Count; - if (count != 0) + lock (_missedOpportunities) { - var location = _missedOpportunities[0]; - Location[]? additionalLocations = null; - if (count > 1) + var count = _missedOpportunities.Count; + if (count != 0) { - additionalLocations = new Location[count - 1]; - _missedOpportunities.CopyTo(1, additionalLocations, 0, count - 1); + var location = _missedOpportunities[0]; + Location[]? additionalLocations = null; + if (count > 1) + { + additionalLocations = new Location[count - 1]; + _missedOpportunities.CopyTo(1, additionalLocations, 0, count - 1); + } + ctx.ReportDiagnostic(Diagnostic.Create(Diagnostics.DapperAotNotEnabled, location, additionalLocations, count)); } - ctx.ReportDiagnostic(Diagnostic.Create(Diagnostics.DapperAotNotEnabled, location, additionalLocations, count)); } } + catch (Exception ex) + { + ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticsBase.UnknownError, null, ex.Message, ex.StackTrace)); + } } public void OnOperation(OperationAnalysisContext ctx) @@ -185,31 +192,41 @@ private void ValidateDapperMethod(in OperationAnalysisContext ctx, IOperation sq } // check the types - var resultMap = MemberMap.Create(invoke.GetResultType(flags), location); - if (resultMap is not null) + var resultType = invoke.GetResultType(flags); + if (resultType is not null && IdentifyDbType(resultType, out _) is null) // don't warn if handled as an inbuilt { - // check for single-row value-type usage - if (flags.HasAny(OperationFlags.SingleRow) && !flags.HasAny(OperationFlags.AtLeastOne) - && resultMap.ElementType.IsValueType && !CouldBeNullable(resultMap.ElementType)) + var resultMap = MemberMap.CreateForResults(resultType, location); + if (resultMap is not null) { - ctx.ReportDiagnostic(Diagnostic.Create(Diagnostics.ValueTypeSingleFirstOrDefaultUsage, location, resultMap.ElementType.Name, invoke.TargetMethod.Name)); - } + // check for single-row value-type usage + if (flags.HasAny(OperationFlags.SingleRow) && !flags.HasAny(OperationFlags.AtLeastOne) + && resultMap.ElementType.IsValueType && !CouldBeNullable(resultMap.ElementType)) + { + ctx.ReportDiagnostic(Diagnostic.Create(Diagnostics.ValueTypeSingleFirstOrDefaultUsage, location, resultMap.ElementType.Name, invoke.TargetMethod.Name)); + } - // check for constructors on the materialized type - DiagnosticDescriptor? ctorFault = ChooseConstructor(resultMap.ElementType, out var ctor) switch - { - ConstructorResult.FailMultipleExplicit => Diagnostics.ConstructorMultipleExplicit, - ConstructorResult.FailMultipleImplicit when aotEnabled => Diagnostics.ConstructorAmbiguous, - _ => null, - }; - if (ctorFault is not null) - { - var loc = ctor?.Locations.FirstOrDefault() ?? resultMap.ElementType.Locations.FirstOrDefault(); - ctx.ReportDiagnostic(Diagnostic.Create(ctorFault, loc, resultMap.ElementType.GetDisplayString())); + // check for constructors on the materialized type + DiagnosticDescriptor? ctorFault = ChooseConstructor(resultMap.ElementType, out var ctor) switch + { + ConstructorResult.FailMultipleExplicit => Diagnostics.ConstructorMultipleExplicit, + ConstructorResult.FailMultipleImplicit when aotEnabled => Diagnostics.ConstructorAmbiguous, + _ => null, + }; + if (ctorFault is not null) + { + var loc = ctor?.Locations.FirstOrDefault() ?? resultMap.ElementType.Locations.FirstOrDefault(); + ctx.ReportDiagnostic(Diagnostic.Create(ctorFault, loc, resultMap.ElementType.GetDisplayString())); + } + else if (resultMap.Members.IsDefaultOrEmpty && IsPublicOrAssemblyLocal(resultType, parseState, out _)) + { + // there are so settable members + there is no constructor to use + // (note: generator uses Inspection.GetMembers(type, dapperAotConstructor: constructor) + ctx.ReportDiagnostic(Diagnostic.Create(Diagnostics.UserTypeNoSettableMembersFound, resultMap.Location, resultType.Name)); + } } } - var parameters = MemberMap.Create(argExpression); + var parameters = MemberMap.CreateForParameters(argExpression); if (aotEnabled) { _ = AdditionalCommandState.Parse(GetSymbol(parseState, invoke), parameters, onDiagnostic); diff --git a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.Diagnostics.cs b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.Diagnostics.cs index 64af7d9d..bd19e768 100644 --- a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.Diagnostics.cs +++ b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.Diagnostics.cs @@ -8,15 +8,13 @@ internal sealed class Diagnostics : DiagnosticsBase { internal static readonly DiagnosticDescriptor - InterceptorsGenerated = LibraryHidden("DAP000", "Interceptors generated", "Dapper.AOT handled {0} of {1} possible call-sites using {2} interceptors, {3} commands and {4} readers", true), + InterceptorsGenerated = LibraryHidden("DAP000", "Interceptors generated", "Dapper.AOT handled {0} of {1} possible call-sites using {2} interceptors, {3} commands and {4} readers"), InterceptorsNotEnabled = LibraryWarning("DAP003", "Interceptors not enabled", - "Interceptors need to be enabled", true), - LanguageVersionTooLow = LibraryWarning("DAP004", "Language version too low", "Interceptors require at least C# version 11", true), + "Interceptors need to be enabled"), + LanguageVersionTooLow = LibraryWarning("DAP004", "Language version too low", "Interceptors require at least C# version 11"), - CommandPropertyNotFound = LibraryWarning("DAP033", "Command property not found", "Command property {0}.{1} was not found or was not valid; attribute will be ignored",true), - CommandPropertyReserved = LibraryWarning("DAP034", "Command property reserved", "Command property {1} is reserved for internal usage; attribute will be ignored", true), - - UserTypeNoSettableMembersFound = LibraryError("DAP037", "No settable members exist for user type", "Type '{0}' has no settable members (fields or properties)"); + CommandPropertyNotFound = LibraryWarning("DAP033", "Command property not found", "Command property {0}.{1} was not found or was not valid; attribute will be ignored"), + CommandPropertyReserved = LibraryWarning("DAP034", "Command property reserved", "Command property {1} is reserved for internal usage; attribute will be ignored"); } } diff --git a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.cs b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.cs index c0225260..6ff8fd47 100644 --- a/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.cs +++ b/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.cs @@ -53,9 +53,19 @@ internal bool PreFilter(SyntaxNode node, CancellationToken cancellationToken) } private SourceState? Parse(GeneratorSyntaxContext ctx, CancellationToken cancellationToken) - => Parse(new(ctx, cancellationToken)); + { + try + { + return Parse(new(ctx, cancellationToken)); + } + catch (Exception ex) + { + Debug.Fail(ex.Message); + return null; + } + } [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Chosen API")] - internal SourceState? Parse(in ParseState ctx) + internal SourceState? Parse(ParseState ctx) { if (ctx.Node is not InvocationExpressionSyntax ie || ctx.SemanticModel.GetOperation(ie) is not IInvocationOperation op @@ -77,7 +87,7 @@ internal bool PreFilter(SyntaxNode node, CancellationToken cancellationToken) // additional result-type checks // perform SQL inspection - var map = MemberMap.Create(argExpression); + var map = MemberMap.CreateForParameters(argExpression); var parameterMap = BuildParameterMap(ctx, op, sql, ref flags, map, location, out var parseFlags); if (flags.HasAny(OperationFlags.CacheCommand)) @@ -188,8 +198,18 @@ private static bool CheckPrerequisites(in GenerateState ctx) } private void Generate(SourceProductionContext ctx, (Compilation Compilation, ImmutableArray Nodes) state) - => Generate(new(ctx, state)); + { + try + { + Generate(new(ctx, state)); + } + catch (Exception ex) + { + ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticsBase.UnknownError, null, ex.Message, ex.StackTrace)); + } + } + const string DapperBaseCommandFactory = "global::Dapper.CommandFactory"; internal void Generate(in GenerateState ctx) { if (!CheckPrerequisites(ctx)) // also reports per-item diagnostics @@ -302,7 +322,6 @@ internal void Generate(in GenerateState ctx) } } - const string DapperBaseCommandFactory = "global::Dapper.CommandFactory"; var baseCommandFactory = GetCommandFactory(ctx.Compilation, out var canConstruct) ?? DapperBaseCommandFactory; if (needsCommandPrep || !canConstruct) { @@ -420,18 +439,21 @@ private static void WriteCommandFactory(in GenerateState ctx, string baseFactory sb.Outdent().NewLine(); - if ((flags & WriteArgsFlags.NeedsPostProcess) != 0) - { - sb.Append("public override void PostProcess(global::System.Data.Common.DbCommand cmd, ").Append(declaredType).Append(" args)").Indent().NewLine(); - WriteArgs(type, sb, WriteArgsMode.PostProcess, map, ref flags); - sb.Outdent().NewLine(); - } - - if ((flags & WriteArgsFlags.NeedsRowCount) != 0) + if ((flags & (WriteArgsFlags.NeedsPostProcess | WriteArgsFlags.NeedsRowCount)) != 0) { sb.Append("public override void PostProcess(global::System.Data.Common.DbCommand cmd, ").Append(declaredType).Append(" args, int rowCount)").Indent().NewLine(); - WriteArgs(type, sb, WriteArgsMode.SetRowCount, map, ref flags); - sb.Append("PostProcess(cmd, args);"); + if ((flags & WriteArgsFlags.NeedsPostProcess) != 0) + { + WriteArgs(type, sb, WriteArgsMode.PostProcess, map, ref flags); + } + if ((flags & WriteArgsFlags.NeedsRowCount) != 0) + { + WriteArgs(type, sb, WriteArgsMode.SetRowCount, map, ref flags); + } + if (baseFactory != DapperBaseCommandFactory) + { + sb.Append("base.PostProcess(cmd, args, rowCount);").NewLine(); + } sb.Outdent().NewLine(); } } @@ -611,26 +633,13 @@ static bool IsReserved(string name) private static void WriteRowFactory(in GenerateState context, CodeWriter sb, ITypeSymbol type, int index) { - var ctorType = Inspection.ChooseConstructor(type, out var constructor); - if (ctorType is Inspection.ConstructorResult.FailMultipleImplicit or Inspection.ConstructorResult.FailMultipleExplicit) - { - // error is emitted, but we still generate default RowFactory to not emit more errors for this type - WriteRowFactoryHeader(); - WriteRowFactoryFooter(); - - return; - } - bool hasExplicitConstructor = ctorType == Inspection.ConstructorResult.SuccessSingleExplicit - && constructor is not null; + var map = MemberMap.CreateForResults(type); + if (map is null) return; - var members = Inspection.GetMembers(type, dapperAotConstructor: constructor); - var membersCount = members.Length; + var members = map.Members; - if (membersCount == 0 && !hasExplicitConstructor) + if (members.IsDefaultOrEmpty && map.Constructor is null) { - // there are so settable members + there is no constructor to use - context.ReportDiagnostic(Diagnostic.Create(Diagnostics.UserTypeNoSettableMembersFound, type.Locations.First(), type.ToDisplayString())); - // error is emitted, but we still generate default RowFactory to not emit more errors for this type WriteRowFactoryHeader(); WriteRowFactoryFooter(); @@ -640,7 +649,7 @@ private static void WriteRowFactory(in GenerateState context, CodeWriter sb, ITy var hasInitOnlyMembers = members.Any(member => member.IsInitOnly); var hasGetOnlyMembers = members.Any(member => member.IsGettable && !member.IsSettable && !member.IsInitOnly); - var useDeferredConstruction = hasExplicitConstructor || hasInitOnlyMembers || hasGetOnlyMembers; + var useDeferredConstruction = map.Constructor is not null || hasInitOnlyMembers || hasGetOnlyMembers; WriteRowFactoryHeader(); @@ -678,7 +687,7 @@ void WriteTokenizeMethod() .Append(" when NormalizedEquals(name, ") .AppendVerbatimLiteral(StringHashing.Normalize(dbName)).Append("):").Indent(false).NewLine() .Append("token = type == typeof(").Append(Inspection.MakeNonNullable(member.CodeType)).Append(") ? ").Append(token) - .Append(" : ").Append(token + membersCount).Append(";") + .Append(" : ").Append(token + map.Members.Length).Append(";") .Append(token == 0 ? " // two tokens for right-typed and type-flexible" : "").NewLine() .Append("break;").Outdent(false).NewLine(); token++; @@ -758,7 +767,7 @@ void WriteReadMethod() sb.NewLine().Append("break;").NewLine().Outdent(false) - .Append("case ").Append(token + membersCount).Append(":").NewLine().Indent(false); + .Append("case ").Append(token + map.Members.Length).Append(":").NewLine().Indent(false); // write `result.X = ` or `member0 = ` if (useDeferredConstruction) sb.Append(DeferredConstructionVariableName).Append(token); @@ -787,7 +796,7 @@ void WriteReadMethod() // ``` sb.Append("return new ").Append(type); - if (hasExplicitConstructor && constructorArgumentsOrdered.Count != 0) + if (map.Constructor is not null && constructorArgumentsOrdered.Count != 0) { // write `(member0, member1, member2, ...)` part of constructor sb.Append('('); @@ -862,7 +871,10 @@ private static void WriteArgs(ITypeSymbol? parameterType, CodeWriter sb, WriteAr bool first = true, firstTest = true; int parameterIndex = 0; - foreach (var member in Inspection.GetMembers(parameterType)) + var memberMap = MemberMap.CreateForParameters(parameterType); + if (memberMap is null or { Members.IsDefaultOrEmpty: true }) return; + + foreach (var member in memberMap.Members) { if (member.IsRowCount) { diff --git a/src/Dapper.AOT.Analyzers/CodeAnalysis/Diagnostics.cs b/src/Dapper.AOT.Analyzers/CodeAnalysis/Diagnostics.cs index b80e35be..13969baa 100644 --- a/src/Dapper.AOT.Analyzers/CodeAnalysis/Diagnostics.cs +++ b/src/Dapper.AOT.Analyzers/CodeAnalysis/Diagnostics.cs @@ -9,33 +9,33 @@ namespace Dapper.CodeAnalysis; internal abstract class DiagnosticsBase { - public static readonly DiagnosticDescriptor UnknownError = LibraryWarning("DAP999", "Unknown analyzer error", "This isn't you; this is me; please log it! '{0}', '{1}'", true); + public static readonly DiagnosticDescriptor UnknownError = LibraryWarning("DAP999", "Unknown analyzer error", "This isn't you; this is me; please log it! '{0}', '{1}'"); protected const string DocsRoot = "https://aot.dapperlib.dev/", RulesRoot = DocsRoot + "rules/"; - private static DiagnosticDescriptor Create(string id, string title, string messageFormat, string category, DiagnosticSeverity severity, bool docs) => + private static DiagnosticDescriptor Create(string id, string title, string messageFormat, string category, DiagnosticSeverity severity) => new(id, title, - messageFormat, category, severity, true, helpLinkUri: docs ? (RulesRoot + id) : null); + messageFormat, category, severity, true, helpLinkUri: RulesRoot + id); - protected static DiagnosticDescriptor LibraryWarning(string id, string title, string messageFormat, bool docs = false) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Warning, docs); + protected static DiagnosticDescriptor LibraryWarning(string id, string title, string messageFormat) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Warning); - protected static DiagnosticDescriptor LibraryError(string id, string title, string messageFormat, bool docs = false) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Error, docs); + protected static DiagnosticDescriptor LibraryError(string id, string title, string messageFormat) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Error); - protected static DiagnosticDescriptor LibraryHidden(string id, string title, string messageFormat, bool docs = false) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Hidden, docs); + protected static DiagnosticDescriptor LibraryHidden(string id, string title, string messageFormat) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Hidden); - protected static DiagnosticDescriptor LibraryInfo(string id, string title, string messageFormat, bool docs = false) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Info, docs); + protected static DiagnosticDescriptor LibraryInfo(string id, string title, string messageFormat) => Create(id, title, messageFormat, Category.Library, DiagnosticSeverity.Info); - protected static DiagnosticDescriptor SqlWarning(string id, string title, string messageFormat, bool docs = true) => Create(id, title, messageFormat, Category.Sql, DiagnosticSeverity.Warning, docs); + protected static DiagnosticDescriptor SqlWarning(string id, string title, string messageFormat, bool docs = true) => Create(id, title, messageFormat, Category.Sql, DiagnosticSeverity.Warning); - protected static DiagnosticDescriptor SqlError(string id, string title, string messageFormat, bool docs = true) => Create(id, title, messageFormat, Category.Sql, DiagnosticSeverity.Error, docs); + protected static DiagnosticDescriptor SqlError(string id, string title, string messageFormat, bool docs = true) => Create(id, title, messageFormat, Category.Sql, DiagnosticSeverity.Error); - protected static DiagnosticDescriptor SqlInfo(string id, string title, string messageFormat, bool docs = true) => Create(id, title, messageFormat, Category.Sql, DiagnosticSeverity.Info, docs); + protected static DiagnosticDescriptor SqlInfo(string id, string title, string messageFormat, bool docs = true) => Create(id, title, messageFormat, Category.Sql, DiagnosticSeverity.Info); - protected static DiagnosticDescriptor PerformanceWarning(string id, string title, string messageFormat, bool docs = false) => Create(id, title, messageFormat, Category.Performance, DiagnosticSeverity.Warning, docs); + protected static DiagnosticDescriptor PerformanceWarning(string id, string title, string messageFormat) => Create(id, title, messageFormat, Category.Performance, DiagnosticSeverity.Warning); - protected static DiagnosticDescriptor PerformanceError(string id, string title, string messageFormat, bool docs = false) => Create(id, title, messageFormat, Category.Performance, DiagnosticSeverity.Error, docs); + protected static DiagnosticDescriptor PerformanceError(string id, string title, string messageFormat) => Create(id, title, messageFormat, Category.Performance, DiagnosticSeverity.Error); - protected static DiagnosticDescriptor PerformanceInfo(string id, string title, string messageFormat, bool docs = false) => Create(id, title, messageFormat, Category.Performance, DiagnosticSeverity.Info, docs); + protected static DiagnosticDescriptor PerformanceInfo(string id, string title, string messageFormat) => Create(id, title, messageFormat, Category.Performance, DiagnosticSeverity.Info); private static ImmutableDictionary? _idsToFieldNames; public static bool TryGetFieldName(string id, out string field) diff --git a/src/Dapper.AOT.Analyzers/Internal/Inspection.cs b/src/Dapper.AOT.Analyzers/Internal/Inspection.cs index f5611213..1417f354 100644 --- a/src/Dapper.AOT.Analyzers/Internal/Inspection.cs +++ b/src/Dapper.AOT.Analyzers/Internal/Inspection.cs @@ -573,10 +573,10 @@ internal static ConstructorResult ChooseConstructor(ITypeSymbol? typeSymbol, out /// /// Yields the type's members. - /// If is passed, will be used to associate element member with the constructor parameter by name (case-insensitive). + /// If is passed, will be used to associate element member with the constructor parameter by name (case-insensitive). /// /// type, which elements to parse - public static ImmutableArray GetMembers(ITypeSymbol? elementType, IMethodSymbol? dapperAotConstructor = null) + internal static ImmutableArray GetMembers(bool forParameters, ITypeSymbol? elementType, IMethodSymbol? constructor) { if (elementType is null) { @@ -590,7 +590,7 @@ public static ImmutableArray GetMembers(ITypeSymbol? elementType, { var elMembers = elementType.GetMembers(); var builder = ImmutableArray.CreateBuilder(elMembers.Length); - var constructorParameters = (dapperAotConstructor is not null) ? ParseConstructorParameters(dapperAotConstructor) : null; + var constructorParameters = (constructor is not null) ? ParseConstructorParameters(constructor) : null; foreach (var member in elMembers) { // instance only, must be able to access by name @@ -627,6 +627,7 @@ public static ImmutableArray GetMembers(ITypeSymbol? elementType, default: continue; } + if (memberType is null) continue; int? constructorParameterOrder = constructorParameters?.TryGetValue(member.Name, out var constructorParameter) == true ? constructorParameter.Order @@ -637,8 +638,20 @@ public static ImmutableArray GetMembers(ITypeSymbol? elementType, if (CodeWriter.IsSettableInstanceMember(member, out _)) flags |= ElementMember.ElementMemberFlags.IsSettable; if (CodeWriter.IsInitOnlyInstanceMember(member, out _)) flags |= ElementMember.ElementMemberFlags.IsInitOnly; + if (forParameters) + { + // needs to be readable + if ((flags & ElementMember.ElementMemberFlags.IsGettable) == 0) continue; + } + else + { + // needs to be writable + if (constructorParameterOrder is null && + (flags & (ElementMember.ElementMemberFlags.IsSettable | ElementMember.ElementMemberFlags.IsInitOnly)) == 0) continue; + } + // see Dapper's TryStringSplit logic - if (memberType is not null && IsCollectionType(memberType, out var innerType) && innerType is not null) + if (IsCollectionType(memberType, out var innerType) && innerType is not null) { flags |= ElementMember.ElementMemberFlags.IsExpandable; } diff --git a/src/Dapper.AOT.Analyzers/Internal/MemberMap.cs b/src/Dapper.AOT.Analyzers/Internal/MemberMap.cs index 82b9943c..686cac73 100644 --- a/src/Dapper.AOT.Analyzers/Internal/MemberMap.cs +++ b/src/Dapper.AOT.Analyzers/Internal/MemberMap.cs @@ -1,5 +1,6 @@ using Microsoft.CodeAnalysis; using System.Collections.Immutable; +using System.Linq; using static Dapper.Internal.Inspection; namespace Dapper.Internal; @@ -28,28 +29,31 @@ enum MapFlags IsCollection = 1 << 2, } - public static MemberMap? Create(IOperation? parameters) - => parameters is null or { Type: null} ? null : new (parameters.Syntax.GetLocation(), parameters.Type, parameters); + public static MemberMap? CreateForParameters(IOperation? parameters) + => parameters is null or { Type: null} ? null : new (true, parameters.Syntax.GetLocation(), parameters.Type, parameters); - public static MemberMap? Create(ITypeSymbol? type, Location location) - => type is null ? null : new(location, type, null); + public static MemberMap? CreateForResults(ITypeSymbol? type, Location? location = null) + => type is null ? null : new(false, location, type, null); + + public static MemberMap? CreateForParameters(ITypeSymbol? type, Location? location = null) + => type is null ? null : new(true, location, type, null); public IOperation? Parameters { get; } - public Location Location { get; } + public Location? Location { get; } - private MemberMap(Location location, ITypeSymbol declaredType, IOperation? parameters) + private MemberMap(bool forParameters, Location? location, ITypeSymbol declaredType, IOperation? parameters) { Parameters = parameters; - Location = location; ElementType = DeclaredType = declaredType; - - if (parameters is not null && IsCollectionType(declaredType, out var elementType, out var castType) + Location = location ?? declaredType.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation(); + if (forParameters && IsCollectionType(declaredType, out var elementType, out var castType) && elementType is not null) { ElementType = elementType; CSharpCastType = castType; _flags |= MapFlags.IsCollection; } + if (IsMissingOrObjectOrDynamic(ElementType)) { _flags |= MapFlags.IsObject; @@ -58,14 +62,17 @@ private MemberMap(Location location, ITypeSymbol declaredType, IOperation? param { _flags |= MapFlags.IsDapperDynamic; } - switch (ChooseConstructor(ElementType, out var constructor)) + if (!forParameters) { - case ConstructorResult.SuccessSingleImplicit: - case ConstructorResult.SuccessSingleExplicit: - Constructor = constructor; - break; + switch (ChooseConstructor(ElementType, out var constructor)) + { + case ConstructorResult.SuccessSingleImplicit: + case ConstructorResult.SuccessSingleExplicit: + Constructor = constructor; + break; + } } - Members = GetMembers(ElementType, constructor); + Members = GetMembers(forParameters, ElementType, Constructor); } static bool IsDynamicParameters(ITypeSymbol? type) diff --git a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.input.cs b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.input.cs index 04f823ca..da7a7be1 100644 --- a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.input.cs +++ b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.input.cs @@ -25,10 +25,10 @@ public override DbCommand GetCommand(DbConnection connection, string sql, Comman return base.GetCommand(connection, sql, commandType, args); } - public override void PostProcess(DbCommand command, T args) + public override void PostProcess(DbCommand command, T args, int rowcount) { Console.WriteLine(nameof(PostProcess)); - base.PostProcess(command, args); + base.PostProcess(command, args, rowcount); } } } \ No newline at end of file diff --git a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.cs b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.cs index 29cec504..b44884ea 100644 --- a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\BaseCommandFactory.input.cs", 14, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.cs index 29cec504..b44884ea 100644 --- a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\BaseCommandFactory.input.cs", 14, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.txt b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.txt index 842954d1..6aee302d 100644 --- a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.txt +++ b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.netfx.txt @@ -1,18 +1,4 @@ -Input code has 2 diagnostics from 'Interceptors/BaseCommandFactory.input.cs': - -Error CS0115 Interceptors/BaseCommandFactory.input.cs L28 C30 -'MyCommandFactory.PostProcess(DbCommand, T)': no suitable method found to override - -Error CS7036 Interceptors/BaseCommandFactory.input.cs L31 C18 -There is no argument given that corresponds to the required parameter 'rowCount' of 'CommandFactory.PostProcess(DbCommand, T, int)' Generator produced 1 diagnostics: Hidden DAP000 L1 C1 Dapper.AOT handled 1 of 1 possible call-sites using 1 interceptors, 1 commands and 0 readers -Output code has 2 diagnostics from 'Interceptors/BaseCommandFactory.input.cs': - -Error CS0115 Interceptors/BaseCommandFactory.input.cs L28 C30 -'MyCommandFactory.PostProcess(DbCommand, T)': no suitable method found to override - -Error CS7036 Interceptors/BaseCommandFactory.input.cs L31 C18 -There is no argument given that corresponds to the required parameter 'rowCount' of 'CommandFactory.PostProcess(DbCommand, T, int)' diff --git a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.txt b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.txt index 842954d1..6aee302d 100644 --- a/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.txt +++ b/test/Dapper.AOT.Test/Interceptors/BaseCommandFactory.output.txt @@ -1,18 +1,4 @@ -Input code has 2 diagnostics from 'Interceptors/BaseCommandFactory.input.cs': - -Error CS0115 Interceptors/BaseCommandFactory.input.cs L28 C30 -'MyCommandFactory.PostProcess(DbCommand, T)': no suitable method found to override - -Error CS7036 Interceptors/BaseCommandFactory.input.cs L31 C18 -There is no argument given that corresponds to the required parameter 'rowCount' of 'CommandFactory.PostProcess(DbCommand, T, int)' Generator produced 1 diagnostics: Hidden DAP000 L1 C1 Dapper.AOT handled 1 of 1 possible call-sites using 1 interceptors, 1 commands and 0 readers -Output code has 2 diagnostics from 'Interceptors/BaseCommandFactory.input.cs': - -Error CS0115 Interceptors/BaseCommandFactory.input.cs L28 C30 -'MyCommandFactory.PostProcess(DbCommand, T)': no suitable method found to override - -Error CS7036 Interceptors/BaseCommandFactory.input.cs L31 C18 -There is no argument given that corresponds to the required parameter 'rowCount' of 'CommandFactory.PostProcess(DbCommand, T, int)' diff --git a/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.cs b/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.cs index 8b4578ad..960c3567 100644 --- a/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 15, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text, CacheCommand + // Execute, HasParameters, Text, CacheCommand, KnownParameters // takes parameter: // parameter map: bar id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -18,7 +18,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 16, 24)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text, CacheCommand + // Execute, HasParameters, Text, CacheCommand, KnownParameters // takes parameter: // parameter map: bar id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -32,7 +32,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 19, 24)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text, CacheCommand + // Execute, HasParameters, Text, CacheCommand, KnownParameters // takes parameter: // parameter map: id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -46,7 +46,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 22, 24)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: // parameter map: (deferred) global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.netfx.cs index 8b4578ad..960c3567 100644 --- a/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/CacheCommand.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 15, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text, CacheCommand + // Execute, HasParameters, Text, CacheCommand, KnownParameters // takes parameter: // parameter map: bar id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -18,7 +18,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 16, 24)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text, CacheCommand + // Execute, HasParameters, Text, CacheCommand, KnownParameters // takes parameter: // parameter map: bar id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -32,7 +32,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 19, 24)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text, CacheCommand + // Execute, HasParameters, Text, CacheCommand, KnownParameters // takes parameter: // parameter map: id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -46,7 +46,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 22, 24)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: // parameter map: (deferred) global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.cs b/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.cs index 6ec1667e..9444d402 100644 --- a/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -20,7 +20,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 16, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -36,7 +36,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -52,7 +52,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 23, 24)] internal static global::System.Collections.Generic.IEnumerable Query3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -69,7 +69,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 26, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.netfx.cs index 6ec1667e..9444d402 100644 --- a/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/CommandProperties.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -20,7 +20,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 16, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -36,7 +36,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, CacheCommand, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -52,7 +52,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 23, 24)] internal static global::System.Collections.Generic.IEnumerable Query3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -69,7 +69,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CommandProperties.input.cs", 26, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/Execute.output.cs b/test/Dapper.AOT.Test/Interceptors/Execute.output.cs index 2c944698..6bfd2f56 100644 --- a/test/Dapper.AOT.Test/Interceptors/Execute.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/Execute.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Execute.input.cs", 13, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -42,7 +42,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Execute.input.cs", 17, 30)] internal static global::System.Threading.Tasks.Task ExecuteAsync3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, Async, HasParameters, StoredProcedure + // Execute, Async, HasParameters, StoredProcedure, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/Execute.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/Execute.output.netfx.cs index 2c944698..6bfd2f56 100644 --- a/test/Dapper.AOT.Test/Interceptors/Execute.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/Execute.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Execute.input.cs", 13, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -42,7 +42,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Execute.input.cs", 17, 30)] internal static global::System.Threading.Tasks.Task ExecuteAsync3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, Async, HasParameters, StoredProcedure + // Execute, Async, HasParameters, StoredProcedure, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.cs b/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.cs index a8bfc371..fff75b54 100644 --- a/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 14, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::System.Collections.Generic.List // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -18,7 +18,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 15, 24)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::System.Collections.Generic.List> // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -32,7 +32,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 16, 24)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.Customer[] // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -46,7 +46,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 17, 24)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::System.Collections.Immutable.ImmutableArray // parameter map: X global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -60,7 +60,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 18, 24)] internal static int Execute4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerEnumerable // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -74,7 +74,7 @@ internal static int Execute4(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 19, 24)] internal static int Execute5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerICollection // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -88,7 +88,7 @@ internal static int Execute5(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 20, 24)] internal static int Execute6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerIList // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -102,7 +102,7 @@ internal static int Execute6(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 21, 24)] internal static int Execute7(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerIReadOnlyCollection // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -116,7 +116,7 @@ internal static int Execute7(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 22, 24)] internal static int Execute8(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerIReadOnlyList // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.netfx.cs index a8bfc371..fff75b54 100644 --- a/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/ExecuteBatch.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 14, 24)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::System.Collections.Generic.List // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -18,7 +18,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 15, 24)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::System.Collections.Generic.List> // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -32,7 +32,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 16, 24)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.Customer[] // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -46,7 +46,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 17, 24)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::System.Collections.Immutable.ImmutableArray // parameter map: X global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -60,7 +60,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 18, 24)] internal static int Execute4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerEnumerable // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -74,7 +74,7 @@ internal static int Execute4(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 19, 24)] internal static int Execute5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerICollection // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -88,7 +88,7 @@ internal static int Execute5(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 20, 24)] internal static int Execute6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerIList // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -102,7 +102,7 @@ internal static int Execute6(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 21, 24)] internal static int Execute7(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerIReadOnlyCollection // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -116,7 +116,7 @@ internal static int Execute7(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteBatch.input.cs", 22, 24)] internal static int Execute8(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::Foo.CustomerIReadOnlyList // parameter map: X Y Z global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.cs b/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.cs index 67f3d057..1f1e2e7d 100644 --- a/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 13, 24)] internal static object? ExecuteScalar0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure, Scalar + // Execute, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -42,7 +42,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 17, 24)] internal static float ExecuteScalar3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, TypedResult, HasParameters, StoredProcedure, Scalar + // Execute, TypedResult, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: float @@ -83,7 +83,7 @@ internal static float ExecuteScalar5(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 21, 30)] internal static global::System.Threading.Tasks.Task ExecuteScalarAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, Async, HasParameters, StoredProcedure, Scalar + // Execute, Async, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -121,7 +121,7 @@ internal static float ExecuteScalar5(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 25, 30)] internal static global::System.Threading.Tasks.Task ExecuteScalarAsync9(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, Async, TypedResult, HasParameters, StoredProcedure, Scalar + // Execute, Async, TypedResult, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: float diff --git a/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.netfx.cs index 67f3d057..1f1e2e7d 100644 --- a/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/ExecuteScalar.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 13, 24)] internal static object? ExecuteScalar0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure, Scalar + // Execute, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -42,7 +42,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 17, 24)] internal static float ExecuteScalar3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, TypedResult, HasParameters, StoredProcedure, Scalar + // Execute, TypedResult, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: float @@ -83,7 +83,7 @@ internal static float ExecuteScalar5(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 21, 30)] internal static global::System.Threading.Tasks.Task ExecuteScalarAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, Async, HasParameters, StoredProcedure, Scalar + // Execute, Async, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -121,7 +121,7 @@ internal static float ExecuteScalar5(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\ExecuteScalar.input.cs", 25, 30)] internal static global::System.Threading.Tasks.Task ExecuteScalarAsync9(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, Async, TypedResult, HasParameters, StoredProcedure, Scalar + // Execute, Async, TypedResult, HasParameters, StoredProcedure, Scalar, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: float diff --git a/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.cs b/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.cs index 1935ec83..90366803 100644 --- a/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\GlobalFetchSize.input.cs", 16, 27)] internal static global::System.Collections.Generic.IEnumerable Query0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::SomeApp.SomeQueryType diff --git a/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.netfx.cs index 1935ec83..90366803 100644 --- a/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/GlobalFetchSize.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\GlobalFetchSize.input.cs", 16, 27)] internal static global::System.Collections.Generic.IEnumerable Query0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::SomeApp.SomeQueryType diff --git a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.cs b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.cs index bad2b2bd..20171f9f 100644 --- a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 14, 20)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeArg // parameter map: A global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -17,10 +17,11 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 17, 20)] [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 23, 20)] + [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 26, 20)] [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 29, 20)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeArg global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); @@ -33,7 +34,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 20, 20)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeArg // parameter map: B global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -44,31 +45,17 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string } - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 26, 20)] - internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) - { - // Execute, HasParameters, Text - // takes parameter: global::Foo.SomeArg - // parameter map: D - global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); - global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); - global::System.Diagnostics.Debug.Assert(param is not null); - - return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory3.Instance).Execute((global::Foo.SomeArg)param!); - - } - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 32, 20)] - internal static int Execute4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) + internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeOtherArg // parameter map: X global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); global::System.Diagnostics.Debug.Assert(param is not null); - return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory4.Instance).Execute((global::Foo.SomeOtherArg)param!); + return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory3.Instance).Execute((global::Foo.SomeOtherArg)param!); } @@ -112,11 +99,6 @@ public override void UpdateParameters(global::System.Data.Common.DbCommand cmd, ps[0].Value = AsValue(args.A); } - public override void PostProcess(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args, int rowCount) - { - args.RowCount = rowCount; - PostProcess(cmd, args); - } public override bool CanPrepare => true; } @@ -150,50 +132,13 @@ public override void UpdateParameters(global::System.Data.Common.DbCommand cmd, ps[0].Value = AsValue(args.B); } - public override void PostProcess(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args, int rowCount) - { - args.RowCount = rowCount; - PostProcess(cmd, args); - } public override bool CanPrepare => true; } - private sealed class CommandFactory3 : CommonCommandFactory + private sealed class CommandFactory3 : CommonCommandFactory { internal static readonly CommandFactory3 Instance = new(); - public override void AddParameters(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args) - { - var ps = cmd.Parameters; - global::System.Data.Common.DbParameter p; - p = cmd.CreateParameter(); - p.ParameterName = "D"; - p.DbType = global::System.Data.DbType.Decimal; - p.Precision = 12; - p.Scale = 42; - p.Direction = global::System.Data.ParameterDirection.Input; - p.Value = AsValue(args.D); - ps.Add(p); - - } - public override void UpdateParameters(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args) - { - var ps = cmd.Parameters; - ps[0].Value = AsValue(args.D); - - } - public override void PostProcess(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args, int rowCount) - { - args.RowCount = rowCount; - PostProcess(cmd, args); - } - public override bool CanPrepare => true; - - } - - private sealed class CommandFactory4 : CommonCommandFactory - { - internal static readonly CommandFactory4 Instance = new(); public override void AddParameters(global::System.Data.Common.DbCommand cmd, global::Foo.SomeOtherArg args) { var ps = cmd.Parameters; @@ -216,7 +161,8 @@ public override void PostProcess(global::System.Data.Common.DbCommand cmd, globa { args.RowCount = rowCount; args.DuplicateToCauseProblems = rowCount; - PostProcess(cmd, args); + base.PostProcess(cmd, args, rowCount); + } public override bool CanPrepare => true; diff --git a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.cs index bad2b2bd..20171f9f 100644 --- a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 14, 20)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeArg // parameter map: A global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -17,10 +17,11 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 17, 20)] [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 23, 20)] + [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 26, 20)] [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 29, 20)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeArg global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); @@ -33,7 +34,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 20, 20)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeArg // parameter map: B global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -44,31 +45,17 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string } - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 26, 20)] - internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) - { - // Execute, HasParameters, Text - // takes parameter: global::Foo.SomeArg - // parameter map: D - global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); - global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); - global::System.Diagnostics.Debug.Assert(param is not null); - - return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory3.Instance).Execute((global::Foo.SomeArg)param!); - - } - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MappedSqlDetection.input.cs", 32, 20)] - internal static int Execute4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) + internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.SomeOtherArg // parameter map: X global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); global::System.Diagnostics.Debug.Assert(param is not null); - return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory4.Instance).Execute((global::Foo.SomeOtherArg)param!); + return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory3.Instance).Execute((global::Foo.SomeOtherArg)param!); } @@ -112,11 +99,6 @@ public override void UpdateParameters(global::System.Data.Common.DbCommand cmd, ps[0].Value = AsValue(args.A); } - public override void PostProcess(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args, int rowCount) - { - args.RowCount = rowCount; - PostProcess(cmd, args); - } public override bool CanPrepare => true; } @@ -150,50 +132,13 @@ public override void UpdateParameters(global::System.Data.Common.DbCommand cmd, ps[0].Value = AsValue(args.B); } - public override void PostProcess(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args, int rowCount) - { - args.RowCount = rowCount; - PostProcess(cmd, args); - } public override bool CanPrepare => true; } - private sealed class CommandFactory3 : CommonCommandFactory + private sealed class CommandFactory3 : CommonCommandFactory { internal static readonly CommandFactory3 Instance = new(); - public override void AddParameters(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args) - { - var ps = cmd.Parameters; - global::System.Data.Common.DbParameter p; - p = cmd.CreateParameter(); - p.ParameterName = "D"; - p.DbType = global::System.Data.DbType.Decimal; - p.Precision = 12; - p.Scale = 42; - p.Direction = global::System.Data.ParameterDirection.Input; - p.Value = AsValue(args.D); - ps.Add(p); - - } - public override void UpdateParameters(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args) - { - var ps = cmd.Parameters; - ps[0].Value = AsValue(args.D); - - } - public override void PostProcess(global::System.Data.Common.DbCommand cmd, global::Foo.SomeArg args, int rowCount) - { - args.RowCount = rowCount; - PostProcess(cmd, args); - } - public override bool CanPrepare => true; - - } - - private sealed class CommandFactory4 : CommonCommandFactory - { - internal static readonly CommandFactory4 Instance = new(); public override void AddParameters(global::System.Data.Common.DbCommand cmd, global::Foo.SomeOtherArg args) { var ps = cmd.Parameters; @@ -216,7 +161,8 @@ public override void PostProcess(global::System.Data.Common.DbCommand cmd, globa { args.RowCount = rowCount; args.DuplicateToCauseProblems = rowCount; - PostProcess(cmd, args); + base.PostProcess(cmd, args, rowCount); + } public override bool CanPrepare => true; diff --git a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.txt b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.txt index 2cbe7fde..b6b45819 100644 --- a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.txt +++ b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.netfx.txt @@ -1,17 +1,4 @@ Generator produced 1 diagnostics: Hidden DAP000 L1 C1 -Dapper.AOT handled 7 of 7 possible call-sites using 5 interceptors, 5 commands and 0 readers -Output code has 4 diagnostics from 'Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs': - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L118 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory0.PostProcess(DbCommand, Foo.SomeArg, int)' - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L156 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory2.PostProcess(DbCommand, Foo.SomeArg, int)' - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L188 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory3.PostProcess(DbCommand, Foo.SomeArg, int)' - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L219 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory4.PostProcess(DbCommand, Foo.SomeOtherArg, int)' +Dapper.AOT handled 7 of 7 possible call-sites using 4 interceptors, 4 commands and 0 readers diff --git a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.txt b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.txt index 2cbe7fde..b6b45819 100644 --- a/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.txt +++ b/test/Dapper.AOT.Test/Interceptors/MappedSqlDetection.output.txt @@ -1,17 +1,4 @@ Generator produced 1 diagnostics: Hidden DAP000 L1 C1 -Dapper.AOT handled 7 of 7 possible call-sites using 5 interceptors, 5 commands and 0 readers -Output code has 4 diagnostics from 'Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs': - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L118 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory0.PostProcess(DbCommand, Foo.SomeArg, int)' - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L156 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory2.PostProcess(DbCommand, Foo.SomeArg, int)' - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L188 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory3.PostProcess(DbCommand, Foo.SomeArg, int)' - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L219 C13 -There is no argument given that corresponds to the required parameter 'rowCount' of 'DapperGeneratedInterceptors.CommandFactory4.PostProcess(DbCommand, Foo.SomeOtherArg, int)' +Dapper.AOT handled 7 of 7 possible call-sites using 4 interceptors, 4 commands and 0 readers diff --git a/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.cs b/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.cs index fef50c4e..44b462e0 100644 --- a/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.cs @@ -41,7 +41,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MiscDiagnostics.input.cs", 92, 24)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::SomeCode.InternalNesting.SomePublicType // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -68,7 +68,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MiscDiagnostics.input.cs", 40, 24)] internal static int Execute5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::SomeCode.InternalNesting.SomeInternalType // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -95,7 +95,7 @@ internal static int Execute5(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MiscDiagnostics.input.cs", 56, 24)] internal static int Execute7(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::SomeCode.InternalNesting.SomeProtectedInternalType // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.netfx.cs index fef50c4e..44b462e0 100644 --- a/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/MiscDiagnostics.output.netfx.cs @@ -41,7 +41,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MiscDiagnostics.input.cs", 92, 24)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::SomeCode.InternalNesting.SomePublicType // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -68,7 +68,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MiscDiagnostics.input.cs", 40, 24)] internal static int Execute5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::SomeCode.InternalNesting.SomeInternalType // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -95,7 +95,7 @@ internal static int Execute5(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\MiscDiagnostics.input.cs", 56, 24)] internal static int Execute7(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, StoredProcedure + // Execute, HasParameters, StoredProcedure, KnownParameters // takes parameter: global::SomeCode.InternalNesting.SomeProtectedInternalType // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/NonConstant.output.cs b/test/Dapper.AOT.Test/Interceptors/NonConstant.output.cs index fdabd751..2a4c52bc 100644 --- a/test/Dapper.AOT.Test/Interceptors/NonConstant.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/NonConstant.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\NonConstant.input.cs", 17, 20)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters + // Execute, HasParameters, KnownParameters // takes parameter: // parameter map: (deferred) global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -17,7 +17,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\NonConstant.input.cs", 19, 20)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters + // Execute, HasParameters, KnownParameters // takes parameter: global::[] // parameter map: (deferred) global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/NonConstant.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/NonConstant.output.netfx.cs index fdabd751..2a4c52bc 100644 --- a/test/Dapper.AOT.Test/Interceptors/NonConstant.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/NonConstant.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\NonConstant.input.cs", 17, 20)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters + // Execute, HasParameters, KnownParameters // takes parameter: // parameter map: (deferred) global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -17,7 +17,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\NonConstant.input.cs", 19, 20)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters + // Execute, HasParameters, KnownParameters // takes parameter: global::[] // parameter map: (deferred) global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/Query.output.cs b/test/Dapper.AOT.Test/Interceptors/Query.output.cs index db40d915..d0bc9739 100644 --- a/test/Dapper.AOT.Test/Interceptors/Query.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/Query.output.cs @@ -18,7 +18,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 15, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -63,7 +63,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -93,7 +93,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 20, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -122,7 +122,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 23, 47)] internal static global::System.Collections.Generic.IAsyncEnumerable QueryUnbufferedAsync8(this global::System.Data.Common.DbConnection cnn, string sql, object? param, global::System.Data.Common.DbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Unbuffered, Text, BindResultsByName + // Query, Async, TypedResult, HasParameters, Unbuffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/Query.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/Query.output.netfx.cs index 341c6781..03c3e8c3 100644 --- a/test/Dapper.AOT.Test/Interceptors/Query.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/Query.output.netfx.cs @@ -18,7 +18,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 15, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -63,7 +63,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -93,7 +93,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Query.input.cs", 20, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.cs b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.cs index 48056c2f..e6346e75 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.cs @@ -316,7 +316,7 @@ private RowFactory1() {} columnOffset++; } - return new global::Foo.GetOnlyPropertiesViaConstructor; + return new global::Foo.GetOnlyPropertiesViaConstructor(value0, value1, value2); } } @@ -448,7 +448,7 @@ private RowFactory3() {} columnOffset++; } - return new global::Foo.RecordClassSimpleCtor; + return new global::Foo.RecordClassSimpleCtor(value0, value1, value2); } } @@ -550,38 +550,38 @@ private RowFactory5() {} } public override global::Foo.RecordStructSimpleCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) { - global::Foo.RecordStructSimpleCtor result = new(); + int value0 = default; + string? value1 = default; + double? value2 = default; foreach (var token in tokens) { switch (token) { case 0: - result.X = reader.GetInt32(columnOffset); + value0 = reader.GetInt32(columnOffset); break; case 3: - result.X = GetValue(reader, columnOffset); + value0 = GetValue(reader, columnOffset); break; case 1: - result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + value1 = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); break; case 4: - result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + value1 = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); break; case 2: - result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + value2 = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); break; case 5: - result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + value2 = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); break; } columnOffset++; } - return result; - + return new global::Foo.RecordStructSimpleCtor(value0, value1, value2); } - } private sealed class RowFactory6 : global::Dapper.RowFactory @@ -717,7 +717,7 @@ private RowFactory7() {} columnOffset++; } - return new global::Foo.InitPropsAndDapperAotCtor + return new global::Foo.InitPropsAndDapperAotCtor(value1) { X = value0, Z = value2, @@ -729,6 +729,65 @@ private sealed class RowFactory8 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.OnlyNonDapperAotCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.OnlyNonDapperAotCtor result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } @@ -736,6 +795,65 @@ private sealed class RowFactory9 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.SingleDefaultCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.SingleDefaultCtor result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } @@ -743,6 +861,65 @@ private sealed class RowFactory10 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.MultipleDapperAotCtors Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.MultipleDapperAotCtors result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } @@ -750,6 +927,65 @@ private sealed class RowFactory11 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.SingleDapperAotCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.SingleDapperAotCtor result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } diff --git a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.cs index 48056c2f..e6346e75 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.cs @@ -316,7 +316,7 @@ private RowFactory1() {} columnOffset++; } - return new global::Foo.GetOnlyPropertiesViaConstructor; + return new global::Foo.GetOnlyPropertiesViaConstructor(value0, value1, value2); } } @@ -448,7 +448,7 @@ private RowFactory3() {} columnOffset++; } - return new global::Foo.RecordClassSimpleCtor; + return new global::Foo.RecordClassSimpleCtor(value0, value1, value2); } } @@ -550,38 +550,38 @@ private RowFactory5() {} } public override global::Foo.RecordStructSimpleCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) { - global::Foo.RecordStructSimpleCtor result = new(); + int value0 = default; + string? value1 = default; + double? value2 = default; foreach (var token in tokens) { switch (token) { case 0: - result.X = reader.GetInt32(columnOffset); + value0 = reader.GetInt32(columnOffset); break; case 3: - result.X = GetValue(reader, columnOffset); + value0 = GetValue(reader, columnOffset); break; case 1: - result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + value1 = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); break; case 4: - result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + value1 = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); break; case 2: - result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + value2 = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); break; case 5: - result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + value2 = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); break; } columnOffset++; } - return result; - + return new global::Foo.RecordStructSimpleCtor(value0, value1, value2); } - } private sealed class RowFactory6 : global::Dapper.RowFactory @@ -717,7 +717,7 @@ private RowFactory7() {} columnOffset++; } - return new global::Foo.InitPropsAndDapperAotCtor + return new global::Foo.InitPropsAndDapperAotCtor(value1) { X = value0, Z = value2, @@ -729,6 +729,65 @@ private sealed class RowFactory8 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.OnlyNonDapperAotCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.OnlyNonDapperAotCtor result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } @@ -736,6 +795,65 @@ private sealed class RowFactory9 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.SingleDefaultCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.SingleDefaultCtor result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } @@ -743,6 +861,65 @@ private sealed class RowFactory10 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.MultipleDapperAotCtors Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.MultipleDapperAotCtors result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } @@ -750,6 +927,65 @@ private sealed class RowFactory11 : global::Dapper.RowFactory tokens, int columnOffset) + { + for (int i = 0; i < tokens.Length; i++) + { + int token = -1; + var name = reader.GetName(columnOffset); + var type = reader.GetFieldType(columnOffset); + switch (NormalizedHash(name)) + { + case 4245442695U when NormalizedEquals(name, "x"): + token = type == typeof(int) ? 0 : 3; // two tokens for right-typed and type-flexible + break; + case 4228665076U when NormalizedEquals(name, "y"): + token = type == typeof(string) ? 1 : 4; + break; + case 4278997933U when NormalizedEquals(name, "z"): + token = type == typeof(double) ? 2 : 5; + break; + + } + tokens[i] = token; + columnOffset++; + + } + return null; + } + public override global::Foo.SingleDapperAotCtor Read(global::System.Data.Common.DbDataReader reader, global::System.ReadOnlySpan tokens, int columnOffset, object? state) + { + global::Foo.SingleDapperAotCtor result = new(); + foreach (var token in tokens) + { + switch (token) + { + case 0: + result.X = reader.GetInt32(columnOffset); + break; + case 3: + result.X = GetValue(reader, columnOffset); + break; + case 1: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : reader.GetString(columnOffset); + break; + case 4: + result.Y = reader.IsDBNull(columnOffset) ? (string?)null : GetValue(reader, columnOffset); + break; + case 2: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : reader.GetDouble(columnOffset); + break; + case 5: + result.Z = reader.IsDBNull(columnOffset) ? (double?)null : GetValue(reader, columnOffset); + break; + + } + columnOffset++; + + } + return result; + + } } diff --git a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.txt b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.txt index 5a0195fb..2203022e 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.txt +++ b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.netfx.txt @@ -2,19 +2,3 @@ Generator produced 1 diagnostics: Hidden DAP000 L1 C1 Dapper.AOT handled 12 of 12 possible call-sites using 12 interceptors, 0 commands and 12 readers -Output code has 5 diagnostics from 'Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs': - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L319 C24 -There is no argument given that corresponds to the required parameter 'x' of 'Foo.GetOnlyPropertiesViaConstructor.GetOnlyPropertiesViaConstructor(int, string, double?)' - -Error CS1526 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L319 C67 -A new expression requires an argument list or (), [], or {} after type - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L451 C24 -There is no argument given that corresponds to the required parameter 'X' of 'Foo.RecordClassSimpleCtor.RecordClassSimpleCtor(int, string, double?)' - -Error CS1526 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L451 C57 -A new expression requires an argument list or (), [], or {} after type - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L720 C24 -There is no argument given that corresponds to the required parameter 'y' of 'Foo.InitPropsAndDapperAotCtor.InitPropsAndDapperAotCtor(string)' diff --git a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.txt b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.txt index 5a0195fb..2203022e 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.txt +++ b/test/Dapper.AOT.Test/Interceptors/QueryCustomConstruction.output.txt @@ -2,19 +2,3 @@ Generator produced 1 diagnostics: Hidden DAP000 L1 C1 Dapper.AOT handled 12 of 12 possible call-sites using 12 interceptors, 0 commands and 12 readers -Output code has 5 diagnostics from 'Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs': - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L319 C24 -There is no argument given that corresponds to the required parameter 'x' of 'Foo.GetOnlyPropertiesViaConstructor.GetOnlyPropertiesViaConstructor(int, string, double?)' - -Error CS1526 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L319 C67 -A new expression requires an argument list or (), [], or {} after type - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L451 C24 -There is no argument given that corresponds to the required parameter 'X' of 'Foo.RecordClassSimpleCtor.RecordClassSimpleCtor(int, string, double?)' - -Error CS1526 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L451 C57 -A new expression requires an argument list or (), [], or {} after type - -Error CS7036 Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/Test.generated.cs L720 C24 -There is no argument given that corresponds to the required parameter 'y' of 'Foo.InitPropsAndDapperAotCtor.InitPropsAndDapperAotCtor(string)' diff --git a/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.cs b/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.cs index 75c66656..df11e2ee 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.cs @@ -5,7 +5,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryDetection.input.cs", 12, 12)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Name global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -20,7 +20,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryDetection.input.cs", 21, 12)] internal static int QuerySingle1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne + // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Name // returns data: int @@ -36,7 +36,7 @@ internal static int QuerySingle1(this global::System.Data.IDbConnection cnn, str [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryDetection.input.cs", 22, 12)] internal static int ExecuteScalar2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, TypedResult, HasParameters, Text, Scalar + // Execute, TypedResult, HasParameters, Text, Scalar, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Name // returns data: int diff --git a/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.netfx.cs index 75c66656..df11e2ee 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryDetection.output.netfx.cs @@ -5,7 +5,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryDetection.input.cs", 12, 12)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Name global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -20,7 +20,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryDetection.input.cs", 21, 12)] internal static int QuerySingle1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne + // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Name // returns data: int @@ -36,7 +36,7 @@ internal static int QuerySingle1(this global::System.Data.IDbConnection cnn, str [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryDetection.input.cs", 22, 12)] internal static int ExecuteScalar2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, TypedResult, HasParameters, Text, Scalar + // Execute, TypedResult, HasParameters, Text, Scalar, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Name // returns data: int diff --git a/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.cs b/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.cs index 7ece3044..b6d5f6b0 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.cs @@ -17,7 +17,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -32,7 +32,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 15, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, StoredProcedure, BindResultsByName + // Query, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -59,7 +59,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, Text, BindResultsByName + // Query, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -87,7 +87,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 20, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -114,7 +114,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 23, 47)] internal static global::System.Collections.Generic.IAsyncEnumerable QueryUnbufferedAsync8(this global::System.Data.Common.DbConnection cnn, string sql, object? param, global::System.Data.Common.DbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, Unbuffered, Text, BindResultsByName + // Query, Async, HasParameters, Unbuffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -128,7 +128,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 26, 24)] internal static dynamic QueryFirst9(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -142,7 +142,7 @@ internal static dynamic QueryFirst9(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 27, 24)] internal static dynamic? QueryFirstOrDefault10(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -156,7 +156,7 @@ internal static dynamic QueryFirst9(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 28, 24)] internal static dynamic QuerySingle11(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -182,7 +182,7 @@ internal static dynamic QuerySingle11(this global::System.Data.IDbConnection cnn [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 31, 30)] internal static global::System.Threading.Tasks.Task QueryFirstAsync13(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, Async, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -196,7 +196,7 @@ internal static dynamic QuerySingle11(this global::System.Data.IDbConnection cnn [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 32, 30)] internal static global::System.Threading.Tasks.Task QueryFirstOrDefaultAsync14(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, Async, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -210,7 +210,7 @@ internal static dynamic QuerySingle11(this global::System.Data.IDbConnection cnn [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 33, 30)] internal static global::System.Threading.Tasks.Task QuerySingleAsync15(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, Async, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.netfx.cs index eae2631e..1cb9d2fe 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryNonGeneric.output.netfx.cs @@ -17,7 +17,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -32,7 +32,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 15, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, StoredProcedure, BindResultsByName + // Query, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -59,7 +59,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, Text, BindResultsByName + // Query, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -87,7 +87,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 20, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -102,7 +102,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 26, 24)] internal static dynamic QueryFirst7(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -116,7 +116,7 @@ internal static dynamic QueryFirst7(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 27, 24)] internal static dynamic? QueryFirstOrDefault8(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -130,7 +130,7 @@ internal static dynamic QueryFirst7(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 28, 24)] internal static dynamic QuerySingle9(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -156,7 +156,7 @@ internal static dynamic QuerySingle9(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 31, 30)] internal static global::System.Threading.Tasks.Task QueryFirstAsync11(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, Async, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -170,7 +170,7 @@ internal static dynamic QuerySingle9(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 32, 30)] internal static global::System.Threading.Tasks.Task QueryFirstOrDefaultAsync12(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, Async, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -184,7 +184,7 @@ internal static dynamic QuerySingle9(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryNonGeneric.input.cs", 33, 30)] internal static global::System.Threading.Tasks.Task QuerySingleAsync13(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, Async, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.cs b/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.cs index 633ec2e0..e8b8c8fc 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.cs @@ -18,7 +18,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: object @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 15, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: object @@ -63,7 +63,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: object @@ -93,7 +93,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 20, 24)] internal static global::System.Collections.Generic.IEnumerable Query6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: dynamic @@ -109,7 +109,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 21, 24)] internal static global::System.Collections.Generic.IEnumerable Query7(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: dynamic @@ -138,7 +138,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 23, 24)] internal static global::System.Collections.Generic.IEnumerable Query9(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: dynamic @@ -167,7 +167,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 26, 24)] internal static global::System.Collections.Generic.IEnumerable Query11(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -182,7 +182,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 27, 24)] internal static global::System.Collections.Generic.IEnumerable Query12(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, StoredProcedure, BindResultsByName + // Query, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -209,7 +209,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 29, 24)] internal static global::System.Collections.Generic.IEnumerable Query14(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, Text, BindResultsByName + // Query, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -238,7 +238,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 32, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync16(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: object @@ -267,7 +267,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 35, 47)] internal static global::System.Collections.Generic.IAsyncEnumerable QueryUnbufferedAsync18(this global::System.Data.Common.DbConnection cnn, string sql, object? param, global::System.Data.Common.DbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Unbuffered, Text, BindResultsByName + // Query, Async, TypedResult, HasParameters, Unbuffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: object @@ -296,7 +296,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 38, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync20(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: dynamic @@ -325,7 +325,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 41, 47)] internal static global::System.Collections.Generic.IAsyncEnumerable QueryUnbufferedAsync22(this global::System.Data.Common.DbConnection cnn, string sql, object? param, global::System.Data.Common.DbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Unbuffered, Text, BindResultsByName + // Query, Async, TypedResult, HasParameters, Unbuffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: dynamic @@ -353,7 +353,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 45, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync24(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.netfx.cs index 17aabcdc..6f5a3a72 100644 --- a/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/QueryUntyped.output.netfx.cs @@ -18,7 +18,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 14, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: object @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 15, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: object @@ -63,7 +63,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 17, 24)] internal static global::System.Collections.Generic.IEnumerable Query4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: object @@ -93,7 +93,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 20, 24)] internal static global::System.Collections.Generic.IEnumerable Query6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: dynamic @@ -109,7 +109,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 21, 24)] internal static global::System.Collections.Generic.IEnumerable Query7(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: dynamic @@ -138,7 +138,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 23, 24)] internal static global::System.Collections.Generic.IEnumerable Query9(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: dynamic @@ -167,7 +167,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 26, 24)] internal static global::System.Collections.Generic.IEnumerable Query11(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -182,7 +182,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 27, 24)] internal static global::System.Collections.Generic.IEnumerable Query12(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, StoredProcedure, BindResultsByName + // Query, HasParameters, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -209,7 +209,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 29, 24)] internal static global::System.Collections.Generic.IEnumerable Query14(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, Buffered, Text, BindResultsByName + // Query, HasParameters, Buffered, Text, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -238,7 +238,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 32, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync16(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: object @@ -268,7 +268,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 38, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync18(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: dynamic @@ -297,7 +297,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\QueryUntyped.input.cs", 45, 30)] internal static global::System.Threading.Tasks.Task> QueryAsync20(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, Async, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.cs b/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.cs index b03e7773..0ce3bf15 100644 --- a/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.cs @@ -18,7 +18,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\RowCountHint.input.cs", 12, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\RowCountHint.input.cs", 13, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: global::Foo.DynamicHint // parameter map: Bar Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.netfx.cs index b03e7773..0ce3bf15 100644 --- a/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/RowCountHint.output.netfx.cs @@ -18,7 +18,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\RowCountHint.input.cs", 12, 24)] internal static global::System.Collections.Generic.IEnumerable Query1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\RowCountHint.input.cs", 13, 24)] internal static global::System.Collections.Generic.IEnumerable Query2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, bool buffered, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, Buffered, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: global::Foo.DynamicHint // parameter map: Bar Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/Single.output.cs b/test/Dapper.AOT.Test/Interceptors/Single.output.cs index 1d44d50a..c1dc4178 100644 --- a/test/Dapper.AOT.Test/Interceptors/Single.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/Single.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 13, 24)] internal static global::Foo.Customer QueryFirst0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -19,7 +19,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 14, 24)] internal static global::Foo.Customer? QueryFirstOrDefault1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 15, 24)] internal static global::Foo.Customer QuerySingle2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -62,7 +62,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 18, 30)] internal static global::System.Threading.Tasks.Task QueryFirstAsync4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -77,7 +77,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 19, 30)] internal static global::System.Threading.Tasks.Task QueryFirstOrDefaultAsync5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -92,7 +92,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 20, 30)] internal static global::System.Threading.Tasks.Task QuerySingleAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, Async, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/Single.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/Single.output.netfx.cs index 1d44d50a..c1dc4178 100644 --- a/test/Dapper.AOT.Test/Interceptors/Single.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/Single.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 13, 24)] internal static global::Foo.Customer QueryFirst0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -19,7 +19,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 14, 24)] internal static global::Foo.Customer? QueryFirstOrDefault1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -34,7 +34,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 15, 24)] internal static global::Foo.Customer QuerySingle2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer @@ -62,7 +62,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 18, 30)] internal static global::System.Threading.Tasks.Task QueryFirstAsync4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName + // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, AtLeastOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -77,7 +77,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 19, 30)] internal static global::System.Threading.Tasks.Task QueryFirstOrDefaultAsync5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName + // Query, Async, TypedResult, HasParameters, SingleRow, StoredProcedure, BindResultsByName, KnownParameters // takes parameter: // parameter map: bar Foo // returns data: global::Foo.Customer @@ -92,7 +92,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\Single.input.cs", 20, 30)] internal static global::System.Threading.Tasks.Task QuerySingleAsync6(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, Async, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, Async, TypedResult, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: Foo // returns data: global::Foo.Customer diff --git a/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.cs b/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.cs index ab6ab0dd..ba62a13c 100644 --- a/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 14, 20)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: // parameter map: B global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -20,7 +20,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 31, 20)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::[] // parameter map: B global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -46,7 +46,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 23, 20)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); @@ -59,7 +59,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 34, 20)] internal static int Execute4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::[] global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); diff --git a/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.netfx.cs index ab6ab0dd..ba62a13c 100644 --- a/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/SqlDetection.output.netfx.cs @@ -4,7 +4,7 @@ file static class DapperGeneratedInterceptors [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 14, 20)] internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: // parameter map: B global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -20,7 +20,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 31, 20)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::[] // parameter map: B global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -46,7 +46,7 @@ internal static int Execute2(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 23, 20)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); @@ -59,7 +59,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlDetection.input.cs", 34, 20)] internal static int Execute4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::[] global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); diff --git a/test/Dapper.AOT.Test/Interceptors/SqlParse.output.cs b/test/Dapper.AOT.Test/Interceptors/SqlParse.output.cs index 726d7bca..59e1e462 100644 --- a/test/Dapper.AOT.Test/Interceptors/SqlParse.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/SqlParse.output.cs @@ -21,7 +21,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlParse.input.cs", 82, 12)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Id Name global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -37,7 +37,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlParse.input.cs", 84, 12)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/SqlParse.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/SqlParse.output.netfx.cs index 726d7bca..59e1e462 100644 --- a/test/Dapper.AOT.Test/Interceptors/SqlParse.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/SqlParse.output.netfx.cs @@ -21,7 +21,7 @@ internal static int Execute0(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlParse.input.cs", 82, 12)] internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Id Name global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -37,7 +37,7 @@ internal static int Execute1(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\SqlParse.input.cs", 84, 12)] internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: global::Foo.Customer // parameter map: Id global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); diff --git a/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.cs b/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.cs index 8e15c5ef..4b271bcc 100644 --- a/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.cs +++ b/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.cs @@ -72,7 +72,7 @@ internal static dynamic QuerySingle2(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\TsqlTips.input.cs", 61, 20)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: // parameter map: a b global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -86,7 +86,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\TsqlTips.input.cs", 73, 24)] internal static dynamic QuerySingle4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: ids global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -100,7 +100,7 @@ internal static dynamic QuerySingle4(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\TsqlTips.input.cs", 76, 24)] internal static dynamic QuerySingle5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); diff --git a/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.netfx.cs b/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.netfx.cs index 8e15c5ef..4b271bcc 100644 --- a/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.netfx.cs +++ b/test/Dapper.AOT.Test/Interceptors/TsqlTips.output.netfx.cs @@ -72,7 +72,7 @@ internal static dynamic QuerySingle2(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\TsqlTips.input.cs", 61, 20)] internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Execute, HasParameters, Text + // Execute, HasParameters, Text, KnownParameters // takes parameter: // parameter map: a b global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -86,7 +86,7 @@ internal static int Execute3(this global::System.Data.IDbConnection cnn, string [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\TsqlTips.input.cs", 73, 24)] internal static dynamic QuerySingle4(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: // parameter map: ids global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); @@ -100,7 +100,7 @@ internal static dynamic QuerySingle4(this global::System.Data.IDbConnection cnn, [global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\TsqlTips.input.cs", 76, 24)] internal static dynamic QuerySingle5(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType) { - // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName + // Query, HasParameters, SingleRow, Text, AtLeastOne, AtMostOne, BindResultsByName, KnownParameters // takes parameter: global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql)); global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text); diff --git a/test/Dapper.AOT.Test/Verifiers/DAP017.cs b/test/Dapper.AOT.Test/Verifiers/DAP017.cs index 906a1450..175f74e4 100644 --- a/test/Dapper.AOT.Test/Verifiers/DAP017.cs +++ b/test/Dapper.AOT.Test/Verifiers/DAP017.cs @@ -14,8 +14,6 @@ public Task NonPublicType() => CSVerifyAsync(""" internal class NestedInternal { - public class InnerPublic {} - [DapperAot] class AotEnabled { @@ -59,8 +57,9 @@ class AotDisabled void QueryG(DbConnection conn) => _ = conn.Query("somesql"); void QueryH(DbConnection conn) => _ = conn.Query("somesql"); } + public class InnerPublic { public int Id {get;set;} } protected class InnerProtected {} - protected internal class InnerProtectedInternal {} + protected internal class InnerProtectedInternal { public int Id {get;set;} } private protected class InnerPrivateProtected {} private class InnerPrivate { @@ -68,8 +67,8 @@ public class InnerInnerPublic {} } } - public class OuterPublic {} - internal class OuterInternal {} + public class OuterPublic { public int Id {get;set;} } + internal class OuterInternal { public int Id {get;set;} } """, DefaultConfig, [ Diagnostic(Diagnostics.NonPublicType).WithLocation(0).WithArguments("NestedInternal.InnerPrivate", "private"), Diagnostic(Diagnostics.NonPublicType).WithLocation(1).WithArguments("NestedInternal.InnerPrivate", "private"), diff --git a/test/Dapper.AOT.Test/Verifiers/DAP027.cs b/test/Dapper.AOT.Test/Verifiers/DAP027.cs index 96f62852..429a6089 100644 --- a/test/Dapper.AOT.Test/Verifiers/DAP027.cs +++ b/test/Dapper.AOT.Test/Verifiers/DAP027.cs @@ -40,7 +40,7 @@ public void Foo(DbConnection conn) _ = conn.QuerySingleOrDefault("storedproc"); } } - class SomeType {} + class SomeType { public int Id {get;set;} } """, DefaultConfig, [ Diagnostic(Diagnostics.UseSingleRowQuery).WithLocation(0).WithArguments("QueryFirst", "First"), Diagnostic(Diagnostics.UseSingleRowQuery).WithLocation(1).WithArguments("QuerySingle", "Single"), diff --git a/test/Dapper.AOT.Test/Verifiers/DAP028.cs b/test/Dapper.AOT.Test/Verifiers/DAP028.cs index 33b5f579..4a8da970 100644 --- a/test/Dapper.AOT.Test/Verifiers/DAP028.cs +++ b/test/Dapper.AOT.Test/Verifiers/DAP028.cs @@ -34,7 +34,7 @@ public void Foo(DbConnection conn) _ = conn.Query("storedproc").AsList(); } } - class SomeType {} + class SomeType { public int Id {get;set;} } """, DefaultConfig, [ Diagnostic(Diagnostics.UseQueryAsList).WithLocation(0), Diagnostic(Diagnostics.UseQueryAsList).WithLocation(1), diff --git a/test/Dapper.AOT.Test/Verifiers/DAP035.cs b/test/Dapper.AOT.Test/Verifiers/DAP035.cs index 888fcc12..4ffadeaa 100644 --- a/test/Dapper.AOT.Test/Verifiers/DAP035.cs +++ b/test/Dapper.AOT.Test/Verifiers/DAP035.cs @@ -22,10 +22,11 @@ public void Foo(DbConnection conn) _ = conn.Query("storedproc"); } } - class NoConstructors {} + class NoConstructors { public int Id {get;set;} } class SingleExplicit { - [ExplicitConstructor] public SingleExplicit(int a) {} + public int A {get;} + [ExplicitConstructor] public SingleExplicit(int a) => A = a; public SingleExplicit(string b) {} public SingleExplicit(decimal c) {} public SingleExplicit(SingleExplicit d) {} diff --git a/test/Dapper.AOT.Test/Verifiers/DAP036.cs b/test/Dapper.AOT.Test/Verifiers/DAP036.cs index c8cab13c..155b52e7 100644 --- a/test/Dapper.AOT.Test/Verifiers/DAP036.cs +++ b/test/Dapper.AOT.Test/Verifiers/DAP036.cs @@ -34,16 +34,18 @@ public void NoAotMode(DbConnection conn) _ = conn.Query("storedproc"); } } - class NoConstructors {} + class NoConstructors { public int Id {get;set;} } [System.Serializable] class SingleImplicit { - public SingleImplicit(string a) {} + public string A {get;} + public SingleImplicit(string a) => A = a; public SingleImplicit(SingleImplicit b) {} public SingleImplicit(SerializationInfo info, StreamingContext ctx) {} } class MultipleImplicit { + public int A {get;set;} public {|#0:MultipleImplicit|}(int a) {} public MultipleImplicit(string b) {} public MultipleImplicit(MultipleImplicit c) {} diff --git a/test/Dapper.AOT.Test/Verifiers/DAP037.cs b/test/Dapper.AOT.Test/Verifiers/DAP037.cs new file mode 100644 index 00000000..151d38f3 --- /dev/null +++ b/test/Dapper.AOT.Test/Verifiers/DAP037.cs @@ -0,0 +1,81 @@ +using Dapper.CodeAnalysis; +using System.Threading.Tasks; +using Xunit; +using static Dapper.CodeAnalysis.DapperAnalyzer; + +namespace Dapper.AOT.Test.Verifiers; + +public class DAP037 : Verifier +{ + [Fact] + public Task UserTypeNoSettableMembersFound() => CSVerifyAsync("""" + using Dapper; + using System.Data.Common; + using System.Runtime.Serialization; + + [DapperAot] + class SomeCode + { + public void Foo(DbConnection conn) + { + var args = new NoSettable(32); // important that this is fine as an arg + const string sql = """ + select Id, Name + from SomeTable + where Id = @b + """; + + _ = conn.{|#0:Query|}(sql, args); + _ = conn.Query(sql, args); + _ = conn.Query(sql, args); + _ = conn.Query(sql, args); + _ = conn.Query(sql, args); + _ = conn.{|#1:Query|}(sql, args); + _ = conn.Query(sql, args); + _ = conn.Query(sql, args); + } + } + + class NoSettable + { + public NoSettable(int a) => B = a; + public int B {get;} + } + class SimpleType + { + public int B {get;set;} + } + class IntOnlyType + { + public int B {get;init;} + } + class ReadWriteField + { + public int B; + } + class ReadOnlyField + { + public readonly int B; + } + record class RecordType(int b); + class HazImplicitConstructor + { + public HazImplicitConstructor(int b) => B = b; + public int B {get;} + } + class HazExplicitConstructor + { + [ExplicitConstructor] + public HazExplicitConstructor(int b) => B = b; + public int B {get;} + } + namespace System.Runtime.CompilerServices + { + static file class IsExternalInit {} + } + """", DefaultConfig, [ + Diagnostic(Diagnostics.UserTypeNoSettableMembersFound).WithLocation(0).WithArguments("NoSettable"), + Diagnostic(Diagnostics.UserTypeNoSettableMembersFound).WithLocation(1).WithArguments("ReadOnlyField"), + ]); + +} \ No newline at end of file diff --git a/test/Dapper.AOT.Test/Verifiers/DAP038.cs b/test/Dapper.AOT.Test/Verifiers/DAP038.cs index 2c0a811f..53adad4e 100644 --- a/test/Dapper.AOT.Test/Verifiers/DAP038.cs +++ b/test/Dapper.AOT.Test/Verifiers/DAP038.cs @@ -38,8 +38,8 @@ public async Task Foo(DbConnection conn) } } - class SomeClass {} - struct SomeStruct {} + class SomeClass { public int Id {get;set;} } + struct SomeStruct { public int Id {get;set;} } """, DefaultConfig, [ Diagnostic(Diagnostics.ValueTypeSingleFirstOrDefaultUsage).WithLocation(0).WithArguments("SomeStruct", "QueryFirstOrDefault"), Diagnostic(Diagnostics.ValueTypeSingleFirstOrDefaultUsage).WithLocation(1).WithArguments("SomeStruct", "QuerySingleOrDefault"),