Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,453 @@
//
// AggressiveRefletionReader.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
using Mono.Cecil.Metadata;
using Mono.Cecil.Signatures;
internal sealed class AggressiveReflectionReader : ReflectionReader {
public AggressiveReflectionReader (ModuleDefinition module) : base (module)
{
}
public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
{
base.VisitTypeDefinitionCollection (types);
ReadGenericParameterConstraints ();
ReadClassLayoutInfos ();
ReadFieldLayoutInfos ();
ReadPInvokeInfos ();
ReadProperties ();
ReadEvents ();
ReadSemantics ();
ReadInterfaces ();
ReadOverrides ();
ReadSecurityDeclarations ();
ReadCustomAttributes ();
ReadConstants ();
ReadExternTypes ();
ReadMarshalSpecs ();
ReadInitialValues ();
m_events = null;
m_properties = null;
m_parameters = null;
}
void ReadGenericParameterConstraints ()
{
if (!m_tHeap.HasTable (GenericParamConstraintTable.RId))
return;
GenericParamConstraintTable gpcTable = m_tableReader.GetGenericParamConstraintTable ();
for (int i = 0; i < gpcTable.Rows.Count; i++) {
GenericParamConstraintRow gpcRow = gpcTable [i];
GenericParameter gp = GetGenericParameterAt (gpcRow.Owner);
gp.Constraints.Add (GetTypeDefOrRef (gpcRow.Constraint, new GenericContext (gp.Owner)));
}
}
void ReadClassLayoutInfos ()
{
if (!m_tHeap.HasTable (ClassLayoutTable.RId))
return;
ClassLayoutTable clTable = m_tableReader.GetClassLayoutTable ();
for (int i = 0; i < clTable.Rows.Count; i++) {
ClassLayoutRow clRow = clTable [i];
TypeDefinition type = GetTypeDefAt (clRow.Parent);
type.PackingSize = clRow.PackingSize;
type.ClassSize = clRow.ClassSize;
}
}
void ReadFieldLayoutInfos ()
{
if (!m_tHeap.HasTable (FieldLayoutTable.RId))
return;
FieldLayoutTable flTable = m_tableReader.GetFieldLayoutTable ();
for (int i = 0; i < flTable.Rows.Count; i++) {
FieldLayoutRow flRow = flTable [i];
FieldDefinition field = GetFieldDefAt (flRow.Field);
field.Offset = flRow.Offset;
}
}
void ReadPInvokeInfos ()
{
if (!m_tHeap.HasTable (ImplMapTable.RId))
return;
ImplMapTable imTable = m_tableReader.GetImplMapTable ();
for (int i = 0; i < imTable.Rows.Count; i++) {
ImplMapRow imRow = imTable [i];
if (imRow.MemberForwarded.TokenType == TokenType.Method) { // should always be true
MethodDefinition meth = GetMethodDefAt (imRow.MemberForwarded.RID);
meth.PInvokeInfo = new PInvokeInfo (
meth, imRow.MappingFlags, MetadataRoot.Streams.StringsHeap [imRow.ImportName],
Module.ModuleReferences [(int) imRow.ImportScope - 1]);
}
}
}
void ReadProperties ()
{
if (!m_tHeap.HasTable (PropertyTable.RId)) {
m_properties = new PropertyDefinition [0];
return;
}
PropertyTable propsTable = m_tableReader.GetPropertyTable ();
PropertyMapTable pmapTable = m_tableReader.GetPropertyMapTable ();
m_properties = new PropertyDefinition [propsTable.Rows.Count];
for (int i = 0; i < pmapTable.Rows.Count; i++) {
PropertyMapRow pmapRow = pmapTable [i];
if (pmapRow.Parent == 0)
continue;
TypeDefinition owner = GetTypeDefAt (pmapRow.Parent);
GenericContext context = new GenericContext (owner);
int start = (int) pmapRow.PropertyList, last = propsTable.Rows.Count + 1, end;
if (i < pmapTable.Rows.Count - 1)
end = (int) pmapTable [i + 1].PropertyList;
else
end = last;
if (end > last)
end = last;
for (int j = start; j < end; j++) {
PropertyRow prow = propsTable [j - 1];
PropertySig psig = m_sigReader.GetPropSig (prow.Type);
PropertyDefinition pdef = new PropertyDefinition (
m_root.Streams.StringsHeap [prow.Name],
GetTypeRefFromSig (psig.Type, context),
prow.Flags);
pdef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Property, j - 1);
pdef.PropertyType = GetModifierType (psig.CustomMods, pdef.PropertyType);
if (!IsDeleted (pdef))
owner.Properties.Add (pdef);
m_properties [j - 1] = pdef;
}
}
}
void ReadEvents ()
{
if (!m_tHeap.HasTable (EventTable.RId)) {
m_events = new EventDefinition [0];
return;
}
EventTable evtTable = m_tableReader.GetEventTable ();
EventMapTable emapTable = m_tableReader.GetEventMapTable ();
m_events = new EventDefinition [evtTable.Rows.Count];
for (int i = 0; i < emapTable.Rows.Count; i++) {
EventMapRow emapRow = emapTable [i];
if (emapRow.Parent == 0)
continue;
TypeDefinition owner = GetTypeDefAt (emapRow.Parent);
GenericContext context = new GenericContext (owner);
int start = (int) emapRow.EventList, last = evtTable.Rows.Count + 1, end;
if (i < (emapTable.Rows.Count - 1))
end = (int) emapTable [i + 1].EventList;
else
end = last;
if (end > last)
end = last;
for (int j = start; j < end; j++) {
EventRow erow = evtTable [j - 1];
EventDefinition edef = new EventDefinition (
m_root.Streams.StringsHeap [erow.Name],
GetTypeDefOrRef (erow.EventType, context), erow.EventFlags);
edef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Event, j - 1);
if (!IsDeleted (edef))
owner.Events.Add (edef);
m_events [j - 1] = edef;
}
}
}
void ReadSemantics ()
{
if (!m_tHeap.HasTable (MethodSemanticsTable.RId))
return;
MethodSemanticsTable semTable = m_tableReader.GetMethodSemanticsTable ();
for (int i = 0; i < semTable.Rows.Count; i++) {
MethodSemanticsRow semRow = semTable [i];
MethodDefinition semMeth = GetMethodDefAt (semRow.Method);
semMeth.SemanticsAttributes = semRow.Semantics;
switch (semRow.Association.TokenType) {
case TokenType.Event :
EventDefinition evt = GetEventDefAt (semRow.Association.RID);
if ((semRow.Semantics & MethodSemanticsAttributes.AddOn) != 0)
evt.AddMethod = semMeth;
else if ((semRow.Semantics & MethodSemanticsAttributes.Fire) != 0)
evt.InvokeMethod = semMeth;
else if ((semRow.Semantics & MethodSemanticsAttributes.RemoveOn) != 0)
evt.RemoveMethod = semMeth;
break;
case TokenType.Property :
PropertyDefinition prop = GetPropertyDefAt (semRow.Association.RID);
if ((semRow.Semantics & MethodSemanticsAttributes.Getter) != 0)
prop.GetMethod = semMeth;
else if ((semRow.Semantics & MethodSemanticsAttributes.Setter) != 0)
prop.SetMethod = semMeth;
break;
}
}
}
void ReadInterfaces ()
{
if (!m_tHeap.HasTable (InterfaceImplTable.RId))
return;
InterfaceImplTable intfsTable = m_tableReader.GetInterfaceImplTable ();
for (int i = 0; i < intfsTable.Rows.Count; i++) {
InterfaceImplRow intfsRow = intfsTable [i];
TypeDefinition owner = GetTypeDefAt (intfsRow.Class);
owner.Interfaces.Add (GetTypeDefOrRef (intfsRow.Interface, new GenericContext (owner)));
}
}
void ReadOverrides ()
{
if (!m_tHeap.HasTable (MethodImplTable.RId))
return;
MethodImplTable implTable = m_tableReader.GetMethodImplTable ();
for (int i = 0; i < implTable.Rows.Count; i++) {
MethodImplRow implRow = implTable [i];
if (implRow.MethodBody.TokenType == TokenType.Method) {
MethodDefinition owner = GetMethodDefAt (implRow.MethodBody.RID);
switch (implRow.MethodDeclaration.TokenType) {
case TokenType.Method :
owner.Overrides.Add (
GetMethodDefAt (implRow.MethodDeclaration.RID));
break;
case TokenType.MemberRef :
owner.Overrides.Add (
(MethodReference) GetMemberRefAt (
implRow.MethodDeclaration.RID, new GenericContext (owner)));
break;
}
}
}
}
void ReadSecurityDeclarations ()
{
if (!m_tHeap.HasTable (DeclSecurityTable.RId))
return;
DeclSecurityTable dsTable = m_tableReader.GetDeclSecurityTable ();
for (int i = 0; i < dsTable.Rows.Count; i++) {
DeclSecurityRow dsRow = dsTable [i];
SecurityDeclaration dec = BuildSecurityDeclaration (dsRow);
if (dsRow.Parent.RID == 0)
continue;
IHasSecurity owner = null;
switch (dsRow.Parent.TokenType) {
case TokenType.Assembly :
owner = this.Module.Assembly;
break;
case TokenType.TypeDef :
owner = GetTypeDefAt (dsRow.Parent.RID);
break;
case TokenType.Method :
owner = GetMethodDefAt (dsRow.Parent.RID);
break;
}
owner.SecurityDeclarations.Add (dec);
}
}
void ReadCustomAttributes ()
{
if (!m_tHeap.HasTable (CustomAttributeTable.RId))
return;
CustomAttributeTable caTable = m_tableReader.GetCustomAttributeTable ();
for (int i = 0; i < caTable.Rows.Count; i++) {
CustomAttributeRow caRow = caTable [i];
MethodReference ctor;
if (caRow.Type.RID == 0)
continue;
if (caRow.Type.TokenType == TokenType.Method)
ctor = GetMethodDefAt (caRow.Type.RID);
else
ctor = GetMemberRefAt (caRow.Type.RID, new GenericContext ()) as MethodReference;
CustomAttrib ca = m_sigReader.GetCustomAttrib (caRow.Value, ctor);
CustomAttribute cattr = BuildCustomAttribute (ctor, m_root.Streams.BlobHeap.Read (caRow.Value), ca);
if (caRow.Parent.RID == 0)
continue;
ICustomAttributeProvider owner = null;
switch (caRow.Parent.TokenType) {
case TokenType.Assembly :
owner = this.Module.Assembly;
break;
case TokenType.Module :
owner = this.Module;
break;
case TokenType.TypeDef :
owner = GetTypeDefAt (caRow.Parent.RID);
break;
case TokenType.TypeRef :
owner = GetTypeRefAt (caRow.Parent.RID);
break;
case TokenType.Field :
owner = GetFieldDefAt (caRow.Parent.RID);
break;
case TokenType.Method :
owner = GetMethodDefAt (caRow.Parent.RID);
break;
case TokenType.Property :
owner = GetPropertyDefAt (caRow.Parent.RID);
break;
case TokenType.Event :
owner = GetEventDefAt (caRow.Parent.RID);
break;
case TokenType.Param :
owner = GetParamDefAt (caRow.Parent.RID);
break;
case TokenType.GenericParam :
owner = GetGenericParameterAt (caRow.Parent.RID);
break;
default :
//TODO: support other ?
break;
}
if (owner != null)
owner.CustomAttributes.Add (cattr);
}
}
void ReadConstants ()
{
if (!m_tHeap.HasTable (ConstantTable.RId))
return;
ConstantTable csTable = m_tableReader.GetConstantTable ();
for (int i = 0; i < csTable.Rows.Count; i++) {
ConstantRow csRow = csTable [i];
object constant = GetConstant (csRow.Value, csRow.Type);
IHasConstant owner = null;
switch (csRow.Parent.TokenType) {
case TokenType.Field :
owner = GetFieldDefAt (csRow.Parent.RID);
break;
case TokenType.Property :
owner = GetPropertyDefAt (csRow.Parent.RID);
break;
case TokenType.Param :
owner = GetParamDefAt (csRow.Parent.RID);
break;
}
owner.Constant = constant;
}
}
void ReadExternTypes ()
{
base.VisitExternTypeCollection (Module.ExternTypes);
}
void ReadMarshalSpecs ()
{
if (!m_tHeap.HasTable (FieldMarshalTable.RId))
return;
FieldMarshalTable fmTable = m_tableReader.GetFieldMarshalTable ();
for (int i = 0; i < fmTable.Rows.Count; i++) {
FieldMarshalRow fmRow = fmTable [i];
if (fmRow.Parent.RID == 0)
continue;
IHasMarshalSpec owner = null;
switch (fmRow.Parent.TokenType) {
case TokenType.Field:
owner = GetFieldDefAt (fmRow.Parent.RID);
break;
case TokenType.Param:
owner = GetParamDefAt (fmRow.Parent.RID);
break;
}
owner.MarshalSpec = BuildMarshalDesc (
m_sigReader.GetMarshalSig (fmRow.NativeType), owner);
}
}
void ReadInitialValues ()
{
if (!m_tHeap.HasTable (FieldRVATable.RId))
return;
FieldRVATable frTable = m_tableReader.GetFieldRVATable ();
for (int i = 0; i < frTable.Rows.Count; i++) {
FieldRVARow frRow = frTable [i];
FieldDefinition field = GetFieldDefAt (frRow.Field);
field.RVA = frRow.RVA;
SetInitialValue (field);
}
}
}
}

View File

@@ -0,0 +1,59 @@
//
// ArrayDimension.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
internal sealed class ArrayDimension {
int m_lowerBound;
int m_upperBound;
public int LowerBound {
get { return m_lowerBound; }
set { m_lowerBound = value; }
}
public int UpperBound {
get { return m_upperBound; }
set { m_upperBound = value; }
}
public ArrayDimension (int lb, int ub)
{
m_lowerBound = lb;
m_upperBound = ub;
}
public override string ToString ()
{
if (m_upperBound == 0)
return string.Empty;
return string.Concat (m_lowerBound, "...", m_upperBound);
}
}
}

View File

@@ -0,0 +1,88 @@
//
// ArrayDimensionCollection.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Generated by /CodeGen/cecil-gen.rb do not edit
// Wed Sep 27 12:46:53 CEST 2006
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
using System.Collections;
using Mono.Cecil.Cil;
internal sealed class ArrayDimensionCollection : CollectionBase {
ArrayType m_container;
public ArrayDimension this [int index] {
get { return List [index] as ArrayDimension; }
set { List [index] = value; }
}
public ArrayType Container {
get { return m_container; }
}
public ArrayDimensionCollection (ArrayType container)
{
m_container = container;
}
public void Add (ArrayDimension value)
{
List.Add (value);
}
public bool Contains (ArrayDimension value)
{
return List.Contains (value);
}
public int IndexOf (ArrayDimension value)
{
return List.IndexOf (value);
}
public void Insert (int index, ArrayDimension value)
{
List.Insert (index, value);
}
public void Remove (ArrayDimension value)
{
List.Remove (value);
}
protected override void OnValidate (object o)
{
if (! (o is ArrayDimension))
throw new ArgumentException ("Must be of type " + typeof (ArrayDimension).FullName);
}
}
}

View File

@@ -0,0 +1,109 @@
//
// ArrayType.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System.Text;
using Mono.Cecil.Signatures;
internal sealed class ArrayType : TypeSpecification {
private ArrayDimensionCollection m_dimensions;
public ArrayDimensionCollection Dimensions {
get { return m_dimensions; }
}
public int Rank {
get { return m_dimensions.Count; }
}
public bool IsSizedArray {
get {
if (this.Rank != 1)
return false;
ArrayDimension dim = m_dimensions [0];
return dim.UpperBound == 0;
}
}
public override string Name {
get { return string.Concat (base.Name, Suffix ()); }
}
public override string FullName {
get { return string.Concat (base.FullName, Suffix ()); }
}
string Suffix ()
{
StringBuilder sb = new StringBuilder ();
sb.Append ("[");
for (int i = 0; i < m_dimensions.Count; i++) {
ArrayDimension dim = m_dimensions [i];
string rank = dim.ToString ();
if (i < m_dimensions.Count - 1)
sb.Append (",");
if (rank.Length > 0) {
sb.Append (" ");
sb.Append (rank);
}
}
sb.Append ("]");
return sb.ToString ();
}
internal ArrayType (TypeReference elementType, ArrayShape shape) : base (elementType)
{
m_dimensions = new ArrayDimensionCollection (this);
for (int i = 0; i < shape.Rank; i++) {
int lower = 0, upper = 0;
if (i < shape.NumSizes)
if (i < shape.NumLoBounds) {
lower = shape.LoBounds [i];
upper = shape.LoBounds [i] + shape.Sizes [i] - 1;
} else
upper = shape.Sizes [i] - 1;
m_dimensions.Add (new ArrayDimension (lower, upper));
}
}
public ArrayType (TypeReference elementType, int rank) : base (elementType)
{
m_dimensions = new ArrayDimensionCollection (this);
for (int i = 0; i < rank; i++)
m_dimensions.Add (new ArrayDimension (0, 0));
}
public ArrayType (TypeReference elementType) : this (elementType, 1)
{
}
}
}

View File

@@ -0,0 +1,169 @@
//
// AssemblyDefinition.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
using System.Collections;
using Mono.Cecil.Metadata;
internal class AssemblyDefinition : ICustomAttributeProvider,
IHasSecurity, IAnnotationProvider, IReflectionStructureVisitable {
MetadataToken m_token;
AssemblyNameDefinition m_asmName;
ModuleDefinitionCollection m_modules;
SecurityDeclarationCollection m_secDecls;
CustomAttributeCollection m_customAttrs;
MethodDefinition m_ep;
TargetRuntime m_runtime;
AssemblyKind m_kind;
ModuleDefinition m_mainModule;
StructureReader m_reader;
IAssemblyResolver m_resolver;
IDictionary m_annotations;
public MetadataToken MetadataToken {
get { return m_token; }
set { m_token = value; }
}
public AssemblyNameDefinition Name {
get { return m_asmName; }
}
public ModuleDefinitionCollection Modules {
get { return m_modules; }
}
public bool HasSecurityDeclarations {
get { return (m_secDecls == null) ? false : (m_secDecls.Count > 0); }
}
public SecurityDeclarationCollection SecurityDeclarations {
get {
if (m_secDecls == null)
m_secDecls = new SecurityDeclarationCollection (this);
return m_secDecls;
}
}
public bool HasCustomAttributes {
get { return (m_customAttrs == null) ? false : (m_customAttrs.Count > 0); }
}
public CustomAttributeCollection CustomAttributes {
get {
if (m_customAttrs == null)
m_customAttrs = new CustomAttributeCollection (this);
return m_customAttrs;
}
}
public MethodDefinition EntryPoint {
get { return m_ep; }
set { m_ep = value; }
}
public TargetRuntime Runtime {
get { return m_runtime; }
set { m_runtime = value; }
}
public AssemblyKind Kind {
get { return m_kind; }
set { m_kind = value; }
}
public ModuleDefinition MainModule {
get {
if (m_mainModule == null) {
foreach (ModuleDefinition module in m_modules) {
if (module.Main) {
m_mainModule = module;
break;
}
}
}
return m_mainModule;
}
}
internal StructureReader Reader {
get { return m_reader; }
}
public IAssemblyResolver Resolver {
get { return m_resolver; }
set { m_resolver = value; }
}
IDictionary IAnnotationProvider.Annotations {
get {
if (m_annotations == null)
m_annotations = new Hashtable ();
return m_annotations;
}
}
internal AssemblyDefinition (AssemblyNameDefinition name)
{
if (name == null)
throw new ArgumentNullException ("name");
m_asmName = name;
m_modules = new ModuleDefinitionCollection (this);
m_resolver = new DefaultAssemblyResolver ();
}
internal AssemblyDefinition (AssemblyNameDefinition name, StructureReader reader) : this (name)
{
m_reader = reader;
}
public void Accept (IReflectionStructureVisitor visitor)
{
visitor.VisitAssemblyDefinition (this);
m_asmName.Accept (visitor);
m_modules.Accept (visitor);
visitor.TerminateAssemblyDefinition (this);
}
public override string ToString ()
{
return m_asmName.FullName;
}
}
}

View File

@@ -0,0 +1,183 @@
//
// AssemblyFactory.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
using System.IO;
using SR = System.Reflection;
using Mono.Cecil.Binary;
internal sealed class AssemblyFactory {
AssemblyFactory ()
{
}
static AssemblyDefinition GetAssembly (ImageReader irv, bool manifestOnly)
{
StructureReader srv = new StructureReader (irv, manifestOnly);
AssemblyDefinition asm = new AssemblyDefinition (
new AssemblyNameDefinition (), srv);
asm.Accept (srv);
return asm;
}
static AssemblyDefinition GetAssembly (ImageReader reader)
{
return GetAssembly (reader, false);
}
static AssemblyDefinition GetAssemblyManifest (ImageReader reader)
{
return GetAssembly (reader, true);
}
public static AssemblyDefinition GetAssembly (string file)
{
return GetAssembly (ImageReader.Read (file));
}
public static AssemblyDefinition GetAssembly (byte [] assembly)
{
return GetAssembly (ImageReader.Read (assembly));
}
public static AssemblyDefinition GetAssembly (Stream stream)
{
return GetAssembly (ImageReader.Read (stream));
}
public static AssemblyDefinition GetAssemblyManifest (string file)
{
return GetAssemblyManifest (ImageReader.Read (file));
}
public static AssemblyDefinition GetAssemblyManifest (byte [] assembly)
{
return GetAssemblyManifest (ImageReader.Read (assembly));
}
public static AssemblyDefinition GetAssemblyManifest (Stream stream)
{
return GetAssemblyManifest (ImageReader.Read (stream));
}
static TargetRuntime CurrentRuntime ()
{
Version corlib = typeof (object).Assembly.GetName ().Version;
switch (corlib.Major) {
case 1:
return corlib.Minor == 0 ? TargetRuntime.NET_1_0 : TargetRuntime.NET_1_1;
case 2:
return TargetRuntime.NET_2_0;
case 4:
return TargetRuntime.NET_4_0;
default:
throw new NotSupportedException ();
}
}
public static AssemblyDefinition DefineAssembly (string name, AssemblyKind kind)
{
return DefineAssembly (name, name, CurrentRuntime (), kind);
}
public static AssemblyDefinition DefineAssembly (string name, TargetRuntime rt, AssemblyKind kind)
{
return DefineAssembly (name, name, rt, kind);
}
public static AssemblyDefinition DefineAssembly (string assemblyName, string moduleName, TargetRuntime rt, AssemblyKind kind)
{
AssemblyNameDefinition asmName = new AssemblyNameDefinition ();
asmName.Name = assemblyName;
AssemblyDefinition asm = new AssemblyDefinition (asmName);
asm.Runtime = rt;
asm.Kind = kind;
ModuleDefinition main = new ModuleDefinition (moduleName, asm, true);
asm.Modules.Add (main);
return asm;
}
static void WriteAssembly (AssemblyDefinition asm, BinaryWriter bw)
{
asm.Accept (new StructureWriter (asm, bw));
}
public static void SaveAssembly (AssemblyDefinition asm, string file)
{
using (FileStream fs = new FileStream (
file, FileMode.Create, FileAccess.Write, FileShare.None)) {
SaveAssembly (asm, fs);
asm.MainModule.Image.SetFileInfo (new FileInfo (file));
}
}
public static void SaveAssembly (AssemblyDefinition asm, out byte [] assembly)
{
MemoryBinaryWriter bw = new MemoryBinaryWriter ();
SaveAssembly (asm, bw.BaseStream);
assembly = bw.ToArray ();
}
public static void SaveAssembly (AssemblyDefinition asm, Stream stream)
{
BinaryWriter bw = new BinaryWriter (stream);
try {
WriteAssembly (asm, bw);
} finally {
bw.Close ();
}
foreach (ModuleDefinition module in asm.Modules)
if (module.Controller.Writer.SaveSymbols)
module.Controller.Writer.WriteSymbols (module);
}
#if !CF_1_0 && !CF_2_0
public static SR.Assembly CreateReflectionAssembly (AssemblyDefinition asm, AppDomain domain)
{
using (MemoryBinaryWriter writer = new MemoryBinaryWriter ()) {
WriteAssembly (asm, writer);
return domain.Load (writer.ToArray ());
}
}
public static SR.Assembly CreateReflectionAssembly (AssemblyDefinition asm)
{
return CreateReflectionAssembly (asm, AppDomain.CurrentDomain);
}
#endif
}
}

View File

@@ -0,0 +1,41 @@
//
// AssemblyFlags.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
[Flags]
internal enum AssemblyFlags : uint {
PublicKey = 0x0001,
SideBySideCompatible = 0x0000,
Retargetable = 0x0100,
EnableJITcompileTracking = 0x8000,
DisableJITcompileOptimizer = 0x4000
}
}

View File

@@ -0,0 +1,37 @@
//
// AssemblyHashAlgorithm.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
internal enum AssemblyHashAlgorithm : uint {
None = 0x0000,
Reserved = 0x8003, // MD5
SHA1 = 0x8004
}
}

View File

@@ -0,0 +1,62 @@
//
// AssemblyInfo.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if !EMBEDDED
[assembly: AssemblyTitle ("Mono.Cecil")]
[assembly: AssemblyDescription ("Library for reading and writing CIL images")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyProduct ("Mono.Cecil")]
[assembly: AssemblyCopyright ("(C) 2005 - 2007, Jb Evain")]
[assembly: AssemblyCulture ("")]
[assembly: CLSCompliant (false)]
[assembly: ComVisible (false)]
[assembly: AssemblyVersion (
//
// DO NOT MODIFY THE STRING BELOWS WITOUT UPDATING cecil.pc.in in mono/data
//
"0.6.9.0"
//
// DO NOT MODIFY THE STRING ABOVE WITHOUT UPDATING cecil.pc.in in mono/data
)]
#if KEYFILE
[assembly: AssemblyKeyFile("../../mono.snk")]
#endif
#endif

View File

@@ -0,0 +1,36 @@
//
// AssemblyKind.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
internal enum AssemblyKind {
Dll,
Console,
Windows
}
}

View File

@@ -0,0 +1,51 @@
//
// AssemblyLinkedResource.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
internal sealed class AssemblyLinkedResource : Resource {
private AssemblyNameReference m_asmRef;
public AssemblyNameReference Assembly {
get { return m_asmRef; }
set { m_asmRef = value; }
}
public AssemblyLinkedResource (string name, ManifestResourceAttributes flags,
AssemblyNameReference asmRef) : base (name, flags)
{
m_asmRef = asmRef;
}
public override void Accept (IReflectionStructureVisitor visitor)
{
visitor.VisitAssemblyLinkedResource (this);
}
}
}

View File

@@ -0,0 +1,52 @@
//
// AssemblyNameDefinition.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
internal sealed class AssemblyNameDefinition : AssemblyNameReference {
public override byte [] Hash {
get { return new byte [0]; }
}
public AssemblyNameDefinition () : base()
{
}
public AssemblyNameDefinition (string name, string culture, Version version) : base (name, culture, version)
{
}
public override void Accept (IReflectionStructureVisitor visitor)
{
visitor.VisitAssemblyNameDefinition (this);
}
}
}

View File

@@ -0,0 +1,275 @@
//
// AssemblyNameReference.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
using System.Collections;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using Mono.Cecil.Metadata;
internal class AssemblyNameReference : IMetadataScope, IAnnotationProvider, IReflectionStructureVisitable {
string m_name;
string m_culture;
Version m_version;
AssemblyFlags m_flags;
byte [] m_publicKey;
byte [] m_publicKeyToken;
AssemblyHashAlgorithm m_hashAlgo;
byte [] m_hash;
MetadataToken m_token;
IDictionary m_annotations;
bool m_fullNameDiscarded = true;
string m_fullName;
public string Name {
get { return m_name; }
set {
m_name = value;
m_fullNameDiscarded = true;
}
}
public string Culture {
get { return m_culture; }
set {
m_culture = value;
m_fullNameDiscarded = true;
}
}
public Version Version {
get { return m_version; }
set {
m_version = value;
m_fullNameDiscarded = true;
}
}
public AssemblyFlags Flags {
get { return m_flags; }
set { m_flags = value; }
}
public bool HasPublicKey {
get { return (m_flags & AssemblyFlags.PublicKey) != 0; }
set {
if (value)
m_flags |= AssemblyFlags.PublicKey;
else
m_flags &= ~AssemblyFlags.PublicKey;
}
}
public bool IsSideBySideCompatible {
get { return (m_flags & AssemblyFlags.SideBySideCompatible) != 0; }
set {
if (value)
m_flags |= AssemblyFlags.SideBySideCompatible;
else
m_flags &= ~AssemblyFlags.SideBySideCompatible;
}
}
public bool IsRetargetable {
get { return (m_flags & AssemblyFlags.Retargetable) != 0; }
set {
if (value)
m_flags |= AssemblyFlags.Retargetable;
else
m_flags &= ~AssemblyFlags.Retargetable;
}
}
public byte [] PublicKey {
get { return m_publicKey; }
set {
m_publicKey = value;
m_publicKeyToken = null;
m_fullNameDiscarded = true;
}
}
public byte [] PublicKeyToken {
get {
#if !CF_1_0
if ((m_publicKeyToken == null || m_publicKeyToken.Length == 0) && (m_publicKey != null && m_publicKey.Length > 0)) {
HashAlgorithm ha;
switch (m_hashAlgo) {
case AssemblyHashAlgorithm.Reserved:
ha = MD5.Create (); break;
default:
// None default to SHA1
ha = SHA1.Create (); break;
}
byte [] hash = ha.ComputeHash (m_publicKey);
// we need the last 8 bytes in reverse order
m_publicKeyToken = new byte [8];
Array.Copy (hash, (hash.Length - 8), m_publicKeyToken, 0, 8);
Array.Reverse (m_publicKeyToken, 0, 8);
}
#endif
return m_publicKeyToken;
}
set {
m_publicKeyToken = value;
m_fullNameDiscarded = true;
}
}
public string FullName {
get {
if (m_fullName != null && !m_fullNameDiscarded)
return m_fullName;
StringBuilder sb = new StringBuilder ();
string sep = ", ";
sb.Append (m_name);
if (m_version != null) {
sb.Append (sep);
sb.Append ("Version=");
sb.Append (m_version.ToString ());
}
sb.Append (sep);
sb.Append ("Culture=");
sb.Append (m_culture == null || m_culture.Length == 0 ? "neutral" : m_culture);
sb.Append (sep);
sb.Append ("PublicKeyToken=");
if (this.PublicKeyToken != null && m_publicKeyToken.Length > 0) {
for (int i = 0 ; i < m_publicKeyToken.Length ; i++) {
sb.Append (m_publicKeyToken [i].ToString ("x2"));
}
} else {
sb.Append ("null");
}
m_fullName = sb.ToString ();
m_fullNameDiscarded = false;
return m_fullName;
}
}
public static AssemblyNameReference Parse (string fullName)
{
if (fullName == null)
throw new ArgumentNullException ("fullName");
if (fullName.Length == 0)
throw new ArgumentException ("Name can not be empty");
AssemblyNameReference name = new AssemblyNameReference ();
string [] tokens = fullName.Split (',');
for (int i = 0; i < tokens.Length; i++) {
string token = tokens [i].Trim ();
if (i == 0) {
name.Name = token;
continue;
}
string [] parts = token.Split ('=');
if (parts.Length != 2)
throw new ArgumentException ("Malformed name");
switch (parts [0]) {
case "Version":
name.Version = new Version (parts [1]);
break;
case "Culture":
name.Culture = parts [1];
break;
case "PublicKeyToken":
string pkToken = parts [1];
if (pkToken == "null")
break;
name.PublicKeyToken = new byte [pkToken.Length / 2];
for (int j = 0; j < name.PublicKeyToken.Length; j++) {
name.PublicKeyToken [j] = Byte.Parse (pkToken.Substring (j * 2, 2), NumberStyles.HexNumber);
}
break;
}
}
return name;
}
public AssemblyHashAlgorithm HashAlgorithm
{
get { return m_hashAlgo; }
set { m_hashAlgo = value; }
}
public virtual byte [] Hash {
get { return m_hash; }
set { m_hash = value; }
}
public MetadataToken MetadataToken {
get { return m_token; }
set { m_token = value; }
}
IDictionary IAnnotationProvider.Annotations {
get {
if (m_annotations == null)
m_annotations = new Hashtable ();
return m_annotations;
}
}
public AssemblyNameReference () : this (string.Empty, string.Empty, new Version (0, 0, 0, 0))
{
}
public AssemblyNameReference (string name, string culture, Version version)
{
if (name == null)
throw new ArgumentNullException ("name");
if (culture == null)
throw new ArgumentNullException ("culture");
m_name = name;
m_culture = culture;
m_version = version;
m_hashAlgo = AssemblyHashAlgorithm.None;
}
public override string ToString ()
{
return this.FullName;
}
public virtual void Accept (IReflectionStructureVisitor visitor)
{
visitor.VisitAssemblyNameReference (this);
}
}
}

View File

@@ -0,0 +1,93 @@
//
// AssemblyNameReferenceCollection.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Generated by /CodeGen/cecil-gen.rb do not edit
// Wed Sep 27 12:46:52 CEST 2006
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
using System.Collections;
using Mono.Cecil.Cil;
internal sealed class AssemblyNameReferenceCollection : CollectionBase, IReflectionStructureVisitable {
ModuleDefinition m_container;
public AssemblyNameReference this [int index] {
get { return List [index] as AssemblyNameReference; }
set { List [index] = value; }
}
public ModuleDefinition Container {
get { return m_container; }
}
public AssemblyNameReferenceCollection (ModuleDefinition container)
{
m_container = container;
}
public void Add (AssemblyNameReference value)
{
List.Add (value);
}
public bool Contains (AssemblyNameReference value)
{
return List.Contains (value);
}
public int IndexOf (AssemblyNameReference value)
{
return List.IndexOf (value);
}
public void Insert (int index, AssemblyNameReference value)
{
List.Insert (index, value);
}
public void Remove (AssemblyNameReference value)
{
List.Remove (value);
}
protected override void OnValidate (object o)
{
if (! (o is AssemblyNameReference))
throw new ArgumentException ("Must be of type " + typeof (AssemblyNameReference).FullName);
}
public void Accept (IReflectionStructureVisitor visitor)
{
visitor.VisitAssemblyNameReferenceCollection (this);
}
}
}

View File

@@ -0,0 +1,264 @@
//
// BaseAssemblyResolver.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System;
using System.Collections;
using System.IO;
using SR = System.Reflection;
using System.Text;
internal abstract class BaseAssemblyResolver : IAssemblyResolver {
ArrayList m_directories;
string[] m_monoGacPaths;
public void AddSearchDirectory (string directory)
{
m_directories.Add (directory);
}
public void RemoveSearchDirectory (string directory)
{
m_directories.Remove (directory);
}
public string [] GetSearchDirectories ()
{
return (string []) m_directories.ToArray (typeof (string));
}
public virtual AssemblyDefinition Resolve (string fullName)
{
return Resolve (AssemblyNameReference.Parse (fullName));
}
public BaseAssemblyResolver ()
{
m_directories = new ArrayList ();
m_directories.Add (".");
m_directories.Add ("bin");
}
public virtual AssemblyDefinition Resolve (AssemblyNameReference name)
{
AssemblyDefinition assembly;
string frameworkdir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);
assembly = SearchDirectory (name, m_directories);
if (assembly != null)
return assembly;
if (IsZero (name.Version)) {
assembly = SearchDirectory (name, new string [] {frameworkdir});
if (assembly != null)
return assembly;
}
#if !CF_1_0 && !CF_2_0 && !NO_SYSTEM_DLL
if (name.Name == "mscorlib") {
assembly = GetCorlib (name);
if (assembly != null)
return assembly;
}
assembly = GetAssemblyInGac (name);
if (assembly != null)
return assembly;
#endif
assembly = SearchDirectory (name, new string [] {frameworkdir});
if (assembly != null)
return assembly;
throw new FileNotFoundException ("Could not resolve: " + name);
}
static readonly string [] _extentions = new string [] { ".dll", ".exe" };
static AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories)
{
foreach (string dir in directories) {
foreach (string ext in _extentions) {
string file = Path.Combine (dir, name.Name + ext);
if (File.Exists (file))
return AssemblyFactory.GetAssembly (file);
}
}
return null;
}
static bool IsZero (Version version)
{
return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0;
}
#if !CF_1_0 && !CF_2_0 && !NO_SYSTEM_DLL
static AssemblyDefinition GetCorlib (AssemblyNameReference reference)
{
SR.AssemblyName corlib = typeof (object).Assembly.GetName ();
if (corlib.Version == reference.Version || IsZero (reference.Version))
return AssemblyFactory.GetAssembly (typeof (object).Module.FullyQualifiedName);
string path = Directory.GetParent (
Directory.GetParent (
typeof (object).Module.FullyQualifiedName).FullName
).FullName;
string runtime_path = null;
if (OnMono ()) {
if (reference.Version.Major == 1)
runtime_path = "1.0";
else if (reference.Version.Major == 2) {
if (reference.Version.Minor == 1)
runtime_path = "2.1";
else
runtime_path = "2.0";
} else if (reference.Version.Major == 4)
runtime_path = "4.0";
} else {
switch (reference.Version.ToString ()) {
case "1.0.3300.0":
runtime_path = "v1.0.3705";
break;
case "1.0.5000.0":
runtime_path = "v1.1.4322";
break;
case "2.0.0.0":
runtime_path = "v2.0.50727";
break;
case "4.0.0.0":
runtime_path = "v4.0.30319";
break;
}
}
if (runtime_path == null)
throw new NotSupportedException ("Version not supported: " + reference.Version);
path = Path.Combine (path, runtime_path);
if (File.Exists (Path.Combine (path, "mscorlib.dll")))
return AssemblyFactory.GetAssembly (Path.Combine (path, "mscorlib.dll"));
return null;
}
public static bool OnMono ()
{
return typeof (object).Assembly.GetType ("System.MonoType", false) != null;
}
string[] MonoGacPaths {
get {
if (m_monoGacPaths == null)
m_monoGacPaths = GetDefaultMonoGacPaths ();
return m_monoGacPaths;
}
}
static string[] GetDefaultMonoGacPaths ()
{
ArrayList paths = new ArrayList ();
string s = GetCurrentGacPath ();
if (s != null)
paths.Add (s);
string gacPathsEnv = Environment.GetEnvironmentVariable ("MONO_GAC_PREFIX");
if (gacPathsEnv != null && gacPathsEnv.Length > 0) {
string[] gacPrefixes = gacPathsEnv.Split (Path.PathSeparator);
foreach (string gacPrefix in gacPrefixes) {
if (gacPrefix != null && gacPrefix.Length > 0) {
string gac = Path.Combine (Path.Combine (Path.Combine (gacPrefix, "lib"), "mono"), "gac");
if (Directory.Exists (gac) && !paths.Contains (gac))
paths.Add (gac);
}
}
}
return (string[]) paths.ToArray (typeof (String));
}
AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference)
{
if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
return null;
if (OnMono ()) {
foreach (string gacpath in MonoGacPaths) {
string s = GetAssemblyFile (reference, gacpath);
if (File.Exists (s))
return AssemblyFactory.GetAssembly (s);
}
} else {
string currentGac = GetCurrentGacPath ();
if (currentGac == null)
return null;
string [] gacs = new string [] {"GAC_MSIL", "GAC_32", "GAC"};
for (int i = 0; i < gacs.Length; i++) {
string gac = Path.Combine (Directory.GetParent (currentGac).FullName, gacs [i]);
string asm = GetAssemblyFile (reference, gac);
if (Directory.Exists (gac) && File.Exists (asm))
return AssemblyFactory.GetAssembly (asm);
}
}
return null;
}
static string GetAssemblyFile (AssemblyNameReference reference, string gac)
{
StringBuilder sb = new StringBuilder ();
sb.Append (reference.Version);
sb.Append ("__");
for (int i = 0; i < reference.PublicKeyToken.Length; i++)
sb.Append (reference.PublicKeyToken [i].ToString ("x2"));
return Path.Combine (
Path.Combine (
Path.Combine (gac, reference.Name), sb.ToString ()),
string.Concat (reference.Name, ".dll"));
}
static string GetCurrentGacPath ()
{
string file = typeof (Uri).Module.FullyQualifiedName;
if (!File.Exists (file))
return null;
return Directory.GetParent (
Directory.GetParent (
Path.GetDirectoryName (
file)
).FullName
).FullName;
}
#endif
}
}

View File

@@ -0,0 +1,73 @@
//
// BaseReflectionReader.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
internal abstract class BaseReflectionReader : BaseReflectionVisitor, IDetailReader {
public virtual void ReadSemantic (EventDefinition evt)
{
}
public virtual void ReadSemantic (PropertyDefinition prop)
{
}
public virtual void ReadMarshalSpec (ParameterDefinition param)
{
}
public virtual void ReadMarshalSpec (FieldDefinition field)
{
}
public virtual void ReadLayout (TypeDefinition type)
{
}
public virtual void ReadLayout (FieldDefinition field)
{
}
public virtual void ReadConstant (FieldDefinition field)
{
}
public virtual void ReadConstant (PropertyDefinition prop)
{
}
public virtual void ReadConstant (ParameterDefinition param)
{
}
public virtual void ReadInitialValue (FieldDefinition field)
{
}
}
}

View File

@@ -0,0 +1,188 @@
//
// BaseReflectionVisitor.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System.Collections;
internal abstract class BaseReflectionVisitor : IReflectionVisitor {
public virtual void VisitModuleDefinition (ModuleDefinition module)
{
}
public virtual void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
{
}
public virtual void VisitTypeDefinition (TypeDefinition type)
{
}
public virtual void VisitTypeReferenceCollection (TypeReferenceCollection refs)
{
}
public virtual void VisitTypeReference (TypeReference type)
{
}
public virtual void VisitMemberReferenceCollection (MemberReferenceCollection members)
{
}
public virtual void VisitMemberReference (MemberReference member)
{
}
public virtual void VisitInterfaceCollection (InterfaceCollection interfaces)
{
}
public virtual void VisitInterface (TypeReference interf)
{
}
public virtual void VisitExternTypeCollection (ExternTypeCollection externs)
{
}
public virtual void VisitExternType (TypeReference externType)
{
}
public virtual void VisitOverrideCollection (OverrideCollection meth)
{
}
public virtual void VisitOverride (MethodReference ov)
{
}
public virtual void VisitNestedTypeCollection (NestedTypeCollection nestedTypes)
{
}
public virtual void VisitNestedType (TypeDefinition nestedType)
{
}
public virtual void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters)
{
}
public virtual void VisitParameterDefinition (ParameterDefinition parameter)
{
}
public virtual void VisitMethodDefinitionCollection (MethodDefinitionCollection methods)
{
}
public virtual void VisitMethodDefinition (MethodDefinition method)
{
}
public virtual void VisitConstructorCollection (ConstructorCollection ctors)
{
}
public virtual void VisitConstructor (MethodDefinition ctor)
{
}
public virtual void VisitPInvokeInfo (PInvokeInfo pinvk)
{
}
public virtual void VisitEventDefinitionCollection (EventDefinitionCollection events)
{
}
public virtual void VisitEventDefinition (EventDefinition evt)
{
}
public virtual void VisitFieldDefinitionCollection (FieldDefinitionCollection fields)
{
}
public virtual void VisitFieldDefinition (FieldDefinition field)
{
}
public virtual void VisitPropertyDefinitionCollection (PropertyDefinitionCollection properties)
{
}
public virtual void VisitPropertyDefinition (PropertyDefinition property)
{
}
public virtual void VisitSecurityDeclarationCollection (SecurityDeclarationCollection secDecls)
{
}
public virtual void VisitSecurityDeclaration (SecurityDeclaration secDecl)
{
}
public virtual void VisitCustomAttributeCollection (CustomAttributeCollection customAttrs)
{
}
public virtual void VisitCustomAttribute (CustomAttribute customAttr)
{
}
public virtual void VisitGenericParameterCollection (GenericParameterCollection genparams)
{
}
public virtual void VisitGenericParameter (GenericParameter genparam)
{
}
public virtual void VisitMarshalSpec (MarshalSpec marshalSpec)
{
}
public virtual void TerminateModuleDefinition (ModuleDefinition module)
{
}
protected void VisitCollection (ICollection coll)
{
if (coll.Count == 0)
return;
foreach (IReflectionVisitable visitable in coll)
visitable.Accept (this);
}
}
}

View File

@@ -0,0 +1,96 @@
//
// BaseStructureVisitor.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System.Collections;
internal abstract class BaseStructureVisitor : IReflectionStructureVisitor {
public virtual void VisitAssemblyDefinition (AssemblyDefinition asm)
{
}
public virtual void VisitAssemblyNameDefinition (AssemblyNameDefinition name)
{
}
public virtual void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection names)
{
}
public virtual void VisitAssemblyNameReference (AssemblyNameReference name)
{
}
public virtual void VisitResourceCollection (ResourceCollection resources)
{
}
public virtual void VisitEmbeddedResource (EmbeddedResource res)
{
}
public virtual void VisitLinkedResource (LinkedResource res)
{
}
public virtual void VisitAssemblyLinkedResource (AssemblyLinkedResource res)
{
}
public virtual void VisitModuleDefinition (ModuleDefinition module)
{
}
public virtual void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules)
{
}
public virtual void VisitModuleReference (ModuleReference module)
{
}
public virtual void VisitModuleReferenceCollection (ModuleReferenceCollection modules)
{
}
public virtual void TerminateAssemblyDefinition (AssemblyDefinition asm)
{
}
protected void VisitCollection (ICollection coll)
{
if (coll.Count == 0)
return;
foreach (IReflectionStructureVisitable visitable in coll)
visitable.Accept (this);
}
}
}

View File

@@ -0,0 +1,109 @@
//
// CallSite.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// (C) 2005 - 2007 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Cecil {
using System.Collections;
using System.Text;
using Mono.Cecil.Metadata;
internal sealed class CallSite : IMethodSignature, IAnnotationProvider, IMetadataTokenProvider {
MethodReference m_function;
public bool HasThis {
get { return m_function.HasThis; }
set { m_function.HasThis = value; }
}
public bool ExplicitThis {
get { return m_function.ExplicitThis; }
set { m_function.ExplicitThis = value; }
}
public MethodCallingConvention CallingConvention {
get { return m_function.CallingConvention; }
set { m_function.CallingConvention = value; }
}
public bool HasParameters {
get { return m_function.HasParameters; }
}
public ParameterDefinitionCollection Parameters {
get { return m_function.Parameters; }
}
public MethodReturnType ReturnType {
get { return m_function.ReturnType; }
set { m_function.ReturnType = value; }
}
public MetadataToken MetadataToken {
get { return m_function.MetadataToken; }
set { m_function.MetadataToken = value; }
}
IDictionary IAnnotationProvider.Annotations {
get { return ((IAnnotationProvider) m_function).Annotations; }
}
public CallSite (bool hasThis, bool explicitThis, MethodCallingConvention callConv, MethodReturnType retType)
{
m_function = new MethodReference (string.Empty, hasThis, explicitThis, callConv);
m_function.ReturnType = retType;
}
public int GetSentinel ()
{
return m_function.GetSentinel ();
}
public override string ToString ()
{
int sentinel = GetSentinel ();
StringBuilder sb = new StringBuilder ();
sb.Append (m_function.ReturnType.ReturnType.FullName);
sb.Append ("(");
if (m_function.HasParameters) {
for (int i = 0; i < m_function.Parameters.Count; i++) {
if (i > 0)
sb.Append (",");
if (i == sentinel)
sb.Append ("...,");
sb.Append (m_function.Parameters [i].ParameterType.FullName);
}
}
sb.Append (")");
return sb.ToString ();
}
}
}

View File

@@ -0,0 +1,68 @@
//
// FrameworkCompatibility.cs
//
// Author:
// Rodrigo B. de Oliveira (rodrigobamboo@gmail.com)
//
// (C) 2005 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if CF_1_0
namespace System {
internal class NotImplementedException : System.Exception {
public NotImplementedException (string message) : base (message)
{
}
public NotImplementedException ()
{
}
}
}
#endif
#if CF_1_0 || CF_2_0
namespace System.Security {
internal class SecurityElement {
public SecurityElement (string tag)
{
}
public string Text
{
get { return string.Empty; }
set {}
}
public void AddChild (SecurityElement child)
{
}
public void AddAttribute (string name, string value)
{
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More