* Fix several issues caused by the partitions change

* Add script for detecting missing imports by comparing against a baseline winmd
This commit is contained in:
Steve Otteson 2021-01-12 15:11:15 -08:00
Родитель feeb054328
Коммит 2bdbd010e1
89 изменённых файлов: 939 добавлений и 141 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -9,6 +9,7 @@
*.user
*.userosscache
*.sln.docstates
*.modified.cs
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

4
.gitmodules поставляемый Normal file
Просмотреть файл

@ -0,0 +1,4 @@
[submodule "ext/sdk-api"]
path = ext/sdk-api
url = https://github.com/MicrosoftDocs/sdk-api
shallow = true

59
.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,59 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File",
"script": "${file}",
"args": [],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File in Temporary Console",
"script": "${file}",
"args": [],
"cwd": "${file}",
"createTemporaryIntegratedConsole": true
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File w/Args Prompt",
"script": "${file}",
"args": [ "${command:SpecifyScriptArgs}" ],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch DebugTest.ps1",
"script": "${workspaceRoot}/DebugTest.ps1",
"args": ["-Count 55 -DelayMilliseconds 250"],
"cwd": "${workspaceRoot}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Interactive Session",
"cwd": "${workspaceRoot}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Pester Tests",
"script": "Invoke-Pester",
"args": [],
"cwd": "${workspaceRoot}"
},
{
"type": "PowerShell",
"request": "attach",
"name": "PowerShell Attach to Host Process",
"processId": "${command:PickPSHostProcess}",
"runspaceId": 1
}
]
}

102
.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,102 @@
// A task runner that invokes Pester to run all Pester tests under the
// current workspace folder.
// NOTE: This Test task runner requires an updated version of Pester (>=4.0.3)
// in order for the problemMatcher to find failed test information (message, line, file).
// If you don't have that version, you can update Pester from the PowerShell Gallery
// with this command:
//
// PS C:\> Update-Module Pester
//
// If that gives an error like:
// "Module 'Pester' was not installed by using Install-Module, so it cannot be updated."
// then execute:
//
// PS C:\> Install-Module Pester -Scope CurrentUser -Force
//
// NOTE: The Clean, Build and Publish tasks require PSake. PSake can be installed
// from the PowerShell Gallery with this command:
//
// PS C:\> Install-Module PSake -Scope CurrentUser -Force
//
// Available variables which can be used inside of strings:
// ${workspaceFolder} the path of the workspace folder that contains the tasks.json file
// ${workspaceFolderBasename} the name of the workspace folder that contains the tasks.json file without any slashes (/)
// ${file} the current opened file
// ${relativeFile} the current opened file relative to the workspace folder containing the file
// ${fileBasename} the current opened file's basename
// ${fileBasenameNoExtension} the current opened file's basename without the extension
// ${fileDirname} the current opened file's dirname
// ${fileExtname} the current opened file's extension
// ${cwd} the task runner's current working directory on startup
// ${lineNumber} the current selected line number in the active file
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"args": [
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command"
]
}
}
},
"linux": {
"options": {
"shell": {
"executable": "/usr/bin/pwsh",
"args": [
"-NoProfile",
"-Command"
]
}
}
},
"osx": {
"options": {
"shell": {
"executable": "/usr/local/bin/pwsh",
"args": [
"-NoProfile",
"-Command"
]
}
}
},
"tasks": [
{
"label": "Clean",
"type": "shell",
"command": "Invoke-PSake build.ps1 -taskList Clean"
},
{
"label": "Build",
"type": "shell",
"command": "Invoke-PSake build.ps1 -taskList Build",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Test",
"type": "shell",
"command": "Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true}",
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": [
"$pester"
]
},
{
"label": "Publish",
"type": "shell",
"command": "Invoke-PSake build.ps1 -taskList Publish"
}
]
}

Просмотреть файл

@ -1,3 +1,3 @@
@echo OFF
powershell.exe -NoLogo -NoProfile -ExecutionPolicy ByPass -Command "& """%~dp0scripts\GenerateMetadataSource.ps1""" %*"
pwsh.exe -NoLogo -NoProfile -ExecutionPolicy ByPass -Command "& """%~dp0scripts\GenerateMetadataSource.ps1""" %*"
exit /B %ERRORLEVEL%

3
TestMetadataBin.cmd Normal file
Просмотреть файл

@ -0,0 +1,3 @@
@echo OFF
powershell.exe -NoLogo -NoProfile -ExecutionPolicy ByPass -Command "& """%~dp0scripts\CompareBinaryAgainstBaseline.ps1""" %*"
exit /B %ERRORLEVEL%

Просмотреть файл

@ -100,6 +100,12 @@ steps:
filePath: 'scripts\BuildMetadataBin.ps1'
arguments: '-assemblyVersion $(PrepOutput.NugetVersion) -metadataSourcePath $(WinMetadataSourceDir)'
- task: PowerShell@2
displayName: Test metadata binary against baseline
inputs:
filePath: 'scripts\CompareBinaryAgainstBaseline.ps1'
arguments: '-assemblyVersion $(PrepOutput.NugetVersion)'
- task: PowerShell@2
displayName: Build csWin32 projected binary
inputs:

Просмотреть файл

@ -5,6 +5,12 @@
#include <windows.h>
#include <sdkddkver.h>
#include <winternl.h>
#define _NTDEF_
#define SECURITY_WIN32
#include <ntsecapi.h>
#include <shlobj_core.h>
#include <cmnquery.h>
#include <dsclient.h>
@ -17,3 +23,4 @@
#include <dsgetdc.h>
#include <dsrole.h>
#include <dsparse.h>
#include <DsGetDC.h>

Просмотреть файл

@ -0,0 +1,32 @@
#define QCC_OS_GROUP_WINDOWS
#include "intrinfix.h"
#include <windows.h>
#include <stdint.h>
#include <MSAJTransport.h>
#include <alljoyn_c\AjAPI.h>
#include <alljoyn_c\AboutData.h>
#include <alljoyn_c\AboutObj.h>
#include <alljoyn_c\AboutObjectDescription.h>
#include <alljoyn_c\AboutProxy.h>
#include <alljoyn_c\ApplicationStateListener.h>
#include <alljoyn_c\AuthListener.h>
#include <alljoyn_c\AutoPinger.h>
#include <alljoyn_c\BusAttachment.h>
#include <alljoyn_c\BusListener.h>
#include <alljoyn_c\BusObject.h>
#include <alljoyn_c\version.h>
#include <alljoyn_c\Init.h>
#include <alljoyn_c\InterfaceDescription.h>
#include <alljoyn_c\KeyStoreListener.h>
#include <alljoyn_c\Message.h>
#include <alljoyn_c\MsgArg.h>
#include <alljoyn_c\Observer.h>
#include <alljoyn_c\PermissionConfigurationListener.h>
#include <alljoyn_c\PermissionConfigurator.h>
#include <alljoyn_c\AutoPinger.h>
#include <alljoyn_c\ProxyBusObject.h>
#include <alljoyn_c\SecurityApplicationProxy.h>
#include <alljoyn_c\SessionListener.h>
#include <alljoyn_c\Session.h>

Просмотреть файл

@ -0,0 +1,43 @@
--file
<RepoRoot>\generation\Partitions\<PartitionName>\main.cpp
--output
<RepoRoot>\sources\Win32MetadataSource\generated\<PartitionName>.cs
--include-directory
<RepoRoot>/generation
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--traverse
<IncludeRoot>/um/alljoyn_c/AjAPI.h
<IncludeRoot>/um/alljoyn_c/Status.h
<IncludeRoot>/um/alljoyn_c/MsgArg.h
<IncludeRoot>/um/alljoyn_c/AboutData.h
<IncludeRoot>/um/alljoyn_c/AboutDataListener.h
<IncludeRoot>/um/alljoyn_c/PermissionConfigurator.h
<IncludeRoot>/um/alljoyn_c/ApplicationStateListener.h
<IncludeRoot>/um/alljoyn_c/KeyStoreListener.h
<IncludeRoot>/um/alljoyn_c/TransportMask.h
<IncludeRoot>/um/alljoyn_c/Session.h
<IncludeRoot>/um/alljoyn_c/Message.h
<IncludeRoot>/um/alljoyn_c/AuthListener.h
<IncludeRoot>/um/alljoyn_c/BusListener.h
<IncludeRoot>/um/alljoyn_c/InterfaceDescription.h
<IncludeRoot>/um/alljoyn_c/MessageReceiver.h
<IncludeRoot>/um/alljoyn_c/BusObject.h
<IncludeRoot>/um/alljoyn_c/ProxyBusObject.h
<IncludeRoot>/um/alljoyn_c/PermissionConfigurationListener.h
<IncludeRoot>/um/alljoyn_c/SessionListener.h
<IncludeRoot>/um/alljoyn_c/SessionPortListener.h
<IncludeRoot>/um/alljoyn_c/AboutListener.h
<IncludeRoot>/um/alljoyn_c/BusAttachment.h
<IncludeRoot>/um/alljoyn_c/AboutObj.h
<IncludeRoot>/um/alljoyn_c/AboutObjectDescription.h
<IncludeRoot>/um/alljoyn_c/AboutProxy.h
<IncludeRoot>/um/alljoyn_c/AutoPinger.h
<IncludeRoot>/um/alljoyn_c/version.h
<IncludeRoot>/um/alljoyn_c/Init.h
<IncludeRoot>/um/alljoyn_c/Observer.h
<IncludeRoot>/um/alljoyn_c/SecurityApplicationProxy.h
<IncludeRoot>/um/MSAJTransport.h
--namespace
Windows.Win32.AllJoyn

Просмотреть файл

@ -13,5 +13,5 @@
#include <propsys.h>
#include <dmusics.h>
#include <audiomediatype.h>
#include <baseaudioprocessingobject.h>
//#include <baseaudioprocessingobject.h> contains only C++ class implementation
#include <msapofxproxy.h>

Просмотреть файл

@ -17,6 +17,5 @@
<IncludeRoot>/um/audioenginebaseapo.h
<IncludeRoot>/um/dmusics.h
<IncludeRoot>/um/audiomediatype.h
<IncludeRoot>/um/baseaudioprocessingobject.h
--namespace
Windows.Win32.Audio

Просмотреть файл

@ -7,6 +7,11 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_LIST_ENTRY
_PROCESSOR_NUMBER
_GROUP_AFFINITY
_ARM64EC_NT_CONTEXT
--traverse
<IncludeRoot>/um/synchapi.h
<IncludeRoot>/um/avrt.h

Просмотреть файл

@ -85,8 +85,6 @@
#include <threadpoollegacyapiset.h>
#include <handleapi.h>
#include <windowsceip.h>
#include <sspi.h> // For secext.h
#include <secext.h>
#include <versionhelpers.h>
#include <realtimeapiset.h>
#include <timezoneapi.h>

Просмотреть файл

@ -7,6 +7,19 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_LIST_ENTRY
_D3DCOLORVALUE
IDirectDraw
IDirectDrawSurface
IDirectDrawPalette
_DDVIDEOPORTCONNECT
_D3DMATRIX
CVssWriter
CreateWriter
CVssWriterEx
CreateWriterEx
CVssWriterEx2
--traverse
<IncludeRoot>/shared/devpkey.h
<IncludeRoot>/um/codecapi.h

Просмотреть файл

@ -7,6 +7,8 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_GUID
--traverse
<IncludeRoot>/um/cguid.h
<IncludeRoot>/um/OleCtl.h

Просмотреть файл

@ -7,6 +7,8 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_DDPIXELFORMAT
--traverse
<IncludeRoot>/um/audiosessiontypes.h
<IncludeRoot>/um/AudioAPOTypes.h

Просмотреть файл

@ -6,6 +6,8 @@
#include <windows.h>
#include <sdkddkver.h>
#include <wct.h>
#include <minidumpapiset.h>
#include <activdbg.h>
#include <activprof.h>
#include <webapplication.h>

Просмотреть файл

@ -7,6 +7,9 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
IWICBitmapSource
IWICBitmap
--traverse
<IncludeRoot>/um/d2d1_2helper.h
<IncludeRoot>/um/d2d1_3helper.h

Просмотреть файл

@ -6,6 +6,8 @@
#include <windows.h>
#include <sdkddkver.h>
#define D3D10_NO_HELPERS
#include <d3d10_1.h>
#include <d3d10.h>
#include <d3d10sdklayers.h>

Просмотреть файл

@ -6,6 +6,8 @@
#include <windows.h>
#include <sdkddkver.h>
#define D3D11_NO_HELPERS
#include <d3d11.h>
#include <d3d11_1.h>
#include <d3d11_2.h>

Просмотреть файл

@ -7,6 +7,10 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_D3DCOLORVALUE
--with-type
D3DFORMAT=uint
--traverse
<IncludeRoot>/shared/d3d9types.h
<IncludeRoot>/shared/d3d9caps.h

Просмотреть файл

@ -7,6 +7,8 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
DXGI_ADAPTER_FLAG_FORCE_DWORD
--traverse
<IncludeRoot>/shared/dxgitype.h
<IncludeRoot>/shared/dxgiformat.h

Просмотреть файл

@ -7,6 +7,9 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_D3DCOLORVALUE
DWRITE_FONT_AXIS_TAG
--traverse
<IncludeRoot>/um/dwrite.h
<IncludeRoot>/um/dwrite_1.h

Просмотреть файл

@ -11,3 +11,5 @@
#include <dinputd.h>
#include <ntddkbd.h>
#include <ntddmou.h>
#include <hidsdi.h>
#include <hidpi.h>

Просмотреть файл

@ -12,5 +12,7 @@
<IncludeRoot>/shared/ntddkbd.h
<IncludeRoot>/um/dinput.h
<IncludeRoot>/shared/dinputd.h
<IncludeRoot>/shared/hidpi.h
<IncludeRoot>/shared/hidsdi.h
--namespace
Windows.Win32.Hid

Просмотреть файл

@ -8,3 +8,4 @@
#include <WinSock2.h>
#include <http.h>
#include <winhttp.h>

Просмотреть файл

@ -9,5 +9,6 @@
<IncludeRoot>/winrt
--traverse
<IncludeRoot>/um/http.h
<IncludeRoot>/um/winhttp.h
--namespace
Windows.Win32.Http

Просмотреть файл

@ -7,3 +7,4 @@
#include <sdkddkver.h>
#include <fltuser.h>
//#include <ntifs.h>

Просмотреть файл

@ -25,3 +25,4 @@
#include <usp10.h>
#include <muiload.h>
#include <gb18030.h>
#include <icu.h>

Просмотреть файл

@ -22,5 +22,6 @@
<IncludeRoot>/um/usp10.h
<IncludeRoot>/um/muiload.h
<IncludeRoot>/um/gb18030.h
<IncludeRoot>/um/icu.h
--namespace
Windows.Win32.Intl

Просмотреть файл

@ -7,6 +7,9 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--with-type
XHR_CERT_IGNORE_FLAG=uint
XHR_CERT_ERROR_FLAG=uint
--traverse
<IncludeRoot>/um/MsXml6.h
--namespace

Просмотреть файл

@ -12,5 +12,6 @@
<IncludeRoot>/um/jsrt9.h
--exclude
JsRuntimeVersion
JS_SOURCE_CONTEXT_NONE
--namespace
Windows.Win32.Js

Просмотреть файл

@ -7,6 +7,12 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_LARGE_INTEGER
_ULARGE_INTEGER
_LUID
COMPARTMENT_ID
_OBJECT_ATTRIBUTES
--traverse
<IncludeRoot>/shared/ntdef.h
--namespace

Просмотреть файл

@ -7,3 +7,4 @@
#include <sdkddkver.h>
#include <winml.h>
#include <MLOperatorAuthor.h>

Просмотреть файл

@ -7,7 +7,10 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
MLOperatorEdgeTypeConstrant
--traverse
<IncludeRoot>/um/winml.h
<IncludeRoot>/um/MLOperatorAuthor.h
--namespace
Windows.Win32.MachineLearning

Просмотреть файл

@ -8,7 +8,7 @@
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
MF_Plugin_Type
_MF_Plugin_Type
--traverse
<IncludeRoot>/um/mfspatialaudio.h
<IncludeRoot>/um/dxva9typ.h

Просмотреть файл

@ -7,6 +7,8 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--with-type
CLUSTER_PROPERTY_SYNTAX=uint
--traverse
<IncludeRoot>/um/msclus.h
<IncludeRoot>/um/ClusApi.h

Просмотреть файл

@ -7,6 +7,9 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--remap
_TuningSpacesForCLSID=_TuningSpacesForCLSID2
_SetAllocator=_SetAllocator2
--traverse
<IncludeRoot>/um/mpeg2bits.h
<IncludeRoot>/shared/bdamedia.h

Просмотреть файл

@ -7,6 +7,9 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_SOCKET_ADDRESS_LIST
SOCKET_ADDRESS_LIST
--traverse
<IncludeRoot>/um/ndattrib.h
<IncludeRoot>/um/ndhelper.h

Просмотреть файл

@ -7,6 +7,8 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--with-type
ATTRIBUTEID=uint
--traverse
<IncludeRoot>/um/authif.h
<IncludeRoot>/um/sdoias.h

Просмотреть файл

@ -11,4 +11,4 @@
<IncludeRoot>/um/propsys.h
<IncludeRoot>/um/propvarutil.h
--namespace
Windows.Win32.roperties
Windows.Win32.Properties

Просмотреть файл

@ -11,11 +11,11 @@
#include <rpcdce.h>
#include <winerror.h>
//#include <unknwnbase.h>
//#include <rpcndr.h>
#include <rpcndr.h>
#include <rpcasync.h>
#include <rpcdcep.h>
#include <rpcnsi.h>
//#include <midles.h>
#include <midles.h>
#include <rpc.h>
#include <rpcssl.h>
//#include <rpcproxy.h> Leaving out on purpose. Requires C-only interfaces and we don't think we need proxy metadata

Просмотреть файл

@ -7,6 +7,8 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
NDR_SCONTEXT
--traverse
<IncludeRoot>/shared/rpcdce.h
<IncludeRoot>/shared/rpcasync.h
@ -15,5 +17,6 @@
<IncludeRoot>/um/Midles.h
<IncludeRoot>/shared/rpc.h
<IncludeRoot>/um/rpcssl.h
<IncludeRoot>/shared/rpcndr.h
--namespace
Windows.Win32.Rpc

Просмотреть файл

@ -12,6 +12,7 @@
#define SECURITY_WIN32
#include <NTSecAPI.h>
#include <sspi.h>
#include <wincred.h>
#include <NTSecPKG.h>
#include <schannel.h>
@ -90,3 +91,4 @@ typedef struct _OLD_LARGE_INTEGER {
#include <slpublic.h>
#include <diagnosticdataquery.h>
#include <diagnosticdataquerytypes.h>
#include <security.h>

Просмотреть файл

@ -7,6 +7,9 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--with-type
_tagSLDATATYPE=uint
SLDATATYPE=uint
--traverse
<IncludeRoot>/um/diagnosticdataquerytypes.h
<IncludeRoot>/um/celib.h
@ -72,5 +75,7 @@
<IncludeRoot>/um/winsafer.h
<IncludeRoot>/um/slpublic.h
<IncludeRoot>/um/DiagnosticDataQuery.h
<IncludeRoot>/shared/security.h
<IncludeRoot>/shared/secext.h
--namespace
Windows.Win32.Security

Просмотреть файл

@ -7,6 +7,8 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--remap
_NavigateToPidl=_NavigateToPidl2
--traverse
<IncludeRoot>/um/cpl.h
<IncludeRoot>/um/hlink.h

Просмотреть файл

@ -16,3 +16,4 @@
#include <propidlbase.h>
#include <coml2api.h>
#include <propapi.h>
#include <esent.h>

Просмотреть файл

@ -13,5 +13,6 @@
<IncludeRoot>/um/PropIdlBase.h
<IncludeRoot>/um/coml2api.h
<IncludeRoot>/um/propapi.h
<IncludeRoot>/um/esent.h
--namespace
Windows.Win32.Stg

Просмотреть файл

@ -8,3 +8,4 @@
#include <wingdi.h>
#include <wcsplugin.h>
#include <Icm.h>

Просмотреть файл

@ -9,5 +9,6 @@
<IncludeRoot>/winrt
--traverse
<IncludeRoot>/um/wcsplugin.h
<IncludeRoot>/um/icm.h
--namespace
Windows.Win32.Wcs

Просмотреть файл

@ -65,5 +65,10 @@
#include <appcompatapi.h>
#include <dsound.h>
#include <wldp.h>
#include <windowsceip.h>
#include <xmllite.h>
#include <devquery.h>
#include <fltdefs.h>
#include <statehelpers.h>
//#include <basetsd.h>

Просмотреть файл

@ -7,6 +7,9 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_UNICODE_STRING
_STRING
--traverse
<IncludeRoot>/um/wldp.h
<IncludeRoot>/shared/tdiinfo.h
@ -17,7 +20,6 @@
<IncludeRoot>/shared/dciddi.h
<IncludeRoot>/um/realtimeapiset.h
<IncludeRoot>/um/timeprov.h
<IncludeRoot>/shared/secext.h
<IncludeRoot>/um/windowsceip.h
<IncludeRoot>/um/profileapi.h
<IncludeRoot>/um/WinBase.h
@ -60,5 +62,11 @@
<IncludeRoot>/um/waasapi.h
<IncludeRoot>/um/dmemmgr.h
<IncludeRoot>/um/ddkernel.h
<IncludeRoot>/um/xmllite.h
<IncludeRoot>/um/devquery.h
<IncludeRoot>/um/devquerydef.h
<IncludeRoot>/um/fltdefs.h
<IncludeRoot>/um/devfiltertypes.h
<IncludeRoot>/um/statehelpers.h
--namespace
Windows.Win32.WinProg

Просмотреть файл

@ -35,6 +35,19 @@
#include <windows.ui.xaml.interop.h>
//#include <Windows.Web.UI.Interop.h> The interfaces make use of templates which ClangSharp can't yet correctly emit
#include <hstring.h>
#include <winstring.h>
#include <restrictederrorinfo.h>
#include <roapi.h>
#include <robuffer.h>
#include <roerrorapi.h>
#include <rometadata.h>
//#include <rometadataapi.h>
//#include <rometadataresolution.h>
#include <roparameterizediid.h>
#include <roregistrationapi.h>
#include <shcore.h>
/*
#include <winnt.h>
#include <winstring.h>

Просмотреть файл

@ -7,6 +7,12 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
PFNGETACTIVATIONFACTORY
RO_REGISTRATION_COOKIE
RoGetActivatableClassRegistration
Windows::Foundation::Diagnostics::RoErrorReportingFlags
ABI::Windows::Foundation::Diagnostics::RoErrorReportingFlags
--traverse
<RepoRoot>\generation\Partitions\<PartitionName>\main.cpp
<IncludeRoot>/um/accountssettingspaneinterop.h
@ -35,5 +41,17 @@
<IncludeRoot>/winrt/windows.ui.xaml.interop.h
<IncludeRoot>/winrt/Windows.Web.UI.Interop.h
<IncludeRoot>/winrt/inspectable.h
<IncludeRoot>/winrt/roapi.h
<IncludeRoot>/winrt/robuffer.h
<IncludeRoot>/winrt/roerrorapi.h
<IncludeRoot>/winrt/rometadata.h
<IncludeRoot>/winrt/RoMetadataApi.h
<IncludeRoot>/winrt/rometadataresolution.h
<IncludeRoot>/winrt/roparameterizediid.h
<IncludeRoot>/winrt/roregistrationapi.h
<IncludeRoot>/winrt/shcore.h
<IncludeRoot>/winrt/winstring.h
<IncludeRoot>/winrt/hstring.h
<IncludeRoot>/um/restrictederrorinfo.h
--namespace
Windows.Win32.WinRt
Windows.Win32.WinRT

Просмотреть файл

@ -8,6 +8,8 @@
#include <scclient.h>
#include <mswmdm.h>
#include <scserver.h>
// #include <scserver.h> Only contains C++ implementation code
#include <wmdmlog.h>
#include <mtpext.h>
// Purposely not traversing scclient.h in settings.rsp. Only contains C++ implementation code

Просмотреть файл

@ -10,9 +10,7 @@
--traverse
<IncludeRoot>/um/mtpext.h
<IncludeRoot>/um/sac.h
<IncludeRoot>/um/scclient.h
<IncludeRoot>/um/mswmdm.h
<IncludeRoot>/um/scserver.h
<IncludeRoot>/um/wmdmlog.h
--namespace
Windows.Win32.Wmdm

Просмотреть файл

@ -8,3 +8,4 @@
#include <webservices.h>
#include <icontentprefetchertasktrigger.h>
#include <webauthn.h>

Просмотреть файл

@ -7,8 +7,11 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
_SecPkgContext_IssuerListInfoEx
--traverse
<IncludeRoot>/um/WebServices.h
<IncludeRoot>/um/IContentPrefetcherTaskTrigger.h
<IncludeRoot>/um/webauthn.h
--namespace
Windows.Win32.Wsw

Просмотреть файл

@ -6,7 +6,8 @@
#include <windows.h>
#include <sdkddkver.h>
#include <xapobase.h>
#include <xapo.h>
//#include <xapobase.h> Class implementations we don't want emitted
#include <xapofx.h>
#include <xaudio2.h>
#include <xaudio2fx.h>

Просмотреть файл

@ -7,9 +7,10 @@
<IncludeRoot>/shared
<IncludeRoot>/um
<IncludeRoot>/winrt
--exclude
CXAPOBase
--traverse
<IncludeRoot>/shared/basetyps.h
<IncludeRoot>/um/xapobase.h
<IncludeRoot>/um/xapofx.h
<IncludeRoot>/um/xaudio2.h
<IncludeRoot>/um/xaudio2fx.h

Просмотреть файл

@ -1052,7 +1052,7 @@ _D3D12_SHADER_TYPE_DESC=D3D12_SHADER_TYPE_DESC
_D3D12_SHADER_VARIABLE_DESC=D3D12_SHADER_VARIABLE_DESC
_D3D12_SIGNATURE_PARAMETER_DESC=D3D12_SIGNATURE_PARAMETER_DESC
_D3DCOLORVALUE=DXGI_RGBA
_D3DMATRIX=D2D_MATRIX_4X4_F
_D3DMATRIX=D3DMATRIX
_D3D_CBUFFER_TYPE=D3D_CBUFFER_TYPE
_D3D_INCLUDE_TYPE=D3D_INCLUDE_TYPE
_D3D_PARAMETER_FLAGS=D3D_PARAMETER_FLAGS
@ -9420,3 +9420,7 @@ _SMB_COMPRESSION_INFO=SMB_COMPRESSION_INFO
_SMB_USE_OPTION_COMPRESSION_PARAMETERS=SMB_USE_OPTION_COMPRESSION_PARAMETERS
_TIMESTAMPING_CONFIG=TIMESTAMPING_CONFIG
_PRIORITY_STATUS=PRIORITY_STATUS
NDR_CCONTEXT=IntPtr
NDR_SCONTEXT=NDR_SCONTEXT_1*
RO_REGISTRATION_COOKIE=IntPtr
_WINHTTP_MATCH_CONNECTION_GUID=WINHTTP_MATCH_CONNECTION_GUID

Просмотреть файл

@ -23,6 +23,7 @@ log-potential-typedef-remappings
exclude-funcs-with-body
generate-cpp-attributes
generate-native-inheritance-attribute
dont-use-using-statics-for-enums
--headerFile
generation\header.txt
--methodClassName

Просмотреть файл

@ -3,6 +3,7 @@ using Windows.Win32.Interop
using Windows.Win32.Ad
using Windows.Win32.Adsi
using Windows.Win32.AllJoyn
using Windows.Win32.Amsi
using Windows.Win32.AppxPkg
using Windows.Win32.Audio
@ -108,7 +109,7 @@ using Windows.Win32.Pla
using Windows.Win32.Policy
using Windows.Win32.ProcSnap
using Windows.Win32.ProjFs
using Windows.Win32.roperties
using Windows.Win32.Properties
using Windows.Win32.PsApi
using Windows.Win32.Qos
using Windows.Win32.Rdc
@ -164,7 +165,7 @@ using Windows.Win32.WinInet
using Windows.Win32.WinLocation
using Windows.Win32.WinProg
using Windows.Win32.WinRm
using Windows.Win32.WinRt
using Windows.Win32.WinRT
using Windows.Win32.WinSat
using Windows.Win32.WinSensors
using Windows.Win32.WinSock
@ -187,3 +188,4 @@ using Windows.Win32.XAudio2
using Windows.Win32.Xblidp
using Windows.Win32.XInput
using Windows.Win32.Xps
using IServiceProvider = Windows.Win32.Base.IServiceProvider;

Двоичные данные
scripts/BaselineWinmd/10.0.19041.5/Windows.Win32.Interop.dll Normal file

Двоичный файл не отображается.

Двоичные данные
scripts/BaselineWinmd/10.0.19041.5/Windows.Win32.winmd Normal file

Двоичный файл не отображается.

Двоичные данные
scripts/BaselineWinmd/10.0.21287.1009/Windows.Win32.Interop.dll Normal file

Двоичный файл не отображается.

Двоичные данные
scripts/BaselineWinmd/10.0.21287.1009/Windows.Win32.winmd Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -31,7 +31,6 @@ $metadataInteropBin = "$metadataInteropPath\bin\Release\netstandard2.1\Windows.W
Copy-Item $metadataInteropBin $binDir
$outputWinmdFileName = "$binDir\Windows.Win32.winmd"
$remapFileName = "$metadataSourcePath\remap.rsp"
Write-Output "`n"

Просмотреть файл

@ -19,11 +19,39 @@ function Replace-Text
Set-Content -path $path -Encoding UTF8 -value $content
}
function Get-LibMappingsFile
{
param ([string]$artifactsDir, [string]$version)
$generationOutArtifactsDir = "$artifactsDir\output"
Create-Directory $generationOutArtifactsDir
$libMappingOutputFileName = Join-Path -Path $generationOutArtifactsDir -ChildPath "$version.libMappings.rsp"
return $libMappingOutputFileName
}
function Invoke-PrepLibMappingsFile
{
param ([string]$artifactsDir, [string]$version)
$libMappingOutputFileName = Get-LibMappingsFile $artifactsDir $version
Write-Output "Creating metadata source for $partitionName..."
if (!(Test-Path $libMappingOutputFileName))
{
Write-Output "Creating lib mapping file: $libMappingOutputFileName"
$libDirectory = "$nugetDestPackagesDir\Microsoft.Windows.SDK.CPP.x64.$version\c\um\x64"
& $PSScriptRoot\CreateProcLibMappingForAllLibs.ps1 -libDirectory $libDirectory -outputFileName $libMappingOutputFileName
}
}
$defaultWinSDKNugetVersion = "10.0.19041.5"
$rootDir = [System.IO.Path]::GetFullPath("$PSScriptRoot\..")
$toolsDir = "$rootDir\tools"
$binDir = "$rootDir\bin"
$outputWinmdFileName = "$binDir\Windows.Win32.winmd"
$sourcesDir = "$rootDir\sources"
$partitionsDir = "$rootDir\generation\Partitions"
$sdkApiPath = "$rootDir\ext\sdk-api"

Просмотреть файл

@ -0,0 +1,61 @@
param
(
[string]
$assemblyVersion,
[string]
$winmdPath
)
. "$PSScriptRoot\CommonUtils.ps1"
if (!$assemblyVersion)
{
$assemblyVersion = $defaultWinSDKNugetVersion
}
if (!$winmdPath)
{
$winmdPath = $outputWinmdFileName
}
function FindBestBaselineWinmd
{
param([int] $buildNumber)
$bestDir = ""
$versionNames = get-childitem $PSScriptRoot\BaselineWinmd
foreach ($versionDir in $versionNames)
{
$baselineVersion = [int]($versionDir.Name.Split(".")[2])
if ($baselineVersion -gt $buildNumber)
{
break
}
$bestDir = $versionDir.Name
}
return $bestDir
}
$buildNumber = [int]($assemblyVersion.Split(".")[2])
$baselineWinmdDir = FindBestBaselineWinmd $buildNumber
if ($baselineWinmdDir -eq "")
{
Write-Output "Failed to find a baseline winmd to compare against."
exit 0
}
$baselineWinmd = "$PSScriptRoot\BaselineWinmd\$baselineWinmdDir\Windows.Win32.winmd"
$winmdUtilsPath = "$sourcesDir\WinmdUtils"
$winmdUtilsPathProj = "$winmdUtilsPath\WinmdUtils.csproj"
$winmdUtilsPathBin = "$winmdUtilsPath\bin\Release\netcoreapp3.1\WinmdUtils.dll"
& dotnet build $winmdUtilsPathProj -c Release
Write-Output "`n"
Write-Output "Comparing $outputWinmdFileName against baseline $baselineWinmd..."
Write-Output "Calling: dotnet $winmdUtilsPathBin showMissingImports --first $baselineWinmd --second $outputWinmdFileName"
& dotnet $winmdUtilsPathBin showMissingImports --first $baselineWinmd --second $outputWinmdFileName

Просмотреть файл

@ -144,14 +144,29 @@ Create-Directory $nugetDestPackagesDir
Create-Directory $sdkGeneratedSourceDir
Remove-Item "$sdkGeneratedSourceDir\*.cs"
Write-Output "`nProcessing each partition..."
Invoke-PrepLibMappingsFile $artifactsDir $version
$throttleCount = [System.Environment]::ProcessorCount / 2
if ($throttleCount -eq 0)
{
$throttleCount = 1
}
$partitionNames = Get-ChildItem $partitionsDir | Select-Object -ExpandProperty Name
foreach ($partitionName in $partitionNames)
{
Write-Output "`nCalling $PSScriptRoot\GenerateMetadataSourceForPartition.ps1 -version $version -partitionName $partitionName -artifactsDir $artifactsDir..."
& $PSScriptRoot\GenerateMetadataSourceForPartition.ps1 -version $version -partitionName $partitionName -artifactsDir $artifactsDir
}
$stopwatch = [system.diagnostics.stopwatch]::StartNew()
Write-Output "`nProcessing each partition...using $throttleCount parralel script(s)"
$partitionNames | ForEach-Object -Parallel {
$out1 = "`n$using:PSScriptRoot\GenerateMetadataSourceForPartition.ps1 -version $using:version -partitionName $_ -artifactsDir $using:artifactsDir..."
$out2 = & $using:PSScriptRoot\GenerateMetadataSourceForPartition.ps1 -version $using:version -partitionName $_ -artifactsDir $using:artifactsDir -indent "`n "
Write-Output "$out1$out2"
} -ThrottleLimit $throttleCount
$stopwatch.Stop()
$totalTime = $stopwatch.Elapsed.ToString("c")
Write-Output "Total time taken for all partitions: $totalTime"
exit 0

Просмотреть файл

@ -8,7 +8,10 @@ param
$version,
[string]
$partitionName
$partitionName,
[string]
$indent = ""
)
. "$PSScriptRoot\CommonUtils.ps1"
@ -18,27 +21,12 @@ if (!$version)
$version = $defaultWinSDKNugetVersion
}
$generationOutArtifactsDir = "$artifactsDir\output"
Create-Directory $generationOutArtifactsDir
$nugetDestPackagesDir = Join-Path -Path $artifactsDir "InstalledPackages"
$libMappingOutputFileName = Join-Path -Path $generationOutArtifactsDir -ChildPath "$version.libMappings.rsp"
$libMappingOutputFileName = Get-LibMappingsFile $artifactsDir $version
$stopwatch = [system.diagnostics.stopwatch]::StartNew()
Write-Output "Creating metadata source for $partitionName..."
if (!(Test-Path $libMappingOutputFileName))
{
Write-Output "Creating lib mapping file: $libMappingOutputFileName"
$libDirectory = "$nugetDestPackagesDir\Microsoft.Windows.SDK.CPP.x64.$version\c\um\x64"
& $PSScriptRoot\CreateProcLibMappingForAllLibs.ps1 -libDirectory $libDirectory -outputFileName $libMappingOutputFileName
}
else
{
Write-Output "Skipping creating of lib mappings as $libMappingOutputFileName already exists."
}
$baseGenerateDir = "$rootDir\generation"
$partitionGenerateDir = "$rootDir\generation\Partitions\$partitionName"
if (!(Test-Path $partitionGenerateDir))
@ -47,6 +35,8 @@ if (!(Test-Path $partitionGenerateDir))
exit -1
}
$generationOutArtifactsDir = "$artifactsDir\output"
$generatorOutput = Join-Path -Path $generationOutArtifactsDir -ChildPath "$partitionName.generation.output.txt"
$withSetLastErrorRsp = "$baseGenerateDir\WithSetLastError.rsp"
@ -60,7 +50,6 @@ if (!(Test-Path $partitionSettingsRsp))
}
$baseRemapRsp = "$baseGenerateDir\baseRemap.rsp"
#$partitionRemapRsp = "$partitionGenerateDir\remap.rsp"
$fixedSettingsRsp = "$generationOutArtifactsDir\$partitionName.fixedSettings.rsp"
@ -70,13 +59,13 @@ $includePath = (Get-ChildItem -Path "$nugetDestPackagesDir\Microsoft.Windows.SDK
[hashtable]$textToReplaceTable = @{ "<IncludeRoot>" = $includePath; "<RepoRoot>" = $rootDir; "<PartitionName>" = $partitionName }
Replace-Text $fixedSettingsRsp $textToReplaceTable
Write-Output "Creating metadata .cs file. Log output: $generatorOutput"
Write-Output "Calling: $toolsDir\ClangSharpPInvokeGenerator.exe "@$baseSettingsRsp" "@$withSetLastErrorRsp" "@$fixedSettingsRsp" "@$baseRemapRsp" "@$libMappingOutputFileName" > $generatorOutput"
Write-Output "$($indent)$partitionName..."
Write-Output "$($indent)$toolsDir\ClangSharpPInvokeGenerator.exe @$baseSettingsRsp @$withSetLastErrorRsp @$fixedSettingsRsp @$baseRemapRsp @$libMappingOutputFileName > $generatorOutput"
& $toolsDir\ClangSharpPInvokeGenerator.exe "@$baseSettingsRsp" "@$withSetLastErrorRsp" "@$fixedSettingsRsp" "@$baseRemapRsp" "@$libMappingOutputFileName" > $generatorOutput
if ($LASTEXITCODE -lt 0)
{
Write-Error "ClangSharpPInvokeGenerator.exe failed:"
Write-Error "$($indent)ClangSharpPInvokeGenerator.exe failed:"
Get-ChildItem $generatorOutput | select-string "Error: "
}
@ -87,9 +76,9 @@ $from = Get-Content -Path $possibleRemapsOutput
if (![string]::IsNullOrEmpty($from))
{
Add-Content -Path $baseRemapRsp -Value $from
Write-Output "Added remaps to $baseRemapRsp"
Write-Output "$($indent)Added remaps to $baseRemapRsp"
}
$stopwatch.Stop()
$totalTime = $stopwatch.Elapsed.ToString("c")
Write-Output "Took $totalTime"
Write-Output "$($indent)Took $totalTime"

Просмотреть файл

@ -1408,6 +1408,7 @@ namespace ClangSharpSourceToWinmd
var fieldAttributes = FieldAttributes.Public;
IFieldSymbol fieldSymbol = (IFieldSymbol)model.GetDeclaredSymbol(fieldVariable);
bool isConst = fieldSymbol.IsStatic && fieldSymbol.HasConstantValue;
if (isConst)
{
fieldAttributes |= FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault;

Просмотреть файл

@ -22,6 +22,8 @@ namespace ClangSharpSourceToWinmd
private HashSet<SyntaxNode> nodesWithMarshalAs = new HashSet<SyntaxNode>();
private Dictionary<string, string> remaps;
private HashSet<string> visitedDelegateNames = new HashSet<string>();
private HashSet<string> visitedMethodNames = new HashSet<string>();
public TreeRewriter(Dictionary<string, string> remaps)
{
@ -59,45 +61,57 @@ namespace ClangSharpSourceToWinmd
return node;
}
return base.VisitParameter(node);
var ret = (ParameterSyntax)base.VisitParameter(node);
// Get rid of default parameter values
if (ret.Default != null)
{
ret = ret.WithDefault(null);
}
return ret;
}
public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
{
string fullName = GetFullName(node);
if (this.GetRemapInfo(fullName, out var listAttributes, out string newType, out string newName))
this.GetRemapInfo(fullName, out var listAttributes, out string newType, out string newName);
// ClangSharp mistakenly emits string[] for WCHAR[] Foo = "Bar".
// Change it to string
if (newType == null && node.Declaration.Type.ToString() == "string[]")
{
node = (FieldDeclarationSyntax)base.VisitFieldDeclaration(node);
if (listAttributes != null)
{
foreach (var attrNode in listAttributes)
{
var attrListNode =
SyntaxFactory.AttributeList(
SyntaxFactory.SingletonSeparatedList<AttributeSyntax>(attrNode));
node = node.WithAttributeLists(node.AttributeLists.Add(attrListNode));
}
}
var firstVar = node.Declaration.Variables.First();
if (newName != null)
{
var newVar = SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier(newName));
node = node.ReplaceNode(firstVar, newVar);
}
if (newType != null)
{
var newDeclaration = node.Declaration.WithType(SyntaxFactory.ParseTypeName(newType));
node = node.ReplaceNode(node.Declaration, newDeclaration);
}
return node;
newType = "string";
}
return base.VisitFieldDeclaration(node);
node = (FieldDeclarationSyntax)base.VisitFieldDeclaration(node);
if (listAttributes != null)
{
foreach (var attrNode in listAttributes)
{
var attrListNode =
SyntaxFactory.AttributeList(
SyntaxFactory.SingletonSeparatedList<AttributeSyntax>(attrNode));
node = node.WithAttributeLists(node.AttributeLists.Add(attrListNode));
}
}
var firstVar = node.Declaration.Variables.First();
if (newName != null)
{
var newVar = SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier(newName));
node = node.ReplaceNode(firstVar, newVar);
}
if (newType != null)
{
var newDeclaration = node.Declaration.WithType(SyntaxFactory.ParseTypeName(newType));
node = node.ReplaceNode(node.Declaration, newDeclaration);
}
return node;
}
public override SyntaxNode VisitAttributeList(AttributeListSyntax node)
@ -148,7 +162,16 @@ namespace ClangSharpSourceToWinmd
public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
string fullName = GetFullName(node);
string returnFullName = $"{GetFullName(node)}::return";
// Remove duplicate delegates in this tree
if (this.visitedDelegateNames.Contains(fullName))
{
return null;
}
this.visitedDelegateNames.Add(fullName);
string returnFullName = $"{fullName}::return";
if (this.GetRemapInfo(returnFullName, out List<AttributeSyntax> listAttributes, out _, out _))
{
@ -183,8 +206,18 @@ namespace ClangSharpSourceToWinmd
}
string fullName = GetFullName(node);
// Remove duplicate methods in this tree
if (this.visitedMethodNames.Contains(fullName))
{
return null;
}
this.visitedMethodNames.Add(fullName);
string returnFullName = $"{fullName}::return";
// Find remap info for the return parameter for this method and apply any that we find
if (this.GetRemapInfo(returnFullName, out List<AttributeSyntax> listAttributes, out _, out _))
{
node = (MethodDeclarationSyntax)base.VisitMethodDeclaration(node);

Просмотреть файл

@ -5,6 +5,7 @@ using System.CommandLine.Invocation;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@ -77,9 +78,16 @@ namespace ClangSharpSourceToWinmd
System.Threading.Tasks.ParallelOptions opt = new System.Threading.Tasks.ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount * 2 };
System.Threading.Tasks.Parallel.ForEach(sourceFiles, opt, (sourceFile) =>
{
if (sourceFile.EndsWith("modified.cs"))
{
return;
}
string fileToRead = Path.GetFullPath(sourceFile);
var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(fileToRead), null, fileToRead);
string modifiedFile = Path.ChangeExtension(fileToRead, ".modified.cs");
var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(fileToRead), null, modifiedFile);
tree = MetadataSyntaxTreeCleaner.CleanSyntaxTree(tree, remaps);
File.WriteAllText(modifiedFile, tree.GetText().ToString());
lock (syntaxTrees)
{
@ -87,16 +95,88 @@ namespace ClangSharpSourceToWinmd
}
});
watch.Stop();
string timeTaken = watch.Elapsed.ToString("c");
Console.WriteLine($"took {timeTaken}");
CSharpCompilationOptions compilationOptions = new CSharpCompilationOptions(OutputKind.WindowsRuntimeMetadata, allowUnsafe: true);
var comp =
CSharpCompilation.Create(
Path.GetFileName(outputFileName),
syntaxTrees,
refs);
refs,
compilationOptions);
Console.Write("looking for errors...");
var diags = comp.GetDeclarationDiagnostics();
watch.Stop();
int errors = 0;
const int MaxErrorsToShow = 10000;
foreach (var diag in diags)
{
if (diag.Severity == DiagnosticSeverity.Warning)
{
continue;
}
// CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type
// We can do this in metadata, so it's OK
// CS0558: Operator, which we don't emit
// CS0562: Operator, which we don't emit
// CS0590: Operator, which we don't emit
// CS0568: Ctor on structs, which we don't emit
// CS0592: FieldOffset on a property which we don't emit
// CS1745: Cannot specify default parameter value in conjunction with DefaultParameterAttribute or OptionalAttribute
// CS0111: Operator
if (diag.Id == "CS0208" || diag.Id == "CS0558" || diag.Id == "CS0562" || diag.Id == "CS0590" || diag.Id == "CS0568" || diag.Id == "CS0592" || diag.Id == "CS1745" ||
diag.Id == "CS0111")
{
continue;
}
// CS0029: Cannot implicitly convert type 'string' to 'string[]'
// Problem with ClangSharp that emits WCHAR Bar[] = "foo" into string[] Bar = "foo"
// We work around this in the emitter
if (diag.Id == "CS0029" && diag.ToString().Contains("'string' to 'string[]'"))
{
continue;
}
// Symbol not found. See if it's in the type import list
if (diag.Id == "CS0246")
{
var symbolNameRegx = new System.Text.RegularExpressions.Regex(@"The type or namespace name '(\w+)'");
var match = symbolNameRegx.Match(diag.GetMessage());
if (match.Success)
{
var symbolName = match.Groups[1].Value;
if (typeImports.ContainsKey(symbolName) || typeImports.ContainsKey($"{symbolName}(interface)"))
{
continue;
}
}
}
if (errors == 0)
{
Console.WriteLine("errors were found.");
}
errors++;
Console.WriteLine(diag.ToString());
if (errors >= MaxErrorsToShow)
{
Console.WriteLine($"Only showing the first {MaxErrorsToShow} errors.");
break;
}
}
if (errors > 0)
{
return -1;
}
string timeTaken = watch.Elapsed.ToString("c");
Console.WriteLine($"took {timeTaken}");
Console.WriteLine($"Emitting {outputFileName}...");
var generator = ClangSharpSourceWinmdGenerator.GenerateWindmdForCompilation(comp, typeImports, assemblyVersion, outputFileName);

Просмотреть файл

@ -10,12 +10,6 @@ namespace Windows.Win32.Base
public const int FALSE = 0;
// Not allowed because UIntPtr can't be const
//[NativeTypeName("const JsSourceContext")]
//public const UIntPtr JS_SOURCE_CONTEXT_NONE = new UIntPtr(-1);
public static uint DWRITE_MAKE_OPENTYPE_TAG(byte a, byte b, byte c, byte d) => ((uint)d << 24) | ((uint)c << 16) | ((uint)b << 8) | a;
public static DWRITE_FONT_AXIS_TAG DWRITE_MAKE_FONT_AXIS_TAG(byte a, byte b, byte c, byte d) => (DWRITE_FONT_AXIS_TAG)DWRITE_MAKE_OPENTYPE_TAG(a, b, c, d);
public const ushort RT_CURSOR = 1;
@ -5899,15 +5893,4 @@ namespace Windows.Win32.Base
public const uint INFINITE = 0xFFFFFFFF;
}
/*
public enum DWRITE_FONT_AXIS_TAG : uint
{
DWRITE_FONT_AXIS_TAG_WEIGHT = (((uint)((byte)('t')) << 24) | ((uint)((byte)('h')) << 16) | ((uint)((byte)('g')) << 8) | (uint)((byte)('w'))),
DWRITE_FONT_AXIS_TAG_WIDTH = (((uint)((byte)('h')) << 24) | ((uint)((byte)('t')) << 16) | ((uint)((byte)('d')) << 8) | (uint)((byte)('w'))),
DWRITE_FONT_AXIS_TAG_SLANT = (((uint)((byte)('t')) << 24) | ((uint)((byte)('n')) << 16) | ((uint)((byte)('l')) << 8) | (uint)((byte)('s'))),
DWRITE_FONT_AXIS_TAG_OPTICAL_SIZE = (((uint)((byte)('z')) << 24) | ((uint)((byte)('s')) << 16) | ((uint)((byte)('p')) << 8) | (uint)((byte)('o'))),
DWRITE_FONT_AXIS_TAG_ITALIC = (((uint)((byte)('l')) << 24) | ((uint)((byte)('a')) << 16) | ((uint)((byte)('t')) << 8) | (uint)((byte)('i'))),
}
*/
}

Просмотреть файл

@ -4,8 +4,8 @@
// Original source is Copyright © Microsoft. All rights reserved.
using System;
using static Windows.Win32.D3D12_FILTER_REDUCTION_TYPE;
using static Windows.Win32.D3D12_FILTER_TYPE;
using static Windows.Win32.Direct3D12.D3D12_FILTER_REDUCTION_TYPE;
using static Windows.Win32.Direct3D12.D3D12_FILTER_TYPE;
namespace Windows.Win32.Direct3D12
{

Просмотреть файл

@ -1,19 +1,7 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
// Ported from shared/dxgi.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.
using System;
namespace Windows.Win32.Direct3DDxgi
{
public enum DXGI_ADAPTER_FLAG : uint
{
DXGI_ADAPTER_FLAG_NONE = 0u,
DXGI_ADAPTER_FLAG_REMOTE = 1u,
DXGI_ADAPTER_FLAG_SOFTWARE = 2u,
}
public static unsafe partial class Apis
{
public const uint DXGI_USAGE_SHADER_INPUT = 0x00000010;
@ -77,27 +65,5 @@ namespace Windows.Win32.Direct3DDxgi
public const uint DXGI_MWA_NO_PRINT_SCREEN = 1 << 2;
public const uint DXGI_MWA_VALID = 0x7;
//public static int D3D_SET_OBJECT_NAME_N_A(IDXGIObject* pObject, uint Chars, sbyte* pName)
//{
// var guid = WKPDID_D3DDebugObjectName;
// return pObject->SetPrivateData(&guid, Chars, pName);
//}
//public static int D3D_SET_OBJECT_NAME_A(IDXGIObject* pObject, sbyte* pName)
//{
// return D3D_SET_OBJECT_NAME_N_A(pObject, (uint)lstrlenA(pName), pName);
//}
//public static int D3D_SET_OBJECT_NAME_N_W(IDXGIObject* pObject, uint Chars, ushort* pName)
//{
// var guid = WKPDID_D3DDebugObjectNameW;
// return pObject->SetPrivateData(&guid, Chars * 2, pName);
//}
//public static int D3D_SET_OBJECT_NAME_W(IDXGIObject* pObject, ushort* pName)
//{
// return D3D_SET_OBJECT_NAME_N_W(pObject, (uint)lstrlenW(pName), pName);
//}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
using System;
using System.Runtime.InteropServices;
using Windows.Win32.Interop;
namespace Windows.Win32.DirectWrite
{
public static unsafe partial class Apis
{
public static uint DWRITE_MAKE_OPENTYPE_TAG(byte a, byte b, byte c, byte d) => ((uint)d << 24) | ((uint)c << 16) | ((uint)b << 8) | a;
public static DWRITE_FONT_AXIS_TAG DWRITE_MAKE_FONT_AXIS_TAG(byte a, byte b, byte c, byte d) => (DWRITE_FONT_AXIS_TAG)DWRITE_MAKE_OPENTYPE_TAG(a, b, c, d);
}
public enum DWRITE_FONT_AXIS_TAG : uint
{
DWRITE_FONT_AXIS_TAG_WEIGHT = (((uint)((byte)('t')) << 24) | ((uint)((byte)('h')) << 16) | ((uint)((byte)('g')) << 8) | (uint)((byte)('w'))),
DWRITE_FONT_AXIS_TAG_WIDTH = (((uint)((byte)('h')) << 24) | ((uint)((byte)('t')) << 16) | ((uint)((byte)('d')) << 8) | (uint)((byte)('w'))),
DWRITE_FONT_AXIS_TAG_SLANT = (((uint)((byte)('t')) << 24) | ((uint)((byte)('n')) << 16) | ((uint)((byte)('l')) << 8) | (uint)((byte)('s'))),
DWRITE_FONT_AXIS_TAG_OPTICAL_SIZE = (((uint)((byte)('z')) << 24) | ((uint)((byte)('s')) << 16) | ((uint)((byte)('p')) << 8) | (uint)((byte)('o'))),
DWRITE_FONT_AXIS_TAG_ITALIC = (((uint)((byte)('l')) << 24) | ((uint)((byte)('a')) << 16) | ((uint)((byte)('t')) << 8) | (uint)((byte)('i'))),
}
}

Просмотреть файл

@ -0,0 +1,33 @@
using System;
using System.Runtime.InteropServices;
using Windows.Win32.Interop;
namespace Windows.Win32.Rpc
{
// Because this emits with an anonymous name
public unsafe partial struct NDR_SCONTEXT_1
{
[NativeTypeName("void *[2]")]
public _pad_e__FixedBuffer pad;
[NativeTypeName("void *")]
public void* userContext;
public unsafe partial struct _pad_e__FixedBuffer
{
public void* e0;
public void* e1;
public ref void* this[int index]
{
get
{
fixed (void** pThis = &e0)
{
return ref pThis[index];
}
}
}
}
}
}

Просмотреть файл

@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Windows.Win32.WinRt
namespace Windows.Win32.WinRT
{
public struct EventRegistrationToken
{

Просмотреть файл

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.IO;
namespace WinmdUtils
{
class Program
{
static int Main(string[] args)
{
var showMissingImportsCommand = new Command("showMissingImports", "Show missing imports between two windmd files.")
{
new Option(new[] { "--first" }, "The first winmd.") { Argument = new Argument<FileInfo>().ExistingOnly(), IsRequired = true },
new Option(new[] { "--second" }, "The second winmd.") { Argument = new Argument<FileInfo>().ExistingOnly(), IsRequired = true },
new Option(new[] { "--exclusions" }, "Exclusions files.") { Argument = new Argument<string>(), IsRequired = false },
};
showMissingImportsCommand.Handler = CommandHandler.Create<FileInfo, FileInfo, string, IConsole>(ShowMissingImports);
var rootCommand = new RootCommand("Win32metadata winmd utils")
{
showMissingImportsCommand,
};
return rootCommand.Invoke(args);
}
public static int ShowMissingImports(FileInfo first, FileInfo second, string exclusions, IConsole console)
{
int ret = 0;
using WinmdUtils w1 = WinmdUtils.LoadFromFile(first.FullName);
HashSet<string> remainingImports = new HashSet<string>();
foreach (var imp in w1.GetDllImports())
{
remainingImports.Add(imp.Name.ToString());
}
using WinmdUtils w2 = WinmdUtils.LoadFromFile(second.FullName);
foreach (var imp in w2.GetDllImports())
{
var text = imp.Name.ToString();
if (remainingImports.Contains(text))
{
remainingImports.Remove(text);
}
}
foreach (var imp in remainingImports)
{
if (ret == 0)
{
console.Out.Write("Missing imports detected:\r\n");
ret = -1;
}
console.Out.Write(imp.ToString());
console.Out.Write("\r\n");
}
if (ret == 0)
{
console.Out.Write("No missing imports found.\r\n");
}
return ret;
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
{
"profiles": {
"WinmdUtils": {
"commandName": "Project",
"commandLineArgs": "showMissingImports --first $(ProjectDir)..\\..\\scripts\\BaselineWinmd\\10.0.19041.5\\Windows.Win32.winmd --second $(ProjectDir)..\\..\\bin\\Windows.Win32.winmd"
}
}
}

Просмотреть файл

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using System.IO;
namespace WinmdUtils
{
public class WinmdUtils : IDisposable
{
private FileStream stream;
private PEReader peReader;
private MetadataReader metadataReader;
private WinmdUtils(string fileName)
{
this.stream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
this.peReader = new PEReader(stream);
this.metadataReader = this.peReader.GetMetadataReader();
}
public static WinmdUtils LoadFromFile(string fileName)
{
return new WinmdUtils(fileName);
}
public void Dispose()
{
this.stream?.Dispose();
this.peReader?.Dispose();
}
public IEnumerable<DllImport> GetDllImports()
{
foreach (var methodDefHandle in this.metadataReader.MethodDefinitions)
{
var method = this.metadataReader.GetMethodDefinition(methodDefHandle);
if (method.Attributes.HasFlag(System.Reflection.MethodAttributes.PinvokeImpl))
{
var name = this.metadataReader.GetString(method.Name);
var import = method.GetImport();
var moduleRef = this.metadataReader.GetModuleReference(import.Module);
var dllName = this.metadataReader.GetString(moduleRef.Name);
yield return new DllImport(name, dllName);
}
}
}
}
public class DllImport
{
public DllImport(string name, string dll)
{
this.Name = name;
this.Dll = dll;
}
public string Name { get; private set; }
public string Dll { get; private set; }
public override string ToString()
{
return $"{this.Name}({this.Dll})";
}
public override int GetHashCode()
{
return this.ToString().GetHashCode();
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinmdUtils", "WinmdUtils.csproj", "{E9A699AC-A690-42ED-83E1-66CB7F65058D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E9A699AC-A690-42ED-83E1-66CB7F65058D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9A699AC-A690-42ED-83E1-66CB7F65058D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9A699AC-A690-42ED-83E1-66CB7F65058D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9A699AC-A690-42ED-83E1-66CB7F65058D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {10CB32D9-2A44-4DE0-B020-26B136672FE1}
EndGlobalSection
EndGlobal

Двоичные данные
tools/ClangSharp.PInvokeGenerator.dll

Двоичный файл не отображается.

Двоичные данные
tools/ClangSharpPInvokeGenerator.dll

Двоичный файл не отображается.