Debian Codegraph @

external/ikvm/reflect/Impl/PdbWriter.cs

raw
1 /*
2 Copyright (C) 2008-2010 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 [email protected]
22
23 */
24 using System;
25 using System.Collections.Generic;
26 using System.Runtime.InteropServices;
27 using System.Diagnostics.SymbolStore;
28 using IKVM.Reflection.Emit;
29
30 namespace IKVM.Reflection.Impl
31 {
32 [Guid("7dac8207-d3ae-4c75-9b67-92801a497d44")]
33 [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
34 [ComImport]
35 interface IMetaDataImport
36 {
37 void PlaceHolder_CloseEnum();
38 void PlaceHolder_CountEnum();
39 void PlaceHolder_ResetEnum();
40 void PlaceHolder_EnumTypeDefs();
41 void PlaceHolder_EnumInterfaceImpls();
42 void PlaceHolder_EnumTypeRefs();
43 void PlaceHolder_FindTypeDefByName();
44 void PlaceHolder_GetScopeProps();
45 void PlaceHolder_GetModuleFromScope();
46
47 void GetTypeDefProps(
48 int td, // [IN] TypeDef token for inquiry.
49 IntPtr szTypeDef, // [OUT] Put name here.
50 int cchTypeDef, // [IN] size of name buffer in wide chars.
51 IntPtr pchTypeDef, // [OUT] put size of name (wide chars) here.
52 IntPtr pdwTypeDefFlags, // [OUT] Put flags here.
53 IntPtr ptkExtends); // [OUT] Put base class TypeDef/TypeRef here.
54
55 void PlaceHolder_GetInterfaceImplProps();
56 void PlaceHolder_GetTypeRefProps();
57 void PlaceHolder_ResolveTypeRef();
58 void PlaceHolder_EnumMembers();
59 void PlaceHolder_EnumMembersWithName();
60 void PlaceHolder_EnumMethods();
61 void PlaceHolder_EnumMethodsWithName();
62 void PlaceHolder_EnumFields();
63 void PlaceHolder_EnumFieldsWithName();
64 void PlaceHolder_EnumParams();
65 void PlaceHolder_EnumMemberRefs();
66 void PlaceHolder_EnumMethodImpls();
67 void PlaceHolder_EnumPermissionSets();
68 void PlaceHolder_FindMember();
69 void PlaceHolder_FindMethod();
70 void PlaceHolder_FindField();
71 void PlaceHolder_FindMemberRef();
72
73 void GetMethodProps(
74 int mb, // The method for which to get props.
75 IntPtr pClass, // Put method's class here.
76 IntPtr szMethod, // Put method's name here.
77 int cchMethod, // Size of szMethod buffer in wide chars.
78 IntPtr pchMethod, // Put actual size here
79 IntPtr pdwAttr, // Put flags here.
80 IntPtr ppvSigBlob, // [OUT] point to the blob value of meta data
81 IntPtr pcbSigBlob, // [OUT] actual size of signature blob
82 IntPtr pulCodeRVA, // [OUT] codeRVA
83 IntPtr pdwImplFlags); // [OUT] Impl. Flags
84
85 void PlaceHolder_GetMemberRefProps();
86 void PlaceHolder_EnumProperties();
87 void PlaceHolder_EnumEvents();
88 void PlaceHolder_GetEventProps();
89 void PlaceHolder_EnumMethodSemantics();
90 void PlaceHolder_GetMethodSemantics();
91 void PlaceHolder_GetClassLayout();
92 void PlaceHolder_GetFieldMarshal();
93 void PlaceHolder_GetRVA();
94 void PlaceHolder_GetPermissionSetProps();
95 void PlaceHolder_GetSigFromToken();
96 void PlaceHolder_GetModuleRefProps();
97 void PlaceHolder_EnumModuleRefs();
98 void PlaceHolder_GetTypeSpecFromToken();
99 void PlaceHolder_GetNameFromToken();
100 void PlaceHolder_EnumUnresolvedMethods();
101 void PlaceHolder_GetUserString();
102 void PlaceHolder_GetPinvokeMap();
103 void PlaceHolder_EnumSignatures();
104 void PlaceHolder_EnumTypeSpecs();
105 void PlaceHolder_EnumUserStrings();
106 void PlaceHolder_GetParamForMethodIndex();
107 void PlaceHolder_EnumCustomAttributes();
108 void PlaceHolder_GetCustomAttributeProps();
109 void PlaceHolder_FindTypeRef();
110 void PlaceHolder_GetMemberProps();
111 void PlaceHolder_GetFieldProps();
112 void PlaceHolder_GetPropertyProps();
113 void PlaceHolder_GetParamProps();
114 void PlaceHolder_GetCustomAttributeByName();
115 void PlaceHolder_IsValidToken();
116
117 void GetNestedClassProps(
118 int tdNestedClass, // [IN] NestedClass token.
119 IntPtr ptdEnclosingClass); // [OUT] EnclosingClass token.
120
121 void PlaceHolder_GetNativeCallConvFromSig();
122 void PlaceHolder_IsGlobal();
123 }
124
125 [Guid("ba3fee4c-ecb9-4e41-83b7-183fa41cd859")]
126 [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
127 [ComImport]
128 interface IMetaDataEmit
129 {
130 void PlaceHolder_SetModuleProps();
131 void PlaceHolder_Save();
132 void PlaceHolder_SaveToStream();
133 void PlaceHolder_GetSaveSize();
134 void PlaceHolder_DefineTypeDef();
135 void PlaceHolder_DefineNestedType();
136 void PlaceHolder_SetHandler();
137 void PlaceHolder_DefineMethod();
138 void PlaceHolder_DefineMethodImpl();
139 void PlaceHolder_DefineTypeRefByName();
140 void PlaceHolder_DefineImportType();
141 void PlaceHolder_DefineMemberRef();
142 void PlaceHolder_DefineImportMember();
143 void PlaceHolder_DefineEvent();
144 void PlaceHolder_SetClassLayout();
145 void PlaceHolder_DeleteClassLayout();
146 void PlaceHolder_SetFieldMarshal();
147 void PlaceHolder_DeleteFieldMarshal();
148 void PlaceHolder_DefinePermissionSet();
149 void PlaceHolder_SetRVA();
150 void PlaceHolder_GetTokenFromSig();
151 void PlaceHolder_DefineModuleRef();
152 void PlaceHolder_SetParent();
153 void PlaceHolder_GetTokenFromTypeSpec();
154 void PlaceHolder_SaveToMemory();
155 void PlaceHolder_DefineUserString();
156 void PlaceHolder_DeleteToken();
157 void PlaceHolder_SetMethodProps();
158 void PlaceHolder_SetTypeDefProps();
159 void PlaceHolder_SetEventProps();
160 void PlaceHolder_SetPermissionSetProps();
161 void PlaceHolder_DefinePinvokeMap();
162 void PlaceHolder_SetPinvokeMap();
163 void PlaceHolder_DeletePinvokeMap();
164 void PlaceHolder_DefineCustomAttribute();
165 void PlaceHolder_SetCustomAttributeValue();
166 void PlaceHolder_DefineField();
167 void PlaceHolder_DefineProperty();
168 void PlaceHolder_DefineParam();
169 void PlaceHolder_SetFieldProps();
170 void PlaceHolder_SetPropertyProps();
171 void PlaceHolder_SetParamProps();
172 void PlaceHolder_DefineSecurityAttributeSet();
173 void PlaceHolder_ApplyEditAndContinue();
174 void PlaceHolder_TranslateSigWithScope();
175 void PlaceHolder_SetMethodImplFlags();
176 void PlaceHolder_SetFieldRVA();
177 void PlaceHolder_Merge();
178 void PlaceHolder_MergeEnd();
179 }
180
181 [Guid("B01FAFEB-C450-3A4D-BEEC-B4CEEC01E006")]
182 [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
183 [ComImport]
184 internal interface ISymUnmanagedDocumentWriter { }
185
186 [Guid("0b97726e-9e6d-4f05-9a26-424022093caa")]
187 [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
188 [ComImport]
189 [CoClass(typeof(CorSymWriterClass))]
190 interface ISymUnmanagedWriter2
191 {
192 ISymUnmanagedDocumentWriter DefineDocument(string url, ref Guid language, ref Guid languageVendor, ref Guid documentType);
193 void PlaceHolder_SetUserEntryPoint();
194 void OpenMethod(int method);
195 void CloseMethod();
196 int OpenScope(int startOffset);
197 void CloseScope(int endOffset);
198 void PlaceHolder_SetScopeRange();
199 void DefineLocalVariable(string name, int attributes, int cSig, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] signature, int addrKind, int addr1, int addr2, int startOffset, int endOffset);
200 void PlaceHolder_DefineParameter();
201 void PlaceHolder_DefineField();
202 void PlaceHolder_DefineGlobalVariable();
203 void Close();
204 void PlaceHolder_SetSymAttribute();
205 void PlaceHolder_OpenNamespace();
206 void PlaceHolder_CloseNamespace();
207 void PlaceHolder_UsingNamespace();
208 void PlaceHolder_SetMethodSourceRange();
209 void Initialize([MarshalAs(UnmanagedType.IUnknown)] object emitter, string filename, [MarshalAs(UnmanagedType.IUnknown)] object pIStream, bool fFullBuild);
210
211 void GetDebugInfo(
212 [In, Out] ref IMAGE_DEBUG_DIRECTORY pIDD,
213 [In] uint cData,
214 [Out] out uint pcData,
215 [Out, MarshalAs(UnmanagedType.LPArray)] byte[] data);
216
217 void DefineSequencePoints(ISymUnmanagedDocumentWriter document, int spCount,
218 [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] offsets,
219 [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] lines,
220 [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] columns,
221 [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] endLines,
222 [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] endColumns);
223
224 void RemapToken(
225 [In] int oldToken,
226 [In] int newToken);
227
228 void PlaceHolder_Initialize2();
229 void PlaceHolder_DefineConstant();
230 void PlaceHolder_Abort();
231
232 void DefineLocalVariable2(string name, int attributes, int token, int addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset);
233
234 void PlaceHolder_DefineGlobalVariable2();
235 void PlaceHolder_DefineConstant2();
236 }
237
238 [Guid("108296c1-281e-11d3-bd22-0000f80849bd")]
239 [ComImport]
240 class CorSymWriterClass { }
241
242 sealed class PdbWriter : ISymbolWriterImpl, IMetaDataEmit, IMetaDataImport
243 {
244 private readonly ModuleBuilder moduleBuilder;
245 private ISymUnmanagedWriter2 symUnmanagedWriter;
246 private readonly Dictionary<string, Document> documents = new Dictionary<string, Document>();
247 private readonly List<Method> methods = new List<Method>();
248 private readonly Dictionary<int, int> remap = new Dictionary<int, int>();
249 private readonly Dictionary<int, int> reversemap = new Dictionary<int, int>();
250 private readonly Dictionary<int, MethodBase> methodMap = new Dictionary<int, MethodBase>();
251 private Method currentMethod;
252
253 internal PdbWriter(ModuleBuilder moduleBuilder)
254 {
255 this.moduleBuilder = moduleBuilder;
256 }
257
258 private sealed class Document : ISymbolDocumentWriter
259 {
260 internal readonly string url;
261 private Guid language;
262 private Guid languageVendor;
263 private Guid documentType;
264 private ISymUnmanagedDocumentWriter unmanagedDocument;
265
266 internal Document(string url, Guid language, Guid languageVendor, Guid documentType)
267 {
268 this.url = url;
269 this.language = language;
270 this.languageVendor = languageVendor;
271 this.documentType = documentType;
272 }
273
274 public void SetCheckSum(Guid algorithmId, byte[] checkSum)
275 {
276 throw new NotImplementedException();
277 }
278
279 public void SetSource(byte[] source)
280 {
281 throw new NotImplementedException();
282 }
283
284 internal ISymUnmanagedDocumentWriter GetUnmanagedDocument(ISymUnmanagedWriter2 symUnmanagedWriter)
285 {
286 if (unmanagedDocument == null)
287 {
288 unmanagedDocument = symUnmanagedWriter.DefineDocument(url, ref language, ref languageVendor, ref documentType);
289 }
290 return unmanagedDocument;
291 }
292
293 internal void Release()
294 {
295 if (unmanagedDocument != null)
296 {
297 Marshal.ReleaseComObject(unmanagedDocument);
298 unmanagedDocument = null;
299 }
300 }
301 }
302
303 private sealed class LocalVar
304 {
305 internal readonly FieldAttributes attributes;
306 internal readonly int signature;
307 internal readonly SymAddressKind addrKind;
308 internal readonly int addr1;
309 internal readonly int addr2;
310 internal readonly int addr3;
311 internal readonly int startOffset;
312 internal readonly int endOffset;
313
314 internal LocalVar(FieldAttributes attributes, int signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset)
315 {
316 this.attributes = attributes;
317 this.signature = signature;
318 this.addrKind = addrKind;
319 this.addr1 = addr1;
320 this.addr2 = addr2;
321 this.addr3 = addr3;
322 this.startOffset = startOffset;
323 this.endOffset = endOffset;
324 }
325 }
326
327 private sealed class Scope
328 {
329 internal readonly int startOffset;
330 internal int endOffset;
331 internal readonly List<Scope> scopes = new List<Scope>();
332 internal readonly Dictionary<string, LocalVar> locals = new Dictionary<string, LocalVar>();
333
334 internal Scope(int startOffset)
335 {
336 this.startOffset = startOffset;
337 }
338
339 internal void Do(ISymUnmanagedWriter2 symUnmanagedWriter)
340 {
341 symUnmanagedWriter.OpenScope(startOffset);
342 foreach (KeyValuePair<string, LocalVar> kv in locals)
343 {
344 symUnmanagedWriter.DefineLocalVariable2(kv.Key, (int)kv.Value.attributes, kv.Value.signature, (int)kv.Value.addrKind, kv.Value.addr1, kv.Value.addr2, kv.Value.addr3, kv.Value.startOffset, kv.Value.endOffset);
345 }
346 foreach (Scope scope in scopes)
347 {
348 scope.Do(symUnmanagedWriter);
349 }
350 symUnmanagedWriter.CloseScope(endOffset);
351 }
352 }
353
354 private sealed class Method
355 {
356 internal readonly int token;
357 internal Document document;
358 internal int[] offsets;
359 internal int[] lines;
360 internal int[] columns;
361 internal int[] endLines;
362 internal int[] endColumns;
363 internal readonly List<Scope> scopes = new List<Scope>();
364 internal readonly Stack<Scope> scopeStack = new Stack<Scope>();
365
366 internal Method(int token)
367 {
368 this.token = token;
369 }
370 }
371
372 public ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType)
373 {
374 Document doc;
375 if (!documents.TryGetValue(url, out doc))
376 {
377 doc = new Document(url, language, languageVendor, documentType);
378 documents.Add(url, doc);
379 }
380 return doc;
381 }
382
383 public void OpenMethod(SymbolToken method)
384 {
385 throw new NotImplementedException();
386 }
387
388 public void OpenMethod(SymbolToken method, MethodBase mb)
389 {
390 int token = method.GetToken();
391 currentMethod = new Method(token);
392 methodMap.Add(token, mb);
393 }
394
395 public void CloseMethod()
396 {
397 methods.Add(currentMethod);
398 currentMethod = null;
399 }
400
401 public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns)
402 {
403 currentMethod.document = (Document)document;
404 currentMethod.offsets = offsets;
405 currentMethod.lines = lines;
406 currentMethod.columns = columns;
407 currentMethod.endLines = endLines;
408 currentMethod.endColumns = endColumns;
409 }
410
411 public int OpenScope(int startOffset)
412 {
413 Scope scope = new Scope(startOffset);
414 if (currentMethod.scopeStack.Count == 0)
415 {
416 currentMethod.scopes.Add(scope);
417 }
418 else
419 {
420 currentMethod.scopeStack.Peek().scopes.Add(scope);
421 }
422 currentMethod.scopeStack.Push(scope);
423 return 0;
424 }
425
426 public void CloseScope(int endOffset)
427 {
428 currentMethod.scopeStack.Pop().endOffset = endOffset;
429 }
430
431 public void DefineLocalVariable2(string name, FieldAttributes attributes, int signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset)
432 {
433 currentMethod.scopeStack.Peek().locals[name] = new LocalVar(attributes, signature, addrKind, addr1, addr2, addr3, startOffset, endOffset);
434 }
435
436 private void InitWriter()
437 {
438 if (symUnmanagedWriter == null)
439 {
440 string fileName = System.IO.Path.ChangeExtension(moduleBuilder.FullyQualifiedName, ".pdb");
441 // pro-actively delete the .pdb to get a meaningful IOException, instead of COMInteropException if the file can't be overwritten (or is corrupt, or who knows what)
442 System.IO.File.Delete(fileName);
443 symUnmanagedWriter = new ISymUnmanagedWriter2();
444 symUnmanagedWriter.Initialize(this, fileName, null, true);
445 }
446 }
447
448 public byte[] GetDebugInfo(ref IMAGE_DEBUG_DIRECTORY idd)
449 {
450 InitWriter();
451 uint cData;
452 symUnmanagedWriter.GetDebugInfo(ref idd, 0, out cData, null);
453 byte[] buf = new byte[cData];
454 symUnmanagedWriter.GetDebugInfo(ref idd, (uint)buf.Length, out cData, buf);
455 return buf;
456 }
457
458 public void RemapToken(int oldToken, int newToken)
459 {
460 remap.Add(oldToken, newToken);
461 reversemap.Add(newToken, oldToken);
462 }
463
464 public void Close()
465 {
466 InitWriter();
467
468 foreach (Method method in methods)
469 {
470 int remappedToken = method.token;
471 remap.TryGetValue(remappedToken, out remappedToken);
472 symUnmanagedWriter.OpenMethod(remappedToken);
473 if (method.document != null)
474 {
475 ISymUnmanagedDocumentWriter doc = method.document.GetUnmanagedDocument(symUnmanagedWriter);
476 symUnmanagedWriter.DefineSequencePoints(doc, method.offsets.Length, method.offsets, method.lines, method.columns, method.endLines, method.endColumns);
477 }
478 foreach (Scope scope in method.scopes)
479 {
480 scope.Do(symUnmanagedWriter);
481 }
482 symUnmanagedWriter.CloseMethod();
483 }
484
485 foreach (Document doc in documents.Values)
486 {
487 doc.Release();
488 }
489
490 symUnmanagedWriter.Close();
491 Marshal.ReleaseComObject(symUnmanagedWriter);
492 symUnmanagedWriter = null;
493 documents.Clear();
494 methods.Clear();
495 remap.Clear();
496 reversemap.Clear();
497 }
498
499 public void DefineLocalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset)
500 {
501 throw new NotImplementedException();
502 }
503
504 public void CloseNamespace()
505 {
506 throw new NotImplementedException();
507 }
508
509 public void DefineField(SymbolToken parent, string name, System.Reflection.FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
510 {
511 throw new NotImplementedException();
512 }
513
514 public void DefineGlobalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
515 {
516 throw new NotImplementedException();
517 }
518
519 public void DefineParameter(string name, System.Reflection.ParameterAttributes attributes, int sequence, SymAddressKind addrKind, int addr1, int addr2, int addr3)
520 {
521 throw new NotImplementedException();
522 }
523
524 public void Initialize(IntPtr emitter, string filename, bool fFullBuild)
525 {
526 throw new NotImplementedException();
527 }
528
529 public void OpenNamespace(string name)
530 {
531 throw new NotImplementedException();
532 }
533
534 public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn)
535 {
536 throw new NotImplementedException();
537 }
538
539 public void SetScopeRange(int scopeID, int startOffset, int endOffset)
540 {
541 throw new NotImplementedException();
542 }
543
544 public void SetSymAttribute(SymbolToken parent, string name, byte[] data)
545 {
546 throw new NotImplementedException();
547 }
548
549 public void SetUnderlyingWriter(IntPtr underlyingWriter)
550 {
551 throw new NotImplementedException();
552 }
553
554 public void SetUserEntryPoint(SymbolToken entryMethod)
555 {
556 throw new NotImplementedException();
557 }
558
559 public void UsingNamespace(string fullName)
560 {
561 throw new NotImplementedException();
562 }
563
564 public void PlaceHolder_CloseEnum()
565 {
566 throw new NotImplementedException();
567 }
568
569 public void PlaceHolder_CountEnum()
570 {
571 throw new NotImplementedException();
572 }
573
574 public void PlaceHolder_ResetEnum()
575 {
576 throw new NotImplementedException();
577 }
578
579 public void PlaceHolder_EnumTypeDefs()
580 {
581 throw new NotImplementedException();
582 }
583
584 public void PlaceHolder_EnumInterfaceImpls()
585 {
586 throw new NotImplementedException();
587 }
588
589 public void PlaceHolder_EnumTypeRefs()
590 {
591 throw new NotImplementedException();
592 }
593
594 public void PlaceHolder_FindTypeDefByName()
595 {
596 throw new NotImplementedException();
597 }
598
599 public void PlaceHolder_GetScopeProps()
600 {
601 throw new NotImplementedException();
602 }
603
604 public void PlaceHolder_GetModuleFromScope()
605 {
606 throw new NotImplementedException();
607 }
608
609 private static void WriteString(IntPtr ptrString, IntPtr ptrLength, string str, int length)
610 {
611 if (ptrString != IntPtr.Zero)
612 {
613 for (int i = 0; i < Math.Min(length, str.Length); i++)
614 {
615 Marshal.WriteInt16(ptrString, i, str[i]);
616 }
617 }
618 if (ptrLength != IntPtr.Zero)
619 {
620 Marshal.WriteInt32(ptrLength, str.Length);
621 }
622 }
623
624 private static void WriteToken(IntPtr ptr, MemberInfo member)
625 {
626 if (ptr != IntPtr.Zero)
627 {
628 Marshal.WriteInt32(ptr, member == null ? 0 : member.MetadataToken);
629 }
630 }
631
632 private static void WriteInt32(IntPtr ptr, int value)
633 {
634 if (ptr != IntPtr.Zero)
635 {
636 Marshal.WriteInt32(ptr, value);
637 }
638 }
639
640 public void GetTypeDefProps(
641 int td, // [IN] TypeDef token for inquiry.
642 IntPtr szTypeDef, // [OUT] Put name here.
643 int cchTypeDef, // [IN] size of name buffer in wide chars.
644 IntPtr pchTypeDef, // [OUT] put size of name (wide chars) here.
645 IntPtr pdwTypeDefFlags, // [OUT] Put flags here.
646 IntPtr ptkExtends) // [OUT] Put base class TypeDef/TypeRef here.
647 {
648 if (td == 0)
649 {
650 // why are we being called with an invalid token?
651 WriteString(szTypeDef, pchTypeDef, "", cchTypeDef);
652 WriteInt32(pdwTypeDefFlags, 0);
653 WriteToken(ptkExtends, null);
654 }
655 else
656 {
657 Type type = moduleBuilder.ResolveType(td);
658 WriteString(szTypeDef, pchTypeDef, type.FullName, cchTypeDef);
659 WriteInt32(pdwTypeDefFlags, (int)type.Attributes);
660 WriteToken(ptkExtends, type.BaseType);
661 }
662 }
663
664 public void PlaceHolder_GetInterfaceImplProps()
665 {
666 throw new NotImplementedException();
667 }
668
669 public void PlaceHolder_GetTypeRefProps()
670 {
671 throw new NotImplementedException();
672 }
673
674 public void PlaceHolder_ResolveTypeRef()
675 {
676 throw new NotImplementedException();
677 }
678
679 public void PlaceHolder_EnumMembers()
680 {
681 throw new NotImplementedException();
682 }
683
684 public void PlaceHolder_EnumMembersWithName()
685 {
686 throw new NotImplementedException();
687 }
688
689 public void PlaceHolder_EnumMethods()
690 {
691 throw new NotImplementedException();
692 }
693
694 public void PlaceHolder_EnumMethodsWithName()
695 {
696 throw new NotImplementedException();
697 }
698
699 public void PlaceHolder_EnumFields()
700 {
701 throw new NotImplementedException();
702 }
703
704 public void PlaceHolder_EnumFieldsWithName()
705 {
706 throw new NotImplementedException();
707 }
708
709 public void PlaceHolder_EnumParams()
710 {
711 throw new NotImplementedException();
712 }
713
714 public void PlaceHolder_EnumMemberRefs()
715 {
716 throw new NotImplementedException();
717 }
718
719 public void PlaceHolder_EnumMethodImpls()
720 {
721 throw new NotImplementedException();
722 }
723
724 public void PlaceHolder_EnumPermissionSets()
725 {
726 throw new NotImplementedException();
727 }
728
729 public void PlaceHolder_FindMember()
730 {
731 throw new NotImplementedException();
732 }
733
734 public void PlaceHolder_FindMethod()
735 {
736 throw new NotImplementedException();
737 }
738
739 public void PlaceHolder_FindField()
740 {
741 throw new NotImplementedException();
742 }
743
744 public void PlaceHolder_FindMemberRef()
745 {
746 throw new NotImplementedException();
747 }
748
749 public void GetMethodProps(
750 int mb, // The method for which to get props.
751 IntPtr pClass, // [OUT] Put method's class here.
752 IntPtr szMethod, // [OUT] Put method's name here.
753 int cchMethod, // Size of szMethod buffer in wide chars.
754 IntPtr pchMethod, // [OUT] Put actual size here
755 IntPtr pdwAttr, // [OUT] Put flags here.
756 IntPtr ppvSigBlob, // [OUT] point to the blob value of meta data
757 IntPtr pcbSigBlob, // [OUT] actual size of signature blob
758 IntPtr pulCodeRVA, // [OUT] codeRVA
759 IntPtr pdwImplFlags) // [OUT] Impl. Flags
760 {
761 if (pdwAttr != IntPtr.Zero || ppvSigBlob != IntPtr.Zero || pcbSigBlob != IntPtr.Zero || pulCodeRVA != IntPtr.Zero || pdwImplFlags != IntPtr.Zero)
762 {
763 throw new NotImplementedException();
764 }
765 MethodBase method = methodMap[reversemap[mb]];
766 WriteToken(pClass, method.DeclaringType);
767 WriteString(szMethod, pchMethod, method.Name, cchMethod);
768 }
769
770 public void PlaceHolder_GetMemberRefProps()
771 {
772 throw new NotImplementedException();
773 }
774
775 public void PlaceHolder_EnumProperties()
776 {
777 throw new NotImplementedException();
778 }
779
780 public void PlaceHolder_EnumEvents()
781 {
782 throw new NotImplementedException();
783 }
784
785 public void PlaceHolder_GetEventProps()
786 {
787 throw new NotImplementedException();
788 }
789
790 public void PlaceHolder_EnumMethodSemantics()
791 {
792 throw new NotImplementedException();
793 }
794
795 public void PlaceHolder_GetMethodSemantics()
796 {
797 throw new NotImplementedException();
798 }
799
800 public void PlaceHolder_GetClassLayout()
801 {
802 throw new NotImplementedException();
803 }
804
805 public void PlaceHolder_GetFieldMarshal()
806 {
807 throw new NotImplementedException();
808 }
809
810 public void PlaceHolder_GetRVA()
811 {
812 throw new NotImplementedException();
813 }
814
815 public void PlaceHolder_GetPermissionSetProps()
816 {
817 throw new NotImplementedException();
818 }
819
820 public void PlaceHolder_GetSigFromToken()
821 {
822 throw new NotImplementedException();
823 }
824
825 public void PlaceHolder_GetModuleRefProps()
826 {
827 throw new NotImplementedException();
828 }
829
830 public void PlaceHolder_EnumModuleRefs()
831 {
832 throw new NotImplementedException();
833 }
834
835 public void PlaceHolder_GetTypeSpecFromToken()
836 {
837 throw new NotImplementedException();
838 }
839
840 public void PlaceHolder_GetNameFromToken()
841 {
842 throw new NotImplementedException();
843 }
844
845 public void PlaceHolder_EnumUnresolvedMethods()
846 {
847 throw new NotImplementedException();
848 }
849
850 public void PlaceHolder_GetUserString()
851 {
852 throw new NotImplementedException();
853 }
854
855 public void PlaceHolder_GetPinvokeMap()
856 {
857 throw new NotImplementedException();
858 }
859
860 public void PlaceHolder_EnumSignatures()
861 {
862 throw new NotImplementedException();
863 }
864
865 public void PlaceHolder_EnumTypeSpecs()
866 {
867 throw new NotImplementedException();
868 }
869
870 public void PlaceHolder_EnumUserStrings()
871 {
872 throw new NotImplementedException();
873 }
874
875 public void PlaceHolder_GetParamForMethodIndex()
876 {
877 throw new NotImplementedException();
878 }
879
880 public void PlaceHolder_EnumCustomAttributes()
881 {
882 throw new NotImplementedException();
883 }
884
885 public void PlaceHolder_GetCustomAttributeProps()
886 {
887 throw new NotImplementedException();
888 }
889
890 public void PlaceHolder_FindTypeRef()
891 {
892 throw new NotImplementedException();
893 }
894
895 public void PlaceHolder_GetMemberProps()
896 {
897 throw new NotImplementedException();
898 }
899
900 public void PlaceHolder_GetFieldProps()
901 {
902 throw new NotImplementedException();
903 }
904
905 public void PlaceHolder_GetPropertyProps()
906 {
907 throw new NotImplementedException();
908 }
909
910 public void PlaceHolder_GetParamProps()
911 {
912 throw new NotImplementedException();
913 }
914
915 public void PlaceHolder_GetCustomAttributeByName()
916 {
917 throw new NotImplementedException();
918 }
919
920 public void PlaceHolder_IsValidToken()
921 {
922 throw new NotImplementedException();
923 }
924
925 public void GetNestedClassProps(
926 int tdNestedClass, // [IN] NestedClass token.
927 IntPtr ptdEnclosingClass) // [OUT] EnclosingClass token.
928 {
929 Type type = moduleBuilder.ResolveType(tdNestedClass);
930 WriteToken(ptdEnclosingClass, type.DeclaringType);
931 }
932
933 public void PlaceHolder_GetNativeCallConvFromSig()
934 {
935 throw new NotImplementedException();
936 }
937
938 public void PlaceHolder_IsGlobal()
939 {
940 throw new NotImplementedException();
941 }
942
943 public void PlaceHolder_SetModuleProps()
944 {
945 throw new NotImplementedException();
946 }
947
948 public void PlaceHolder_Save()
949 {
950 throw new NotImplementedException();
951 }
952
953 public void PlaceHolder_SaveToStream()
954 {
955 throw new NotImplementedException();
956 }
957
958 public void PlaceHolder_GetSaveSize()
959 {
960 throw new NotImplementedException();
961 }
962
963 public void PlaceHolder_DefineTypeDef()
964 {
965 throw new NotImplementedException();
966 }
967
968 public void PlaceHolder_DefineNestedType()
969 {
970 throw new NotImplementedException();
971 }
972
973 public void PlaceHolder_SetHandler()
974 {
975 throw new NotImplementedException();
976 }
977
978 public void PlaceHolder_DefineMethod()
979 {
980 throw new NotImplementedException();
981 }
982
983 public void PlaceHolder_DefineMethodImpl()
984 {
985 throw new NotImplementedException();
986 }
987
988 public void PlaceHolder_DefineTypeRefByName()
989 {
990 throw new NotImplementedException();
991 }
992
993 public void PlaceHolder_DefineImportType()
994 {
995 throw new NotImplementedException();
996 }
997
998 public void PlaceHolder_DefineMemberRef()
999 {
1000 throw new NotImplementedException();
1001 }
1002
1003 public void PlaceHolder_DefineImportMember()
1004 {
1005 throw new NotImplementedException();
1006 }
1007
1008 public void PlaceHolder_DefineEvent()
1009 {
1010 throw new NotImplementedException();
1011 }
1012
1013 public void PlaceHolder_SetClassLayout()
1014 {
1015 throw new NotImplementedException();
1016 }
1017
1018 public void PlaceHolder_DeleteClassLayout()
1019 {
1020 throw new NotImplementedException();
1021 }
1022
1023 public void PlaceHolder_SetFieldMarshal()
1024 {
1025 throw new NotImplementedException();
1026 }
1027
1028 public void PlaceHolder_DeleteFieldMarshal()
1029 {
1030 throw new NotImplementedException();
1031 }
1032
1033 public void PlaceHolder_DefinePermissionSet()
1034 {
1035 throw new NotImplementedException();
1036 }
1037
1038 public void PlaceHolder_SetRVA()
1039 {
1040 throw new NotImplementedException();
1041 }
1042
1043 public void PlaceHolder_GetTokenFromSig()
1044 {
1045 throw new NotImplementedException();
1046 }
1047
1048 public void PlaceHolder_DefineModuleRef()
1049 {
1050 throw new NotImplementedException();
1051 }
1052
1053 public void PlaceHolder_SetParent()
1054 {
1055 throw new NotImplementedException();
1056 }
1057
1058 public void PlaceHolder_GetTokenFromTypeSpec()
1059 {
1060 throw new NotImplementedException();
1061 }
1062
1063 public void PlaceHolder_SaveToMemory()
1064 {
1065 throw new NotImplementedException();
1066 }
1067
1068 public void PlaceHolder_DefineUserString()
1069 {
1070 throw new NotImplementedException();
1071 }
1072
1073 public void PlaceHolder_DeleteToken()
1074 {
1075 throw new NotImplementedException();
1076 }
1077
1078 public void PlaceHolder_SetMethodProps()
1079 {
1080 throw new NotImplementedException();
1081 }
1082
1083 public void PlaceHolder_SetTypeDefProps()
1084 {
1085 throw new NotImplementedException();
1086 }
1087
1088 public void PlaceHolder_SetEventProps()
1089 {
1090 throw new NotImplementedException();
1091 }
1092
1093 public void PlaceHolder_SetPermissionSetProps()
1094 {
1095 throw new NotImplementedException();
1096 }
1097
1098 public void PlaceHolder_DefinePinvokeMap()
1099 {
1100 throw new NotImplementedException();
1101 }
1102
1103 public void PlaceHolder_SetPinvokeMap()
1104 {
1105 throw new NotImplementedException();
1106 }
1107
1108 public void PlaceHolder_DeletePinvokeMap()
1109 {
1110 throw new NotImplementedException();
1111 }
1112
1113 public void PlaceHolder_DefineCustomAttribute()
1114 {
1115 throw new NotImplementedException();
1116 }
1117
1118 public void PlaceHolder_SetCustomAttributeValue()
1119 {
1120 throw new NotImplementedException();
1121 }
1122
1123 public void PlaceHolder_DefineField()
1124 {
1125 throw new NotImplementedException();
1126 }
1127
1128 public void PlaceHolder_DefineProperty()
1129 {
1130 throw new NotImplementedException();
1131 }
1132
1133 public void PlaceHolder_DefineParam()
1134 {
1135 throw new NotImplementedException();
1136 }
1137
1138 public void PlaceHolder_SetFieldProps()
1139 {
1140 throw new NotImplementedException();
1141 }
1142
1143 public void PlaceHolder_SetPropertyProps()
1144 {
1145 throw new NotImplementedException();
1146 }
1147
1148 public void PlaceHolder_SetParamProps()
1149 {
1150 throw new NotImplementedException();
1151 }
1152
1153 public void PlaceHolder_DefineSecurityAttributeSet()
1154 {
1155 throw new NotImplementedException();
1156 }
1157
1158 public void PlaceHolder_ApplyEditAndContinue()
1159 {
1160 throw new NotImplementedException();
1161 }
1162
1163 public void PlaceHolder_TranslateSigWithScope()
1164 {
1165 throw new NotImplementedException();
1166 }
1167
1168 public void PlaceHolder_SetMethodImplFlags()
1169 {
1170 throw new NotImplementedException();
1171 }
1172
1173 public void PlaceHolder_SetFieldRVA()
1174 {
1175 throw new NotImplementedException();
1176 }
1177
1178 public void PlaceHolder_Merge()
1179 {
1180 throw new NotImplementedException();
1181 }
1182
1183 public void PlaceHolder_MergeEnd()
1184 {
1185 throw new NotImplementedException();
1186 }
1187
1188 public bool IsDeterministic
1189 {
1190 get { return false; }
1191 }
1192 }
1193 }