11using System ;
22using System . Collections . Concurrent ;
3+ using System . Linq ;
34using System . Reflection ;
45using System . Threading . Tasks ;
56using Temporalio . Runtime ;
@@ -11,10 +12,7 @@ namespace Temporalio.Workflows
1112 /// </summary>
1213 public class WorkflowQueryDefinition
1314 {
14- /// <summary>
15- /// All known reserved query handler prefixes.
16- /// </summary>
17- internal static readonly string [ ] ReservedQueryHandlerPrefixes =
15+ private static readonly string [ ] ReservedQueryHandlerPrefixes =
1816 {
1917 TemporalRuntime . ReservedNamePrefix ,
2018 "__stack_trace" ,
@@ -28,12 +26,10 @@ private WorkflowQueryDefinition(string? name, string? description, MethodInfo? m
2826 {
2927 if ( ! bypassReserved && name != null )
3028 {
31- foreach ( var reservedQ in ReservedQueryHandlerPrefixes )
29+ var reservedQ = ReservedQueryHandlerPrefixes . FirstOrDefault ( p => name . StartsWith ( p ) ) ;
30+ if ( ! string . IsNullOrEmpty ( reservedQ ) )
3231 {
33- if ( name . StartsWith ( reservedQ ) )
34- {
35- throw new ArgumentException ( $ "Query handler name { name } cannot start with { reservedQ } ") ;
36- }
32+ throw new ArgumentException ( $ "Query handler name { name } cannot start with { reservedQ } ") ;
3733 }
3834 }
3935 Name = name ;
@@ -127,21 +123,6 @@ public static WorkflowQueryDefinition CreateWithoutAttribute(
127123 return new ( name , description , null , del ) ;
128124 }
129125
130- /// <summary>
131- /// Internal version of <see cref="CreateWithoutAttribute" /> that bypasses reserved name checks.
132- /// </summary>
133- /// <param name="name">Query name. Null for dynamic query.</param>
134- /// <param name="del">Query delegate.</param>
135- /// <param name="description">Optional description. WARNING: This setting is experimental.
136- /// </param>
137- /// <returns>Query definition.</returns>
138- internal static WorkflowQueryDefinition CreateWithoutAttributeReservedName (
139- string name , Delegate del , string ? description = null )
140- {
141- AssertValid ( del . Method , dynamic : name == null ) ;
142- return new ( name , description , null , del , bypassReserved : true ) ;
143- }
144-
145126 /// <summary>
146127 /// Gets the query name for calling or fail if no attribute or if dynamic.
147128 /// </summary>
0 commit comments