本文整理汇总了C#中MetadataBuilder类的典型用法代码示例。如果您正苦于以下问题:C# MetadataBuilder类的具体用法?C# MetadataBuilder怎么用?C# MetadataBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataBuilder类属于命名空间,在下文中一共展示了MetadataBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDebugWriter
public static ImageWriter CreateDebugWriter(ModuleDefinition module, MetadataBuilder metadata, Disposable<Stream> stream)
{
var writer = new ImageWriter (module, "PDB V1.0", metadata, stream, metadataOnly: true);
var length = metadata.text_map.GetLength ();
writer.text = new Section { SizeOfRawData = length, VirtualSize = length };
return writer;
}
示例2: Ctor_Errors
public void Ctor_Errors()
{
var mdBuilder = new MetadataBuilder();
Assert.Throws<ArgumentNullException>(() => new PortablePdbBuilder(null, MetadataRootBuilder.EmptyRowCounts, default(MethodDefinitionHandle)));
Assert.Throws<ArgumentNullException>(() => new PortablePdbBuilder(mdBuilder, default(ImmutableArray<int>), default(MethodDefinitionHandle)));
var rowCounts = new int[128];
rowCounts[64] = 1;
Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));
rowCounts = new int[64];
rowCounts[63] = 1;
Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));
rowCounts = new int[64];
rowCounts[(int)TableIndex.EventPtr] = 1;
Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));
rowCounts = new int[64];
rowCounts[(int)TableIndex.CustomDebugInformation] = 1;
Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));
rowCounts = new int[64];
rowCounts[(int)TableIndex.MethodDef] = -1;
Assert.Throws<ArgumentOutOfRangeException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));
rowCounts = new int[64];
rowCounts[(int)TableIndex.GenericParamConstraint] = 0x01000000;
Assert.Throws<ArgumentOutOfRangeException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));
}
示例3: Ctor_Errors
public void Ctor_Errors()
{
var mdBuilder = new MetadataBuilder();
Assert.Throws<ArgumentNullException>(() => new MetadataRootBuilder(null));
Assert.Throws<ArgumentException>(() => new MetadataRootBuilder(mdBuilder, new string('x', 255)));
}
示例4: NetTextBuilder
public NetTextBuilder(ImageNetDirectory directory)
{
_directory = directory;
ImportBuilder = new ImageImportDirectoryBuilder(directory.Assembly, directory.Assembly.ImportDirectory);
Segments.Add(ImportBuilder.AddressTablesBuilder);
Segments.Add(directory);
Segments.Add(MethodBodyTableBuilder = new MethodBodyTableBuilder());
Segments.Add(NetResourceDirectoryBuilder = new NetResourceDirectoryBuilder());
Segments.Add(DataBuilder = new NetDataTableBuilder());
if (directory.StrongNameData != null)
Segments.Add(directory.StrongNameData);
Segments.Add(Metadata = new MetadataBuilder(directory.MetadataHeader));
if (directory.Assembly.DebugDirectory != null)
{
Segments.Add(directory.Assembly.DebugDirectory);
Segments.Add(directory.Assembly.DebugDirectory.Data);
}
Segments.Add(ImportBuilder);
Segments.Add(StartupCode = new StartupCodeSegmentBuilder());
}
示例5: CodeWriter
public CodeWriter (MetadataBuilder metadata)
: base (0)
{
this.code_base = metadata.text_map.GetNextRVA (TextSegment.CLIHeader);
this.current = code_base;
this.metadata = metadata;
this.standalone_signatures = new Dictionary<uint, MetadataToken> ();
}
示例6: Serialize_Errors
public void Serialize_Errors()
{
var mdBuilder = new MetadataBuilder();
var pdbBuilder = new PortablePdbBuilder(mdBuilder, MetadataRootBuilder.EmptyRowCounts, default(MethodDefinitionHandle));
var builder = new BlobBuilder();
Assert.Throws<ArgumentNullException>(() => pdbBuilder.Serialize(null));
}
示例7: Serialize_Errors
public void Serialize_Errors()
{
var mdBuilder = new MetadataBuilder();
var rootBuilder = new MetadataRootBuilder(mdBuilder);
var builder = new BlobBuilder();
Assert.Throws<ArgumentNullException>(() => rootBuilder.Serialize(null, 0, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => rootBuilder.Serialize(builder, -1, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => rootBuilder.Serialize(builder, 0, -1));
}
示例8: ImageWriter
ImageWriter(ModuleDefinition module, MetadataBuilder metadata, Stream stream)
: base(stream)
{
this.module = module;
this.metadata = metadata;
this.GetDebugHeader ();
this.GetWin32Resources ();
this.text_map = BuildTextMap ();
this.sections = 2; // text + reloc
this.pe64 = module.Architecture != TargetArchitecture.I386;
this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
}
示例9: BuildMetadata
public static void BuildMetadata(MetadataBuilder<MainViewModel> builder) {
builder.Property(x => x.FirstName)
.Required(() => "Please enter the first name.");
builder.Property(x => x.LastName)
.Required(() => "Please enter the last name.");
builder.Property(x => x.Email)
.EmailAddressDataType(() => "Please enter a correct email address.");
AddPasswordCheck(builder.Property(x => x.Password))
.Required(() => "Please enter the password.");
AddPasswordCheck(builder.Property(x => x.ConfirmPassword))
.Required(() => "Please confirm the password.");
}
示例10: Complex
public void Complex()
{
using (var peStream = new MemoryStream())
{
var ilBuilder = new BlobBuilder();
var metadataBuilder = new MetadataBuilder();
var entryPoint = ComplexEmit(metadataBuilder, ilBuilder);
WritePEImage(peStream, metadataBuilder, ilBuilder, entryPoint);
// peStream.Position = 0;
// File.WriteAllBytes(@"c:\temp\test.dll", peStream.ToArray());
}
}
示例11: BasicValidation
public void BasicValidation()
{
using (var peStream = new MemoryStream())
{
var ilBuilder = new BlobBuilder();
var metadataBuilder = new MetadataBuilder();
var entryPoint = BasicValidationEmit(metadataBuilder, ilBuilder);
WritePEImage(peStream, metadataBuilder, ilBuilder, entryPoint);
peStream.Position = 0;
var r = new PEReader(peStream);
var h = r.PEHeaders;
var mdReader = r.GetMetadataReader();
}
}
示例12: ImageWriter
ImageWriter(ModuleDefinition module, string runtime_version, MetadataBuilder metadata, Disposable<Stream> stream, bool metadataOnly = false)
: base(stream.value)
{
this.module = module;
this.runtime_version = runtime_version;
this.text_map = metadata.text_map;
this.stream = stream;
this.metadata = metadata;
if (metadataOnly)
return;
this.pe64 = module.Architecture == TargetArchitecture.AMD64 || module.Architecture == TargetArchitecture.IA64;
this.has_reloc = module.Architecture == TargetArchitecture.I386;
this.GetDebugHeader ();
this.GetWin32Resources ();
this.BuildTextMap ();
this.sections = (ushort) (has_reloc ? 2 : 1); // text + reloc?
}
示例13: PatchRawSection
void PatchRawSection (ByteBuffer buffer, MetadataBuilder metadata)
{
var position = base.position;
Align (4);
buffer.WriteBytes (base.position - position);
const byte fat_format = 0x40;
const byte more_sects = 0x80;
var flags = ReadByte ();
if ((flags & fat_format) == 0) {
buffer.WriteByte (flags);
PatchRawSmallSection (buffer, metadata);
} else
PatchRawFatSection (buffer, metadata);
if ((flags & more_sects) != 0)
PatchRawSection (buffer, metadata);
}
示例14: PatchRawSmallSection
void PatchRawSmallSection (ByteBuffer buffer, MetadataBuilder metadata)
{
var length = ReadByte ();
buffer.WriteByte (length);
Advance (2);
buffer.WriteUInt16 (0);
var count = length / 12;
PatchRawExceptionHandlers (buffer, metadata, count, false);
}
示例15: ValidateNestedClassTable
public void ValidateNestedClassTable()
{
var builder = new MetadataBuilder();
builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(2), default(TypeDefinitionHandle));
builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(1), default(TypeDefinitionHandle));
Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
builder = new MetadataBuilder();
builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(1), default(TypeDefinitionHandle));
builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(1), default(TypeDefinitionHandle));
Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
}