|
1 | | -namespaceTUnit.Core.Hooks; |
| 1 | +usingSystem.Diagnostics.CodeAnalysis; |
| 2 | +usingSystem.Reflection; |
| 3 | +usingTUnit.Core.Extensions; |
| 4 | +usingTUnit.Core.Interfaces; |
2 | 5 |
|
3 | | -publicclassHookMethod |
| 6 | +namespaceTUnit.Core.Hooks; |
| 7 | + |
| 8 | +#if !DEBUG |
| 9 | +[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] |
| 10 | +#endif |
| 11 | +publicabstractrecordHookMethod |
4 | 12 | { |
5 | | -publicStaticHookMethod?StaticHookMethod{get;} |
6 | | -publicInstanceHookMethod?InstanceHookMethod{get;} |
| 13 | +publicrequiredMethodMetadataMethodInfo{get;init;} |
| 14 | + |
| 15 | +[field:AllowNull,MaybeNull] |
| 16 | +publicstringName=>field??=$"{ClassType.Name}.{MethodInfo.Name}({string.Join(", ",MethodInfo.Parameters.Select(x =>x.Name))})"; |
| 17 | + |
| 18 | +publicabstractTypeClassType{get;} |
| 19 | +publicvirtualAssembly?Assembly=>ClassType?.Assembly; |
| 20 | + |
| 21 | +[field:AllowNull,MaybeNull] |
| 22 | +publicIEnumerable<Attribute>Attributes=>field??=MethodInfo.GetCustomAttributes(); |
| 23 | + |
| 24 | +publicTAttribute?GetAttribute<TAttribute>()whereTAttribute:Attribute=>Attributes.OfType<TAttribute>().FirstOrDefault(); |
7 | 25 |
|
8 | | -publicHookMethod(InstanceHookMethodinstanceHookMethod) |
9 | | -{ |
10 | | -InstanceHookMethod=instanceHookMethod; |
11 | | -} |
| 26 | +/// <summary> |
| 27 | +/// Gets the timeout for this hook method. This will be set during hook registration |
| 28 | +/// by the event receiver infrastructure, falling back to the default 5-minute timeout. |
| 29 | +/// </summary> |
| 30 | +publicTimeSpan?Timeout{get;internalset;}=TimeSpan.FromMinutes(5); |
12 | 31 |
|
13 | | -publicHookMethod(StaticHookMethodstaticHookMethod) |
14 | | -{ |
15 | | -StaticHookMethod=staticHookMethod; |
16 | | -} |
| 32 | +publicrequiredIHookExecutorHookExecutor{get;init;} |
17 | 33 |
|
18 | | -publicstaticimplicitoperatorHookMethod(InstanceHookMethodinstanceHookMethod)=>new(instanceHookMethod); |
19 | | -publicstaticimplicitoperatorHookMethod(StaticHookMethodstaticHookMethod)=>new(staticHookMethod); |
| 34 | +publicrequiredintOrder{get;init;} |
| 35 | + |
| 36 | +publicrequiredintRegistrationIndex{get;init;} |
20 | 37 | } |
0 commit comments