blob: 964a2ff6b630a51f6e9d2a7ec0f04f7758d3377f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
//
// Mono.ILASM.CustomAttr
//
// Author(s):
// Jackson Harper (Jackson@LatitudeGeo.com)
//
// (C) 2003 Jackson Harper, All rights reserved
//
using System;
using System.Collections;
namespace Mono.ILASM {
public interface ICustomAttrTarget {
void AddCustomAttribute (CustomAttr customattr);
}
public class CustomAttr {
private BaseMethodRef method_ref;
private byte[] data;
public CustomAttr (BaseMethodRef method_ref, byte[] data)
{
this.method_ref = method_ref;
this.data = data;
}
public void AddTo (CodeGen code_gen, PEAPI.MetaDataElement elem)
{
method_ref.Resolve (code_gen);
code_gen.PEFile.AddCustomAttribute (method_ref.PeapiMethod, data, elem);
}
public bool IsSuppressUnmanaged (CodeGen codegen)
{
string asmname = "";
BaseTypeRef owner = method_ref.Owner;
if (owner == null)
return false;
ExternTypeRef etr = owner as ExternTypeRef;
if (etr != null) {
ExternAssembly ea = etr.ExternRef as ExternAssembly;
if (ea != null)
asmname = ea.Name;
}
return (owner.FullName == "System.Security.SuppressUnmanagedCodeSecurityAttribute"
&& (asmname == "mscorlib" || codegen.IsThisAssembly ("mscorlib")) );
}
}
}
|