5
5
6
6
namespace System . Reflection . Emit
7
7
{
8
- public class ParameterBuilder
8
+ internal sealed class RuntimeParameterBuilder : ParameterBuilder
9
9
{
10
10
// Set the default value of the parameter
11
- public virtual void SetConstant ( object ? defaultValue )
11
+ public override void SetConstant ( object ? defaultValue )
12
12
{
13
13
RuntimeTypeBuilder . SetConstantValue (
14
14
_methodBuilder . GetModuleBuilder ( ) ,
@@ -17,28 +17,16 @@ public virtual void SetConstant(object? defaultValue)
17
17
defaultValue ) ;
18
18
}
19
19
20
- // Use this function if client decides to form the custom attribute blob themselves
21
- public void SetCustomAttribute ( ConstructorInfo con , byte [ ] binaryAttribute )
20
+ protected override void SetCustomAttributeCore ( ConstructorInfo con , ReadOnlySpan < byte > binaryAttribute )
22
21
{
23
- ArgumentNullException . ThrowIfNull ( con ) ;
24
- ArgumentNullException . ThrowIfNull ( binaryAttribute ) ;
25
-
26
22
RuntimeTypeBuilder . DefineCustomAttribute (
27
23
_methodBuilder . GetModuleBuilder ( ) ,
28
24
_token ,
29
25
( ( RuntimeModuleBuilder ) _methodBuilder . GetModule ( ) ) . GetMethodMetadataToken ( con ) ,
30
26
binaryAttribute ) ;
31
27
}
32
28
33
- // Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder
34
- public void SetCustomAttribute ( CustomAttributeBuilder customBuilder )
35
- {
36
- ArgumentNullException . ThrowIfNull ( customBuilder ) ;
37
-
38
- customBuilder . CreateCustomAttribute ( ( RuntimeModuleBuilder ) ( _methodBuilder . GetModule ( ) ) , _token ) ;
39
- }
40
-
41
- internal ParameterBuilder (
29
+ internal RuntimeParameterBuilder (
42
30
RuntimeMethodBuilder methodBuilder ,
43
31
int sequence ,
44
32
ParameterAttributes attributes ,
@@ -62,17 +50,11 @@ internal int GetToken()
62
50
return _token ;
63
51
}
64
52
65
- public virtual string ? Name => _name ;
66
-
67
- public virtual int Position => _position ;
68
-
69
- public virtual int Attributes => ( int ) _attributes ;
70
-
71
- public bool IsIn => ( _attributes & ParameterAttributes . In ) != 0 ;
53
+ public override string ? Name => _name ;
72
54
73
- public bool IsOut => ( _attributes & ParameterAttributes . Out ) != 0 ;
55
+ public override int Position => _position ;
74
56
75
- public bool IsOptional => ( _attributes & ParameterAttributes . Optional ) != 0 ;
57
+ public override int Attributes => ( int ) _attributes ;
76
58
77
59
private readonly string ? _name ;
78
60
private readonly int _position ;
0 commit comments