-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from microsoft/fix429
Fix cross-winmd type references
- Loading branch information
Showing
8 changed files
with
284 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.Windows.CsWin32 | ||
{ | ||
using System.Reflection.Metadata; | ||
|
||
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter | ||
#pragma warning disable SA1649 // Filenames must match first declared type | ||
|
||
internal record struct QualifiedTypeReferenceHandle(Generator Generator, TypeReferenceHandle ReferenceHandle) | ||
{ | ||
internal MetadataReader Reader => this.Generator.Reader; | ||
|
||
internal QualifiedTypeReference Resolve() => new(this.Generator, this.Generator.Reader.GetTypeReference(this.ReferenceHandle)); | ||
} | ||
|
||
internal record struct QualifiedTypeReference(Generator Generator, TypeReference Reference) | ||
{ | ||
internal MetadataReader Reader => this.Generator.Reader; | ||
} | ||
|
||
internal record struct QualifiedTypeDefinitionHandle(Generator Generator, TypeDefinitionHandle DefinitionHandle) | ||
{ | ||
internal MetadataReader Reader => this.Generator.Reader; | ||
|
||
internal QualifiedTypeDefinition Resolve() => new(this.Generator, this.Generator.Reader.GetTypeDefinition(this.DefinitionHandle)); | ||
} | ||
|
||
internal record struct QualifiedTypeDefinition(Generator Generator, TypeDefinition Definition) | ||
{ | ||
internal MetadataReader Reader => this.Generator.Reader; | ||
} | ||
|
||
internal record struct QualifiedMethodDefinitionHandle(Generator Generator, MethodDefinitionHandle MethodHandle) | ||
{ | ||
internal MetadataReader Reader => this.Generator.Reader; | ||
|
||
internal QualifiedMethodDefinition Resolve() => new(this.Generator, this.Generator.Reader.GetMethodDefinition(this.MethodHandle)); | ||
} | ||
|
||
internal record struct QualifiedMethodDefinition(Generator Generator, MethodDefinition Method) | ||
{ | ||
internal MetadataReader Reader => this.Generator.Reader; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/Microsoft.Windows.CsWin32/templates/marshaling/CoCreateInstance.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/// <inheritdoc cref="CoCreateInstance(Guid*, object, win32.System.Com.CLSCTX, Guid*, out object)"/> | ||
internal static unsafe win32.Foundation.HRESULT CoCreateInstance<T>(in Guid rclsid, object pUnkOuter, win32.System.Com.CLSCTX dwClsContext, out T ppv) | ||
/// <inheritdoc cref="CoCreateInstance(Guid*, object, global::Windows.Win32.System.Com.CLSCTX, Guid*, out object)"/> | ||
internal static unsafe global::Windows.Win32.Foundation.HRESULT CoCreateInstance<T>(in Guid rclsid, object pUnkOuter, global::Windows.Win32.System.Com.CLSCTX dwClsContext, out T ppv) | ||
where T : class | ||
{ | ||
win32.Foundation.HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, typeof(T).GUID, out object o); | ||
global::Windows.Win32.Foundation.HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, typeof(T).GUID, out object o); | ||
ppv = (T)o; | ||
return hr; | ||
} |
6 changes: 3 additions & 3 deletions
6
src/Microsoft.Windows.CsWin32/templates/no_marshaling/CoCreateInstance.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/// <inheritdoc cref="CoCreateInstance(Guid*, win32.System.Com.IUnknown*, win32.System.Com.CLSCTX, Guid*, void**)"/> | ||
internal static unsafe win32.Foundation.HRESULT CoCreateInstance<T>(in Guid rclsid, win32.System.Com.IUnknown* pUnkOuter, win32.System.Com.CLSCTX dwClsContext, out T* ppv) | ||
/// <inheritdoc cref="CoCreateInstance(Guid*, global::Windows.Win32.System.Com.IUnknown*, global::Windows.Win32.System.Com.CLSCTX, Guid*, void**)"/> | ||
internal static unsafe global::Windows.Win32.Foundation.HRESULT CoCreateInstance<T>(in Guid rclsid, global::Windows.Win32.System.Com.IUnknown* pUnkOuter, global::Windows.Win32.System.Com.CLSCTX dwClsContext, out T* ppv) | ||
where T : unmanaged | ||
{ | ||
win32.Foundation.HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, typeof(T).GUID, out void* o); | ||
global::Windows.Win32.Foundation.HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, typeof(T).GUID, out void* o); | ||
ppv = (T*)o; | ||
return hr; | ||
} |
Oops, something went wrong.