| 1 | // Licensed to the .NET Foundation under one or more agreements. | 
| 2 | // The .NET Foundation licenses this file to you under the MIT license. | 
| 3 | // See the LICENSE file in the project root for more information. | 
| 4 |  | 
| 5 | //  | 
| 6 | // ======================================================================================================= | 
| 7 | // Defines the surface area between md\WinMD and md\everything-else. | 
| 8 | // | 
| 9 | // md\WinMD contains adapter importers that wrap RegMeta and MDInternalRO to make .winmd files look like | 
| 10 | // regular .NET assemblies. | 
| 11 | // ======================================================================================================= | 
| 12 |  | 
| 13 | #ifndef __WINMDINTERFACES_H__ | 
| 14 | #define __WINMDINTERFACES_H__ | 
| 15 |  | 
| 16 | #include "metamodel.h" | 
| 17 |  | 
| 18 |  | 
| 19 | //----------------------------------------------------------------------------------------------------- | 
| 20 | // A common interface unifying RegMeta and MDInternalRO, giving the adapter a common interface to | 
| 21 | // access the raw metadata. | 
| 22 | //----------------------------------------------------------------------------------------------------- | 
| 23 |  | 
| 24 | // {4F8EE8A3-24F8-4241-BC75-C8CAEC0255B5} | 
| 25 | EXTERN_GUID(IID_IMDCommon, 0x4f8ee8a3, 0x24f8, 0x4241, 0xbc, 0x75, 0xc8, 0xca, 0xec, 0x2, 0x55, 0xb5); | 
| 26 |  | 
| 27 | #undef  INTERFACE | 
| 28 | #define INTERFACE IID_IMDCommon | 
| 29 | DECLARE_INTERFACE_(IMDCommon, IUnknown) | 
| 30 | { | 
| 31 |     STDMETHOD_(IMetaModelCommon*, GetMetaModelCommon)() PURE;        | 
| 32 |     STDMETHOD_(IMetaModelCommonRO*, GetMetaModelCommonRO)() PURE;        | 
| 33 |     STDMETHOD(GetVersionString)(LPCSTR *pszVersionString) PURE; | 
| 34 | }; | 
| 35 |  | 
| 36 |  | 
| 37 | //----------------------------------------------------------------------------------------------------- | 
| 38 | // Returns: | 
| 39 | //    S_OK:    if WinMD adapter should be used. | 
| 40 | //    S_FALSE: if not | 
| 41 | //----------------------------------------------------------------------------------------------------- | 
| 42 | HRESULT CheckIfWinMDAdapterNeeded(IMDCommon *pRawMDCommon); | 
| 43 |  | 
| 44 |  | 
| 45 |  | 
| 46 | //----------------------------------------------------------------------------------------------------- | 
| 47 | // Factory method that creates an WinMD adapter that implements: | 
| 48 | // | 
| 49 | //     IMetaDataImport2 | 
| 50 | //     IMetaDataAssemblyImport | 
| 51 | //     IMetaDataValidate | 
| 52 | //     IMarshal | 
| 53 | //     IMDCommon (subset) | 
| 54 | // | 
| 55 | // IMDCommon is included as a concession to the fact that certain IMetaDataEmit apis have | 
| 56 | // an (apparently undocumented) dependency on their importer arguments supporting this. | 
| 57 | // | 
| 58 | // You must provide a regular MD importer that implements: | 
| 59 | // | 
| 60 | //     IMDCommon | 
| 61 | //     IMetaDataImport2 | 
| 62 | //     IMetaDataAssemblyImport | 
| 63 | //     IMetaDataValidate | 
| 64 | // | 
| 65 | // The underlying metadata file must follow these restrictions: | 
| 66 | // | 
| 67 | //     - Have an existing assemblyRef to "mscorlib" | 
| 68 | // | 
| 69 | //----------------------------------------------------------------------------------------------------- | 
| 70 | HRESULT CreateWinMDImport(IMDCommon * pRawMDCommon, REFIID riid, /*[out]*/ void **ppWinMDImport); | 
| 71 |  | 
| 72 |  | 
| 73 | //----------------------------------------------------------------------------------------------------- | 
| 74 | // Factory method that creates an WinMD adapter that implements IMDInternalImport. | 
| 75 | // You must provide a regular MD importer that implements: | 
| 76 | // | 
| 77 | //     IMDCommon | 
| 78 | //     IMDInternalImport | 
| 79 | // | 
| 80 | // The underlying metadata file must follow these restrictions: | 
| 81 | // | 
| 82 | //     - Have an existing assemblyRef to "mscorlib" | 
| 83 | // | 
| 84 | //----------------------------------------------------------------------------------------------------- | 
| 85 | #ifdef FEATURE_METADATA_INTERNAL_APIS | 
| 86 | HRESULT CreateWinMDInternalImportRO(IMDCommon * pRawMDCommon, REFIID riid, /*[out]*/ void **ppWinMDInternalImport); | 
| 87 |  | 
| 88 | #endif // FEATURE_METADATA_INTERNAL_APIS | 
| 89 | //----------------------------------------------------------------------------------------------------- | 
| 90 | // S_OK if pUnknown is really a WinMD wrapper. This is just a polite way of asking "is it bad to | 
| 91 | //   to static cast pUnknown to RegMeta/MDInternalRO."  | 
| 92 | //----------------------------------------------------------------------------------------------------- | 
| 93 | HRESULT CheckIfImportingWinMD(IUnknown *pUnknown); | 
| 94 |  | 
| 95 |  | 
| 96 | //----------------------------------------------------------------------------------------------------- | 
| 97 | // E_NOTIMPL if pUnknown is really a WinMD wrapper. | 
| 98 | //----------------------------------------------------------------------------------------------------- | 
| 99 | HRESULT VerifyNotWinMDHelper(IUnknown *pUnknown | 
| 100 | #ifdef _DEBUG | 
| 101 |                             ,LPCSTR    assertMsg | 
| 102 |                             ,LPCSTR    file | 
| 103 |                             ,int       line | 
| 104 | #endif //_DEBUG | 
| 105 |                             ); | 
| 106 | #define VerifyNotWinMD(pUnknown, assertMsg) S_OK | 
| 107 |  | 
| 108 |  | 
| 109 | #endif //__WINMDINTERFACES_H__ | 
| 110 |  | 
| 111 |  | 
| 112 |   | 
| 113 |  |