Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElinor Fung <elfung@microsoft.com>2022-02-24 05:36:10 +0300
committerGitHub <noreply@github.com>2022-02-24 05:36:10 +0300
commit7984b32774916c98ab7c85c244c9e40581e4cdf5 (patch)
tree9c135e64aaecd6e04d6fad10924ea2d02a927c01
parent67d8b96d6d04d8aae231425bbf2a192966c4a3f8 (diff)
Update GeneratedDllImportAttribute CharSet -> StringMarshalling (#65544)
-rw-r--r--docs/design/libraries/DllImportGenerator/Compatibility.md19
-rw-r--r--eng/generators.targets1
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/CLRConfig.cs2
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs2
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.CoreCLR.cs4
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs8
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs16
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs8
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs2
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs2
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.CoreCLR.cs6
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs14
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs4
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs2
-rw-r--r--src/coreclr/System.Private.CoreLib/src/System/TypeNameParser.cs2
-rw-r--r--src/libraries/Common/src/Interop/Android/Interop.Logcat.cs2
-rw-r--r--src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs2
-rw-r--r--src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs2
-rw-r--r--src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs8
-rw-r--r--src/libraries/Common/src/Interop/BSD/System.Native/Interop.ProtocolStatistics.cs2
-rw-r--r--src/libraries/Common/src/Interop/Interop.Calendar.cs6
-rw-r--r--src/libraries/Common/src/Interop/Interop.Casing.cs8
-rw-r--r--src/libraries/Common/src/Interop/Interop.Collation.cs18
-rw-r--r--src/libraries/Common/src/Interop/Interop.HostPolicy.cs8
-rw-r--r--src/libraries/Common/src/Interop/Interop.ICU.cs2
-rw-r--r--src/libraries/Common/src/Interop/Interop.ICU.iOS.cs2
-rw-r--r--src/libraries/Common/src/Interop/Interop.Idna.cs4
-rw-r--r--src/libraries/Common/src/Interop/Interop.Locale.cs16
-rw-r--r--src/libraries/Common/src/Interop/Interop.Normalization.cs4
-rw-r--r--src/libraries/Common/src/Interop/Interop.Odbc.cs26
-rw-r--r--src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs6
-rw-r--r--src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ber.cs48
-rw-r--r--src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs173
-rw-r--r--src/libraries/Common/src/Interop/Linux/System.Native/Interop.INotify.cs2
-rw-r--r--src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs4
-rw-r--r--src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs2
-rw-r--r--src/libraries/Common/src/Interop/OSX/Interop.libc.cs2
-rw-r--r--src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs4
-rw-r--r--src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.cs2
-rw-r--r--src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.iOS.cs2
-rw-r--r--src/libraries/Common/src/Interop/OSX/System.Native/Interop.iOSSupportVersion.cs2
-rw-r--r--src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs6
-rw-r--r--src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChMod.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.DynamicLoad.cs4
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDefaultTimeZone.Android.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroupList.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerUserName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.HostEntry.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.InitializeTerminalAndSignalHandling.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.InterfaceNameToIndex.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.Link.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.Open.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.RealPath.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.Rename.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.RmDir.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.SNPrintF.cs4
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.ShmOpen.cs4
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.cs4
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.UTimensat.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Native/Interop.Unlink.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.Nid.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.cs4
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.BIO.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.CheckX509Hostname_IntPtr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Crypto.cs4
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LookupFriendlyNameByOid.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs4
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs2
-rw-r--r--src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Stack.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Activeds/Interop.ADsOpenObject.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ClearEventLog.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSidToStringSid.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSidToSid.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateService.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext_IntPtr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetDefaultProvider.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSignHash.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LogonUser.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountSid.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenEventLog.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs8
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs10
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterEventSource.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReportEvent.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Authz/Interop.AuthzInitializeResourceManager.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs6
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCreateHash.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptExportKey.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGetProperty.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHashData.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptImportKey.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptOpenAlgorithmProvider.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Credui/Interop.CredUIParseUserName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContextWithKeyContainerDeletion.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextPropertyString.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetNameString.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertStrToName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_IntPtr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_string.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectData.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Dsrole/Interop.DsRoleGetPrimaryDomainInformation.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateFontIndirect.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/HttpApi/Interop.HttpApi.cs6
-rw-r--r--src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.if_nametoindex.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile_IntPtr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipe.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipeClient.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcessModules.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcesses.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputCharacter.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage_SafeLibraryHandle.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleTitle.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDiskFreeSpaceEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDriveType.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleBaseName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileNameEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeHandleState.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs8
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessPriorityBoost.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs26
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx_IntPtr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsole.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleOutput.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadDirectoryChangesW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTitle.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetVolumeLabel.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitNamedPipe.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsole.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsoleOutput.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Logoncli/Interop.DsGetDcName.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Keys.cs18
-rw-r--r--src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptOpenStorageProvider.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/NCrypt/Interop.SignVerify.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs4
-rw-r--r--src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs10
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.GetMessage.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.PostQuitMessage.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoSizeEx.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Version/Interop.VerQueryValue.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs48
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinMm/Interop.PlaySound.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinMm/Interop.mmioOpen.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoExW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetNameInfoW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSADuplicateSocket.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.SafeCloseSocket.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Wkscli/Interop.NetWkstaGetInfo.cs2
-rw-r--r--src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs30
-rw-r--r--src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs94
-rw-r--r--src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs2
-rw-r--r--src/libraries/Common/src/System/Runtime/InteropServices/StringMarshalling.cs23
-rw-r--r--src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs2
-rw-r--r--src/libraries/Microsoft.Win32.Registry/tests/Helpers.cs6
-rw-r--r--src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs8
-rw-r--r--src/libraries/System.DirectoryServices/src/Interop/SafeNativeMethods.cs4
-rw-r--r--src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs12
-rw-r--r--src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs12
-rw-r--r--src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs18
-rw-r--r--src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs2
-rw-r--r--src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs2
-rw-r--r--src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs4
-rw-r--r--src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs8
-rw-r--r--src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs12
-rw-r--r--src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Windows.cs16
-rw-r--r--src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs36
-rw-r--r--src/libraries/System.Drawing.Common/src/System/Drawing/Printing/LibcupsNative.cs29
-rw-r--r--src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs4
-rw-r--r--src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Unix.cs2
-rw-r--r--src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.NotifyFilter.cs2
-rw-r--r--src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.NotifyFilter.cs2
-rw-r--r--src/libraries/System.IO.FileSystem/tests/FileSystemTest.Unix.cs2
-rw-r--r--src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs2
-rw-r--r--src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs2
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md1
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md25
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs81
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs59
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj8
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs12
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs12
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs28
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs27
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx11
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs8
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs179
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs2
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs7
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj1
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs6
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs16
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs217
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs27
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs26
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs13
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs36
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs36
330 files changed, 1090 insertions, 1185 deletions
diff --git a/docs/design/libraries/DllImportGenerator/Compatibility.md b/docs/design/libraries/DllImportGenerator/Compatibility.md
index 4eee2455edc..f141ea99a36 100644
--- a/docs/design/libraries/DllImportGenerator/Compatibility.md
+++ b/docs/design/libraries/DllImportGenerator/Compatibility.md
@@ -12,9 +12,9 @@ In the event a marshaller would generate code that has a specific target framewo
### Semantic changes compared to `DllImportAttribute`
-The default value of [`CharSet`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.charset) is runtime/language-defined. In the built-in system, the default value of the `CharSet` property is `CharSet.Ansi`. The P/Invoke source generator makes no assumptions about the `CharSet` if it is not explicitly set on `GeneratedDllImportAttribute`. Marshalling of `char` or `string` requires explicitly specifying marshalling information.
+[`CharSet`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.charset) has been replaced with a new `StringMarshalling` enumeration. `Ansi` and `Auto` are no longer supported as first-class options and `Utf8` has been added.
-The built-in system treats `CharSet.None` as `CharSet.Ansi`. The P/Invoke source generator will treat `CharSet.None` as if the `CharSet` was not set.
+With `DllImportAttribute`, the default value of [`CharSet`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.charset) is runtime/language-defined. In the built-in system, the default value of the `CharSet` property is `CharSet.Ansi`. The P/Invoke source generator makes no assumptions about `StringMarshalling` if it is not explicitly set on `GeneratedDllImportAttribute`. Marshalling of `char` or `string` requires explicitly specifying marshalling information.
[`BestFitMapping`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.bestfitmapping) and [`ThrowOnUnmappableChar`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.throwonunmappablechar) will not be supported for `GeneratedDllImportAttribute`. These values only have meaning on Windows when marshalling string data (`char`, `string`, `StringBuilder`) as [ANSI](https://docs.microsoft.com/windows/win32/intl/code-pages). As the general recommendation - including from Windows - is to move away from ANSI, the P/Invoke source generator will not support these fields.
@@ -33,31 +33,30 @@ These are all part of `NetCoreApp` and will be referenced by default unless [imp
### `char` marshalling
-Marshalling of `char` will not be supported when configured with any of the following:
- - [`CharSet.Ansi`, `CharSet.Auto`, or `CharSet.None`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.charset) will not be supported.
+Marshalling of `char` will only be supported with `StringMarshalling.Utf16` or as `UnmanagedType.U2` or `UnmanagedType.I2`. It will not be supported when configured with any of the following:
- [`UnmanagedType.U1` or `UnmanagedType.I1`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.unmanagedtype)
- - No explicit marshalling information - either [`DllImportAttribute.CharSet`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.charset) or [`MarshalAsAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute)
+ - `StringMarshalling.Utf8` will not be supported.
+ - No explicit marshalling information - either `GeneratedDllImportAttribute.StringMarshalling` or [`MarshalAsAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute)
-For `CharSet.Ansi` and `CharSet.None`, the built-in system used the [system default Windows ANSI code page](https://docs.microsoft.com/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte) when on Windows and took the first byte of the UTF-8 encoding on non-Windows platforms. The above reasoning also applies to marshalling of a `char` as `UnmanagedType.U1` and `UnmanagedType.I1`. All approaches are fundamentally flawed and therefore not supported. If a single-byte character is expected to be marshalled it is left to the caller to convert a .NET `char` into a single `byte` prior to calling the native function.
+In the built-in system, marshalling with `CharSet.Ansi` and `CharSet.None` used the [system default Windows ANSI code page](https://docs.microsoft.com/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte) when on Windows and took the first byte of the UTF-8 encoding on non-Windows platforms. The above reasoning also applies to marshalling of a `char` as `UnmanagedType.U1` and `UnmanagedType.I1`. All approaches are fundamentally flawed and therefore not supported. If a single-byte character is expected to be marshalled it is left to the caller to convert a .NET `char` into a single `byte` prior to calling the native function.
For `CharSet.Auto`, the built-in system relied upon detection at runtime of the platform when determining the targeted encoding. Performing this check in generated code violates the "pay-for-play" principle. Given that there are no scenarios for this feature in `NetCoreApp` it will not be supported.
### `string` marshalling
Marshalling of `string` will not be supported when configured with any of the following:
- - [`CharSet.None`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.charset)
- [`UnmanagedType.VBByRefStr`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.unmanagedtype)
- - No explicit marshalling information - either [`DllImportAttribute.CharSet`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.charset) or [`MarshalAsAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute)
+ - No explicit marshalling information - either `GeneratedDllImportAttribute.StringMarshalling` or [`MarshalAsAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute)
When converting from native to managed, the built-in system would throw a [`MarshalDirectiveException`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshaldirectiveexception) if the string's length is over 0x7ffffff0. The generated marshalling code will no longer perform this check.
In the built-in system, marshalling a `string` contains an optimization for parameters passed by value to allocate on the stack (instead of through [`AllocCoTaskMem`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.alloccotaskmem)) if the string is below a certain length (MAX_PATH). For UTF-16, this optimization was also applied for parameters passed by read-only reference. The generated marshalling code will include this optimization for read-only reference parameters for non-UTF-16 as well.
-When marshalling as [ANSI](https://docs.microsoft.com/windows/win32/intl/code-pages) on Windows (using `CharSet.Ansi` or `UnmanagedType.LPStr`):
+When marshalling as [ANSI](https://docs.microsoft.com/windows/win32/intl/code-pages) on Windows (using `UnmanagedType.LPStr`):
- Best-fit mapping will be disabled and no exception will be thrown for unmappable characters. In the built-in system, this behaviour was configured through [`DllImportAttribute.BestFitMapping`] and [`DllImportAttribute.ThrowOnUnmappableChar`]. The generated marshalling code will have the equivalent behaviour of `BestFitMapping=false` and `ThrowOnUnmappableChar=false`.
- No optimization for stack allocation will be performed. Marshalling will always allocate through `AllocCoTaskMem`.
-On Windows, marshalling using `CharSet.Auto` is treated as UTF-16. When marshalling a string as UTF-16 by value or by read-only reference, the string is pinned and the pointer passed to the P/Invoke. The generated marshalling code will always pin the input string - even on non-Windows.
+The p/invoke source generator does not provide an equivalent to using `CharSet.Auto` in the built-in system. If platform-dependent behaviour is desired, it is left to the user to define different p/invokes with different marshalling configurations.
### Custom marshaller support
diff --git a/eng/generators.targets b/eng/generators.targets
index d73019014a8..f13e56995af 100644
--- a/eng/generators.targets
+++ b/eng/generators.targets
@@ -47,6 +47,7 @@
and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DllImportGenerator'))
and '$(IncludeDllImportGeneratorSources)' == 'true'">
<Compile Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\GeneratedDllImportAttribute.cs" />
+ <Compile Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\StringMarshalling.cs" />
<!-- Only add the following files if we are on the latest TFM (that is, net7). -->
<Compile Condition="'$(NetCoreAppCurrentTargetFrameworkMoniker)' == '$(TargetFrameworkMoniker)'" Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\GeneratedMarshallingAttribute.cs" />
diff --git a/src/coreclr/System.Private.CoreLib/src/System/CLRConfig.cs b/src/coreclr/System.Private.CoreLib/src/System/CLRConfig.cs
index de634153403..6d09407a2d9 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/CLRConfig.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/CLRConfig.cs
@@ -15,7 +15,7 @@ namespace System
return GetConfigBoolValue(switchName, out exist);
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ClrConfig_GetConfigBoolValue", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ClrConfig_GetConfigBoolValue", StringMarshalling = StringMarshalling.Utf16)]
private static partial bool GetConfigBoolValue(string configSwitchName, out bool exist);
}
}
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs
index d5528ca93dc..5ed71821cad 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs
@@ -77,7 +77,7 @@ namespace System.Diagnostics
// report the message depending on its settings.
public static void Log(int level, string? category, string? message) => LogInternal(level, category, message);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_Log", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_Log", StringMarshalling = StringMarshalling.Utf16)]
private static partial void LogInternal(int level, string? category, string? message);
// Checks to see if an attached debugger has logging enabled
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.CoreCLR.cs
index d4938c14002..bda9ceaaf20 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.CoreCLR.cs
@@ -28,13 +28,13 @@ namespace System.Diagnostics.Tracing
//
// These PInvokes are used by EventSource to interact with the EventPipe.
//
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "EventPipeInternal_CreateProvider", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "EventPipeInternal_CreateProvider", StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr CreateProvider(string providerName, Interop.Advapi32.EtwEnableCallback callbackFunc);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "EventPipeInternal_DefineEvent")]
internal static unsafe partial IntPtr DefineEvent(IntPtr provHandle, uint eventID, long keywords, uint eventVersion, uint level, void *pMetadata, uint metadataLength);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "EventPipeInternal_GetProvider", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "EventPipeInternal_GetProvider", StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr GetProvider(string providerName);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "EventPipeInternal_DeleteProvider")]
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs
index 3bf175e13e1..e9c4e77471a 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs
@@ -93,7 +93,7 @@ namespace System.Reflection.Emit
return SymbolType.FormCompoundType(strFormat, baseType, 0);
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetTypeRef", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetTypeRef", StringMarshalling = StringMarshalling.Utf16)]
private static partial int GetTypeRef(QCallModule module, string strFullName, QCallModule refedModule, string? strRefedModuleFileName, int tkResolution);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetMemberRef")]
@@ -107,7 +107,7 @@ namespace System.Reflection.Emit
return GetMemberRef(new QCallModule(ref thisModule), new QCallModule(ref refedRuntimeModule), tr, defToken);
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetMemberRefFromSignature", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetMemberRefFromSignature", StringMarshalling = StringMarshalling.Utf16)]
private static partial int GetMemberRefFromSignature(QCallModule module, int tr, string methodName, byte[] signature, int length);
private int GetMemberRefFromSignature(int tr, string methodName, byte[] signature, int length)
@@ -159,10 +159,10 @@ namespace System.Reflection.Emit
return GetTokenFromTypeSpec(new QCallModule(ref thisModule), signature, length);
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetArrayMethodToken", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetArrayMethodToken", StringMarshalling = StringMarshalling.Utf16)]
private static partial int GetArrayMethodToken(QCallModule module, int tkTypeSpec, string methodName, byte[] signature, int sigLength);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetStringConstant", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_GetStringConstant", StringMarshalling = StringMarshalling.Utf16)]
private static partial int GetStringConstant(QCallModule module, string str, int length);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ModuleBuilder_SetFieldRVAContent")]
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
index f5823d837f3..87bc1b9156f 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
@@ -148,14 +148,14 @@ namespace System.Reflection.Emit
#endregion
#region Internal Static FCalls
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineMethod", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineMethod", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DefineMethod(QCallModule module, int tkParent, string name, byte[] signature, int sigLength,
MethodAttributes attributes);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineMethodSpec")]
internal static partial int DefineMethodSpec(QCallModule module, int tkParent, byte[] signature, int sigLength);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineField", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineField", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DefineField(QCallModule module, int tkParent, string name, byte[] signature, int sigLength,
FieldAttributes attributes);
@@ -186,11 +186,11 @@ namespace System.Reflection.Emit
localAttr, (localAttr != null) ? localAttr.Length : 0);
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineProperty", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineProperty", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DefineProperty(QCallModule module, int tkParent, string name, PropertyAttributes attributes,
byte[] signature, int sigLength);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineEvent", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineEvent", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DefineEvent(QCallModule module, int tkParent, string name, EventAttributes attributes, int tkEventType);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineMethodSemantics")]
@@ -203,7 +203,7 @@ namespace System.Reflection.Emit
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_SetMethodImpl")]
internal static partial void SetMethodImpl(QCallModule module, int tkMethod, MethodImplAttributes MethodImplAttributes);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_SetParamInfo", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_SetParamInfo", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int SetParamInfo(QCallModule module, int tkMethod, int iSequence,
ParameterAttributes iParamAttributes, string? strParamName);
@@ -219,7 +219,7 @@ namespace System.Reflection.Emit
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_SetConstantValue")]
private static unsafe partial void SetConstantValue(QCallModule module, int tk, int corType, void* pValue);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_SetPInvokeData", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_SetPInvokeData", StringMarshalling = StringMarshalling.Utf16)]
private static partial void SetPInvokeData(QCallModule module, string DllName, string name, int token, int linkFlags);
#endregion
@@ -635,11 +635,11 @@ namespace System.Reflection.Emit
#endregion
#region FCalls
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineType", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineType", StringMarshalling = StringMarshalling.Utf16)]
private static partial int DefineType(QCallModule module,
string fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineGenericParam", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeBuilder_DefineGenericParam", StringMarshalling = StringMarshalling.Utf16)]
private static partial int DefineGenericParam(QCallModule module,
string name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints);
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
index 1b66fb3c824..d0268d1d292 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
@@ -174,7 +174,7 @@ namespace System.Reflection
}
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetType", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetType", StringMarshalling = StringMarshalling.Utf16)]
private static partial void GetType(QCallAssembly assembly,
string name,
bool throwOnError,
@@ -252,7 +252,7 @@ namespace System.Reflection
}
// GetResource will return a pointer to the resources in memory.
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetResource", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetResource", StringMarshalling = StringMarshalling.Utf16)]
private static unsafe partial byte* GetResource(QCallAssembly assembly,
string resourceName,
out uint length);
@@ -357,7 +357,7 @@ namespace System.Reflection
// Returns the module in this assembly with name 'name'
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetModule", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetModule", StringMarshalling = StringMarshalling.Utf16)]
private static partial void GetModule(QCallAssembly assembly, string name, ObjectHandleOnStack retModule);
public override Module? GetModule(string name)
@@ -430,7 +430,7 @@ namespace System.Reflection
return GetReferencedAssemblies(GetNativeHandle());
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetManifestResourceInfo", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetManifestResourceInfo", StringMarshalling = StringMarshalling.Utf16)]
private static partial int GetManifestResourceInfo(QCallAssembly assembly,
string resourceName,
ObjectHandleOnStack assemblyRef,
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs
index 4b5760f14c7..4a2cf7bee78 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs
@@ -14,7 +14,7 @@ namespace System.Reflection
internal RuntimeModule() { throw new NotSupportedException(); }
#region FCalls
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeModule_GetType", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeModule_GetType", StringMarshalling = StringMarshalling.Utf16)]
private static partial void GetType(QCallModule module, string className, bool throwOnError, bool ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeModule_GetScopeName")]
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs
index 9bd809a37fe..203ad5ae393 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs
@@ -284,7 +284,7 @@ namespace System.Runtime.InteropServices
return type;
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "MarshalNative_GetTypeFromCLSID", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "MarshalNative_GetTypeFromCLSID", StringMarshalling = StringMarshalling.Utf16)]
private static partial void GetTypeFromCLSID(in Guid clsid, string? server, ObjectHandleOnStack retType);
/// <summary>
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.CoreCLR.cs
index 428299b2a08..1394cc733a1 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.CoreCLR.cs
@@ -20,10 +20,10 @@ namespace System.Runtime.InteropServices
/// External functions that implement the NativeLibrary interface
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "NativeLibrary_LoadFromPath", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "NativeLibrary_LoadFromPath", StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr LoadFromPath(string libraryName, bool throwOnError);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "NativeLibrary_LoadByName", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "NativeLibrary_LoadByName", StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr LoadByName(string libraryName, QCallAssembly callingAssembly,
bool hasDllImportSearchPathFlag, uint dllImportSearchPathFlag,
bool throwOnError);
@@ -31,7 +31,7 @@ namespace System.Runtime.InteropServices
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "NativeLibrary_FreeLib")]
internal static partial void FreeLib(IntPtr handle);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "NativeLibrary_GetSymbol", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "NativeLibrary_GetSymbol", StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr GetSymbol(IntPtr handle, string symbolName, bool throwOnError);
}
}
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs
index 189544527f6..70cbc6dd1d2 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs
@@ -21,14 +21,14 @@ namespace System.Runtime.Loader
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_LoadFromStream")]
private static partial void LoadFromStream(IntPtr ptrNativeAssemblyBinder, IntPtr ptrAssemblyArray, int iAssemblyArrayLen, IntPtr ptrSymbols, int iSymbolArrayLen, ObjectHandleOnStack retAssembly);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "MultiCoreJIT_InternalSetProfileRoot", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "MultiCoreJIT_InternalSetProfileRoot", StringMarshalling = StringMarshalling.Utf16)]
internal static partial void InternalSetProfileRoot(string directoryPath);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "MultiCoreJIT_InternalStartProfile", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "MultiCoreJIT_InternalStartProfile", StringMarshalling = StringMarshalling.Utf16)]
internal static partial void InternalStartProfile(string? profile, IntPtr ptrNativeAssemblyBinder);
[RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_LoadFromPath", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_LoadFromPath", StringMarshalling = StringMarshalling.Utf16)]
private static partial void LoadFromPath(IntPtr ptrNativeAssemblyBinder, string? ilPath, string? niPath, ObjectHandleOnStack retAssembly);
[MethodImpl(MethodImplOptions.InternalCall)]
@@ -37,16 +37,16 @@ namespace System.Runtime.Loader
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern bool IsTracingEnabled();
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceResolvingHandlerInvoked", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceResolvingHandlerInvoked", StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool TraceResolvingHandlerInvoked(string assemblyName, string handlerName, string? alcName, string? resultAssemblyName, string? resultAssemblyPath);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceAssemblyResolveHandlerInvoked", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceAssemblyResolveHandlerInvoked", StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool TraceAssemblyResolveHandlerInvoked(string assemblyName, string handlerName, string? resultAssemblyName, string? resultAssemblyPath);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceAssemblyLoadFromResolveHandlerInvoked", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceAssemblyLoadFromResolveHandlerInvoked", StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool TraceAssemblyLoadFromResolveHandlerInvoked(string assemblyName, bool isTrackedAssembly, string requestingAssemblyPath, string? requestedAssemblyPath);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceSatelliteSubdirectoryPathProbed", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_TraceSatelliteSubdirectoryPathProbed", StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool TraceSatelliteSubdirectoryPathProbed(string filePath, int hResult);
[RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
index 515a53fe6b5..e6e56037111 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
@@ -518,7 +518,7 @@ namespace System
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern IRuntimeMethodInfo GetDeclaringMethod(RuntimeType type);
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetTypeByName", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetTypeByName", StringMarshalling = StringMarshalling.Utf16)]
private static partial void GetTypeByName(string name, bool throwOnError, bool ignoreCase, StackCrawlMarkHandle stackMark,
ObjectHandleOnStack assemblyLoadContext,
ObjectHandleOnStack type, ObjectHandleOnStack keepalive);
@@ -552,7 +552,7 @@ namespace System
return type;
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetTypeByNameUsingCARules", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetTypeByNameUsingCARules", StringMarshalling = StringMarshalling.Utf16)]
private static partial void GetTypeByNameUsingCARules(string name, QCallModule scope, ObjectHandleOnStack type);
internal static RuntimeType GetTypeByNameUsingCARules(string name, RuntimeModule scope)
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
index 9f111b996d2..90f08b289c3 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
@@ -157,7 +157,7 @@ namespace System.Threading
InformThreadNameChange(GetNativeHandle(), value, value?.Length ?? 0);
}
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_InformThreadNameChange", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_InformThreadNameChange", StringMarshalling = StringMarshalling.Utf16)]
private static partial void InformThreadNameChange(ThreadHandle t, string? name, int len);
/// <summary>Returns true if the thread has been started and is not dead.</summary>
diff --git a/src/coreclr/System.Private.CoreLib/src/System/TypeNameParser.cs b/src/coreclr/System.Private.CoreLib/src/System/TypeNameParser.cs
index f77e755be77..48e24f38a45 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/TypeNameParser.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/TypeNameParser.cs
@@ -37,7 +37,7 @@ namespace System
internal sealed partial class TypeNameParser : IDisposable
{
#region QCalls
- [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeName_CreateTypeNameParser", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeName_CreateTypeNameParser", StringMarshalling = StringMarshalling.Utf16)]
private static partial void _CreateTypeNameParser(string typeName, ObjectHandleOnStack retHandle, bool throwOnError);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "TypeName_GetNames")]
diff --git a/src/libraries/Common/src/Interop/Android/Interop.Logcat.cs b/src/libraries/Common/src/Interop/Android/Interop.Logcat.cs
index 690555d8246..27dd92ad210 100644
--- a/src/libraries/Common/src/Interop/Android/Interop.Logcat.cs
+++ b/src/libraries/Common/src/Interop/Android/Interop.Logcat.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Logcat
{
- [GeneratedDllImport(Libraries.Liblog, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.Liblog, StringMarshalling = StringMarshalling.Utf8)]
private static partial void __android_log_print(LogLevel level, string? tag, string format, string args, IntPtr ptr);
internal static void AndroidLogPrint(LogLevel level, string? tag, string message) =>
diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs
index 0a309400e00..edad37efa9f 100644
--- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs
+++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class AndroidCrypto
{
- [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByKeyParameters", StringMarshalling = StringMarshalling.Utf8)]
private static partial int EcKeyCreateByKeyParameters(
out SafeEcKeyHandle key,
string oid,
diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs
index ca8d82680d1..178610b0e9a 100644
--- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs
+++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class AndroidCrypto
{
- [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByOid", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByOid", StringMarshalling = StringMarshalling.Utf8)]
private static partial SafeEcKeyHandle AndroidCryptoNative_EcKeyCreateByOid(string oid);
internal static SafeEcKeyHandle? EcKeyCreateByOid(string oid)
{
diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs
index 78e9e46b182..2dcbd1683b5 100644
--- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs
+++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs
@@ -11,14 +11,14 @@ internal static partial class Interop
{
internal static partial class AndroidCrypto
{
- [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificate", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificate", StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool X509StoreAddCertificate(
SafeX509StoreHandle store,
SafeX509Handle cert,
string hashString);
- [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificateWithPrivateKey", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificateWithPrivateKey", StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool X509StoreAddCertificateWithPrivateKey(
SafeX509StoreHandle store,
@@ -27,7 +27,7 @@ internal static partial class Interop
PAL_KeyAlgorithm algorithm,
string hashString);
- [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreContainsCertificate", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreContainsCertificate", StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool X509StoreContainsCertificate(
SafeX509StoreHandle store,
@@ -51,7 +51,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreOpenDefault")]
internal static unsafe partial SafeX509StoreHandle X509StoreOpenDefault();
- [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreRemoveCertificate", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreRemoveCertificate", StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool X509StoreRemoveCertificate(
SafeX509StoreHandle store,
diff --git a/src/libraries/Common/src/Interop/BSD/System.Native/Interop.ProtocolStatistics.cs b/src/libraries/Common/src/Interop/BSD/System.Native/Interop.ProtocolStatistics.cs
index b7548f71385..12554a3f2ff 100644
--- a/src/libraries/Common/src/Interop/BSD/System.Native/Interop.ProtocolStatistics.cs
+++ b/src/libraries/Common/src/Interop/BSD/System.Native/Interop.ProtocolStatistics.cs
@@ -155,7 +155,7 @@ internal static partial class Interop
public readonly ulong Flags;
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNativeIPInterfaceStatistics", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNativeIPInterfaceStatistics", StringMarshalling = StringMarshalling.Utf8)]
public static partial int GetNativeIPInterfaceStatistics(string name, out NativeIPInterfaceStatistics stats);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNumRoutes")]
diff --git a/src/libraries/Common/src/Interop/Interop.Calendar.cs b/src/libraries/Common/src/Interop/Interop.Calendar.cs
index 4cc06c7702d..2d9df562505 100644
--- a/src/libraries/Common/src/Interop/Interop.Calendar.cs
+++ b/src/libraries/Common/src/Interop/Interop.Calendar.cs
@@ -9,10 +9,10 @@ internal static partial class Interop
{
internal static partial class Globalization
{
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetCalendars", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetCalendars", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetCalendars(string localeName, CalendarId[] calendars, int calendarsCapacity);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetCalendarInfo", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetCalendarInfo", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char* result, int resultCapacity);
internal static unsafe bool EnumCalendarInfo(delegate* unmanaged<char*, IntPtr, void> callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context)
@@ -20,7 +20,7 @@ internal static partial class Interop
return EnumCalendarInfo((IntPtr)callback, localeName, calendarId, calendarDataType, context);
}
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EnumCalendarInfo", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EnumCalendarInfo", StringMarshalling = StringMarshalling.Utf16)]
// We skip the following DllImport because of 'Parsing function pointer types in signatures is not supported.' for some targeted
// platforms (for example, WASM build).
private static unsafe partial bool EnumCalendarInfo(IntPtr callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context);
diff --git a/src/libraries/Common/src/Interop/Interop.Casing.cs b/src/libraries/Common/src/Interop/Interop.Casing.cs
index fcb77ec3bd6..57ae276588d 100644
--- a/src/libraries/Common/src/Interop/Interop.Casing.cs
+++ b/src/libraries/Common/src/Interop/Interop.Casing.cs
@@ -7,16 +7,16 @@ internal static partial class Interop
{
internal static partial class Globalization
{
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCase", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCase", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCaseInvariant", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCaseInvariant", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial void ChangeCaseInvariant(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCaseTurkish", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCaseTurkish", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial void ChangeCaseTurkish(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_InitOrdinalCasingPage", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_InitOrdinalCasingPage", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial void InitOrdinalCasingPage(int pageNumber, char* pTarget);
}
}
diff --git a/src/libraries/Common/src/Interop/Interop.Collation.cs b/src/libraries/Common/src/Interop/Interop.Collation.cs
index 5b210bafb0d..cb43ca14ce2 100644
--- a/src/libraries/Common/src/Interop/Interop.Collation.cs
+++ b/src/libraries/Common/src/Interop/Interop.Collation.cs
@@ -10,40 +10,40 @@ internal static partial class Interop
{
internal static partial class Globalization
{
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortHandle", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortHandle", StringMarshalling = StringMarshalling.Utf8)]
internal static unsafe partial ResultCode GetSortHandle(string localeName, out IntPtr sortHandle);
[GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CloseSortHandle")]
internal static partial void CloseSortHandle(IntPtr handle);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CompareString", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CompareString", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int CompareString(IntPtr sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IndexOf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IndexOf", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int IndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LastIndexOf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LastIndexOf", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_StartsWith", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_StartsWith", StringMarshalling = StringMarshalling.Utf16)]
[MethodImpl(MethodImplOptions.NoInlining)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool StartsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options, int* matchedLength);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EndsWith", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EndsWith", StringMarshalling = StringMarshalling.Utf16)]
[MethodImpl(MethodImplOptions.NoInlining)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool EndsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options, int* matchedLength);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_StartsWith", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_StartsWith", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool StartsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EndsWith", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EndsWith", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool EndsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortKey", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortKey", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int GetSortKey(IntPtr sortHandle, char* str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options);
[GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortVersion")]
diff --git a/src/libraries/Common/src/Interop/Interop.HostPolicy.cs b/src/libraries/Common/src/Interop/Interop.HostPolicy.cs
index d808de7bea1..f41a18dad89 100644
--- a/src/libraries/Common/src/Interop/Interop.HostPolicy.cs
+++ b/src/libraries/Common/src/Interop/Interop.HostPolicy.cs
@@ -16,12 +16,16 @@ internal static partial class Interop
internal delegate void corehost_error_writer_fn(IntPtr message);
#pragma warning disable CS3016 // Arrays as attribute arguments is not CLS-compliant
- [GeneratedDllImport(Libraries.HostPolicy, CharSet = CharSet.Auto)]
+#if TARGET_WINDOWS
+ [GeneratedDllImport(Libraries.HostPolicy, StringMarshalling = StringMarshalling.Utf16)]
+#else
+ [GeneratedDllImport(Libraries.HostPolicy, StringMarshalling = StringMarshalling.Utf8)]
+#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial int corehost_resolve_component_dependencies(string componentMainAssemblyPath,
corehost_resolve_component_dependencies_result_fn result);
- [GeneratedDllImport(Libraries.HostPolicy, CharSet = CharSet.Auto)]
+ [GeneratedDllImport(Libraries.HostPolicy)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial IntPtr corehost_set_error_writer(IntPtr errorWriter);
#pragma warning restore CS3016 // Arrays as attribute arguments is not CLS-compliant
diff --git a/src/libraries/Common/src/Interop/Interop.ICU.cs b/src/libraries/Common/src/Interop/Interop.ICU.cs
index 7aa5fba7ec2..de80c0a5425 100644
--- a/src/libraries/Common/src/Interop/Interop.ICU.cs
+++ b/src/libraries/Common/src/Interop/Interop.ICU.cs
@@ -20,7 +20,7 @@ internal static partial class Interop
InitICUFunctions(icuuc, icuin, version.ToString(), suffix.Length > 0 ? suffix.ToString() : null);
}
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_InitICUFunctions", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_InitICUFunctions", StringMarshalling = StringMarshalling.Utf8)]
internal static partial void InitICUFunctions(IntPtr icuuc, IntPtr icuin, string version, string? suffix);
[GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")]
diff --git a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs
index 96c64d7aaaf..496e5db1294 100644
--- a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs
+++ b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Globalization
{
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICUData", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICUData", StringMarshalling = StringMarshalling.Utf8)]
internal static partial int LoadICUData(string path);
}
}
diff --git a/src/libraries/Common/src/Interop/Interop.Idna.cs b/src/libraries/Common/src/Interop/Interop.Idna.cs
index 7bac573f294..1c720abde79 100644
--- a/src/libraries/Common/src/Interop/Interop.Idna.cs
+++ b/src/libraries/Common/src/Interop/Interop.Idna.cs
@@ -10,10 +10,10 @@ internal static partial class Interop
internal const int AllowUnassigned = 0x1;
internal const int UseStd3AsciiRules = 0x2;
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ToAscii", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ToAscii", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int ToAscii(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ToUnicode", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ToUnicode", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int ToUnicode(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
}
}
diff --git a/src/libraries/Common/src/Interop/Interop.Locale.cs b/src/libraries/Common/src/Interop/Interop.Locale.cs
index a4b05dcc9bf..7ce34b88fb2 100644
--- a/src/libraries/Common/src/Interop/Interop.Locale.cs
+++ b/src/libraries/Common/src/Interop/Interop.Locale.cs
@@ -7,35 +7,35 @@ internal static partial class Interop
{
internal static partial class Globalization
{
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleName", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleName", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool GetLocaleName(string localeName, char* value, int valueLength);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoString", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoString", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool GetLocaleInfoString(string localeName, uint localeStringData, char* value, int valueLength, string? uiLocaleName = null);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleName", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleName", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool GetDefaultLocaleName(char* value, int valueLength);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsPredefinedLocale", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsPredefinedLocale", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool IsPredefinedLocale(string localeName);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleTimeFormat", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleTimeFormat", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool GetLocaleTimeFormat(string localeName, bool shortFormat, char* value, int valueLength);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoInt", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoInt", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool GetLocaleInfoInt(string localeName, uint localeNumberData, ref int value);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoGroupingSizes", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoGroupingSizes", StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool GetLocaleInfoGroupingSizes(string localeName, uint localeGroupingData, ref int primaryGroupSize, ref int secondaryGroupSize);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocales", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocales", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetLocales([Out] char[]? value, int valueLength);
}
}
diff --git a/src/libraries/Common/src/Interop/Interop.Normalization.cs b/src/libraries/Common/src/Interop/Interop.Normalization.cs
index 0b240884514..287bc028ead 100644
--- a/src/libraries/Common/src/Interop/Interop.Normalization.cs
+++ b/src/libraries/Common/src/Interop/Interop.Normalization.cs
@@ -8,10 +8,10 @@ internal static partial class Interop
{
internal static partial class Globalization
{
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsNormalized", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsNormalized", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int IsNormalized(NormalizationForm normalizationForm, char* src, int srcLen);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_NormalizeString", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_NormalizeString", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int NormalizeString(NormalizationForm normalizationForm, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
}
}
diff --git a/src/libraries/Common/src/Interop/Interop.Odbc.cs b/src/libraries/Common/src/Interop/Interop.Odbc.cs
index cad9bcab346..8e2a09f65c0 100644
--- a/src/libraries/Common/src/Interop/Interop.Odbc.cs
+++ b/src/libraries/Common/src/Interop/Interop.Odbc.cs
@@ -108,7 +108,7 @@ internal static partial class Interop
// SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute);
// #endif
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLColumnsW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */string CatalogName,
@@ -124,7 +124,7 @@ internal static partial class Interop
internal static partial ODBC32.SQLRETURN SQLDisconnect(
/*SQLHDBC*/IntPtr ConnectionHandle);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLDriverConnectW(
/*SQLHDBC*/OdbcConnectionHandle hdbc,
/*SQLHWND*/IntPtr hwnd,
@@ -141,7 +141,7 @@ internal static partial class Interop
/*SQLHANDLE*/IntPtr Handle,
/*SQLSMALLINT*/short CompletionType);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLExecDirectW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */string StatementText,
@@ -191,7 +191,7 @@ internal static partial class Interop
/*SQLINTEGER*/int BufferLength,
/*SQLINTEGER* */out int StringLength);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLGetDiagRecW(
/*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType,
/*SQLHANDLE*/OdbcHandle Handle,
@@ -202,7 +202,7 @@ internal static partial class Interop
/*SQLSMALLINT*/short BufferLength,
/*SQLSMALLINT* */out short TextLength);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLGetDiagFieldW(
/*SQLSMALLINT*/ ODBC32.SQL_HANDLE HandleType,
/*SQLHANDLE*/ OdbcHandle Handle,
@@ -256,13 +256,13 @@ internal static partial class Interop
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLSMALLINT* */out short ColumnCount);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLPrepareW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */string StatementText,
/*SQLINTEGER*/int TextLength);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLPrimaryKeysW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */string? CatalogName,
@@ -272,7 +272,7 @@ internal static partial class Interop
/*SQLCHAR* */string TableName,
/*SQLSMALLINT*/short NameLen3);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLProcedureColumnsW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */ string? CatalogName,
@@ -284,7 +284,7 @@ internal static partial class Interop
/*SQLCHAR* */ string? ColumnName,
/*SQLSMALLINT*/short NameLen4);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLProceduresW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */ string CatalogName,
@@ -299,7 +299,7 @@ internal static partial class Interop
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLLEN* */out IntPtr RowCount);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLSetConnectAttrW(
/*SQLHBDC*/OdbcConnectionHandle ConnectionHandle,
/*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
@@ -355,7 +355,7 @@ internal static partial class Interop
/*SQLPOINTER*/IntPtr Value,
/*SQLINTEGER*/int StringLength);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLSpecialColumnsW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLUSMALLINT*/ODBC32.SQL_SPECIALCOLS IdentifierType,
@@ -368,7 +368,7 @@ internal static partial class Interop
/*SQLUSMALLINT*/ODBC32.SQL_SCOPE Scope,
/*SQLUSMALLINT*/ ODBC32.SQL_NULLABILITY Nullable);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLStatisticsW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */string? CatalogName,
@@ -380,7 +380,7 @@ internal static partial class Interop
/*SQLUSMALLINT*/short Unique,
/*SQLUSMALLINT*/short Reserved);
- [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Odbc32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ODBC32.SQLRETURN SQLTablesW(
/*SQLHSTMT*/OdbcStatementHandle StatementHandle,
/*SQLCHAR* */string CatalogName,
diff --git a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs
index 6d223046927..3163a215f26 100644
--- a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs
+++ b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Globalization
{
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetTimeZoneDisplayName", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetTimeZoneDisplayName", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial ResultCode GetTimeZoneDisplayName(
string localeName,
string timeZoneId,
@@ -16,10 +16,10 @@ internal static partial class Interop
char* result,
int resultLength);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_WindowsIdToIanaId", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_WindowsIdToIanaId", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int WindowsIdToIanaId(string windowsId, IntPtr region, char* ianaId, int ianaIdLength);
- [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IanaIdToWindowsId", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IanaIdToWindowsId", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int IanaIdToWindowsId(string ianaId, char* windowsId, int windowsIdLength);
}
}
diff --git a/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ber.cs b/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ber.cs
index 2521b4082e7..32ce0da44ab 100644
--- a/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ber.cs
+++ b/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ber.cs
@@ -12,13 +12,13 @@ internal static partial class Interop
{
public const int ber_default_successful_return_code = 0;
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_alloc_t", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_alloc_t")]
public static partial IntPtr ber_alloc(int option);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_init", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_init")]
public static partial IntPtr ber_init(BerVal value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_free", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_free")]
public static partial IntPtr ber_free(IntPtr berelement, int option);
public static int ber_printf_emptyarg(SafeBerHandle berElement, string format, nuint tag)
@@ -46,19 +46,19 @@ internal static partial class Interop
}
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_start_seq", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_start_seq")]
public static partial int ber_start_seq(SafeBerHandle berElement, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_start_set", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_start_set")]
public static partial int ber_start_set(SafeBerHandle berElement, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_seq", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_seq")]
public static partial int ber_put_seq(SafeBerHandle berElement, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_set", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_set")]
public static partial int ber_put_set(SafeBerHandle berElement, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_null", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_null")]
public static partial int ber_put_null(SafeBerHandle berElement, nuint tag);
public static int ber_printf_int(SafeBerHandle berElement, string format, int value, nuint tag)
@@ -78,13 +78,13 @@ internal static partial class Interop
}
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_int", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_int")]
public static partial int ber_put_int(SafeBerHandle berElement, int value, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_enum", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_enum")]
public static partial int ber_put_enum(SafeBerHandle berElement, int value, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_boolean", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_boolean")]
public static partial int ber_put_boolean(SafeBerHandle berElement, int value, nuint tag);
public static int ber_printf_bytearray(SafeBerHandle berElement, string format, HGlobalMemHandle value, nuint length, nuint tag)
@@ -104,22 +104,22 @@ internal static partial class Interop
}
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_ostring", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_ostring")]
private static partial int ber_put_ostring(SafeBerHandle berElement, HGlobalMemHandle value, nuint length, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_string", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_string")]
private static partial int ber_put_string(SafeBerHandle berElement, HGlobalMemHandle value, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_bitstring", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_put_bitstring")]
private static partial int ber_put_bitstring(SafeBerHandle berElement, HGlobalMemHandle value, nuint length, nuint tag);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_flatten", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_flatten")]
public static partial int ber_flatten(SafeBerHandle berElement, ref IntPtr value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_bvfree", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_bvfree")]
public static partial int ber_bvfree(IntPtr value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_bvecfree", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_bvecfree")]
public static partial int ber_bvecfree(IntPtr value);
public static int ber_scanf_emptyarg(SafeBerHandle berElement, string format)
@@ -141,10 +141,10 @@ internal static partial class Interop
}
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_skip_tag", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_skip_tag")]
private static partial int ber_skip_tag(SafeBerHandle berElement, ref nuint len);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_null", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_null")]
private static partial int ber_get_null(SafeBerHandle berElement);
public static int ber_scanf_int(SafeBerHandle berElement, string format, ref int value)
@@ -164,13 +164,13 @@ internal static partial class Interop
}
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_int", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_int")]
private static partial int ber_get_int(SafeBerHandle berElement, ref int value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_enum", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_enum")]
private static partial int ber_get_enum(SafeBerHandle berElement, ref int value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_boolean", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_boolean")]
private static partial int ber_get_boolean(SafeBerHandle berElement, ref int value);
public static int ber_scanf_bitstring(SafeBerHandle berElement, string format, ref IntPtr value, ref uint bitLength)
@@ -182,7 +182,7 @@ internal static partial class Interop
return res;
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_stringb", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_stringb")]
private static partial int ber_get_stringb(SafeBerHandle berElement, ref IntPtr value, ref nuint bitLength);
public static int ber_scanf_ptr(SafeBerHandle berElement, string format, ref IntPtr value)
@@ -191,7 +191,7 @@ internal static partial class Interop
return ber_get_stringal(berElement, ref value);
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_stringal", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ber_get_stringal")]
private static partial int ber_get_stringal(SafeBerHandle berElement, ref IntPtr value);
public static int ber_printf_berarray(SafeBerHandle berElement, string format, IntPtr value, nuint tag)
diff --git a/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs
index 263d49c91e2..ed4c6339dc2 100644
--- a/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs
+++ b/src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs
@@ -76,149 +76,190 @@ internal static partial class Interop
ldap_get_option_int(IntPtr.Zero, LdapOption.LDAP_OPT_DEBUG_LEVEL, ref unused);
}
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_initialize", CharSet = CharSet.Ansi, SetLastError = true)]
- public static partial int ldap_initialize(out IntPtr ld, string uri);
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_initialize", SetLastError = true)]
+ public static partial int ldap_initialize(out IntPtr ld, [MarshalAs(UnmanagedType.LPUTF8Str)] string uri);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_unbind_ext_s", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_unbind_ext_s")]
public static partial int ldap_unbind_ext_s(IntPtr ld, ref IntPtr serverctrls, ref IntPtr clientctrls);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_dn", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_dn")]
public static partial IntPtr ldap_get_dn(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option")]
public static partial int ldap_get_option_bool(ConnectionHandle ldapHandle, LdapOption option, ref bool outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option")]
public static unsafe partial int ldap_get_option_secInfo(ConnectionHandle ldapHandle, LdapOption option, void* outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option")]
public static partial int ldap_get_option_sechandle(ConnectionHandle ldapHandle, LdapOption option, ref SecurityHandle outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option")]
private static partial int ldap_get_option_int(IntPtr ldapHandle, LdapOption option, ref int outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option")]
public static partial int ldap_get_option_int(ConnectionHandle ldapHandle, LdapOption option, ref int outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_option")]
public static partial int ldap_get_option_ptr(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_values_len", CharSet = CharSet.Ansi)]
- public static partial IntPtr ldap_get_values_len(ConnectionHandle ldapHandle, IntPtr result, string name);
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_get_values_len")]
+ public static partial IntPtr ldap_get_values_len(ConnectionHandle ldapHandle, IntPtr result, [MarshalAs(UnmanagedType.LPUTF8Str)] string name);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_result", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_result", SetLastError = true)]
public static partial int ldap_result(ConnectionHandle ldapHandle, int messageId, int all, in LDAP_TIMEVAL timeout, ref IntPtr Mesage);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_result2error", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_result2error")]
public static partial int ldap_result2error(ConnectionHandle ldapHandle, IntPtr result, int freeIt);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_search_ext", CharSet = CharSet.Ansi)]
- public static partial int ldap_search(ConnectionHandle ldapHandle, string dn, int scope, string filter, IntPtr attributes, bool attributeOnly, IntPtr servercontrol, IntPtr clientcontrol, int timelimit, int sizelimit, ref int messageNumber);
-
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_search_ext")]
+ public static partial int ldap_search(
+ ConnectionHandle ldapHandle,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string dn,
+ int scope,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string filter,
+ IntPtr attributes,
+ bool attributeOnly,
+ IntPtr servercontrol,
+ IntPtr clientcontrol,
+ int timelimit,
+ int sizelimit,
+ ref int messageNumber);
+
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", SetLastError = true)]
public static partial int ldap_set_option_bool(ConnectionHandle ld, LdapOption option, bool value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option")]
public static partial int ldap_set_option_clientcert(ConnectionHandle ldapHandle, LdapOption option, QUERYCLIENTCERT outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option")]
public static partial int ldap_set_option_servercert(ConnectionHandle ldapHandle, LdapOption option, VERIFYSERVERCERT outValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", SetLastError = true)]
public static partial int ldap_set_option_int(ConnectionHandle ld, LdapOption option, ref int inValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option")]
public static partial int ldap_set_option_ptr(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr inValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", CharSet = CharSet.Ansi)]
- public static partial int ldap_set_option_string(ConnectionHandle ldapHandle, LdapOption option, string inValue);
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option")]
+ public static partial int ldap_set_option_string(ConnectionHandle ldapHandle, LdapOption option, [MarshalAs(UnmanagedType.LPUTF8Str)] string inValue);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_set_option")]
public static partial int ldap_set_option_referral(ConnectionHandle ldapHandle, LdapOption option, ref LdapReferralCallback outValue);
// Note that ldap_start_tls_s has a different signature across Windows LDAP and OpenLDAP
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_start_tls_s", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_start_tls_s")]
public static partial int ldap_start_tls(ConnectionHandle ldapHandle, IntPtr serverControls, IntPtr clientControls);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_result", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_result")]
public static partial int ldap_parse_result(ConnectionHandle ldapHandle, IntPtr result, ref int serverError, ref IntPtr dn, ref IntPtr message, ref IntPtr referral, ref IntPtr control, byte freeIt);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_result", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_result")]
public static partial int ldap_parse_result_referral(ConnectionHandle ldapHandle, IntPtr result, IntPtr serverError, IntPtr dn, IntPtr message, ref IntPtr referral, IntPtr control, byte freeIt);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_extended_result", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_extended_result")]
public static partial int ldap_parse_extended_result(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr oid, ref IntPtr data, byte freeIt);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_reference", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_parse_reference")]
public static partial int ldap_parse_reference(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr referrals, IntPtr ServerControls, byte freeIt);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_sasl_bind_s", CharSet = CharSet.Ansi)]
- internal static partial int ldap_sasl_bind(ConnectionHandle ld, string dn, string mechanism, in BerVal cred, IntPtr serverctrls, IntPtr clientctrls, IntPtr servercredp);
-
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_sasl_interactive_bind_s", CharSet = CharSet.Ansi)]
- internal static partial int ldap_sasl_interactive_bind(ConnectionHandle ld, string dn, string mechanism, IntPtr serverctrls, IntPtr clientctrls, uint flags, LDAP_SASL_INTERACT_PROC proc, IntPtr defaults);
-
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_err2string", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_sasl_bind_s")]
+ internal static partial int ldap_sasl_bind(
+ ConnectionHandle ld,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string dn,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string mechanism,
+ in BerVal cred,
+ IntPtr serverctrls,
+ IntPtr clientctrls,
+ IntPtr servercredp);
+
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_sasl_interactive_bind_s")]
+ internal static partial int ldap_sasl_interactive_bind(
+ ConnectionHandle ld,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string dn,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string mechanism,
+ IntPtr serverctrls,
+ IntPtr clientctrls,
+ uint flags,
+ LDAP_SASL_INTERACT_PROC proc,
+ IntPtr defaults);
+
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_err2string")]
public static partial IntPtr ldap_err2string(int err);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_extended_operation", CharSet = CharSet.Ansi)]
- public static partial int ldap_extended_operation(ConnectionHandle ldapHandle, string oid, in BerVal data, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_extended_operation")]
+ public static partial int ldap_extended_operation(ConnectionHandle ldapHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string oid, in BerVal data, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_first_attribute", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_first_attribute")]
public static partial IntPtr ldap_first_attribute(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr address);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_first_entry", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_first_entry")]
public static partial IntPtr ldap_first_entry(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_first_reference", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_first_reference")]
public static partial IntPtr ldap_first_reference(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_create_sort_control", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_create_sort_control")]
public static partial int ldap_create_sort_control(ConnectionHandle handle, IntPtr keys, byte critical, ref IntPtr control);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_control_free", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_control_free")]
public static partial int ldap_control_free(IntPtr control);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_controls_free", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_controls_free")]
public static partial int ldap_controls_free(IntPtr value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_value_free", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_value_free")]
public static partial int ldap_value_free(IntPtr value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_value_free_len", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_value_free_len")]
public static partial IntPtr ldap_value_free_len(IntPtr berelement);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_memfree", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_memfree")]
public static partial void ldap_memfree(IntPtr value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_msgfree", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_msgfree")]
public static partial void ldap_msgfree(IntPtr value);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_modify_ext", CharSet = CharSet.Ansi)]
- public static partial int ldap_modify(ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_modify_ext")]
+ public static partial int ldap_modify(ConnectionHandle ldapHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_next_attribute", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_next_attribute")]
public static partial IntPtr ldap_next_attribute(ConnectionHandle ldapHandle, IntPtr result, IntPtr address);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_next_entry", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_next_entry")]
public static partial IntPtr ldap_next_entry(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_next_reference", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_next_reference")]
public static partial IntPtr ldap_next_reference(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_abandon", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_abandon")]
public static partial int ldap_abandon(ConnectionHandle ldapHandle, int messagId);
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_add_ext", CharSet = CharSet.Ansi)]
- public static partial int ldap_add(ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
-
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_delete_ext", CharSet = CharSet.Ansi)]
- public static partial int ldap_delete_ext(ConnectionHandle ldapHandle, string dn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
-
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_rename", CharSet = CharSet.Ansi)]
- public static partial int ldap_rename(ConnectionHandle ldapHandle, string dn, string newRdn, string newParentDn, int deleteOldRdn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
-
- [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_compare_ext", CharSet = CharSet.Ansi)]
- public static partial int ldap_compare(ConnectionHandle ldapHandle, string dn, string attributeName, in BerVal binaryValue, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_add_ext")]
+ public static partial int ldap_add(ConnectionHandle ldapHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
+
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_delete_ext")]
+ public static partial int ldap_delete_ext(ConnectionHandle ldapHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string dn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
+
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_rename")]
+ public static partial int ldap_rename(
+ ConnectionHandle ldapHandle,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string dn,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string newRdn,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string newParentDn,
+ int deleteOldRdn,
+ IntPtr servercontrol,
+ IntPtr clientcontrol,
+ ref int messageNumber);
+
+ [GeneratedDllImport(Libraries.OpenLdap, EntryPoint = "ldap_compare_ext")]
+ public static partial int ldap_compare(
+ ConnectionHandle ldapHandle,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string dn,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string attributeName,
+ in BerVal binaryValue,
+ IntPtr servercontrol,
+ IntPtr clientcontrol,
+ ref int messageNumber);
}
}
diff --git a/src/libraries/Common/src/Interop/Linux/System.Native/Interop.INotify.cs b/src/libraries/Common/src/Interop/Linux/System.Native/Interop.INotify.cs
index f93f542f722..8f0936bf1c3 100644
--- a/src/libraries/Common/src/Interop/Linux/System.Native/Interop.INotify.cs
+++ b/src/libraries/Common/src/Interop/Linux/System.Native/Interop.INotify.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyInit", SetLastError = true)]
internal static partial SafeFileHandle INotifyInit();
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyAddWatch", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyAddWatch", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int INotifyAddWatch(SafeFileHandle fd, string pathName, uint mask);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyRemoveWatch", SetLastError = true)]
diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs
index b5d64a92606..6233a4048d2 100644
--- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs
+++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs
@@ -63,7 +63,7 @@ internal static partial class Interop
/// <param name="encoding">The encoding of the str variable. This should be UTF 8 for OS X</param>
/// <returns>Returns a pointer to a CFString on success; otherwise, returns IntPtr.Zero</returns>
/// <remarks>For *nix systems, the CLR maps ANSI to UTF-8, so be explicit about that</remarks>
- [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary, StringMarshalling = StringMarshalling.Utf8)]
private static partial SafeCreateHandle CFStringCreateWithCString(
IntPtr allocator,
string str,
@@ -77,7 +77,7 @@ internal static partial class Interop
/// <param name="encoding">The encoding of the str variable. This should be UTF 8 for OS X</param>
/// <returns>Returns a pointer to a CFString on success; otherwise, returns IntPtr.Zero</returns>
/// <remarks>For *nix systems, the CLR maps ANSI to UTF-8, so be explicit about that</remarks>
- [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary, StringMarshalling = StringMarshalling.Utf8)]
private static partial SafeCreateHandle CFStringCreateWithCString(
IntPtr allocator,
IntPtr str,
diff --git a/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs b/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs
index db2675f73a5..f4402692f2c 100644
--- a/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs
+++ b/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs
@@ -99,7 +99,7 @@ internal static partial class Interop
/// <param name="flags">Flags to say what kind of events should be sent through this stream.</param>
/// <returns>On success, returns a pointer to an FSEventStream object; otherwise, returns IntPtr.Zero</returns>
/// <remarks>For *nix systems, the CLR maps ANSI to UTF-8, so be explicit about that</remarks>
- [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary, StringMarshalling = StringMarshalling.Utf8)]
internal static unsafe partial SafeEventStreamHandle FSEventStreamCreate(
IntPtr allocator,
delegate* unmanaged<FSEventStreamRef, IntPtr, size_t, byte**, FSEventStreamEventFlags*, FSEventStreamEventId*, void> callback,
diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libc.cs
index 51cf2ac16b7..5e9f0e9e413 100644
--- a/src/libraries/Common/src/Interop/OSX/Interop.libc.cs
+++ b/src/libraries/Common/src/Interop/OSX/Interop.libc.cs
@@ -23,7 +23,7 @@ internal static partial class Interop
public const uint ATTR_CMN_CRTIME = 0x00000200;
}
- [GeneratedDllImport(Libraries.libc, EntryPoint = "setattrlist", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.libc, EntryPoint = "setattrlist", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static unsafe partial int setattrlist(string path, AttrList* attrList, void* attrBuf, nint attrBufSize, CULong options);
internal const uint FSOPT_NOFOLLOW = 0x00000001;
diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs
index c338e87bfc0..6dbd15a4d29 100644
--- a/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs
+++ b/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs
@@ -16,9 +16,9 @@ internal static partial class Interop
public nint patchVersion;
}
- [GeneratedDllImport(Libraries.libobjc, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.libobjc, StringMarshalling = StringMarshalling.Utf8)]
private static partial IntPtr objc_getClass(string className);
- [GeneratedDllImport(Libraries.libobjc, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.libobjc, StringMarshalling = StringMarshalling.Utf8)]
private static partial IntPtr sel_getUid(string selector);
[GeneratedDllImport(Libraries.libobjc, EntryPoint = "objc_msgSend")]
private static partial IntPtr intptr_objc_msgSend(IntPtr basePtr, IntPtr selector);
diff --git a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.cs b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.cs
index 2a41f989f77..580111cbabb 100644
--- a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.cs
+++ b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SearchPath", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SearchPath", StringMarshalling = StringMarshalling.Utf8)]
internal static partial string? SearchPath(NSSearchPathDirectory folderId);
internal enum NSSearchPathDirectory
diff --git a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.iOS.cs b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.iOS.cs
index 3b113c29c94..f4afa274687 100644
--- a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.iOS.cs
+++ b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.iOS.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SearchPath_TempDirectory", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SearchPath_TempDirectory", StringMarshalling = StringMarshalling.Utf8)]
internal static partial string SearchPathTempDirectory();
}
}
diff --git a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.iOSSupportVersion.cs b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.iOSSupportVersion.cs
index 5a7af296163..d429c27ae87 100644
--- a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.iOSSupportVersion.cs
+++ b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.iOSSupportVersion.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_iOSSupportVersion", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_iOSSupportVersion", StringMarshalling = StringMarshalling.Utf8)]
internal static partial string iOSSupportVersion();
}
}
diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs
index ebe9e3af8d2..48766e4b4f5 100644
--- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs
+++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs
@@ -20,14 +20,14 @@ internal static partial class Interop
IntPtr item,
out SafeKeychainHandle keychain);
- [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SecKeychainCreate", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SecKeychainCreate", StringMarshalling = StringMarshalling.Utf8)]
private static unsafe partial int AppleCryptoNative_SecKeychainCreateTemporary(
string path,
int utf8PassphraseLength,
byte* utf8Passphrase,
out SafeTemporaryKeychainHandle keychain);
- [GeneratedDllImport(Libraries.AppleCryptoNative, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AppleCryptoNative, StringMarshalling = StringMarshalling.Utf8)]
private static partial int AppleCryptoNative_SecKeychainCreate(
string path,
int utf8PassphraseLength,
@@ -40,7 +40,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.AppleCryptoNative)]
private static partial int AppleCryptoNative_SecKeychainCopyDefault(out SafeKeychainHandle keychain);
- [GeneratedDllImport(Libraries.AppleCryptoNative, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.AppleCryptoNative, StringMarshalling = StringMarshalling.Utf8)]
private static partial int AppleCryptoNative_SecKeychainOpen(
string keychainPath,
out SafeKeychainHandle keychain);
diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs
index af6596efd51..c728f15917e 100644
--- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs
+++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs
@@ -111,7 +111,7 @@ internal static partial class Interop
SafeSslHandle sslHandle,
SafeCreateHandle cfCertRefs);
- [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, StringMarshalling = StringMarshalling.Utf8)]
private static partial int AppleCryptoNative_SslSetTargetName(
SafeSslHandle sslHandle,
string targetName,
diff --git a/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs b/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs
index 0752826b4ea..e7aa1b1e4db 100644
--- a/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Serial
{
- [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_SerialPortOpen", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_SerialPortOpen", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial SafeSerialDeviceHandle SerialPortOpen(string name);
[GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_SerialPortClose", SetLastError = true)]
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs
index 70728287b22..82c32b02cf5 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs
@@ -15,7 +15,7 @@ internal static partial class Interop
R_OK = 4, /* Check for read */
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Access", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Access", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int Access(string path, AccessMode mode);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs
index 29e072b856b..2184935f742 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChDir", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChDir", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int ChDir(string path);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChMod.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChMod.cs
index 044f8cd414a..423aa455022 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChMod.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChMod.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChMod", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChMod", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int ChMod(string path, int mode);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.DynamicLoad.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.DynamicLoad.cs
index a6ccd9121d8..33f36acfc89 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.DynamicLoad.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.DynamicLoad.cs
@@ -8,13 +8,13 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
- [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_LoadLibrary", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_LoadLibrary", StringMarshalling = StringMarshalling.Utf8)]
internal static partial IntPtr LoadLibrary(string filename);
[GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetProcAddress")]
internal static partial IntPtr GetProcAddress(IntPtr handle, byte* symbol);
- [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetProcAddress", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetProcAddress", StringMarshalling = StringMarshalling.Utf8)]
internal static partial IntPtr GetProcAddress(IntPtr handle, string symbol);
[GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_FreeLibrary")]
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs
index 295caba93c2..9454d42adb7 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs
@@ -40,7 +40,7 @@ internal static partial class Interop
}
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ForkAndExecProcess", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ForkAndExecProcess", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
private static unsafe partial int ForkAndExecProcess(
string filename, byte** argv, byte** envp, string? cwd,
int redirectStdin, int redirectStdout, int redirectStderr,
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDefaultTimeZone.Android.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDefaultTimeZone.Android.cs
index 2da78b9a47f..1029cff060c 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDefaultTimeZone.Android.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDefaultTimeZone.Android.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetDefaultTimeZone", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetDefaultTimeZone", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial string? GetDefaultTimeZone();
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs
index 467ea92ba20..583288b65b3 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
- [GeneratedDllImport(Interop.Libraries.SystemNative, CharSet = CharSet.Ansi, EntryPoint = "SystemNative_GetEnv")]
+ [GeneratedDllImport(Interop.Libraries.SystemNative, StringMarshalling = StringMarshalling.Utf8, EntryPoint = "SystemNative_GetEnv")]
internal static unsafe partial IntPtr GetEnv(string name);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroupList.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroupList.cs
index 1b00355f570..973a704a7c2 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroupList.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroupList.cs
@@ -43,7 +43,7 @@ internal static partial class Interop
} while (true);
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroupList", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroupList", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
private static unsafe partial int GetGroupList(string name, uint group, uint* groups, int* ngroups);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerUserName.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerUserName.cs
index 9dea586f1d6..b24072f71d6 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerUserName.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerUserName.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerUserName", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerUserName", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial string GetPeerUserName(SafeHandle socket);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs
index ddcd49790aa..52fc19fe772 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
/// <summary>
/// Returns the full path to the executable for the current process, resolving symbolic links.
/// </summary>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessPath", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessPath", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial string? GetProcessPath();
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs
index 06b431cbffd..f30235d8730 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs
@@ -23,7 +23,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwUidR", SetLastError = false)]
internal static unsafe partial int GetPwUidR(uint uid, out Passwd pwd, byte* buf, int bufLen);
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwNamR", CharSet = CharSet.Ansi, SetLastError = false)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwNamR", StringMarshalling = StringMarshalling.Utf8, SetLastError = false)]
internal static unsafe partial int GetPwNamR(string name, out Passwd pwd, byte* buf, int bufLen);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs
index cf47ba34fe1..994e4dcc443 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixRelease", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixRelease", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
public static partial string GetUnixRelease();
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs
index 3c130da95f5..35503c185b2 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixVersion", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixVersion", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
private static partial int GetUnixVersion(byte[] version, ref int capacity);
internal static string GetUnixVersion()
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.HostEntry.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.HostEntry.cs
index 360ae8a340a..531c5ce82e9 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.HostEntry.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.HostEntry.cs
@@ -32,7 +32,7 @@ internal static partial class Interop
internal int IPAddressCount; // Number of IP addresses in the list
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostEntryForName", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostEntryForName", StringMarshalling = StringMarshalling.Utf8)]
internal static unsafe partial int GetHostEntryForName(string address, AddressFamily family, HostEntry* entry);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FreeHostEntry")]
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InitializeTerminalAndSignalHandling.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InitializeTerminalAndSignalHandling.cs
index a9d4b29d235..01c04149477 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InitializeTerminalAndSignalHandling.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InitializeTerminalAndSignalHandling.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeTerminalAndSignalHandling", SetLastError = true)]
internal static partial bool InitializeTerminalAndSignalHandling();
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetKeypadXmit", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetKeypadXmit", StringMarshalling = StringMarshalling.Utf8)]
internal static partial void SetKeypadXmit(string terminfoString);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InterfaceNameToIndex.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InterfaceNameToIndex.cs
index 7d0c0dd64c2..7a6af166ed5 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InterfaceNameToIndex.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.InterfaceNameToIndex.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InterfaceNameToIndex", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InterfaceNameToIndex", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
public static partial uint InterfaceNameToIndex(string name);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs
index a5bc36dfa3d..04e18dc0da3 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs
@@ -14,7 +14,7 @@ internal static partial class Interop
UF_HIDDEN = 0x8000
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflags", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflags", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int LChflags(string path, uint flags);
internal static readonly bool CanSetHiddenFlag = (LChflagsCanSetHiddenFlag() != 0);
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Link.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Link.cs
index 6fca0a14d00..c09c4e2dfc7 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Link.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Link.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Link", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Link", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int Link(string source, string link);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Open.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Open.cs
index 2024ee61694..3daa76c3bfc 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Open.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Open.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Open", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Open", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial SafeFileHandle Open(string filename, OpenFlags flags, int mode);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs
index 4ed5bbb552d..6485745c34d 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs
@@ -20,7 +20,7 @@ internal static partial class Interop
PC_VDISABLE = 9,
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PathConf", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PathConf", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
private static partial int PathConf(string path, PathConfName name);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs
index 37a89d871c2..9bac51a9106 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs
@@ -53,7 +53,7 @@ internal static partial class Interop
}
}
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial IntPtr OpenDir(string path);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetReadDirRBufferSize", SetLastError = false)]
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RealPath.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RealPath.cs
index 8ff4105dae6..fc4c934ead3 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RealPath.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RealPath.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
/// </summary>
/// <param name="path">The path to the file system object</param>
/// <returns>Returns the result string on success and null on failure</returns>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RealPath", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RealPath", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial string RealPath(string path);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Rename.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Rename.cs
index 741f4000627..9d5881713c5 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Rename.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Rename.cs
@@ -17,7 +17,7 @@ internal static partial class Interop
/// <returns>
/// Returns 0 on success; otherwise, returns -1
/// </returns>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Rename", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Rename", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int Rename(string oldPath, string newPath);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Rename", SetLastError = true)]
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RmDir.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RmDir.cs
index 24b04035262..2fce1f19ed9 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RmDir.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RmDir.cs
@@ -15,7 +15,7 @@ internal static partial class Interop
/// <returns>
/// Returns 0 on success; otherwise, returns -1
/// </returns>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RmDir", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RmDir", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int RmDir(string path);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SNPrintF.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SNPrintF.cs
index 47a20fd4357..41e403ecf76 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SNPrintF.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SNPrintF.cs
@@ -26,7 +26,7 @@ internal static partial class Interop
/// success; if the return value is equal to the size then the result may have been truncated.
/// On failure, returns a negative value.
/// </returns>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static unsafe partial int SNPrintF(byte* str, int size, string format, string arg1);
/// <summary>
@@ -47,7 +47,7 @@ internal static partial class Interop
/// success; if the return value is equal to the size then the result may have been truncated.
/// On failure, returns a negative value.
/// </returns>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static unsafe partial int SNPrintF(byte* str, int size, string format, int arg1);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ShmOpen.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ShmOpen.cs
index 7d559cb34f4..f7f100cda2a 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ShmOpen.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ShmOpen.cs
@@ -8,10 +8,10 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmOpen", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmOpen", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial SafeFileHandle ShmOpen(string name, OpenFlags flags, int mode);
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int ShmUnlink(string name);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.cs
index 4f8193e8595..3da48e827fa 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.cs
@@ -56,10 +56,10 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat", SetLastError = true)]
internal static partial int FStat(SafeHandle fd, out FileStatus output);
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int Stat(string path, out FileStatus output);
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int LStat(string path, out FileStatus output);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs
index d0721eef785..9e97fd87a97 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SymLink", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SymLink", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int SymLink(string target, string linkPath);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs
index 11284f10738..47576743865 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs
@@ -29,7 +29,7 @@ internal static partial class Interop
/// </param>
/// <param name="message">The message to put in the log entry</param>
/// <param name="arg1">Like printf, the argument is passed to the variadic part of the C++ function to wildcards in the message</param>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysLog", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysLog", StringMarshalling = StringMarshalling.Utf8)]
internal static partial void SysLog(SysLogPriority priority, string message, string arg1);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UTimensat.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UTimensat.cs
index dd9ab901450..d1788ee8154 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UTimensat.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UTimensat.cs
@@ -22,7 +22,7 @@ internal static partial class Interop
/// <returns>
/// Returns 0 on success; otherwise, returns -1
/// </returns>
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UTimensat", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UTimensat", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static unsafe partial int UTimensat(string path, TimeSpec* times);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Unlink.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Unlink.cs
index fed2f15688a..ec2c5444de7 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Unlink.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Unlink.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
- [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Unlink", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Unlink", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
internal static partial int Unlink(string pathname);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs
index c8aece74e58..16f342d7513 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs
@@ -58,7 +58,7 @@ internal static partial class Interop
SafeGssNameHandle desiredName,
out SafeGssCredHandle outputCredHandle);
- [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitiateCredWithPassword", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitiateCredWithPassword", StringMarshalling = StringMarshalling.Utf8)]
internal static partial Status InitiateCredWithPassword(
out Status minorStatus,
bool isNtlm,
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.Nid.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.Nid.cs
index 178f800f4f8..4d486460685 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.Nid.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.Nid.cs
@@ -15,7 +15,7 @@ internal static partial class Interop
internal const int NID_undef = 0;
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Nid", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Nid", StringMarshalling = StringMarshalling.Utf8)]
private static partial int ObjTxt2Nid(string oid);
internal static int ResolveRequiredNid(string oid)
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.cs
index 029f9a688aa..efbca475dc5 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.cs
@@ -12,13 +12,13 @@ internal static partial class Interop
{
internal static partial class Crypto
{
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Obj", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Obj", StringMarshalling = StringMarshalling.Utf8)]
internal static partial SafeAsn1ObjectHandle ObjTxt2Obj(string s);
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjObj2Txt")]
private static unsafe partial int ObjObj2Txt(byte* buf, int buf_len, IntPtr a);
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetObjectDefinitionByName", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetObjectDefinitionByName", StringMarshalling = StringMarshalling.Utf8)]
private static partial IntPtr CryptoNative_GetObjectDefinitionByName(string friendlyName);
internal static IntPtr GetObjectDefinitionByName(string friendlyName)
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.BIO.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.BIO.cs
index 64c1be63398..159a6ef2dfb 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.BIO.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.BIO.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CreateMemoryBio")]
internal static partial SafeBioHandle CreateMemoryBio();
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioNewFile", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioNewFile", StringMarshalling = StringMarshalling.Utf8)]
internal static partial SafeBioHandle BioNewFile(string filename, string mode);
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioDestroy")]
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.CheckX509Hostname_IntPtr.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.CheckX509Hostname_IntPtr.cs
index 5b3ad7cbff5..b139a446901 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.CheckX509Hostname_IntPtr.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.CheckX509Hostname_IntPtr.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypto
{
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname", StringMarshalling = StringMarshalling.Utf8)]
internal static partial int CheckX509Hostname(
IntPtr x509,
string hostname,
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Crypto.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Crypto.cs
index 633d6b09e8a..01960008575 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Crypto.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Crypto.cs
@@ -99,10 +99,10 @@ internal static partial class Interop
int second,
[MarshalAs(UnmanagedType.Bool)] bool isDst);
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509IpAddress", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509IpAddress", StringMarshalling = StringMarshalling.Utf8)]
internal static partial int CheckX509IpAddress(SafeX509Handle x509, byte[] addressBytes, int addressLen, string hostname, int cchHostname);
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname", StringMarshalling = StringMarshalling.Utf8)]
internal static partial int CheckX509Hostname(SafeX509Handle x509, string hostname, int cchHostname);
internal static byte[] GetAsn1StringBytes(IntPtr asn1)
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs
index 0b23fc788b9..3dd314b9883 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
{
internal static partial class Crypto
{
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByKeyParameters", StringMarshalling = StringMarshalling.Utf8)]
private static partial int EcKeyCreateByKeyParameters(
out SafeEcKeyHandle key,
string oid,
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs
index 8051dc5bfd3..7ad6d523099 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Crypto
{
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid", StringMarshalling = StringMarshalling.Utf8)]
private static partial SafeEcKeyHandle CryptoNative_EcKeyCreateByOid(string oid);
internal static SafeEcKeyHandle? EcKeyCreateByOid(string oid)
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LookupFriendlyNameByOid.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LookupFriendlyNameByOid.cs
index db1b67c63bc..8d82c6cca2f 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LookupFriendlyNameByOid.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LookupFriendlyNameByOid.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypto
{
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_LookupFriendlyNameByOid", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_LookupFriendlyNameByOid", StringMarshalling = StringMarshalling.Utf8)]
internal static partial int LookupFriendlyNameByOid(string oidValue, ref IntPtr friendlyNamePtr);
}
}
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs
index 86ec6c33191..81f12a4135c 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs
@@ -34,7 +34,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspResponseDestroy")]
internal static partial void OcspResponseDestroy(IntPtr ocspReq);
- [GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, StringMarshalling = StringMarshalling.Utf8)]
private static partial int CryptoNative_X509ChainGetCachedOcspStatus(
SafeX509StoreCtxHandle ctx,
string cachePath,
@@ -53,7 +53,7 @@ internal static partial class Interop
return response;
}
- [GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, StringMarshalling = StringMarshalling.Utf8)]
private static partial int CryptoNative_X509ChainVerifyOcsp(
SafeX509StoreCtxHandle ctx,
SafeOcspRequestHandle req,
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs
index d599fe7ecf7..8755c4a46cc 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs
@@ -53,7 +53,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetVersion")]
internal static partial IntPtr SslGetVersion(SafeSslHandle ssl);
- [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetTlsExtHostName", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetTlsExtHostName", StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool SslSetTlsExtHostName(SafeSslHandle ssl, string host);
diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Stack.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Stack.cs
index f3ee9c3e22b..7a75fb46c3c 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Stack.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Stack.cs
@@ -35,7 +35,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackField")]
internal static partial IntPtr GetX509StackField(SafeSharedX509StackHandle stack, int loc);
- [GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.CryptoNative, StringMarshalling = StringMarshalling.Utf8)]
private static partial int CryptoNative_X509StackAddDirectoryStore(SafeX509StackHandle stack, string storePath);
internal static void X509StackAddDirectoryStore(SafeX509StackHandle stack, string storePath)
diff --git a/src/libraries/Common/src/Interop/Windows/Activeds/Interop.ADsOpenObject.cs b/src/libraries/Common/src/Interop/Windows/Activeds/Interop.ADsOpenObject.cs
index 784956800bb..6b99600ee05 100644
--- a/src/libraries/Common/src/Interop/Windows/Activeds/Interop.ADsOpenObject.cs
+++ b/src/libraries/Common/src/Interop/Windows/Activeds/Interop.ADsOpenObject.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Activeds
{
- [GeneratedDllImport(Interop.Libraries.Activeds, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Activeds, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int ADsOpenObject(string path, string? userName, string? password, int flags, ref Guid iid, out IntPtr ppObject);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ClearEventLog.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ClearEventLog.cs
index 4faa6be43bd..1c4a03809fa 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ClearEventLog.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ClearEventLog.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ClearEventLogW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ClearEventLogW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial bool ClearEventLog(SafeEventLogReadHandle hEventLog, string lpBackupFileName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs
index 53dfdc4f0cd..8ea00976b98 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
internal static partial class Advapi32
{
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertSecurityDescriptorToStringSecurityDescriptorW",
- CharSet = CharSet.Unicode, SetLastError = true)]
+ SetLastError = true)]
internal static partial bool ConvertSdToStringSd(
byte[] securityDescriptor,
/* DWORD */ uint requestedRevision,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSidToStringSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSidToStringSid.cs
index 97cd4f0f37d..ece6aad42eb 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSidToStringSid.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSidToStringSid.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ConvertSidToStringSidW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ConvertSidToStringSidW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial BOOL ConvertSidToStringSid(IntPtr sid, out string stringSid);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs
index 82dc0d34c76..4e173d112f1 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
internal static partial class Advapi32
{
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW",
- CharSet = CharSet.Unicode, SetLastError = true)]
+ SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool ConvertStringSdToSd(
string stringSd,
/* DWORD */ uint stringSdRevision,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs
index 7abb40acf06..794f4312f27 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool ConvertStringSecurityDescriptorToSecurityDescriptor(
string StringSecurityDescriptor,
int StringSDRevision,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSidToSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSidToSid.cs
index 6f0ce7b6b38..f5bba0ba8c0 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSidToSid.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSidToSid.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial BOOL ConvertStringSidToSid(
string stringSid,
out IntPtr ByteArray);
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs
index df499a80c73..7a427352261 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CreateProcessWithLogonW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CreateProcessWithLogonW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool CreateProcessWithLogonW(
string userName,
string domain,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateService.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateService.cs
index 7e8160af6cd..5ee78eb9256 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateService.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateService.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CreateServiceW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CreateServiceW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr CreateService(SafeServiceHandle databaseHandle, string serviceName, string displayName, int access, int serviceType,
int startType, int errorControl, string binaryPath, string loadOrderGroup, IntPtr pTagId, string dependencies,
string servicesStartName, string password);
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs
index bffdc2007e9..b1515452c4b 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs
@@ -20,7 +20,7 @@ internal static partial class Interop
CRYPT_VERIFYCONTEXT = 0xF0000000 // CRYPT_VERIFYCONTEXT
}
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial bool CryptAcquireContext(
out SafeProvHandle phProv,
string? szContainer,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext_IntPtr.cs
index 142b7ec549b..1af84f68a51 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext_IntPtr.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext_IntPtr.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool CryptAcquireContext(
out IntPtr psafeProvHandle,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetDefaultProvider.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetDefaultProvider.cs
index 92d048b9be0..9535769ff6c 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetDefaultProvider.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetDefaultProvider.cs
@@ -15,7 +15,7 @@ internal static partial class Interop
CRYPT_USER_DEFAULT = 0x00000002
}
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptGetDefaultProviderW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptGetDefaultProviderW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial bool CryptGetDefaultProvider(
int dwProvType,
IntPtr pdwReserved,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSignHash.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSignHash.cs
index dd7a12c30b3..a2abbc43e45 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSignHash.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSignHash.cs
@@ -24,7 +24,7 @@ internal static partial class Interop
CRYPT_X931_FORMAT = 0x00000004, // Not supported
}
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptSignHashW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptSignHashW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial bool CryptSignHash(
SafeHashHandle hHash,
KeySpec dwKeySpec,
@@ -33,7 +33,7 @@ internal static partial class Interop
byte[]? pbSignature,
ref int pdwSigLen);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptVerifySignatureW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptVerifySignatureW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial bool CryptVerifySignature(
SafeHashHandle hHash,
byte[] pbSignature,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs
index 2b600071024..7ac904cc8f3 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use EncryptFile.
/// </summary>
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool EncryptFilePrivate(string lpFileName);
internal static bool EncryptFile(string path)
@@ -23,7 +23,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DecryptFile.
/// </summary>
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool DecryptFileFilePrivate(
string lpFileName,
int dwReserved);
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs
index 57f899ede3c..cadfd0741b9 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EnumDependentServicesW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EnumDependentServicesW", SetLastError = true)]
internal static partial bool EnumDependentServices(
SafeServiceHandle serviceHandle,
int serviceState,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs
index 7eee4b470f9..d5d9041aef5 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EnumServicesStatusExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EnumServicesStatusExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool EnumServicesStatusEx(
SafeServiceHandle databaseHandle,
int infolevel,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs
index a2f92387abe..620cfee6e74 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs
@@ -7,11 +7,11 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(Libraries.Advapi32)]
internal static partial int EventWriteString(
long registrationHandle,
byte level,
long keyword,
- string msg);
+ [MarshalAs(UnmanagedType.LPStr)] string msg);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs
index 66e1308f034..d02e09c3a3a 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetSecurityDescriptorLength", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32)]
internal static partial uint GetSecurityDescriptorLength(IntPtr byteArray);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs
index ed4e6c1acb8..fa2a4b72073 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetSecurityInfoByName(
string name,
/*DWORD*/ uint objectType,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs
index 4556380eadc..3fe6f1ccbbb 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetServiceDisplayNameW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetServiceDisplayNameW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool GetServiceDisplayName(SafeServiceHandle? SCMHandle, string serviceName, char* displayName, ref int displayNameLength);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs
index 0d39fddee07..9d8adfdbb94 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetServiceKeyNameW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetServiceKeyNameW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool GetServiceKeyName(SafeServiceHandle? SCMHandle, string displayName, char* KeyName, ref int KeyNameLength);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LogonUser.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LogonUser.cs
index d9c69a2f919..11628880ef7 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LogonUser.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LogonUser.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "LogonUserW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "LogonUserW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int LogonUser(
string username,
string? domain,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs
index ed8fd877de2..7ac7f85d0f8 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool LookupAccountNameW(
string? lpSystemName,
ref char lpAccountName,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountSid.cs
index bf058fb4a77..8e932fc1d97 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountSid.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountSid.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LookupAccountSidW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LookupAccountSidW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static unsafe partial int LookupAccountSid(
string lpSystemName,
byte[] Sid,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs
index 7781cf4b6cf..3123d952f68 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "LookupPrivilegeValueW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "LookupPrivilegeValueW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool LookupPrivilegeValue(
[MarshalAs(UnmanagedType.LPTStr)] string? lpSystemName, [MarshalAs(UnmanagedType.LPTStr)] string lpName, out LUID lpLuid);
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs
index f2ada1ff4f4..d79900044c3 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupNames2", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupNames2", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint LsaLookupNames2(
SafeLsaPolicyHandle handle,
int flags,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenEventLog.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenEventLog.cs
index 1be1ef69605..b5e69c759bc 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenEventLog.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenEventLog.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenEventLogW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenEventLogW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeEventLogReadHandle OpenEventLog(string lpUNCServerName, string lpSourceName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken.cs
index d01c7725ea9..cd05a864e8e 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, out SafeTokenHandle TokenHandle);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs
index 03e3c704e92..7dcb9b9f0b6 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenSCManagerW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenSCManagerW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr OpenSCManager(string? machineName, string? databaseName, int access);
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs
index 88758ec52b7..027995f5ce9 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenServiceW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenServiceW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr OpenService(SafeServiceHandle? databaseHandle, string serviceName, int access);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs
index 242fb1ed88a..49f66757155 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "QueryServiceConfigW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "QueryServiceConfigW", SetLastError = true)]
internal static partial bool QueryServiceConfig(SafeServiceHandle serviceHandle, IntPtr queryServiceConfigPtr, int bufferSize, out int bytesNeeded);
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs
index 4d0fbbb415c..e7c6a1818db 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs
@@ -14,7 +14,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegConnectRegistryW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegConnectRegistryW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegConnectRegistry(
string machineName,
SafeRegistryHandle key,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs
index 94f4c4fd08e..edf3bc01fbe 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs
@@ -14,7 +14,7 @@ internal static partial class Interop
{
// Note: RegCreateKeyEx won't set the last error on failure - it returns
// an error code if it fails.
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegCreateKeyExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegCreateKeyExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegCreateKeyEx(
SafeRegistryHandle hKey,
string lpSubKey,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs
index 2a2a94cc761..8881398a0e1 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegDeleteKeyExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegDeleteKeyExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegDeleteKeyEx(
SafeRegistryHandle hKey,
string lpSubKey,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs
index 2a1127e14e0..00ae18319d1 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegDeleteValueW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegDeleteValueW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegDeleteValue(
SafeRegistryHandle hKey,
string? lpValueName);
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
index df01f62966f..fbfa4afd630 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumKeyExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumKeyExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegEnumKeyEx(
SafeRegistryHandle hKey,
int dwIndex,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs
index dd0b9e737d3..eb124caf1f7 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumValueW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumValueW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegEnumValue(
SafeRegistryHandle hKey,
int dwIndex,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs
index d51d73c1481..31df2772851 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegOpenKeyEx(
SafeRegistryHandle hKey,
string? lpSubKey,
@@ -21,7 +21,7 @@ internal static partial class Interop
int samDesired,
out SafeRegistryHandle hkResult);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegOpenKeyEx(
IntPtr hKey,
string? lpSubKey,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
index 4e4e1ef888f..18dd716f63b 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
@@ -14,7 +14,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryInfoKeyW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryInfoKeyW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegQueryInfoKey(
SafeRegistryHandle hKey,
[Out] char[]? lpClass,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
index 602ceeb475b..71548822174 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
@@ -22,7 +22,7 @@ internal static partial class Interop
byte[]? lpData,
ref int lpcbData);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
@@ -31,7 +31,7 @@ internal static partial class Interop
ref int lpData,
ref int lpcbData);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
@@ -40,7 +40,7 @@ internal static partial class Interop
ref long lpData,
ref int lpcbData);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs
index a28ac8e362c..031fbc02708 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegSetValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
@@ -21,7 +21,7 @@ internal static partial class Interop
byte[]? lpData,
int cbData);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegSetValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
@@ -30,7 +30,7 @@ internal static partial class Interop
char[]? lpData,
int cbData);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegSetValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
@@ -39,7 +39,7 @@ internal static partial class Interop
ref int lpData,
int cbData);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegSetValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
@@ -48,7 +48,7 @@ internal static partial class Interop
ref long lpData,
int cbData);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int RegSetValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterEventSource.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterEventSource.cs
index e4b39adb849..e995568e9d5 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterEventSource.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterEventSource.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegisterEventSourceW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegisterEventSourceW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeEventLogWriteHandle RegisterEventSource(string lpUNCServerName, string lpSourceName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs
index c734b070615..7428a4a8e3a 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
public delegate int ServiceControlCallbackEx(int control, int eventType, IntPtr eventData, IntPtr eventContext);
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegisterServiceCtrlHandlerExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegisterServiceCtrlHandlerExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr RegisterServiceCtrlHandlerEx(string? serviceName, ServiceControlCallbackEx? callback, IntPtr userData);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReportEvent.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReportEvent.cs
index 4dadc0cd2bd..fdf9b28f4bd 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReportEvent.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReportEvent.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ReportEventW", SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ReportEventW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial bool ReportEvent(
SafeEventLogWriteHandle hEventLog,
short wType,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs
index 09c49ae7fa9..d7b84c123d2 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
internal static partial class Advapi32
{
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "SetNamedSecurityInfoW",
- CharSet = CharSet.Unicode, SetLastError = true)]
+ SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint SetSecurityInfoByName(
string name,
/*DWORD*/ uint objectType,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs
index 6d98b11505c..f37559c34ff 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "StartServiceW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "StartServiceW", SetLastError = true)]
internal static partial bool StartService(SafeServiceHandle serviceHandle, int argNum, IntPtr argPtrs);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs
index b1432031db9..3835162a88d 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "StartServiceCtrlDispatcherW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "StartServiceCtrlDispatcherW", SetLastError = true)]
public static partial bool StartServiceCtrlDispatcher(IntPtr entry);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Authz/Interop.AuthzInitializeResourceManager.cs b/src/libraries/Common/src/Interop/Windows/Authz/Interop.AuthzInitializeResourceManager.cs
index aee246dce29..2b43eb94750 100644
--- a/src/libraries/Common/src/Interop/Windows/Authz/Interop.AuthzInitializeResourceManager.cs
+++ b/src/libraries/Common/src/Interop/Windows/Authz/Interop.AuthzInitializeResourceManager.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Authz
{
- [GeneratedDllImport(Libraries.Authz, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Authz, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool AuthzInitializeResourceManager(
int flags,
IntPtr pfnAccessCheck,
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs
index 2ddaade387b..407118d61b8 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs
@@ -121,13 +121,13 @@ namespace Internal.NativeCrypto
{
internal static partial class Interop
{
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
public static partial NTSTATUS BCryptOpenAlgorithmProvider(out SafeAlgorithmHandle phAlgorithm, string pszAlgId, string? pszImplementation, int dwFlags);
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
public static partial NTSTATUS BCryptSetProperty(SafeAlgorithmHandle hObject, string pszProperty, string pbInput, int cbInput, int dwFlags);
- [GeneratedDllImport(Libraries.BCrypt, EntryPoint = "BCryptSetProperty", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, EntryPoint = "BCryptSetProperty", StringMarshalling = StringMarshalling.Utf16)]
private static partial NTSTATUS BCryptSetIntPropertyPrivate(SafeBCryptHandle hObject, string pszProperty, ref int pdwInput, int cbInput, int dwFlags);
public static unsafe NTSTATUS BCryptSetIntProperty(SafeBCryptHandle hObject, string pszProperty, ref int pdwInput, int dwFlags)
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCreateHash.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCreateHash.cs
index 619b9848fa1..06f0707207c 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCreateHash.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCreateHash.cs
@@ -16,7 +16,7 @@ internal static partial class Interop
return BCryptCreateHash(hAlgorithm, out phHash, pbHashObject, cbHashObject, ref MemoryMarshal.GetReference(secret), cbSecret, dwFlags);
}
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
private static partial NTSTATUS BCryptCreateHash(SafeBCryptAlgorithmHandle hAlgorithm, out SafeBCryptHashHandle phHash, IntPtr pbHashObject, int cbHashObject, ref byte pbSecret, int cbSecret, BCryptCreateHashFlags dwFlags);
[Flags]
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs
index 6a1eaaaed7c..ab67c0d7d3c 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
{
internal static partial class BCrypt
{
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial NTSTATUS BCryptDeriveKeyPBKDF2(
SafeBCryptAlgorithmHandle hPrf,
byte* pbPassword,
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptExportKey.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptExportKey.cs
index b9f585e3a24..eace8eb2545 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptExportKey.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptExportKey.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
{
internal static partial class BCrypt
{
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial NTSTATUS BCryptExportKey(SafeBCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, byte[]? pbOutput, int cbOutput, out int pcbResult, int dwFlags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGetProperty.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGetProperty.cs
index f5429ac535a..8dc018841da 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGetProperty.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGetProperty.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
{
internal static partial class BCrypt
{
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial NTSTATUS BCryptGetProperty(SafeBCryptHandle hObject, string pszProperty, void* pbOutput, int cbOutput, out int pcbResult, int dwFlags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs
index e490fe07eae..4b69c44ba2a 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class BCrypt
{
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial NTSTATUS BCryptHash(nuint hAlgorithm, byte* pbSecret, int cbSecret, byte* pbInput, int cbInput, byte* pbOutput, int cbOutput);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHashData.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHashData.cs
index db9a126b48a..b8d8ba4c27c 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHashData.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHashData.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
internal static NTSTATUS BCryptHashData(SafeBCryptHashHandle hHash, ReadOnlySpan<byte> pbInput, int cbInput, int dwFlags) =>
BCryptHashData(hHash, ref MemoryMarshal.GetReference(pbInput), cbInput, dwFlags);
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
private static partial NTSTATUS BCryptHashData(SafeBCryptHashHandle hHash, ref byte pbInput, int cbInput, int dwFlags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptImportKey.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptImportKey.cs
index 94e650df636..05dac933912 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptImportKey.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptImportKey.cs
@@ -61,7 +61,7 @@ internal static partial class Interop
public const uint BCRYPT_KEY_DATA_BLOB_VERSION1 = 0x1;
}
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
private static unsafe partial NTSTATUS BCryptImportKey(SafeAlgorithmHandle hAlgorithm, IntPtr hImportKey, string pszBlobType, out SafeKeyHandle hKey, IntPtr pbKeyObject, int cbKeyObject, byte* pbInput, int cbInput, int dwFlags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptOpenAlgorithmProvider.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptOpenAlgorithmProvider.cs
index a0bb0c9e35e..a898fb287bc 100644
--- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptOpenAlgorithmProvider.cs
+++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptOpenAlgorithmProvider.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
{
internal static partial class BCrypt
{
- [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.BCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial NTSTATUS BCryptOpenAlgorithmProvider(out SafeBCryptAlgorithmHandle phAlgorithm, string pszAlgId, string? pszImplementation, BCryptOpenAlgorithmProviderFlags dwFlags);
[Flags]
diff --git a/src/libraries/Common/src/Interop/Windows/Credui/Interop.CredUIParseUserName.cs b/src/libraries/Common/src/Interop/Windows/Credui/Interop.CredUIParseUserName.cs
index 8d37329019e..92f3c08320e 100644
--- a/src/libraries/Common/src/Interop/Windows/Credui/Interop.CredUIParseUserName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Credui/Interop.CredUIParseUserName.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
internal const int CRED_MAX_USERNAME_LENGTH = 514;
internal const int CRED_MAX_DOMAIN_TARGET_LENGTH = 338;
- [GeneratedDllImport(Libraries.Credui, EntryPoint = "CredUIParseUserNameW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Credui, EntryPoint = "CredUIParseUserNameW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int CredUIParseUserName(
string pszUserName,
char* pszUser,
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContextWithKeyContainerDeletion.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContextWithKeyContainerDeletion.cs
index ff720e14f1d..7f30b7dfeac 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContextWithKeyContainerDeletion.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContextWithKeyContainerDeletion.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertDuplicateCertificateContext", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertDuplicateCertificateContext", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeCertContextHandleWithKeyContainerDeletion CertDuplicateCertificateContextWithKeyContainerDeletion(IntPtr pCertContext);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextPropertyString.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextPropertyString.cs
index ed60c1730e5..7a31f5dbcd3 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextPropertyString.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextPropertyString.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertGetCertificateContextProperty", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertGetCertificateContextProperty", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool CertGetCertificateContextPropertyString(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, byte* pvData, ref uint pcbData);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetNameString.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetNameString.cs
index a9ed56eb09f..e3973c419f8 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetNameString.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetNameString.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertGetNameStringW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertGetNameStringW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int CertGetNameString(SafeCertContextHandle pCertContext, CertNameType dwType, CertNameFlags dwFlags, in CertNameStringType pvTypePara, char* pszNameString, int cchNameString);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs
index 0228f4b78da..d9cb7227ab3 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertNameToStrW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertNameToStrW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int CertNameToStr(
int dwCertEncodingType,
void* pName,
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertStrToName.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertStrToName.cs
index ae82cf52a97..a7cc4aa1de2 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertStrToName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertStrToName.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertStrToNameW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertStrToNameW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool CertStrToName(CertEncodingType dwCertEncodingType, string pszX500, CertNameStrTypeAndFlags dwStrType, IntPtr pvReserved, byte[]? pbEncoded, ref int pcbEncoded, IntPtr ppszError);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_IntPtr.cs
index 2a3535a5fa9..caa8a4581f7 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_IntPtr.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_IntPtr.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CryptDecodeObject", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CryptDecodeObject", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool CryptDecodeObjectPointer(
CertEncodingType dwCertEncodingType,
IntPtr lpszStructType,
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_string.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_string.cs
index bbe47942f3f..cd0575c8e45 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_string.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObjectPointer_string.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CryptDecodeObject", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CryptDecodeObject", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool CryptDecodeObjectPointer(
CertEncodingType dwCertEncodingType,
[MarshalAs(UnmanagedType.LPStr)] string lpszStructType,
diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectData.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectData.cs
index 54aa2d954b8..891b3918e07 100644
--- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectData.cs
+++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectData.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
- [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Crypt32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool CryptProtectData(
in DATA_BLOB pDataIn,
diff --git a/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs b/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs
index 0b4f5521dc4..3f4077e2e37 100644
--- a/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs
+++ b/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs
@@ -210,11 +210,11 @@ internal static partial class Interop
#endif
}
- [GeneratedDllImport(Interop.Libraries.CryptUI, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.CryptUI, SetLastError = true)]
internal static partial bool CryptUIDlgViewCertificateW(
in CRYPTUI_VIEWCERTIFICATE_STRUCTW ViewInfo, IntPtr pfPropertiesChanged);
- [GeneratedDllImport(Interop.Libraries.CryptUI, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.CryptUI, SetLastError = true)]
internal static partial SafeCertContextHandle CryptUIDlgSelectCertificateW(ref CRYPTUI_SELECTCERTIFICATE_STRUCTW csc);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Dsrole/Interop.DsRoleGetPrimaryDomainInformation.cs b/src/libraries/Common/src/Interop/Windows/Dsrole/Interop.DsRoleGetPrimaryDomainInformation.cs
index 19ec950afc7..2853d27fc60 100644
--- a/src/libraries/Common/src/Interop/Windows/Dsrole/Interop.DsRoleGetPrimaryDomainInformation.cs
+++ b/src/libraries/Common/src/Interop/Windows/Dsrole/Interop.DsRoleGetPrimaryDomainInformation.cs
@@ -16,7 +16,7 @@ internal static partial class Interop
DsRolePrimaryDomainInfoBasicEx = 4
}
- [GeneratedDllImport(Libraries.Dsrole, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Dsrole, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DsRoleGetPrimaryDomainInformation(
[MarshalAs(UnmanagedType.LPTStr)] string lpServer,
DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs
index 41bb3d669c4..768bb63afae 100644
--- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs
+++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Gdi32
{
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Gdi32, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr CreateDCW(string pwszDriver, string pwszDevice, string? pszPort, IntPtr pdm);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateFontIndirect.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateFontIndirect.cs
index 8f4afccea46..8536e7c745d 100644
--- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateFontIndirect.cs
+++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateFontIndirect.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Gdi32
{
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Gdi32)]
public static partial IntPtr CreateFontIndirectW(ref User32.LOGFONT lplf);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs
index c71e8656401..5a910510e46 100644
--- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs
+++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Gdi32
{
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Gdi32, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr CreateICW(string pszDriver, string pszDevice, string? pszPort, IntPtr pdm);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/HttpApi/Interop.HttpApi.cs b/src/libraries/Common/src/Interop/Windows/HttpApi/Interop.HttpApi.cs
index ac41ba64035..7822f894dcd 100644
--- a/src/libraries/Common/src/Interop/Windows/HttpApi/Interop.HttpApi.cs
+++ b/src/libraries/Common/src/Interop/Windows/HttpApi/Interop.HttpApi.cs
@@ -470,14 +470,14 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.HttpApi, SetLastError = true)]
internal static partial uint HttpCloseUrlGroup(ulong urlGroupId);
- [GeneratedDllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.HttpApi, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial uint HttpCreateRequestQueue(HTTPAPI_VERSION version, string pName,
Interop.Kernel32.SECURITY_ATTRIBUTES* pSecurityAttributes, uint flags, out HttpRequestQueueV2Handle pReqQueueHandle);
- [GeneratedDllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.HttpApi, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint HttpAddUrlToUrlGroup(ulong urlGroupId, string pFullyQualifiedUrl, ulong context, uint pReserved);
- [GeneratedDllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.HttpApi, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint HttpRemoveUrlFromUrlGroup(ulong urlGroupId, string pFullyQualifiedUrl, uint flags);
[GeneratedDllImport(Libraries.HttpApi, SetLastError = true)]
diff --git a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.if_nametoindex.cs b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.if_nametoindex.cs
index 01235ca5f73..856a1c56a9b 100644
--- a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.if_nametoindex.cs
+++ b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.if_nametoindex.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class IpHlpApi
{
- [GeneratedDllImport(Interop.Libraries.IpHlpApi, CharSet = CharSet.Ansi, SetLastError = true)]
- internal static partial uint if_nametoindex(string name);
+ [GeneratedDllImport(Interop.Libraries.IpHlpApi, SetLastError = true)]
+ internal static partial uint if_nametoindex([MarshalAs(UnmanagedType.LPStr)] string name);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs
index 4b45b5666c3..dc93d2ee0e8 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CopyFileEx.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool CopyFileExPrivate(
string src,
string dst,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs
index de0c073cf4c..a1a3ca11a91 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateDirectory.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool CreateDirectoryPrivate(
string path,
ref SECURITY_ATTRIBUTES lpSecurityAttributes);
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs
index 0dd320c2fba..b598f2e3d3f 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateFile.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static unsafe partial SafeFileHandle CreateFilePrivate(
string lpFileName,
int dwDesiredAccess,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs
index 005311e4f38..8a4cebbbf59 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeMemoryMappedFileHandle CreateFileMapping(
SafeFileHandle hFile,
ref SECURITY_ATTRIBUTES lpFileMappingAttributes,
@@ -19,7 +19,7 @@ internal static partial class Interop
int dwMaximumSizeLow,
string? lpName);
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeMemoryMappedFileHandle CreateFileMapping(
IntPtr hFile,
ref SECURITY_ATTRIBUTES lpFileMappingAttributes,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile_IntPtr.cs
index b53785b8bf5..37ae80b99ec 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile_IntPtr.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile_IntPtr.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateFile.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static unsafe partial IntPtr CreateFilePrivate_IntPtr(
string lpFileName,
int dwDesiredAccess,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipe.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipe.cs
index cc190de6989..0e67ae59676 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipe.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipe.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateNamedPipeW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateNamedPipeW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafePipeHandle CreateNamedPipe(
string pipeName,
int openMode,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipeClient.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipeClient.cs
index f5cad97b7c4..baca7eae851 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipeClient.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipeClient.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafePipeHandle CreateNamedPipeClient(
string? lpFileName,
int dwDesiredAccess,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs
index c31f8a36755..18c7e453f7e 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateProcessW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateProcessW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool CreateProcess(
string? lpApplicationName,
char* lpCommandLine,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs
index cc727e91b5e..96d85d9c5b5 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs
@@ -20,7 +20,7 @@ internal static partial class Interop
/// </summary>
internal const int SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2;
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateSymbolicLinkW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateSymbolicLinkW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool CreateSymbolicLinkPrivate(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
/// <summary>
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs
index a4868c9707c..bef3a96b6a2 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DeleteFile.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool DeleteFilePrivate(string path);
internal static bool DeleteFile(string path)
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs
index 39b3cad6db3..3c73de3d62d 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DeleteVolumeMountPoint.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool DeleteVolumeMountPointPrivate(string mountPoint);
internal static bool DeleteVolumeMountPoint(string mountPoint)
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs
index 3029dbc4a13..3d0781f4e3f 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
// https://docs.microsoft.com/windows/win32/api/winioctl/ni-winioctl-fsctl_get_reparse_point
internal const int FSCTL_GET_REPARSE_POINT = 0x000900a8;
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeviceIoControl", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeviceIoControl", SetLastError = true)]
internal static partial bool DeviceIoControl(
SafeHandle hDevice,
uint dwIoControlCode,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcessModules.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcessModules.cs
index e88e5050b84..3c079ab76e2 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcessModules.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcessModules.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32EnumProcessModules", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32EnumProcessModules", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool EnumProcessModules(SafeProcessHandle handle, IntPtr[]? modules, int size, out int needed);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcesses.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcesses.cs
index 6ffb508d3f0..9a8833a9160 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcesses.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EnumProcesses.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32EnumProcesses", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32EnumProcesses", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool EnumProcesses(int[] processIds, int size, out int needed);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs
index 6223e165432..fef6409c47d 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs
@@ -18,10 +18,10 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial bool ResetEvent(SafeWaitHandle handle);
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateEventExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateEventExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeWaitHandle CreateEventEx(IntPtr lpSecurityAttributes, string? name, uint flags, uint desiredAccess);
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenEventW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenEventW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeWaitHandle OpenEvent(uint desiredAccess, bool inheritHandle, string name);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs
index ed5b6a0eae5..8f8ea391aba 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ExpandEnvironmentStringsW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ExpandEnvironmentStringsW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint ExpandEnvironmentStrings(string lpSrc, ref char lpDst, uint nSize);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputCharacter.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputCharacter.cs
index 4e9f464e470..f58918aa4b7 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputCharacter.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputCharacter.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FillConsoleOutputCharacterW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FillConsoleOutputCharacterW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool FillConsoleOutputCharacter(IntPtr hConsoleOutput, char character, int nLength, COORD dwWriteCoord, out int pNumCharsWritten);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs
index c5db774302e..aad022d6f81 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use FindFirstFile.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FindFirstFileExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FindFirstFileExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial SafeFindHandle FindFirstFileExPrivate(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, ref WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, int dwAdditionalFlags);
internal static SafeFindHandle FindFirstFile(string fileName, ref WIN32_FIND_DATA data)
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs
index dc4f9a4dec1..06086bf72c8 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FindNextFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FindNextFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool FindNextFile(SafeFindHandle hndFindFile, ref WIN32_FIND_DATA lpFindFileData);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage_SafeLibraryHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage_SafeLibraryHandle.cs
index 59f1ef154be..6c14dad8825 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage_SafeLibraryHandle.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage_SafeLibraryHandle.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
public const int FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
public const int FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FormatMessageW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FormatMessageW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial int FormatMessage(
int dwFlags,
SafeLibraryHandle lpSource,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs
index 773f7ddb901..e47bb8ab527 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetCPInfoExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetCPInfoExW", StringMarshalling = StringMarshalling.Utf16)]
private static unsafe partial Interop.BOOL GetCPInfoExW(uint CodePage, uint dwFlags, CPINFOEXW* lpCPInfoEx);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
index 8faecd4c9a7..fe441839e0b 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetComputerNameW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetComputerNameW")]
private static unsafe partial int GetComputerName(char* lpBuffer, uint* nSize);
// maximum length of the NETBIOS name (not including NULL)
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleTitle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleTitle.cs
index 3adffc38755..955d4973436 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleTitle.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleTitle.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static unsafe partial uint GetConsoleTitleW(char* title, uint nSize);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs
index 6996010df6f..48608469dbc 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetCurrentDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetCurrentDirectoryW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetCurrentDirectory(uint nBufferLength, ref char lpBuffer);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDiskFreeSpaceEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDiskFreeSpaceEx.cs
index c9d6b8d8787..1131b5a43e5 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDiskFreeSpaceEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDiskFreeSpaceEx.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
// NOTE: The out parameters are PULARGE_INTEGERs and may require
// some byte munging magic.
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetDiskFreeSpaceExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetDiskFreeSpaceExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool GetDiskFreeSpaceEx(string drive, out long freeBytesForUser, out long totalBytes, out long freeBytes);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDriveType.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDriveType.cs
index 51321d6d6b0..641be553029 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDriveType.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDriveType.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetDriveTypeW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetDriveTypeW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetDriveType(string drive);
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs
index 35fe168de82..e3691f6c6dc 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetEnvironmentVariableW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetEnvironmentVariableW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetEnvironmentVariable(string lpName, ref char lpBuffer, uint nSize);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs
index 3c1df29b42c..ec8472cd4a2 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use GetFileAttributesEx.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool GetFileAttributesExPrivate(
string? name,
GET_FILEEX_INFO_LEVELS fileInfoLevel,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs
index f96916c7ebc..3d15bf6dedd 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
internal const uint FILE_NAME_NORMALIZED = 0x0;
// https://docs.microsoft.com/windows/desktop/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew (kernel32)
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFinalPathNameByHandleW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFinalPathNameByHandleW", SetLastError = true)]
internal static unsafe partial uint GetFinalPathNameByHandle(
SafeFileHandle hFile,
char* lpszFilePath,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs
index e766053beff..687d5bf188a 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use GetFullPathName or PathHelper.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetFullPathNameW(
ref char lpFileName,
uint nBufferLength,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs
index ea3e04e1d09..a99a77a2a51 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use GetFullPath/PathHelper.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetLongPathNameW(
ref char lpszShortPath,
ref char lpszLongPath,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleBaseName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleBaseName.cs
index 930b96442f1..def7124cbd3 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleBaseName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleBaseName.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleBaseNameW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleBaseNameW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetModuleBaseName(SafeProcessHandle processHandle, IntPtr moduleHandle, [Out] char[] baseName, int size);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs
index edb2f706afd..08b6784c4d2 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetModuleFileNameW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetModuleFileNameW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetModuleFileName(IntPtr hModule, ref char lpFilename, uint nSize);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileNameEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileNameEx.cs
index 285ad50403d..1b89788d9f0 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileNameEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileNameEx.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleFileNameExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleFileNameExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetModuleFileNameEx(SafeProcessHandle processHandle, IntPtr moduleHandle, [Out] char[] baseName, int size);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs
index ad1bbb9b966..710e14fc2ef 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetModuleHandleW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetModuleHandleW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr GetModuleHandle(string? moduleName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs
index 73470ceecb8..c7a888c64d7 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleInformation", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleInformation", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool GetModuleInformation(SafeProcessHandle processHandle, IntPtr moduleHandle, out NtModuleInfo ntModuleInfo, int size);
internal static unsafe bool GetModuleInformation(SafeProcessHandle processHandle, IntPtr moduleHandle, out NtModuleInfo ntModuleInfo) =>
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeHandleState.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeHandleState.cs
index c1ac58d9395..99d9dba7d4c 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeHandleState.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeHandleState.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static unsafe partial bool GetNamedPipeHandleStateW(
SafePipeHandle hNamedPipe,
uint* lpState,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs
index cce63bf6bee..c76bda41ab8 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs
@@ -10,10 +10,10 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Ansi)]
- public static partial IntPtr GetProcAddress(SafeLibraryHandle hModule, string lpProcName);
+ [GeneratedDllImport(Libraries.Kernel32)]
+ public static partial IntPtr GetProcAddress(SafeLibraryHandle hModule, [MarshalAs(UnmanagedType.LPStr)] string lpProcName);
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Ansi)]
- public static partial IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
+ [GeneratedDllImport(Libraries.Kernel32)]
+ public static partial IntPtr GetProcAddress(IntPtr hModule, [MarshalAs(UnmanagedType.LPStr)] string lpProcName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
index 25dfb72e462..d3032c105b1 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "QueryFullProcessImageNameW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "QueryFullProcessImageNameW", SetLastError = true)]
private static unsafe partial bool QueryFullProcessImageName(
SafeHandle hProcess,
uint dwFlags,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessPriorityBoost.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessPriorityBoost.cs
index d5efb5e07ca..bf0255d2937 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessPriorityBoost.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessPriorityBoost.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool GetProcessPriorityBoost(SafeProcessHandle handle, out bool disabled);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs
index dc019f330d8..ecea358569e 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool GetProcessTimes(
SafeProcessHandle handle, out long creation, out long exit, out long kernel, out long user);
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs
index a1050e87405..699d4b97f27 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetSystemDirectoryW(ref char lpBuffer, uint uSize);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs
index 74db0802310..a0c39568ee4 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetTempFileNameW(ref char lpPathName, string lpPrefixString, uint uUnique, ref char lpTempFileName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs
index 719f19cd1bc..bef74a92e15 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Kernel32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetTempPathW(int bufferLen, ref char buffer);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs
index bf1750b57cd..1ec27107edf 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool GetVolumeInformation(
string drive,
char* volumeName,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs
index de7dbaa8441..422ade1476a 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs
@@ -47,13 +47,13 @@ internal static partial class Interop
internal const string LOCALE_NAME_USER_DEFAULT = null;
internal const string LOCALE_NAME_SYSTEM_DEFAULT = "!x-sys-default-locale";
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int LCIDToLocaleName(int locale, char* pLocaleName, int cchName, uint dwFlags);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int LocaleNameToLCID(string lpName, uint dwFlags);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport("kernel32.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int LCMapStringEx(
string? lpLocaleName,
uint dwMapFlags,
@@ -107,7 +107,7 @@ internal static partial class Interop
int cchValue,
BOOL bIgnoreCase);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool IsNLSDefinedString(
int Function,
uint dwFlags,
@@ -115,31 +115,31 @@ internal static partial class Interop
char* lpString,
int cchStr);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Auto)]
+ [GeneratedDllImport("kernel32.dll")]
internal static unsafe partial Interop.BOOL GetUserPreferredUILanguages(uint dwFlags, uint* pulNumLanguages, char* pwszLanguagesBuffer, uint* pcchLanguagesBuffer);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int GetLocaleInfoEx(string lpLocaleName, uint LCType, void* lpLCData, int cchData);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool EnumSystemLocalesEx(delegate* unmanaged<char*, uint, void*, BOOL> lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool EnumTimeFormatsEx(delegate* unmanaged<char*, void*, BOOL> lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetCalendarInfoEx(string? lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, out int lpValue);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetCalendarInfoEx(string? lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, IntPtr lpValue);
[GeneratedDllImport("kernel32.dll")]
internal static partial int GetUserGeoID(int geoClass);
- [GeneratedDllImport("kernel32.dll", EntryPoint = "GetGeoInfoW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", EntryPoint = "GetGeoInfoW")]
internal static unsafe partial int GetGeoInfo(int location, int geoType, char* lpGeoData, int cchData, int LangId);
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool EnumCalendarInfoExEx(delegate* unmanaged<char*, uint, IntPtr, void*, BOOL> pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string? lpReserved, uint CalType, void* lParam);
[StructLayout(LayoutKind.Sequential)]
@@ -152,7 +152,7 @@ internal static partial class Interop
internal Guid guidCustomVersion;
}
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool GetNLSVersionEx(int function, string localeName, NlsVersionInfoEx* lpVersionInformation);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs
index 7ba68fe3266..eb9e38114e4 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "LoadLibraryW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "LoadLibraryW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr LoadLibrary(string libFilename);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx.cs
index 248059c3875..9d1f7a8f815 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
public const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
public const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial SafeLibraryHandle LoadLibraryExW(string lpwLibFileName, IntPtr hFile, uint dwFlags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx_IntPtr.cs
index 4d589ba30c0..b987f56a022 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx_IntPtr.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx_IntPtr.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
internal const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "LoadLibraryExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "LoadLibraryExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr LoadLibraryEx(string libFilename, IntPtr reserved, int flags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs
index ed29c33acca..79a3387618a 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeMemoryMappedViewHandle MapViewOfFile(
SafeMemoryMappedFileHandle hFileMappingObject,
int dwDesiredAccess,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs
index f08d5e48617..bba2cc1cfda 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs
@@ -15,7 +15,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use MoveFile.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool MoveFileExPrivate(
string src, string dst, uint flags);
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs
index be9e0bf8c46..fd5513ec5ad 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs
@@ -11,10 +11,10 @@ internal static partial class Interop
{
internal const uint CREATE_MUTEX_INITIAL_OWNER = 0x1;
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenMutexW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenMutexW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeWaitHandle OpenMutex(uint desiredAccess, bool inheritHandle, string name);
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateMutexExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateMutexExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeWaitHandle CreateMutexEx(IntPtr lpMutexAttributes, string? name, uint flags, uint desiredAccess);
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs
index a60c27fa760..8d8a0c91e8c 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeMemoryMappedFileHandle OpenFileMapping(
int dwDesiredAccess,
[MarshalAs(UnmanagedType.Bool)] bool bInheritHandle,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs
index 5390bf90ee5..937999e0ceb 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Interop.Libraries.Kernel32, EntryPoint = "OutputDebugStringW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Kernel32, EntryPoint = "OutputDebugStringW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial void OutputDebugString(string message);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs
index 179d0b29dbe..6480dbac957 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "PeekConsoleInputW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "PeekConsoleInputW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool PeekConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsole.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsole.cs
index 022d0849b5e..3aa15e13b0a 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsole.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsole.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool ReadConsole(
IntPtr hConsoleInput,
byte* lpBuffer,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs
index c6ed13076da..7542a8faa48 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs
@@ -32,7 +32,7 @@ internal static partial class Interop
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleInputW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleInputW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool ReadConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleOutput.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleOutput.cs
index d5722aea5ec..4aca20cbd1e 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleOutput.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleOutput.cs
@@ -15,7 +15,7 @@ internal static partial class Interop
private short attributes;
}
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleOutputW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleOutputW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool ReadConsoleOutput(IntPtr hConsoleOutput, CHAR_INFO* pBuffer, COORD bufferSize, COORD bufferCoord, ref SMALL_RECT readRegion);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadDirectoryChangesW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadDirectoryChangesW.cs
index aa94e95d556..5894e1e9fd0 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadDirectoryChangesW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadDirectoryChangesW.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadDirectoryChangesW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadDirectoryChangesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool ReadDirectoryChangesW(
SafeFileHandle hDirectory,
byte[] lpBuffer,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs
index abca057bf9c..d14e87cc272 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use RemoveDirectory.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool RemoveDirectoryPrivate(string path);
internal static bool RemoveDirectory(string path)
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs
index cd7612c0212..bf65c31322c 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool ReplaceFilePrivate(
string replacedFileName, string replacementFileName, string? backupFileName,
int dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs
index cf01ba66e8b..b70c6d8fdf3 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal const int LOCALE_NAME_MAX_LENGTH = 85;
- [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int ResolveLocaleName(string lpNameToResolve, char* lpLocaleName, int cchLocaleName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs
index 4aa1e0beab3..f3e167a18ca 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs
@@ -9,10 +9,10 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenSemaphoreW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenSemaphoreW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeWaitHandle OpenSemaphore(uint desiredAccess, bool inheritHandle, string name);
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateSemaphoreExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateSemaphoreExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SafeWaitHandle CreateSemaphoreEx(IntPtr lpSecurityAttributes, int initialCount, int maximumCount, string? name, uint flags, uint desiredAccess);
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTitle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTitle.cs
index 246f395c9a0..b79b85bf4b2 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTitle.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTitle.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetConsoleTitleW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetConsoleTitleW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool SetConsoleTitle(string title);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs
index 1abc814f65a..a098ac929a1 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetCurrentDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetCurrentDirectoryW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool SetCurrentDirectory(string path);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs
index f310466ea55..08eb78d2683 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetEnvironmentVariableW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetEnvironmentVariableW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool SetEnvironmentVariable(string lpName, string? lpValue);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs
index a382d01bbca..239fd0030a4 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use SetFileAttributes.
/// </summary>
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool SetFileAttributesPrivate(
string name,
int attr);
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetVolumeLabel.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetVolumeLabel.cs
index ca70a7fa2c5..7f8570f4ca1 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetVolumeLabel.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetVolumeLabel.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetVolumeLabelW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetVolumeLabelW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool SetVolumeLabel(string driveLetter, string? volumeName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs
index c9e8832996c..4ecb0f45f7d 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs
@@ -83,10 +83,10 @@ internal static partial class Interop
internal const uint TIME_ZONE_ID_INVALID = unchecked((uint)-1);
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial uint GetDynamicTimeZoneInformation(out TIME_DYNAMIC_ZONE_INFORMATION pTimeZoneInformation);
- [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial uint GetTimeZoneInformation(out TIME_ZONE_INFORMATION lpTimeZoneInformation);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitNamedPipe.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitNamedPipe.cs
index 118464eac29..1a656256245 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitNamedPipe.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitNamedPipe.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WaitNamedPipeW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WaitNamedPipeW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool WaitNamedPipe(string? name, int timeout);
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsole.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsole.cs
index 95b6495d216..071af6da935 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsole.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsole.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WriteConsoleW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WriteConsoleW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool WriteConsole(
IntPtr hConsoleOutput,
byte* lpBuffer,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsoleOutput.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsoleOutput.cs
index d656cebed02..3a483d4bb06 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsoleOutput.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsoleOutput.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WriteConsoleOutputW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WriteConsoleOutputW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial bool WriteConsoleOutput(IntPtr hConsoleOutput, CHAR_INFO* buffer, COORD bufferSize, COORD bufferCoord, ref SMALL_RECT writeRegion);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Logoncli/Interop.DsGetDcName.cs b/src/libraries/Common/src/Interop/Windows/Logoncli/Interop.DsGetDcName.cs
index e9796be059c..af7280f949c 100644
--- a/src/libraries/Common/src/Interop/Windows/Logoncli/Interop.DsGetDcName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Logoncli/Interop.DsGetDcName.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Logoncli
{
- [GeneratedDllImport(Libraries.Logoncli, EntryPoint = "DsGetDcNameW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Logoncli, EntryPoint = "DsGetDcNameW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DsGetDcName(
string computerName,
string domainName,
diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Keys.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Keys.cs
index 5d9fbe7595e..abd0f171ba3 100644
--- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Keys.cs
+++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Keys.cs
@@ -16,31 +16,31 @@ internal static partial class Interop
internal const int NCRYPT_CIPHER_KEY_BLOB_MAGIC = 0x52485043; //'CPHR'
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptOpenKey(SafeNCryptProviderHandle hProvider, out SafeNCryptKeyHandle phKey, string pszKeyName, int dwLegacyKeySpec, CngKeyOpenOptions dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptImportKey(SafeNCryptProviderHandle hProvider, IntPtr hImportKey, string pszBlobType, IntPtr pParameterList, out SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptImportKey(SafeNCryptProviderHandle hProvider, IntPtr hImportKey, string pszBlobType, ref NCryptBufferDesc pParameterList, out SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, IntPtr pParameterList, byte[]? pbOutput, int cbOutput, out int pcbResult, int dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, IntPtr pParameterList, ref byte pbOutput, int cbOutput, out int pcbResult, int dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, ref NCryptBufferDesc pParameterList, ref byte pbOutput, int cbOutput, out int pcbResult, int dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptDeleteKey(SafeNCryptKeyHandle hKey, int dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptCreatePersistedKey(SafeNCryptProviderHandle hProvider, out SafeNCryptKeyHandle phKey, string pszAlgId, string? pszKeyName, int dwLegacyKeySpec, CngKeyCreationOptions dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptFinalizeKey(SafeNCryptKeyHandle hKey, int dwFlags);
[StructLayout(LayoutKind.Sequential)]
diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs
index f0fa8ff2324..02298a6a76e 100644
--- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs
+++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs
@@ -15,7 +15,7 @@ internal static partial class Interop
/// <summary>
/// Generate a key from a secret agreement
/// </summary>
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
private static partial ErrorCode NCryptDeriveKey(
SafeNCryptSecretHandle hSharedSecret,
string pwszKDF,
diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptOpenStorageProvider.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptOpenStorageProvider.cs
index 97368d05509..28adee9d595 100644
--- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptOpenStorageProvider.cs
+++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptOpenStorageProvider.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class NCrypt
{
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static partial ErrorCode NCryptOpenStorageProvider(out SafeNCryptProviderHandle phProvider, string pszProviderName, int dwFlags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs
index d160b1a7d42..a52da43417b 100644
--- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs
+++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs
@@ -13,7 +13,7 @@ internal static partial class Interop
{
internal static partial class NCrypt
{
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial ErrorCode NCryptGetProperty(
SafeNCryptHandle hObject,
string pszProperty,
@@ -22,7 +22,7 @@ internal static partial class Interop
out int pcbResult,
CngPropertyOptions dwFlags);
- [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial ErrorCode NCryptSetProperty(
SafeNCryptHandle hObject,
string pszProperty,
diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.SignVerify.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.SignVerify.cs
index 8e651c7277d..723f78e0849 100644
--- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.SignVerify.cs
+++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.SignVerify.cs
@@ -12,13 +12,13 @@ internal static partial class Interop
internal static unsafe ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ReadOnlySpan<byte> pbHashValue, int cbHashValue, Span<byte> pbSignature, int cbSignature, out int pcbResult, AsymmetricPaddingMode dwFlags) =>
NCryptSignHash(hKey, pPaddingInfo, ref MemoryMarshal.GetReference(pbHashValue), cbHashValue, ref MemoryMarshal.GetReference(pbSignature), cbSignature, out pcbResult, dwFlags);
- [GeneratedDllImport(Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
private static unsafe partial ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ref byte pbHashValue, int cbHashValue, ref byte pbSignature, int cbSignature, out int pcbResult, AsymmetricPaddingMode dwFlags);
internal static unsafe ErrorCode NCryptVerifySignature(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ReadOnlySpan<byte> pbHashValue, int cbHashValue, ReadOnlySpan<byte> pbSignature, int cbSignature, AsymmetricPaddingMode dwFlags) =>
NCryptVerifySignature(hKey, pPaddingInfo, ref MemoryMarshal.GetReference(pbHashValue), cbHashValue, ref MemoryMarshal.GetReference(pbSignature), cbSignature, dwFlags);
- [GeneratedDllImport(Libraries.NCrypt, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
private static unsafe partial ErrorCode NCryptVerifySignature(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ref byte pbHashValue, int cbHashValue, ref byte pbSignature, int cbSignature, AsymmetricPaddingMode dwFlags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs
index d796f9e2f0c..63104e2d240 100644
--- a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs
+++ b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
// Idn APIs
//
- [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int IdnToAscii(
uint dwFlags,
char* lpUnicodeCharStr,
@@ -19,7 +19,7 @@ internal static partial class Interop
char* lpASCIICharStr,
int cchASCIIChar);
- [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int IdnToUnicode(
uint dwFlags,
char* lpASCIICharStr,
diff --git a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs
index 09a5bd0d109..741380134ed 100644
--- a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs
+++ b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs
@@ -8,10 +8,10 @@ internal static partial class Interop
{
internal static partial class Normaliz
{
- [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial BOOL IsNormalizedString(NormalizationForm normForm, char* source, int length);
- [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int NormalizeString(
NormalizationForm normForm,
char* source,
diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs
index d8e8f287c96..c72613c21dd 100644
--- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
// https://msdn.microsoft.com/en-us/library/bb432380.aspx
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff566424.aspx
- [GeneratedDllImport(Libraries.NtDll, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.NtDll)]
private static unsafe partial uint NtCreateFile(
IntPtr* FileHandle,
DesiredAccess DesiredAccess,
diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs
index 9465891720c..3ada672b1b0 100644
--- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs
@@ -10,7 +10,7 @@ internal static partial class Interop
{
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff556633.aspx
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff567047.aspx
- [GeneratedDllImport(Libraries.NtDll, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.NtDll)]
public static unsafe partial int NtQueryDirectoryFile(
IntPtr FileHandle,
IntPtr Event,
diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs
index 0b7c7450080..b2af31cab12 100644
--- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs
+++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Ole32
{
- [GeneratedDllImport(Interop.Libraries.Ole32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Interop.Libraries.Ole32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int CLSIDFromProgID(string lpszProgID, out Guid lpclsid);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs
index 16a08a170e7..4b262a1b824 100644
--- a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs
+++ b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs
@@ -8,10 +8,10 @@ internal static partial class Interop
{
internal static partial class OleAut32
{
- [GeneratedDllImport(Libraries.OleAut32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.OleAut32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr SysAllocStringLen(IntPtr src, uint len);
- [GeneratedDllImport(Libraries.OleAut32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.OleAut32, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr SysAllocStringLen(string src, uint len);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs b/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs
index 6ceeff0fcee..0019272d3a0 100644
--- a/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs
+++ b/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs
@@ -60,7 +60,7 @@ internal static partial class Interop
out SafePerfProviderHandle phProvider
);
- [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Advapi32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial PerfCounterSetInstanceStruct* PerfCreateInstance(
SafePerfProviderHandle hProvider,
ref Guid CounterSetGuid,
diff --git a/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs b/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs
index 52b9ab248d4..d0b16e7c6b5 100644
--- a/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Secur32
{
- [GeneratedDllImport(Libraries.Secur32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Secur32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial BOOLEAN GetUserNameExW(int NameFormat, ref char lpNameBuffer, ref uint lpnSize);
internal const int NameSamCompatible = 2;
diff --git a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs
index 108731c9cd5..ce96b7ed29e 100644
--- a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs
+++ b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
internal const int COR_E_PLATFORMNOTSUPPORTED = unchecked((int)0x80131539);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx
- [GeneratedDllImport(Libraries.Shell32, CharSet = CharSet.Unicode, SetLastError = false)]
+ [GeneratedDllImport(Libraries.Shell32, SetLastError = false, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int SHGetKnownFolderPath(
in Guid rfid,
uint dwFlags,
diff --git a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs
index 285677d41bd..2929d3ba9e6 100644
--- a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs
+++ b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs
@@ -50,7 +50,7 @@ internal static partial class Interop
internal const uint SEE_MASK_NOCLOSEPROCESS = 0x00000040;
internal const uint SEE_MASK_FLAG_NO_UI = 0x00000400;
- [GeneratedDllImport(Libraries.Shell32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Shell32, SetLastError = true)]
internal static unsafe partial bool ShellExecuteExW(
SHELLEXECUTEINFO* pExecInfo);
}
diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs
index d98fd8c51d0..c5410814edd 100644
--- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs
+++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs
@@ -391,7 +391,7 @@ internal static partial class Interop
out int pkgnum,
out SafeFreeContextBuffer_SECURITY handle);
- [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.SspiCli, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int AcquireCredentialsHandleW(
string? principal,
string moduleName,
@@ -403,7 +403,7 @@ internal static partial class Interop
ref CredHandle handlePtr,
out long timeStamp);
- [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.SspiCli, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int AcquireCredentialsHandleW(
string? principal,
string moduleName,
@@ -415,7 +415,7 @@ internal static partial class Interop
ref CredHandle handlePtr,
out long timeStamp);
- [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.SspiCli, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int AcquireCredentialsHandleW(
string? principal,
string moduleName,
@@ -427,7 +427,7 @@ internal static partial class Interop
ref CredHandle handlePtr,
out long timeStamp);
- [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.SspiCli, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int AcquireCredentialsHandleW(
string? principal,
string moduleName,
@@ -468,7 +468,7 @@ internal static partial class Interop
internal static partial SECURITY_STATUS SspiFreeAuthIdentity(
IntPtr authData);
- [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.SspiCli, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial SECURITY_STATUS SspiEncodeStringsAsAuthIdentity(
string userName,
string domainName,
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs
index 563b05026de..18f69bdeac7 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr CreateWindowExW(
int exStyle,
string lpszClassName,
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs
index e2249386ea6..b41bcf9082b 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial IntPtr DefWindowProcW(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs
index 133cf3a7187..efd057a296f 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial int DispatchMessageW(ref MSG msg);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs
index ac383c8d57e..3cd58188bf6 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr FindWindowW(string lpClassName, string lpWindowName);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs
index 82c665edc86..f8a8caeb6c6 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32, StringMarshalling = StringMarshalling.Utf16)]
public static partial bool GetClassInfoW(IntPtr hInst, string lpszClass, ref WNDCLASS wc);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetMessage.cs
index 1b002e7aa2d..70caacaedac 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetMessage.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetMessage.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial int GetMessageW(ref MSG msg, IntPtr hwnd, int msgMin, int msgMax);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs
index 16e4936fde6..5247bfeadd9 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, SetLastError = true)]
public static unsafe partial bool GetUserObjectInformationW(IntPtr hObj, int nIndex, void* pvBuffer, uint nLength, ref uint lpnLengthNeeded);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextW.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextW.cs
index 152ba302a2d..9eb8c1f116c 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextW.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextW.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, SetLastError = true)]
public static unsafe partial int GetWindowTextW(IntPtr hWnd, char* lpString, int nMaxCount);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs
index f07ba155ae7..639c0b1698a 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, EntryPoint = "LoadStringW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, EntryPoint = "LoadStringW", SetLastError = true)]
internal static unsafe partial int LoadString(IntPtr hInstance, uint uID, char* lpBuffer, int cchBufferMax);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs
index 17d66f2e950..729cedbc1b9 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial int PostMessageW(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.PostQuitMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.PostQuitMessage.cs
index 47aa4da70e5..1b9f80168cf 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.PostQuitMessage.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.PostQuitMessage.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial void PostQuitMessage(int exitCode);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs
index 99afb4a46a6..5254e3efd5d 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, SetLastError = true)]
public static partial short RegisterClassW(ref WNDCLASS wc);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs
index 3d10e35df73..1bf0969de74 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32, StringMarshalling = StringMarshalling.Utf16)]
public static partial int RegisterWindowMessageW(string msg);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs
index 366decfc164..72f350af3c2 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial IntPtr SendMessageW(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs
index a64170a339f..59705ea4408 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial IntPtr SetClassLongW(IntPtr hwnd, int nIndex, IntPtr dwNewLong);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs
index fff95d708b3..8a1924e886e 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial IntPtr SetClassLongPtrW(IntPtr hwnd, int nIndex, IntPtr dwNewLong);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs
index be280dd826e..b0532f17073 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial IntPtr SetWindowLongW(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs
index 1c3a2f970b0..04f38129aee 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.User32)]
public static partial IntPtr SetWindowLongPtrW(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs
index 64d014db478..3379b063e44 100644
--- a/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs
+++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial short UnregisterClassW(string lpClassName, IntPtr hInstance);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoEx.cs b/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoEx.cs
index f5ce78b9baf..33125eb39cf 100644
--- a/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoEx.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Version
{
- [GeneratedDllImport(Libraries.Version, EntryPoint = "GetFileVersionInfoExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Version, EntryPoint = "GetFileVersionInfoExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool GetFileVersionInfoEx(
uint dwFlags,
string lpwstrFilename,
diff --git a/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoSizeEx.cs b/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoSizeEx.cs
index db328678979..b59284751c5 100644
--- a/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoSizeEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoSizeEx.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Version
{
- [GeneratedDllImport(Libraries.Version, EntryPoint = "GetFileVersionInfoSizeExW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Version, EntryPoint = "GetFileVersionInfoSizeExW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint GetFileVersionInfoSizeEx(uint dwFlags, string lpwstrFilename, out uint lpdwHandle);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Version/Interop.VerQueryValue.cs b/src/libraries/Common/src/Interop/Windows/Version/Interop.VerQueryValue.cs
index a3674ed1030..47d71079bef 100644
--- a/src/libraries/Common/src/Interop/Windows/Version/Interop.VerQueryValue.cs
+++ b/src/libraries/Common/src/Interop/Windows/Version/Interop.VerQueryValue.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Version
{
- [GeneratedDllImport(Libraries.Version, EntryPoint = "VerQueryValueW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Version, EntryPoint = "VerQueryValueW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool VerQueryValue(IntPtr pBlock, string lpSubBlock, out IntPtr lplpBuffer, out uint puLen);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs
index 165551fa6f9..8edc9e64e7b 100644
--- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs
@@ -9,26 +9,26 @@ internal static partial class Interop
{
internal static partial class WinHttp
{
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial SafeWinHttpHandle WinHttpOpen(
IntPtr userAgent,
uint accessType,
string? proxyName,
string? proxyBypass, int flags);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpCloseHandle(
IntPtr handle);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial SafeWinHttpHandle WinHttpConnect(
SafeWinHttpHandle sessionHandle,
string serverName,
ushort serverPort,
uint reserved);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial SafeWinHttpHandle WinHttpOpenRequest(
SafeWinHttpHandle connectHandle,
string verb,
@@ -38,7 +38,7 @@ internal static partial class Interop
string acceptTypes,
uint flags);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpAddRequestHeaders(
SafeWinHttpHandle requestHandle,
@@ -73,7 +73,7 @@ internal static partial class Interop
}
#endif
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpAddRequestHeaders(
SafeWinHttpHandle requestHandle,
@@ -81,7 +81,7 @@ internal static partial class Interop
uint headersLength,
uint modifiers);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpSendRequest(
SafeWinHttpHandle requestHandle,
@@ -92,19 +92,19 @@ internal static partial class Interop
uint totalLength,
IntPtr context);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpReceiveResponse(
SafeWinHttpHandle requestHandle,
IntPtr reserved);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpQueryDataAvailable(
SafeWinHttpHandle requestHandle,
IntPtr parameterIgnoredAndShouldBeNullForAsync);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpReadData(
SafeWinHttpHandle requestHandle,
@@ -112,7 +112,7 @@ internal static partial class Interop
uint bufferSize,
IntPtr parameterIgnoredAndShouldBeNullForAsync);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpQueryHeaders(
SafeWinHttpHandle requestHandle,
@@ -122,7 +122,7 @@ internal static partial class Interop
ref uint bufferLength,
ref uint index);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpQueryHeaders(
SafeWinHttpHandle requestHandle,
@@ -132,7 +132,7 @@ internal static partial class Interop
ref uint bufferLength,
IntPtr index);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpQueryOption(
SafeWinHttpHandle handle,
@@ -140,7 +140,7 @@ internal static partial class Interop
ref IntPtr buffer,
ref uint bufferSize);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpQueryOption(
SafeWinHttpHandle handle,
@@ -148,7 +148,7 @@ internal static partial class Interop
IntPtr buffer,
ref uint bufferSize);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpQueryOption(
SafeWinHttpHandle handle,
@@ -156,7 +156,7 @@ internal static partial class Interop
ref uint buffer,
ref uint bufferSize);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpWriteData(
SafeWinHttpHandle requestHandle,
@@ -164,7 +164,7 @@ internal static partial class Interop
uint bufferSize,
IntPtr parameterIgnoredAndShouldBeNullForAsync);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpSetOption(
SafeWinHttpHandle handle,
@@ -172,7 +172,7 @@ internal static partial class Interop
ref uint optionData,
uint optionLength = sizeof(uint));
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpSetOption(
SafeWinHttpHandle handle,
@@ -180,7 +180,7 @@ internal static partial class Interop
IntPtr optionData,
uint optionLength);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpSetCredentials(
SafeWinHttpHandle requestHandle,
@@ -190,7 +190,7 @@ internal static partial class Interop
string? password,
IntPtr reserved);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpQueryAuthSchemes(
SafeWinHttpHandle requestHandle,
@@ -198,7 +198,7 @@ internal static partial class Interop
out uint firstScheme,
out uint authTarget);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpSetTimeouts(
SafeWinHttpHandle handle,
@@ -207,19 +207,19 @@ internal static partial class Interop
int sendTimeout,
int receiveTimeout);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool WinHttpGetIEProxyConfigForCurrentUser(
out WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[return: MarshalAs(UnmanagedType.Bool)]public static partial bool WinHttpGetProxyForUrl(
SafeWinHttpHandle? sessionHandle,
string url,
ref WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions,
out WINHTTP_PROXY_INFO proxyInfo);
- [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.WinHttp, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static partial IntPtr WinHttpSetStatusCallback(
SafeWinHttpHandle handle,
WINHTTP_STATUS_CALLBACK callback,
diff --git a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.PlaySound.cs b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.PlaySound.cs
index 51526b50417..f0a362676d8 100644
--- a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.PlaySound.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.PlaySound.cs
@@ -17,7 +17,7 @@ internal static partial class Interop
internal const int SND_FILENAME = 0x20000;
internal const int SND_NOSTOP = 0x10;
- [GeneratedDllImport(Libraries.WinMM, EntryPoint = "PlaySoundW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.WinMM, EntryPoint = "PlaySoundW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool PlaySound(string soundName, IntPtr hmod, int soundFlags);
[GeneratedDllImport(Libraries.WinMM, EntryPoint = "PlaySoundW")]
diff --git a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.mmioOpen.cs b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.mmioOpen.cs
index 143976534f1..85da9dfc980 100644
--- a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.mmioOpen.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.mmioOpen.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
internal const int MMIO_READ = 0x00000000;
internal const int MMIO_ALLOCBUF = 0x00010000;
- [GeneratedDllImport(Libraries.WinMM, EntryPoint = "mmioOpenW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.WinMM, EntryPoint = "mmioOpenW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr mmioOpen(string fileName, IntPtr not_used, int flags);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoExW.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoExW.cs
index 11438ec180d..4fc9f28c55c 100644
--- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoExW.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoExW.cs
@@ -17,7 +17,7 @@ internal static partial class Interop
internal const int NS_ALL = 0;
- [GeneratedDllImport(Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Ws2_32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int GetAddrInfoExW(
string pName,
string? pServiceName,
diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoW.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoW.cs
index cd1e42d99d4..70be2c9a38e 100644
--- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoW.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoW.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Winsock
{
- [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial int GetAddrInfoW(
string pNameName,
string? pServiceName,
diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetNameInfoW.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetNameInfoW.cs
index 7825ed7ac5a..2a5882ddae5 100644
--- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetNameInfoW.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetNameInfoW.cs
@@ -19,7 +19,7 @@ internal static partial class Interop
NI_DGRAM = 0x10, /* Service is a datagram service */
}
- [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial SocketError GetNameInfoW(
byte* pSockaddr,
int SockaddrLength,
diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSADuplicateSocket.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSADuplicateSocket.cs
index 8743ea6e760..1d1254646d5 100644
--- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSADuplicateSocket.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSADuplicateSocket.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Winsock
{
- [GeneratedDllImport(Interop.Libraries.Ws2_32, EntryPoint = "WSADuplicateSocketW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Ws2_32, EntryPoint = "WSADuplicateSocketW", SetLastError = true)]
internal static unsafe partial int WSADuplicateSocket(
SafeSocketHandle s,
uint dwProcessId,
diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.SafeCloseSocket.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.SafeCloseSocket.cs
index fcf408c262a..9ababac9065 100644
--- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.SafeCloseSocket.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.SafeCloseSocket.cs
@@ -9,7 +9,7 @@ internal static partial class Interop
{
internal static partial class Winsock
{
- [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr WSASocketW(
AddressFamily addressFamily,
SocketType socketType,
diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.cs
index 9f0060b4afd..f18f7d214f8 100644
--- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.cs
@@ -12,7 +12,7 @@ internal static partial class Interop
{
internal static partial class Winsock
{
- [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial IntPtr WSASocketW(
AddressFamily addressFamily,
SocketType socketType,
diff --git a/src/libraries/Common/src/Interop/Windows/Wkscli/Interop.NetWkstaGetInfo.cs b/src/libraries/Common/src/Interop/Windows/Wkscli/Interop.NetWkstaGetInfo.cs
index 3288f2d2a1f..b21852267e1 100644
--- a/src/libraries/Common/src/Interop/Windows/Wkscli/Interop.NetWkstaGetInfo.cs
+++ b/src/libraries/Common/src/Interop/Windows/Wkscli/Interop.NetWkstaGetInfo.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Wkscli
{
- [GeneratedDllImport(Libraries.Wkscli, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wkscli, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int NetWkstaGetInfo(string server, int level, ref IntPtr buffer);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs
index 34fe73e8984..ea1f38f2f5c 100644
--- a/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs
+++ b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs
@@ -9,63 +9,63 @@ internal static partial class Interop
{
internal static partial class Ldap
{
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_free", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_free", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ber_free(IntPtr berelement, int option);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_alloc_t", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_alloc_t", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ber_alloc(int option);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_printf(SafeBerHandle berElement, string format, IntPtr value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_printf(SafeBerHandle berElement, string format, HGlobalMemHandle value, uint length);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_printf(SafeBerHandle berElement, string format);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_printf(SafeBerHandle berElement, string format, int value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_printf(SafeBerHandle berElement, string format, uint tag);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_flatten", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_flatten", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_flatten(SafeBerHandle berElement, ref IntPtr value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_init", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_init", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ber_init(BerVal value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_scanf(SafeBerHandle berElement, string format);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_scanf(SafeBerHandle berElement, string format, ref IntPtr ptrResult, ref uint bitLength);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_scanf(SafeBerHandle berElement, string format, ref int result);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_scanf(SafeBerHandle berElement, string format, ref IntPtr value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_bvfree", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_bvfree", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_bvfree(IntPtr value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_bvecfree", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ber_bvecfree", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ber_bvecfree(IntPtr value);
}
diff --git a/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs
index 043c8dadf04..8cc0f6a3baf 100644
--- a/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs
+++ b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs
@@ -9,55 +9,55 @@ internal static partial class Interop
{
internal static partial class Ldap
{
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_bind_sW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_bind_sW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_bind_s(ConnectionHandle ldapHandle, string dn, in SEC_WINNT_AUTH_IDENTITY_EX credentials, BindMethod method);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_initW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_initW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_init(string hostName, int portNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_connect", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_connect")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_connect(ConnectionHandle ldapHandle, in LDAP_TIMEVAL timeout);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_unbind", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_unbind")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_unbind(IntPtr ldapHandle);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_get_option_int(ConnectionHandle ldapHandle, LdapOption option, ref int outValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_set_option_int(ConnectionHandle ldapHandle, LdapOption option, ref int inValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_get_option_ptr(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr outValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_set_option_ptr(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr inValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_get_option_sechandle(ConnectionHandle ldapHandle, LdapOption option, ref SecurityHandle outValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static unsafe partial int ldap_get_option_secInfo(ConnectionHandle ldapHandle, LdapOption option, void* outValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_set_option_referral(ConnectionHandle ldapHandle, LdapOption option, ref LdapReferralCallback outValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_set_option_clientcert(ConnectionHandle ldapHandle, LdapOption option, QUERYCLIENTCERT outValue);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_set_option_servercert(ConnectionHandle ldapHandle, LdapOption option, VERIFYSERVERCERT outValue);
@@ -65,138 +65,138 @@ internal static partial class Interop
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int LdapGetLastError();
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "cldap_openW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "cldap_openW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr cldap_open(string hostName, int portNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_simple_bind_sW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_simple_bind_sW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_simple_bind_s(ConnectionHandle ldapHandle, string distinguishedName, string password);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_delete_extW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_delete_extW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_delete_ext(ConnectionHandle ldapHandle, string dn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_result", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_result", SetLastError = true)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_result(ConnectionHandle ldapHandle, int messageId, int all, in LDAP_TIMEVAL timeout, ref IntPtr Mesage);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_resultW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_resultW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_parse_result(ConnectionHandle ldapHandle, IntPtr result, ref int serverError, ref IntPtr dn, ref IntPtr message, ref IntPtr referral, ref IntPtr control, byte freeIt);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_resultW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_resultW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_parse_result_referral(ConnectionHandle ldapHandle, IntPtr result, IntPtr serverError, IntPtr dn, IntPtr message, ref IntPtr referral, IntPtr control, byte freeIt);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_memfreeW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_memfreeW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial void ldap_memfree(IntPtr value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_value_freeW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_value_freeW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_value_free(IntPtr value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_controls_freeW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_controls_freeW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_controls_free(IntPtr value);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_abandon", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_abandon")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_abandon(ConnectionHandle ldapHandle, int messagId);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_start_tls_sW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_start_tls_sW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_start_tls(ConnectionHandle ldapHandle, ref int ServerReturnValue, ref IntPtr Message, IntPtr ServerControls, IntPtr ClientControls);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_stop_tls_s", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_stop_tls_s")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial byte ldap_stop_tls(ConnectionHandle ldapHandle);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_rename_extW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_rename_extW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_rename(ConnectionHandle ldapHandle, string dn, string newRdn, string newParentDn, int deleteOldRdn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_compare_extW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_compare_extW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_compare(ConnectionHandle ldapHandle, string dn, string attributeName, string strValue, BerVal binaryValue, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_add_extW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_add_extW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_add(ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_modify_extW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_modify_extW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_modify(ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_extended_operationW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_extended_operationW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_extended_operation(ConnectionHandle ldapHandle, string oid, BerVal data, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_extended_resultW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_extended_resultW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_parse_extended_result(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr oid, ref IntPtr data, byte freeIt);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_msgfree", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_msgfree")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_msgfree(IntPtr result);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_search_extW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_search_extW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_search(ConnectionHandle ldapHandle, string dn, int scope, string filter, IntPtr attributes, bool attributeOnly, IntPtr servercontrol, IntPtr clientcontrol, int timelimit, int sizelimit, ref int messageNumber);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_first_entry", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_first_entry")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_first_entry(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_next_entry", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_next_entry")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_next_entry(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_first_reference", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_first_reference")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_first_reference(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_next_reference", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_next_reference")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_next_reference(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_dnW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_dnW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_get_dn(ConnectionHandle ldapHandle, IntPtr result);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_first_attributeW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_first_attributeW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_first_attribute(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr address);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_next_attributeW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_next_attributeW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_next_attribute(ConnectionHandle ldapHandle, IntPtr result, IntPtr address);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_values_lenW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_get_values_lenW", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_get_values_len(ConnectionHandle ldapHandle, IntPtr result, string name);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_value_free_len", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_value_free_len")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr ldap_value_free_len(IntPtr berelement);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_referenceW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_parse_referenceW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_parse_reference(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr referrals);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_create_sort_controlW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_create_sort_controlW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_create_sort_control(ConnectionHandle handle, IntPtr keys, byte critical, ref IntPtr control);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_control_freeW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_control_freeW")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_control_free(IntPtr control);
- [GeneratedDllImport("Crypt32.dll", EntryPoint = "CertFreeCRLContext", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("Crypt32.dll", EntryPoint = "CertFreeCRLContext")]
public static partial int CertFreeCRLContext(IntPtr certContext);
- [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_result2error", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Wldap32, EntryPoint = "ldap_result2error")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial int ldap_result2error(ConnectionHandle ldapHandle, IntPtr result, int freeIt);
}
diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs
index 2d6c3990e0c..3c94e8da00f 100644
--- a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs
+++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs
@@ -19,9 +19,9 @@ namespace System.Runtime.InteropServices
#endif
sealed class GeneratedDllImportAttribute : Attribute
{
- public CharSet CharSet { get; set; }
public string? EntryPoint { get; set; }
public bool SetLastError { get; set; }
+ public StringMarshalling StringMarshalling { get; set; }
public GeneratedDllImportAttribute(string dllName)
{
diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/StringMarshalling.cs b/src/libraries/Common/src/System/Runtime/InteropServices/StringMarshalling.cs
new file mode 100644
index 00000000000..90f17af94ed
--- /dev/null
+++ b/src/libraries/Common/src/System/Runtime/InteropServices/StringMarshalling.cs
@@ -0,0 +1,23 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+//
+// Types in this file are used for generated p/invokes
+//
+namespace System.Runtime.InteropServices
+{
+ /// <summary>
+ /// Specifies how strings should be marshalled for generated p/invokes
+ /// </summary>
+#if DLLIMPORT_GENERATOR_TEST
+ public
+#else
+ internal
+#endif
+ enum StringMarshalling
+ {
+ Custom = 0,
+ Utf8, // UTF-8
+ Utf16, // UTF-16, machine-endian
+ }
+}
diff --git a/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs b/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs
index 7ab0e9a49d7..decefa1400c 100644
--- a/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs
+++ b/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs
@@ -109,7 +109,7 @@ namespace System
}
}
- [GeneratedDllImport("advapi32.dll", EntryPoint = "LogonUserW", SetLastError = true, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("advapi32.dll", EntryPoint = "LogonUserW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial bool LogonUser(string userName, string domain, string password, int logonType, int logonProvider, out SafeAccessTokenHandle safeAccessTokenHandle);
#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
diff --git a/src/libraries/Microsoft.Win32.Registry/tests/Helpers.cs b/src/libraries/Microsoft.Win32.Registry/tests/Helpers.cs
index 76ebbaf1809..0cd7c8160df 100644
--- a/src/libraries/Microsoft.Win32.Registry/tests/Helpers.cs
+++ b/src/libraries/Microsoft.Win32.Registry/tests/Helpers.cs
@@ -9,7 +9,7 @@ namespace Microsoft.Win32.RegistryTests
{
internal static partial class Helpers
{
- [GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueW", SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "RegSetValueW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial int RegSetValue(SafeRegistryHandle handle, string value, int regType, string sb, int sizeIgnored);
internal static bool SetDefaultValue(this RegistryKey key, string value)
@@ -18,7 +18,7 @@ namespace Microsoft.Win32.RegistryTests
return RegSetValue(key.Handle, null, REG_SZ, value, 0) == 0;
}
- [GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegQueryValueExW", SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "RegQueryValueExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial int RegQueryValueEx(SafeRegistryHandle handle, string valueName, int[] reserved, IntPtr regType, byte[] value, ref int size);
internal static bool IsDefaultValueSet(this RegistryKey key)
@@ -29,7 +29,7 @@ namespace Microsoft.Win32.RegistryTests
return RegQueryValueEx(key.Handle, null, null, IntPtr.Zero, b, ref size) != ERROR_FILE_NOT_FOUND;
}
- [GeneratedDllImport(Interop.Libraries.Kernel32, EntryPoint = "SetEnvironmentVariableW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Kernel32, EntryPoint = "SetEnvironmentVariableW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool SetEnvironmentVariable(string lpName, string lpValue);
}
}
diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs
index 0e798d0b5f4..bf20eebf976 100644
--- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs
+++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs
@@ -552,7 +552,7 @@ namespace Microsoft.Win32
EventLogHandle session,
int flags);
- [GeneratedDllImport(Interop.Libraries.Wevtapi, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Wevtapi, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool EvtNextChannelPath(
EventLogHandle channelEnum,
int channelPathBufferSize,
@@ -564,7 +564,7 @@ namespace Microsoft.Win32
EventLogHandle session,
int flags);
- [GeneratedDllImport(Interop.Libraries.Wevtapi, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Wevtapi, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool EvtNextPublisherId(
EventLogHandle publisherEnum,
int publisherIdBufferSize,
@@ -646,7 +646,7 @@ namespace Microsoft.Win32
string[] valuePaths,
EvtRenderContextFlags flags);
- [GeneratedDllImport(Interop.Libraries.Wevtapi, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Wevtapi, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool EvtRender(
EventLogHandle context,
EventLogHandle eventHandle,
@@ -715,7 +715,7 @@ namespace Microsoft.Win32
#endif
};
- [GeneratedDllImport(Interop.Libraries.Wevtapi, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Wevtapi, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial bool EvtFormatMessage(
EventLogHandle publisherMetadataHandle,
EventLogHandle eventHandle,
diff --git a/src/libraries/System.DirectoryServices/src/Interop/SafeNativeMethods.cs b/src/libraries/System.DirectoryServices/src/Interop/SafeNativeMethods.cs
index b9f850d13db..e2941a78c1a 100644
--- a/src/libraries/System.DirectoryServices/src/Interop/SafeNativeMethods.cs
+++ b/src/libraries/System.DirectoryServices/src/Interop/SafeNativeMethods.cs
@@ -22,10 +22,10 @@ namespace System.DirectoryServices.Interop
ERROR_MORE_DATA = 234,
ERROR_SUCCESS = 0;
- [GeneratedDllImport(global::Interop.Libraries.Activeds, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Activeds, StringMarshalling = StringMarshalling.Utf16)]
public static unsafe partial int ADsGetLastError(out int error, char* errorBuffer, int errorBufferLength, char* nameBuffer, int nameBufferLength);
- [GeneratedDllImport(global::Interop.Libraries.Activeds, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Activeds, StringMarshalling = StringMarshalling.Utf16)]
public static partial int ADsSetLastError(int error, string? errorString, string? provider);
public class EnumVariant
diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs
index 93371a60a1e..48cb155c452 100644
--- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs
+++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs
@@ -309,7 +309,7 @@ namespace System.DirectoryServices.ActiveDirectory
ULONG Flags,
PDOMAIN_CONTROLLER_INFO* DomainControllerInfo
);*/
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcNameW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcNameW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DsGetDcName(
string? computerName,
string? domainName,
@@ -327,7 +327,7 @@ namespace System.DirectoryServices.ActiveDirectory
ULONG DcFlags,
PHANDLE RetGetDcContext
);*/
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcOpenW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcOpenW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DsGetDcOpen(
string? dnsName,
int optionFlags,
@@ -343,7 +343,7 @@ namespace System.DirectoryServices.ActiveDirectory
LPSOCKET_ADDRESS* SockAddresses,
LPTSTR* DnsHostName
);*/
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcNextW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcNextW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DsGetDcNext(
IntPtr getDcContextHandle,
ref IntPtr sockAddressCount,
@@ -353,7 +353,7 @@ namespace System.DirectoryServices.ActiveDirectory
/*void WINAPI DsGetDcClose(
HANDLE GetDcContextHandle
);*/
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcCloseW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetDcCloseW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial void DsGetDcClose(
IntPtr getDcContextHandle);
@@ -380,7 +380,7 @@ namespace System.DirectoryServices.ActiveDirectory
PDNS_RECORD *ppQueryResultsSet,
PVOID *pReserved
);*/
- [GeneratedDllImport(global::Interop.Libraries.Dnsapi, EntryPoint = "DnsQuery_W", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Dnsapi, EntryPoint = "DnsQuery_W", StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DnsQuery(
string recordName,
short recordType,
@@ -447,7 +447,7 @@ namespace System.DirectoryServices.ActiveDirectory
DWORD lpString2,
DWORD cchCount2
);*/
- [GeneratedDllImport(global::Interop.Libraries.Kernel32, EntryPoint = "CompareStringW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(global::Interop.Libraries.Kernel32, EntryPoint = "CompareStringW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int CompareString(
uint locale,
uint dwCmpFlags,
diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs
index 7cdcf8d7dee..17483507574 100644
--- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs
+++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs
@@ -574,16 +574,16 @@ namespace System.DirectoryServices.ActiveDirectory
internal static partial class UnsafeNativeMethods
{
- [GeneratedDllImport(global::Interop.Libraries.Activeds, EntryPoint = "ADsEncodeBinaryData", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Activeds, EntryPoint = "ADsEncodeBinaryData", StringMarshalling = StringMarshalling.Utf16)]
public static partial int ADsEncodeBinaryData(byte[] data, int length, ref IntPtr result);
[GeneratedDllImport(global::Interop.Libraries.Activeds, EntryPoint = "FreeADsMem")]
public static partial bool FreeADsMem(IntPtr pVoid);
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetSiteNameW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetSiteNameW", StringMarshalling = StringMarshalling.Utf16)]
public static partial int DsGetSiteName(string? dcName, ref IntPtr ptr);
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsEnumerateDomainTrustsW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsEnumerateDomainTrustsW", StringMarshalling = StringMarshalling.Utf16)]
public static partial int DsEnumerateDomainTrustsW(string serverName, int flags, out IntPtr domains, out int count);
[GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "NetApiBufferFree")]
@@ -604,7 +604,7 @@ namespace System.DirectoryServices.ActiveDirectory
[GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaDeleteTrustedDomain")]
public static partial uint LsaDeleteTrustedDomain(SafeLsaPolicyHandle handle, IntPtr pSid);
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "I_NetLogonControl2", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "I_NetLogonControl2", StringMarshalling = StringMarshalling.Utf16)]
public static partial int I_NetLogonControl2(string serverName, int FunctionCode, int QueryLevel, IntPtr data, out IntPtr buffer);
[GeneratedDllImport(global::Interop.Libraries.Kernel32, EntryPoint = "GetSystemTimeAsFileTime")]
@@ -629,13 +629,13 @@ namespace System.DirectoryServices.ActiveDirectory
PBYTE* Buffer
); */
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", StringMarshalling = StringMarshalling.Utf16)]
public static partial int DsRoleGetPrimaryDomainInformation(
[MarshalAs(UnmanagedType.LPTStr)] string lpServer,
DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
out IntPtr Buffer);
- [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", StringMarshalling = StringMarshalling.Utf16)]
public static partial int DsRoleGetPrimaryDomainInformation(
IntPtr lpServer,
DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs
index d968f39e77b..c1e712a72a2 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs
@@ -54,28 +54,28 @@ internal static partial class Interop
#endif
HandleRef hDC, DOCINFO lpDocInfo);
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int StartPage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int EndPage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int AbortDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int EndDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -93,7 +93,7 @@ internal static partial class Interop
#endif
HandleRef /*DEVMODE*/ lpDevMode);
- [GeneratedDllImport(Libraries.Gdi32, EntryPoint = "AddFontResourceExW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, EntryPoint = "AddFontResourceExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int AddFontResourceEx(string lpszFilename, int fl, IntPtr pdv);
internal static int AddFontFile(string fileName)
@@ -101,21 +101,21 @@ internal static partial class Interop
return AddFontResourceEx(fileName, /*FR_PRIVATE*/ 0x10, IntPtr.Zero);
}
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int ExtEscape(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int nEscape, int cbInput, ref int inData, int cbOutput, out int outData);
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int ExtEscape(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int nEscape, int cbInput, byte[] inData, int cbOutput, out int outData);
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int IntersectClipRect(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -129,7 +129,7 @@ internal static partial class Interop
#endif
HandleRef hObject, int nSize, ref BITMAP bm);
- [GeneratedDllImport(Libraries.Gdi32, EntryPoint = "GetObjectW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs
index 084d23d1adf..3d2545ea6ca 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs
@@ -22,7 +22,7 @@ internal static partial class Interop
return IntGlobalAlloc(uFlags, new UIntPtr(dwBytes));
}
- [GeneratedDllImport(Libraries.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Gdi32, SetLastError = true)]
internal static partial IntPtr SelectObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs
index 0b4506e9e55..97dbc841790 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
{
internal static partial class Shell32
{
- [GeneratedDllImport(Libraries.Shell32, EntryPoint = "ExtractAssociatedIconW", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(Libraries.Shell32, EntryPoint = "ExtractAssociatedIconW")]
internal static unsafe partial IntPtr ExtractAssociatedIcon(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs
index cffb777cbd9..ec372ff2010 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
{
internal static partial class User32
{
- [GeneratedDllImport(Libraries.User32, EntryPoint = "LoadIconW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, EntryPoint = "LoadIconW", SetLastError = true)]
internal static partial IntPtr LoadIcon(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -42,7 +42,7 @@ internal static partial class Interop
[GeneratedDllImport(Libraries.User32, SetLastError = true)]
public static partial int GetSystemMetrics(int nIndex);
- [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.User32, SetLastError = true)]
internal static partial bool DrawIconEx(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs
index 9b00c106e70..715c8cf5634 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs
@@ -11,10 +11,10 @@ internal static partial class Interop
{
internal static partial class Winspool
{
- [GeneratedDllImport(Libraries.Winspool, EntryPoint = "DeviceCapabilitiesW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Winspool, EntryPoint = "DeviceCapabilitiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DeviceCapabilities(string pDevice, string pPort, short fwCapabilities, IntPtr pOutput, IntPtr /*DEVMODE*/ pDevMode);
- [GeneratedDllImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DocumentProperties(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -29,7 +29,7 @@ internal static partial class Interop
#endif
HandleRef /*DEVMODE*/ pDevModeInput, int fMode);
- [GeneratedDllImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DocumentProperties(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -40,7 +40,7 @@ internal static partial class Interop
#endif
HandleRef hPrinter, string pDeviceName, IntPtr /*DEVMODE*/ pDevModeOutput, IntPtr /*DEVMODE*/ pDevModeInput, int fMode);
- [GeneratedDllImport(Libraries.Winspool, CharSet = CharSet.Auto, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Winspool, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int EnumPrinters(int flags, string? name, int level, IntPtr pPrinterEnum/*buffer*/, int cbBuf, out int pcbNeeded, out int pcReturned);
}
}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs
index 6ce3506cda7..f9d0e46502d 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs
@@ -118,10 +118,10 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipGetNearestColor(IntPtr graphics, out int argb);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipAddPathString(IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref RectangleF layoutRect, IntPtr format);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipAddPathStringI(IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref Rectangle layoutRect, IntPtr format);
[GeneratedDllImport(LibraryName)]
@@ -145,7 +145,7 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipGetImageThumbnail(IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipSaveImageToFile(IntPtr image, string filename, ref Guid encoderClsID, IntPtr encoderParameters);
[GeneratedDllImport(LibraryName)]
@@ -347,7 +347,7 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref Interop.User32.LOGFONT lf);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipGetMetafileHeaderFromFile(string filename, IntPtr header);
[GeneratedDllImport(LibraryName)]
@@ -398,13 +398,13 @@ namespace System.Drawing
StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
StreamCloseDelegate close, StreamSizeDelegate size, IntPtr header);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileFromDelegate_linux(StreamGetHeaderDelegate getHeader,
StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref RectangleF frameRect,
MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileFromDelegateI_linux(StreamGetHeaderDelegate getHeader,
StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref Rectangle frameRect,
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Windows.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Windows.cs
index 9e94e7cff5f..12c5993cd64 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Windows.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Windows.cs
@@ -262,7 +262,7 @@ namespace System.Drawing
#endif
HandleRef addingPath, bool connect);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipAddPathString(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -277,7 +277,7 @@ namespace System.Drawing
#endif
HandleRef format);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipAddPathStringI(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -532,7 +532,7 @@ namespace System.Drawing
#endif
HandleRef image, out IntPtr cloneimage);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipSaveImageToFile(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -910,7 +910,7 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipGetMetafileHeaderFromEmf(IntPtr hEnhMetafile, MetafileHeaderEmf metafileHeaderEmf);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipGetMetafileHeaderFromFile(string filename, IntPtr header);
[GeneratedDllImport(LibraryName)]
@@ -933,13 +933,13 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipCreateMetafileFromStream(IntPtr stream, IntPtr* metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileStream(IntPtr stream, IntPtr referenceHdc, EmfType emfType, RectangleF* frameRect, MetafileFrameUnit frameUnit, string? description, IntPtr* metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileStream(IntPtr stream, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, IntPtr* metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileStreamI(IntPtr stream, IntPtr referenceHdc, EmfType emfType, Rectangle* frameRect, MetafileFrameUnit frameUnit, string? description, IntPtr* metafile);
[GeneratedDllImport(LibraryName)]
@@ -949,7 +949,7 @@ namespace System.Drawing
#endif
HandleRef graphics, int sizeData, byte[] data);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName)]
internal static partial int GdipCreateFontFromLogfontW(IntPtr hdc, ref Interop.User32.LOGFONT lf, out IntPtr font);
[GeneratedDllImport(LibraryName)]
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
index 6ebf6420636..04151cfa353 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
@@ -808,7 +808,7 @@ namespace System.Drawing
#endif
HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorChannelFlag flags);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipSetImageAttributesOutputChannelColorProfile(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -1008,7 +1008,7 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipCloneFontFamily(IntPtr fontfamily, out IntPtr clonefontfamily);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipCreateFontFamilyFromName(string name,
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -1031,7 +1031,7 @@ namespace System.Drawing
#endif
HandleRef fontFamily);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipGetFamilyName(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -1082,7 +1082,7 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipDeletePrivateFontCollection(ref IntPtr fontCollection);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipPrivateAddFontFile(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -2575,10 +2575,10 @@ namespace System.Drawing
[GeneratedDllImport(LibraryName)]
internal static partial int GdipDisposeImage(IntPtr image);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipCreateBitmapFromFile(string filename, out IntPtr bitmap);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipCreateBitmapFromFileICM(string filename, out IntPtr bitmap);
[GeneratedDllImport(LibraryName)]
@@ -2695,25 +2695,25 @@ namespace System.Drawing
#endif
WmfPlaceableFileHeader wmfplacealbeHeader, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipCreateMetafileFromFile(string file, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileI(IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipRecordMetafileFileNameI(string fileName, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[GeneratedDllImport(LibraryName)]
@@ -2976,7 +2976,7 @@ namespace System.Drawing
#endif
HandleRef brush, Rectangle* rects, int count);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(LibraryName, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipDrawString(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -3189,7 +3189,7 @@ namespace System.Drawing
#endif
HandleRef brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipMeasureString(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -3204,7 +3204,7 @@ namespace System.Drawing
#endif
HandleRef stringFormat, ref RectangleF boundingBox, out int codepointsFitted, out int linesFilled);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipMeasureCharacterRanges(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
@@ -3430,10 +3430,10 @@ namespace System.Drawing
#endif
HandleRef graphics, int destSpace, int srcSpace, Point* points, int count);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipLoadImageFromFileICM(string filename, out IntPtr image);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GdipLoadImageFromFile(string filename, out IntPtr image);
[GeneratedDllImport(LibraryName)]
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/LibcupsNative.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/LibcupsNative.cs
index a4a73646bd5..6052738d20a 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/LibcupsNative.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/LibcupsNative.cs
@@ -32,29 +32,34 @@ namespace System.Drawing.Printing
[GeneratedDllImport(LibraryName)]
internal static partial void cupsFreeDests(int num_dests, IntPtr dests);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(LibraryName)]
internal static partial IntPtr cupsTempFd(sbyte[] sb, int len);
[GeneratedDllImport(LibraryName)]
internal static partial IntPtr cupsGetDefault();
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Ansi)]
- internal static partial int cupsPrintFile(string printer, string filename, string title, int num_options, IntPtr options);
+ [GeneratedDllImport(LibraryName)]
+ internal static partial int cupsPrintFile(
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string printer,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string filename,
+ [MarshalAs(UnmanagedType.LPUTF8Str)] string title,
+ int num_options,
+ IntPtr options);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Ansi)]
- internal static partial IntPtr cupsGetPPD(string printer);
+ [GeneratedDllImport(LibraryName)]
+ internal static partial IntPtr cupsGetPPD([MarshalAs(UnmanagedType.LPUTF8Str)] string printer);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Ansi)]
- internal static partial IntPtr ppdOpenFile(string filename);
+ [GeneratedDllImport(LibraryName)]
+ internal static partial IntPtr ppdOpenFile([MarshalAs(UnmanagedType.LPUTF8Str)] string filename);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Ansi)]
- internal static partial IntPtr ppdFindOption(IntPtr ppd_file, string keyword);
+ [GeneratedDllImport(LibraryName)]
+ internal static partial IntPtr ppdFindOption(IntPtr ppd_file, [MarshalAs(UnmanagedType.LPUTF8Str)] string keyword);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(LibraryName)]
internal static partial void ppdClose(IntPtr ppd);
- [GeneratedDllImport(LibraryName, CharSet = CharSet.Ansi)]
- internal static partial int cupsParseOptions(string arg, int number_of_options, ref IntPtr options);
+ [GeneratedDllImport(LibraryName)]
+ internal static partial int cupsParseOptions([MarshalAs(UnmanagedType.LPUTF8Str)] string arg, int number_of_options, ref IntPtr options);
[GeneratedDllImport(LibraryName)]
internal static partial void cupsFreeOptions(int number_options, IntPtr options);
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs
index 90b91cbe547..e7f64052d75 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs
@@ -151,7 +151,7 @@ namespace System.Drawing
}
#region Cocoa Methods
- [GeneratedDllImport("libobjc.dylib", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport("libobjc.dylib", StringMarshalling = StringMarshalling.Utf8)]
public static partial IntPtr objc_getClass(string className);
[GeneratedDllImport("libobjc.dylib", EntryPoint = "objc_msgSend")]
public static partial IntPtr intptr_objc_msgSend(IntPtr basePtr, IntPtr selector);
@@ -160,7 +160,7 @@ namespace System.Drawing
[GeneratedDllImport("libobjc.dylib", EntryPoint = "objc_msgSend")]
[return:MarshalAs(UnmanagedType.U1)]
public static partial bool bool_objc_msgSend(IntPtr handle, IntPtr selector);
- [GeneratedDllImport("libobjc.dylib", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport("libobjc.dylib", StringMarshalling = StringMarshalling.Utf8)]
public static partial IntPtr sel_registerName(string selectorName);
#endregion
diff --git a/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Unix.cs b/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Unix.cs
index 1e50125b13e..def9a99cb49 100644
--- a/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Unix.cs
+++ b/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Unix.cs
@@ -196,7 +196,7 @@ namespace System.IO.Compression.Tests
return expectedPermissions;
}
- [GeneratedDllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport("libc", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
private static partial int mkfifo(string path, int mode);
}
}
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.NotifyFilter.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.NotifyFilter.cs
index e7623b4d094..9fd5f1d6297 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.NotifyFilter.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.NotifyFilter.cs
@@ -10,7 +10,7 @@ namespace System.IO.Tests
[ActiveIssue("https://github.com/dotnet/runtime/issues/34583", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
public partial class Directory_NotifyFilter_Tests : FileSystemWatcherTest
{
- [GeneratedDllImport("advapi32.dll", EntryPoint = "SetNamedSecurityInfoW", SetLastError = true, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("advapi32.dll", EntryPoint = "SetNamedSecurityInfoW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial uint SetSecurityInfoByHandle( string name, uint objectType, uint securityInformation,
IntPtr owner, IntPtr group, IntPtr dacl, IntPtr sacl);
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.NotifyFilter.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.NotifyFilter.cs
index a98d06096b3..e3f2c95eaad 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.NotifyFilter.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.NotifyFilter.cs
@@ -12,7 +12,7 @@ namespace System.IO.Tests
[ActiveIssue("https://github.com/dotnet/runtime/issues/34583", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
public partial class File_NotifyFilter_Tests : FileSystemWatcherTest
{
- [GeneratedDllImport("advapi32.dll", EntryPoint = "SetNamedSecurityInfoW", SetLastError = true, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport("advapi32.dll", EntryPoint = "SetNamedSecurityInfoW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial uint SetSecurityInfoByHandle(string name, uint objectType, uint securityInformation,
IntPtr owner, IntPtr group, IntPtr dacl, IntPtr sacl);
diff --git a/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Unix.cs b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Unix.cs
index 96b7c63f80a..011e4c188d3 100644
--- a/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Unix.cs
+++ b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Unix.cs
@@ -11,7 +11,7 @@ namespace System.IO.Tests
[GeneratedDllImport("libc", SetLastError = true)]
protected static partial int geteuid();
- [GeneratedDllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport("libc", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
protected static partial int mkfifo(string path, int mode);
}
}
diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs
index 89652ef5bd7..cd0c98c44b5 100644
--- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs
+++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs
@@ -34,7 +34,7 @@ namespace System.IO.MemoryMappedFiles.Tests
[GeneratedDllImport("libc", SetLastError = true)]
private static partial int sysconf(int name);
- [GeneratedDllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
+ [GeneratedDllImport("libc", StringMarshalling = StringMarshalling.Utf8, SetLastError = true)]
protected static partial int mkfifo(string path, int mode);
/// <summary>Asserts that the handle's inheritability matches the specified value.</summary>
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs
index ab15b9ca274..46e5d0502c7 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs
@@ -41,7 +41,7 @@ namespace System.Diagnostics.Tracing
[GeneratedDllImport(RuntimeHelpers.QCall)]
private static partial bool IsEventSourceLoggingEnabled();
- [GeneratedDllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(RuntimeHelpers.QCall, StringMarshalling = StringMarshalling.Utf16)]
private static partial void LogEventSource(int eventID, string? eventName, string eventSourceName, string payload);
private static readonly List<char> escape_seq = new List<char> { '\b', '\f', '\n', '\r', '\t', '\"', '\\' };
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md
deleted file mode 100644
index 2bf47965696..00000000000
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md
+++ /dev/null
@@ -1 +0,0 @@
-; Shipped analyzer releases \ No newline at end of file
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md
deleted file mode 100644
index 05e2158b078..00000000000
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md
+++ /dev/null
@@ -1,25 +0,0 @@
-### New Rules
-
-Rule ID | Category | Severity | Notes
---------|----------|----------|-------
-DLLIMPORTGEN001 | SourceGeneration | Error | TypeNotSupported
-DLLIMPORTGEN002 | SourceGeneration | Error | ConfigurationNotSupported
-DLLIMPORTGEN003 | SourceGeneration | Error | TargetFrameworkNotSupported
-DLLIMPORTGENANALYZER001 | Usage | Error | BlittableTypeMustBeBlittable
-DLLIMPORTGENANALYZER002 | Usage | Error | CannotHaveMultipleMarshallingAttributes
-DLLIMPORTGENANALYZER003 | Usage | Error | NativeTypeMustBeNonNull
-DLLIMPORTGENANALYZER004 | Usage | Error | NativeTypeMustBeBlittable
-DLLIMPORTGENANALYZER005 | Usage | Error | GetPinnableReferenceReturnTypeBlittable
-DLLIMPORTGENANALYZER006 | Usage | Error | NativeTypeMustBePointerSized
-DLLIMPORTGENANALYZER007 | Usage | Error | NativeTypeMustHaveRequiredShape
-DLLIMPORTGENANALYZER008 | Usage | Error | ValuePropertyMustHaveSetter
-DLLIMPORTGENANALYZER009 | Usage | Error | ValuePropertyMustHaveGetter
-DLLIMPORTGENANALYZER010 | Usage | Warning | GetPinnableReferenceShouldSupportAllocatingMarshallingFallback
-DLLIMPORTGENANALYZER011 | Usage | Warning | StackallocMarshallingShouldSupportAllocatingMarshallingFallback
-DLLIMPORTGENANALYZER012 | Usage | Error | StackallocConstructorMustHaveStackBufferSizeConstant
-DLLIMPORTGENANALYZER013 | Usage | Warning | GeneratedDllImportMissingRequiredModifiers
-DLLIMPORTGENANALYZER014 | Usage | Error | RefValuePropertyUnsupported
-DLLIMPORTGENANALYZER015 | Interoperability | Disabled | ConvertToGeneratedDllImportAnalyzer
-DLLIMPORTGENANALYZER016 | Usage | Error | GenericTypeMustBeClosed
-DLLIMPORTGENANALYZER017 | Usage | Warning | GeneratedDllImportContainingTypeMissingModifiers
-DLLIMPORTGENANALYZER018 | Usage | Error | MarshallerGetPinnableReferenceRequiresValueProperty
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs
index e0ad5552f21..cf139a2da3a 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs
@@ -38,6 +38,7 @@ namespace Microsoft.Interop.Analyzers
nameof(DllImportAttribute.ExactSpelling),
nameof(DllImportAttribute.PreserveSig),
nameof(DllImportAttribute.SetLastError),
+ nameof(StringMarshalling),
nameof(DllImportAttribute.ThrowOnUnmappableChar)
};
@@ -50,11 +51,12 @@ namespace Microsoft.Interop.Analyzers
if (root == null || model == null)
return;
- // Nothing to do if the GeneratedDllImportAttribute is not in the compilation
+ // Nothing to do if GeneratedDllImportAttribute is not in the compilation
INamedTypeSymbol? generatedDllImportAttrType = model.Compilation.GetTypeByMetadataName(TypeNames.GeneratedDllImportAttribute);
if (generatedDllImportAttrType == null)
return;
+ // Nothing to do if DllImportAttribute is not in the compilation
INamedTypeSymbol? dllImportAttrType = model.Compilation.GetTypeByMetadataName(typeof(DllImportAttribute).FullName);
if (dllImportAttrType == null)
return;
@@ -146,9 +148,8 @@ namespace Microsoft.Interop.Analyzers
editor,
generator,
dllImportSyntax,
- methodSymbol.GetDllImportData()!,
+ methodSymbol,
generatedDllImportAttrType,
- methodSymbol.Name,
entryPointSuffix,
out SyntaxNode? unmanagedCallConvAttributeMaybe);
@@ -355,21 +356,25 @@ namespace Microsoft.Interop.Analyzers
DocumentEditor editor,
SyntaxGenerator generator,
AttributeSyntax dllImportSyntax,
- DllImportData dllImportData,
+ IMethodSymbol methodSymbol,
INamedTypeSymbol generatedDllImportAttrType,
- string methodName,
char? entryPointSuffix,
out SyntaxNode? unmanagedCallConvAttributeMaybe)
{
unmanagedCallConvAttributeMaybe = null;
+
+ DllImportData dllImportData = methodSymbol.GetDllImportData()!;
+ string methodName = methodSymbol.Name;
+
// Create GeneratedDllImport based on the DllImport attribute
SyntaxNode generatedDllImportSyntax = generator.ReplaceNode(dllImportSyntax,
dllImportSyntax.Name,
generator.TypeExpression(generatedDllImportAttrType));
// Update attribute arguments for GeneratedDllImport
+ bool hasEntryPointAttributeArgument = false;
+ List<SyntaxNode> argumentsToAdd= new List<SyntaxNode>();
List<SyntaxNode> argumentsToRemove = new List<SyntaxNode>();
- AttributeArgumentSyntax? entryPointAttributeArgument = null;
foreach (SyntaxNode argument in generator.GetAttributeArguments(generatedDllImportSyntax))
{
if (argument is not AttributeArgumentSyntax attrArg)
@@ -384,6 +389,25 @@ namespace Microsoft.Interop.Analyzers
// has the equivalent behaviour of BestFitMapping=false, so we can remove the argument.
argumentsToRemove.Add(argument);
}
+ else if (IsMatchingNamedArg(attrArg, nameof(DllImportAttribute.CharSet)))
+ {
+ if (MethodRequiresStringMarshalling(methodSymbol))
+ {
+ // For Unicode, we can translate the argument to StringMarshalling.Utf16
+ // TODO: Handle ANSI once we have a public marshaller type for ANSI strings that we can use with StringMarshallerCustomType
+ if (dllImportData.CharacterSet == CharSet.Unicode)
+ {
+ ITypeSymbol stringMarshallingType = editor.SemanticModel.Compilation.GetTypeByMetadataName(TypeNames.StringMarshalling)!;
+ argumentsToAdd.Add(generator.AttributeArgument(
+ nameof(StringMarshalling),
+ generator.MemberAccessExpression(
+ generator.TypeExpression(stringMarshallingType),
+ generator.IdentifierName(nameof(StringMarshalling.Utf16)))));
+ }
+ }
+
+ argumentsToRemove.Add(argument);
+ }
else if (dllImportData.ThrowOnUnmappableCharacter != null
&& !dllImportData.ThrowOnUnmappableCharacter.Value
&& IsMatchingNamedArg(attrArg, nameof(DllImportAttribute.ThrowOnUnmappableChar)))
@@ -410,29 +434,30 @@ namespace Microsoft.Interop.Analyzers
}
else if (IsMatchingNamedArg(attrArg, nameof(DllImportAttribute.EntryPoint)))
{
- entryPointAttributeArgument = attrArg;
+ hasEntryPointAttributeArgument = true;
if (!dllImportData.ExactSpelling && entryPointSuffix.HasValue)
{
- if (entryPointAttributeArgument.Expression.IsKind(SyntaxKind.StringLiteralExpression))
+ if (attrArg.Expression.IsKind(SyntaxKind.StringLiteralExpression))
{
- string? entryPoint = (string?)((LiteralExpressionSyntax)entryPointAttributeArgument.Expression).Token.Value;
+ string? entryPoint = (string?)((LiteralExpressionSyntax)attrArg.Expression).Token.Value;
if (entryPoint is not null)
{
- entryPointAttributeArgument = entryPointAttributeArgument.WithExpression(
+ argumentsToRemove.Add(attrArg);
+ argumentsToAdd.Add(attrArg.WithExpression(
SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression,
- SyntaxFactory.Literal(entryPoint + entryPointSuffix)));
+ SyntaxFactory.Literal(entryPoint + entryPointSuffix))));
}
}
else
{
- entryPointAttributeArgument = entryPointAttributeArgument.WithExpression(
+ argumentsToRemove.Add(attrArg);
+ argumentsToAdd.Add(attrArg.WithExpression(
SyntaxFactory.BinaryExpression(SyntaxKind.AddExpression,
- entryPointAttributeArgument.Expression,
- SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression,
- SyntaxFactory.Literal(entryPointSuffix.ToString()))));
+ attrArg.Expression,
+ SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression,
+ SyntaxFactory.Literal(entryPointSuffix.ToString())))));
}
}
- argumentsToRemove.Add(attrArg);
}
else if (IsMatchingNamedArg(attrArg, nameof(DllImportAttribute.PreserveSig)))
{
@@ -441,17 +466,14 @@ namespace Microsoft.Interop.Analyzers
}
}
- if (entryPointSuffix.HasValue && entryPointAttributeArgument is null)
+ if (entryPointSuffix.HasValue && !hasEntryPointAttributeArgument)
{
- entryPointAttributeArgument = (AttributeArgumentSyntax)generator.AttributeArgument("EntryPoint",
- generator.LiteralExpression(methodName + entryPointSuffix.Value));
+ argumentsToAdd.Add(generator.AttributeArgument("EntryPoint",
+ generator.LiteralExpression(methodName + entryPointSuffix.Value)));
}
generatedDllImportSyntax = generator.RemoveNodes(generatedDllImportSyntax, argumentsToRemove);
- if (entryPointAttributeArgument is not null)
- {
- generatedDllImportSyntax = generator.AddAttributeArguments(generatedDllImportSyntax, new[] { entryPointAttributeArgument });
- }
+ generatedDllImportSyntax = generator.AddAttributeArguments(generatedDllImportSyntax, argumentsToAdd);
return SortDllImportAttributeArguments((AttributeSyntax)generatedDllImportSyntax, generator);
}
@@ -543,5 +565,18 @@ namespace Microsoft.Interop.Analyzers
{
return arg.NameEquals != null && arg.NameEquals.Name.Identifier.Text == nameToMatch;
}
+
+ private static bool MethodRequiresStringMarshalling(IMethodSymbol method)
+ {
+ foreach (IParameterSymbol param in method.Parameters)
+ {
+ if (param.Type.SpecialType is SpecialType.System_String or SpecialType.System_Char)
+ {
+ return true;
+ }
+ }
+
+ return method.ReturnType.SpecialType is SpecialType.System_String or SpecialType.System_Char;
+ }
}
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs
index 92f2c4adc83..5828c07206d 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs
@@ -353,27 +353,28 @@ namespace Microsoft.Interop
// documented semanatics of DllImportAttribute:
// - https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute
DllImportMember userDefinedValues = DllImportMember.None;
- CharSet charSet = CharSet.Ansi;
string? entryPoint = null;
bool setLastError = false;
+ StringMarshalling stringMarshalling = StringMarshalling.Custom;
+
// All other data on attribute is defined as NamedArguments.
foreach (KeyValuePair<string, TypedConstant> namedArg in attrData.NamedArguments)
{
switch (namedArg.Key)
{
default:
- Debug.Fail($"An unknown member was found on {attrData.AttributeClass}");
+ Debug.Fail($"An unknown member '{namedArg.Key}' was found on {attrData.AttributeClass}");
continue;
- case nameof(GeneratedDllImportData.CharSet):
- userDefinedValues |= DllImportMember.CharSet;
+ case nameof(GeneratedDllImportData.StringMarshalling):
+ userDefinedValues |= DllImportMember.StringMarshalling;
// TypedConstant's Value property only contains primitive values.
if (namedArg.Value.Value is not int)
{
return null;
}
// A boxed primitive can be unboxed to an enum with the same underlying type.
- charSet = (CharSet)namedArg.Value.Value!;
+ stringMarshalling = (StringMarshalling)namedArg.Value.Value!;
break;
case nameof(GeneratedDllImportData.EntryPoint):
userDefinedValues |= DllImportMember.EntryPoint;
@@ -402,7 +403,7 @@ namespace Microsoft.Interop
return new GeneratedDllImportData(attrData.ConstructorArguments[0].Value!.ToString())
{
IsUserDefined = userDefinedValues,
- CharSet = charSet,
+ StringMarshalling = stringMarshalling,
EntryPoint = entryPoint,
SetLastError = setLastError,
};
@@ -476,13 +477,12 @@ namespace Microsoft.Interop
MethodDeclarationSyntax originalSyntax,
DllImportGeneratorOptions options)
{
+ var diagnostics = new GeneratorDiagnostics();
if (options.GenerateForwarders)
{
- return (PrintForwarderStub(originalSyntax, dllImportStub), dllImportStub.Diagnostics);
+ return (PrintForwarderStub(originalSyntax, dllImportStub, diagnostics), dllImportStub.Diagnostics.AddRange(diagnostics.Diagnostics));
}
- var diagnostics = new GeneratorDiagnostics();
-
// Generate stub code
var stubGenerator = new PInvokeStubCodeGenerator(
dllImportStub.Environment,
@@ -499,7 +499,7 @@ namespace Microsoft.Interop
if (stubGenerator.StubIsBasicForwarder
|| !stubGenerator.SupportsTargetFramework)
{
- return (PrintForwarderStub(originalSyntax, dllImportStub), dllImportStub.Diagnostics.AddRange(diagnostics.Diagnostics));
+ return (PrintForwarderStub(originalSyntax, dllImportStub, diagnostics), dllImportStub.Diagnostics.AddRange(diagnostics.Diagnostics));
}
ImmutableArray<AttributeSyntax> forwardedAttributes = dllImportStub.ForwardedAttributes;
@@ -529,8 +529,24 @@ namespace Microsoft.Interop
return (PrintGeneratedSource(originalSyntax, dllImportStub.StubContext, code), dllImportStub.Diagnostics.AddRange(diagnostics.Diagnostics));
}
- private MemberDeclarationSyntax PrintForwarderStub(MethodDeclarationSyntax userDeclaredMethod, IncrementalStubGenerationContext stub)
+ private MemberDeclarationSyntax PrintForwarderStub(MethodDeclarationSyntax userDeclaredMethod, IncrementalStubGenerationContext stub, GeneratorDiagnostics diagnostics)
{
+ GeneratedDllImportData targetDllImportData = GetTargetDllImportDataFromStubData(
+ stub.DllImportData,
+ userDeclaredMethod.Identifier.ValueText,
+ forwardAll: true);
+
+ if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.StringMarshalling)
+ && targetDllImportData.StringMarshalling != StringMarshalling.Utf16)
+ {
+ diagnostics.ReportCannotForwardToDllImport(
+ $"{nameof(TypeNames.GeneratedDllImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}",
+ $"{nameof(StringMarshalling)}{Type.Delimiter}{targetDllImportData.StringMarshalling}",
+ userDeclaredMethod);
+
+ targetDllImportData = targetDllImportData with { IsUserDefined = targetDllImportData.IsUserDefined & ~DllImportMember.StringMarshalling };
+ }
+
SyntaxTokenList modifiers = StripTriviaFromModifiers(userDeclaredMethod.Modifiers);
modifiers = AddToModifiers(modifiers, SyntaxKind.ExternKeyword);
// Create stub function
@@ -542,11 +558,7 @@ namespace Microsoft.Interop
.AddAttributeLists(
AttributeList(
SingletonSeparatedList(
- CreateDllImportAttributeForTarget(
- GetTargetDllImportDataFromStubData(
- stub.DllImportData,
- userDeclaredMethod.Identifier.ValueText,
- forwardAll: true)))));
+ CreateDllImportAttributeForTarget(targetDllImportData))));
MemberDeclarationSyntax toPrint = WrapMethodInContainingScopes(stub.StubContext, stubMethod);
@@ -560,6 +572,8 @@ namespace Microsoft.Interop
string stubTargetName,
string stubMethodName)
{
+ Debug.Assert(!options.GenerateForwarders, "GenerateForwarders should have already been handled to use a forwarder stub");
+
(ParameterListSyntax parameterList, TypeSyntax returnType, AttributeListSyntax returnTypeAttributes) = stubGenerator.GenerateTargetMethodSignatureData();
LocalFunctionStatementSyntax localDllImport = LocalFunctionStatement(returnType, stubTargetName)
.AddModifiers(
@@ -574,7 +588,7 @@ namespace Microsoft.Interop
GetTargetDllImportDataFromStubData(
dllImportData,
stubMethodName,
- options.GenerateForwarders))))))
+ forwardAll: false))))))
.WithParameterList(parameterList);
if (returnTypeAttributes is not null)
{
@@ -600,10 +614,11 @@ namespace Microsoft.Interop
CreateBoolExpressionSyntax(true))
};
- if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet))
+ if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.StringMarshalling))
{
+ Debug.Assert(targetDllImportData.StringMarshalling == StringMarshalling.Utf16);
NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.CharSet));
- ExpressionSyntax value = CreateEnumExpressionSyntax(targetDllImportData.CharSet);
+ ExpressionSyntax value = CreateEnumExpressionSyntax(CharSet.Unicode);
newAttributeArgs.Add(AttributeArgument(name, null, value));
}
if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.SetLastError))
@@ -647,7 +662,9 @@ namespace Microsoft.Interop
DllImportMember membersToForward = DllImportMember.All
// https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.setlasterror
// If SetLastError=true (default is false), the P/Invoke stub gets/caches the last error after invoking the native function.
- & ~DllImportMember.SetLastError;
+ & ~DllImportMember.SetLastError
+ // StringMarshalling does not have a direct mapping on DllImport. The generated code should handle string marshalling.
+ & ~DllImportMember.StringMarshalling;
if (forwardAll)
{
membersToForward = DllImportMember.All;
@@ -655,9 +672,9 @@ namespace Microsoft.Interop
var targetDllImportData = new GeneratedDllImportData(dllImportData.ModuleName)
{
- CharSet = dllImportData.CharSet,
EntryPoint = dllImportData.EntryPoint,
SetLastError = dllImportData.SetLastError,
+ StringMarshalling = dllImportData.StringMarshalling,
IsUserDefined = dllImportData.IsUserDefined & membersToForward
};
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj
index b46d0c83ac7..f3127acd4ad 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj
@@ -9,6 +9,9 @@
<RootNamespace>Microsoft.Interop</RootNamespace>
<IsRoslynComponent>true</IsRoslynComponent>
<RunAnalyzers>true</RunAnalyzers>
+ <!-- Disable RS2008: Enable analyzer release tracking
+ Diagnostics in runtime use a different mechanism (docs/project/list-of-diagnostics.md) -->
+ <NoWarn>RS2008;$(NoWarn)</NoWarn>
<!-- Packaging properties -->
<!-- In the future DllImportGenerator might ship as part of a package, but meanwhile disable packaging. -->
@@ -23,6 +26,11 @@
</PropertyGroup>
<ItemGroup>
+ <!-- Code included from System.Runtime.InteropServices -->
+ <Compile Include="$(CommonPath)System\Runtime\InteropServices\StringMarshalling.cs" Link="Production\StringMarshalling.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
<Compile Update="Resources.Designer.cs"
DesignTime="True"
AutoGen="True"
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs
index 1f6e7f16e09..49f920c0957 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs
@@ -153,14 +153,14 @@ namespace Microsoft.Interop
{
// Compute the current default string encoding value.
CharEncoding defaultEncoding = CharEncoding.Undefined;
- if (dllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet))
+ if (dllImportData.IsUserDefined.HasFlag(DllImportMember.StringMarshalling))
{
- defaultEncoding = dllImportData.CharSet switch
+ defaultEncoding = dllImportData.StringMarshalling switch
{
- CharSet.Unicode => CharEncoding.Utf16,
- CharSet.Auto => CharEncoding.PlatformDefined,
- CharSet.Ansi => CharEncoding.Ansi,
- _ => CharEncoding.Undefined, // [Compat] Do not assume a specific value for None
+ StringMarshalling.Utf16 => CharEncoding.Utf16,
+ StringMarshalling.Utf8 => CharEncoding.Utf8,
+ StringMarshalling.Custom => CharEncoding.Custom,
+ _ => CharEncoding.Undefined, // [Compat] Do not assume a specific value
};
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs
index 0424e15ce83..114062ad3f9 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs
@@ -2,9 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Collections.Generic;
using System.Runtime.InteropServices;
-using System.Text;
namespace Microsoft.Interop
{
@@ -15,9 +13,9 @@ namespace Microsoft.Interop
public enum DllImportMember
{
None = 0,
- CharSet = 1 << 0,
- EntryPoint = 1 << 1,
- SetLastError = 1 << 2,
+ EntryPoint = 1 << 0,
+ SetLastError = 1 << 1,
+ StringMarshalling = 1 << 2,
All = ~None
}
@@ -28,13 +26,13 @@ namespace Microsoft.Interop
/// The names of these members map directly to those on the
/// DllImportAttribute and should not be changed.
/// </remarks>
- public sealed record GeneratedDllImportData(string ModuleName)
+ internal sealed record GeneratedDllImportData(string ModuleName)
{
/// <summary>
/// Value set by the user on the original declaration.
/// </summary>
public DllImportMember IsUserDefined { get; init; }
- public CharSet CharSet { get; init; }
+ public StringMarshalling StringMarshalling { get; init; }
public string? EntryPoint { get; init; }
public bool SetLastError { get; init; }
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs
index 0ebfe4830d8..9b882858e8c 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs
@@ -11,7 +11,6 @@ using System.Text;
namespace Microsoft.Interop
{
-
/// <summary>
/// Class for reporting diagnostics in the DLL import generator
/// </summary>
@@ -23,6 +22,7 @@ namespace Microsoft.Interop
public const string TypeNotSupported = Prefix + "001";
public const string ConfigurationNotSupported = Prefix + "002";
public const string TargetFrameworkNotSupported = Prefix + "003";
+ public const string CannotForwardToDllImport = Prefix + "004";
}
private const string Category = "SourceGeneration";
@@ -127,6 +127,16 @@ namespace Microsoft.Interop
isEnabledByDefault: true,
description: GetResourceString(nameof(Resources.TargetFrameworkNotSupportedDescription)));
+ public static readonly DiagnosticDescriptor CannotForwardToDllImport =
+ new DiagnosticDescriptor(
+ Ids.CannotForwardToDllImport,
+ GetResourceString(nameof(Resources.CannotForwardToDllImportTitle)),
+ GetResourceString(nameof(Resources.CannotForwardToDllImportMessage)),
+ Category,
+ DiagnosticSeverity.Error,
+ isEnabledByDefault: true,
+ description: GetResourceString(nameof(Resources.CannotForwardToDllImportDescription)));
+
private readonly List<Diagnostic> _diagnostics = new List<Diagnostic>();
public IEnumerable<Diagnostic> Diagnostics => _diagnostics;
@@ -274,6 +284,22 @@ namespace Microsoft.Interop
minimumSupportedVersion.ToString(2)));
}
+ /// <summary>
+ /// Report diagnostic for configuration that cannot be forwarded to <see cref="DllImportAttribute" />
+ /// </summary>
+ /// <param name="name">Configuration name</param>
+ /// <param name="value">Configuration value</param>
+ /// <param name="method">Method with the arguments that cannot be forwarded</param>
+ public void ReportCannotForwardToDllImport(string name, string value, MethodDeclarationSyntax method)
+ {
+ _diagnostics.Add(
+ Diagnostic.Create(
+ CannotForwardToDllImport,
+ Location.Create(method.SyntaxTree, method.Identifier.Span),
+ name,
+ value));
+ }
+
private static LocalizableResourceString GetResourceString(string resourceName)
{
return new LocalizableResourceString(resourceName, Resources.ResourceManager, typeof(Resources));
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs
index c2739352c03..eeacde5ad96 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs
@@ -115,6 +115,33 @@ namespace Microsoft.Interop {
}
/// <summary>
+ /// Looks up a localized string similar to The generated &apos;DllImportAttribute&apos; will not have a value corresponding to &apos;{0}={1}&apos;..
+ /// </summary>
+ internal static string CannotForwardToDllImportDescription {
+ get {
+ return ResourceManager.GetString("CannotForwardToDllImportDescription", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to &apos;{0}={1}&apos; has no equivalent in &apos;DllImportAtttribute&apos; and will not be forwarded.
+ /// </summary>
+ internal static string CannotForwardToDllImportMessage {
+ get {
+ return ResourceManager.GetString("CannotForwardToDllImportMessage", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Specified &apos;GeneratedDllImportAttribute&apos; arguments cannot be forwarded to &apos;DllImportAttribute&apos;.
+ /// </summary>
+ internal static string CannotForwardToDllImportTitle {
+ get {
+ return ResourceManager.GetString("CannotForwardToDllImportTitle", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to The &apos;BlittableTypeAttribute&apos; and &apos;NativeMarshallingAttribute&apos; attributes are mutually exclusive..
/// </summary>
internal static string CannotHaveMultipleMarshallingAttributesDescription {
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx
index f6776650d2b..bf203cf1203 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx
+++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx
@@ -135,6 +135,17 @@
<data name="CallerAllocMarshallingShouldSupportAllocatingMarshallingFallbackMessage" xml:space="preserve">
<value>Native type '{0}' has a constructor taking a caller-allocated buffer, but does not support marshalling in scenarios where using a caller-allocated buffer is impossible</value>
</data>
+ <data name="CannotForwardToDllImportDescription" xml:space="preserve">
+ <value>The generated 'DllImportAttribute' will not have a value corresponding to '{0}={1}'.</value>
+ <comment>{0} and {1} are the name and value of an attribute argument</comment>
+ </data>
+ <data name="CannotForwardToDllImportMessage" xml:space="preserve">
+ <value>'{0}={1}' has no equivalent in 'DllImportAtttribute' and will not be forwarded</value>
+ <comment>{0} and {1} are the name and value of an attribute argument</comment>
+ </data>
+ <data name="CannotForwardToDllImportTitle" xml:space="preserve">
+ <value>Specified 'GeneratedDllImportAttribute' arguments cannot be forwarded to 'DllImportAttribute'</value>
+ </data>
<data name="CannotHaveMultipleMarshallingAttributesDescription" xml:space="preserve">
<value>The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive.</value>
</data>
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs
index ca61227661f..905034df768 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs
@@ -16,7 +16,6 @@ namespace Microsoft.Interop
private static readonly Utf16StringMarshaller s_utf16String = new();
private static readonly Utf8StringMarshaller s_utf8String = new();
private static readonly AnsiStringMarshaller s_ansiString = new AnsiStringMarshaller(s_utf8String);
- private static readonly PlatformDefinedStringMarshaller s_platformDefinedString = new PlatformDefinedStringMarshaller(s_utf16String, s_utf8String);
private static readonly Forwarder s_forwarder = new();
private static readonly BlittableMarshaller s_blittable = new();
@@ -149,11 +148,6 @@ namespace Microsoft.Interop
{
NotSupportedDetails = string.Format(Resources.MarshallingCharAsSpecifiedCharSetNotSupported, CharSet.Ansi)
};
- case CharEncoding.PlatformDefined:
- throw new MarshallingNotSupportedException(info, context) // [Compat] See conversion of CharSet.Auto.
- {
- NotSupportedDetails = string.Format(Resources.MarshallingCharAsSpecifiedCharSetNotSupported, CharSet.Auto)
- };
}
}
@@ -196,8 +190,6 @@ namespace Microsoft.Interop
return s_utf16String;
case CharEncoding.Utf8:
return s_utf8String;
- case CharEncoding.PlatformDefined:
- return s_platformDefinedString;
}
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs
deleted file mode 100644
index 655e2fe1b21..00000000000
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-using static Microsoft.Interop.MarshallerHelpers;
-
-namespace Microsoft.Interop
-{
- public sealed class PlatformDefinedStringMarshaller : ConditionalStackallocMarshallingGenerator
- {
- private static readonly TypeSyntax s_nativeType = PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword)));
-
- private readonly IMarshallingGenerator _windowsMarshaller;
- private readonly IMarshallingGenerator _nonWindowsMarshaller;
-
- public PlatformDefinedStringMarshaller(IMarshallingGenerator windowsMarshaller, IMarshallingGenerator nonWindowsMarshaller)
- {
- _windowsMarshaller = windowsMarshaller;
- _nonWindowsMarshaller = nonWindowsMarshaller;
- }
-
- public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context)
- {
- ExpressionSyntax windowsExpr = _windowsMarshaller.AsArgument(info, context).Expression;
- ExpressionSyntax nonWindowsExpr = _nonWindowsMarshaller.AsArgument(info, context).Expression;
-
- // If the Windows and non-Windows syntax are equivalent, just return one of them.
- if (windowsExpr.IsEquivalentTo(nonWindowsExpr))
- return Argument(windowsExpr);
-
- // OperatingSystem.IsWindows() ? << Windows code >> : << non-Windows code >>
- return Argument(
- ConditionalExpression(
- IsWindows,
- windowsExpr,
- nonWindowsExpr));
- }
-
- public override TypeSyntax AsNativeType(TypePositionInfo info)
- {
- // void*
- return s_nativeType;
- }
-
- public override ParameterSyntax AsParameter(TypePositionInfo info)
- {
- // void**
- // or
- // void*
- TypeSyntax type = info.IsByRef
- ? PointerType(AsNativeType(info))
- : AsNativeType(info);
- return Parameter(Identifier(info.InstanceIdentifier))
- .WithType(type);
- }
-
- public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, StubCodeContext context)
- {
- switch (context.CurrentStage)
- {
- case StubCodeContext.Stage.Setup:
- if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup))
- yield return conditionalAllocSetup;
-
- break;
- case StubCodeContext.Stage.Marshal:
- if (info.RefKind != RefKind.Out)
- {
- if (TryGetConditionalBlockForStatements(
- _windowsMarshaller.Generate(info, context),
- _nonWindowsMarshaller.Generate(info, context),
- out StatementSyntax marshal))
- {
- yield return marshal;
- }
- }
- break;
- case StubCodeContext.Stage.Pin:
- // [Compat] The built-in system could determine the platform at runtime and pin only on
- // the platform on which is is needed. In the generated source, if pinning is needed for
- // any platform, it is done on every platform.
- foreach (StatementSyntax s in _windowsMarshaller.Generate(info, context))
- yield return s;
-
- foreach (StatementSyntax s in _nonWindowsMarshaller.Generate(info, context))
- yield return s;
-
- break;
- case StubCodeContext.Stage.Unmarshal:
- if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In))
- {
- if (TryGetConditionalBlockForStatements(
- _windowsMarshaller.Generate(info, context),
- _nonWindowsMarshaller.Generate(info, context),
- out StatementSyntax unmarshal))
- {
- yield return unmarshal;
- }
- }
- break;
- case StubCodeContext.Stage.Cleanup:
- yield return GenerateConditionalAllocationFreeSyntax(info, context);
- break;
- }
- }
-
- public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
-
- public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
-
- // This marshaller only uses the conditional allocaction base for setup and cleanup.
- // It relies on the UTF-16 (Windows) and UTF-8 (non-Windows) string marshallers for allocation/marshalling.
- protected override ExpressionSyntax GenerateAllocationExpression(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, out bool allocationRequiresByteLength) => throw new NotImplementedException();
- protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) => throw new NotImplementedException();
- protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) => throw new NotImplementedException();
-
- protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info, StubCodeContext context)
- {
- return StringMarshaller.FreeExpression(context.GetIdentifiers(info).native);
- }
-
- private bool TryGetConditionalBlockForStatements(
- IEnumerable<StatementSyntax> windowsStatements,
- IEnumerable<StatementSyntax> nonWindowsStatements,
- out StatementSyntax conditionalBlock)
- {
- conditionalBlock = EmptyStatement();
-
- bool hasWindowsStatements = windowsStatements.Any();
- bool hasNonWindowsStatements = nonWindowsStatements.Any();
- if (hasWindowsStatements)
- {
- IfStatementSyntax windowsIfBlock = IfStatement(IsWindows, Block(windowsStatements));
- if (hasNonWindowsStatements)
- {
- // if (OperatingSystem.IsWindows())
- // {
- // << Windows code >>
- // }
- // else
- // {
- // << non-Windows code >>
- // }
- conditionalBlock = windowsIfBlock.WithElse(
- ElseClause(Block(nonWindowsStatements)));
- }
- else
- {
- // if (OperatingSystem.IsWindows())
- // {
- // << Windows code >>
- // }
- conditionalBlock = windowsIfBlock;
- }
-
- return true;
- }
- else if (hasNonWindowsStatements)
- {
- // if (!OperatingSystem.IsWindows())
- // {
- // << non-Windows code >>
- // }
- conditionalBlock = IfStatement(PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, IsWindows),
- Block(nonWindowsStatements));
-
- }
-
- return hasWindowsStatements || hasNonWindowsStatements;
- }
- }
-}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
index c151607c972..82d18df159a 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
@@ -60,7 +60,7 @@ namespace Microsoft.Interop
Utf8,
Utf16,
Ansi,
- PlatformDefined
+ Custom
}
/// <summary>
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs
index d8b816e1a85..75a796701c0 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs
@@ -1,18 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.Interop;
-
namespace Microsoft.Interop
{
public static class TypeNames
{
public const string DllImportAttribute = "System.Runtime.InteropServices.DllImportAttribute";
public const string GeneratedDllImportAttribute = "System.Runtime.InteropServices.GeneratedDllImportAttribute";
+ public const string StringMarshalling = "System.Runtime.InteropServices.StringMarshalling";
public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute";
diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj
index 63d4ff9b654..8c35cd9ad01 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj
+++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj
@@ -14,5 +14,6 @@
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs" Link="GeneratedDllImportAttribute.cs" />
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs" Link="GeneratedMarshallingAttribute.cs" />
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs" Link="ArrayMarshaller.cs" />
+ <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/StringMarshalling.cs" Link="StringMarshalling.cs" />
</ItemGroup>
</Project>
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs
index 1284f9c3bd9..bfef66b13a2 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs
@@ -35,13 +35,13 @@ namespace DllImportGenerator.IntegrationTests
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")]
public static partial void CreateRange_Out(int start, int end, out int numValues, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out int[] res);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_char_array", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_char_array", StringMarshalling = StringMarshalling.Utf16)]
public static partial int SumChars(char[] chars, int numElements);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "fill_char_array", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "fill_char_array", StringMarshalling = StringMarshalling.Utf16)]
public static partial void FillChars([Out] char[] chars, int length, ushort start);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_char_array", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_char_array", StringMarshalling = StringMarshalling.Utf16)]
public static partial void ReverseChars([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ref char[] chars, int numElements);
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")]
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs
index d68aef5f91b..d144ab1257b 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs
@@ -12,30 +12,30 @@ namespace DllImportGenerator.IntegrationTests
{
partial class NativeExportsNE
{
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "unicode_return_as_uint", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "unicode_return_as_uint", StringMarshalling = StringMarshalling.Utf16)]
public static partial uint ReturnUnicodeAsUInt(char input);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf16)]
public static partial char ReturnUIntAsUnicode(uint input);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)]
public static partial void ReturnUIntAsUnicode_Ref(uint input, ref char res);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)]
public static partial void ReturnUIntAsUnicode_Out(uint input, out char res);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)]
public static partial void ReturnUIntAsUnicode_In(uint input, in char res);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.None)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Custom)]
[return: MarshalAs(UnmanagedType.U2)]
public static partial char ReturnU2AsU2IgnoreCharSet([MarshalAs(UnmanagedType.U2)] char input);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.I2)]
public static partial char ReturnI2AsI2IgnoreCharSet([MarshalAs(UnmanagedType.I2)] char input);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_reverse_buffer_ref", CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_reverse_buffer_ref", StringMarshalling = StringMarshalling.Utf16)]
public static partial void ReverseBuffer(ref char buffer, int len);
}
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs
index db99bf81a8b..1a833c92c77 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs
@@ -42,24 +42,24 @@ namespace DllImportGenerator.IntegrationTests
}
}
- public partial class Unicode
+ public partial class Utf16
{
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Utf16)]
public static partial int ReturnLength(string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, StringMarshalling = StringMarshalling.Utf16)]
public static partial string Reverse_Return(string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, StringMarshalling = StringMarshalling.Utf16)]
public static partial void Reverse_Out(string s, out string ret);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshalling = StringMarshalling.Utf16)]
public static partial void Reverse_Ref(ref string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshalling = StringMarshalling.Utf16)]
public static partial void Reverse_In(in string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, CharSet = CharSet.Unicode)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, StringMarshalling = StringMarshalling.Utf16)]
public static partial void Reverse_Replace_Ref(ref string s);
}
@@ -68,8 +68,8 @@ namespace DllImportGenerator.IntegrationTests
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)]
public static partial int ReturnLength([MarshalAs(UnmanagedType.LPTStr)] string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)]
- public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPTStr)] string s);
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Custom)]
+ public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPTStr)] string s);
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)]
[return: MarshalAs(UnmanagedType.LPTStr)]
@@ -93,8 +93,8 @@ namespace DllImportGenerator.IntegrationTests
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)]
public static partial int ReturnLength([MarshalAs(UnmanagedType.LPWStr)] string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)]
- public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPWStr)] string s);
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Custom)]
+ public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPWStr)] string s);
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)]
[return: MarshalAs(UnmanagedType.LPWStr)]
@@ -118,8 +118,8 @@ namespace DllImportGenerator.IntegrationTests
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)]
public static partial int ReturnLength([MarshalAs(UnmanagedType.LPUTF8Str)] string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)]
- public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPUTF8Str)] string s);
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Custom)]
+ public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPUTF8Str)] string s);
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)]
[return: MarshalAs(UnmanagedType.LPUTF8Str)]
@@ -138,24 +138,24 @@ namespace DllImportGenerator.IntegrationTests
public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s);
}
- public partial class Ansi
+ public partial class Utf8
{
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Utf8)]
public static partial int ReturnLength(string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, StringMarshalling = StringMarshalling.Utf8)]
public static partial string Reverse_Return(string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, StringMarshalling = StringMarshalling.Utf8)]
public static partial void Reverse_Out(string s, out string ret);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)]
public static partial void Reverse_Ref(ref string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)]
public static partial void Reverse_In(in string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)]
public static partial void Reverse_Replace_Ref(ref string s);
}
@@ -164,8 +164,8 @@ namespace DllImportGenerator.IntegrationTests
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)]
public static partial int ReturnLength([MarshalAs(UnmanagedType.LPStr)] string s);
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)]
- public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPStr)] string s);
+ [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Custom)]
+ public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPStr)] string s);
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)]
[return: MarshalAs(UnmanagedType.LPStr)]
@@ -183,51 +183,6 @@ namespace DllImportGenerator.IntegrationTests
[GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)]
public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s);
}
-
- public partial class Auto
- {
- public partial class Unix
- {
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Auto)]
- public static partial int ReturnLength(string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Auto)]
- public static partial string Reverse_Return(string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Auto)]
- public static partial void Reverse_Out(string s, out string ret);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)]
- public static partial void Reverse_Ref(ref string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)]
- public static partial void Reverse_In(in string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)]
- public static partial void Reverse_Replace_Ref(ref string s);
- }
-
- public partial class Windows
- {
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Auto)]
- public static partial int ReturnLength(string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Auto)]
- public static partial string Reverse_Return(string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Auto)]
- public static partial void Reverse_Out(string s, out string ret);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)]
- public static partial void Reverse_Ref(ref string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)]
- public static partial void Reverse_In(in string s);
-
- [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)]
- public static partial void Reverse_Replace_Ref(ref string s);
- }
- }
}
public class StringTests
@@ -247,12 +202,12 @@ namespace DllImportGenerator.IntegrationTests
public void UnicodeStringMarshalledAsExpected(string value)
{
int expectedLen = value != null ? value.Length : -1;
- Assert.Equal(expectedLen, NativeExportsNE.Unicode.ReturnLength(value));
+ Assert.Equal(expectedLen, NativeExportsNE.Utf16.ReturnLength(value));
Assert.Equal(expectedLen, NativeExportsNE.LPWStr.ReturnLength(value));
Assert.Equal(expectedLen, NativeExportsNE.LPTStr.ReturnLength(value));
- Assert.Equal(expectedLen, NativeExportsNE.LPWStr.ReturnLength_IgnoreCharSet(value));
- Assert.Equal(expectedLen, NativeExportsNE.LPTStr.ReturnLength_IgnoreCharSet(value));
+ Assert.Equal(expectedLen, NativeExportsNE.LPWStr.ReturnLength_IgnoreStringMarshalling(value));
+ Assert.Equal(expectedLen, NativeExportsNE.LPTStr.ReturnLength_IgnoreStringMarshalling(value));
}
[Theory]
@@ -261,12 +216,12 @@ namespace DllImportGenerator.IntegrationTests
{
string expected = ReverseChars(value);
- Assert.Equal(expected, NativeExportsNE.Unicode.Reverse_Return(value));
+ Assert.Equal(expected, NativeExportsNE.Utf16.Reverse_Return(value));
Assert.Equal(expected, NativeExportsNE.LPWStr.Reverse_Return(value));
Assert.Equal(expected, NativeExportsNE.LPTStr.Reverse_Return(value));
string ret;
- NativeExportsNE.Unicode.Reverse_Out(value, out ret);
+ NativeExportsNE.Utf16.Reverse_Out(value, out ret);
Assert.Equal(expected, ret);
ret = null;
@@ -285,7 +240,7 @@ namespace DllImportGenerator.IntegrationTests
string refValue = value;
string expected = ReverseChars(value);
- NativeExportsNE.Unicode.Reverse_In(in refValue);
+ NativeExportsNE.Utf16.Reverse_In(in refValue);
Assert.Equal(value, refValue); // Should not be updated when using 'in'
NativeExportsNE.LPWStr.Reverse_In(in refValue);
@@ -295,7 +250,7 @@ namespace DllImportGenerator.IntegrationTests
Assert.Equal(value, refValue); // Should not be updated when using 'in'
refValue = value;
- NativeExportsNE.Unicode.Reverse_Ref(ref refValue);
+ NativeExportsNE.Utf16.Reverse_Ref(ref refValue);
Assert.Equal(expected, refValue);
refValue = value;
@@ -307,7 +262,7 @@ namespace DllImportGenerator.IntegrationTests
Assert.Equal(expected, refValue);
refValue = value;
- NativeExportsNE.Unicode.Reverse_Replace_Ref(ref refValue);
+ NativeExportsNE.Utf16.Reverse_Replace_Ref(ref refValue);
Assert.Equal(expected, refValue);
refValue = value;
@@ -325,7 +280,8 @@ namespace DllImportGenerator.IntegrationTests
{
int expectedLen = value != null ? Encoding.UTF8.GetByteCount(value) : -1;
Assert.Equal(expectedLen, NativeExportsNE.LPUTF8Str.ReturnLength(value));
- Assert.Equal(expectedLen, NativeExportsNE.LPUTF8Str.ReturnLength_IgnoreCharSet(value));
+ Assert.Equal(expectedLen, NativeExportsNE.LPUTF8Str.ReturnLength_IgnoreStringMarshalling(value));
+ Assert.Equal(expectedLen, NativeExportsNE.Utf8.ReturnLength(value));
}
[Theory]
@@ -335,6 +291,7 @@ namespace DllImportGenerator.IntegrationTests
string expected = ReverseBytes(value, Encoding.UTF8);
Assert.Equal(expected, NativeExportsNE.LPUTF8Str.Reverse_Return(value));
+ Assert.Equal(expected, NativeExportsNE.Utf8.Reverse_Return(value));
string ret;
NativeExportsNE.LPUTF8Str.Reverse_Out(value, out ret);
@@ -351,13 +308,24 @@ namespace DllImportGenerator.IntegrationTests
NativeExportsNE.LPUTF8Str.Reverse_In(in refValue);
Assert.Equal(value, refValue); // Should not be updated when using 'in'
+ NativeExportsNE.Utf8.Reverse_In(in refValue);
+ Assert.Equal(value, refValue); // Should not be updated when using 'in'
+
refValue = value;
NativeExportsNE.LPUTF8Str.Reverse_Ref(ref refValue);
Assert.Equal(expected, refValue);
refValue = value;
+ NativeExportsNE.Utf8.Reverse_Ref(ref refValue);
+ Assert.Equal(expected, refValue);
+
+ refValue = value;
NativeExportsNE.LPUTF8Str.Reverse_Replace_Ref(ref refValue);
Assert.Equal(expected, refValue);
+
+ refValue = value;
+ NativeExportsNE.Utf8.Reverse_Replace_Ref(ref refValue);
+ Assert.Equal(expected, refValue);
}
[Theory]
@@ -368,10 +336,8 @@ namespace DllImportGenerator.IntegrationTests
? OperatingSystem.IsWindows() ? GetLengthAnsi(value) : Encoding.UTF8.GetByteCount(value)
: -1;
- Assert.Equal(expectedLen, NativeExportsNE.Ansi.ReturnLength(value));
Assert.Equal(expectedLen, NativeExportsNE.LPStr.ReturnLength(value));
-
- Assert.Equal(expectedLen, NativeExportsNE.LPStr.ReturnLength_IgnoreCharSet(value));
+ Assert.Equal(expectedLen, NativeExportsNE.LPStr.ReturnLength_IgnoreStringMarshalling(value));
}
[Theory]
@@ -380,14 +346,9 @@ namespace DllImportGenerator.IntegrationTests
{
string expected = OperatingSystem.IsWindows() ? ReverseAnsi(value) : ReverseBytes(value, Encoding.UTF8);
- Assert.Equal(expected, NativeExportsNE.Ansi.Reverse_Return(value));
Assert.Equal(expected, NativeExportsNE.LPStr.Reverse_Return(value));
string ret;
- NativeExportsNE.Ansi.Reverse_Out(value, out ret);
- Assert.Equal(expected, ret);
-
- ret = null;
NativeExportsNE.LPStr.Reverse_Out(value, out ret);
Assert.Equal(expected, ret);
}
@@ -399,106 +360,18 @@ namespace DllImportGenerator.IntegrationTests
string refValue = value;
string expected = OperatingSystem.IsWindows() ? ReverseAnsi(value) : ReverseBytes(value, Encoding.UTF8);
- NativeExportsNE.Ansi.Reverse_In(in refValue);
- Assert.Equal(value, refValue); // Should not be updated when using 'in'
-
NativeExportsNE.LPStr.Reverse_In(in refValue);
Assert.Equal(value, refValue); // Should not be updated when using 'in'
refValue = value;
- NativeExportsNE.Ansi.Reverse_Ref(ref refValue);
- Assert.Equal(expected, refValue);
-
- refValue = value;
NativeExportsNE.LPStr.Reverse_Ref(ref refValue);
Assert.Equal(expected, refValue);
refValue = value;
- NativeExportsNE.Ansi.Reverse_Replace_Ref(ref refValue);
- Assert.Equal(expected, refValue);
-
- refValue = value;
NativeExportsNE.LPStr.Reverse_Replace_Ref(ref refValue);
Assert.Equal(expected, refValue);
}
- [Theory]
- [MemberData(nameof(UnicodeStrings))]
- public void AutoStringMarshalledAsExpected(string value)
- {
- if (OperatingSystem.IsWindows())
- {
- int expectedLen = value != null ? value.Length : -1;
- Assert.Equal(expectedLen, NativeExportsNE.Auto.Windows.ReturnLength(value));
- }
- else
- {
- int expectedLen = value != null ? Encoding.UTF8.GetByteCount(value) : -1;
- Assert.Equal(expectedLen, NativeExportsNE.Auto.Unix.ReturnLength(value));
- }
- }
-
- [Theory]
- [MemberData(nameof(UnicodeStrings))]
- public void AutoStringReturn(string value)
- {
- if (OperatingSystem.IsWindows())
- {
- string expected = ReverseChars(value);
- Assert.Equal(expected, NativeExportsNE.Auto.Windows.Reverse_Return(value));
-
- string ret;
- NativeExportsNE.Auto.Windows.Reverse_Out(value, out ret);
- Assert.Equal(expected, ret);
- }
- else
- {
- string expected = ReverseBytes(value, Encoding.UTF8);
- Assert.Equal(expected, NativeExportsNE.Auto.Unix.Reverse_Return(value));
-
- string ret;
- NativeExportsNE.Auto.Unix.Reverse_Out(value, out ret);
- Assert.Equal(expected, ret);
- }
- }
-
- [Theory]
- [MemberData(nameof(UnicodeStrings))]
- public void AutoStringByRef(string value)
- {
- string refValue = value;
-
- if (OperatingSystem.IsWindows())
- {
- string expected = ReverseChars(value);
- NativeExportsNE.Auto.Windows.Reverse_In(in refValue);
- Assert.Equal(value, refValue); // Should not be updated when using 'in'
-
- refValue = value;
- NativeExportsNE.Auto.Windows.Reverse_Ref(ref refValue);
- Assert.Equal(expected, refValue);
-
- refValue = value;
- NativeExportsNE.Auto.Windows.Reverse_Replace_Ref(ref refValue);
- Assert.Equal(expected, refValue);
-
- }
- else
- {
- string expected = ReverseBytes(value, Encoding.UTF8);
- NativeExportsNE.Auto.Unix.Reverse_In(in refValue);
- Assert.Equal(value, refValue); // Should not be updated when using 'in'
-
- refValue = value;
- NativeExportsNE.Auto.Unix.Reverse_Ref(ref refValue);
- Assert.Equal(expected, refValue);
-
- refValue = value;
- NativeExportsNE.Auto.Unix.Reverse_Replace_Ref(ref refValue);
- Assert.Equal(expected, refValue);
- }
- }
-
private static string ReverseChars(string value)
{
if (value == null)
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs
index fa013fff38c..b86eecf9f6b 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs
@@ -13,10 +13,17 @@ namespace DllImportGenerator.UnitTests
public static readonly string GeneratedDllImportAttributeDeclaration = @"
namespace System.Runtime.InteropServices
{
+ internal enum StringMarshalling
+ {
+ Custom = 0,
+ Utf8,
+ Utf16,
+ }
+
sealed class GeneratedDllImportAttribute : System.Attribute
{
public GeneratedDllImportAttribute(string a) { }
- public CharSet CharSet { get; set; }
+ public StringMarshalling StringMarshalling { get; set; }
}
}
";
@@ -191,7 +198,7 @@ using System.Runtime.InteropServices;
partial class Test
{
[GeneratedDllImport(""DoesNotExist"",
- CharSet = CharSet.Unicode,
+ StringMarshalling = StringMarshalling.Utf16,
EntryPoint = ""UserDefinedEntryPoint"",
SetLastError = true)]
public static partial void Method();
@@ -212,19 +219,19 @@ partial class Test
private const int Two = 2;
[GeneratedDllImport(nameof(Test),
- CharSet = (CharSet)2,
+ StringMarshalling = (StringMarshalling)2,
EntryPoint = EntryPointName,
SetLastError = IsFalse)]
public static partial void Method1();
[GeneratedDllImport(nameof(Test),
- CharSet = (CharSet)Two,
+ StringMarshalling = (StringMarshalling)Two,
EntryPoint = EntryPointName,
SetLastError = !IsTrue)]
public static partial void Method2();
[GeneratedDllImport(nameof(Test),
- CharSet = (CharSet)2,
+ StringMarshalling = (StringMarshalling)2,
EntryPoint = EntryPointName,
SetLastError = 0 != 1)]
public static partial void Method3();
@@ -330,14 +337,14 @@ partial class Test
public static readonly string DisableRuntimeMarshalling = "[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]";
/// <summary>
- /// Declaration with parameters with <see cref="CharSet"/> set.
+ /// Declaration with parameters with <see cref="StringMarshalling"/> set.
/// </summary>
- public static string BasicParametersAndModifiersWithCharSet(string typename, CharSet value, string preDeclaration = "") => @$"
+ public static string BasicParametersAndModifiersWithStringMarshalling(string typename, StringMarshalling value, string preDeclaration = "") => @$"
using System.Runtime.InteropServices;
{preDeclaration}
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", CharSet = CharSet.{value})]
+ [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.{value})]
public static partial {typename} Method(
{typename} p,
in {typename} pIn,
@@ -346,8 +353,8 @@ partial class Test
}}
";
- public static string BasicParametersAndModifiersWithCharSet<T>(CharSet value, string preDeclaration = "") =>
- BasicParametersAndModifiersWithCharSet(typeof(T).ToString(), value, preDeclaration);
+ public static string BasicParametersAndModifiersWithStringMarshalling<T>(StringMarshalling value, string preDeclaration = "") =>
+ BasicParametersAndModifiersWithStringMarshalling(typeof(T).ToString(), value, preDeclaration);
/// <summary>
/// Declaration with parameters.
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs
index 053668c7ddb..f97723495c4 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
@@ -25,11 +26,10 @@ namespace DllImportGenerator.UnitTests
yield return new object[] { CodeSnippets.BasicParametersAndModifiers<char[]>(), 5, 0 };
yield return new object[] { CodeSnippets.BasicParametersAndModifiers<string[]>(), 5, 0 };
- // Unsupported CharSet
- yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<char>(CharSet.Auto), 5, 0 };
- yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<char>(CharSet.Ansi), 5, 0 };
- yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<char>(CharSet.None), 5, 0 };
- yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<string>(CharSet.None), 5, 0 };
+ // Unsupported StringMarshalling configuration
+ yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<char>(StringMarshalling.Custom), 6, 0 };
+ yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<char>(StringMarshalling.Utf8), 6, 0 };
+ yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<string>(StringMarshalling.Custom), 6, 0 };
// Unsupported UnmanagedType
yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers<char>(UnmanagedType.I1), 5, 0 };
@@ -125,11 +125,17 @@ namespace DllImportGenerator.UnitTests
var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator());
// Verify the compilation failed with errors.
- int generatorErrors = generatorDiags.Count(d => d.Severity == DiagnosticSeverity.Error);
- Assert.Equal(expectedGeneratorErrors, generatorErrors);
-
- int compilerErrors = newComp.GetDiagnostics().Count(d => d.Severity == DiagnosticSeverity.Error);
- Assert.Equal(expectedCompilerErrors, compilerErrors);
+ IEnumerable<Diagnostic> generatorErrors = generatorDiags.Where(d => d.Severity == DiagnosticSeverity.Error);
+ int generatorErrorCount = generatorErrors.Count();
+ Assert.True(
+ expectedGeneratorErrors == generatorErrorCount,
+ $"Expected {expectedGeneratorErrors} errors, but encountered {generatorErrorCount}. Errors: {string.Join(Environment.NewLine, generatorErrors.Select(d => d.ToString()))}");
+
+ IEnumerable<Diagnostic> compilerErrors = newComp.GetDiagnostics().Where(d => d.Severity == DiagnosticSeverity.Error);
+ int compilerErrorCount = compilerErrors.Count();
+ Assert.True(
+ expectedCompilerErrors == compilerErrorCount,
+ $"Expected {expectedCompilerErrors} errors, but encountered {compilerErrorCount}. Errors: {string.Join(Environment.NewLine, compilerErrors.Select(d => d.ToString()))}");
}
public static IEnumerable<object[]> CodeSnippetsToCompile_InvalidCode()
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs
index edde539be5c..543b6fe0d39 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs
@@ -78,11 +78,10 @@ namespace DllImportGenerator.UnitTests
yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam<IntPtr>(isByRef: true) };
yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam<UIntPtr>(isByRef: true) };
- // CharSet
- yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<char>(CharSet.Unicode) };
- yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<string>(CharSet.Unicode) };
- yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<string>(CharSet.Ansi) };
- yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<string>(CharSet.Auto) };
+ // StringMarshalling
+ yield return new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<char>(StringMarshalling.Utf16) };
+ yield return new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<string>(StringMarshalling.Utf16) };
+ yield return new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<string>(StringMarshalling.Utf8) };
// MarshalAs
yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers<bool>(UnmanagedType.Bool) };
@@ -298,7 +297,7 @@ namespace DllImportGenerator.UnitTests
// Confirm that all unsupported target frameworks fallback to a forwarder.
{
- string code = CodeSnippets.BasicParametersAndModifiersWithCharSet<string>(CharSet.Unicode, CodeSnippets.GeneratedDllImportAttributeDeclaration);
+ string code = CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<string>(StringMarshalling.Utf16, CodeSnippets.GeneratedDllImportAttributeDeclaration);
yield return new object[] { code, TestTargetFramework.Net5, true };
yield return new object[] { code, TestTargetFramework.Core, true };
yield return new object[] { code, TestTargetFramework.Standard, true };
@@ -443,7 +442,7 @@ namespace DllImportGenerator.UnitTests
public static IEnumerable<object[]> CodeSnippetsToCompileMultipleSources()
{
yield return new object[] { new[] { CodeSnippets.BasicParametersAndModifiers<int>(), CodeSnippets.MarshalAsParametersAndModifiers<bool>(UnmanagedType.Bool) } };
- yield return new object[] { new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet<int>(CharSet.Unicode), CodeSnippets.MarshalAsParametersAndModifiers<bool>(UnmanagedType.Bool) } };
+ yield return new object[] { new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<int>(StringMarshalling.Utf16), CodeSnippets.MarshalAsParametersAndModifiers<bool>(UnmanagedType.Bool) } };
yield return new object[] { new[] { CodeSnippets.BasicParameterByValue("int[]", CodeSnippets.DisableRuntimeMarshalling), CodeSnippets.BasicParameterWithByRefModifier("ref", "int") } };
}
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs
index 71ab2e5a66b..f6f0fc540b2 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs
@@ -119,7 +119,7 @@ partial class Test
public static extern int [|Method1|](out int ret);
[DllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Unicode)]
- public static extern int [|Method2|](out int ret);
+ public static extern string [|Method2|](out int ret);
}}";
// Fixed source will have CS8795 (Partial method must have an implementation) without generator run
string fixedSource = @$"
@@ -129,8 +129,8 @@ partial class Test
[GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")]
public static partial int {{|CS8795:Method1|}}(out int ret);
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Unicode)]
- public static partial int {{|CS8795:Method2|}}(out int ret);
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", StringMarshalling = StringMarshalling.Utf16)]
+ public static partial string {{|CS8795:Method2|}}(out int ret);
}}";
await VerifyCS.VerifyCodeFixAsync(
source,
@@ -155,6 +155,9 @@ partial class Test
[DllImport(""DoesNotExist"", PreserveSig = true)]
public static extern int [|Method3|](out int ret);
+
+ [DllImport(""DoesNotExist"", CharSet = CharSet.Unicode)]
+ public static extern int [|Method4|](out int ret);
}}";
// Fixed source will have CS8795 (Partial method must have an implementation) without generator run
string fixedSource = @$"
@@ -172,6 +175,9 @@ partial class Test
[GeneratedDllImport(""DoesNotExist"")]
public static partial int {{|CS8795:Method3|}}(out int ret);
+
+ [GeneratedDllImport(""DoesNotExist"")]
+ public static partial int {{|CS8795:Method4|}}(out int ret);
}}";
await VerifyCS.VerifyCodeFixAsync(
source,
@@ -237,15 +243,15 @@ using System.Runtime.InteropServices;
partial class Test
{{
[DllImport(""DoesNotExist"", SetLastError = true, EntryPoint = ""Entry"", CharSet = CharSet.Unicode)]
- public static extern int [|Method|](out int ret);
+ public static extern string [|Method|](out int ret);
}}";
// Fixed source will have CS8795 (Partial method must have an implementation) without generator run
string fixedSource = @$"
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Unicode, SetLastError = true)]
- public static partial int {{|CS8795:Method|}}(out int ret);
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
+ public static partial string {{|CS8795:Method|}}(out int ret);
}}";
await VerifyCS.VerifyCodeFixAsync(
source,
@@ -268,7 +274,7 @@ partial class Test
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.{charSet})]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceNoSuffix, "ConvertToGeneratedDllImport");
@@ -276,7 +282,7 @@ partial class Test
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry{suffix}"", CharSet = CharSet.{charSet})]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry{suffix}"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithSuffix, $"ConvertToGeneratedDllImport{suffix}");
@@ -296,7 +302,7 @@ partial class Test
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Auto)]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceNoSuffix, "ConvertToGeneratedDllImport");
@@ -304,7 +310,7 @@ partial class Test
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""EntryA"", CharSet = CharSet.Auto)]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""EntryA"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, "ConvertToGeneratedDllImportA");
@@ -312,7 +318,7 @@ partial class Test
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""EntryW"", CharSet = CharSet.Auto)]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""EntryW"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithWSuffix, "ConvertToGeneratedDllImportW");
@@ -362,7 +368,7 @@ using System.Runtime.InteropServices;
partial class Test
{{
private const string EntryPoint = ""Entry"";
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = EntryPoint + ""A"", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = EntryPoint + ""A"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, "ConvertToGeneratedDllImportA");
@@ -382,7 +388,7 @@ partial class Test
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""MethodA"", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""MethodA"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, "ConvertToGeneratedDllImportA");
@@ -404,7 +410,7 @@ using System.Runtime.InteropServices;
partial class Test
{{
private const string Foo = ""Bar"";
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = nameof(Foo) + ""A"", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = nameof(Foo) + ""A"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, "ConvertToGeneratedDllImportA");
@@ -424,7 +430,7 @@ partial class Test
using System.Runtime.InteropServices;
partial class Test
{{
- [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""MethodA"", CharSet = CharSet.Ansi)]
+ [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""MethodA"")]
public static partial void {{|CS8795:Method|}}();
}}";
await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, "ConvertToGeneratedDllImportA");
diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs
index 135bfe52241..6a0d0940179 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs
@@ -343,6 +343,42 @@ partial class Test
Assert.Empty(newCompDiags);
}
+ [ConditionalFact]
+ public async Task StringMarshallingForwardingNotSupported_ReportsDiagnostic()
+ {
+ string source = @"
+using System.Runtime.InteropServices;
+partial class Test
+{
+ [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Utf8)]
+ public static partial void Method1(string s);
+
+ [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Custom)]
+ public static partial void Method2(string s);
+}
+" + CodeSnippets.GeneratedDllImportAttributeDeclaration;
+
+ // Compile against Standard so that we generate forwarders
+ Compilation comp = await TestUtils.CreateCompilation(source, TestTargetFramework.Standard);
+ TestUtils.AssertPreSourceGeneratorCompilation(comp);
+
+ var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator());
+ DiagnosticResult[] expectedDiags = new DiagnosticResult[]
+ {
+ (new DiagnosticResult(GeneratorDiagnostics.CannotForwardToDllImport))
+ .WithSpan(6, 32, 6, 39)
+ .WithArguments($"{nameof(TypeNames.GeneratedDllImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}", $"{nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Utf8)}"),
+ (new DiagnosticResult(GeneratorDiagnostics.CannotForwardToDllImport))
+ .WithSpan(9, 32, 9, 39)
+ .WithArguments($"{nameof(TypeNames.GeneratedDllImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}", $"{nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Custom)}"),
+ (new DiagnosticResult(GeneratorDiagnostics.ParameterTypeNotSupported))
+ .WithSpan(9, 47, 9, 48)
+ };
+ VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags));
+ var newCompDiags = newComp.GetDiagnostics();
+ Assert.Empty(newCompDiags);
+ }
+
private static void VerifyDiagnostics(DiagnosticResult[] expectedDiagnostics, Diagnostic[] actualDiagnostics)
{
Assert.Equal(expectedDiagnostics.Length, actualDiagnostics.Length);