1
1
using System ;
2
2
using System . Collections . Concurrent ;
3
+ using System . Linq ;
3
4
using System . Reflection ;
4
5
using System . Threading . Tasks ;
5
6
using Temporalio . Runtime ;
@@ -11,10 +12,7 @@ namespace Temporalio.Workflows
11
12
/// </summary>
12
13
public class WorkflowQueryDefinition
13
14
{
14
- /// <summary>
15
- /// All known reserved query handler prefixes.
16
- /// </summary>
17
- internal static readonly string [ ] ReservedQueryHandlerPrefixes =
15
+ private static readonly string [ ] ReservedQueryHandlerPrefixes =
18
16
{
19
17
TemporalRuntime . ReservedNamePrefix ,
20
18
"__stack_trace" ,
@@ -24,16 +22,14 @@ public class WorkflowQueryDefinition
24
22
private static readonly ConcurrentDictionary < MethodInfo , WorkflowQueryDefinition > MethodDefinitions = new ( ) ;
25
23
private static readonly ConcurrentDictionary < PropertyInfo , WorkflowQueryDefinition > PropertyDefinitions = new ( ) ;
26
24
27
- private WorkflowQueryDefinition ( string ? name , string ? description , MethodInfo ? method , Delegate ? del , bool bypassReserved = false )
25
+ private WorkflowQueryDefinition ( string ? name , string ? description , MethodInfo ? method , Delegate ? del )
28
26
{
29
- if ( ! bypassReserved && name != null )
27
+ if ( name != null )
30
28
{
31
- foreach ( var reservedQ in ReservedQueryHandlerPrefixes )
29
+ var reservedQ = ReservedQueryHandlerPrefixes . FirstOrDefault ( p => name . StartsWith ( p ) ) ;
30
+ if ( ! string . IsNullOrEmpty ( reservedQ ) )
32
31
{
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 } ") ;
37
33
}
38
34
}
39
35
Name = name ;
@@ -127,21 +123,6 @@ public static WorkflowQueryDefinition CreateWithoutAttribute(
127
123
return new ( name , description , null , del ) ;
128
124
}
129
125
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
-
145
126
/// <summary>
146
127
/// Gets the query name for calling or fail if no attribute or if dynamic.
147
128
/// </summary>
0 commit comments