From 1557d60deec2d979f5b59aa2c882aab2b74da765 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 17 Feb 2022 20:17:37 -0800 Subject: [PATCH 1/4] Update GeneratedDllImportAttribute CharSet -> StringMarshalling --- .../GeneratedDllImportAttribute.cs | 2 +- .../InteropServices/StringMarshalling.cs | 23 ++ .../AnalyzerReleases.Shipped.md | 1 - .../AnalyzerReleases.Unshipped.md | 25 -- .../ConvertToGeneratedDllImportFixer.cs | 81 +++++-- .../DllImportGenerator/DllImportGenerator.cs | 59 +++-- .../DllImportGenerator.csproj | 8 + .../DllImportStubContext.cs | 12 +- .../GeneratedDllImportData.cs | 12 +- .../GeneratorDiagnostics.cs | 28 ++- .../DllImportGenerator/Resources.Designer.cs | 27 +++ .../gen/DllImportGenerator/Resources.resx | 11 + .../MarshallingAttributeInfo.cs | 3 +- .../TypeNames.cs | 7 +- .../Ancillary.Interop.csproj | 1 + .../DllImportGenerator.Tests/ArrayTests.cs | 6 +- .../CharacterTests.cs | 16 +- .../DllImportGenerator.Tests/StringTests.cs | 217 ++++-------------- .../CodeSnippets.cs | 27 ++- .../CompileFails.cs | 26 ++- .../DllImportGenerator.UnitTests/Compiles.cs | 13 +- .../ConvertToGeneratedDllImportFixerTests.cs | 36 +-- .../Diagnostics.cs | 36 +++ 23 files changed, 360 insertions(+), 317 deletions(-) create mode 100644 src/libraries/Common/src/System/Runtime/InteropServices/StringMarshalling.cs delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs index 2d6c3990e0ce51..3c94e8da00fa5c 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 00000000000000..90f17af94ed4b0 --- /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 +{ + /// + /// Specifies how strings should be marshalled for generated p/invokes + /// +#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/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md deleted file mode 100644 index 2bf479656968a6..00000000000000 --- 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 05e2158b078b14..00000000000000 --- 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 e0ad5552f210ea..cf139a2da3ac69 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 @@ public sealed class ConvertToGeneratedDllImportFixer : CodeFixProvider nameof(DllImportAttribute.ExactSpelling), nameof(DllImportAttribute.PreserveSig), nameof(DllImportAttribute.SetLastError), + nameof(StringMarshalling), nameof(DllImportAttribute.ThrowOnUnmappableChar) }; @@ -50,11 +51,12 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) 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 @@ private async Task ConvertToGeneratedDllImport( editor, generator, dllImportSyntax, - methodSymbol.GetDllImportData()!, + methodSymbol, generatedDllImportAttrType, - methodSymbol.Name, entryPointSuffix, out SyntaxNode? unmanagedCallConvAttributeMaybe); @@ -355,21 +356,25 @@ private SyntaxNode GetGeneratedDllImportAttribute( 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 argumentsToAdd= new List(); List argumentsToRemove = new List(); - AttributeArgumentSyntax? entryPointAttributeArgument = null; foreach (SyntaxNode argument in generator.GetAttributeArguments(generatedDllImportSyntax)) { if (argument is not AttributeArgumentSyntax attrArg) @@ -384,6 +389,25 @@ private SyntaxNode GetGeneratedDllImportAttribute( // 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 @@ private SyntaxNode GetGeneratedDllImportAttribute( } 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 @@ private SyntaxNode GetGeneratedDllImportAttribute( } } - 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 @@ private static bool IsMatchingNamedArg(AttributeArgumentSyntax arg, string nameT { 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 92f2c4adc83d4f..5828c07206d832 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 @@ private static TargetFramework DetermineTargetFramework(Compilation compilation, // 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 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 @@ private static TargetFramework DetermineTargetFramework(Compilation compilation, return new GeneratedDllImportData(attrData.ConstructorArguments[0].Value!.ToString()) { IsUserDefined = userDefinedValues, - CharSet = charSet, + StringMarshalling = stringMarshalling, EntryPoint = entryPoint, SetLastError = setLastError, }; @@ -476,13 +477,12 @@ private static IncrementalStubGenerationContext CalculateStubInformation(IMethod 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 @@ private static IncrementalStubGenerationContext CalculateStubInformation(IMethod 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 forwardedAttributes = dllImportStub.ForwardedAttributes; @@ -529,8 +529,24 @@ private static IncrementalStubGenerationContext CalculateStubInformation(IMethod 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 @@ private MemberDeclarationSyntax PrintForwarderStub(MethodDeclarationSyntax userD .AddAttributeLists( AttributeList( SingletonSeparatedList( - CreateDllImportAttributeForTarget( - GetTargetDllImportDataFromStubData( - stub.DllImportData, - userDeclaredMethod.Identifier.ValueText, - forwardAll: true))))); + CreateDllImportAttributeForTarget(targetDllImportData)))); MemberDeclarationSyntax toPrint = WrapMethodInContainingScopes(stub.StubContext, stubMethod); @@ -560,6 +572,8 @@ private static LocalFunctionStatementSyntax CreateTargetFunctionAsLocalStatement 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 @@ private static LocalFunctionStatementSyntax CreateTargetFunctionAsLocalStatement GetTargetDllImportDataFromStubData( dllImportData, stubMethodName, - options.GenerateForwarders)))))) + forwardAll: false)))))) .WithParameterList(parameterList); if (returnTypeAttributes is not null) { @@ -600,10 +614,11 @@ private static AttributeSyntax CreateDllImportAttributeForTarget(GeneratedDllImp 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 @@ private static GeneratedDllImportData GetTargetDllImportDataFromStubData(Generat 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 @@ private static GeneratedDllImportData GetTargetDllImportDataFromStubData(Generat 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 8aeb91f565b2c8..78c3f38a016f1a 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 @@ Microsoft.Interop true true + + RS2008;$(NoWarn) true @@ -21,6 +24,11 @@ true + + + + + , IMarshallingGeneratorFactory) { // 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 0424e15ce83a6e..114062ad3f9a84 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 @@ public enum DllImportMember /// The names of these members map directly to those on the /// DllImportAttribute and should not be changed. /// - public sealed record GeneratedDllImportData(string ModuleName) + internal sealed record GeneratedDllImportData(string ModuleName) { /// /// Value set by the user on the original declaration. /// 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 0ebfe4830d8ba3..9b882858e8c25e 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 @@ namespace Microsoft.Interop { - /// /// Class for reporting diagnostics in the DLL import generator /// @@ -23,6 +22,7 @@ public class Ids 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 @@ public class Ids 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 _diagnostics = new List(); public IEnumerable Diagnostics => _diagnostics; @@ -274,6 +284,22 @@ public void ReportTargetFrameworkNotSupported(Version minimumSupportedVersion) minimumSupportedVersion.ToString(2))); } + /// + /// Report diagnostic for configuration that cannot be forwarded to + /// + /// Configuration name + /// Configuration value + /// Method with the arguments that cannot be forwarded + 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 c2739352c031ac..eeacde5ad966fd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -114,6 +114,33 @@ internal static string CallerAllocMarshallingShouldSupportAllocatingMarshallingF } } + /// + /// Looks up a localized string similar to The generated 'DllImportAttribute' will not have a value corresponding to '{0}={1}'.. + /// + internal static string CannotForwardToDllImportDescription { + get { + return ResourceManager.GetString("CannotForwardToDllImportDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to '{0}={1}' has no equivalent in 'DllImportAtttribute' and will not be forwarded. + /// + internal static string CannotForwardToDllImportMessage { + get { + return ResourceManager.GetString("CannotForwardToDllImportMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specified 'GeneratedDllImportAttribute' arguments cannot be forwarded to 'DllImportAttribute'. + /// + internal static string CannotForwardToDllImportTitle { + get { + return ResourceManager.GetString("CannotForwardToDllImportTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index f6776650d2b7e3..bf203cf12033c6 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 @@ 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 + + The generated 'DllImportAttribute' will not have a value corresponding to '{0}={1}'. + {0} and {1} are the name and value of an attribute argument + + + '{0}={1}' has no equivalent in 'DllImportAtttribute' and will not be forwarded + {0} and {1} are the name and value of an attribute argument + + + Specified 'GeneratedDllImportAttribute' arguments cannot be forwarded to 'DllImportAttribute' + The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive. 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 c151607c9721d6..9a4c78d47a5381 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,8 @@ public enum CharEncoding Utf8, Utf16, Ansi, - PlatformDefined + PlatformDefined, + Custom } /// 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 d8b816e1a855bf..75a796701c0c22 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 63d4ff9b654540..8c35cd9ad018f3 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 @@ + 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 1284f9c3bd93bd..bfef66b13a258e 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 @@ public partial class Arrays [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 d68aef5f91b883..d144ab1257bf40 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 db99bf81a8bc13..1a833c92c77fbf 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 @@ public class UShort } } - 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 @@ public partial class LPTStr [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 @@ public partial class LPWStr [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 @@ public partial class LPUTF8Str [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 @@ public partial class LPUTF8Str 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 @@ public partial class LPStr [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 @@ public partial class LPStr [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 @@ public class StringTests 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 @@ public void UnicodeStringReturn(string value) { 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 @@ public void UnicodeStringByRef(string value) 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 @@ public void UnicodeStringByRef(string value) 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 @@ public void UnicodeStringByRef(string value) 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 @@ public void UTF8StringMarshalledAsExpected(string value) { 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 @@ public void UTF8StringReturn(string value) 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 @@ public void UTF8StringByRef(string value) 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 @@ public void AnsiStringMarshalledAsExpected(string value) ? 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 @@ public void AnsiStringReturn(string value) { 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 @@ public void AnsiStringByRef(string value) 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 fa013fff38cd4f..b86eecf9f6b5e3 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 @@ internal static class CodeSnippets 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 @@ partial class Test 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]"; /// - /// Declaration with parameters with set. + /// Declaration with parameters with set. /// - 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(CharSet value, string preDeclaration = "") => - BasicParametersAndModifiersWithCharSet(typeof(T).ToString(), value, preDeclaration); + public static string BasicParametersAndModifiersWithStringMarshalling(StringMarshalling value, string preDeclaration = "") => + BasicParametersAndModifiersWithStringMarshalling(typeof(T).ToString(), value, preDeclaration); /// /// 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 053668c7ddbad7..f97723495c4007 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 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; - // Unsupported CharSet - yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto), 5, 0 }; - yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi), 5, 0 }; - yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.None), 5, 0 }; - yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.None), 5, 0 }; + // Unsupported StringMarshalling configuration + yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(StringMarshalling.Custom), 6, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(StringMarshalling.Utf8), 6, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(StringMarshalling.Custom), 6, 0 }; // Unsupported UnmanagedType yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1), 5, 0 }; @@ -125,11 +125,17 @@ public async Task ValidateSnippets(string source, int expectedGeneratorErrors, i 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 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 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 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 edde539be5c36b..543b6fe0d39b0c 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 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; - // CharSet - yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode) }; - yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode) }; - yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi) }; - yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto) }; + // StringMarshalling + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(StringMarshalling.Utf16) }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(StringMarshalling.Utf16) }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(StringMarshalling.Utf8) }; // MarshalAs yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; @@ -298,7 +297,7 @@ public static IEnumerable CodeSnippetsToValidateFallbackForwarder() // Confirm that all unsupported target frameworks fallback to a forwarder. { - string code = CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode, CodeSnippets.GeneratedDllImportAttributeDeclaration); + string code = CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(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 @@ public async Task ValidateSnippetsWithMarshalType(string source) public static IEnumerable CodeSnippetsToCompileMultipleSources() { yield return new object[] { new[] { CodeSnippets.BasicParametersAndModifiers(), CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) } }; - yield return new object[] { new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode), CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) } }; + yield return new object[] { new[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling(StringMarshalling.Utf16), CodeSnippets.MarshalAsParametersAndModifiers(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 71ab2e5a66b111..f6f0fc540b23df 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 @@ public async Task PreferredAttributeOrder() 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 @@ partial class Test 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 @@ partial class Test 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 135bfe5224198e..6a0d0940179cd4 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); From 96bbcda0ae520bf5ffaa47297c8ec34f94114b5e Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 17 Feb 2022 20:19:02 -0800 Subject: [PATCH 2/4] Update usage in libraries --- eng/generators.targets | 1 + .../src/System/CLRConfig.cs | 2 +- .../src/System/Diagnostics/Debugger.cs | 2 +- .../Diagnostics/Eventing/EventPipe.CoreCLR.cs | 4 +- .../System/Reflection/Emit/ModuleBuilder.cs | 8 +- .../src/System/Reflection/Emit/TypeBuilder.cs | 16 +- .../src/System/Reflection/RuntimeAssembly.cs | 8 +- .../src/System/Reflection/RuntimeModule.cs | 2 +- .../InteropServices/Marshal.CoreCLR.cs | 2 +- .../InteropServices/NativeLibrary.CoreCLR.cs | 6 +- .../Loader/AssemblyLoadContext.CoreCLR.cs | 14 +- .../src/System/RuntimeHandles.cs | 4 +- .../src/System/Threading/Thread.CoreCLR.cs | 2 +- .../src/System/TypeNameParser.cs | 2 +- .../src/Interop/Android/Interop.Logcat.cs | 2 +- .../Interop.EcDsa.ImportExport.cs | 2 +- .../Interop.EcKey.cs | 2 +- .../Interop.X509Store.cs | 8 +- .../Interop.ProtocolStatistics.cs | 2 +- .../Common/src/Interop/Interop.Calendar.cs | 6 +- .../Common/src/Interop/Interop.Casing.cs | 8 +- .../Common/src/Interop/Interop.Collation.cs | 18 +- .../Common/src/Interop/Interop.HostPolicy.cs | 8 +- .../Common/src/Interop/Interop.ICU.cs | 2 +- .../Common/src/Interop/Interop.ICU.iOS.cs | 2 +- .../Common/src/Interop/Interop.Idna.cs | 4 +- .../Common/src/Interop/Interop.Locale.cs | 16 +- .../src/Interop/Interop.Normalization.cs | 4 +- .../Common/src/Interop/Interop.Odbc.cs | 26 +-- .../src/Interop/Interop.TimeZoneInfo.cs | 6 +- .../src/Interop/Linux/OpenLdap/Interop.Ber.cs | 48 ++--- .../Interop/Linux/OpenLdap/Interop.Ldap.cs | 173 +++++++++++------- .../Linux/System.Native/Interop.INotify.cs | 2 +- .../src/Interop/OSX/Interop.CoreFoundation.cs | 4 +- .../src/Interop/OSX/Interop.EventStream.cs | 2 +- .../Common/src/Interop/OSX/Interop.libc.cs | 2 +- .../Common/src/Interop/OSX/Interop.libobjc.cs | 4 +- .../OSX/System.Native/Interop.SearchPath.cs | 2 +- .../System.Native/Interop.SearchPath.iOS.cs | 2 +- .../Interop.iOSSupportVersion.cs | 2 +- .../Interop.Keychain.macOS.cs | 6 +- .../Interop.Ssl.cs | 2 +- .../System.IO.Ports.Native/Interop.Serial.cs | 2 +- .../Unix/System.Native/Interop.Access.cs | 2 +- .../Unix/System.Native/Interop.ChDir.cs | 2 +- .../Unix/System.Native/Interop.ChMod.cs | 2 +- .../Unix/System.Native/Interop.DynamicLoad.cs | 4 +- .../Interop.ForkAndExecProcess.cs | 2 +- .../Interop.GetDefaultTimeZone.Android.cs | 2 +- .../Unix/System.Native/Interop.GetEnv.cs | 2 +- .../System.Native/Interop.GetGroupList.cs | 2 +- .../System.Native/Interop.GetPeerUserName.cs | 2 +- .../System.Native/Interop.GetProcessPath.cs | 2 +- .../Unix/System.Native/Interop.GetPwUid.cs | 2 +- .../System.Native/Interop.GetUnixRelease.cs | 2 +- .../System.Native/Interop.GetUnixVersion.cs | 2 +- .../Unix/System.Native/Interop.HostEntry.cs | 2 +- ...rop.InitializeTerminalAndSignalHandling.cs | 2 +- .../Interop.InterfaceNameToIndex.cs | 2 +- .../Unix/System.Native/Interop.LChflags.cs | 2 +- .../Unix/System.Native/Interop.Link.cs | 2 +- .../Unix/System.Native/Interop.Open.cs | 2 +- .../Unix/System.Native/Interop.PathConf.cs | 2 +- .../Unix/System.Native/Interop.ReadDir.cs | 2 +- .../Unix/System.Native/Interop.RealPath.cs | 2 +- .../Unix/System.Native/Interop.Rename.cs | 2 +- .../Unix/System.Native/Interop.RmDir.cs | 2 +- .../Unix/System.Native/Interop.SNPrintF.cs | 4 +- .../Unix/System.Native/Interop.ShmOpen.cs | 4 +- .../Unix/System.Native/Interop.Stat.cs | 4 +- .../Unix/System.Native/Interop.SymLink.cs | 2 +- .../Unix/System.Native/Interop.SysLog.cs | 2 +- .../Unix/System.Native/Interop.UTimensat.cs | 2 +- .../Unix/System.Native/Interop.Unlink.cs | 2 +- .../Interop.NetSecurityNative.cs | 2 +- .../Interop.ASN1.Nid.cs | 2 +- .../Interop.ASN1.cs | 4 +- .../Interop.BIO.cs | 2 +- .../Interop.CheckX509Hostname_IntPtr.cs | 2 +- .../Interop.Crypto.cs | 4 +- .../Interop.EcDsa.ImportExport.cs | 2 +- .../Interop.EcKey.cs | 2 +- .../Interop.LookupFriendlyNameByOid.cs | 2 +- .../Interop.OCSP.cs | 4 +- .../Interop.Ssl.cs | 2 +- .../Interop.X509Stack.cs | 2 +- .../Windows/Activeds/Interop.ADsOpenObject.cs | 2 +- .../Windows/Advapi32/Interop.ClearEventLog.cs | 2 +- .../Advapi32/Interop.ConvertSdToStringSd.cs | 2 +- .../Advapi32/Interop.ConvertSidToStringSid.cs | 2 +- .../Advapi32/Interop.ConvertStringSdToSd.cs | 2 +- ...gSecurityDescriptorToSecurityDescriptor.cs | 2 +- .../Advapi32/Interop.ConvertStringSidToSid.cs | 2 +- .../Interop.CreateProcessWithLogon.cs | 2 +- .../Windows/Advapi32/Interop.CreateService.cs | 2 +- .../Advapi32/Interop.CryptAcquireContext.cs | 2 +- .../Interop.CryptAcquireContext_IntPtr.cs | 2 +- .../Interop.CryptGetDefaultProvider.cs | 2 +- .../Windows/Advapi32/Interop.CryptSignHash.cs | 4 +- .../Advapi32/Interop.EncryptDecrypt.cs | 4 +- .../Advapi32/Interop.EnumDependentServices.cs | 2 +- .../Advapi32/Interop.EnumServicesStatusEx.cs | 2 +- .../Advapi32/Interop.EventWriteString.cs | 4 +- .../Interop.GetSecurityDescriptorLength.cs | 2 +- .../Advapi32/Interop.GetSecurityInfoByName.cs | 2 +- .../Advapi32/Interop.GetServiceDisplayName.cs | 2 +- .../Advapi32/Interop.GetServiceKeyName.cs | 2 +- .../Windows/Advapi32/Interop.LogonUser.cs | 2 +- .../Advapi32/Interop.LookupAccountNameW.cs | 2 +- .../Advapi32/Interop.LookupAccountSid.cs | 2 +- .../Advapi32/Interop.LookupPrivilegeValue.cs | 2 +- .../Advapi32/Interop.LsaLookupNames2.cs | 2 +- .../Windows/Advapi32/Interop.OpenEventLog.cs | 2 +- .../Advapi32/Interop.OpenProcessToken.cs | 2 +- .../Windows/Advapi32/Interop.OpenSCManager.cs | 2 +- .../Windows/Advapi32/Interop.OpenService.cs | 2 +- .../Advapi32/Interop.QueryServiceConfig.cs | 2 +- .../Advapi32/Interop.RegConnectRegistry.cs | 2 +- .../Advapi32/Interop.RegCreateKeyEx.cs | 2 +- .../Advapi32/Interop.RegDeleteKeyEx.cs | 2 +- .../Advapi32/Interop.RegDeleteValue.cs | 2 +- .../Windows/Advapi32/Interop.RegEnumKeyEx.cs | 2 +- .../Windows/Advapi32/Interop.RegEnumValue.cs | 2 +- .../Windows/Advapi32/Interop.RegOpenKeyEx.cs | 4 +- .../Advapi32/Interop.RegQueryInfoKey.cs | 2 +- .../Advapi32/Interop.RegQueryValueEx.cs | 8 +- .../Windows/Advapi32/Interop.RegSetValueEx.cs | 10 +- .../Advapi32/Interop.RegisterEventSource.cs | 2 +- .../Interop.RegisterServiceCtrlHandlerEx.cs | 2 +- .../Windows/Advapi32/Interop.ReportEvent.cs | 2 +- .../Advapi32/Interop.SetSecurityInfoByName.cs | 2 +- .../Windows/Advapi32/Interop.StartService.cs | 2 +- .../Interop.StartServiceCtrlDispatcher.cs | 2 +- .../Interop.AuthzInitializeResourceManager.cs | 2 +- .../Common/src/Interop/Windows/BCrypt/Cng.cs | 6 +- .../BCrypt/Interop.BCryptCreateHash.cs | 2 +- .../BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs | 2 +- .../Windows/BCrypt/Interop.BCryptExportKey.cs | 2 +- .../BCrypt/Interop.BCryptGetProperty.cs | 2 +- .../Windows/BCrypt/Interop.BCryptHash.cs | 2 +- .../Windows/BCrypt/Interop.BCryptHashData.cs | 2 +- .../Windows/BCrypt/Interop.BCryptImportKey.cs | 2 +- .../Interop.BCryptOpenAlgorithmProvider.cs | 2 +- .../Credui/Interop.CredUIParseUserName.cs | 2 +- ...tificateContextWithKeyContainerDeletion.cs | 2 +- ...CertGetCertificateContextPropertyString.cs | 2 +- .../Crypt32/Interop.CertGetNameString.cs | 2 +- .../Windows/Crypt32/Interop.CertNameToStr.cs | 2 +- .../Windows/Crypt32/Interop.CertStrToName.cs | 2 +- ...Interop.CryptDecodeObjectPointer_IntPtr.cs | 2 +- ...Interop.CryptDecodeObjectPointer_string.cs | 2 +- .../Crypt32/Interop.CryptProtectData.cs | 2 +- .../CryptUI/Interop.CryptUIDlgCertificate.cs | 4 +- ...terop.DsRoleGetPrimaryDomainInformation.cs | 2 +- .../Interop/Windows/Gdi32/Interop.CreateDC.cs | 2 +- .../Gdi32/Interop.CreateFontIndirect.cs | 2 +- .../Interop/Windows/Gdi32/Interop.CreateIC.cs | 2 +- .../Windows/HttpApi/Interop.HttpApi.cs | 6 +- .../IpHlpApi/Interop.if_nametoindex.cs | 4 +- .../Windows/Kernel32/Interop.CopyFileEx.cs | 2 +- .../Kernel32/Interop.CreateDirectory.cs | 2 +- .../Windows/Kernel32/Interop.CreateFile.cs | 2 +- .../Kernel32/Interop.CreateFileMapping.cs | 4 +- .../Kernel32/Interop.CreateFile_IntPtr.cs | 2 +- .../Kernel32/Interop.CreateNamedPipe.cs | 2 +- .../Kernel32/Interop.CreateNamedPipeClient.cs | 2 +- .../Windows/Kernel32/Interop.CreateProcess.cs | 2 +- .../Kernel32/Interop.CreateSymbolicLink.cs | 2 +- .../Windows/Kernel32/Interop.DeleteFile.cs | 2 +- .../Interop.DeleteVolumeMountPoint.cs | 2 +- .../Kernel32/Interop.DeviceIoControl.cs | 2 +- .../Kernel32/Interop.EnumProcessModules.cs | 2 +- .../Windows/Kernel32/Interop.EnumProcesses.cs | 2 +- .../Kernel32/Interop.EventWaitHandle.cs | 4 +- .../Interop.ExpandEnvironmentStrings.cs | 2 +- .../Interop.FillConsoleOutputCharacter.cs | 2 +- .../Kernel32/Interop.FindFirstFileEx.cs | 2 +- .../Windows/Kernel32/Interop.FindNextFile.cs | 2 +- ...Interop.FormatMessage_SafeLibraryHandle.cs | 2 +- .../Windows/Kernel32/Interop.GetCPInfoEx.cs | 2 +- .../Kernel32/Interop.GetComputerName.cs | 2 +- .../Kernel32/Interop.GetConsoleTitle.cs | 2 +- .../Kernel32/Interop.GetCurrentDirectory.cs | 2 +- .../Kernel32/Interop.GetDiskFreeSpaceEx.cs | 2 +- .../Windows/Kernel32/Interop.GetDriveType.cs | 2 +- .../Interop.GetEnvironmentVariable.cs | 2 +- .../Kernel32/Interop.GetFileAttributesEx.cs | 2 +- .../Interop.GetFinalPathNameByHandle.cs | 2 +- .../Kernel32/Interop.GetFullPathNameW.cs | 2 +- .../Kernel32/Interop.GetLongPathNameW.cs | 2 +- .../Kernel32/Interop.GetModuleBaseName.cs | 2 +- .../Kernel32/Interop.GetModuleFileName.cs | 2 +- .../Kernel32/Interop.GetModuleFileNameEx.cs | 2 +- .../Kernel32/Interop.GetModuleHandle.cs | 2 +- .../Kernel32/Interop.GetModuleInformation.cs | 2 +- .../Interop.GetNamedPipeHandleState.cs | 2 +- .../Kernel32/Interop.GetProcAddress.cs | 8 +- .../Kernel32/Interop.GetProcessName.cs | 2 +- .../Interop.GetProcessPriorityBoost.cs | 2 +- .../Kernel32/Interop.GetProcessTimes.cs | 2 +- .../Kernel32/Interop.GetSystemDirectoryW.cs | 2 +- .../Kernel32/Interop.GetTempFileNameW.cs | 2 +- .../Windows/Kernel32/Interop.GetTempPathW.cs | 2 +- .../Kernel32/Interop.GetVolumeInformation.cs | 2 +- .../Windows/Kernel32/Interop.Globalization.cs | 26 +-- .../Windows/Kernel32/Interop.LoadLibrary.cs | 2 +- .../Windows/Kernel32/Interop.LoadLibraryEx.cs | 2 +- .../Kernel32/Interop.LoadLibraryEx_IntPtr.cs | 2 +- .../Windows/Kernel32/Interop.MapViewOfFile.cs | 2 +- .../Windows/Kernel32/Interop.MoveFileEx.cs | 2 +- .../Interop/Windows/Kernel32/Interop.Mutex.cs | 4 +- .../Kernel32/Interop.OpenFileMapping.cs | 2 +- .../Kernel32/Interop.OutputDebugString.cs | 2 +- .../Kernel32/Interop.PeekConsoleInput.cs | 2 +- .../Windows/Kernel32/Interop.ReadConsole.cs | 2 +- .../Kernel32/Interop.ReadConsoleInput.cs | 2 +- .../Kernel32/Interop.ReadConsoleOutput.cs | 2 +- .../Kernel32/Interop.ReadDirectoryChangesW.cs | 2 +- .../Kernel32/Interop.RemoveDirectory.cs | 2 +- .../Windows/Kernel32/Interop.ReplaceFile.cs | 2 +- .../Kernel32/Interop.ResolveLocaleName.cs | 2 +- .../Windows/Kernel32/Interop.Semaphore.cs | 4 +- .../Kernel32/Interop.SetConsoleTitle.cs | 2 +- .../Kernel32/Interop.SetCurrentDirectory.cs | 2 +- .../Interop.SetEnvironmentVariable.cs | 2 +- .../Kernel32/Interop.SetFileAttributes.cs | 2 +- .../Kernel32/Interop.SetVolumeLabel.cs | 2 +- .../Windows/Kernel32/Interop.TimeZone.cs | 4 +- .../Windows/Kernel32/Interop.WaitNamedPipe.cs | 2 +- .../Windows/Kernel32/Interop.WriteConsole.cs | 2 +- .../Kernel32/Interop.WriteConsoleOutput.cs | 2 +- .../Windows/Logoncli/Interop.DsGetDcName.cs | 2 +- .../Interop/Windows/NCrypt/Interop.Keys.cs | 18 +- .../NCrypt/Interop.NCryptDeriveKeyMaterial.cs | 2 +- .../Interop.NCryptOpenStorageProvider.cs | 2 +- .../Windows/NCrypt/Interop.Properties.cs | 4 +- .../Windows/NCrypt/Interop.SignVerify.cs | 4 +- .../Interop/Windows/Normaliz/Interop.Idna.cs | 4 +- .../Windows/Normaliz/Interop.Normalization.cs | 4 +- .../Windows/NtDll/Interop.NtCreateFile.cs | 2 +- .../NtDll/Interop.NtQueryDirectoryFile.cs | 2 +- .../Windows/Ole32/Interop.CLSIDFromProgID.cs | 2 +- .../OleAut32/Interop.SysAllocStringLen.cs | 4 +- .../PerfCounter/Interop.PerformanceData.cs | 2 +- .../Windows/Secur32/Interop.GetUserNameExW.cs | 2 +- .../Shell32/Interop.SHGetKnownFolderPath.cs | 2 +- .../Shell32/Interop.ShellExecuteExW.cs | 2 +- .../Interop/Windows/SspiCli/Interop.SSPI.cs | 10 +- .../Windows/User32/Interop.CreateWindowEx.cs | 2 +- .../Windows/User32/Interop.DefWindowProc.cs | 2 +- .../Windows/User32/Interop.DispatchMessage.cs | 2 +- .../Windows/User32/Interop.FindWindow.cs | 2 +- .../Windows/User32/Interop.GetClassInfo.cs | 2 +- .../Windows/User32/Interop.GetMessage.cs | 2 +- .../Interop.GetUserObjectInformation.cs | 2 +- .../Windows/User32/Interop.GetWindowTextW.cs | 2 +- .../Windows/User32/Interop.LoadString.cs | 2 +- .../Windows/User32/Interop.PostMessage.cs | 2 +- .../Windows/User32/Interop.PostQuitMessage.cs | 2 +- .../Windows/User32/Interop.RegisterClass.cs | 2 +- .../User32/Interop.RegisterWindowMessage.cs | 2 +- .../Windows/User32/Interop.SendMessage.cs | 2 +- .../Windows/User32/Interop.SetClassLong.cs | 2 +- .../Windows/User32/Interop.SetClassLongPtr.cs | 2 +- .../Windows/User32/Interop.SetWindowLong.cs | 2 +- .../User32/Interop.SetWindowLongPtr.cs | 2 +- .../Windows/User32/Interop.UnregisterClass.cs | 2 +- .../Version/Interop.GetFileVersionInfoEx.cs | 2 +- .../Interop.GetFileVersionInfoSizeEx.cs | 2 +- .../Windows/Version/Interop.VerQueryValue.cs | 2 +- .../Windows/WinHttp/Interop.winhttp.cs | 48 ++--- .../Windows/WinMm/Interop.PlaySound.cs | 2 +- .../Interop/Windows/WinMm/Interop.mmioOpen.cs | 2 +- .../Windows/WinSock/Interop.GetAddrInfoExW.cs | 2 +- .../Windows/WinSock/Interop.GetAddrInfoW.cs | 2 +- .../Windows/WinSock/Interop.GetNameInfoW.cs | 2 +- .../WinSock/Interop.WSADuplicateSocket.cs | 2 +- .../Interop.WSASocketW.SafeCloseSocket.cs | 2 +- .../Windows/WinSock/Interop.WSASocketW.cs | 2 +- .../Windows/Wkscli/Interop.NetWkstaGetInfo.cs | 2 +- .../Interop/Windows/Wldap32/Interop.Ber.cs | 30 +-- .../Interop/Windows/Wldap32/Interop.Ldap.cs | 94 +++++----- .../System/WindowsIdentityFixture.cs | 2 +- .../Microsoft.Win32.Registry/tests/Helpers.cs | 6 +- .../Diagnostics/Reader/UnsafeNativeMethods.cs | 8 +- .../src/Interop/SafeNativeMethods.cs | 4 +- .../ActiveDirectory/NativeMethods.cs | 12 +- .../ActiveDirectory/UnsafeNativeMethods.cs | 12 +- .../src/Interop/Windows/Interop.Gdi32.cs | 18 +- .../src/Interop/Windows/Interop.Kernel32.cs | 2 +- .../src/Interop/Windows/Interop.Shell32.cs | 2 +- .../src/Interop/Windows/Interop.User32.cs | 4 +- .../src/Interop/Windows/Interop.Winspool.cs | 8 +- .../src/System/Drawing/GdiplusNative.Unix.cs | 12 +- .../System/Drawing/GdiplusNative.Windows.cs | 16 +- .../src/System/Drawing/GdiplusNative.cs | 36 ++-- .../System/Drawing/Printing/LibcupsNative.cs | 29 +-- .../src/System/Drawing/macFunctions.cs | 4 +- .../tests/ZipFile.Unix.cs | 2 +- ...ileSystemWatcher.Directory.NotifyFilter.cs | 2 +- .../FileSystemWatcher.File.NotifyFilter.cs | 2 +- .../tests/FileSystemTest.Unix.cs | 2 +- .../tests/MemoryMappedFilesTestsBase.Unix.cs | 2 +- .../Tracing/TraceLogging/XplatEventLogger.cs | 2 +- 304 files changed, 722 insertions(+), 671 deletions(-) diff --git a/eng/generators.targets b/eng/generators.targets index d73019014a8c7a..f13e56995aff83 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -47,6 +47,7 @@ and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DllImportGenerator')) and '$(IncludeDllImportGeneratorSources)' == 'true'"> + diff --git a/src/coreclr/System.Private.CoreLib/src/System/CLRConfig.cs b/src/coreclr/System.Private.CoreLib/src/System/CLRConfig.cs index de634153403b7b..6d09407a2d99f8 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 @@ internal static bool GetBoolValue(string switchName, out bool exist) 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 d5528ca93dc02b..5ed71821cad782 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 @@ public static extern bool IsAttached // 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 d4938c14002edc..bda9ceaaf2012a 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 @@ private static unsafe partial ulong Enable( // // 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 3bf175e13e1f62..e9c4e77471a5a0 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 @@ internal void CheckTypeNameConflict(string strTypeName, Type? enclosingType) 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 @@ private int GetMemberRef(Module? refedModule, int tr, int defToken) 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 @@ private int GetTokenFromTypeSpec(byte[] signature, int length) 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 f5823d837f3844..87bc1b9156fc81 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 @@ public static FieldInfo GetField(Type type, FieldInfo field) #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 @@ internal static void DefineCustomAttribute(ModuleBuilder module, int tkAssociate 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 @@ internal static partial void DefineMethodSemantics(QCallModule module, int tkAss [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 @@ internal static partial int SetParamInfo(QCallModule module, int tkMethod, int i [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 @@ public bool IsCreated() #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 1b66fb3c8244c1..d0268d1d2928b5 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 @@ public override MethodInfo? EntryPoint } } - [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 @@ public override bool IsCollectible } // 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 @@ private static partial void InternalLoad(ObjectHandleOnStack assemblyName, // 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 @@ public override AssemblyName[] GetReferencedAssemblies() 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 4b5760f14c713e..4a2cf7bee78bb6 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 @@ internal sealed partial class RuntimeModule : Module 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 9bd809a37fea4b..203ad5ae3931c0 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 @@ public static string GetTypeInfoName(ITypeInfo typeInfo!!) 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); /// 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 428299b2a08f40..1394cc733a10bd 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 @@ internal static IntPtr LoadLibraryByName(string libraryName, Assembly assembly, /// 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 @@ internal static partial IntPtr LoadByName(string libraryName, QCallAssembly call [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 189544527f65b5..70cbc6dd1d2ead 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 @@ public partial class AssemblyLoadContext [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 @@ public partial class AssemblyLoadContext [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 515a53fe6b5c35..e6e560371113c8 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 @@ internal static MdUtf8String GetUtf8Name(RuntimeType type) [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 @@ private static partial void GetTypeByName(string name, bool throwOnError, bool i 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 9f111b996d207e..90f08b289c3fcf 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 @@ partial void ThreadNameChanged(string? value) 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); /// Returns true if the thread has been started and is not dead. diff --git a/src/coreclr/System.Private.CoreLib/src/System/TypeNameParser.cs b/src/coreclr/System.Private.CoreLib/src/System/TypeNameParser.cs index f77e755be77c2e..48e24f38a45e0d 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 @@ protected override bool ReleaseHandle() 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 690555d824665d..27dd92ad210e89 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 0a309400e001b0..edad37efa9f5d2 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 ca8d82680d1b1e..178610b0e9a36f 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 78e9e46b1823fd..2dcbd1683b5f38 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 unsafe partial bool X509StoreAddCertificateWithPrivateKey( 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 unsafe partial bool X509StoreEnumerateTrustedCertificates( [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 b7548f7138514a..12554a3f2ff6a1 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 @@ public readonly struct NativeIPInterfaceStatistics 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 4cc06c7702d74b..2d9df562505a9d 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 callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context) @@ -20,7 +20,7 @@ internal static unsafe bool EnumCalendarInfo(delegate* unmanaged 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 96c64d7aaafb30..496e5db12941fa 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 7bac573f2942a1..1c720abde79557 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 Globalization 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 a4b05dcc9bf706..7ce34b88fb22e3 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 0b240884514d96..287bc028ead582 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 cad9bcab346841..8e2a09f65c0aed 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 ODBC32.SQLRETURN SQLColAttributeW( // 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 ODBC32.SQLRETURN SQLColumnsW( 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 ODBC32.SQLRETURN SQLEndTran( /*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 ODBC32.SQLRETURN SQLGetDescFieldW( /*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 ODBC32.SQLRETURN SQLGetDiagRecW( /*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 ODBC32.SQLRETURN SQLNumResultCols( /*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 ODBC32.SQLRETURN SQLPrimaryKeysW( /*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 ODBC32.SQLRETURN SQLProcedureColumnsW( /*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 ODBC32.SQLRETURN SQLRowCount( /*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 ODBC32.SQLRETURN SQLSetStmtAttrW( /*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 ODBC32.SQLRETURN SQLSpecialColumnsW( /*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 ODBC32.SQLRETURN SQLStatisticsW( /*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 6d223046927dea..3163a215f2647e 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 unsafe partial ResultCode GetTimeZoneDisplayName( 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 2521b4082e78ef..32ce0da44abfa7 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 Ldap { 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 @@ public static int ber_printf_emptyarg(SafeBerHandle berElement, string format, n } } - [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 @@ public static int ber_printf_int(SafeBerHandle berElement, string format, int va } } - [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 @@ public static int ber_printf_bytearray(SafeBerHandle berElement, string format, } } - [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 @@ public static int ber_scanf_emptyarg(SafeBerHandle berElement, string format) } } - [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 @@ public static int ber_scanf_int(SafeBerHandle berElement, string format, ref int } } - [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 @@ public static int ber_scanf_bitstring(SafeBerHandle berElement, string format, r 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 @@ public static int ber_scanf_ptr(SafeBerHandle berElement, string format, ref Int 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 263d49c91e2af5..ed4c6339dc2469 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 @@ static Ldap() 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 f93f542f7229f9..8f0936bf1c3011 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 Sys [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 b5d64a92606edc..6233a4048d236e 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 @@ private static partial SafeCreateHandle CFStringCreateWithBytes( /// The encoding of the str variable. This should be UTF 8 for OS X /// Returns a pointer to a CFString on success; otherwise, returns IntPtr.Zero /// For *nix systems, the CLR maps ANSI to UTF-8, so be explicit about that - [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 @@ private static partial SafeCreateHandle CFStringCreateWithCString( /// The encoding of the str variable. This should be UTF 8 for OS X /// Returns a pointer to a CFString on success; otherwise, returns IntPtr.Zero /// For *nix systems, the CLR maps ANSI to UTF-8, so be explicit about that - [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 db2675f73a58d1..f4402692f2cc05 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 struct FSEventStreamContext /// Flags to say what kind of events should be sent through this stream. /// On success, returns a pointer to an FSEventStream object; otherwise, returns IntPtr.Zero /// For *nix systems, the CLR maps ANSI to UTF-8, so be explicit about that - [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary, StringMarshalling = StringMarshalling.Utf8)] internal static unsafe partial SafeEventStreamHandle FSEventStreamCreate( IntPtr allocator, delegate* unmanaged callback, diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libc.cs index 51cf2ac16b7ace..5e9f0e9e41380e 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 struct AttrList 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 c338e87bfc0635..6dbd15a4d290a4 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 @@ private struct NSOperatingSystemVersion 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 2a41f989f77937..580111cbabb932 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 3b113c29c945c8..f4afa274687241 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 5a7af296163e40..d429c27ae871ee 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 ebe9e3af8d2eb8..48766e4b4f5e4d 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 @@ private static partial int AppleCryptoNative_SecKeychainItemCopyKeychain( 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 @@ private static partial int AppleCryptoNative_SecKeychainCreate( [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 af6596efd51da6..c728f15917e86b 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 @@ private static partial int AppleCryptoNative_SslSetCertificate( 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 0752826b4eaf25..e7aa1b1e4db112 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 70728287b22ba5..82c32b02cf50d5 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 enum AccessMode : int 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 29e072b856bc47..2184935f742af1 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 044f8cd414ac62..423aa455022071 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 a6ccd9121d84f6..33f36acfc89178 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 295caba93c28d5..9454d42adb71ee 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 unsafe int ForkAndExecProcess( } } - [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 2da78b9a47fbe3..1029cff060c040 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 467ea92ba20cd3..583288b65b361a 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 1b00355f570f03..973a704a7c2ffd 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 Sys } 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 9dea586f1d6a07..b24072f71d6268 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 ddcd49790aaae3..52fc19fe7723f1 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 Sys /// /// Returns the full path to the executable for the current process, resolving symbolic links. /// - [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 06b431cbffd0e8..f30235d87301c3 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 unsafe struct Passwd [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 cf47ba34fe14c8..994e4dcc443346 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 3c130da95f54d7..35503c185b2268 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 360ae8a340aa6c..531c5ce82e9694 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 unsafe struct HostEntry 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 a9d4b29d23517a..01c04149477f27 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 Sys [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 7d0c0dd64c2a71..7a6af166ed504d 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 a5bc36dfa3d2fc..04e18dc0da37ae 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 enum UserFlags : uint 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 6fca0a14d003f0..c09c4e2dfc74d6 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 2024ee616943f2..3daa76c3bfc24c 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 4ed5bbb552d923..6485745c34d835 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 enum PathConfName : int 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 37a89d871c25e4..9bac51a9106de4 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 ReadOnlySpan GetName(Span buffer) } } - [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 8ff4105dae6bf2..fc4c934ead3c0c 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 Sys /// /// The path to the file system object /// Returns the result string on success and null on failure - [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 741f4000627c00..9d5881713c5c10 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 Sys /// /// Returns 0 on success; otherwise, returns -1 /// - [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 24b04035262c24..2fce1f19ed9eb7 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 Sys /// /// Returns 0 on success; otherwise, returns -1 /// - [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 47a20fd4357271..41e403ecf76469 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 Sys /// success; if the return value is equal to the size then the result may have been truncated. /// On failure, returns a negative value. /// - [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); /// @@ -47,7 +47,7 @@ internal static partial class Sys /// success; if the return value is equal to the size then the result may have been truncated. /// On failure, returns a negative value. /// - [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 7d559cb34f4a7c..f7f100cda2aede 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 4f8193e8595990..3da48e827fa1e2 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 enum FileStatusFlags [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 d0721eef785d90..9e97fd87a97941 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 11284f10738216..475767438655a6 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 enum SysLogPriority : int /// /// The message to put in the log entry /// Like printf, the argument is passed to the variadic part of the C++ function to wildcards in the message - [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 dd9ab9014508ce..d1788ee81549da 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 struct TimeSpec /// /// Returns 0 on success; otherwise, returns -1 /// - [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 fed2f15688ab78..ec2c5444de7444 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 c8aece74e58851..16f342d75134e1 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 Status InitiateCredSpNego( 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 178f800f4f860b..4d486460685b04 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 Crypto 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 029f9a688aac4a..efbca475dc5515 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 64c1be633986fd..159a6ef2dfb892 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 Crypto [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 5b3ad7cbff5755..b139a446901590 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 633d6b09e8a349..019600085757db 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 @@ private static partial int CryptoNative_X509StoreSetVerifyTime( 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 0b23fc788b9971..3dd314b9883efa 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 8051dc5bfd3cf0..7ad6d52309983c 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 db1b67c63bcdb2..8d82c6cca2fa5a 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 86ec6c33191e00..81f12a4135cbc7 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 @@ ref MemoryMarshal.GetReference(buf), [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 X509VerifyStatusCode X509ChainGetCachedOcspStatus(SafeX509StoreC 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 d599fe7ecf7372..8755c4a46cc1c9 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 Ssl [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 f3ee9c3e22bb69..7a75fb46c3cc36 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 Crypto [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 784956800bb863..6b99600ee05523 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 4faa6be43bd9c7..1c4a03809fa60e 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 53dfdc4f0cd078..8ea00976b98603 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 97cd4f0f37d6b5..ece6aad42eb7a2 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 82dc0d34c763f4..4e173d112f1558 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 7abb40acf0681e..794f4312f27b4b 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 6f0ce7b6b38627..f5bba0ba8c0bf4 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 df499a80c730e2..7a427352261967 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 7e8160af6cd7ae..5ee78eb9256433 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 bffdc2007e9120..b1515452c4bdaa 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 enum CryptAcquireContextFlags : uint 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 142b7ec549b85e..1af84f68a51a6b 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 92d048b9be0652..9535769ff6c91b 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 enum GetDefaultProviderFlags : int 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 dd7a12c30b397e..a2abbc43e45a48 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 enum CryptSignAndVerifyHashFlags : int 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 @@ public static partial bool CryptSignHash( 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 2b60007102466c..7ac904cc8f3520 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 Advapi32 /// /// WARNING: This method does not implicitly handle long paths. Use EncryptFile. /// - [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 bool EncryptFile(string path) /// /// WARNING: This method does not implicitly handle long paths. Use DecryptFile. /// - [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 57f899ede3cb78..cadfd0741b9007 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 7eee4b470f9fbb..d5d9041aef5466 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 a2f92387abe9ea..620cfee6e74fa9 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 66e1308f0342d0..d02e09c3a3a26c 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 ed4e6c1acb8f16..fa2a4b72073a5e 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 4556380eadc8d0..3fe6f1ccbbbe01 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 0d39fddee07be2..9d8adfdbb94232 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 d9c69a2f919b64..11628880ef7544 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 ed8fd877de2fa6..7ac7f85d0f85fd 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 bf058fb4a774e4..8e932fc1d976e6 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 7781cf4b6cf2a6..3123d952f68cdc 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 f2ada1ff4f4439..d79900044c3ad9 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 1be1ef696052c1..b5e69c759bc40f 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 d01c7725ea9d52..cd05a864e8e508 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 03e3c704e92841..7dcb9b9f0b6d26 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 88758ec52b76a4..027995f5ce9d43 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 242fb1ed88aea2..49f66757155be6 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 4d0fbbb415c1de..e7c6a1818db8a6 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 94f4c4fd08e2a1..edf3bc01fbef0a 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 Advapi32 { // 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 2a2a94cc7615fe..8881398a0e1898 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 2a1127e14e004a..00ae18319d1d21 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 df01f62966fdcc..fbfa4afd630ac4 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 dd0b9e737d3a9e..eb124caf1f7b34 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 d51d73c148178e..31df2772851a07 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 int RegOpenKeyEx( 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 4e4e1ef888f5bb..18dd716f63bc83 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 602ceeb475bc2f..71548822174e01 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 int RegQueryValueEx( 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 int RegQueryValueEx( 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 int RegQueryValueEx( 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 a28ac8e362cc0f..031fbc02708cf4 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 int RegSetValueEx( 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 int RegSetValueEx( 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 int RegSetValueEx( 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 int RegSetValueEx( 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 e4b39adb849126..e995568e9d53e7 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 c734b07061580a..7428a4a8e3ac9c 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 Advapi32 { 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 4dadc0cd2bdf7e..fdf9b28f4bdd21 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 09c49ae7fa90af..d7b84c123d26b9 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 6d98b11505c285..f37559c34ffcb8 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 b1432031db9ee8..3835162a88d2cd 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 aee246dce29dbc..2b43eb94750c76 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 2ddaade387b703..407118d61b8ac0 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 @@ internal static partial class Cng { 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 619b9848fa13c4..06f0707207cbec 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 NTSTATUS BCryptCreateHash(SafeBCryptAlgorithmHandle hAlgorithm, 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 6a1eaaaed7c98e..ab67c0d7d3c6f0 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 b9f585e3a245d9..eace8eb2545710 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 f5429ac535a12b..8dc018841da902 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 e490fe07eaecb3..4b69c44ba2a355 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 db9a126b48a990..b8d8ba4c27c17b 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 BCrypt internal static NTSTATUS BCryptHashData(SafeBCryptHashHandle hHash, ReadOnlySpan 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 94e650df6362ae..05dac933912e81 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 struct BCRYPT_KEY_DATA_BLOB_HEADER 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 a0bb0c9e35ee94..a898fb287bc990 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 8d37329019ea15..92f3c08320ec92 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 Credui 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 ff720e14f1df8b..7f30b7dfeacf91 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 ed60c1730e54e9..7a31f5dbcd32fd 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 a9ed56eb09fcb9..e3973c419f8578 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 0228f4b78da755..d9cb7227ab38ee 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 ae82cf52a97f8a..a7cc4aa1de21ea 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 2a3535a5fa9142..caa8a4581f7f61 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 bbe47942f3fd7c..cd0575c8e459f7 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 54aa2d954b8c36..891b3918e0766a 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 0b4f5521dc40b7..3f4077e2e37d26 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 @@ public CRYPTUI_SELECTCERTIFICATE_STRUCTW ToManaged() #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 19ec950afc7d99..2853d27fc60b9b 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 enum DSROLE_PRIMARY_DOMAIN_INFO_LEVEL 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 41bb3d669c4fbf..768bb63afae504 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 8f4afccea460bb..8536e7c745de5c 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 c71e8656401fd9..5a910510e46302 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 ac41ba64035b0f..7822f894dcd1d9 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 struct HTTP_BINDING_INFO [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 01235ca5f73407..856a1c56a9b2e1 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 4b45b5666c31f9..dc93d2ee0e8cb6 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CopyFileEx. /// - [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 de0c073cf4cf1a..a1a3ca11a915c6 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateDirectory. /// - [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 0dd320c2fbafbf..b598f2e3d3ffe8 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// - [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 005311e4f38759..8a4cebbbf5952e 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 SafeMemoryMappedFileHandle CreateFileMapping( 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 b53785b8bf567e..37ae80b99ec4d1 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// - [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 cc190de6989c74..0e67ae596761f9 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 f5cad97b7c4775..baca7eae8512d6 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 c31f8a36755cb2..18c7e453f7e6ba 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 cc727e91b5e62f..96d85d9c5b5d9f 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 Kernel32 /// 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); /// 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 a4868c9707c11b..bef3a96b6a2192 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use DeleteFile. /// - [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 39b3cad6db35a4..3c73de3d62dec1 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use DeleteVolumeMountPoint. /// - [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 3029dbc4a13ef3..3d0781f4e3f05c 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 Kernel32 // 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 e88e5050b84cbd..3c079ab76e21d6 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 6ffb508d3f0188..9a8833a91606a8 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 6223e165432158..fef6409c47d2ce 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 Kernel32 [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 ed5b6a0eae5189..8f8ea391abaf63 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 4e9f464e4702aa..f58918aa4b794a 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 c5db774302e840..aad022d6f81c38 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use FindFirstFile. /// - [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 dc4f9a4dec172e..06086bf72c893e 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 59f1ef154be0d2..6c14dad882537d 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 Kernel32 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 773f7ddb90110e..e47bb8ab5276a3 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 8faecd4c9a759c..fe441839e0be6a 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 3adffc38755b01..955d4973436ad2 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 6996010df6f1a0..48608469dbc955 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 c9d6b8d8787746..1131b5a43e545c 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 Kernel32 { // 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 51321d6d6b0a03..641be553029e86 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 35fe168de82e83..e3691f6c6dc5c3 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 3c1df29b42cc79..ec8472cd4a2f1d 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use GetFileAttributesEx. /// - [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 f96916c7ebcc5f..3d15bf6dedd419 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 Kernel32 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 e766053beff521..687d5bf188a657 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use GetFullPathName or PathHelper. /// - [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 ea3e04e1d09bac..a99a77a2a5105e 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use GetFullPath/PathHelper. /// - [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 930b96442f1126..def7124cbd3cb6 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 edb2f706afdaff..08b6784c4d293d 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 285ad50403d8f8..1b89788d9f0458 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 ad1bbb9b966b18..710e14fc2efb26 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 73470ceecb8418..c7a888c64d76c7 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 c1ac58d9395ffc..99d9dba7d4cc06 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 cce63bf6bee479..c76bda41ab8d16 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 25dfb72e4629c8..d3032c105b158c 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 d5efb5e07cabd7..bf0255d2937ae6 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 dc019f330d8712..ecea358569ee61 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 a1050e874057cf..699d4b97f275c8 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 74db0802310b4b..a0c39568ee40ed 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 719f19cd1bc7ca..bef74a92e154a1 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 bf1750b57cdebd..1ec27107edf60d 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 de7dbaa844143b..422ade1476afbd 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 Kernel32 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 unsafe partial int FindStringOrdinal( 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 unsafe partial bool IsNLSDefinedString( 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 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 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 pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string? lpReserved, uint CalType, void* lParam); [StructLayout(LayoutKind.Sequential)] @@ -152,7 +152,7 @@ internal struct NlsVersionInfoEx 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 7ba68fe32665ff..eb9e38114e4023 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 248059c3875a15..9d1f7a8f815764 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 Kernel32 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 4d589ba30c0f54..b987f56a022a07 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 Kernel32 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 ed29c33acca486..79a3387618a23c 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 f08d5e48617ea6..bba2cc1cfda525 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use MoveFile. /// - [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 be9e0bf8c46e1b..fd5513ec5ad2ac 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 Kernel32 { 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 a60c27fa7602d4..8d8a0c91e8c6d3 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 5390bf90ee5314..937999e0cebdea 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 179d0b29dbe6f3..6480dbac957145 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 022d0849b5e387..3aa15e13b0a487 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 c6ed13076daf5c..7542a8faa48c6f 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 struct InputRecord 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 d5722aea5ecb9b..4aca20cbd1e812 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 struct CHAR_INFO 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 aa94e95d556a50..5894e1e9fd04d9 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 abca057bf9ce7d..d14e87cc272394 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use RemoveDirectory. /// - [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 cd7612c0212be9..bf65c31322c191 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 cf01ba66e8b3bb..b70c6d8fdf3827 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 unsafe partial class Kernel32 { 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 4aa1e0beab3c2b..f3e167a18ca242 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 246f395c9a024a..b79b85bf4b2d9e 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 1abc814f65a062..a098ac929a1f46 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 f310466ea55347..08eb78d26835f0 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 a382d01bbca415..239fd0030a4c92 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 Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use SetFileAttributes. /// - [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 ca70a7fa2c52fd..7f8570f4ca142b 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 c9e8832996c6bb..4ecb0f45f7d6f4 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 string GetDaylightName() 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 118464eac29fb2..1a6562562456fc 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 95b6495d216db0..071af6da935c9a 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 d656cebed02c33..3a483d4bb06efa 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 e9796be059c82d..af7280f949c4f3 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 5d9fbe7595ed0a..abd0f171ba3ce0 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 NCrypt 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 f0fa8ff23249a1..02298a6a76e29b 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 NCrypt /// /// Generate a key from a secret agreement /// - [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 97368d0550922d..28adee9d595a38 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 d160b1a7d42c9b..a52da43417bdeb 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 unsafe partial ErrorCode NCryptGetProperty( 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 8e651c7277df82..723f78e084991e 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 NCrypt internal static unsafe ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ReadOnlySpan pbHashValue, int cbHashValue, Span 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 pbHashValue, int cbHashValue, ReadOnlySpan 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 d796f9e2f0c264..63104e2d240e5d 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 Normaliz // 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 unsafe partial int IdnToAscii( 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 09a5bd0d10922a..741380134edd0e 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 d8e8f287c96caf..c72613c21dd711 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 NtDll { // 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 9465891720c0ec..3ada672b1b001f 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 NtDll { // 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 0b7c745008097d..b2af31cab122fa 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 16a08a170e788e..4b262a1b824ca7 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 6ceeff0fcee7b3..0019272d3a09c4 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 uint PerfStartProvider( 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 52b9ab248d45ec..d0b16e7c6b5ce0 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 108731c9cd53e0..ce96b7ed29e64b 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 Shell32 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 285677d41bd4d5..2929d3ba9e64f8 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 unsafe struct SHELLEXECUTEINFO 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 d98fd8c51d0d1a..c5410814edda81 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 int EnumerateSecurityPackagesW( 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 unsafe partial int AcquireCredentialsHandleW( 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 unsafe partial int AcquireCredentialsHandleW( 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 unsafe partial int AcquireCredentialsHandleW( 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 unsafe partial int ApplyControlToken( 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 563b05026dee0e..18f69bdeac73cb 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 e2249386ea643f..b41bcf9082b510 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 133cf3a7187bbf..efd057a296fc72 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 ac383c8d57ecd6..3cd58188bf65b2 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 82c665edc86812..f8a8caeb6c653b 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 1b002e7aa2d8bd..70caacaedac236 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 16e4936fde6194..5247bfeadd939d 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 152ba302a2d861..9eb8c1f116cb00 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 f07ba155ae7e50..639c0b1698ab76 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 17d66f2e95074a..729cedbc1b917a 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 47aa4da70e567c..1b9f80168cf799 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 99afb4a46a62f2..5254e3efd5d842 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 3d10e35df73e1b..1bf0969de74916 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 366decfc164e8c..72f350af3c262d 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 a64170a339f076..59705ea4408b9d 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 fff95d708b319b..8a1924e886e355 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 be280dd826eba8..b0532f1707349a 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 1c3a2f970b053a..04f38129aeee5f 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 64d014db478479..3379b063e44a11 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 f5ce78b9bafe4f..33125eb39cffdf 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 db3286789798de..b59284751c5907 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 a3674ed10300ab..47d71079befaea 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 165551fa6f9972..8edc9e64e7bb7a 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 @@ public static partial SafeWinHttpHandle WinHttpOpenRequest( 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 @@ public void FreeNative() } #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 @@ public static partial bool WinHttpAddRequestHeaders( 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 @@ public static partial bool WinHttpSendRequest( 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 @@ public static partial bool WinHttpReadData( 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 @@ public static partial bool WinHttpQueryHeaders( 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 @@ public static partial bool WinHttpQueryHeaders( 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 @@ public static partial bool WinHttpQueryOption( 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 @@ public static partial bool WinHttpQueryOption( 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 @@ public static partial bool WinHttpQueryOption( 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 @@ public static partial bool WinHttpWriteData( 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 @@ public static partial bool WinHttpSetOption( 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 @@ public static partial bool WinHttpSetOption( 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 @@ public static partial bool WinHttpSetCredentials( 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 @@ public static partial bool WinHttpQueryAuthSchemes( 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 @@ public static partial bool WinHttpSetTimeouts( 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 51526b50417d3a..f0a362676d8442 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 WinMM 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 143976534f18bf..85da9dfc980473 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 WinMM 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 11438ec180dede..4fc9f28c55c407 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 Winsock 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 cd1e42d99d4999..70be2c9a38e0af 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 7825ed7ac5ae29..2a5882ddae5b44 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 enum NameInfoFlags 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 8743ea6e760283..1d1254646d552a 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 fcf408c262a03f..9ababac9065061 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 9f0060b4afdd11..f18f7d214f8abc 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 3288f2d2a1f574..b21852267e1a0a 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 34fe73e8984c55..ea1f38f2f5c23c 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 043c8dadf0492e..8cc0f6a3baf906 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 Ldap [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/tests/TestUtilities/System/WindowsIdentityFixture.cs b/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs index 1adb9b3020b48e..b35fa45640b126 100644 --- a/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs +++ b/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs @@ -109,7 +109,7 @@ private void CreateUser() } } - [GeneratedDllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport("advapi32.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] private static partial bool LogonUser(string userName, string domain, string password, int logonType, int logonProvider, out SafeAccessTokenHandle safeAccessTokenHandle); diff --git a/src/libraries/Microsoft.Win32.Registry/tests/Helpers.cs b/src/libraries/Microsoft.Win32.Registry/tests/Helpers.cs index 76ebbaf18093a4..0cd7c8160df13f 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 @@ internal static bool SetDefaultValue(this RegistryKey key, string value) 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 @@ internal static bool IsDefaultValueSet(this RegistryKey key) 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 0e798d0b5f43ca..bf20eebf9769d6 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 @@ internal static partial EventLogHandle EvtOpenChannelEnum( 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 @@ internal static partial EventLogHandle EvtOpenPublisherEnum( 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 @@ internal static partial EventLogHandle EvtCreateRenderContext( 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 @@ public void FreeNative() #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 b9f850d13db467..e2941a78c1a0b4 100644 --- a/src/libraries/System.DirectoryServices/src/Interop/SafeNativeMethods.cs +++ b/src/libraries/System.DirectoryServices/src/Interop/SafeNativeMethods.cs @@ -22,10 +22,10 @@ public const int 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 93371a60a1e396..48cb155c45272a 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 @@ private NativeMethods() { } 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 @@ internal static partial int DsGetDcName( 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 @@ internal static partial int DsGetDcOpen( 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 @@ internal static partial int DsGetDcNext( /*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 @@ internal static partial int NetApiBufferFree( 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 @@ internal static partial int LsaDeregisterLogonProcess( 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 7cdcf8d7dee1ed..174835075746cd 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 @@ internal struct POLICY_ACCOUNT_DOMAIN_INFO 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 @@ internal static partial class UnsafeNativeMethods [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 @@ DWORD DsRoleGetPrimaryDomainInformation( 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 d968f39e77b5dc..c1e712a72a2f9e 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 int StartDoc( #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 int EndDoc( #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 int AddFontFile(string fileName) 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 int GetObject( #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 084d23d1adf32f..3d2545ea6caf98 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 IntPtr GlobalAlloc(int uFlags, uint dwBytes) 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 0b4506e9e55a3c..97dbc8417908e2 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 cffb777cbd9bf9..ec372ff2010922 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 bool GetIconInfo( [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 9b00c106e70cc9..715c8cf5634391 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 int DocumentProperties( #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 int DocumentProperties( #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 6ce3506cda7dba..f9d0e46502d715 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 @@ internal static partial int GdipReleaseDC( [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 @@ internal static partial int GdipReleaseDC( [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 @@ internal static partial int GdipDeletePath( [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 @@ internal static partial int GdipGetMetafileHeaderFromDelegate_linux(StreamGetHea 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 9e94e7cff5f08a..12c5993cd642a6 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 @@ internal static partial int GdipAddPathPath( #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 @@ internal static partial int GdipAddPathString( #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 @@ internal static partial int GdipCloneImage( #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 @@ MetafileHeaderWmf metafileHeaderWmf [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 @@ internal static partial int GdipGetHemfFromMetafile( [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 @@ internal static partial int GdipComment( #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 6ebf6420636ec3..04151cfa3534f9 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 @@ internal static partial int GdipSetImageAttributesOutputChannel( #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 @@ internal static partial int GdipGetFontCollectionFamilyList( [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 @@ internal static partial int GdipDeleteFontFamily( #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 @@ internal static partial int GdipGetLineSpacing( [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 @@ internal static partial int GdipDisposeImage( [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 @@ internal static partial int GdipCreateMetafileFromWmf(IntPtr hMetafile, bool del #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 @@ internal static partial int GdipFillRectanglesI( #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 @@ internal static partial int GdipFillPieI( #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 @@ internal static partial int GdipMeasureString( #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 @@ internal static partial int GdipTransformPointsI( #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 a4a73646bd5142..6052738d20abdc 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 @@ internal static IntPtr LoadLibcups() [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 90b91cbe54729f..e7f64052d75cc7 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 @@ internal static void ReleaseContext(IntPtr port, IntPtr context) } #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 @@ internal static void ReleaseContext(IntPtr port, IntPtr context) [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 1e50125b13e29a..def9a99cb49870 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 @@ private static string GetExpectedPermissions(string expectedPermissions) 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 e7623b4d094a36..9fd5f1d6297e8b 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 a98d06096b3625..e3f2c95eaad5eb 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 96b7c63f80a1ef..011e4c188d3433 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 @@ public abstract partial class FileSystemTest [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 89652ef5bd7016..cd0c98c44b5f39 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 @@ public abstract partial class MemoryMappedFilesTestBase : FileCleanupTestBase [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); /// Asserts that the handle's inheritability matches the specified value. 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 ab15b9ca2742a3..46e5d0502c72d6 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 @@ public XplatEventLogger() {} [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 escape_seq = new List { '\b', '\f', '\n', '\r', '\t', '\"', '\\' }; From 5649bc6f341ca5cad9a3828a6e84640ca2e541a4 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 17 Feb 2022 20:24:18 -0800 Subject: [PATCH 3/4] Remove PlatformDefined (Auto) string marshaller --- .../MarshalAsMarshallingGeneratorFactory.cs | 8 - .../StringMarshaller.PlatformDefined.cs | 179 ------------------ .../MarshallingAttributeInfo.cs | 1 - 3 files changed, 188 deletions(-) delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs 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 ca61227661f00b..905034df768a91 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 @@ public sealed class MarshalAsMarshallingGeneratorFactory : IMarshallingGenerator 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 @@ private IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCo { 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 @@ private IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, Stub 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 655e2fe1b218a7..00000000000000 --- 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 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 windowsStatements, - IEnumerable 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 9a4c78d47a5381..82d18df159ae44 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,6 @@ public enum CharEncoding Utf8, Utf16, Ansi, - PlatformDefined, Custom } From 28b8a47b8f0bc2ebfbad6bccc859857be78dc5a4 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 18 Feb 2022 13:05:52 -0800 Subject: [PATCH 4/4] Update doc --- .../DllImportGenerator/Compatibility.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/design/libraries/DllImportGenerator/Compatibility.md b/docs/design/libraries/DllImportGenerator/Compatibility.md index 4eee2455edc56a..f141ea99a3674b 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