diff --git a/BuildTools/BuildTools.proj b/BuildTools/BuildTools.proj index 2f8e3718c..d59bfbf31 100644 --- a/BuildTools/BuildTools.proj +++ b/BuildTools/BuildTools.proj @@ -4,7 +4,6 @@ - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de3da6587..ad8aaf7fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -156,7 +156,7 @@ Constants are removed from the metadata when they are detected as members of an ## Attributes -Our tooling defines several [attributes](sources/Win32MetadataInterop) that can be applied to APIs to provide useful context to language projections. +Our tooling defines several [attributes](generation/WinSDK/manual/Metadata.cs) that can be applied to APIs to provide useful context to language projections. To apply an attribute to an API, update the `--memberRemap` section of [emitter.settings.rsp](generation/WinSDK/emitter.settings.rsp) in one of the following ways: diff --git a/README.md b/README.md index 45eed3cac..07cd751d3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Note: Community projects are listed here to help with discovery but are not offi See the [roadmap](./docs/roadmap.md) and [FAQ](./docs/faq.md) for more details. -If you'd like to browse the metadata to see what we're emitting, extract Windows.Win32.winmd and Windows.Win32.Interop.dll from the [Microsoft.Windows.SDK.Win32Metadata](https://www.nuget.org/packages/Microsoft.Windows.SDK.Win32Metadata/) NuGet package and load Windows.Win32.winmd in [ILSpy](https://github.com/icsharpcode/ILSpy/releases/latest). Download the package and rename it to .zip to browse and extract its content. +If you'd like to browse the metadata to see what we're emitting, extract Windows.Win32.winmd from the [Microsoft.Windows.SDK.Win32Metadata](https://www.nuget.org/packages/Microsoft.Windows.SDK.Win32Metadata/) NuGet package and load Windows.Win32.winmd in [ILSpy](https://github.com/icsharpcode/ILSpy/releases/latest). Download the package and rename it to .zip to browse and extract its content. ![ILSpy with winmd](./images/ILSpyWithWinmd.png) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2d3948da9..2cfdb188d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -169,7 +169,7 @@ jobs: inputs: ConnectedServiceName: 'Xlang Code Signing' FolderPath: '$(Build.SourcesDirectory)\bin' - Pattern: 'Windows.Win32.Interop.dll,Windows.Win32.winmd' + Pattern: 'Windows.Win32.winmd' signConfigType: 'inlineSignParams' inlineOperation: | [ diff --git a/generation/WinSDK/manual/ApplicationInstallationAndServicing.cs b/generation/WinSDK/manual/ApplicationInstallationAndServicing.cs index ae3ffc418..350c516a6 100644 --- a/generation/WinSDK/manual/ApplicationInstallationAndServicing.cs +++ b/generation/WinSDK/manual/ApplicationInstallationAndServicing.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.ApplicationInstallationAndServicing { diff --git a/generation/WinSDK/manual/Audio.cs b/generation/WinSDK/manual/Audio.cs index 29ca2a195..96d4ef8fc 100644 --- a/generation/WinSDK/manual/Audio.cs +++ b/generation/WinSDK/manual/Audio.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.UI.WindowsAndMessaging.Apis; namespace Windows.Win32.Media.Audio diff --git a/generation/WinSDK/manual/Com.cs b/generation/WinSDK/manual/Com.cs index 074bbde32..79fe2972e 100644 --- a/generation/WinSDK/manual/Com.cs +++ b/generation/WinSDK/manual/Com.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.UI.Controls.Apis; namespace Windows.Win32.System.Com diff --git a/generation/WinSDK/manual/Console.cs b/generation/WinSDK/manual/Console.cs index 7b0dcbb1b..353a9cf73 100644 --- a/generation/WinSDK/manual/Console.cs +++ b/generation/WinSDK/manual/Console.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Console { diff --git a/generation/WinSDK/manual/Controls.cs b/generation/WinSDK/manual/Controls.cs index a14adb98e..f8f6d39c5 100644 --- a/generation/WinSDK/manual/Controls.cs +++ b/generation/WinSDK/manual/Controls.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.UI.Controls.Apis; namespace Windows.Win32.UI.Controls diff --git a/generation/WinSDK/manual/CryptCerts.cs b/generation/WinSDK/manual/CryptCerts.cs index fbea30008..4a926ab08 100644 --- a/generation/WinSDK/manual/CryptCerts.cs +++ b/generation/WinSDK/manual/CryptCerts.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.UI.WindowsAndMessaging.Apis; namespace Windows.Win32.Security.Cryptography.Certificates diff --git a/generation/WinSDK/manual/DevInst.cs b/generation/WinSDK/manual/DevInst.cs index 823895b36..8da14f566 100644 --- a/generation/WinSDK/manual/DevInst.cs +++ b/generation/WinSDK/manual/DevInst.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Devices.DeviceAndDriverInstallation { diff --git a/generation/WinSDK/manual/Dfs.cs b/generation/WinSDK/manual/Dfs.cs index ebf2fac62..100359e88 100644 --- a/generation/WinSDK/manual/Dfs.cs +++ b/generation/WinSDK/manual/Dfs.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Storage.IscsiDisc { diff --git a/generation/WinSDK/manual/Direct2D.cs b/generation/WinSDK/manual/Direct2D.cs index efecbbd90..6110b95d6 100644 --- a/generation/WinSDK/manual/Direct2D.cs +++ b/generation/WinSDK/manual/Direct2D.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Graphics.Direct2D { diff --git a/generation/WinSDK/manual/DirectWrite.cs b/generation/WinSDK/manual/DirectWrite.cs index 2f6c9beab..c290de0fd 100644 --- a/generation/WinSDK/manual/DirectWrite.cs +++ b/generation/WinSDK/manual/DirectWrite.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.System.SystemServices.Apis; namespace Windows.Win32.Graphics.DirectWrite diff --git a/generation/WinSDK/manual/Dxgi.cs b/generation/WinSDK/manual/Dxgi.cs index 9c15f2b39..4b8986a7b 100644 --- a/generation/WinSDK/manual/Dxgi.cs +++ b/generation/WinSDK/manual/Dxgi.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Graphics.Dxgi { diff --git a/generation/WinSDK/manual/ETW.cs b/generation/WinSDK/manual/ETW.cs index 861e511b7..91bad7ea3 100644 --- a/generation/WinSDK/manual/ETW.cs +++ b/generation/WinSDK/manual/ETW.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Diagnostics.Etw { diff --git a/generation/WinSDK/manual/FileSystem.cs b/generation/WinSDK/manual/FileSystem.cs index 2cd3c46b2..1d7491a9c 100644 --- a/generation/WinSDK/manual/FileSystem.cs +++ b/generation/WinSDK/manual/FileSystem.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Storage.FileSystem { diff --git a/generation/WinSDK/manual/Foundation.cs b/generation/WinSDK/manual/Foundation.cs index 71f7f9fc5..d2487d441 100644 --- a/generation/WinSDK/manual/Foundation.cs +++ b/generation/WinSDK/manual/Foundation.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Foundation { diff --git a/generation/WinSDK/manual/Gdi.cs b/generation/WinSDK/manual/Gdi.cs index 97642d4b5..4beac98c8 100644 --- a/generation/WinSDK/manual/Gdi.cs +++ b/generation/WinSDK/manual/Gdi.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Graphics.Gdi { diff --git a/generation/WinSDK/manual/HiDpi.cs b/generation/WinSDK/manual/HiDpi.cs index a38f30c6f..aba86020b 100644 --- a/generation/WinSDK/manual/HiDpi.cs +++ b/generation/WinSDK/manual/HiDpi.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.UI.HiDpi { diff --git a/generation/WinSDK/manual/Identity.cs b/generation/WinSDK/manual/Identity.cs index f36c19367..fa96c31d6 100644 --- a/generation/WinSDK/manual/Identity.cs +++ b/generation/WinSDK/manual/Identity.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.InteropServices; - -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Security.Authentication.Identity { diff --git a/generation/WinSDK/manual/Iis.cs b/generation/WinSDK/manual/Iis.cs index 2ee718434..af087068f 100644 --- a/generation/WinSDK/manual/Iis.cs +++ b/generation/WinSDK/manual/Iis.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; using Windows.Win32.Foundation; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Iis { diff --git a/generation/WinSDK/manual/Ioctl.cs b/generation/WinSDK/manual/Ioctl.cs index 881c475ed..778b79c5b 100644 --- a/generation/WinSDK/manual/Ioctl.cs +++ b/generation/WinSDK/manual/Ioctl.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Ioctl { diff --git a/generation/WinSDK/manual/JobObjects.cs b/generation/WinSDK/manual/JobObjects.cs index 4557c51dc..d5beab2cb 100644 --- a/generation/WinSDK/manual/JobObjects.cs +++ b/generation/WinSDK/manual/JobObjects.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.JobObjects { diff --git a/generation/WinSDK/manual/Js.cs b/generation/WinSDK/manual/Js.cs index 8f9dd68cb..0b2f91340 100644 --- a/generation/WinSDK/manual/Js.cs +++ b/generation/WinSDK/manual/Js.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Js { diff --git a/generation/WinSDK/manual/Kernel.cs b/generation/WinSDK/manual/Kernel.cs index f74ddab9e..35333048a 100644 --- a/generation/WinSDK/manual/Kernel.cs +++ b/generation/WinSDK/manual/Kernel.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Kernel { diff --git a/generation/WinSDK/manual/MediaFoundation.cs b/generation/WinSDK/manual/MediaFoundation.cs index 61775b284..cb2114fcf 100644 --- a/generation/WinSDK/manual/MediaFoundation.cs +++ b/generation/WinSDK/manual/MediaFoundation.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Media.MediaFoundation { diff --git a/generation/WinSDK/manual/Metadata.cs b/generation/WinSDK/manual/Metadata.cs new file mode 100644 index 000000000..1a7739d96 --- /dev/null +++ b/generation/WinSDK/manual/Metadata.cs @@ -0,0 +1,276 @@ +using System; +using System.Runtime.InteropServices; + +namespace Windows.Win32.Foundation.Metadata; + +[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false, Inherited = true)] +public class AgileAttribute : Attribute +{ + public AgileAttribute() + { + } +} + +public class AlsoUsableForAttribute : Attribute +{ + public AlsoUsableForAttribute(string otherType) + { + } +} + +public class CanReturnErrorsAsSuccessAttribute : Attribute +{ + public CanReturnErrorsAsSuccessAttribute() + { + } +} + +public class CanReturnMultipleSuccessValuesAttribute : Attribute +{ + public CanReturnMultipleSuccessValuesAttribute() + { + } +} + +[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] +public class ComOutPtrAttribute : Attribute +{ + public ComOutPtrAttribute() + { + } +} + +public class ConstantAttribute : Attribute +{ + public ConstantAttribute(String Value) + { + } +} + +public class ConstAttribute : Attribute +{ + public ConstAttribute() + { + } +} + +[AttributeUsage(AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] +[ComVisible(true)] +public class CppAttributeList : Attribute +{ + public CppAttributeList(String AttributeList) + { + } +} + +public class DoNotReleaseAttribute : Attribute +{ + public DoNotReleaseAttribute() + { + } +} + +[AttributeUsage(AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] +[ComVisible(true)] +public class FreeWithAttribute : Attribute +{ + public FreeWithAttribute(String Name) + { + } +} + +public class GuidAttribute : Attribute +{ + public GuidAttribute(uint a, ushort b, ushort c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) + { + } +} + +[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true, Inherited = true)] +public class InvalidHandleValueAttribute : Attribute +{ + public InvalidHandleValueAttribute(long Value) + { + } +} + +public class MemorySizeAttribute : Attribute +{ + public short BytesParamIndex; + + public MemorySizeAttribute() + { + } +} + +public class NativeArrayInfoAttribute : Attribute +{ + // + // Summary: + // Indicates the number of elements in the fixed-length array or the number of characters + // (not bytes) in a string to import. + public int CountConst; + + // + // Summary: + // Indicates the zero-based parameter that contains the count of array elements, + // similar to size_is in COM. + public short CountParamIndex; + + // + // Summary: + // Indicates the struct field name that contains the count of array elements. + public string CountFieldName; + + public NativeArrayInfoAttribute() + { + } +} + +/// Defines the encoding of a string as it was defined in the native signature. +//[Conditional("DEBUG")] +[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] +[ComVisible(true)] +public class NativeEncodingAttribute : Attribute +{ + /// Initializes a new instance of the class. + /// The encoding of a string as it was defined in the native signature. + public NativeEncodingAttribute(String Name) + { + } +} + +[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = true)] +public class NativeInheritanceAttribute : Attribute +{ + public NativeInheritanceAttribute(string BaseName) + { + } +} + +public class NativeTypedefAttribute : Attribute +{ + public NativeTypedefAttribute() + { + } +} + +/// Defines the type of a member as it was used in the native signature. +//[Conditional("DEBUG")] +[AttributeUsage(AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] +[ComVisible(true)] +public class NativeTypeNameAttribute : Attribute +{ + /// Initializes a new instance of the class. + /// The name of the type that was used in the native signature. + public NativeTypeNameAttribute(String Name) + { + } +} + +public class NotNullTerminatedAttribute : Attribute +{ + public NotNullTerminatedAttribute() + { + } +} + +public class NullNullTerminatedAttribute : Attribute +{ + public NullNullTerminatedAttribute() + { + } +} + +public class PropertyKeyAttribute : Attribute +{ + public PropertyKeyAttribute(uint a, ushort b, ushort c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k, uint pid) + { + } +} + +public class RAIIFreeAttribute : Attribute +{ + public RAIIFreeAttribute(string Name) + { + } +} + +public class ReservedAttribute : Attribute +{ + public ReservedAttribute() + { + } +} + +public class ReturnsUnownedHandle : Attribute +{ + public ReturnsUnownedHandle() + { + } +} + +[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] +public class RetValAttribute : Attribute +{ + public RetValAttribute() + { + } +} + +public class ScopedEnumAttribute : Attribute +{ + public ScopedEnumAttribute() + { + } +} + +/// +/// Indicates that the attributed method is defined in an unmanaged static library (LIB). +/// +[AttributeUsage(AttributeTargets.Method, Inherited = false)] +public class StaticLibraryAttribute : Attribute +{ + /// + /// Initialize a new instance of with the name of the LIB + /// file that contains the definition of this method. + /// + /// + /// The name of the LIB file that contains the definition of this method. + /// + public StaticLibraryAttribute(string LibName) + { + } +} + +public class StructSizeFieldAttribute : Attribute +{ + public StructSizeFieldAttribute(string field) + { + } +} + +[Flags] +public enum Architecture +{ + None = 0, + X86 = 1, + X64 = 2, + Arm64 = 4, + All = Architecture.X64 | Architecture.X86 | Architecture.Arm64 +} + +public class SupportedArchitectureAttribute : Attribute +{ + public SupportedArchitectureAttribute(Architecture arch) + { + } +} + +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = false)] +public class SupportedOSPlatformAttribute : Attribute +{ + public SupportedOSPlatformAttribute(string platform) + { + } +} diff --git a/generation/WinSDK/manual/Mi.cs b/generation/WinSDK/manual/Mi.cs index ae88b5487..399e2b499 100644 --- a/generation/WinSDK/manual/Mi.cs +++ b/generation/WinSDK/manual/Mi.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Wmi { diff --git a/generation/WinSDK/manual/MsCs.cs b/generation/WinSDK/manual/MsCs.cs index 0b5b5ea07..1a927e95d 100644 --- a/generation/WinSDK/manual/MsCs.cs +++ b/generation/WinSDK/manual/MsCs.cs @@ -1,4 +1,4 @@ -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Networking.Clustering { // Here becauase of: https://github.com/dotnet/ClangSharp/issues/367 diff --git a/generation/WinSDK/manual/Multimedia.cs b/generation/WinSDK/manual/Multimedia.cs index b4225e6e6..2a751ec5f 100644 --- a/generation/WinSDK/manual/Multimedia.cs +++ b/generation/WinSDK/manual/Multimedia.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.Media.Audio.Apis; using static Windows.Win32.UI.WindowsAndMessaging.Apis; diff --git a/generation/WinSDK/manual/NativeWiFi.cs b/generation/WinSDK/manual/NativeWiFi.cs index 5971dfc29..af72c51cd 100644 --- a/generation/WinSDK/manual/NativeWiFi.cs +++ b/generation/WinSDK/manual/NativeWiFi.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.NetworkManagement.WiFi { diff --git a/generation/WinSDK/manual/Ole.cs b/generation/WinSDK/manual/Ole.cs index ab489039e..6e9f75029 100644 --- a/generation/WinSDK/manual/Ole.cs +++ b/generation/WinSDK/manual/Ole.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.Foundation.Apis; using static Windows.Win32.System.Diagnostics.Debug.FACILITY_CODE; using static Windows.Win32.System.SystemServices.Apis; diff --git a/generation/WinSDK/manual/Power.cs b/generation/WinSDK/manual/Power.cs index e15c5f294..957b45e0f 100644 --- a/generation/WinSDK/manual/Power.cs +++ b/generation/WinSDK/manual/Power.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Power { diff --git a/generation/WinSDK/manual/Printing.cs b/generation/WinSDK/manual/Printing.cs index d5701a4f5..26f894eb8 100644 --- a/generation/WinSDK/manual/Printing.cs +++ b/generation/WinSDK/manual/Printing.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; using Windows.Win32.Devices.Communication; using Windows.Win32.Foundation; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using Windows.Win32.System.Power; namespace Windows.Win32.Graphics.Printing diff --git a/generation/WinSDK/manual/Registry.cs b/generation/WinSDK/manual/Registry.cs index 86422d867..e8eab1c99 100644 --- a/generation/WinSDK/manual/Registry.cs +++ b/generation/WinSDK/manual/Registry.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Registry { diff --git a/generation/WinSDK/manual/RemoteDesktop.cs b/generation/WinSDK/manual/RemoteDesktop.cs index 40d401047..f9479298f 100644 --- a/generation/WinSDK/manual/RemoteDesktop.cs +++ b/generation/WinSDK/manual/RemoteDesktop.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.RemoteDesktop { diff --git a/generation/WinSDK/manual/RestartManager.cs b/generation/WinSDK/manual/RestartManager.cs index b6cfe6874..fc4383b33 100644 --- a/generation/WinSDK/manual/RestartManager.cs +++ b/generation/WinSDK/manual/RestartManager.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.RestartManager { diff --git a/generation/WinSDK/manual/Rpc.cs b/generation/WinSDK/manual/Rpc.cs index 6ff332819..ec8543fa6 100644 --- a/generation/WinSDK/manual/Rpc.cs +++ b/generation/WinSDK/manual/Rpc.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; using Windows.Win32.Foundation; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Rpc { diff --git a/generation/WinSDK/manual/Scsi.cs b/generation/WinSDK/manual/Scsi.cs index 71095f7c2..4d470d7bf 100644 --- a/generation/WinSDK/manual/Scsi.cs +++ b/generation/WinSDK/manual/Scsi.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Storage.DistributedFileSystem { diff --git a/generation/WinSDK/manual/Security.cs b/generation/WinSDK/manual/Security.cs index 6f30b1ac8..6078cf597 100644 --- a/generation/WinSDK/manual/Security.cs +++ b/generation/WinSDK/manual/Security.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Security { diff --git a/generation/WinSDK/manual/Services.cs b/generation/WinSDK/manual/Services.cs index 4f7217421..c61f57b23 100644 --- a/generation/WinSDK/manual/Services.cs +++ b/generation/WinSDK/manual/Services.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Services { diff --git a/generation/WinSDK/manual/Shell.cs b/generation/WinSDK/manual/Shell.cs index 500844066..ca7eb69c9 100644 --- a/generation/WinSDK/manual/Shell.cs +++ b/generation/WinSDK/manual/Shell.cs @@ -1,6 +1,7 @@ using System; +using Windows.Win32.Foundation.Metadata; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; using static Windows.Win32.Foundation.Apis; using static Windows.Win32.System.SystemServices.Apis; diff --git a/generation/WinSDK/manual/SystemInformation.cs b/generation/WinSDK/manual/SystemInformation.cs index 6adb36642..b50652f98 100644 --- a/generation/WinSDK/manual/SystemInformation.cs +++ b/generation/WinSDK/manual/SystemInformation.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.SystemInformation { diff --git a/generation/WinSDK/manual/SystemServices.cs b/generation/WinSDK/manual/SystemServices.cs index a1fa871a7..5e231b9b7 100644 --- a/generation/WinSDK/manual/SystemServices.cs +++ b/generation/WinSDK/manual/SystemServices.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.SystemServices { diff --git a/generation/WinSDK/manual/TabletPC.cs b/generation/WinSDK/manual/TabletPC.cs index a593339ce..baa72c8cc 100644 --- a/generation/WinSDK/manual/TabletPC.cs +++ b/generation/WinSDK/manual/TabletPC.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.UI.TabletPC { diff --git a/generation/WinSDK/manual/TextServices.Manual.cs b/generation/WinSDK/manual/TextServices.Manual.cs index 6dc429d1e..2a57598e6 100644 --- a/generation/WinSDK/manual/TextServices.Manual.cs +++ b/generation/WinSDK/manual/TextServices.Manual.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.UI.TextServices { diff --git a/generation/WinSDK/manual/Threading.cs b/generation/WinSDK/manual/Threading.cs index e6514d04f..db14ee5c4 100644 --- a/generation/WinSDK/manual/Threading.cs +++ b/generation/WinSDK/manual/Threading.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; using Windows.Win32.Foundation; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.Threading { diff --git a/generation/WinSDK/manual/VirtualDiskService.cs b/generation/WinSDK/manual/VirtualDiskService.cs index fc3f8578d..902064304 100644 --- a/generation/WinSDK/manual/VirtualDiskService.cs +++ b/generation/WinSDK/manual/VirtualDiskService.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; using Windows.Win32.Foundation; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Storage.VirtualDiskService { diff --git a/generation/WinSDK/manual/WinProg.cs b/generation/WinSDK/manual/WinProg.cs index be3e582aa..536269a62 100644 --- a/generation/WinSDK/manual/WinProg.cs +++ b/generation/WinSDK/manual/WinProg.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.System.WindowsProgramming { diff --git a/generation/WinSDK/manual/WinSock.cs b/generation/WinSDK/manual/WinSock.cs index 5a3a35caa..5febb1b5d 100644 --- a/generation/WinSDK/manual/WinSock.cs +++ b/generation/WinSDK/manual/WinSock.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Networking.WinSock { diff --git a/generation/WinSDK/manual/WindowsAndMessaging.cs b/generation/WinSDK/manual/WindowsAndMessaging.cs index 4077d69e0..626640e83 100644 --- a/generation/WinSDK/manual/WindowsAndMessaging.cs +++ b/generation/WinSDK/manual/WindowsAndMessaging.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.UI.WindowsAndMessaging { diff --git a/generation/WinSDK/scraper.header.txt b/generation/WinSDK/scraper.header.txt index 9ffeded19..6762580b4 100644 --- a/generation/WinSDK/scraper.header.txt +++ b/generation/WinSDK/scraper.header.txt @@ -29,6 +29,7 @@ using Windows.Win32.Devices.Tapi; using Windows.Win32.Devices.Usb; using Windows.Win32.Devices.WebServicesOnDevices; using Windows.Win32.Foundation; +using Windows.Win32.Foundation.Metadata; using Windows.Win32.Gaming; using Windows.Win32.Globalization; using Windows.Win32.Graphics.Direct2D; diff --git a/scripts/BuildMetadataBin.ps1 b/scripts/BuildMetadataBin.ps1 index 5ebdcc440..bb8986545 100644 --- a/scripts/BuildMetadataBin.ps1 +++ b/scripts/BuildMetadataBin.ps1 @@ -27,10 +27,6 @@ if (!$skipInstallTools.IsPresent) $assemblyVersion = nbgv get-version -v AssemblyVersion -$metadataInteropBin = "$PSScriptRoot\..\bin\Release\netstandard2.1\Windows.Win32.Interop.dll" - -Copy-Item $metadataInteropBin $binDir - $arch = "crossarch" $outputWinmdFileName = Get-OutputWinmdFileName -Arch $arch diff --git a/scripts/ChangesSinceLastRelease.txt b/scripts/ChangesSinceLastRelease.txt index f4ce2a3b3..ebdcf2e64 100644 --- a/scripts/ChangesSinceLastRelease.txt +++ b/scripts/ChangesSinceLastRelease.txt @@ -57,3 +57,40 @@ Windows.Win32.Security.Cryptography.BCRYPTGENRANDOM_FLAGS.BCRYPT_USE_SYSTEM_PREF # Fixed #1526. Windows.Win32.UI.TextServices.Apis.TF_DEFAULT_SELECTION...System.UInt64 => System.UInt32 Windows.Win32.UI.TextServices.Apis.TS_DEFAULT_SELECTION...System.UInt64 => System.UInt32 +# Fixed #1467. +Windows.Win32.Foundation.Metadata.AgileAttribute added +Windows.Win32.Foundation.Metadata.AlsoUsableForAttribute added +Windows.Win32.Foundation.Metadata.Architecture added +Windows.Win32.Foundation.Metadata.Architecture.All added +Windows.Win32.Foundation.Metadata.Architecture.Arm64 added +Windows.Win32.Foundation.Metadata.Architecture.None added +Windows.Win32.Foundation.Metadata.Architecture.X64 added +Windows.Win32.Foundation.Metadata.Architecture.X86 added +Windows.Win32.Foundation.Metadata.CanReturnErrorsAsSuccessAttribute added +Windows.Win32.Foundation.Metadata.CanReturnMultipleSuccessValuesAttribute added +Windows.Win32.Foundation.Metadata.ComOutPtrAttribute added +Windows.Win32.Foundation.Metadata.ConstantAttribute added +Windows.Win32.Foundation.Metadata.ConstAttribute added +Windows.Win32.Foundation.Metadata.CppAttributeList added +Windows.Win32.Foundation.Metadata.DoNotReleaseAttribute added +Windows.Win32.Foundation.Metadata.FreeWithAttribute added +Windows.Win32.Foundation.Metadata.GuidAttribute added +Windows.Win32.Foundation.Metadata.InvalidHandleValueAttribute added +Windows.Win32.Foundation.Metadata.MemorySizeAttribute added +Windows.Win32.Foundation.Metadata.NativeArrayInfoAttribute added +Windows.Win32.Foundation.Metadata.NativeEncodingAttribute added +Windows.Win32.Foundation.Metadata.NativeInheritanceAttribute added +Windows.Win32.Foundation.Metadata.NativeTypedefAttribute added +Windows.Win32.Foundation.Metadata.NativeTypeNameAttribute added +Windows.Win32.Foundation.Metadata.NotNullTerminatedAttribute added +Windows.Win32.Foundation.Metadata.NullNullTerminatedAttribute added +Windows.Win32.Foundation.Metadata.PropertyKeyAttribute added +Windows.Win32.Foundation.Metadata.RAIIFreeAttribute added +Windows.Win32.Foundation.Metadata.ReservedAttribute added +Windows.Win32.Foundation.Metadata.ReturnsUnownedHandle added +Windows.Win32.Foundation.Metadata.RetValAttribute added +Windows.Win32.Foundation.Metadata.ScopedEnumAttribute added +Windows.Win32.Foundation.Metadata.StaticLibraryAttribute added +Windows.Win32.Foundation.Metadata.StructSizeFieldAttribute added +Windows.Win32.Foundation.Metadata.SupportedArchitectureAttribute added +Windows.Win32.Foundation.Metadata.SupportedOSPlatformAttribute added diff --git a/scripts/CreateUsingsForGeneratedSources.ps1 b/scripts/CreateUsingsForGeneratedSources.ps1 index 3b755e3a0..25ef7d3ca 100644 --- a/scripts/CreateUsingsForGeneratedSources.ps1 +++ b/scripts/CreateUsingsForGeneratedSources.ps1 @@ -27,7 +27,7 @@ $outputFileName = "$PSScriptRoot\..\generation\header.txt" $stream = [System.IO.StreamWriter] $outputFileName $stream.WriteLine("// Copyright © Microsoft") -$stream.WriteLine("using Windows.Win32.Interop;") +$stream.WriteLine("using Windows.Win32.Foundation.Metadata;") $stream.WriteLine() $sortedKeys = $namespaces.Keys | Sort-Object diff --git a/sources/BuildTools.sln b/sources/BuildTools.sln index 4d86c5e40..1129151c1 100644 --- a/sources/BuildTools.sln +++ b/sources/BuildTools.sln @@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClangSharpSourceToWinmd", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinmdUtils", "WinmdUtils\WinmdUtils.csproj", "{D58855C2-F427-4C4D-990A-7F932A7B4CA3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win32MetadataInterop", "Win32MetadataInterop\Win32MetadataInterop.csproj", "{C8AA8253-FF34-4963-9CD0-B7A4C28D33BB}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{4D4F6043-CD81-4FD3-A6E5-0A2148281E78}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetadataUtils", "MetadataUtils\MetadataUtils.csproj", "{08297558-5DC0-4ACB-A67B-3E498638AD4B}" diff --git a/sources/ClangSharpSourceToWinmd/ClangSharpSourceCompilation.cs b/sources/ClangSharpSourceToWinmd/ClangSharpSourceCompilation.cs index 9f89ebabd..3449ee477 100644 --- a/sources/ClangSharpSourceToWinmd/ClangSharpSourceCompilation.cs +++ b/sources/ClangSharpSourceToWinmd/ClangSharpSourceCompilation.cs @@ -6,7 +6,6 @@ using System.Collections.ObjectModel; using System.IO; using System.Linq; -using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -72,23 +71,23 @@ private static IEnumerable FilesToTrees(IEnumerable files) } } - private static Windows.Win32.Interop.Architecture GetArchitectureForFileName(string fileName) + private static Architecture GetArchitectureForFileName(string fileName) { string potentialArch = Path.GetFileName(Path.GetDirectoryName(fileName)); switch (potentialArch) { case "x64": - return Windows.Win32.Interop.Architecture.X64; + return Architecture.X64; case "x86": - return Windows.Win32.Interop.Architecture.X86; + return Architecture.X86; case "arm64": - return Windows.Win32.Interop.Architecture.Arm64; + return Architecture.Arm64; default: - return Windows.Win32.Interop.Architecture.None; + return Architecture.None; } } @@ -96,8 +95,8 @@ private static CrossArchSyntaxMap LoadCrossArchMapFromFiles(IEnumerable { CrossArchSyntaxMap crossArchSyntaxMap = new CrossArchSyntaxMap(); - var nonx86Files = files.Where(f => GetArchitectureForFileName(f) == Windows.Win32.Interop.Architecture.X64 || GetArchitectureForFileName(f) == Windows.Win32.Interop.Architecture.Arm64); - var x86Files = files.Where(f => GetArchitectureForFileName(f) == Windows.Win32.Interop.Architecture.X86); + var nonx86Files = files.Where(f => GetArchitectureForFileName(f) == Architecture.X64 || GetArchitectureForFileName(f) == Architecture.Arm64); + var x86Files = files.Where(f => GetArchitectureForFileName(f) == Architecture.X86); // Add non-x86 first so that x86 has a chance to see if it can merge structs not marked // with 4-byte packing with 64-bit versions that are marked. The default packing is 4 @@ -123,7 +122,6 @@ private static string GetPartitionNameFromFileName(string fileName) public static ClangSharpSourceCompilation Create( string sourceDirectory, string arch, - string interopFileName, Dictionary remaps, Dictionary> enumAdditions, IEnumerable enumsMakeFlags, @@ -151,7 +149,6 @@ public static ClangSharpSourceCompilation Create( } List refs = new List(); - refs.Add(MetadataReference.CreateFromFile(interopFileName)); refs.Add(MetadataReference.CreateFromFile(netstandardPath)); if (addedRefs != null) @@ -238,7 +235,7 @@ public static ClangSharpSourceCompilation Create( watch.Restart(); List filesToMerge = new List(); - foreach (string x86FileName in modifiedFiles.Where(f => GetArchitectureForFileName(f) == Windows.Win32.Interop.Architecture.X86)) + foreach (string x86FileName in modifiedFiles.Where(f => GetArchitectureForFileName(f) == Architecture.X86)) { string x64FileName = x86FileName.Replace(@"\x86\", @"\x64\", StringComparison.OrdinalIgnoreCase); string arm64FileName = x86FileName.Replace(@"\x86\", @"\arm64\", StringComparison.OrdinalIgnoreCase); @@ -268,7 +265,7 @@ public static ClangSharpSourceCompilation Create( HashSet nonX86TreesUsedForX86 = crossArchSyntaxMap.Get64BitTreesUsedForX86(); CrossArchTreeMerger crossArchTreeMerger = new CrossArchTreeMerger(crossArchSyntaxMap); - System.Threading.Tasks.Parallel.ForEach(FilesToTrees(filesToMerge.Where(f => GetArchitectureForFileName(f) == Windows.Win32.Interop.Architecture.X86)), opt, (x86Tree) => + System.Threading.Tasks.Parallel.ForEach(FilesToTrees(filesToMerge.Where(f => GetArchitectureForFileName(f) == Architecture.X86)), opt, (x86Tree) => { string x64FileName = x86Tree.FilePath.Replace(@"\x86\", @"\x64\", StringComparison.OrdinalIgnoreCase); string arm64FileName = x86Tree.FilePath.Replace(@"\x86\", @"\arm64\", StringComparison.OrdinalIgnoreCase); diff --git a/sources/ClangSharpSourceToWinmd/ClangSharpSourceToWinmd.csproj b/sources/ClangSharpSourceToWinmd/ClangSharpSourceToWinmd.csproj index ba4294a81..a897daf89 100644 --- a/sources/ClangSharpSourceToWinmd/ClangSharpSourceToWinmd.csproj +++ b/sources/ClangSharpSourceToWinmd/ClangSharpSourceToWinmd.csproj @@ -20,7 +20,6 @@ - diff --git a/sources/ClangSharpSourceToWinmd/ClangSharpSourceWinmdGenerator.cs b/sources/ClangSharpSourceToWinmd/ClangSharpSourceWinmdGenerator.cs index 34aa131d1..20e17ff91 100644 --- a/sources/ClangSharpSourceToWinmd/ClangSharpSourceWinmdGenerator.cs +++ b/sources/ClangSharpSourceToWinmd/ClangSharpSourceWinmdGenerator.cs @@ -9,15 +9,16 @@ using System.IO; using System.Linq; using System.Reflection; -using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; using System.Reflection.PortableExecutable; using System.Runtime.InteropServices; using System.Text.RegularExpressions; +using MetadataUtils; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using MetadataUtils; +using Newtonsoft.Json.Linq; namespace ClangSharpSourceToWinmd { @@ -26,13 +27,11 @@ public class ClangSharpSourceWinmdGenerator public const string Win32WideStringType = "Windows.Win32.Foundation.PWSTR"; public const string Win32StringType = "Windows.Win32.Foundation.PSTR"; - private const string InteropNamespace = "Windows.Win32.Interop"; private const string ScannedSuffix = "__scanned__"; private const string RemovePrefix = "__remove__"; private const string ForceConstPrefix = "__forceconst__"; private const string SystemAssemblyName = "netstandard"; - private const string Win32InteropAssemblyName = "Windows.Win32.Interop"; private const string Win32MetadataAssemblyName = "Windows.Win32.winmd"; private static readonly Regex TypeImportRegex = new Regex(@"<(([^,]+),\s*Version=(\d+\.\d+\.\d+\.\d+),\s*Culture=([^,]+),\s*PublicKeyToken=([^>]+))>(\S+)"); @@ -100,7 +99,7 @@ private ClangSharpSourceWinmdGenerator( void VerifySymbolsLoadedByCompiler() { - string[] standardSymbolNames = new string[] { "System.Object", "System.Attribute", $"{InteropNamespace}.ConstAttribute" }; + string[] standardSymbolNames = new string[] { "System.Object", "System.Attribute" }; foreach (var name in standardSymbolNames) { @@ -157,17 +156,6 @@ void InitReferences() default); this.assemblyNamesToRefHandles[SystemAssemblyName] = systemAssemblyRef; - var interopAssembly = this.compilation.ReferencedAssemblyNames.ToList().Find(a => a.Name == Win32InteropAssemblyName); - var interopAssemblyRef = - this.metadataBuilder.AddAssemblyReference( - this.metadataBuilder.GetOrAddString(InteropNamespace), - interopAssembly.Version, - default, - this.metadataBuilder.GetOrAddBlob(interopAssembly.PublicKeyToken), - default, - default); - this.assemblyNamesToRefHandles[Win32InteropAssemblyName] = interopAssemblyRef; - var win32Assembly = this.compilation.ReferencedAssemblyNames.ToList().Find(a => a.Name == Win32MetadataAssemblyName); if (win32Assembly != null) { @@ -257,7 +245,7 @@ private static string GetQualifiedName(string @namespace, string name) private static bool HasGuidAttribute(SyntaxList attributeLists) { - bool ret = attributeLists.Any(list => list.Attributes.Any(attr => attr.Name.ToString() == "Windows.Win32.Interop.Guid")); + bool ret = attributeLists.Any(list => list.Attributes.Any(attr => attr.Name.ToString() == "Windows.Win32.Foundation.Metadata.Guid")); return ret; } @@ -597,10 +585,6 @@ private EntityHandle GetTypeReference(string @namespace, string name, EntityHand { scopeRef = this.assemblyNamesToRefHandles[SystemAssemblyName]; } - else if (@namespace.StartsWith(InteropNamespace)) - { - scopeRef = this.assemblyNamesToRefHandles[Win32InteropAssemblyName]; - } else { scopeRef = this.moduleRef; @@ -971,7 +955,7 @@ private ITypeSymbol GetTypeFromShortName(string name) if (!fixedName.Contains(".")) { - foreach (string @namespace in new string[] { InteropNamespace, "System" }) + foreach (string @namespace in new string[] { "System" }) { var fullNameToCheck = GetQualifiedName(@namespace, fixedName); ret = this.compilation.GetTypeByMetadataName(fullNameToCheck); @@ -1263,11 +1247,16 @@ private FieldDefinitionHandle WriteClassFields(ClassDeclarationSyntax node) if (!fieldSymbol.IsConst) { - fieldAttributes = FieldAttributes.Public | FieldAttributes.Static; + fieldAttributes = FieldAttributes.Public; - if (!HasGuidAttribute(field.AttributeLists) && !HasConstantAttribute(field.AttributeLists)) + if (node.BaseList?.Types[0]?.ToString() != "Attribute") { - continue; + fieldAttributes |= FieldAttributes.Static; + + if (!HasGuidAttribute(field.AttributeLists) && !HasConstantAttribute(field.AttributeLists)) + { + continue; + } } if (fieldSymbol.Name.StartsWith("IID_")) @@ -1352,6 +1341,25 @@ private MethodDefinitionHandle WriteClassMethods(ClassDeclarationSyntax node) MethodDefinitionHandle firstMethod = default; string classFullName = this.GetFullNameForSymbol(classSymbol); + foreach (ConstructorDeclarationSyntax constructor in node.Members.Where(m => m is ConstructorDeclarationSyntax)) + { + var symbol = model.GetDeclaredSymbol(constructor); + + MethodImplAttributes methodImplAttributes = MethodImplAttributes.Managed; + var methodDef = + this.AddMethodViaSymbol( + symbol, + MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, + methodImplAttributes, + false, + false); + + if (firstMethod.IsNil) + { + firstMethod = methodDef; + } + } + foreach (MethodDeclarationSyntax method in node.Members.Where(m => m is MethodDeclarationSyntax)) { var symbol = model.GetDeclaredSymbol(method); @@ -1476,7 +1484,8 @@ private void WriteClassDef(ClassDeclarationSyntax node) var name = node.Identifier.ValueText; string fullName = symbol.ConstructedFrom.ToString(); - TypeAttributes typeAttributes = TypeAttributes.Public | TypeAttributes.AutoClass | TypeAttributes.Abstract | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit; + TypeAttributes typeAttributes = TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AutoClass | TypeAttributes.BeforeFieldInit; + typeAttributes |= node.BaseList is null ? TypeAttributes.Abstract : TypeAttributes.Class; if (methodDefinition.IsNil) { @@ -1493,10 +1502,12 @@ private void WriteClassDef(ClassDeclarationSyntax node) typeAttributes, nsHandle, this.metadataBuilder.GetOrAddString(name), - this.GetTypeReference("System", "Object"), + this.GetTypeReference("System", node.BaseList is null ? "Object" : node.BaseList.Types[0].ToString()), fieldList: fieldDefinition, methodList: methodDefinition); + this.AddCustomAttributes(symbol.GetAttributes(), destTypeDefHandle); + this.namesToTypeDefHandles[fullName] = destTypeDefHandle; } diff --git a/sources/ClangSharpSourceToWinmd/CrossArchSyntaxMap.cs b/sources/ClangSharpSourceToWinmd/CrossArchSyntaxMap.cs index 8f3eca8ac..691a9afdd 100644 --- a/sources/ClangSharpSourceToWinmd/CrossArchSyntaxMap.cs +++ b/sources/ClangSharpSourceToWinmd/CrossArchSyntaxMap.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Windows.Win32.Interop; using MetadataUtils; namespace ClangSharpSourceToWinmd diff --git a/sources/ClangSharpSourceToWinmd/CrossArchTreeMerger.cs b/sources/ClangSharpSourceToWinmd/CrossArchTreeMerger.cs index f4718bc1a..5efedf933 100644 --- a/sources/ClangSharpSourceToWinmd/CrossArchTreeMerger.cs +++ b/sources/ClangSharpSourceToWinmd/CrossArchTreeMerger.cs @@ -6,7 +6,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Windows.Win32.Interop; using MetadataUtils; namespace ClangSharpSourceToWinmd @@ -235,7 +234,7 @@ private static string FormatArch(Architecture arch) ret.Append(" | "); } - ret.Append($"Windows.Win32.Interop.Architecture.{val}"); + ret.Append($"Windows.Win32.Foundation.Metadata.Architecture.{val}"); } } diff --git a/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs b/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs index a3c033b3b..ad66bfa55 100644 --- a/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs +++ b/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs @@ -292,7 +292,7 @@ public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node) SyntaxFactory.AttributeList( SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Attribute( - SyntaxFactory.ParseName("Windows.Win32.Interop.Guid"), + SyntaxFactory.ParseName("Windows.Win32.Foundation.Metadata.Guid"), SyntaxFactory.ParseAttributeArgumentList(argsFormatted)))); node = node.AddAttributeLists(attrsList).WithLeadingTrivia(node.GetLeadingTrivia()); diff --git a/sources/ClangSharpSourceToWinmd/NativeTypedefStructsCreator.cs b/sources/ClangSharpSourceToWinmd/NativeTypedefStructsCreator.cs index 7fd8d6ed3..47c52ba25 100644 --- a/sources/ClangSharpSourceToWinmd/NativeTypedefStructsCreator.cs +++ b/sources/ClangSharpSourceToWinmd/NativeTypedefStructsCreator.cs @@ -11,7 +11,7 @@ public static void WriteToStream(Dictionary methodNamesToNamespa using var writer = new StreamWriter(output, leaveOpen: true); writer.Write( @"using System; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; "); string currentNamespace = null; diff --git a/sources/ClangSharpSourceToWinmd/Program.cs b/sources/ClangSharpSourceToWinmd/Program.cs index 0d115cfbf..7acba2bd7 100644 --- a/sources/ClangSharpSourceToWinmd/Program.cs +++ b/sources/ClangSharpSourceToWinmd/Program.cs @@ -23,7 +23,6 @@ public static int Main(string[] args) { new Option("--sourceDir", "The location of the source files.") { IsRequired = true }, new Option("--arch", () => "x64", "The CPU architecture."), - new Option("--interopFileName", "The path to Windows.Win32.Interop.dll") { IsRequired = true }, new Option("--outputFileName", "The path to the .winmd to create") { IsRequired = true }, new Option("--version", description: "The version to use on the .winmd", getDefaultValue: () => "1.0.0.0"), new Option("--memberRemap", "Remaps fields and parameters by adding attributes or changing the type.", ArgumentArity.OneOrMore), @@ -48,7 +47,6 @@ public static int Run(InvocationContext context) { string sourceDirectory = context.ParseResult.ValueForOption("--sourceDir"); string arch = context.ParseResult.ValueForOption("--arch"); - string interopFileName = context.ParseResult.ValueForOption("--interopFileName"); string outputFileName = context.ParseResult.ValueForOption("--outputFileName"); string version = context.ParseResult.ValueForOption("--version"); var remappedNameValuePairs = context.ParseResult.ValueForOption("--memberRemap"); @@ -118,7 +116,7 @@ public static int Run(InvocationContext context) ClangSharpSourceCompilation clangSharpCompliation = ClangSharpSourceCompilation.Create( - sourceDirectory, arch, interopFileName, remaps, enumAdditions, enumMakeFlags, typeImports, requiredNamespaces, reducePointerLevels, refs, staticLibs); + sourceDirectory, arch, remaps, enumAdditions, enumMakeFlags, typeImports, requiredNamespaces, reducePointerLevels, refs, staticLibs); System.Diagnostics.Stopwatch errorsWatch = System.Diagnostics.Stopwatch.StartNew(); Console.WriteLine(" Looking for compilation errors..."); diff --git a/sources/ClangSharpSourceToWinmd/Properties/launchSettings.json b/sources/ClangSharpSourceToWinmd/Properties/launchSettings.json index 3e78f5d59..68f8251b1 100644 --- a/sources/ClangSharpSourceToWinmd/Properties/launchSettings.json +++ b/sources/ClangSharpSourceToWinmd/Properties/launchSettings.json @@ -2,15 +2,15 @@ "profiles": { "ClangSharpSourceToWinmd": { "commandName": "Project", - "commandLineArgs": "--sourceDir $(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated --arch crossarch --interopFileName $(ProjectDir)..\\..\\bin\\Windows.Win32.Interop.dll --version 1.0.0.0 --outputFileName $(ProjectDir)..\\..\\bin\\Windows.Win32.winmd --autoTypes $(ProjectDir)..\\..\\generation\\WinSDK\\autoTypes.json @$(ProjectDir)..\\..\\generation\\WinSDK\\emitter.settings.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\requiredNamespacesForNames.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated\\emitter.functionPointerFixups.generated.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated\\enumsMakeFlags.generated.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated\\enumsRemap.rsp" + "commandLineArgs": "--sourceDir $(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated --arch crossarch --version 1.0.0.0 --outputFileName $(ProjectDir)..\\..\\bin\\Windows.Win32.winmd --autoTypes $(ProjectDir)..\\..\\generation\\WinSDK\\autoTypes.json @$(ProjectDir)..\\..\\generation\\WinSDK\\emitter.settings.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\requiredNamespacesForNames.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated\\emitter.functionPointerFixups.generated.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated\\enumsMakeFlags.generated.rsp @$(ProjectDir)..\\..\\generation\\WinSDK\\obj\\generated\\enumsRemap.rsp" }, "TestSource": { "commandName": "Project", - "commandLineArgs": "--sourceDir $(ProjectDir)..\\..\\tests\\SourceToWinmd\\source --arch fake --interopFileName $(ProjectDir)..\\Win32MetadataInterop\\bin\\Debug\\netstandard2.1\\Windows.Win32.Interop.dll --outputFileName $(ProjectDir)..\\..\\bin\\Test.winmd --version 10.0.15000.3-preview @$(ProjectDir)..\\..\\tests\\SourceToWinmd\\generation\\remap.rsp" + "commandLineArgs": "--sourceDir $(ProjectDir)..\\..\\tests\\SourceToWinmd\\source --arch fake --outputFileName $(ProjectDir)..\\..\\bin\\Test.winmd --version 10.0.15000.3-preview @$(ProjectDir)..\\..\\tests\\SourceToWinmd\\generation\\remap.rsp" }, "Debug winmd builder": { "commandName": "Project", - "commandLineArgs": "--sourceDir D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\scraped --arch crossarch --interopFileName D:\\repos\\win32metadata\\bin\\Windows.Win32.Interop.dll --version 1.0.0.0 --outputFileName D:\\repos\\win32metadata\\bin\\Windows.Win32.winmd --autoTypes D:\\repos\\win32metadata\\generation\\autoTypes.json \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\emitter.remap.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\requiredNamespacesForNames.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\emitter.functionPointerFixups.generated.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\scraped\\enumsMakeFlags.generated.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\scraped\\enumsRemap.rsp\" " + "commandLineArgs": "--sourceDir D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\scraped --arch crossarch --version 1.0.0.0 --outputFileName D:\\repos\\win32metadata\\bin\\Windows.Win32.winmd --autoTypes D:\\repos\\win32metadata\\generation\\autoTypes.json \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\emitter.remap.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\requiredNamespacesForNames.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\emitter.functionPointerFixups.generated.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\scraped\\enumsMakeFlags.generated.rsp\" \"@D:\\repos\\win32metadata\\generation\\Windows.Win32\\obj\\scraped\\enumsRemap.rsp\" " } } } \ No newline at end of file diff --git a/sources/GeneratorSdk/MetadataTasks/EmitWinmd.cs b/sources/GeneratorSdk/MetadataTasks/EmitWinmd.cs index 1399f1897..7d04ccddc 100644 --- a/sources/GeneratorSdk/MetadataTasks/EmitWinmd.cs +++ b/sources/GeneratorSdk/MetadataTasks/EmitWinmd.cs @@ -61,7 +61,6 @@ protected override string GenerateCommandLineCommands() var builder = new CommandLineBuilder(); builder.AppendFileNameIfNotNull(Path.Combine(this.ToolsBinDir, "ClangSharpSourceToWinmd.dll")); - string interopPath = Path.Combine(this.Win32WinmdBinDir, "Windows.Win32.Interop.dll"); string win32WinmdPath = Path.Combine(this.Win32WinmdBinDir, "Windows.Win32.winmd"); this.outputWinmdFullPath = this.OutputWinmd; @@ -72,7 +71,6 @@ protected override string GenerateCommandLineCommands() builder.AppendSwitchIfNotNull("--sourceDir ", this.EmitterSourceDir); builder.AppendSwitchIfNotNull("--arch ", "crossarch"); - builder.AppendSwitchIfNotNull("--interopFileName ", interopPath); if (!StringComparer.OrdinalIgnoreCase.Equals( Path.GetFileName(this.outputWinmdFullPath), diff --git a/sources/GeneratorSdk/samples/DiaSdk/Dia.manual.cs b/sources/GeneratorSdk/samples/DiaSdk/Dia.manual.cs index 65dce33d4..983bffbdd 100644 --- a/sources/GeneratorSdk/samples/DiaSdk/Dia.manual.cs +++ b/sources/GeneratorSdk/samples/DiaSdk/Dia.manual.cs @@ -1,5 +1,5 @@ using Windows.Win32.Foundation; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Microsoft.Dia { diff --git a/sources/GeneratorSdk/samples/DiaSdk/Microsoft.Dia.Win32Metadata.nuspec b/sources/GeneratorSdk/samples/DiaSdk/Microsoft.Dia.Win32Metadata.nuspec index e9a1d01b1..34b88dfc5 100644 --- a/sources/GeneratorSdk/samples/DiaSdk/Microsoft.Dia.Win32Metadata.nuspec +++ b/sources/GeneratorSdk/samples/DiaSdk/Microsoft.Dia.Win32Metadata.nuspec @@ -17,7 +17,7 @@ images\windows.png - + diff --git a/sources/GeneratorSdk/tools/assets/scraper/ConstantsScraper.header.txt b/sources/GeneratorSdk/tools/assets/scraper/ConstantsScraper.header.txt index 55813e5f5..3f38a92e1 100644 --- a/sources/GeneratorSdk/tools/assets/scraper/ConstantsScraper.header.txt +++ b/sources/GeneratorSdk/tools/assets/scraper/ConstantsScraper.header.txt @@ -1,2 +1,2 @@ using System; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; diff --git a/sources/GeneratorSdk/tools/assets/scraper/scraper.header.txt b/sources/GeneratorSdk/tools/assets/scraper/scraper.header.txt index 4b1b6f47a..dca2e81b8 100644 --- a/sources/GeneratorSdk/tools/assets/scraper/scraper.header.txt +++ b/sources/GeneratorSdk/tools/assets/scraper/scraper.header.txt @@ -1,2 +1,2 @@ -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; diff --git a/sources/MetadataUtils/Architecture.cs b/sources/MetadataUtils/Architecture.cs new file mode 100644 index 000000000..7ab7be09e --- /dev/null +++ b/sources/MetadataUtils/Architecture.cs @@ -0,0 +1,14 @@ +using System; + +namespace MetadataUtils +{ + [Flags] + public enum Architecture + { + None = 0, + X86 = 1, + X64 = 2, + Arm64 = 4, + All = Architecture.X64 | Architecture.X86 | Architecture.Arm64 + } +} \ No newline at end of file diff --git a/sources/MetadataUtils/EncodeHelpers.cs b/sources/MetadataUtils/EncodeHelpers.cs index f01210aad..d30874fef 100644 --- a/sources/MetadataUtils/EncodeHelpers.cs +++ b/sources/MetadataUtils/EncodeHelpers.cs @@ -207,23 +207,47 @@ public static void NamedArgumentType(this NamedArgumentTypeEncoder encoder, INam { var fieldMembers = attributeType.GetMembers(field); var fieldSymbol = fieldMembers.First() as IFieldSymbol; + var propertySymbol = fieldMembers.First() as IPropertySymbol; - if (fieldSymbol.Type.SpecialType == SpecialType.System_Object) + if (fieldSymbol != null) { - encoder.Object(); - } - else if (fieldSymbol.Type.SpecialType == SpecialType.System_Array) - { - // TODO array type encoder - encoder.SZArray(); - } - else if (fieldSymbol.Type.TypeKind == TypeKind.Enum) - { - encoder.ScalarType().Enum(fieldSymbol.Type.ToString()); + if (fieldSymbol.Type.SpecialType == SpecialType.System_Object) + { + encoder.Object(); + } + else if (fieldSymbol.Type.SpecialType == SpecialType.System_Array) + { + // TODO array type encoder + encoder.SZArray(); + } + else if (fieldSymbol.Type.TypeKind == TypeKind.Enum) + { + encoder.ScalarType().Enum(fieldSymbol.Type.ToString()); + } + else + { + encoder.ScalarType().CustomElementType(fieldSymbol); + } } - else + else if (propertySymbol != null) { - encoder.ScalarType().CustomElementType(fieldSymbol); + if (propertySymbol.Type.SpecialType == SpecialType.System_Object) + { + encoder.Object(); + } + else if (propertySymbol.Type.SpecialType == SpecialType.System_Array) + { + // TODO array type encoder + encoder.SZArray(); + } + else if (propertySymbol.Type.TypeKind == TypeKind.Enum) + { + encoder.ScalarType().Enum(propertySymbol.Type.ToString()); + } + else + { + encoder.ScalarType().CustomElementType(propertySymbol); + } } } @@ -278,6 +302,57 @@ public static void CustomElementType(this CustomAttributeElementTypeEncoder type } } + public static void CustomElementType(this CustomAttributeElementTypeEncoder typeEncoder, IPropertySymbol property) + { + switch (property.Type.SpecialType) + { + case SpecialType.System_Boolean: + typeEncoder.Boolean(); + break; + case SpecialType.System_Byte: + typeEncoder.Byte(); + break; + case SpecialType.System_Int16: + typeEncoder.Int16(); + break; + case SpecialType.System_Int32: + typeEncoder.Int32(); + break; + case SpecialType.System_Int64: + typeEncoder.Int64(); + break; + case SpecialType.System_UInt16: + typeEncoder.UInt16(); + break; + case SpecialType.System_UInt32: + typeEncoder.UInt32(); + break; + case SpecialType.System_UInt64: + typeEncoder.UInt64(); + break; + case SpecialType.System_Single: + typeEncoder.Single(); + break; + case SpecialType.System_Double: + typeEncoder.Double(); + break; + case SpecialType.System_Char: + typeEncoder.Char(); + break; + case SpecialType.System_String: + typeEncoder.String(); + break; + case SpecialType.System_Enum: + typeEncoder.Enum(property.Type.ToString()); + break; + case SpecialType.System_SByte: + typeEncoder.SByte(); + break; + default: + throw new NotImplementedException(); + } + } + public static void NamedArguments( this CustomAttributeNamedArgumentsEncoder argumentsEncoder, INamedTypeSymbol attributeType, @@ -325,7 +400,7 @@ public static AttributeListSyntax ConvertGuidToAttributeList(Guid guid) SyntaxFactory.AttributeList( SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Attribute( - SyntaxFactory.ParseName("Windows.Win32.Interop.Guid"), + SyntaxFactory.ParseName("Windows.Win32.Foundation.Metadata.Guid"), SyntaxFactory.ParseAttributeArgumentList(args)))); } } diff --git a/sources/MetadataUtils/RepoInfo.cs b/sources/MetadataUtils/RepoInfo.cs index d71a73f52..5548f830e 100644 --- a/sources/MetadataUtils/RepoInfo.cs +++ b/sources/MetadataUtils/RepoInfo.cs @@ -34,7 +34,7 @@ public void UpdateGeneratedSourceHeader() using (StreamWriter streamWriter = new StreamWriter(headerPath)) { streamWriter.WriteLine("// Copyright © Microsoft"); - streamWriter.WriteLine("using Windows.Win32.Interop"); + streamWriter.WriteLine("using Windows.Win32.Foundation.Metadata"); streamWriter.WriteLine(); foreach (var partInfo in this.GetPartitionInfos()) diff --git a/sources/Win32MetadataInterop/AgileAttribute.cs b/sources/Win32MetadataInterop/AgileAttribute.cs deleted file mode 100644 index 6ea5019bc..000000000 --- a/sources/Win32MetadataInterop/AgileAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Interface, AllowMultiple = false, Inherited = true)] - public sealed class AgileAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/AlsoUsableForAttribute.cs b/sources/Win32MetadataInterop/AlsoUsableForAttribute.cs deleted file mode 100644 index de33084ab..000000000 --- a/sources/Win32MetadataInterop/AlsoUsableForAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Windows.Win32.Interop -{ - public class AlsoUsableForAttribute : Attribute - { - public AlsoUsableForAttribute(string otherType) - { - - } - } -} diff --git a/sources/Win32MetadataInterop/CanReturnErrorsAsSuccessAttribute.cs b/sources/Win32MetadataInterop/CanReturnErrorsAsSuccessAttribute.cs deleted file mode 100644 index f4ab4ac01..000000000 --- a/sources/Win32MetadataInterop/CanReturnErrorsAsSuccessAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class CanReturnErrorsAsSuccessAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/CanReturnMultipleSuccessValuesAttribute.cs b/sources/Win32MetadataInterop/CanReturnMultipleSuccessValuesAttribute.cs deleted file mode 100644 index 4e3c15b82..000000000 --- a/sources/Win32MetadataInterop/CanReturnMultipleSuccessValuesAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class CanReturnMultipleSuccessValuesAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/ComOutPtrAttribute.cs b/sources/Win32MetadataInterop/ComOutPtrAttribute.cs deleted file mode 100644 index 7e501368b..000000000 --- a/sources/Win32MetadataInterop/ComOutPtrAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] - public sealed class ComOutPtrAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/ConstAttribute.cs b/sources/Win32MetadataInterop/ConstAttribute.cs deleted file mode 100644 index 67a764643..000000000 --- a/sources/Win32MetadataInterop/ConstAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class ConstAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/ConstantAttribute.cs b/sources/Win32MetadataInterop/ConstantAttribute.cs deleted file mode 100644 index e2334dd32..000000000 --- a/sources/Win32MetadataInterop/ConstantAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class ConstantAttribute : Attribute - { - public ConstantAttribute(String value) - { - this.Value = value; - } - - public string Value { get; } - } -} diff --git a/sources/Win32MetadataInterop/CppAttributeListAttribute.cs b/sources/Win32MetadataInterop/CppAttributeListAttribute.cs deleted file mode 100644 index 29865c1d5..000000000 --- a/sources/Win32MetadataInterop/CppAttributeListAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] - [System.Runtime.InteropServices.ComVisible(true)] - public sealed class CppAttributeList : Attribute - { - public CppAttributeList(String attributeList) - { - this.AttributeList = attributeList; - } - - public string AttributeList { get; } - } -} diff --git a/sources/Win32MetadataInterop/DoNotReleaseAttribute.cs b/sources/Win32MetadataInterop/DoNotReleaseAttribute.cs deleted file mode 100644 index 25c3efa0e..000000000 --- a/sources/Win32MetadataInterop/DoNotReleaseAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class DoNotReleaseAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/FreeWithAttribute.cs b/sources/Win32MetadataInterop/FreeWithAttribute.cs deleted file mode 100644 index e71181855..000000000 --- a/sources/Win32MetadataInterop/FreeWithAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] - [System.Runtime.InteropServices.ComVisible(true)] - public sealed class FreeWithAttribute : Attribute - { - public FreeWithAttribute(String name) - { - this.Name = name; - } - - public string Name { get; } - } -} diff --git a/sources/Win32MetadataInterop/GuidAttribute.cs b/sources/Win32MetadataInterop/GuidAttribute.cs deleted file mode 100644 index 2ea0c4db0..000000000 --- a/sources/Win32MetadataInterop/GuidAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Windows.Win32.Interop -{ - public class GuidAttribute : Attribute - { - public GuidAttribute(uint a, ushort b, ushort c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) - { - } - } -} diff --git a/sources/Win32MetadataInterop/InvalidHandleValueAttribute.cs b/sources/Win32MetadataInterop/InvalidHandleValueAttribute.cs deleted file mode 100644 index 0726c7276..000000000 --- a/sources/Win32MetadataInterop/InvalidHandleValueAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Struct, AllowMultiple = true, Inherited = true)] - public class InvalidHandleValueAttribute : Attribute - { - public InvalidHandleValueAttribute(long value) => this.Value = value; - public long Value { get; } - } -} diff --git a/sources/Win32MetadataInterop/MemorySizeAttribute.cs b/sources/Win32MetadataInterop/MemorySizeAttribute.cs deleted file mode 100644 index 9c6c22427..000000000 --- a/sources/Win32MetadataInterop/MemorySizeAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class MemorySizeAttribute : Attribute - { - public short BytesParamIndex; - public MemorySizeAttribute() - { - } - } -} diff --git a/sources/Win32MetadataInterop/NativeArrayInfoAttribute.cs b/sources/Win32MetadataInterop/NativeArrayInfoAttribute.cs deleted file mode 100644 index 47bff9696..000000000 --- a/sources/Win32MetadataInterop/NativeArrayInfoAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class NativeArrayInfoAttribute : Attribute - { - // - // Summary: - // Indicates the number of elements in the fixed-length array or the number of characters - // (not bytes) in a string to import. - public int CountConst; - // - // Summary: - // Indicates the zero-based parameter that contains the count of array elements, - // similar to size_is in COM. - public short CountParamIndex; - // - // Summary: - // Indicates the struct field name that contains the count of array elements. - public string CountFieldName; - - public NativeArrayInfoAttribute() - { - } - } -} diff --git a/sources/Win32MetadataInterop/NativeEncodingAttribute.cs b/sources/Win32MetadataInterop/NativeEncodingAttribute.cs deleted file mode 100644 index 27736142b..000000000 --- a/sources/Win32MetadataInterop/NativeEncodingAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Diagnostics; - -namespace Windows.Win32.Interop -{ - /// Defines the encoding of a string as it was defined in the native signature. - //[Conditional("DEBUG")] - [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] - [System.Runtime.InteropServices.ComVisible(true)] - public sealed class NativeEncodingAttribute : Attribute - { - /// Initializes a new instance of the class. - /// The encoding of a string as it was defined in the native signature. - public NativeEncodingAttribute(String name) - { - this.Name = name; - } - - /// Gets the encoding of a string as it was defined in the native signature. - public string Name { get; } - } -} diff --git a/sources/Win32MetadataInterop/NativeInheritanceAttribute.cs b/sources/Win32MetadataInterop/NativeInheritanceAttribute.cs deleted file mode 100644 index 963826f6e..000000000 --- a/sources/Win32MetadataInterop/NativeInheritanceAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Diagnostics; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = true)] - public sealed class NativeInheritanceAttribute : Attribute - { - public NativeInheritanceAttribute(string baseName) - { - this.BaseName = BaseName; - } - - public string BaseName { get; } - } -} diff --git a/sources/Win32MetadataInterop/NativeTypeNameAttribute.cs b/sources/Win32MetadataInterop/NativeTypeNameAttribute.cs deleted file mode 100644 index 9267f7aad..000000000 --- a/sources/Win32MetadataInterop/NativeTypeNameAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Diagnostics; - -namespace Windows.Win32.Interop -{ - /// Defines the type of a member as it was used in the native signature. - //[Conditional("DEBUG")] - [AttributeUsage(AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] - [System.Runtime.InteropServices.ComVisible(true)] - public sealed class NativeTypeNameAttribute : Attribute - { - /// Initializes a new instance of the class. - /// The name of the type that was used in the native signature. - public NativeTypeNameAttribute(String name) - { - this.Name = name; - } - - /// Gets the name of the type that was used in the native signature. - public string Name { get; } - } -} diff --git a/sources/Win32MetadataInterop/NativeTypedefAttribute.cs b/sources/Win32MetadataInterop/NativeTypedefAttribute.cs deleted file mode 100644 index 8050fb039..000000000 --- a/sources/Win32MetadataInterop/NativeTypedefAttribute.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - public class NativeTypedefAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/NotNullTerminatedAttribute.cs b/sources/Win32MetadataInterop/NotNullTerminatedAttribute.cs deleted file mode 100644 index 3aa9b7fbb..000000000 --- a/sources/Win32MetadataInterop/NotNullTerminatedAttribute.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - public class NotNullTerminatedAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/NullNullTerminatedAttribute.cs b/sources/Win32MetadataInterop/NullNullTerminatedAttribute.cs deleted file mode 100644 index 82ab8f20f..000000000 --- a/sources/Win32MetadataInterop/NullNullTerminatedAttribute.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - public class NullNullTerminatedAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/RAIIFreeAttribute.cs b/sources/Win32MetadataInterop/RAIIFreeAttribute.cs deleted file mode 100644 index 5a0d1c38c..000000000 --- a/sources/Win32MetadataInterop/RAIIFreeAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - public class RAIIFreeAttribute : Attribute - { - public RAIIFreeAttribute(string name) - { - this.Name = name; - } - - /// Gets the name of the type that was used in the native signature. - public string Name { get; } - } -} diff --git a/sources/Win32MetadataInterop/ReservedAttribute.cs b/sources/Win32MetadataInterop/ReservedAttribute.cs deleted file mode 100644 index e06722a8a..000000000 --- a/sources/Win32MetadataInterop/ReservedAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class ReservedAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/RetValAttribute.cs b/sources/Win32MetadataInterop/RetValAttribute.cs deleted file mode 100644 index bb0b20bea..000000000 --- a/sources/Win32MetadataInterop/RetValAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] - public sealed class RetValAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/ReturnsUnownedHandle.cs b/sources/Win32MetadataInterop/ReturnsUnownedHandle.cs deleted file mode 100644 index f46b8e044..000000000 --- a/sources/Win32MetadataInterop/ReturnsUnownedHandle.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class ReturnsUnownedHandle : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/ScopedEnumAttribute.cs b/sources/Win32MetadataInterop/ScopedEnumAttribute.cs deleted file mode 100644 index f46d95e8c..000000000 --- a/sources/Win32MetadataInterop/ScopedEnumAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows.Win32.Interop -{ - public class ScopedEnumAttribute : Attribute - { - } -} diff --git a/sources/Win32MetadataInterop/StaticLibraryAttribute.cs b/sources/Win32MetadataInterop/StaticLibraryAttribute.cs deleted file mode 100644 index 79a3dfada..000000000 --- a/sources/Win32MetadataInterop/StaticLibraryAttribute.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - /// - /// Indicates that the attributed method is defined in an unmanaged static library (LIB). - /// - [AttributeUsage(AttributeTargets.Method, Inherited = false)] - public class StaticLibraryAttribute : Attribute - { - /// - /// Initialize a new instance of with the name of the LIB - /// file that contains the definition of this method. - /// - /// - /// The name of the LIB file that contains the definition of this method. - /// - public StaticLibraryAttribute(string libName) - { - this.Value = libName; - } - - /// - /// Gets the name of a static library which may be substituted for the - /// DLL. - /// - /// - /// The name of the LIB file that contains the definition of this entry point. - /// - public string Value { get; } - } -} diff --git a/sources/Win32MetadataInterop/StructSizeFieldAttribute.cs b/sources/Win32MetadataInterop/StructSizeFieldAttribute.cs deleted file mode 100644 index a60e9afaf..000000000 --- a/sources/Win32MetadataInterop/StructSizeFieldAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Windows.Win32.Interop -{ - public class StructSizeFieldAttribute : Attribute - { - public StructSizeFieldAttribute(string field) - { - - } - } -} diff --git a/sources/Win32MetadataInterop/SupportedArchitectureAttribute.cs b/sources/Win32MetadataInterop/SupportedArchitectureAttribute.cs deleted file mode 100644 index fa3cd9c70..000000000 --- a/sources/Win32MetadataInterop/SupportedArchitectureAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Windows.Win32.Interop -{ - [Flags] - public enum Architecture - { - None = 0, - X86 = 1, - X64 = 2, - Arm64 = 4, - All = Architecture.X64 | Architecture.X86 | Architecture.Arm64 - } - - public class SupportedArchitectureAttribute : Attribute - { - public SupportedArchitectureAttribute(Architecture arch) - { - } - } -} diff --git a/sources/Win32MetadataInterop/SupportedOSPlatformAttribute.cs b/sources/Win32MetadataInterop/SupportedOSPlatformAttribute.cs deleted file mode 100644 index cea2a8596..000000000 --- a/sources/Win32MetadataInterop/SupportedOSPlatformAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Windows.Win32.Interop -{ - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = false)] - public class SupportedOSPlatformAttribute : Attribute - { - public SupportedOSPlatformAttribute(string platform) - { - } - } -} diff --git a/sources/Win32MetadataInterop/Win32MetadataInterop.csproj b/sources/Win32MetadataInterop/Win32MetadataInterop.csproj deleted file mode 100644 index 0d00fa646..000000000 --- a/sources/Win32MetadataInterop/Win32MetadataInterop.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - netstandard2.1 - Windows.Win32.Interop - Windows.Win32.Interop - true - 1701;1702;0649 - - diff --git a/sources/WinmdUtils/Program.cs b/sources/WinmdUtils/Program.cs index 757968527..20d0aec4f 100644 --- a/sources/WinmdUtils/Program.cs +++ b/sources/WinmdUtils/Program.cs @@ -15,7 +15,6 @@ using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.TypeSystem; using MetadataUtils; -using Windows.Win32.Interop; namespace WinmdUtilsProgram { @@ -724,7 +723,7 @@ public static int ShowEmptyDelegates(FileInfo winmd, string[] allowItem, IConsol private static string GetArchInfo(IEnumerable attributes) { - var archAttr = attributes.FirstOrDefault(a => a.AttributeType.FullName == "Windows.Win32.Interop.SupportedArchitectureAttribute"); + var archAttr = attributes.FirstOrDefault(a => a.AttributeType.Name == "SupportedArchitectureAttribute"); if (archAttr != null) { Architecture arch = (Architecture)archAttr.FixedArguments[0].Value; @@ -769,7 +768,7 @@ private static bool VerifyTypeHasRightArch( foreach (var archType in foundArchTypes) { var typeArchAttr = - archType.GetAttributes().Single(a => a.AttributeType.FullName == "Windows.Win32.Interop.SupportedArchitectureAttribute"); + archType.GetAttributes().Single(a => a.AttributeType.FullName == "Windows.Win32.Foundation.Metadata.SupportedArchitectureAttribute"); var typeArch = (Architecture)typeArchAttr.FixedArguments[0].Value; typeArches |= typeArch; @@ -821,7 +820,7 @@ public static int ShowBrokenArchTypes(FileInfo winmd, IConsole console) foreach (var type in winmd1.GetTopLevelTypeDefinitions() .Where(t => t.GetAttributes() - .Any(a => a.AttributeType.FullName == "Windows.Win32.Interop.SupportedArchitectureAttribute"))) + .Any(a => a.AttributeType.FullName == "Windows.Win32.Foundation.Metadata.SupportedArchitectureAttribute"))) { if (!namesToArchDefs.TryGetValue(type.FullName, out var list)) { @@ -834,7 +833,7 @@ public static int ShowBrokenArchTypes(FileInfo winmd, IConsole console) foreach (var type in namesToArchDefs.SelectMany(map => map.Value)) { - var archAttr = type.GetAttributes().Single(a => a.AttributeType.FullName == "Windows.Win32.Interop.SupportedArchitectureAttribute"); + var archAttr = type.GetAttributes().Single(a => a.AttributeType.FullName == "Windows.Win32.Foundation.Metadata.SupportedArchitectureAttribute"); Architecture arch = (Architecture)archAttr.FixedArguments[0].Value; if (!VerifyTypeHasRightArch(namesToArchDefs, type, type, arch, console)) @@ -847,9 +846,9 @@ public static int ShowBrokenArchTypes(FileInfo winmd, IConsole console) { foreach (var method in apisClass.Methods.Where( m => m.IsStatic && m.DeclaringType == apisClass && m.GetAttributes() - .Any(a => a.AttributeType.FullName == "Windows.Win32.Interop.SupportedArchitectureAttribute"))) + .Any(a => a.AttributeType.FullName == "Windows.Win32.Foundation.Metadata.SupportedArchitectureAttribute"))) { - var archAttr = method.GetAttributes().Single(a => a.AttributeType.FullName == "Windows.Win32.Interop.SupportedArchitectureAttribute"); + var archAttr = method.GetAttributes().Single(a => a.AttributeType.FullName == "Windows.Win32.Foundation.Metadata.SupportedArchitectureAttribute"); Architecture arch = (Architecture)archAttr.FixedArguments[0].Value; foreach (var param in method.Parameters) diff --git a/sources/WinmdUtils/WinmdUtils.csproj b/sources/WinmdUtils/WinmdUtils.csproj index 54f4b4206..9d661c530 100644 --- a/sources/WinmdUtils/WinmdUtils.csproj +++ b/sources/WinmdUtils/WinmdUtils.csproj @@ -12,7 +12,6 @@ - diff --git a/sources/nuget/Microsoft.Windows.SDK.Win32Metadata/Microsoft.Windows.SDK.Win32Metadata.nuspec b/sources/nuget/Microsoft.Windows.SDK.Win32Metadata/Microsoft.Windows.SDK.Win32Metadata.nuspec index 19fe5da69..4e4896b33 100644 --- a/sources/nuget/Microsoft.Windows.SDK.Win32Metadata/Microsoft.Windows.SDK.Win32Metadata.nuspec +++ b/sources/nuget/Microsoft.Windows.SDK.Win32Metadata/Microsoft.Windows.SDK.Win32Metadata.nuspec @@ -23,7 +23,6 @@ - diff --git a/tests/SourceToWinmd/source/generated/fake/test.cs b/tests/SourceToWinmd/source/generated/fake/test.cs index 81b29c26e..3e0fb4971 100644 --- a/tests/SourceToWinmd/source/generated/fake/test.cs +++ b/tests/SourceToWinmd/source/generated/fake/test.cs @@ -5,7 +5,7 @@ using Windows.Win32.Foundation; using Windows.Win32.System.Memory; -using Windows.Win32.Interop; +using Windows.Win32.Foundation.Metadata; namespace Windows.Win32.Test {