From d60daba4c8c490a24a0c0bfedc5f35efc13629c5 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Sun, 12 Jul 2020 17:52:41 -0700 Subject: [PATCH 001/161] Initial scaffolding for DllImportGenerator - Includes identification of GeneratedDllImportAttribute - Generation of enclosing types for partial methods - Basic tests for compilation of generation code Commit migrated from https://github.com/dotnet/runtimelab/commit/56076d30fd1e83f441d316094a69577b54b8799b --- .../gen/.gitignore | 3 + .../DllImportGenerator.Test/CodeSnippets.cs | 170 ++++++++++ .../gen/DllImportGenerator.Test/Compiles.cs | 55 +++ .../DllImportGenerator.Test.csproj | 32 ++ .../DllImportGenerator/DllImportGenerator.cs | 313 ++++++++++++++++++ .../DllImportGenerator.csproj | 48 +++ .../gen/DllImportGenerator/DllImportStub.cs | 118 +++++++ .../gen/readme.md | 3 + .../DllImportGeneratorSample.csproj | 14 + .../DllImportGeneratorSample/Program.cs | 14 + 10 files changed, 770 insertions(+) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/.gitignore create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/readme.md create mode 100644 src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj create mode 100644 src/samples/DllImportGeneratorSample/Program.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/.gitignore b/src/libraries/System.Runtime.InteropServices/gen/.gitignore new file mode 100644 index 0000000000000..7d37c147c16be --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/.gitignore @@ -0,0 +1,3 @@ +.vs/ +**/bin +**/obj \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs new file mode 100644 index 0000000000000..a632b1938bdcf --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Metadata; +using System.Text; +using System.Threading.Tasks; + +namespace DllImportGenerator.Test +{ + internal static class CodeSnippets + { + /// + /// Trivial declaration of GeneratedDllImport usage + /// + public static readonly string TrivialClassDeclarations = @" +using System.Runtime.InteropServices; +partial class Basic +{ + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method2(); + + [System.Runtime.InteropServices.GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method3(); + + [System.Runtime.InteropServices.GeneratedDllImport(""DoesNotExist"")] + public static partial void Method4(); +} +"; + /// + /// Trivial declaration of GeneratedDllImport usage + /// + public static readonly string TrivialStructDeclarations = @" +using System.Runtime.InteropServices; +partial struct Basic +{ + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method2(); + + [System.Runtime.InteropServices.GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method3(); + + [System.Runtime.InteropServices.GeneratedDllImport(""DoesNotExist"")] + public static partial void Method4(); +} +"; + + /// + /// Declaration with multiple attributes + /// + public static readonly string MultipleAttributes = @" +using System; +using System.Runtime.InteropServices; + +sealed class DummyAttribute : Attribute +{ + public DummyAttribute() { } +} + +sealed class Dummy2Attribute : Attribute +{ + public Dummy2Attribute(string input) { } +} + +partial class Test +{ + [DummyAttribute] + [GeneratedDllImport(""DoesNotExist""), Dummy2Attribute(""string value"")] + public static partial void Method(); +} +"; + + /// + /// Validate nested namespaces are handled + /// + public static readonly string NestedNamespace = @" +using System.Runtime.InteropServices; +namespace NS +{ + namespace InnerNS + { + partial class Test + { + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method1(); + } + } +} +namespace NS.InnerNS +{ + partial class Test + { + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method2(); + } +} +"; + + /// + /// Validate nested types are handled. + /// + public static readonly string NestedTypes = @" +using System.Runtime.InteropServices; +namespace NS +{ + partial class OuterClass + { + partial class InnerClass + { + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(); + } + } + partial struct OuterStruct + { + partial struct InnerStruct + { + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(); + } + } + partial class OuterClass + { + partial struct InnerStruct + { + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(); + } + } + partial struct OuterStruct + { + partial class InnerClass + { + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(); + } + } +} +"; + + /// + /// Declaration with user defined EntryPoint. + /// + public static readonly string UserDefinedEntryPoint = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"", EntryPoint=""UserDefinedEntryPoint"")] + public static partial void NotAnExport(); +} +"; + + /// + /// Declaration with default parameters. + /// + public static readonly string DefaultParameters = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(int t = 0); +} +"; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs new file mode 100644 index 0000000000000..236aab4958fce --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -0,0 +1,55 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Reflection; +using Xunit; + +namespace DllImportGenerator.Test +{ + public class Compiles + { + public static IEnumerable CodeSnippetsToCompile() + { + yield return new[] { CodeSnippets.TrivialClassDeclarations }; + yield return new[] { CodeSnippets.TrivialStructDeclarations }; + yield return new[] { CodeSnippets.MultipleAttributes }; + yield return new[] { CodeSnippets.NestedNamespace }; + yield return new[] { CodeSnippets.NestedTypes }; + yield return new[] { CodeSnippets.UserDefinedEntryPoint }; + yield return new[] { CodeSnippets.DefaultParameters }; + } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompile))] + public void ValidateSnippets(string source) + { + Compilation comp = CreateCompilation(source); + + var newComp = RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(generatorDiags); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + private static Compilation CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) + => CSharpCompilation.Create("compilation", + new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, + new[] { MetadataReference.CreateFromFile(typeof(Binder).GetTypeInfo().Assembly.Location) }, + new CSharpCompilationOptions(outputKind)); + + private static GeneratorDriver CreateDriver(Compilation c, params ISourceGenerator[] generators) + => new CSharpGeneratorDriver(c.SyntaxTrees.First().Options, + ImmutableArray.Create(generators), + null, + ImmutableArray.Empty); + + private static Compilation RunGenerators(Compilation c, out ImmutableArray diagnostics, params ISourceGenerator[] generators) + { + CreateDriver(c, generators).RunFullGeneration(c, out var d, out diagnostics); + return d; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj new file mode 100644 index 0000000000000..74398ed619e68 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj @@ -0,0 +1,32 @@ + + + + net5.0 + false + Preview + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs new file mode 100644 index 0000000000000..e2b4bcd7f2fd2 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -0,0 +1,313 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.Interop +{ + [Generator] + public class DllImportGenerator : ISourceGenerator + { + private const string GeneratedDllImport = nameof(GeneratedDllImport); + private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute); + private static readonly string GeneratedDllImportAttributeSource = $@" +#nullable enable +namespace System.Runtime.InteropServices +{{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public sealed class {nameof(GeneratedDllImportAttribute)} : Attribute + {{ + public bool BestFitMapping; + public CallingConvention CallingConvention; + public CharSet CharSet; + public string? EntryPoint; + public bool ExactSpelling; + public bool PreserveSig; + public bool SetLastError; + public bool ThrowOnUnmappableChar; + + public {nameof(GeneratedDllImportAttribute)}(string dllName) + {{ + this.Value = dllName; + }} + + public string Value {{ get; private set; }} + }} +}} +"; + + public void Execute(SourceGeneratorContext context) + { + var synRec = context.SyntaxReceiver as SyntaxReceiver; + if (synRec is null) + { + return; + } + + // Store a mapping between SyntaxTree and SemanticModel. + // SemanticModels cache results and since we could be looking at + // method declarations in the same SyntaxTree we want to benefit from + // this caching. + var syntaxToModel = new Dictionary(); + + context.AddSource(nameof(GeneratedDllImportAttributeSource), SourceText.From(GeneratedDllImportAttributeSource, Encoding.UTF8)); + + var generatedDllImports = new StringBuilder(); + foreach (SyntaxReference synRef in synRec.Methods) + { + var methodSyntax = (MethodDeclarationSyntax)synRef.GetSyntax(context.CancellationToken); + + // Get the model for the method. + if (!syntaxToModel.TryGetValue(methodSyntax.SyntaxTree, out SemanticModel sm)) + { + sm = context.Compilation.GetSemanticModel(methodSyntax.SyntaxTree, ignoreAccessibility: true); + syntaxToModel.Add(methodSyntax.SyntaxTree, sm); + } + + // Process the method syntax and get its SymbolInfo. + var methodSymbolInfo = sm.GetDeclaredSymbol(methodSyntax, context.CancellationToken); + + // Create the stub details. + var dllImportStub = DllImportStub.Create(methodSymbolInfo, context.CancellationToken); + + // Report any diagnostics from the stub genertion step. + foreach (var diag in dllImportStub.Diagnostics) + { + context.ReportDiagnostic(diag); + } + + // Process the attributes on the method. + AttributeSyntax dllImportAttr; + var additionalAttrs = this.ProcessAttributes(methodSymbolInfo.Name, methodSyntax.AttributeLists, out dllImportAttr); + + PrintGeneratedSource(generatedDllImports, methodSyntax, ref dllImportStub, dllImportAttr, additionalAttrs); + } + + Debug.WriteLine(generatedDllImports.ToString()); // [TODO] Find some way to emit this for debugging - logs? + context.AddSource("DllImportGenerator.g.cs", SourceText.From(generatedDllImports.ToString(), Encoding.UTF8)); + } + + private void PrintGeneratedSource( + StringBuilder builder, + MethodDeclarationSyntax userDeclaredMethod, + ref DllImportStub stub, + AttributeSyntax dllImportAttr, + IEnumerable additionalAttrDecls) + { + const string SingleDepth = " "; + var currentIndent = string.Empty; + + // Declare namespace + if (!(stub.StubTypeNamespace is null)) + { + builder.AppendLine($@"namespace {stub.StubTypeNamespace} +{{"); + currentIndent += SingleDepth; + } + + // Print type declarations + var typeIndentStack = new Stack(); + foreach (var typeDecl in stub.StubContainingTypesDecl) + { + builder.AppendLine($@"{currentIndent}{typeDecl} +{currentIndent}{{"); + + typeIndentStack.Push(currentIndent); + currentIndent += SingleDepth; + } + + // Clean up the parameters + // - Remove default parameter values + var paramSyntaxNodes = new List(); + foreach (var paramSyntax in userDeclaredMethod.ParameterList.Parameters) + { + if (paramSyntax.Default is null) + { + paramSyntaxNodes.Add(paramSyntax); + } + else + { + paramSyntaxNodes.Add(paramSyntax.WithDefault(null)); + } + } + SeparatedSyntaxList newParams = SyntaxFactory.SeparatedList(paramSyntaxNodes); + var newParameterList = userDeclaredMethod.ParameterList.WithParameters(newParams); + + // Declare function + builder.AppendLine( +$@"{currentIndent}{userDeclaredMethod.Modifiers} {userDeclaredMethod.ReturnType} {userDeclaredMethod.Identifier}{newParameterList} +{currentIndent}{{"); + + // Insert lines into function + foreach (var line in stub.StubCode) + { + builder.AppendLine($@"{currentIndent}{SingleDepth}{line}"); + } + + builder.AppendLine( +$@"{ currentIndent}}} + +{currentIndent}[{dllImportAttr}]"); + + // Create the DllImport declaration. + builder.Append($"{currentIndent}extern private static {stub.DllImportReturnType} {stub.DllImportMethodName}"); + if (!stub.DllImportParameters.Any()) + { + builder.AppendLine("();"); + } + else + { + char delim = '('; + foreach (var paramPair in stub.DllImportParameters) + { + builder.Append($"{delim}{paramPair.Type} {paramPair.Name}"); + delim = ','; + } + builder.AppendLine(");"); + } + + // Print closing type declarations + while (typeIndentStack.Count > 0) + { + builder.AppendLine($@"{typeIndentStack.Pop()}}}"); + } + + // Close namespace + if (!(stub.StubTypeNamespace is null)) + { + builder.AppendLine("}"); + } + } + + public void Initialize(InitializationContext context) + { + context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); + } + + private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMaybe) + { + var attrName = attrSyntaxMaybe.Name.ToString(); + return attrName.EndsWith(GeneratedDllImport) + || attrName.EndsWith(GeneratedDllImportAttribute); + } + + private IEnumerable ProcessAttributes( + string methodName, + SyntaxList attributes, + out AttributeSyntax dllImportAttr) + { + dllImportAttr = default; + + var retainedAttrs = new List(); + + // Process all attributes + foreach (AttributeListSyntax listSyntax in attributes) + { + foreach (AttributeSyntax attrSyntax in listSyntax.Attributes) + { + // Retain the attribute if not GeneratedDllImport. + if (!IsGeneratedDllImportAttribute(attrSyntax)) + { + retainedAttrs.Add(attrSyntax.ToString()); + continue; + } + + // Determine if the attribute has the EntryPoint property set. + bool hasEntryPoint = false; + if (!(attrSyntax.ArgumentList is null)) + { + foreach (var arg in attrSyntax.ArgumentList.Arguments) + { + if (arg.NameEquals is null) + { + continue; + } + + hasEntryPoint = nameof(DllImportAttribute.EntryPoint).Equals(arg.NameEquals.Name.ToString()); + if (hasEntryPoint) + { + break; + } + } + } + + // Don't retain the GeneratedDllImport attribute. + // However, we use its settings for the real DllImport. + AttributeSyntax newAttr = attrSyntax; + if (!hasEntryPoint) + { + // If the EntryPoint property is not set, we will compute and + // add it based on existing semantics (i.e. method name). + // + // N.B. The export discovery logic is identical regardless of where + // the name is defined (i.e. method name vs EntryPoint property). + var entryPointName = SyntaxFactory.NameEquals(nameof(DllImportAttribute.EntryPoint)); + + // The name of the method is the entry point name to use. + var entryPointValue = SyntaxFactory.LiteralExpression( + SyntaxKind.StringLiteralExpression, + SyntaxFactory.Literal(methodName)); + + var entryPointProp = SyntaxFactory.AttributeArgument(entryPointName, null, entryPointValue); + + // Add the new property to the existing attribute thus creating a new attribute. + newAttr = attrSyntax.AddArgumentListArguments(entryPointProp); + } + + // Replace the name of the attribute + NameSyntax dllImportName = SyntaxFactory.ParseName(typeof(DllImportAttribute).FullName); + dllImportAttr = newAttr.WithName(dllImportName); + } + } + + return retainedAttrs; + } + + private class SyntaxReceiver : ISyntaxReceiver + { + public ICollection Methods { get; } = new List(); + + public void OnVisitSyntaxNode(SyntaxNode syntaxNode) + { + // We only support C# method declarations. + if (syntaxNode.Language != LanguageNames.CSharp + || !syntaxNode.IsKind(SyntaxKind.MethodDeclaration)) + { + return; + } + + var methodSyntax = (MethodDeclarationSyntax)syntaxNode; + + // Verify the method has no generic types or defined implementation + // and is marked static and partial. + if (!(methodSyntax.TypeParameterList is null) + || !(methodSyntax.Body is null) + || !methodSyntax.Modifiers.Any(SyntaxKind.StaticKeyword) + || !methodSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) + { + return; + } + + // Check if the method is marked with the GeneratedDllImport attribute. + foreach (AttributeListSyntax listSyntax in methodSyntax.AttributeLists) + { + foreach (AttributeSyntax attrSyntax in listSyntax.Attributes) + { + if (IsGeneratedDllImportAttribute(attrSyntax)) + { + this.Methods.Add(syntaxNode.GetReference()); + return; + } + } + } + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj new file mode 100644 index 0000000000000..1c4e12833579a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -0,0 +1,48 @@ + + + + netstandard2.0 + false + true + True + Preview + + + + DllImportGenerator + 1.0.0.0 + arobins + http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE + http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE + http://ICON_URL_HERE_OR_DELETE_THIS_LINE + http://REPOSITORY_URL_HERE_OR_DELETE_THIS_LINE + false + DllImportGenerator + Summary of changes made in this release of the package. + Copyright + DllImportGenerator, analyzers + true + + + + https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json ;$(RestoreAdditionalProjectSources) + + + + true + + + + + + + + + + + + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs new file mode 100644 index 0000000000000..5ee838670459e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; + +using Microsoft.CodeAnalysis; + +namespace Microsoft.Interop +{ + internal class DllImportStub + { + private DllImportStub() + { + } + + public string StubTypeNamespace { get; private set; } + + public IEnumerable StubContainingTypesDecl { get; private set; } + + public IEnumerable StubCode { get; private set; } + + public string DllImportReturnType { get; private set; } + + public string DllImportMethodName { get; private set; } + + public IEnumerable<(string Type, string Name)> DllImportParameters { get; private set; } + + public IEnumerable Diagnostics { get; private set; } + + public static DllImportStub Create(IMethodSymbol method, CancellationToken token = default) + { + // Cancel early if requested + token.ThrowIfCancellationRequested(); + + // Determine the namespace + string stubTypeNamespace = null; + if (!(method.ContainingNamespace is null) + && !method.ContainingNamespace.IsGlobalNamespace) + { + stubTypeNamespace = method.ContainingNamespace.ToString(); + } + + // Determine type + var stubContainingTypes = new List(); + INamedTypeSymbol currType = method.ContainingType; + while (!(currType is null)) + { + var visibility = currType.DeclaredAccessibility switch + { + Accessibility.Public => "public", + Accessibility.Private => "private", + Accessibility.Protected => "protected", + Accessibility.Internal => "internal", + _ => throw new NotSupportedException(), // [TODO] Proper error message + }; + + var typeKeyword = currType.TypeKind switch + { + TypeKind.Class => "class", + TypeKind.Struct => "struct", + _ => throw new NotSupportedException(), // [TODO] Proper error message + }; + + stubContainingTypes.Add($"{visibility} partial {typeKeyword} {currType.Name}"); + currType = currType.ContainingType; + } + + // Flip the order to that of how to declare the types + stubContainingTypes.Reverse(); + + // Determine parameter types + var parameters = new List<(string Type, string Name)>(); + foreach (var namePair in method.Parameters) + { + parameters.Add((ComputeTypeForDllImport(namePair.Type), namePair.Name)); + } + + return new DllImportStub() + { + StubTypeNamespace = stubTypeNamespace, + StubContainingTypesDecl = stubContainingTypes, + StubCode = new[] { $"throw new System.{nameof(NotSupportedException)}();" }, + DllImportReturnType = ComputeTypeForDllImport(method.ReturnType), + DllImportMethodName = method.Name + "__PInvoke__", + DllImportParameters = parameters, + Diagnostics = Enumerable.Empty(), + }; + } + + private static string ComputeTypeForDllImport(ITypeSymbol type) + { + if (!type.IsUnmanagedType) + { + return "void*"; + } + + return type.SpecialType switch + { + SpecialType.System_Void => "void", + SpecialType.System_SByte => "sbyte", + SpecialType.System_Byte => "byte", + SpecialType.System_Int16 => "short", + SpecialType.System_UInt16 => "ushort", + SpecialType.System_Int32 => "int", + SpecialType.System_UInt32 => "uint", + SpecialType.System_Int64 => "long", + SpecialType.System_UInt64 => "ulong", + SpecialType.System_Single => "float", + SpecialType.System_Double => "double", + SpecialType.System_String => "char*", // [TODO] Consider encoding here + SpecialType.System_IntPtr => "void*", + SpecialType.System_UIntPtr => "void*", + _ => "void*", + }; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/readme.md b/src/libraries/System.Runtime.InteropServices/gen/readme.md new file mode 100644 index 0000000000000..3a3f5d25594a4 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/readme.md @@ -0,0 +1,3 @@ +# DllImport Generator + +See [P/Invoke source generator proposal](https://github.com/dotnet/runtime/blob/master/docs/design/features/source-generator-pinvokes.md) for design and goals. \ No newline at end of file diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj new file mode 100644 index 0000000000000..f03d8a3f6c20d --- /dev/null +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -0,0 +1,14 @@ + + + + Exe + net5.0 + true + preview + + + + + + + diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs new file mode 100644 index 0000000000000..7b6e0892cc831 --- /dev/null +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Demo +{ + unsafe class Program + { + static void Main(string[] args) + { + } + } +} From 18ed2b452c000ae0e36a52a4da0c874150921de8 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Sun, 12 Jul 2020 21:23:16 -0700 Subject: [PATCH 002/161] Add GENERATE_FORWARDER define to demonstrate the ability to forward calls directly to the real DllImport from the generated one. Add test for handling RefKind (i.e. in, ref, out). Commit migrated from https://github.com/dotnet/runtimelab/commit/36706439bd965d05baffd52c579f2a375369bb54 --- .../DllImportGenerator.Test/CodeSnippets.cs | 16 +++ .../gen/DllImportGenerator.Test/Compiles.cs | 1 + .../DllImportGenerator/DllImportGenerator.cs | 28 ++--- .../DllImportGenerator.csproj | 1 + .../gen/DllImportGenerator/DllImportStub.cs | 104 ++++++++++++++++-- 5 files changed, 126 insertions(+), 24 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs index a632b1938bdcf..4094f9f66c62d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs @@ -153,6 +153,22 @@ partial class Test [GeneratedDllImport(""DoesNotExist"", EntryPoint=""UserDefinedEntryPoint"")] public static partial void NotAnExport(); } +"; + + /// + /// Declaration with basic parameters. + /// + public static readonly string BasicParametersAndModifiers = @" +using System; +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method1(string s, IntPtr i, UIntPtr u); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method2(in string s, ref IntPtr i, out UIntPtr u); +} "; /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index 236aab4958fce..77a7eeeff4e0d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -18,6 +18,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.NestedNamespace }; yield return new[] { CodeSnippets.NestedTypes }; yield return new[] { CodeSnippets.UserDefinedEntryPoint }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers }; yield return new[] { CodeSnippets.DefaultParameters }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index e2b4bcd7f2fd2..e7cdc0b6d6d3a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -123,26 +123,20 @@ private void PrintGeneratedSource( currentIndent += SingleDepth; } - // Clean up the parameters - // - Remove default parameter values - var paramSyntaxNodes = new List(); - foreach (var paramSyntax in userDeclaredMethod.ParameterList.Parameters) + // Begin declare function + builder.Append( +$@"{currentIndent}{userDeclaredMethod.Modifiers} {stub.StubReturnType} {userDeclaredMethod.Identifier}("); + + char delim = ' '; + foreach (var param in stub.StubParameters) { - if (paramSyntax.Default is null) - { - paramSyntaxNodes.Add(paramSyntax); - } - else - { - paramSyntaxNodes.Add(paramSyntax.WithDefault(null)); - } + builder.Append($"{delim}{param.Type} {param.Name}"); + delim = ','; } - SeparatedSyntaxList newParams = SyntaxFactory.SeparatedList(paramSyntaxNodes); - var newParameterList = userDeclaredMethod.ParameterList.WithParameters(newParams); - // Declare function + // End declare function builder.AppendLine( -$@"{currentIndent}{userDeclaredMethod.Modifiers} {userDeclaredMethod.ReturnType} {userDeclaredMethod.Identifier}{newParameterList} +$@") {currentIndent}{{"); // Insert lines into function @@ -164,7 +158,7 @@ private void PrintGeneratedSource( } else { - char delim = '('; + delim = '('; foreach (var paramPair in stub.DllImportParameters) { builder.Append($"{delim}{paramPair.Type} {paramPair.Name}"); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 1c4e12833579a..45150f8845055 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -30,6 +30,7 @@ true + GENERATE_FORWARDER diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 5ee838670459e..e80b10a538dd2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.Specialized; using System.Linq; using System.Text; using System.Threading; @@ -18,13 +19,17 @@ private DllImportStub() public IEnumerable StubContainingTypesDecl { get; private set; } + public string StubReturnType { get; private set; } + + public IEnumerable<(string Type, string Name, RefKind refKind)> StubParameters { get; private set; } + public IEnumerable StubCode { get; private set; } public string DllImportReturnType { get; private set; } public string DllImportMethodName { get; private set; } - public IEnumerable<(string Type, string Name)> DllImportParameters { get; private set; } + public IEnumerable<(string Type, string Name, RefKind refKind)> DllImportParameters { get; private set; } public IEnumerable Diagnostics { get; private set; } @@ -70,26 +75,110 @@ public static DllImportStub Create(IMethodSymbol method, CancellationToken token stubContainingTypes.Reverse(); // Determine parameter types - var parameters = new List<(string Type, string Name)>(); + var stubParams = new List<(string Type, string Name, RefKind RefKind)>(); + var dllImportParams = new List<(string Type, string Name, RefKind RefKind)>(); foreach (var namePair in method.Parameters) { - parameters.Add((ComputeTypeForDllImport(namePair.Type), namePair.Name)); + stubParams.Add((ComputeTypeForStub(namePair.Type, namePair.RefKind), namePair.Name, namePair.RefKind)); + dllImportParams.Add((ComputeTypeForDllImport(namePair.Type, namePair.RefKind), namePair.Name, namePair.RefKind)); + } + + string dllImportName = method.Name + "__PInvoke__"; + +#if !GENERATE_FORWARDER + var dispatchCall = new StringBuilder($"throw new System.{nameof(NotSupportedException)}();"); +#else + // Forward call to generated P/Invoke + var returnMaybe = method.ReturnType.SpecialType == SpecialType.System_Void + ? string.Empty + : "return"; + + var dispatchCall = new StringBuilder($"{returnMaybe} {dllImportName}"); + if (!dllImportParams.Any()) + { + dispatchCall.Append("();"); + } + else + { + char delim = '('; + foreach (var param in dllImportParams) + { + dispatchCall.Append($"{delim}{RefKindToString(param.RefKind)}{param.Name}"); + delim = ','; + } + dispatchCall.Append(");"); } +#endif return new DllImportStub() { StubTypeNamespace = stubTypeNamespace, StubContainingTypesDecl = stubContainingTypes, - StubCode = new[] { $"throw new System.{nameof(NotSupportedException)}();" }, + StubReturnType = ComputeTypeForStub(method.ReturnType), + StubParameters = stubParams, + StubCode = new[] { dispatchCall.ToString() }, DllImportReturnType = ComputeTypeForDllImport(method.ReturnType), - DllImportMethodName = method.Name + "__PInvoke__", - DllImportParameters = parameters, + DllImportMethodName = dllImportName, + DllImportParameters = dllImportParams, Diagnostics = Enumerable.Empty(), }; } - private static string ComputeTypeForDllImport(ITypeSymbol type) + private static string RefKindToString(RefKind refKind) + { + return refKind switch + { + RefKind.In => "in ", + RefKind.Ref => "ref ", + RefKind.Out => "out ", + RefKind.None => string.Empty, + _ => throw new NotImplementedException("Support for some RefKind"), + }; + } + + private static string ComputeTypeForStub(ITypeSymbol type, RefKind refKind = RefKind.None) + { + var typeAsString = type.SpecialType switch + { + SpecialType.System_Void => "void", + SpecialType.System_SByte => "sbyte", + SpecialType.System_Byte => "byte", + SpecialType.System_Int16 => "short", + SpecialType.System_UInt16 => "ushort", + SpecialType.System_Int32 => "int", + SpecialType.System_UInt32 => "uint", + SpecialType.System_Int64 => "long", + SpecialType.System_UInt64 => "ulong", + SpecialType.System_Single => "float", + SpecialType.System_Double => "double", + SpecialType.System_String => "string", + SpecialType.System_IntPtr => "System.IntPtr", + SpecialType.System_UIntPtr => "System.UIntPtr", + _ => null, + }; + + var typePrefix = string.Empty; + if (typeAsString is null) + { + // Determine the namespace + if (!(type.ContainingNamespace is null) + && !type.ContainingNamespace.IsGlobalNamespace) + { + typePrefix = $"{type.ContainingNamespace}{Type.Delimiter}"; + } + + typeAsString = type.ToString(); + } + + string refKindAsString = RefKindToString(refKind); + return $"{refKindAsString}{typePrefix}{typeAsString}"; + } + + private static string ComputeTypeForDllImport(ITypeSymbol type, RefKind refKind = RefKind.None) { +#if GENERATE_FORWARDER + return ComputeTypeForStub(type, refKind); +#else if (!type.IsUnmanagedType) { return "void*"; @@ -113,6 +202,7 @@ private static string ComputeTypeForDllImport(ITypeSymbol type) SpecialType.System_UIntPtr => "void*", _ => "void*", }; +#endif } } } From 1021cf0fc03157a656dc3de088510a68f5fb0caf Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Sun, 12 Jul 2020 22:07:36 -0700 Subject: [PATCH 003/161] Check for code snippet compilation errors - User defined source needs to be "correct" Commit migrated from https://github.com/dotnet/runtimelab/commit/f9f705cc62acc4d1b9a3cd10273bea70b1128e71 --- .../gen/DllImportGenerator.Test/Compiles.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index 77a7eeeff4e0d..b41bdc1912b5d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -27,6 +27,15 @@ public static IEnumerable CodeSnippetsToCompile() public void ValidateSnippets(string source) { Compilation comp = CreateCompilation(source); + var compDiags = comp.GetDiagnostics(); + foreach (var diag in compDiags) + { + Assert.True( + "CS8795".Equals(diag.Id) // Partial method impl missing + || "CS0234".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute + || "CS0246".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute + || "CS8019".Equals(diag.Id)); // Unnecessary using + } var newComp = RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); Assert.Empty(generatorDiags); From c2a28f680bafe9fe7782446a3e0bee4d4ac5cd52 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Sun, 12 Jul 2020 22:09:29 -0700 Subject: [PATCH 004/161] Add example that runs on Windows to the demo project. It is interesting to step into the generated method and observe the UX. Commit migrated from https://github.com/dotnet/runtimelab/commit/35c9adc2b099a51aff24992e15380a1f26a60d39 --- src/samples/DllImportGeneratorSample/Program.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index 7b6e0892cc831..335cef053259e 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -5,10 +5,19 @@ namespace Demo { + partial class Kernel32 + { + [GeneratedDllImport(nameof(Kernel32), EntryPoint = "QueryPerformanceCounter")] + public static partial int Method(ref long t); + } + unsafe class Program { static void Main(string[] args) { + var ts = (long)0; + int suc = Kernel32.Method(ref ts); + Console.WriteLine($"{suc}: 0x{ts:x}"); } } } From 8968ab319431bbdad4a25d78c61ad2210059abc6 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 13 Jul 2020 14:57:21 -0700 Subject: [PATCH 005/161] Update readme with existing experiments (dotnet/runtimelab#8) * Update readme with existing experiments * Add "CreateAnExperiment.md" Commit migrated from https://github.com/dotnet/runtimelab/commit/542dd851129f974632dddaa24a2b9cb214fd5975 --- CreateAnExperiment.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 CreateAnExperiment.md diff --git a/CreateAnExperiment.md b/CreateAnExperiment.md new file mode 100644 index 0000000000000..324ef578aa65d --- /dev/null +++ b/CreateAnExperiment.md @@ -0,0 +1,11 @@ +# Create an experiment + +Experiments should be contained within a branch in the repository. Instead of using forks of the `dotnet/runtimelab` repository to house experiments, keep branches in the official repository which helps with community visibility. Once an experiment branch is pushed up, remember to submit a PR to update the [README.MD](README.MD#Active%20Experimental%20Projects) in the [main branch][main_branch_link] with the name of the branch and a brief description of the experiment. + +Things to consider: + +- Experiments often involve updates to the [runtime](https://github.com/dotnet/runtime). Instead of branching off of the [main branch][main_branch_link] consider branching from the [official runtime branch](https://github.com/dotnet/runtimelab/tree/runtime-master). Including the entire runtime permits a self contained experiment that is easy for the community to try out. + + + +[main_branch_link]: https://github.com/dotnet/runtimelab/tree/master \ No newline at end of file From 910657672461d7041d9268077d3246c33205195d Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sat, 25 Jul 2020 10:09:44 -0700 Subject: [PATCH 006/161] Update CreateAndExperiment.md (dotnet/runtimelab#32) Commit migrated from https://github.com/dotnet/runtimelab/commit/4072ab96916749f598fdab82d3a83c66b9cdbffb --- CreateAnExperiment.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CreateAnExperiment.md b/CreateAnExperiment.md index 324ef578aa65d..5fd8eee24ceb3 100644 --- a/CreateAnExperiment.md +++ b/CreateAnExperiment.md @@ -1,11 +1,14 @@ # Create an experiment -Experiments should be contained within a branch in the repository. Instead of using forks of the `dotnet/runtimelab` repository to house experiments, keep branches in the official repository which helps with community visibility. Once an experiment branch is pushed up, remember to submit a PR to update the [README.MD](README.MD#Active%20Experimental%20Projects) in the [main branch][main_branch_link] with the name of the branch and a brief description of the experiment. - -Things to consider: - -- Experiments often involve updates to the [runtime](https://github.com/dotnet/runtime). Instead of branching off of the [main branch][main_branch_link] consider branching from the [official runtime branch](https://github.com/dotnet/runtimelab/tree/runtime-master). Including the entire runtime permits a self contained experiment that is easy for the community to try out. - - - -[main_branch_link]: https://github.com/dotnet/runtimelab/tree/master \ No newline at end of file +Experiments should be contained within a branch in the dotnet/runtimelab repository. Keeping all experiments branches in one repository helps with community visibility. + +## Steps to setup a new experiment + +- Pick a good name for your experiment and create branch for it in dotnet/runtimelab. + - If the experiment is expected to require changes of .NET runtime itself, it should be branched off of [dotnet/runtimelab:runtime-master](https://github.com/dotnet/runtimelab/tree/runtime-master) that is a manually maitained mirror of [dotnet/runtime:master](https://github.com/dotnet/runtime/tree/master). + - Otherwise, the experiment should be branched off of [dotnet/runtimelab:master](https://github.com/dotnet/runtimelab/tree/master) to get the required boilerplate such as LICENSE.TXT. +- Submit a PR to update the [README.MD](https://github.com/dotnet/runtimelab/blob/master/README.md#active-experimental-projects) with the name of your branch and a brief description of the experiment. Example: [#19](https://github.com/dotnet/runtimelab/pull/19/files) +- Create label `area-` for tagging issues. The label should use color `#d4c5f9`. +- If your experiment is branched from dotnet/runtime: + - Enable CI builds by editing `eng/pipelines/runtimelab.yml` in your branch. Example: [#25](https://github.com/dotnet/runtimelab/pull/25/files) + - To avoid spurious github notifications for merges from upstream, delete `.github/CODEOWNERS` from your branch or replace it with setting specific to your experiment. Example: [#26](https://github.com/dotnet/runtimelab/pull/26/files) \ No newline at end of file From 81a7a3db28361348f01c8b1e1660560ee68dbec4 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Tue, 28 Jul 2020 10:08:58 -0700 Subject: [PATCH 007/161] Add testing for attribute discovery in cases where the user prefixes the attribute name. Add test cases for compilation failures. Commit migrated from https://github.com/dotnet/runtimelab/commit/d2f6f5a752a88349c80a37e34e55357c0309628b --- .../DllImportGenerator.Test/CodeSnippets.cs | 29 +++++++++ .../DllImportGenerator.Test/CompileFails.cs | 39 ++++++++++++ .../gen/DllImportGenerator.Test/Compiles.cs | 36 +---------- .../gen/DllImportGenerator.Test/TestUtils.cs | 61 +++++++++++++++++++ .../DllImportGenerator/DllImportGenerator.cs | 18 +++++- .../gen/DllImportGenerator/DllImportStub.cs | 4 +- 6 files changed, 150 insertions(+), 37 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs index 4094f9f66c62d..18888cf58795d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs @@ -181,6 +181,35 @@ partial class Test [GeneratedDllImport(""DoesNotExist"")] public static partial void Method(int t = 0); } +"; + + /// + /// Declaration with user defined attributes with prefixed name. + /// + public static readonly string UserDefinedPrefixedAttributes = @" +using System; +using System.Runtime.InteropServices; + +namespace System.Runtime.InteropServices +{ + // Prefix with ATTRIBUTE so the lengths will match during check. + sealed class ATTRIBUTEGeneratedDllImportAttribute : Attribute + { + public ATTRIBUTEGeneratedDllImportAttribute(string a) { } + } +} + +partial class Test +{ + [ATTRIBUTEGeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); + + [ATTRIBUTEGeneratedDllImport(""DoesNotExist"")] + public static partial void Method2(); + + [System.Runtime.InteropServices.ATTRIBUTEGeneratedDllImport(""DoesNotExist"")] + public static partial void Method3(); +} "; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs new file mode 100644 index 0000000000000..75e8847232dcc --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs @@ -0,0 +1,39 @@ +using Microsoft.CodeAnalysis; +using System.Collections.Generic; +using Xunit; + +namespace DllImportGenerator.Test +{ + public class CompileFails + { + public static IEnumerable CodeSnippetsToCompile() + { + yield return new object[] { CodeSnippets.UserDefinedPrefixedAttributes, 3 }; + } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompile))] + public void ValidateSnippets(string source, int failCount) + { + Compilation comp = TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(generatorDiags); + + var newCompDiags = newComp.GetDiagnostics(); + + // Verify the compilation failed with missing impl. + int missingImplCount = 0; + foreach (var diag in newCompDiags) + { + if ("CS8795".Equals(diag.Id)) + { + missingImplCount++; + } + } + + Assert.Equal(failCount, missingImplCount); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index b41bdc1912b5d..5375ab26a7e73 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -1,9 +1,5 @@ using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Reflection; using Xunit; namespace DllImportGenerator.Test @@ -26,40 +22,14 @@ public static IEnumerable CodeSnippetsToCompile() [MemberData(nameof(CodeSnippetsToCompile))] public void ValidateSnippets(string source) { - Compilation comp = CreateCompilation(source); - var compDiags = comp.GetDiagnostics(); - foreach (var diag in compDiags) - { - Assert.True( - "CS8795".Equals(diag.Id) // Partial method impl missing - || "CS0234".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute - || "CS0246".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute - || "CS8019".Equals(diag.Id)); // Unnecessary using - } + Compilation comp = TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); - var newComp = RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); Assert.Empty(generatorDiags); var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); } - - private static Compilation CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) - => CSharpCompilation.Create("compilation", - new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, - new[] { MetadataReference.CreateFromFile(typeof(Binder).GetTypeInfo().Assembly.Location) }, - new CSharpCompilationOptions(outputKind)); - - private static GeneratorDriver CreateDriver(Compilation c, params ISourceGenerator[] generators) - => new CSharpGeneratorDriver(c.SyntaxTrees.First().Options, - ImmutableArray.Create(generators), - null, - ImmutableArray.Empty); - - private static Compilation RunGenerators(Compilation c, out ImmutableArray diagnostics, params ISourceGenerator[] generators) - { - CreateDriver(c, generators).RunFullGeneration(c, out var d, out diagnostics); - return d; - } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs new file mode 100644 index 0000000000000..0afb4144787a5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs @@ -0,0 +1,61 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using System.Collections.Immutable; +using System.Linq; +using System.Reflection; +using Xunit; + +namespace DllImportGenerator.Test +{ + internal static class TestUtils + { + /// + /// Assert the pre-srouce generator compilation has only + /// the expected failure diagnostics. + /// + /// + public static void AssertPreSourceGeneratorCompilation(Compilation comp) + { + var compDiags = comp.GetDiagnostics(); + foreach (var diag in compDiags) + { + Assert.True( + "CS8795".Equals(diag.Id) // Partial method impl missing + || "CS0234".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute + || "CS0246".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute + || "CS8019".Equals(diag.Id)); // Unnecessary using + } + } + + /// + /// Create a compilation given source + /// + /// Source to compile + /// Output type + /// The resulting compilation + public static Compilation CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) + => CSharpCompilation.Create("compilation", + new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, + new[] { MetadataReference.CreateFromFile(typeof(Binder).GetTypeInfo().Assembly.Location) }, + new CSharpCompilationOptions(outputKind)); + + /// + /// Run the supplied generators on the compilation. + /// + /// Compilation target + /// Resulting diagnostics + /// Source generator instances + /// The resulting compilation + public static Compilation RunGenerators(Compilation comp, out ImmutableArray diagnostics, params ISourceGenerator[] generators) + { + CreateDriver(comp, generators).RunFullGeneration(comp, out var d, out diagnostics); + return d; + } + + private static GeneratorDriver CreateDriver(Compilation c, params ISourceGenerator[] generators) + => new CSharpGeneratorDriver(c.SyntaxTrees.First().Options, + ImmutableArray.Create(generators), + null, + ImmutableArray.Empty); + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index e7cdc0b6d6d3a..801c8b0597704 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -188,8 +188,22 @@ public void Initialize(InitializationContext context) private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMaybe) { var attrName = attrSyntaxMaybe.Name.ToString(); - return attrName.EndsWith(GeneratedDllImport) - || attrName.EndsWith(GeneratedDllImportAttribute); + + if (attrName.Length == GeneratedDllImport.Length) + { + return attrName.Equals(GeneratedDllImport); + } + else if (attrName.Length == GeneratedDllImportAttribute.Length) + { + return attrName.Equals(GeneratedDllImportAttribute); + } + + // Handle the case where the user defines an attribute with + // the same name but adds a prefix. + const string PrefixedGeneratedDllImport = "." + GeneratedDllImport; + const string PrefixedGeneratedDllImportAttribute = "." + GeneratedDllImportAttribute; + return attrName.EndsWith(PrefixedGeneratedDllImport) + || attrName.EndsWith(PrefixedGeneratedDllImportAttribute); } private IEnumerable ProcessAttributes( diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index e80b10a538dd2..511e75862d426 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -91,9 +91,9 @@ public static DllImportStub Create(IMethodSymbol method, CancellationToken token // Forward call to generated P/Invoke var returnMaybe = method.ReturnType.SpecialType == SpecialType.System_Void ? string.Empty - : "return"; + : "return "; - var dispatchCall = new StringBuilder($"{returnMaybe} {dllImportName}"); + var dispatchCall = new StringBuilder($"{returnMaybe}{dllImportName}"); if (!dllImportParams.Any()) { dispatchCall.Append("();"); From 9968397fdd4260b897f533853340dd46106fdde6 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 3 Aug 2020 16:50:22 -0700 Subject: [PATCH 008/161] Collect DllImport details through Roslyn semantic model (dotnet/runtimelab#36) * Collect DllImport details through Roslyn semantic model Create an assembly that provides the GeneratedDllImportAttribute which allows use of the semantic model. * Collect MarshalAsAttribute data * Collect MarshalAsAttribute data Convert P/Invoke centric data structures to handle positional type information for managed/unmanaged scenarios. Commit migrated from https://github.com/dotnet/runtimelab/commit/21e634efd416d3457d171d0db6efe505b48c711d --- .../DllImportGenerator.Test/CodeSnippets.cs | 90 +++++++ .../gen/DllImportGenerator.Test/Compiles.cs | 3 + .../DllImportGenerator.Test.csproj | 1 + .../gen/DllImportGenerator.Test/TestUtils.cs | 22 +- .../DllImportGenerator/DllImportGenerator.cs | 249 +++++++++++------- .../DllImportGenerator.csproj | 11 +- .../gen/DllImportGenerator/DllImportStub.cs | 196 +++++++------- .../DllImportGenerator/TypePositionInfo.cs | 232 ++++++++++++++++ .../gen/readme.md | 15 +- .../Ancillary.Interop.csproj | 8 + .../GeneratedDllImportAttribute.cs | 25 ++ .../DllImportGeneratorSample.csproj | 1 + 12 files changed, 640 insertions(+), 213 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj create mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs index 18888cf58795d..b69856e490642 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs @@ -153,6 +153,50 @@ partial class Test [GeneratedDllImport(""DoesNotExist"", EntryPoint=""UserDefinedEntryPoint"")] public static partial void NotAnExport(); } +"; + + /// + /// Declaration with all DllImport named arguments. + /// + public static readonly string AllDllImportNamedArguments = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"", + BestFitMapping = false, + CallingConvention = CallingConvention.Cdecl, + CharSet = CharSet.Unicode, + EntryPoint = ""UserDefinedEntryPoint"", + ExactSpelling = true, + PreserveSig = false, + SetLastError = true, + ThrowOnUnmappableChar = true)] + public static partial void Method(); +} +"; + + /// + /// Declaration using various methods to compute constants in C#. + /// + public static readonly string UseCSharpFeaturesForConstants = @" +using System.Runtime.InteropServices; +partial class Test +{ + private const bool IsTrue = true; + private const bool IsFalse = false; + private const string EntryPointName = nameof(Test) + nameof(IsFalse); + + [GeneratedDllImport(nameof(Test), + BestFitMapping = 0 != 1, + CallingConvention = (CallingConvention)1, + CharSet = (CharSet)2, + EntryPoint = EntryPointName, + ExactSpelling = IsTrue, + PreserveSig = IsFalse, + SetLastError = !IsFalse, + ThrowOnUnmappableChar = !IsTrue)] + public static partial void Method(); +} "; /// @@ -181,6 +225,52 @@ partial class Test [GeneratedDllImport(""DoesNotExist"")] public static partial void Method(int t = 0); } +"; + + /// + /// Apply MarshalAsAttribute to parameters and return types. + /// + public static readonly string MarshalAsAttributeOnTypes = @" +using System; +using System.Runtime.InteropServices; +namespace NS +{ + class MyCustomMarshaler : ICustomMarshaler + { + static ICustomMarshaler GetInstance(string pstrCookie) + => new MyCustomMarshaler(); + + public void CleanUpManagedData(object ManagedObj) + => throw new NotImplementedException(); + + public void CleanUpNativeData(IntPtr pNativeData) + => throw new NotImplementedException(); + + public int GetNativeDataSize() + => throw new NotImplementedException(); + + public IntPtr MarshalManagedToNative(object ManagedObj) + => throw new NotImplementedException(); + + public object MarshalNativeToManaged(IntPtr pNativeData) + => throw new NotImplementedException(); + } +} + +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.LPWStr)] + public static partial string Method1([MarshalAs(UnmanagedType.LPStr)]string t); + + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.LPWStr)] + public static partial string Method2([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NS.MyCustomMarshaler), MarshalCookie=""COOKIE1"")]string t); + + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.LPWStr)] + public static partial string Method3([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = ""NS.MyCustomMarshaler"", MarshalCookie=""COOKIE2"")]string t); +} "; /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index 5375ab26a7e73..85cd5cad87a8e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -14,8 +14,11 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.NestedNamespace }; yield return new[] { CodeSnippets.NestedTypes }; yield return new[] { CodeSnippets.UserDefinedEntryPoint }; + yield return new[] { CodeSnippets.AllDllImportNamedArguments }; yield return new[] { CodeSnippets.BasicParametersAndModifiers }; yield return new[] { CodeSnippets.DefaultParameters }; + yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; + yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj index 74398ed619e68..4cba239e624ec 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj @@ -26,6 +26,7 @@ + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs index 0afb4144787a5..a52480f22ea57 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs @@ -1,8 +1,10 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; using Xunit; namespace DllImportGenerator.Test @@ -34,10 +36,26 @@ public static void AssertPreSourceGeneratorCompilation(Compilation comp) /// Output type /// The resulting compilation public static Compilation CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) - => CSharpCompilation.Create("compilation", + { + var mdRefs = new List(); + + // Include the assembly containing the new attribute and all of its references. + // [TODO] Remove once the attribute has been added to the BCL + var attrAssem = typeof(GeneratedDllImportAttribute).GetTypeInfo().Assembly; + mdRefs.Add(MetadataReference.CreateFromFile(attrAssem.Location)); + foreach (var assemName in attrAssem.GetReferencedAssemblies()) + { + var assemRef = Assembly.Load(assemName); + mdRefs.Add(MetadataReference.CreateFromFile(assemRef.Location)); + } + + // Add a CoreLib reference + mdRefs.Add(MetadataReference.CreateFromFile(typeof(Binder).GetTypeInfo().Assembly.Location)); + return CSharpCompilation.Create("compilation", new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, - new[] { MetadataReference.CreateFromFile(typeof(Binder).GetTypeInfo().Assembly.Location) }, + mdRefs, new CSharpCompilationOptions(outputKind)); + } /// /// Run the supplied generators on the compilation. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 801c8b0597704..35bca6a05fa6f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; - +using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -17,31 +17,6 @@ public class DllImportGenerator : ISourceGenerator { private const string GeneratedDllImport = nameof(GeneratedDllImport); private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute); - private static readonly string GeneratedDllImportAttributeSource = $@" -#nullable enable -namespace System.Runtime.InteropServices -{{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public sealed class {nameof(GeneratedDllImportAttribute)} : Attribute - {{ - public bool BestFitMapping; - public CallingConvention CallingConvention; - public CharSet CharSet; - public string? EntryPoint; - public bool ExactSpelling; - public bool PreserveSig; - public bool SetLastError; - public bool ThrowOnUnmappableChar; - - public {nameof(GeneratedDllImportAttribute)}(string dllName) - {{ - this.Value = dllName; - }} - - public string Value {{ get; private set; }} - }} -}} -"; public void Execute(SourceGeneratorContext context) { @@ -57,8 +32,6 @@ public void Execute(SourceGeneratorContext context) // this caching. var syntaxToModel = new Dictionary(); - context.AddSource(nameof(GeneratedDllImportAttributeSource), SourceText.From(GeneratedDllImportAttributeSource, Encoding.UTF8)); - var generatedDllImports = new StringBuilder(); foreach (SyntaxReference synRef in synRec.Methods) { @@ -74,32 +47,37 @@ public void Execute(SourceGeneratorContext context) // Process the method syntax and get its SymbolInfo. var methodSymbolInfo = sm.GetDeclaredSymbol(methodSyntax, context.CancellationToken); - // Create the stub details. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, context.CancellationToken); + // Process the attributes on the method. + DllImportStub.GeneratedDllImportData dllImportData; + AttributeSyntax dllImportAttr = this.ProcessAttributes(methodSymbolInfo, context.CancellationToken, out dllImportData); + Debug.Assert(!(dllImportAttr is null) && !(dllImportData is null)); + + // Create the stub. + var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData, context.CancellationToken); - // Report any diagnostics from the stub genertion step. + // Report any diagnostics from the stub generation step. foreach (var diag in dllImportStub.Diagnostics) { context.ReportDiagnostic(diag); } - // Process the attributes on the method. - AttributeSyntax dllImportAttr; - var additionalAttrs = this.ProcessAttributes(methodSymbolInfo.Name, methodSyntax.AttributeLists, out dllImportAttr); - - PrintGeneratedSource(generatedDllImports, methodSyntax, ref dllImportStub, dllImportAttr, additionalAttrs); + PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub, dllImportAttr); } Debug.WriteLine(generatedDllImports.ToString()); // [TODO] Find some way to emit this for debugging - logs? context.AddSource("DllImportGenerator.g.cs", SourceText.From(generatedDllImports.ToString(), Encoding.UTF8)); } + public void Initialize(InitializationContext context) + { + context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); + } + private void PrintGeneratedSource( StringBuilder builder, MethodDeclarationSyntax userDeclaredMethod, - ref DllImportStub stub, - AttributeSyntax dllImportAttr, - IEnumerable additionalAttrDecls) + DllImportStub stub, + AttributeSyntax dllImportAttr) { const string SingleDepth = " "; var currentIndent = string.Empty; @@ -180,11 +158,6 @@ private void PrintGeneratedSource( } } - public void Initialize(InitializationContext context) - { - context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); - } - private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMaybe) { var attrName = attrSyntaxMaybe.Name.ToString(); @@ -206,76 +179,150 @@ private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMayb || attrName.EndsWith(PrefixedGeneratedDllImportAttribute); } - private IEnumerable ProcessAttributes( - string methodName, - SyntaxList attributes, - out AttributeSyntax dllImportAttr) + private AttributeSyntax ProcessAttributes( + IMethodSymbol method, + CancellationToken cancelToken, + out DllImportStub.GeneratedDllImportData dllImportData) { - dllImportAttr = default; - - var retainedAttrs = new List(); + dllImportData = new DllImportStub.GeneratedDllImportData(); // Process all attributes - foreach (AttributeListSyntax listSyntax in attributes) + foreach (AttributeData attrData in method.GetAttributes()) { - foreach (AttributeSyntax attrSyntax in listSyntax.Attributes) + if (attrData.ApplicationSyntaxReference is null) { - // Retain the attribute if not GeneratedDllImport. - if (!IsGeneratedDllImportAttribute(attrSyntax)) - { - retainedAttrs.Add(attrSyntax.ToString()); - continue; - } + continue; + } - // Determine if the attribute has the EntryPoint property set. - bool hasEntryPoint = false; - if (!(attrSyntax.ArgumentList is null)) - { - foreach (var arg in attrSyntax.ArgumentList.Arguments) - { - if (arg.NameEquals is null) - { - continue; - } - - hasEntryPoint = nameof(DllImportAttribute.EntryPoint).Equals(arg.NameEquals.Name.ToString()); - if (hasEntryPoint) - { - break; - } - } - } + var attrSyntax = (AttributeSyntax)attrData.ApplicationSyntaxReference.GetSyntax(cancelToken); - // Don't retain the GeneratedDllImport attribute. - // However, we use its settings for the real DllImport. - AttributeSyntax newAttr = attrSyntax; - if (!hasEntryPoint) + // Skip the attribute if not GeneratedDllImport. + if (!IsGeneratedDllImportAttribute(attrSyntax)) + { + continue; + } + + // Found the GeneratedDllImport, but it has an error so report the error. + // This is most likely an issue with targeting an incorrect TFM. + if (attrData.AttributeClass.TypeKind == TypeKind.Error) + { + // [TODO] Report GeneratedDllImport has an error - corrupt metadata? + throw new InvalidProgramException(); + } + + var newAttributeArgs = new List(); + + // Populate the DllImport data from the GeneratedDllImportAttribute attribute. + dllImportData.ModuleName = attrData.ConstructorArguments[0].Value.ToString(); + + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(SyntaxFactory.LiteralExpression( + SyntaxKind.StringLiteralExpression, + SyntaxFactory.Literal(dllImportData.ModuleName)))); + + // All other data on attribute is defined as NamedArguments. + foreach (var namedArg in attrData.NamedArguments) + { + ExpressionSyntax expSyntaxMaybe = null; + switch (namedArg.Key) { - // If the EntryPoint property is not set, we will compute and - // add it based on existing semantics (i.e. method name). - // - // N.B. The export discovery logic is identical regardless of where - // the name is defined (i.e. method name vs EntryPoint property). - var entryPointName = SyntaxFactory.NameEquals(nameof(DllImportAttribute.EntryPoint)); - - // The name of the method is the entry point name to use. - var entryPointValue = SyntaxFactory.LiteralExpression( - SyntaxKind.StringLiteralExpression, - SyntaxFactory.Literal(methodName)); - - var entryPointProp = SyntaxFactory.AttributeArgument(entryPointName, null, entryPointValue); - - // Add the new property to the existing attribute thus creating a new attribute. - newAttr = attrSyntax.AddArgumentListArguments(entryPointProp); + default: + Debug.Fail($"An unknown member was found on {GeneratedDllImport}"); + continue; + case nameof(DllImportStub.GeneratedDllImportData.BestFitMapping): + dllImportData.BestFitMapping = (bool)namedArg.Value.Value; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.BestFitMapping); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.BestFitMapping; + break; + case nameof(DllImportStub.GeneratedDllImportData.CallingConvention): + dllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value; + expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CallingConvention); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CallingConvention; + break; + case nameof(DllImportStub.GeneratedDllImportData.CharSet): + dllImportData.CharSet = (CharSet)namedArg.Value.Value; + expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CharSet); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CharSet; + break; + case nameof(DllImportStub.GeneratedDllImportData.EntryPoint): + dllImportData.EntryPoint = (string)namedArg.Value.Value; + expSyntaxMaybe = CreateStringExpressionSyntax(dllImportData.EntryPoint); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.EntryPoint; + break; + case nameof(DllImportStub.GeneratedDllImportData.ExactSpelling): + dllImportData.ExactSpelling = (bool)namedArg.Value.Value; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ExactSpelling); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ExactSpelling; + break; + case nameof(DllImportStub.GeneratedDllImportData.PreserveSig): + dllImportData.PreserveSig = (bool)namedArg.Value.Value; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.PreserveSig); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.PreserveSig; + break; + case nameof(DllImportStub.GeneratedDllImportData.SetLastError): + dllImportData.SetLastError = (bool)namedArg.Value.Value; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.SetLastError); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.SetLastError; + break; + case nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar): + dllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ThrowOnUnmappableChar); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ThrowOnUnmappableChar; + break; } - // Replace the name of the attribute - NameSyntax dllImportName = SyntaxFactory.ParseName(typeof(DllImportAttribute).FullName); - dllImportAttr = newAttr.WithName(dllImportName); + Debug.Assert(!(expSyntaxMaybe is null)); + + // Defer the name equals syntax till we know the value means something. If we created + // an expression we know the key value was valid. + NameEqualsSyntax nameSyntax = SyntaxFactory.NameEquals(namedArg.Key); + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe)); + } + + // If the EntryPoint property is not set, we will compute and + // add it based on existing semantics (i.e. method name). + // + // N.B. The export discovery logic is identical regardless of where + // the name is defined (i.e. method name vs EntryPoint property). + if (!dllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) + { + var entryPointName = SyntaxFactory.NameEquals(nameof(DllImportAttribute.EntryPoint)); + + // The name of the method is the entry point name to use. + var entryPointValue = CreateStringExpressionSyntax(method.Name); + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(entryPointName, null, entryPointValue)); } + + // Create new attribute + return SyntaxFactory.Attribute( + SyntaxFactory.ParseName(typeof(DllImportAttribute).FullName), + SyntaxFactory.AttributeArgumentList(SyntaxFactory.SeparatedList(newAttributeArgs))); + } + + // [TODO] Report the missing GeneratedDllImportAttribute + throw new NotSupportedException(); + + static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) + { + return SyntaxFactory.LiteralExpression( + trueOrFalse + ? SyntaxKind.TrueLiteralExpression + : SyntaxKind.FalseLiteralExpression); + } + + static ExpressionSyntax CreateStringExpressionSyntax(string str) + { + return SyntaxFactory.LiteralExpression( + SyntaxKind.StringLiteralExpression, + SyntaxFactory.Literal(str)); } - return retainedAttrs; + static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum + { + return SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + SyntaxFactory.IdentifierName(typeof(T).FullName), + SyntaxFactory.IdentifierName(value.ToString())); + } } private class SyntaxReceiver : ISyntaxReceiver diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 45150f8845055..8082fd111732f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -1,17 +1,19 @@ - + netstandard2.0 false true True + true + GENERATE_FORWARDER Preview DllImportGenerator 1.0.0.0 - arobins + Microsoft http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE http://ICON_URL_HERE_OR_DELETE_THIS_LINE @@ -28,11 +30,6 @@ https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json ;$(RestoreAdditionalProjectSources) - - true - GENERATE_FORWARDER - - diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 511e75862d426..c5fe2532a9ec2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; +using System.Diagnostics; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading; @@ -11,6 +12,9 @@ namespace Microsoft.Interop { internal class DllImportStub { + private TypePositionInfo returnTypeInfo; + private IEnumerable paramsTypeInfo; + private DllImportStub() { } @@ -19,21 +23,94 @@ private DllImportStub() public IEnumerable StubContainingTypesDecl { get; private set; } - public string StubReturnType { get; private set; } + public string StubReturnType { get => this.returnTypeInfo.ManagedTypeDecl; } - public IEnumerable<(string Type, string Name, RefKind refKind)> StubParameters { get; private set; } + public IEnumerable<(string Type, string Name)> StubParameters + { + get + { + foreach (var typeinfo in paramsTypeInfo) + { + //if (typeinfo.ManagedIndex != TypePositionInfo.UnsetIndex) + { + yield return (typeinfo.ManagedTypeDecl, typeinfo.InstanceIdentifier); + } + } + } + } public IEnumerable StubCode { get; private set; } - public string DllImportReturnType { get; private set; } + public string DllImportReturnType { get => this.returnTypeInfo.UnmanagedTypeDecl; } public string DllImportMethodName { get; private set; } - public IEnumerable<(string Type, string Name, RefKind refKind)> DllImportParameters { get; private set; } + public IEnumerable<(string Type, string Name)> DllImportParameters + { + get + { + foreach (var typeinfo in paramsTypeInfo) + { + //if (typeinfo.UnmanagedIndex != TypePositionInfo.UnsetIndex) + { + yield return (typeinfo.UnmanagedTypeDecl, typeinfo.InstanceIdentifier); + } + } + } + } public IEnumerable Diagnostics { get; private set; } - public static DllImportStub Create(IMethodSymbol method, CancellationToken token = default) + /// + /// Flags used to indicate members on GeneratedDllImport attribute. + /// + [Flags] + public enum DllImportMember + { + None = 0, + BestFitMapping = 1 << 0, + CallingConvention = 1 << 1, + CharSet = 1 << 2, + EntryPoint = 1 << 3, + ExactSpelling = 1 << 4, + PreserveSig = 1 << 5, + SetLastError = 1 << 6, + ThrowOnUnmappableChar = 1 << 7, + } + + /// + /// GeneratedDllImportAttribute data + /// + /// + /// The names of these members map directly to those on the + /// DllImportAttribute and should not be changed. + /// + public class GeneratedDllImportData + { + public string ModuleName { get; set; } + + /// + /// Value set by the user on the original declaration. + /// + public DllImportMember IsUserDefined = DllImportMember.None; + + // Default values for the below fields are based on the + // documented semanatics of DllImportAttribute: + // - https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute + public bool BestFitMapping { get; set; } = true; + public CallingConvention CallingConvention { get; set; } = CallingConvention.Winapi; + public CharSet CharSet { get; set; } = CharSet.Ansi; + public string EntryPoint { get; set; } = null; + public bool ExactSpelling { get; set; } = false; // VB has different and unusual default behavior here. + public bool PreserveSig { get; set; } = true; + public bool SetLastError { get; set; } = false; + public bool ThrowOnUnmappableChar { get; set; } = false; + } + + public static DllImportStub Create( + IMethodSymbol method, + GeneratedDllImportData dllImportData, + CancellationToken token = default) { // Cancel early if requested token.ThrowIfCancellationRequested(); @@ -75,35 +152,33 @@ public static DllImportStub Create(IMethodSymbol method, CancellationToken token stubContainingTypes.Reverse(); // Determine parameter types - var stubParams = new List<(string Type, string Name, RefKind RefKind)>(); - var dllImportParams = new List<(string Type, string Name, RefKind RefKind)>(); - foreach (var namePair in method.Parameters) + var paramsTypeInfo = new List(); + foreach (var paramSymbol in method.Parameters) { - stubParams.Add((ComputeTypeForStub(namePair.Type, namePair.RefKind), namePair.Name, namePair.RefKind)); - dllImportParams.Add((ComputeTypeForDllImport(namePair.Type, namePair.RefKind), namePair.Name, namePair.RefKind)); + paramsTypeInfo.Add(TypePositionInfo.CreateForParameter(paramSymbol)); } + var retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes()); + string dllImportName = method.Name + "__PInvoke__"; #if !GENERATE_FORWARDER var dispatchCall = new StringBuilder($"throw new System.{nameof(NotSupportedException)}();"); #else // Forward call to generated P/Invoke - var returnMaybe = method.ReturnType.SpecialType == SpecialType.System_Void - ? string.Empty - : "return "; + var returnMaybe = method.ReturnsVoid ? string.Empty : "return "; var dispatchCall = new StringBuilder($"{returnMaybe}{dllImportName}"); - if (!dllImportParams.Any()) + if (!paramsTypeInfo.Any()) { dispatchCall.Append("();"); } else { char delim = '('; - foreach (var param in dllImportParams) + foreach (var param in paramsTypeInfo) { - dispatchCall.Append($"{delim}{RefKindToString(param.RefKind)}{param.Name}"); + dispatchCall.Append($"{delim}{param.RefKindDecl}{param.InstanceIdentifier}"); delim = ','; } dispatchCall.Append(");"); @@ -112,97 +187,14 @@ public static DllImportStub Create(IMethodSymbol method, CancellationToken token return new DllImportStub() { + returnTypeInfo = retTypeInfo, + paramsTypeInfo = paramsTypeInfo, StubTypeNamespace = stubTypeNamespace, StubContainingTypesDecl = stubContainingTypes, - StubReturnType = ComputeTypeForStub(method.ReturnType), - StubParameters = stubParams, StubCode = new[] { dispatchCall.ToString() }, - DllImportReturnType = ComputeTypeForDllImport(method.ReturnType), DllImportMethodName = dllImportName, - DllImportParameters = dllImportParams, Diagnostics = Enumerable.Empty(), }; } - - private static string RefKindToString(RefKind refKind) - { - return refKind switch - { - RefKind.In => "in ", - RefKind.Ref => "ref ", - RefKind.Out => "out ", - RefKind.None => string.Empty, - _ => throw new NotImplementedException("Support for some RefKind"), - }; - } - - private static string ComputeTypeForStub(ITypeSymbol type, RefKind refKind = RefKind.None) - { - var typeAsString = type.SpecialType switch - { - SpecialType.System_Void => "void", - SpecialType.System_SByte => "sbyte", - SpecialType.System_Byte => "byte", - SpecialType.System_Int16 => "short", - SpecialType.System_UInt16 => "ushort", - SpecialType.System_Int32 => "int", - SpecialType.System_UInt32 => "uint", - SpecialType.System_Int64 => "long", - SpecialType.System_UInt64 => "ulong", - SpecialType.System_Single => "float", - SpecialType.System_Double => "double", - SpecialType.System_String => "string", - SpecialType.System_IntPtr => "System.IntPtr", - SpecialType.System_UIntPtr => "System.UIntPtr", - _ => null, - }; - - var typePrefix = string.Empty; - if (typeAsString is null) - { - // Determine the namespace - if (!(type.ContainingNamespace is null) - && !type.ContainingNamespace.IsGlobalNamespace) - { - typePrefix = $"{type.ContainingNamespace}{Type.Delimiter}"; - } - - typeAsString = type.ToString(); - } - - string refKindAsString = RefKindToString(refKind); - return $"{refKindAsString}{typePrefix}{typeAsString}"; - } - - private static string ComputeTypeForDllImport(ITypeSymbol type, RefKind refKind = RefKind.None) - { -#if GENERATE_FORWARDER - return ComputeTypeForStub(type, refKind); -#else - if (!type.IsUnmanagedType) - { - return "void*"; - } - - return type.SpecialType switch - { - SpecialType.System_Void => "void", - SpecialType.System_SByte => "sbyte", - SpecialType.System_Byte => "byte", - SpecialType.System_Int16 => "short", - SpecialType.System_UInt16 => "ushort", - SpecialType.System_Int32 => "int", - SpecialType.System_UInt32 => "uint", - SpecialType.System_Int64 => "long", - SpecialType.System_UInt64 => "ulong", - SpecialType.System_Single => "float", - SpecialType.System_Double => "double", - SpecialType.System_String => "char*", // [TODO] Consider encoding here - SpecialType.System_IntPtr => "void*", - SpecialType.System_UIntPtr => "void*", - _ => "void*", - }; -#endif - } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs new file mode 100644 index 0000000000000..34e7f77dd9ddd --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -0,0 +1,232 @@ +using Microsoft.CodeAnalysis; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Text; + +namespace Microsoft.Interop +{ + /// + /// Collected MarshalAsAttribute info. + /// + internal sealed class MarshalAsInfo + { + public UnmanagedType UnmanagedType { get; set; } + public string CustomMarshallerTypeName { get; set; } + public string CustomMarshallerCookie { get; set; } + + public UnmanagedType UnmanagedArraySubType { get; set; } + public int ArraySizeConst { get; set; } + public short ArraySizeParamIndex { get; set; } + } + + /// + /// Positional type information involved in unmanaged/managed scenarios. + /// + internal sealed class TypePositionInfo + { + public const int UnsetIndex = int.MinValue; + public const int ReturnIndex = UnsetIndex + 1; + + private TypePositionInfo() + { + this.ManagedIndex = UnsetIndex; + this.UnmanagedIndex = UnsetIndex; + this.UnmanagedLCIDConversionArgIndex = UnsetIndex; + } + + public ITypeSymbol TypeSymbol { get; private set; } + public string InstanceIdentifier { get; private set; } + + public RefKind RefKind { get; private set; } + public string RefKindDecl { get => RefKindToString(this.RefKind); } + public string ManagedTypeDecl { get; private set; } + public string UnmanagedTypeDecl { get; private set; } + + public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } + public bool IsUnmanagedReturnPosition { get => this.UnmanagedIndex == ReturnIndex; } + + public int ManagedIndex { get; set; } + public int UnmanagedIndex { get; set; } + public int UnmanagedLCIDConversionArgIndex { get; private set; } + + public MarshalAsInfo MarshalAsInfo { get; private set; } + + public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol) + { + var typeInfo = new TypePositionInfo() + { + TypeSymbol = paramSymbol.Type, + InstanceIdentifier = paramSymbol.Name, + ManagedTypeDecl = ComputeTypeForManaged(paramSymbol.Type, paramSymbol.RefKind), + UnmanagedTypeDecl = ComputeTypeForUnmanaged(paramSymbol.Type, paramSymbol.RefKind), + RefKind = paramSymbol.RefKind + }; + + UpdateWithAttributeData(paramSymbol.GetAttributes(), ref typeInfo); + + return typeInfo; + } + + public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes) + { + var typeInfo = new TypePositionInfo() + { + TypeSymbol = type, + InstanceIdentifier = string.Empty, + ManagedTypeDecl = ComputeTypeForManaged(type, RefKind.None), + UnmanagedTypeDecl = ComputeTypeForUnmanaged(type, RefKind.None), + RefKind = RefKind.None + }; + + UpdateWithAttributeData(attributes, ref typeInfo); + + return typeInfo; + } + + private static void UpdateWithAttributeData(IEnumerable attributes, ref TypePositionInfo typeInfo) + { + // Look at attributes on the type. + foreach (var attrData in attributes) + { + string attributeName = attrData.AttributeClass.Name; + + if (nameof(MarshalAsAttribute).Equals(attributeName)) + { + // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute + typeInfo.MarshalAsInfo = CreateMarshalAsInfo(attrData); + } + else if (nameof(LCIDConversionAttribute).Equals(attributeName)) + { + // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute + typeInfo.UnmanagedLCIDConversionArgIndex = (int)attrData.ConstructorArguments[0].Value; + } + } + + static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData) + { + var info = new MarshalAsInfo + { + UnmanagedType = (UnmanagedType)attrData.ConstructorArguments[0].Value + }; + + // All other data on attribute is defined as NamedArguments. + foreach (var namedArg in attrData.NamedArguments) + { + switch (namedArg.Key) + { + default: + Debug.Fail($"An unknown member was found on {nameof(MarshalAsAttribute)}"); + continue; + case nameof(MarshalAsAttribute.SafeArraySubType): + case nameof(MarshalAsAttribute.SafeArrayUserDefinedSubType): + case nameof(MarshalAsAttribute.IidParameterIndex): + // [TODO] Report not supported + break; + case nameof(MarshalAsAttribute.MarshalTypeRef): + case nameof(MarshalAsAttribute.MarshalType): + // Call ToString() to handle INamedTypeSymbol as well. + info.CustomMarshallerTypeName = namedArg.Value.Value.ToString(); + break; + case nameof(MarshalAsAttribute.MarshalCookie): + info.CustomMarshallerCookie = (string)namedArg.Value.Value; + break; + case nameof(MarshalAsAttribute.ArraySubType): + info.UnmanagedArraySubType = (UnmanagedType)namedArg.Value.Value; + break; + case nameof(MarshalAsAttribute.SizeConst): + info.ArraySizeConst = (int)namedArg.Value.Value; + break; + case nameof(MarshalAsAttribute.SizeParamIndex): + info.ArraySizeParamIndex = (short)namedArg.Value.Value; + break; + } + } + + return info; + } + } + + private static string ComputeTypeForManaged(ITypeSymbol type, RefKind refKind) + { + var typeAsString = type.SpecialType switch + { + SpecialType.System_Void => "void", + SpecialType.System_SByte => "sbyte", + SpecialType.System_Byte => "byte", + SpecialType.System_Int16 => "short", + SpecialType.System_UInt16 => "ushort", + SpecialType.System_Int32 => "int", + SpecialType.System_UInt32 => "uint", + SpecialType.System_Int64 => "long", + SpecialType.System_UInt64 => "ulong", + SpecialType.System_Single => "float", + SpecialType.System_Double => "double", + SpecialType.System_String => "string", + SpecialType.System_IntPtr => "System.IntPtr", + SpecialType.System_UIntPtr => "System.UIntPtr", + _ => null, + }; + + var typePrefix = string.Empty; + if (typeAsString is null) + { + // Determine the namespace + if (!(type.ContainingNamespace is null) + && !type.ContainingNamespace.IsGlobalNamespace) + { + typePrefix = $"{type.ContainingNamespace}{Type.Delimiter}"; + } + + typeAsString = type.ToString(); + } + + string refKindAsString = RefKindToString(refKind); + return $"{refKindAsString}{typePrefix}{typeAsString}"; + } + + private static string ComputeTypeForUnmanaged(ITypeSymbol type, RefKind refKind) + { +#if GENERATE_FORWARDER + return ComputeTypeForManaged(type, refKind); +#else + if (!type.IsUnmanagedType) + { + return "void*"; + } + + return type.SpecialType switch + { + SpecialType.System_Void => "void", + SpecialType.System_SByte => "sbyte", + SpecialType.System_Byte => "byte", + SpecialType.System_Int16 => "short", + SpecialType.System_UInt16 => "ushort", + SpecialType.System_Int32 => "int", + SpecialType.System_UInt32 => "uint", + SpecialType.System_Int64 => "long", + SpecialType.System_UInt64 => "ulong", + SpecialType.System_Single => "float", + SpecialType.System_Double => "double", + SpecialType.System_String => "char*", // [TODO] Consider encoding here + SpecialType.System_IntPtr => "void*", + SpecialType.System_UIntPtr => "void*", + _ => "void*", + }; +#endif + } + + private static string RefKindToString(RefKind refKind) + { + return refKind switch + { + RefKind.In => "in ", + RefKind.Ref => "ref ", + RefKind.Out => "out ", + RefKind.None => string.Empty, + _ => throw new NotImplementedException("Support for some RefKind"), + }; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/readme.md b/src/libraries/System.Runtime.InteropServices/gen/readme.md index 3a3f5d25594a4..e54d73e8164e2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/readme.md +++ b/src/libraries/System.Runtime.InteropServices/gen/readme.md @@ -1,3 +1,16 @@ # DllImport Generator -See [P/Invoke source generator proposal](https://github.com/dotnet/runtime/blob/master/docs/design/features/source-generator-pinvokes.md) for design and goals. \ No newline at end of file +See [P/Invoke source generator proposal](https://github.com/dotnet/runtime/blob/master/docs/design/features/source-generator-pinvokes.md) for design and goals. + +## Additional work + +Below are additional work items that are not presently captured in this repository. + +### Required + +* Add `GeneratedDllImportAttribute` to the BCL. See [`GeneratedDllImportAttribute.cs`](./DllImportGeneratorAttribute/GeneratedDllImportAttribute.cs). +* Add support for calling [`SetLastError()`](https://docs.microsoft.com/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror) from managed code with the expected semantics. During P/Invoke transitions the runtime manipulates the associated thread's error code and thus breaks `SetLastError()` semantics. + +### Optional + +* A tool to compare the resulting IL from the generated source to that generated by the built-in IL Marshaller system. This would help with validation of what is being generated. \ No newline at end of file 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 new file mode 100644 index 0000000000000..ad8edc594033a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj @@ -0,0 +1,8 @@ + + + + net5.0 + 8.0 + + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs new file mode 100644 index 0000000000000..0f0d322da4dd8 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs @@ -0,0 +1,25 @@ +#nullable enable + +namespace System.Runtime.InteropServices +{ + // [TODO] Remove once the attribute has been added to the BCL + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public sealed class GeneratedDllImportAttribute : Attribute + { + public bool BestFitMapping; + public CallingConvention CallingConvention; + public CharSet CharSet; + public string? EntryPoint; + public bool ExactSpelling; + public bool PreserveSig; + public bool SetLastError; + public bool ThrowOnUnmappableChar; + + public GeneratedDllImportAttribute(string dllName) + { + this.Value = dllName; + } + + public string Value { get; private set; } + } +} diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index f03d8a3f6c20d..09299b00addba 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -8,6 +8,7 @@ + From c58deadab46be312d8a458db7aac411bd8378e10 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 5 Aug 2020 13:02:57 -0700 Subject: [PATCH 009/161] Special case boolean/char types in managed/native signatures. (dotnet/runtimelab#47) Commit migrated from https://github.com/dotnet/runtimelab/commit/39ce2af428817677201f0f2fdd79c2a3bfddcefe --- .../gen/DllImportGenerator/TypePositionInfo.cs | 5 ++++- .../tests/Ancillary.Interop/Ancillary.Interop.csproj | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 34e7f77dd9ddd..c9cf380c3db9b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; -using System.Text; namespace Microsoft.Interop { @@ -153,6 +152,8 @@ private static string ComputeTypeForManaged(ITypeSymbol type, RefKind refKind) var typeAsString = type.SpecialType switch { SpecialType.System_Void => "void", + SpecialType.System_Boolean => "bool", + SpecialType.System_Char => "char", SpecialType.System_SByte => "sbyte", SpecialType.System_Byte => "byte", SpecialType.System_Int16 => "short", @@ -199,6 +200,8 @@ private static string ComputeTypeForUnmanaged(ITypeSymbol type, RefKind refKind) return type.SpecialType switch { SpecialType.System_Void => "void", + SpecialType.System_Boolean => "byte", // [TODO] Determine marshalling default C++ bool or Windows' BOOL + SpecialType.System_Char => "ushort", // CLR character width (UTF-16) SpecialType.System_SByte => "sbyte", SpecialType.System_Byte => "byte", SpecialType.System_Int16 => "short", 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 ad8edc594033a..536eec52ae8f5 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 @@ -3,6 +3,7 @@ net5.0 8.0 + System.Runtime.InteropServices From 83fbd4e34d5256a904fa3fa923687b5e67f75a69 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 17 Aug 2020 09:54:53 -0700 Subject: [PATCH 010/161] Add struct marshalling design doc. (dotnet/runtimelab#45) Co-authored-by: Jan Kotas Commit migrated from https://github.com/dotnet/runtimelab/commit/e50c8c26eaef29e47a455c0781eda10a3786957e --- .../DllImportGenerator/StructMarshalling.md | 246 ++++++++++++++++++ .../gen/readme.md | 6 +- 2 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md new file mode 100644 index 0000000000000..efefd426a96d1 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md @@ -0,0 +1,246 @@ +# Struct Marshalling + +As part of the new source-generated direction for .NET Interop, we are looking at various options for supporting marshaling user-defined struct types. + +These types pose an interesting problem for a number of reasons listed below. With a few constraints, I believe we can create a system that will enable users to use their own user-defined types and pass them by-value to native code. + +## Problems + +- Unmanaged vs Blittable + - The C# language (and Roslyn) do not have a concept of "blittable types". It only has the concept of "unmanaged types", which is similar to blittable, but differs for `bool`s and `char`s. `bool` and `char` types are "unmanaged", but are never (in the case of `bool`), or only sometimes (in the case of `char`) blittable. As a result, we cannot use the "is this type unmanaged" check in Roslyn for structures. +- Limited type information in ref assemblies. + - In the ref assemblies generated by dotnet/runtime, we save space and prevent users from relying on private implementation details of structures by emitting limited information about their fields. Structures that have at least one non-object field are given a private `int` field, and structures that have at least one field that transitively contains an object are given one private `object`-typed field. As a result, we do not have full type information at code-generation time for any structures defined in the BCL when compiling a library that uses the ref assemblies. +- Private reflection + - Even when we do have information about all of the fields, we can't emit code that references them if they are private, so we would have to emit unsafe code and calculate offsets manually to support marshaling them. + +## Opt-in Interop + +We've been working around another problem for a while in the runtime-integrated interop design: The user can use any type that is non-auto layout and has fields that can be marshaled in interop. This has lead to various issues where types that were not intended for interop usage became usable and then we couldn't update their behavior to be special-cased since users may have been relying on the generic behavior (`Span`, `Vector` come to mind). + +I propose an opt-in design where the owner of a struct has to explicitly opt-in to usage for interop. This enables our team to add special support as desired for various types such as `Span` while also avoiding the private reflection and limited type information issues mentioned above. + +This design would use these attributes: + +```csharp + +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] +public class GeneratedMarshallingAttribute : Attribute {} + +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] +public class BlittableTypeAttribute : Attribute {} + +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] +public class NativeMarshallingAttribute : Attribute +{ + public NativeMarshallingAttribute(Type nativeType) {} +} + +[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field)] +public class MarshalUsingAttribute : Attribute +{ + public MarshalUsingAttribute(Type nativeType) {} +} + +``` + +The `NativeMarshallingAttribute` and `MarshalUsingAttribute` attributes would require that the provided native type `TNative` is a blittable `struct` and has a subset of three methods with the following names and shapes (with the managed type named TManaged): + +```csharp +partial struct TNative +{ + public TNative(TManaged managed) {} + public TManaged ToManaged() {} + + public void FreeNative() {} +} +``` + +The analyzer will report an error if neither the construtor nor the ToManaged method is defined. When one of those two methods is missing, the direction of marshalling (managed to native/native to managed) that relies on the missing method is considered unsupported for the corresponding managed type. The FreeNative method is only required when there are resources that need to be released. + + +> :question: Does this API surface and shape work for all marshalling scenarios we plan on supporting? It may have issues with the current "layout class" by-value `[Out]` parameter marshalling where the runtime updates a `class` typed object in place. We already recommend against using classes for interop for performance reasons and a struct value passed via `ref` or `out` with the same members would cover this scenario. + +If the native type `TNative` also has a public `Value` property, then the value of the `Value` property will be passed to native code instead of the `TNative` value itself. As a result, the type `TNative` will be allowed to be non-blittable and the type of the `Value` property will be required to be blittable. If the `Value` property is settable, then when marshalling in the native-to-managed direction, a default value of `TNative` will have its `Value` property set to the native value. If `Value` does not have a setter, then marshalling from native to managed is not supported. + +### Performance features + +#### Pinning + +Since C# 7.3 added a feature to enable custom pinning logic for user types, we should also add support for custom pinning logic. If the user provides a `GetPinnableReference` method that matches the requirements to be used in a `fixed` statement and the pointed-to type is blittable, then we will support using pinning to marshal the managed value when possible. The analyzer should issue a warning when the pointed-to type would not match the final native type, accounting for the `Value` property on the native type. Since `MarshalUsingAttribute` is applied at usage time instead of at type authoring time, we will not enable the pinning feature since the implementation of `GetPinnableReference` unless the pointed-to return type matches the native type. + +#### Stackalloc + +Custom marshalers of collection-like types or custom string encodings (such as UTF-32) may want to use stack space for extra storage for additional performance when possible. If the `TNative` type provides additional members with the following signatures, then it will opt in to using a stack-allocated buffer: + +```csharp +partial struct TNative +{ + public TNative(TManaged managed, Span stackSpace) {} + + public static const int StackBufferSize = /* */; +} +``` + +When these members are both present, the source generator will call the two-parameter constructor with a stack-allocated buffer of `StackBufferSize` bytes when a stack-allocated buffer is usable. As this buffer is guaranteed to be stack allocated and not on the GC heap, it is safe to use `Unsafe.AsPointer` to get a pointer to the stack buffer to pass to native code. As a stack-allocated buffer is not usable in all scenarios, for example Reverse P/Invoke and struct marshalling, a one-parameter constructor must also be provided for usage in those scenarios. This may also be provided by providing a two-parameter constructor with a default value for the second parameter. + +### Usage + +There are 2 usage mechanisms of these attributes. + +#### Usage 1, Source-generated interop + +The user can apply the `GeneratedMarshallingAttribute` to their structure `S`. The source generator will determine if the type is blittable. If it is blittable, the source generator will generate a partial definition and apply the `BlittableTypeAttribute` to the struct type `S`. Otherwise, it will generate a blittable representation of the struct with the aformentioned requried shape and apply the `NativeMarshallingAttribute` and point it to the blittable representation. The blittable representation can either be generated as a separate top-level type or as a nested type on `S`. + +#### Usage 2, Manual interop + +The user may want to manually mark their types as marshalable in this system due to specific restrictions in their code base around marshaling specific types that the source generator does not account for. We could also use this internally to support custom types in source instead of in the code generator. In this scenario, the user would apply either the `BlittableTypeAttribute` or the `NativeMarshallingAttribute` attribute to their struct type. An analyzer would validate that the struct is blittable if the `BlittableTypeAttribute` is applied or validate that the native struct type is blittable and has marshalling methods of the required shape when the `NativeMarshallingAttribute` is applied. + +The P/Invoke source generator (as well as the struct source generator when nested struct types are used) would use the `BlittableTypeAttribute` and `NativeMarshallingAttribute` to determine how to marshal a value type parameter or field instead of looking at the fields of the struct directly. + +If a structure type does not have either the `BlittableTypeAttribute` or the `NativeMarshallingAttribute` applied at the type definition, the user can supply a `MarshalUsingAttribute` at the marshalling location (field, parameter, or return value) with a native type matching the same requirements as `NativeMarshallingAttribute`'s native type. + +### Why do we need `BlittableTypeAttribute`? + +Based on the design above, it seems that we wouldn't need `BlittableTypeAttribute`. However, due to the ref assembly issue above in combination with the desire to enable manual interop, we need to provide a way for users to signal that a given type should be blittable and that the source generator should not generate marshalling code. + +I'll give a specific example for where we need the `BlittableTypeAttribute` below. Let's take a scenario where we don't have `BlittableTypeAttribute`. + +In Foo.csproj, we have the following types: + +```csharp +public struct Foo +{ + private bool b; +} + +public struct Bar +{ + private short s; +} +``` + +We compile these types into an assembly Foo.dll and we want to publish a package. We decide to use infrastructure similar to dotnet/runtime and produce a ref assembly. The ref assembly will have the following types: + +```csharp +struct Foo +{ + private int dummy; +} +struct Bar +{ + private int dummy; +} +``` + +We package up the ref and impl assemblies and ship them in a NuGet package. + +Someone else pulls down this package and writes their own struct type Baz1 and Baz2: + +```csharp +struct Baz1 +{ + private Foo f; +} +struct Baz2 +{ + private Bar b; +} +``` + +Since the source generator only sees ref assemblies, it would think that both `Baz1` and `Baz2` are blittable, when in reality only `Baz2` is blittable. This is the ref assembly issue mentioned above. The source generator cannot trust the shape of structures in other assemblies since those types may have private implementation details hidden. + +Now let's take this scenario again with `BlittableTypeAttribute`: + +```csharp +[BlittableType] +public struct Foo +{ + private bool b; +} + +[BlittableType] +public struct Bar +{ + private short s; +} +``` + +This time, we produce an error since Foo is not blittable. We need to either apply the `GeneratedMarshalling` attribute (to generate marshalling code) or the `NativeMarshallingAttribute` attribute (so provide manually written marshalling code) to Foo. This is also why we require each type used in interop to have either a `[BlittableType]` attribute or a `[NativeMarshallingAttribute]` attribute; we can't validate the shape of a type not defined in the current assembly because its shape may be different between its reference assembly and the runtime type. + +Now there's another question: Why we can't just say that a type with `[GeneratedMarshalling]` and not `[NativeMarshallingAttribute]` has been considered blittable? + +We don't want to require usage of `[GeneratedMarshalling]` to mark that a type is blittable because then there is no way to enforce that the type is blittable. If we require usage of `[GeneratedMarshalling]`, then we will automatically generate marshalling code if the type is not blittable. By also having the `[BlittableType]` attribute, we enable users to mark types that they want to ensure are blittable and an analyzer will validate the blittability. + +Basically, the design of this feature is as follows: + +At build time, the user can apply either `[GeneratedMarshallling]`, `[BlittableType]`, or `[NativeMarshallingAttribute]`. If they apply `[GeneratedMarshalling]`, then the source generator will run and generate marshalling code as needed and apply either `[BlittableType]` or `[NativeMarshallingAttribute]`. If the user manually applies `[BlittableType]` or `[NativeMarshallingAttribute]` instead of `[GeneratedMarshalling]`, then an analyzer validates that the type is blittable (for `[BlitttableType]`) or that the marshalling methods and types have the required shapes (for `[NativeMarshallingAttribute]`). + +When the source generator (either Struct, P/Invoke, Reverse P/Invoke, etc.) encounters a struct type, it will look for either the `[BlittableType]` or the `[NativeMarshallingAttribute]` attributes to determine how to marshal the structure. If neither of these attributes are applied, then the struct cannot be passed by value. + + +If someone actively disables the analyzer or writes their types in IL, then they have stepped out of the supported scenarios and marshalling code generated for their types may be inaccurate. + +### Special case: Transparent Structures + +There has been discussion about Transparent Structures, structure types that are treated as their underlying types when passed to native code. The support for a `Value` property on a generated marshalling type supports the transparent struct support. For example, we could support strongly typed `HRESULT` returns with this model as shown below: + +```csharp +[NativeMarshalling(typeof(HRESULT))] +struct HResult +{ + public HResult(int result) + { + Result = result; + } + public readonly int Result; +} + +struct HRESULT +{ + public HRESULT(HResult hr) + { + Value = hr; + } + + public HResult ToManaged() => new HResult(Value); + public int Value { get; set; } +} +``` + +In this case, the underlying native type would actually be an `int`, but the user could use the strongly-typed `HResult` type as the public surface area. + +> :question: Should we support transparent structures on manually annotated blittable types? If we do, we should do so in an opt-in manner to make it possible to have a `Value` property on the blittable type. + +#### Special case: ComWrappers marshalling with Transparent Structures + +Building on this Transparent Structures support, we can also support ComWrappers marshalling with this proposal via the manually-decorated types approach: + +```csharp +[NativeMarshalling(typeof(ComWrappersMarshaler))] +class Foo +{} + +struct ComWrappersMarshaler + where TComWrappers : ComWrappers, new() +{ + private static readonly TComWrappers ComWrappers = new TComWrappers(); + + private IntPtr nativeObj; + + public ComWrappersMarshaler(TClass obj) + { + nativeObj = ComWrappers.GetOrCreateComInterfaceForObject(obj, CreateComInterfaceFlags.None); + } + + public IntPtr Value { get => nativeObj; set => nativeObj = value; } + + public TClass ToManaged() => (TClass)ComWrappers.GetOrCreateObjectForComInstance(nativeObj, CreateObjectFlags.None); + + public unsafe void FreeNative() + { + ((delegate* unmanaged[Stdcall])((*(void***)nativeObj)[2 /* Release */]))(nativeObj); + } +} +``` + +This ComWrappers-based marshaller works with all `ComWrappers`-derived types that have a parameterless constructor and correctly passes down a native integer (not a structure) to native code to match the expected ABI. diff --git a/src/libraries/System.Runtime.InteropServices/gen/readme.md b/src/libraries/System.Runtime.InteropServices/gen/readme.md index e54d73e8164e2..a765a7a51257d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/readme.md +++ b/src/libraries/System.Runtime.InteropServices/gen/readme.md @@ -13,4 +13,8 @@ Below are additional work items that are not presently captured in this reposito ### Optional -* A tool to compare the resulting IL from the generated source to that generated by the built-in IL Marshaller system. This would help with validation of what is being generated. \ No newline at end of file +* A tool to compare the resulting IL from the generated source to that generated by the built-in IL Marshaller system. This would help with validation of what is being generated. + +## Designs + +- [Struct Marshalling](./designs/StructMarshalling.md) From 0f74067286e3fd422da603e0fc7eb46feb0ad8c6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 1 Sep 2020 10:11:11 -0700 Subject: [PATCH 011/161] Add the struct marshalling attributes to Ancillary.Interop and add an analyzer that validates manual usage. (dotnet/runtimelab#61) Co-authored-by: Elinor Fung Commit migrated from https://github.com/dotnet/runtimelab/commit/05d6ef236f7bd698870b17e8abb1b7c6bb130198 --- .../DllImportGenerator.Test/CompileFails.cs | 5 +- .../gen/DllImportGenerator.Test/Compiles.cs | 5 +- .../DllImportGenerator.Test.csproj | 6 +- .../ManualTypeMarshallingAnalyzerTests.cs | 974 ++++++++++++++++++ .../gen/DllImportGenerator.Test/TestUtils.cs | 31 +- .../Verifiers/CSharpAnalyzerVerifier.cs | 64 ++ .../Verifiers/CSharpVerifierHelper.cs | 33 + .../DllImportGenerator.csproj | 15 + .../ManualTypeMarshallingAnalyzer.cs | 385 +++++++ .../DllImportGenerator/Resources.Designer.cs | 261 +++++ .../gen/DllImportGenerator/Resources.resx | 186 ++++ .../gen/DllImportGenerator/TypeNames.cs | 19 + .../TypeSymbolExtensions.cs | 103 ++ .../GeneratedMarshallingAttribute.cs | 36 + 14 files changed, 2104 insertions(+), 19 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpAnalyzerVerifier.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpVerifierHelper.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs index 75e8847232dcc..3acbdace6ced4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs @@ -1,5 +1,6 @@ using Microsoft.CodeAnalysis; using System.Collections.Generic; +using System.Threading.Tasks; using Xunit; namespace DllImportGenerator.Test @@ -13,9 +14,9 @@ public static IEnumerable CodeSnippetsToCompile() [Theory] [MemberData(nameof(CodeSnippetsToCompile))] - public void ValidateSnippets(string source, int failCount) + public async Task ValidateSnippets(string source, int failCount) { - Compilation comp = TestUtils.CreateCompilation(source); + Compilation comp = await TestUtils.CreateCompilation(source); TestUtils.AssertPreSourceGeneratorCompilation(comp); var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index 85cd5cad87a8e..9e0fda1aab002 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -1,5 +1,6 @@ using Microsoft.CodeAnalysis; using System.Collections.Generic; +using System.Threading.Tasks; using Xunit; namespace DllImportGenerator.Test @@ -23,9 +24,9 @@ public static IEnumerable CodeSnippetsToCompile() [Theory] [MemberData(nameof(CodeSnippetsToCompile))] - public void ValidateSnippets(string source) + public async Task ValidateSnippets(string source) { - Compilation comp = TestUtils.CreateCompilation(source); + Compilation comp = await TestUtils.CreateCompilation(source); TestUtils.AssertPreSourceGeneratorCompilation(comp); var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj index 4cba239e624ec..298f48c678644 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj @@ -9,6 +9,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -29,5 +30,8 @@ - + + + https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json ;$(RestoreAdditionalProjectSources) + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs new file mode 100644 index 0000000000000..414a4bcd09186 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs @@ -0,0 +1,974 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using static Microsoft.Interop.ManualTypeMarshallingAnalyzer; + +using VerifyCS = DllImportGenerator.Test.Verifiers.CSharpAnalyzerVerifier; + +namespace DllImportGenerator.Test +{ + public class ManualTypeMarshallingAnalyzerTests + { + public static IEnumerable NonBlittableTypeMarkedBlittable_ReportsDiagnostic_TestData { + get + { + yield return new object[] + { + @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public bool field; +} +" + }; + yield return new object[] + { + @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public char field; +} +" + }; + yield return new object[] + { + +@" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public string field; +} +" + }; + } + } + + [MemberData(nameof(NonBlittableTypeMarkedBlittable_ReportsDiagnostic_TestData))] + [Theory] + public async Task NonBlittableTypeMarkedBlittable_ReportsDiagnostic(string source) + { + var diagnostic = VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S"); + await VerifyCS.VerifyAnalyzerAsync(source, diagnostic); + } + + [Fact] + public async Task TypeWithBlittablePrimitiveFieldsMarkedBlittableNoDiagnostic() + { + + string source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public int field; +} +"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task TypeWithBlittableStructFieldsMarkedBlittableNoDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public T field; +} + +[BlittableType] +struct T +{ + public int field; +} +"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task TypeMarkedBlittableWithNonBlittableFieldsMarkedBlittableReportDiagnosticOnFieldTypeDefinition() + { + string source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public T field; +} + +[BlittableType] +struct T +{ + public bool field; +} +"; + var diagnostic = VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(10, 2, 10, 15).WithArguments("T"); + await VerifyCS.VerifyAnalyzerAsync(source, diagnostic); + } + + [Fact] + public async Task NonUnmanagedTypeMarkedBlittable_ReportsDiagnosticOnStructType() + { + string source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public T field; +} + +[BlittableType] +struct T +{ + public string field; +} +"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S"), + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(10, 2, 10, 15).WithArguments("T")); + } + + [Fact] + public async Task BlittableTypeWithNonBlittableStaticField_DoesNotReportDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public static string Static; + public int instance; +} +"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NullNativeType_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[NativeMarshalling(null)] +struct S +{ + public string s; +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBeNonNullRule).WithSpan(4, 2, 4, 25).WithArguments("S")); + } + + [Fact] + public async Task NonNamedNativeType_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(int*))] +struct S +{ + public string s; +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(4, 2, 4, 33).WithArguments("int*", "S")); + } + + [Fact] + public async Task NonBlittableNativeType_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +struct Native +{ + private string value; + + public Native(S s) + { + value = s.s; + } + + public S ToManaged() => new S { s = value }; +}"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 20, 2).WithArguments("Native", "S")); + } + + [Fact] + public async Task ClassNativeType_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +class Native +{ + private IntPtr value; + + public Native(S s) + { + } + + public S ToManaged() => new S(); +}"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(11, 1, 20, 2).WithArguments("Native", "S")); + } + + [Fact] + public async Task BlittableNativeType_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +[BlittableType] +struct Native +{ + private IntPtr value; + + public Native(S s) + { + value = IntPtr.Zero; + } + + public S ToManaged() => new S(); +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task BlittableNativeWithNonBlittableValueProperty_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +[BlittableType] +struct Native +{ + private IntPtr value; + + public Native(S s) + { + value = IntPtr.Zero; + } + + public S ToManaged() => new S(); + + public string Value { get => null; set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(23, 5, 23, 48).WithArguments("string", "S")); + } + + [Fact] + public async Task NonBlittableNativeTypeWithBlittableValueProperty_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +struct Native +{ + private string value; + + public Native(S s) + { + value = s.s; + } + + public S ToManaged() => new S() { s = value }; + + public IntPtr Value { get => IntPtr.Zero; set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task ClassNativeTypeWithValueProperty_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +class Native +{ + private string value; + + public Native(S s) + { + value = s.s; + } + + public S ToManaged() => new S() { s = value }; + + public IntPtr Value { get => IntPtr.Zero; set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(11, 1, 23, 2).WithArguments("Native", "S")); + } + + [Fact] + public async Task NonBlittableGetPinnableReferenceReturnType_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public char c; + + public ref char GetPinnableReference() => ref c; +} + +unsafe struct Native +{ + private IntPtr value; + + public Native(S s) + { + value = IntPtr.Zero; + } + + public S ToManaged() => new S(); + + public IntPtr Value { get => IntPtr.Zero; set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(GetPinnableReferenceReturnTypeBlittableRule).WithSpan(10, 5, 10, 53)); + } + + + [Fact] + public async Task BlittableGetPinnableReferenceReturnType_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; + + public ref byte GetPinnableReference() => ref c; +} + +unsafe struct Native +{ + private IntPtr value; + + public Native(S s) : this() + { + value = IntPtr.Zero; + } + + public S ToManaged() => new S(); + + public IntPtr Value { get => IntPtr.Zero; set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task TypeWithGetPinnableReferenceNonPointerReturnType_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; + + public ref byte GetPinnableReference() => ref c; +} + +unsafe struct Native +{ + private IntPtr value; + + public Native(S s) : this() + { + value = IntPtr.Zero; + } + + public S ToManaged() => new S(); + + public int Value { get => 0; set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithSpan(24, 5, 24, 42).WithArguments("int", "S")); + } + + [Fact] + public async Task BlittableValueTypeWithNoFields_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NativeTypeWithNoMarshallingMethods_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[BlittableType] +struct Native +{ +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(11, 1, 14, 2).WithArguments("Native", "S")); + } + + [Fact] + public async Task NativeTypeWithOnlyConstructor_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[BlittableType] +struct Native +{ + public Native(S s) {} +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NativeTypeWithOnlyToManagedMethod_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[BlittableType] +struct Native +{ + public S ToManaged() => new S(); +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NativeTypeWithOnlyStackallocConstructor_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[BlittableType] +struct Native +{ + public Native(S s, Span buffer) {} +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(11, 1, 15, 2).WithArguments("Native")); + } + + [Fact] + public async Task TypeWithOnlyNativeStackallocConstructorAndGetPinnableReference_ReportsDiagnostics() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; + public ref byte GetPinnableReference() => ref c; +} + +struct Native +{ + public Native(S s, Span buffer) {} + + public IntPtr Value => IntPtr.Zero; +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(12, 1, 17, 2).WithArguments("Native"), + VerifyCS.Diagnostic(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule).WithSpan(5, 2, 5, 35).WithArguments("S", "Native")); + } + + [Fact] + public async Task NativeTypeWithConstructorAndSetOnlyValueProperty_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +struct Native +{ + public Native(S s) {} + + public IntPtr Value { set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(ValuePropertyMustHaveGetterRule).WithSpan(15, 5, 15, 35).WithArguments("Native")); + } + + [Fact] + public async Task NativeTypeWithToManagedAndGetOnlyValueProperty_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +struct Native +{ + public S ToManaged() => new S(); + + public IntPtr Value => IntPtr.Zero; +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(ValuePropertyMustHaveSetterRule).WithSpan(15, 5, 15, 40).WithArguments("Native")); + } + + [Fact] + public async Task BlittableNativeTypeOnMarshalUsingParameter_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +struct S +{ + public string s; +} + +[BlittableType] +struct Native +{ + private IntPtr value; + + public Native(S s) + { + value = IntPtr.Zero; + } + + public S ToManaged() => new S(); +} + + +static class Test +{ + static void Foo([MarshalUsing(typeof(Native))] S s) + {} +} +"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NonBlittableNativeTypeOnMarshalUsingParameter_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +struct S +{ + public string s; +} + +struct Native +{ + private string value; + + public Native(S s) : this() + { + } + + public S ToManaged() => new S(); +} + + +static class Test +{ + static void Foo([MarshalUsing(typeof(Native))] S s) + {} +} +"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 19, 2).WithArguments("Native", "S")); + } + + [Fact] + public async Task NonBlittableNativeTypeOnMarshalUsingReturn_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +struct S +{ + public string s; +} + +struct Native +{ + private string value; + + public Native(S s) : this() + { + } + + public S ToManaged() => new S(); +} + + +static class Test +{ + [return: MarshalUsing(typeof(Native))] + static S Foo() => new S(); +} +"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 19, 2).WithArguments("Native", "S")); + } + + [Fact] + public async Task NonBlittableNativeTypeOnMarshalUsingField_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +struct S +{ + public string s; +} + +struct Native +{ + private string value; + + public Native(S s) : this() + { + } + + public S ToManaged() => new S(); +} + + +struct Test +{ + [MarshalUsing(typeof(Native))] + S s; +} +"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 19, 2).WithArguments("Native", "S")); + } + + + [Fact] + public async Task GenericNativeTypeWithValueTypeValueProperty_DoesNotReportDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +struct Native + where T : new() +{ + public Native(T s) + { + Value = 0; + } + + public T ToManaged() => new T(); + + public int Value { get; set; } +}"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task GenericNativeTypeWithGenericMemberInstantiatedWithBlittable_DoesNotReportDiagnostic() + { + + string source = @" +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +struct S +{ + public string s; +} + +struct Native + where T : new() +{ + public Native(S s) + { + Value = new T(); + } + + public S ToManaged() => new S(); + + public T Value { get; set; } +}"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + public static IEnumerable GenericTypeWithGenericFieldMarkedBlittable_ReportsDiagnostic_TestData { + get + { + yield return new object[] + { + @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S +{ + public T t; +}" + }; + yield return new object[] + { + @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S where T : class +{ + public T t; +}" + }; + yield return new object[] + { + @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S where T : struct +{ + public T t; +}" + }; + yield return new object[] + { + @" +using System.Runtime.InteropServices; + +[BlittableType] +struct S where T : unmanaged +{ + public T t; +}" + }; + } + } + + [MemberData(nameof(GenericTypeWithGenericFieldMarkedBlittable_ReportsDiagnostic_TestData))] + [Theory] + public async Task GenericTypeWithGenericFieldMarkedBlittable_ReportsDiagnostic(string source) + { + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S")); + } + + [Fact] + public async Task ValueTypeContainingPointerBlittableType_DoesNotReportDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +unsafe struct S +{ + private int* ptr; +}"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task ValueTypeContainingPointerToNonBlittableType_ReportsDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +unsafe struct S +{ + private bool* ptr; +}"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S")); + } + + [Fact] + public async Task BlittableValueTypeContainingPointerToSelf_DoesNotReportDiagnostic() + { + + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +unsafe struct S +{ + private int fld; + private S* ptr; +}"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NonBlittableValueTypeContainingPointerToSelf_ReportsDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +unsafe struct S +{ + private bool fld; + private S* ptr; +}"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S")); + } + + [Fact] + public async Task BlittableTypeContainingFunctionPointer_DoesNotReportDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +unsafe struct S +{ + private delegate* ptr; +}"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs index a52480f22ea57..5e56b9d5aca3e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs @@ -1,10 +1,13 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Testing; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; using Xunit; namespace DllImportGenerator.Test @@ -35,26 +38,26 @@ public static void AssertPreSourceGeneratorCompilation(Compilation comp) /// Source to compile /// Output type /// The resulting compilation - public static Compilation CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) + public static async Task CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) { - var mdRefs = new List(); + var (mdRefs, ancillary) = GetReferenceAssemblies(); + + return CSharpCompilation.Create("compilation", + new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, + (await mdRefs.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)).Add(ancillary), + new CSharpCompilationOptions(outputKind)); + } + + public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() + { + // TODO: When .NET 5.0 releases, we can simplify this. + var referenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp50; // Include the assembly containing the new attribute and all of its references. // [TODO] Remove once the attribute has been added to the BCL var attrAssem = typeof(GeneratedDllImportAttribute).GetTypeInfo().Assembly; - mdRefs.Add(MetadataReference.CreateFromFile(attrAssem.Location)); - foreach (var assemName in attrAssem.GetReferencedAssemblies()) - { - var assemRef = Assembly.Load(assemName); - mdRefs.Add(MetadataReference.CreateFromFile(assemRef.Location)); - } - // Add a CoreLib reference - mdRefs.Add(MetadataReference.CreateFromFile(typeof(Binder).GetTypeInfo().Assembly.Location)); - return CSharpCompilation.Create("compilation", - new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, - mdRefs, - new CSharpCompilationOptions(outputKind)); + return (referenceAssemblies, MetadataReference.CreateFromFile(attrAssem.Location)); } /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpAnalyzerVerifier.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpAnalyzerVerifier.cs new file mode 100644 index 0000000000000..9ccff97f18b1d --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpAnalyzerVerifier.cs @@ -0,0 +1,64 @@ + +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.CSharp.Testing.XUnit; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Testing.Verifiers; + +namespace DllImportGenerator.Test.Verifiers +{ + public static class CSharpAnalyzerVerifier + where TAnalyzer : DiagnosticAnalyzer, new() + { + /// + public static DiagnosticResult Diagnostic() + => AnalyzerVerifier.Diagnostic(); + + /// + public static DiagnosticResult Diagnostic(string diagnosticId) + => AnalyzerVerifier.Diagnostic(diagnosticId); + + /// + public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) + => AnalyzerVerifier.Diagnostic(descriptor); + + /// + public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) + { + var test = new Test + { + TestCode = source, + }; + + test.ExpectedDiagnostics.AddRange(expected); + await test.RunAsync(CancellationToken.None); + } + + internal class Test : CSharpAnalyzerTest + { + public Test() + { + var (refAssem, ancillary) = TestUtils.GetReferenceAssemblies(); + ReferenceAssemblies = refAssem; + SolutionTransforms.Add((solution, projectId) => + { + var project = solution.GetProject(projectId); + var compilationOptions = project.CompilationOptions; + compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( + compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); + solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); + solution = solution.WithProjectMetadataReferences(projectId, project.MetadataReferences.Concat(ImmutableArray.Create(ancillary))); + solution = solution.WithProjectParseOptions(projectId, ((CSharpParseOptions)project.ParseOptions!).WithLanguageVersion(LanguageVersion.Preview)); + + return solution; + }); + } + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpVerifierHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpVerifierHelper.cs new file mode 100644 index 0000000000000..61c0639752703 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpVerifierHelper.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; + +namespace DllImportGenerator.Test.Verifiers +{ + internal static class CSharpVerifierHelper + { + /// + /// By default, the compiler reports diagnostics for nullable reference types at + /// , and the analyzer test framework defaults to only validating + /// diagnostics at . This map contains all compiler diagnostic IDs + /// related to nullability mapped to , which is then used to enable all + /// of these warnings for default validation during analyzer and code fix tests. + /// + internal static ImmutableDictionary NullableWarnings { get; } = GetNullableWarningsFromCompiler(); + + private static ImmutableDictionary GetNullableWarningsFromCompiler() + { + string[] args = { "/warnaserror:nullable" }; + var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory); + var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; + + // Workaround for https://github.com/dotnet/roslyn/issues/41610 + nullableWarnings = nullableWarnings + .SetItem("CS8632", ReportDiagnostic.Error) + .SetItem("CS8669", ReportDiagnostic.Error); + + return nullableWarnings; + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 8082fd111732f..e2eb6d380e83e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -43,4 +43,19 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs new file mode 100644 index 0000000000000..29860466b765f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -0,0 +1,385 @@ +using System; +using System.Collections.Immutable; +using System.Linq; +using DllImportGenerator; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +#nullable enable + +namespace Microsoft.Interop +{ + [DiagnosticAnalyzer(LanguageNames.CSharp)] + public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer + { + private const string Category = "Interoperability"; + public readonly static DiagnosticDescriptor BlittableTypeMustBeBlittableRule = + new DiagnosticDescriptor( + "INTEROPGEN001", + "BlittableTypeMustBeBlittable", + new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor CannotHaveMultipleMarshallingAttributesRule = + new DiagnosticDescriptor( + "INTEROPGEN002", + "CannotHaveMultipleMarshallingAttributes", + new LocalizableResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesDescription), Resources.ResourceManager, typeof(Resources))); + + + public readonly static DiagnosticDescriptor NativeTypeMustBeNonNullRule = + new DiagnosticDescriptor( + "INTEROPGEN003", + "NativeTypeMustBeNonNull", + new LocalizableResourceString(nameof(Resources.NativeTypeMustBeNonNullMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.NativeTypeMustBeNonNullDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor NativeTypeMustBeBlittableRule = + new DiagnosticDescriptor( + "INTEROPGEN004", + "NativeTypeMustBeBlittable", + new LocalizableResourceString(nameof(Resources.NativeTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor GetPinnableReferenceReturnTypeBlittableRule = + new DiagnosticDescriptor( + "INTEROPGEN005", + "GetPinnableReferenceReturnTypeBlittable", + new LocalizableResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor NativeTypeMustBePointerSizedRule = + new DiagnosticDescriptor( + "INTEROPGEN006", + "NativeTypeMustBePointerSized", + new LocalizableResourceString(nameof(Resources.NativeTypeMustBePointerSizedMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.NativeTypeMustBePointerSizedDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor NativeTypeMustHaveRequiredShapeRule = + new DiagnosticDescriptor( + "INTEROPGEN007", + "NativeTypeMustHaveRequiredShape", + new LocalizableResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor ValuePropertyMustHaveSetterRule = + new DiagnosticDescriptor( + "INTEROPGEN008", + "ValuePropertyMustHaveSetter", + new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveSetterMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveSetterDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor ValuePropertyMustHaveGetterRule = + new DiagnosticDescriptor( + "INTEROPGEN009", + "ValuePropertyMustHaveGetter", + new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveGetterMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveGetterDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule = + new DiagnosticDescriptor( + "INTEROPGEN010", + "GetPinnableReferenceShouldSupportAllocatingMarshallingFallback", + new LocalizableResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackDescription), Resources.ResourceManager, typeof(Resources))); + + public readonly static DiagnosticDescriptor StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule = + new DiagnosticDescriptor( + "INTEROPGEN011", + "StackallocMarshallingShouldSupportAllocatingMarshallingFallback", + new LocalizableResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackDescription), Resources.ResourceManager, typeof(Resources))); + + public override ImmutableArray SupportedDiagnostics => + ImmutableArray.Create( + BlittableTypeMustBeBlittableRule, + CannotHaveMultipleMarshallingAttributesRule, + NativeTypeMustBeNonNullRule, + NativeTypeMustBeBlittableRule, + GetPinnableReferenceReturnTypeBlittableRule, + NativeTypeMustBePointerSizedRule, + NativeTypeMustHaveRequiredShapeRule, + ValuePropertyMustHaveSetterRule, + ValuePropertyMustHaveGetterRule, + GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, + StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule); + + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + context.RegisterCompilationStartAction(PrepareForAnalysis); + } + + private void PrepareForAnalysis(CompilationStartAnalysisContext context) + { + var generatedMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute); + var blittableTypeAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute); + var nativeMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute); + var marshalUsingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute); + var spanOfByte = context.Compilation.GetTypeByMetadataName(TypeNames.System_Span)!.Construct(context.Compilation.GetSpecialType(SpecialType.System_Byte)); + + if (generatedMarshallingAttribute is not null && + blittableTypeAttribute is not null && + nativeMarshallingAttribute is not null && + marshalUsingAttribute is not null && + spanOfByte is not null) + { + var perCompilationAnalyzer = new PerCompilationAnalyzer(generatedMarshallingAttribute, blittableTypeAttribute, nativeMarshallingAttribute, marshalUsingAttribute, spanOfByte); + context.RegisterSymbolAction(context => perCompilationAnalyzer.AnalyzeTypeDefinition(context), SymbolKind.NamedType); + context.RegisterSymbolAction(context => perCompilationAnalyzer.AnalyzeElement(context), SymbolKind.Parameter, SymbolKind.Field); + context.RegisterSymbolAction(context => perCompilationAnalyzer.AnalyzeReturnType(context), SymbolKind.Method); + } + } + + class PerCompilationAnalyzer + { + private readonly INamedTypeSymbol GeneratedMarshallingAttribute; + private readonly INamedTypeSymbol BlittableTypeAttribute; + private readonly INamedTypeSymbol NativeMarshallingAttribute; + private readonly INamedTypeSymbol MarshalUsingAttribute; + private readonly ITypeSymbol SpanOfByte; + + public PerCompilationAnalyzer(INamedTypeSymbol generatedMarshallingAttribute, + INamedTypeSymbol blittableTypeAttribute, + INamedTypeSymbol nativeMarshallingAttribute, + INamedTypeSymbol marshalUsingAttribute, + INamedTypeSymbol spanOfByte) + { + GeneratedMarshallingAttribute = generatedMarshallingAttribute; + BlittableTypeAttribute = blittableTypeAttribute; + NativeMarshallingAttribute = nativeMarshallingAttribute; + MarshalUsingAttribute = marshalUsingAttribute; + SpanOfByte = spanOfByte; + } + + public void AnalyzeTypeDefinition(SymbolAnalysisContext context) + { + INamedTypeSymbol type = (INamedTypeSymbol)context.Symbol; + + AttributeData? blittableTypeAttributeData = null; + AttributeData? nativeMarshallingAttributeData = null; + foreach (var attr in type.GetAttributes()) + { + if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, GeneratedMarshallingAttribute)) + { + // If the type has the GeneratedMarshallingAttribute, + // we let the source generator handle error checking. + return; + } + else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, BlittableTypeAttribute)) + { + blittableTypeAttributeData = attr; + } + else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, NativeMarshallingAttribute)) + { + nativeMarshallingAttributeData = attr; + } + } + + if (blittableTypeAttributeData is not null && nativeMarshallingAttributeData is not null) + { + context.ReportDiagnostic(Diagnostic.Create(CannotHaveMultipleMarshallingAttributesRule, blittableTypeAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + } + else if (blittableTypeAttributeData is not null && !type.HasOnlyBlittableFields()) + { + context.ReportDiagnostic(Diagnostic.Create(BlittableTypeMustBeBlittableRule, blittableTypeAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + } + else if (nativeMarshallingAttributeData is not null) + { + AnalyzeNativeMarshalerType(context, type, nativeMarshallingAttributeData, validateGetPinnableReference: true, validateAllScenarioSupport: true); + } + } + + public void AnalyzeElement(SymbolAnalysisContext context) + { + AttributeData? attrData = context.Symbol.GetAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(MarshalUsingAttribute, attr.AttributeClass)); + if (attrData is not null) + { + if (context.Symbol is IParameterSymbol param) + { + AnalyzeNativeMarshalerType(context, param.Type, attrData, false, false); + } + else if (context.Symbol is IFieldSymbol field) + { + AnalyzeNativeMarshalerType(context, field.Type, attrData, false, false); + } + } + } + + public void AnalyzeReturnType(SymbolAnalysisContext context) + { + var method = (IMethodSymbol)context.Symbol; + AttributeData? attrData = method.GetReturnTypeAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(MarshalUsingAttribute, attr.AttributeClass)); + if (attrData is not null) + { + AnalyzeNativeMarshalerType(context, method.ReturnType, attrData, false, false); + } + } + + private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymbol type, AttributeData nativeMarshalerAttributeData, bool validateGetPinnableReference, bool validateAllScenarioSupport) + { + if (nativeMarshalerAttributeData.ConstructorArguments[0].IsNull) + { + context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustBeNonNullRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + return; + } + + ITypeSymbol nativeType = (ITypeSymbol)nativeMarshalerAttributeData.ConstructorArguments[0].Value!; + + if (!nativeType.IsValueType) + { + context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustHaveRequiredShapeRule, GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), nativeType.ToDisplayString(), type.ToDisplayString())); + return; + } + + if (nativeType is not INamedTypeSymbol marshalerType) + { + context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustHaveRequiredShapeRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), nativeType.ToDisplayString(), type.ToDisplayString())); + return; + } + + bool hasConstructor = false; + bool hasStackallocConstructor = false; + foreach (var ctor in marshalerType.Constructors) + { + if (ctor.IsStatic) + { + continue; + } + if (ctor.Parameters.Length == 1 && SymbolEqualityComparer.Default.Equals(type, ctor.Parameters[0].Type)) + { + hasConstructor = true; + } + if (ctor.Parameters.Length == 2 && SymbolEqualityComparer.Default.Equals(type, ctor.Parameters[0].Type) + && SymbolEqualityComparer.Default.Equals(SpanOfByte, ctor.Parameters[1].Type)) + { + hasStackallocConstructor = true; + } + } + + bool hasToManaged = marshalerType.GetMembers("ToManaged") + .OfType() + .Any(m => m.Parameters.IsEmpty && !m.ReturnsByRef && !m.ReturnsByRefReadonly && SymbolEqualityComparer.Default.Equals(m.ReturnType, type) && !m.IsStatic); + + // Validate that the native type has at least one marshalling method (either managed to native or native to managed) + if (!hasConstructor && !hasStackallocConstructor && !hasToManaged) + { + context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustHaveRequiredShapeRule, GetSyntaxReferenceForDiagnostic(marshalerType).GetSyntax().GetLocation(), marshalerType.ToDisplayString(), type.ToDisplayString())); + } + + // Validate that this type can support marshalling when stackalloc is not usable. + if (validateAllScenarioSupport && hasStackallocConstructor && !hasConstructor) + { + context.ReportDiagnostic(Diagnostic.Create(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, GetSyntaxReferenceForDiagnostic(marshalerType).GetSyntax().GetLocation(), marshalerType.ToDisplayString())); + } + + IPropertySymbol? valueProperty = nativeType.GetMembers("Value").OfType().FirstOrDefault(); + if (valueProperty is not null) + { + nativeType = valueProperty.Type; + + // Validate that we don't have partial implementations. + // We error if either of the conditions below are partially met but not fully met: + // - a constructor and a Value property getter + // - a ToManaged method and a Value property setter + if ((hasConstructor || hasStackallocConstructor) && valueProperty.GetMethod is null) + { + context.ReportDiagnostic(Diagnostic.Create(ValuePropertyMustHaveGetterRule, GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation(), marshalerType.ToDisplayString())); + } + if (hasToManaged && valueProperty.SetMethod is null) + { + context.ReportDiagnostic(Diagnostic.Create(ValuePropertyMustHaveSetterRule, GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation(), marshalerType.ToDisplayString())); + } + } + + if (!nativeType.IsConsideredBlittable()) + { + context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustBeBlittableRule, + valueProperty is not null + ? GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation() + : GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), + nativeType.ToDisplayString(), + type.ToDisplayString())); + } + + IMethodSymbol? getPinnableReferenceMethod = type.GetMembers("GetPinnableReference") + .OfType() + .FirstOrDefault(m => m is { Parameters: { Length: 0 } } and ({ ReturnsByRef: true } or { ReturnsByRefReadonly: true })); + if (validateGetPinnableReference && getPinnableReferenceMethod is not null) + { + if (!getPinnableReferenceMethod.ReturnType.IsConsideredBlittable()) + { + context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceReturnTypeBlittableRule, getPinnableReferenceMethod.DeclaringSyntaxReferences[0].GetSyntax().GetLocation())); + } + // Validate that the Value property is a pointer-sized primitive type. + if (valueProperty is null || + valueProperty.Type is not ( + IPointerTypeSymbol _ or + { SpecialType: SpecialType.System_IntPtr } or + { SpecialType: SpecialType.System_UIntPtr })) + { + context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustBePointerSizedRule, + valueProperty is not null + ? GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation() + : GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), + nativeType.ToDisplayString(), + type.ToDisplayString())); + } + + // Validate that our marshaler supports scenarios where GetPinnableReference cannot be used. + if (validateAllScenarioSupport && (!hasConstructor || valueProperty is { GetMethod: null })) + { + context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + } + } + + SyntaxReference GetSyntaxReferenceForDiagnostic(ISymbol targetSymbol) + { + if (targetSymbol.DeclaringSyntaxReferences.IsEmpty) + { + return nativeMarshalerAttributeData.ApplicationSyntaxReference!; + } + else + { + return targetSymbol.DeclaringSyntaxReferences[0]; + } + } + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs new file mode 100644 index 0000000000000..6b20376d3b5d8 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -0,0 +1,261 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DllImportGenerator { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DllImportGenerator.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to A type marked with 'BlittableTypeAttribute' must be blittable.. + /// + internal static string BlittableTypeMustBeBlittableDescription { + get { + return ResourceManager.GetString("BlittableTypeMustBeBlittableDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type '{0}' is marked with 'BlittableTypeAttribute' but is not blittable.. + /// + internal static string BlittableTypeMustBeBlittableMessage { + get { + return ResourceManager.GetString("BlittableTypeMustBeBlittableMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'BlittableTypeAttribute' and 'NativeMarshallingAttributes' are mutually exclusive.. + /// + internal static string CannotHaveMultipleMarshallingAttributesDescription { + get { + return ResourceManager.GetString("CannotHaveMultipleMarshallingAttributesDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes.. + /// + internal static string CannotHaveMultipleMarshallingAttributesMessage { + get { + return ResourceManager.GetString("CannotHaveMultipleMarshallingAttributesMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The return type of 'GetPinnableReference' (after accounting for 'ref') must be blittable.. + /// + internal static string GetPinnableReferenceReturnTypeBlittableDescription { + get { + return ResourceManager.GetString("GetPinnableReferenceReturnTypeBlittableDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The dereferenced type of the return type of the 'GetPinnableReference' method must be blittable.. + /// + internal static string GetPinnableReferenceReturnTypeBlittableMessage { + get { + return ResourceManager.GetString("GetPinnableReferenceReturnTypeBlittableMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A type that supports marshalling from managed to native by pinning should also support marshalling from managed to native where pinning is impossible.. + /// + internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackDescription { + get { + return ResourceManager.GetString("GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible.. + /// + internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage { + get { + return ResourceManager.GetString("GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A native type for a given type must be blittable.. + /// + internal static string NativeTypeMustBeBlittableDescription { + get { + return ResourceManager.GetString("NativeTypeMustBeBlittableDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' for the type '{1}' is not blittable.. + /// + internal static string NativeTypeMustBeBlittableMessage { + get { + return ResourceManager.GetString("NativeTypeMustBeBlittableMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A native type for a given type must be non-null.. + /// + internal static string NativeTypeMustBeNonNullDescription { + get { + return ResourceManager.GetString("NativeTypeMustBeNonNullDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type for the type '{0}' is null.. + /// + internal static string NativeTypeMustBeNonNullMessage { + get { + return ResourceManager.GetString("NativeTypeMustBeNonNullMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type must be pointer sized so we can cast the pinned result of 'GetPinnableReference' to the native type.. + /// + internal static string NativeTypeMustBePointerSizedDescription { + get { + return ResourceManager.GetString("NativeTypeMustBePointerSizedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference" method.. + /// + internal static string NativeTypeMustBePointerSizedMessage { + get { + return ResourceManager.GetString("NativeTypeMustBePointerSizedMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type must have at least one of the two marshalling methods to enable marshalling the managed type.. + /// + internal static string NativeTypeMustHaveRequiredShapeDescription { + get { + return ResourceManager.GetString("NativeTypeMustHaveRequiredShapeDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}'.. + /// + internal static string NativeTypeMustHaveRequiredShapeMessage { + get { + return ResourceManager.GetString("NativeTypeMustHaveRequiredShapeMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A type that supports marshalling from managed to native by stack allocation should also support marshalling from managed to native where stack allocation is impossible.. + /// + internal static string StackallocMarshallingShouldSupportAllocatingMarshallingFallbackDescription { + get { + return ResourceManager.GetString("StackallocMarshallingShouldSupportAllocatingMarshallingFallbackDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Native type '{0}' has a stack-allocating constructor does not support marshalling in scenarios where stack allocation is impossible.. + /// + internal static string StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage { + get { + return ResourceManager.GetString("StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type's 'Value' property must have a getter to support marshalling from managed to native.. + /// + internal static string ValuePropertyMustHaveGetterDescription { + get { + return ResourceManager.GetString("ValuePropertyMustHaveGetterDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a getter.. + /// + internal static string ValuePropertyMustHaveGetterMessage { + get { + return ResourceManager.GetString("ValuePropertyMustHaveGetterMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type's 'Value' property must have a setter to support marshalling from native to managed.. + /// + internal static string ValuePropertyMustHaveSetterDescription { + get { + return ResourceManager.GetString("ValuePropertyMustHaveSetterDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a setter.. + /// + internal static string ValuePropertyMustHaveSetterMessage { + get { + return ResourceManager.GetString("ValuePropertyMustHaveSetterMessage", resourceCulture); + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx new file mode 100644 index 0000000000000..0f0e30a357f9d --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + A type marked with 'BlittableTypeAttribute' must be blittable. + + + Type '{0}' is marked with 'BlittableTypeAttribute' but is not blittable. + + + The 'BlittableTypeAttribute' and 'NativeMarshallingAttributes' are mutually exclusive. + + + Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes. + + + The return type of 'GetPinnableReference' (after accounting for 'ref') must be blittable. + + + The dereferenced type of the return type of the 'GetPinnableReference' method must be blittable. + + + A type that supports marshalling from managed to native by pinning should also support marshalling from managed to native where pinning is impossible. + + + Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible. + + + A native type for a given type must be blittable. + + + The native type '{0}' for the type '{1}' is not blittable. + + + A native type for a given type must be non-null. + + + The native type for the type '{0}' is null. + + + The native type must be pointer sized so the pinned result of 'GetPinnableReference' can be cast to the native type. + + + The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference' method. + + + The native type must have at least one of the two marshalling methods to enable marshalling the managed type. + + + The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}'. + + + A type that supports marshalling from managed to native by stack allocation should also support marshalling from managed to native where stack allocation is impossible. + + + Native type '{0}' has a stack-allocating constructor does not support marshalling in scenarios where stack allocation is impossible. + + + The native type's 'Value' property must have a getter to support marshalling from managed to native. + + + The 'Value' property on the native type '{0}' must have a getter. + + + The native type's 'Value' property must have a setter to support marshalling from native to managed. + + + The 'Value' property on the native type '{0}' must have a setter. + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs new file mode 100644 index 0000000000000..2faec2ee43a4b --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace DllImportGenerator +{ + static class TypeNames + { + public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute"; + + public const string BlittableTypeAttribute = "System.Runtime.InteropServices.BlittableTypeAttribute"; + + public const string NativeMarshallingAttribute = "System.Runtime.InteropServices.NativeMarshallingAttribute"; + + public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute"; + + public const string System_Span = "System.Span`1"; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs new file mode 100644 index 0000000000000..1acefc8c6d773 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -0,0 +1,103 @@ +using Microsoft.CodeAnalysis; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; + +#nullable enable + +namespace Microsoft.Interop +{ + static class TypeSymbolExtensions + { + public static bool HasOnlyBlittableFields(this ITypeSymbol type) + { + if (!type.IsUnmanagedType || !type.IsValueType) + { + return false; + } + + foreach (var field in type.GetMembers().OfType()) + { + bool? fieldBlittable = field switch + { + { IsStatic : true } => null, + { Type : { IsValueType : false }} => false, + { Type : IPointerTypeSymbol ptr } => IsConsideredBlittable(ptr.PointedAtType), + { Type : IFunctionPointerTypeSymbol } => true, + not { Type : { SpecialType : SpecialType.None }} => IsSpecialTypeBlittable(field.Type.SpecialType), + // A recursive struct type isn't blittable. + // It's also illegal in C#, but I believe that source generators run + // before that is detected, so we check here to avoid a stack overflow. + // [TODO]: Handle mutual recursion. + _ => !SymbolEqualityComparer.Default.Equals(field.Type, type) && IsConsideredBlittable(field.Type) + }; + + if (fieldBlittable is false) + { + return false; + } + } + + return true; + } + + private static bool IsSpecialTypeBlittable(SpecialType specialType) + => specialType switch + { + SpecialType.System_SByte + or SpecialType.System_Byte + or SpecialType.System_Int16 + or SpecialType.System_UInt16 + or SpecialType.System_Int32 + or SpecialType.System_UInt32 + or SpecialType.System_Int64 + or SpecialType.System_UInt64 + or SpecialType.System_Single + or SpecialType.System_Double + or SpecialType.System_IntPtr + or SpecialType.System_UIntPtr => true, + _ => false + }; + + public static bool IsConsideredBlittable(this ITypeSymbol type) + { + if (type.SpecialType != SpecialType.None) + { + return IsSpecialTypeBlittable(type.SpecialType); + } + bool hasNativeMarshallingAttribute = false; + bool hasGeneratedMarshallingAttribute = false; + // [TODO]: Match attributes on full name or symbol, not just on type name. + foreach (var attr in type.GetAttributes()) + { + if (attr.AttributeClass is null) + { + continue; + } + if (attr.AttributeClass.Name == "BlittableTypeAttribute") + { + return true; + } + else if (attr.AttributeClass.Name == "GeneratedMarshallingAttribute") + { + hasGeneratedMarshallingAttribute = true; + } + else if (attr.AttributeClass.Name == "NativeMarshallingAttribute") + { + hasNativeMarshallingAttribute = true; + } + } + + if (hasGeneratedMarshallingAttribute && !hasNativeMarshallingAttribute) + { + // The struct type has generated marshalling via a source generator. + // We can't guarantee that we can see the results of the struct source generator, + // so we re-calculate if the type is blittable here. + return type.HasOnlyBlittableFields(); + } + return false; + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs new file mode 100644 index 0000000000000..a483c22c19159 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs @@ -0,0 +1,36 @@ +#nullable enable + +namespace System.Runtime.InteropServices +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + class GeneratedMarshallingAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Struct)] + public class BlittableTypeAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] + public class NativeMarshallingAttribute : Attribute + { + public NativeMarshallingAttribute(Type nativeType) + { + NativeType = nativeType; + } + + public Type NativeType { get; } + } + + [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field)] + public class MarshalUsingAttribute : Attribute + { + public MarshalUsingAttribute(Type nativeType) + { + NativeType = nativeType; + } + + public Type NativeType { get; } + } +} \ No newline at end of file From 11047118a55e4ce58b0f50fd473f337bc76c6dad Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 3 Sep 2020 15:58:08 -0700 Subject: [PATCH 012/161] Implement infra to support marshalling blittable generics (equivalent to .NET 5 support) (dotnet/runtimelab#80) Commit migrated from https://github.com/dotnet/runtimelab/commit/91b131e8d9340e8591d258793dd142e7c2e7a011 --- .../ManualTypeMarshallingAnalyzerTests.cs | 196 ++++++++++++------ .../ManualTypeMarshallingAnalyzer.cs | 34 ++- .../DllImportGenerator/Resources.Designer.cs | 6 +- .../gen/DllImportGenerator/Resources.resx | 4 +- .../gen/DllImportGenerator/TypeNames.cs | 2 + .../TypeSymbolExtensions.cs | 39 +++- .../DllImportGenerator/StructMarshalling.md | 12 +- 7 files changed, 214 insertions(+), 79 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs index 414a4bcd09186..b4ddfcb874aed 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs @@ -140,7 +140,6 @@ struct T } "; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S"), VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(10, 2, 10, 15).WithArguments("T")); } @@ -243,7 +242,7 @@ public Native(S s) public S ToManaged() => new S(); }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(11, 1, 20, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(11, 1, 20, 2).WithArguments("Native", "S")); } [Fact] @@ -837,64 +836,6 @@ public Native(S s) }"; await VerifyCS.VerifyAnalyzerAsync(source); } - - public static IEnumerable GenericTypeWithGenericFieldMarkedBlittable_ReportsDiagnostic_TestData { - get - { - yield return new object[] - { - @" -using System.Runtime.InteropServices; - -[BlittableType] -struct S -{ - public T t; -}" - }; - yield return new object[] - { - @" -using System.Runtime.InteropServices; - -[BlittableType] -struct S where T : class -{ - public T t; -}" - }; - yield return new object[] - { - @" -using System.Runtime.InteropServices; - -[BlittableType] -struct S where T : struct -{ - public T t; -}" - }; - yield return new object[] - { - @" -using System.Runtime.InteropServices; - -[BlittableType] -struct S where T : unmanaged -{ - public T t; -}" - }; - } - } - - [MemberData(nameof(GenericTypeWithGenericFieldMarkedBlittable_ReportsDiagnostic_TestData))] - [Theory] - public async Task GenericTypeWithGenericFieldMarkedBlittable_ReportsDiagnostic(string source) - { - await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S")); - } [Fact] public async Task ValueTypeContainingPointerBlittableType_DoesNotReportDiagnostic() @@ -967,6 +908,141 @@ public async Task BlittableTypeContainingFunctionPointer_DoesNotReportDiagnostic unsafe struct S { private delegate* ptr; +}"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task BlittableGenericTypeInBlittableType_DoesNotReportDiagnostic() + { + + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct G +{ + T fld; +} + +[BlittableType] +unsafe struct S +{ + private G field; +}"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NonBlittableGenericTypeInBlittableType_ReportsDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct G +{ + T fld; +} + +[BlittableType] +unsafe struct S +{ + private G field; +}"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(10, 2, 10, 15).WithArguments("S")); + } + + [Fact] + public async Task BlittableGenericTypeTypeParameterReferenceType_ReportsDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct G where T : class +{ + T fld; +}"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("G")); + } + + [Fact] + public async Task BlittableGenericTypeContainingGenericType_DoesNotReportDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct G +{ + T fld; +} + +[BlittableType] +struct F +{ + G fld; +} +"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task BlittableNestedGenericType_DoesNotReportDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +struct C +{ + [BlittableType] + public struct G + { + T fld; + } +} + +[BlittableType] +struct S +{ + C.G g; +} +"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task BlittableNestedGenericTypeWithReferenceTypeGenericParameter_DoesNotReportDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +struct C where T : class +{ + [BlittableType] + struct G + { + T fld; + } +} +"; + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(6, 6, 6, 19).WithArguments("C.G")); + } + + [Fact] + public async Task BlittableGenericTypeWithReferenceTypeParameterNotUsedInFieldType_DoesNotReportDiagnostic() + { + var source = @" +using System.Runtime.InteropServices; + +[BlittableType] +struct G where U : class +{ + T fld; }"; await VerifyCS.VerifyAnalyzerAsync(source); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs index 29860466b765f..71e7a71afedcf 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -12,7 +12,7 @@ namespace Microsoft.Interop [DiagnosticAnalyzer(LanguageNames.CSharp)] public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer { - private const string Category = "Interoperability"; + private const string Category = "Usage"; public readonly static DiagnosticDescriptor BlittableTypeMustBeBlittableRule = new DiagnosticDescriptor( "INTEROPGEN001", @@ -159,7 +159,13 @@ nativeMarshallingAttribute is not null && marshalUsingAttribute is not null && spanOfByte is not null) { - var perCompilationAnalyzer = new PerCompilationAnalyzer(generatedMarshallingAttribute, blittableTypeAttribute, nativeMarshallingAttribute, marshalUsingAttribute, spanOfByte); + var perCompilationAnalyzer = new PerCompilationAnalyzer( + generatedMarshallingAttribute, + blittableTypeAttribute, + nativeMarshallingAttribute, + marshalUsingAttribute, + spanOfByte, + context.Compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_StructLayoutAttribute)!); context.RegisterSymbolAction(context => perCompilationAnalyzer.AnalyzeTypeDefinition(context), SymbolKind.NamedType); context.RegisterSymbolAction(context => perCompilationAnalyzer.AnalyzeElement(context), SymbolKind.Parameter, SymbolKind.Field); context.RegisterSymbolAction(context => perCompilationAnalyzer.AnalyzeReturnType(context), SymbolKind.Method); @@ -172,19 +178,22 @@ class PerCompilationAnalyzer private readonly INamedTypeSymbol BlittableTypeAttribute; private readonly INamedTypeSymbol NativeMarshallingAttribute; private readonly INamedTypeSymbol MarshalUsingAttribute; - private readonly ITypeSymbol SpanOfByte; + private readonly INamedTypeSymbol SpanOfByte; + private readonly INamedTypeSymbol StructLayoutAttribute; public PerCompilationAnalyzer(INamedTypeSymbol generatedMarshallingAttribute, INamedTypeSymbol blittableTypeAttribute, INamedTypeSymbol nativeMarshallingAttribute, INamedTypeSymbol marshalUsingAttribute, - INamedTypeSymbol spanOfByte) + INamedTypeSymbol spanOfByte, + INamedTypeSymbol structLayoutAttribute) { GeneratedMarshallingAttribute = generatedMarshallingAttribute; BlittableTypeAttribute = blittableTypeAttribute; NativeMarshallingAttribute = nativeMarshallingAttribute; MarshalUsingAttribute = marshalUsingAttribute; SpanOfByte = spanOfByte; + StructLayoutAttribute = structLayoutAttribute; } public void AnalyzeTypeDefinition(SymbolAnalysisContext context) @@ -211,11 +220,11 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) } } - if (blittableTypeAttributeData is not null && nativeMarshallingAttributeData is not null) + if (HasMultipleMarshallingAttributes(blittableTypeAttributeData, nativeMarshallingAttributeData)) { - context.ReportDiagnostic(Diagnostic.Create(CannotHaveMultipleMarshallingAttributesRule, blittableTypeAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + context.ReportDiagnostic(Diagnostic.Create(CannotHaveMultipleMarshallingAttributesRule, blittableTypeAttributeData!.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); } - else if (blittableTypeAttributeData is not null && !type.HasOnlyBlittableFields()) + else if (blittableTypeAttributeData is not null && (!type.HasOnlyBlittableFields() || type.IsAutoLayout(StructLayoutAttribute))) { context.ReportDiagnostic(Diagnostic.Create(BlittableTypeMustBeBlittableRule, blittableTypeAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); } @@ -225,6 +234,17 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) } } + private bool HasMultipleMarshallingAttributes(AttributeData? blittableTypeAttributeData, AttributeData? nativeMarshallingAttributeData) + { + return (blittableTypeAttributeData, nativeMarshallingAttributeData) switch + { + (null, null) => false, + (not null, null) => false, + (null, not null) => false, + _ => true + }; + } + public void AnalyzeElement(SymbolAnalysisContext context) { AttributeData? attrData = context.Symbol.GetAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(MarshalUsingAttribute, attr.AttributeClass)); 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 6b20376d3b5d8..57a4b44d93afc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -79,7 +79,7 @@ internal static string BlittableTypeMustBeBlittableMessage { } /// - /// Looks up a localized string similar to The 'BlittableTypeAttribute' and 'NativeMarshallingAttributes' are mutually exclusive.. + /// Looks up a localized string similar to The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive.. /// internal static string CannotHaveMultipleMarshallingAttributesDescription { get { @@ -169,7 +169,7 @@ internal static string NativeTypeMustBeNonNullMessage { } /// - /// Looks up a localized string similar to The native type must be pointer sized so we can cast the pinned result of 'GetPinnableReference' to the native type.. + /// Looks up a localized string similar to The native type must be pointer sized so the pinned result of 'GetPinnableReference' can be cast to the native type.. /// internal static string NativeTypeMustBePointerSizedDescription { get { @@ -178,7 +178,7 @@ internal static string NativeTypeMustBePointerSizedDescription { } /// - /// Looks up a localized string similar to The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference" method.. + /// Looks up a localized string similar to The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference' method.. /// internal static string NativeTypeMustBePointerSizedMessage { get { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 0f0e30a357f9d..836175ad06b9d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -124,7 +124,7 @@ Type '{0}' is marked with 'BlittableTypeAttribute' but is not blittable. - The 'BlittableTypeAttribute' and 'NativeMarshallingAttributes' are mutually exclusive. + The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive. Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes. @@ -183,4 +183,4 @@ The 'Value' property on the native type '{0}' must have a setter. - + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 2faec2ee43a4b..37f10eab3c795 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -15,5 +15,7 @@ static class TypeNames public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute"; public const string System_Span = "System.Span`1"; + + public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 1acefc8c6d773..3145c3aec4fbf 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -1,6 +1,7 @@ using Microsoft.CodeAnalysis; using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; @@ -13,20 +14,19 @@ static class TypeSymbolExtensions { public static bool HasOnlyBlittableFields(this ITypeSymbol type) { - if (!type.IsUnmanagedType || !type.IsValueType) - { - return false; - } - foreach (var field in type.GetMembers().OfType()) { bool? fieldBlittable = field switch { { IsStatic : true } => null, - { Type : { IsValueType : false }} => false, + { Type : { IsReferenceType : true }} => false, { Type : IPointerTypeSymbol ptr } => IsConsideredBlittable(ptr.PointedAtType), { Type : IFunctionPointerTypeSymbol } => true, not { Type : { SpecialType : SpecialType.None }} => IsSpecialTypeBlittable(field.Type.SpecialType), + // Assume that type parameters that can be blittable are blittable. + // We'll re-evaluate blittability for generic fields of generic types at instantation time. + { Type : ITypeParameterSymbol } => true, + { Type : { IsValueType : false }} => false, // A recursive struct type isn't blittable. // It's also illegal in C#, but I believe that source generators run // before that is detected, so we check here to avoid a stack overflow. @@ -67,6 +67,12 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) { return IsSpecialTypeBlittable(type.SpecialType); } + + if (!type.IsValueType || type.IsReferenceType) + { + return false; + } + bool hasNativeMarshallingAttribute = false; bool hasGeneratedMarshallingAttribute = false; // [TODO]: Match attributes on full name or symbol, not just on type name. @@ -78,6 +84,15 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) } if (attr.AttributeClass.Name == "BlittableTypeAttribute") { + if (type is INamedTypeSymbol { IsGenericType: true } generic) + { + // If the type is generic, we inspect the fields again + // to determine blittability of this instantiation + // since we are guaranteed that if a type has generic fields, + // they will be present in the contract assembly to ensure + // that recursive structs can be identified at build time. + return generic.HasOnlyBlittableFields(); + } return true; } else if (attr.AttributeClass.Name == "GeneratedMarshallingAttribute") @@ -99,5 +114,17 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) } return false; } + + public static bool IsAutoLayout(this INamedTypeSymbol type, ITypeSymbol structLayoutAttributeType) + { + foreach (var attr in type.GetAttributes()) + { + if (SymbolEqualityComparer.Default.Equals(structLayoutAttributeType, attr.AttributeClass)) + { + return (LayoutKind)(int)attr.ConstructorArguments[0].Value! == LayoutKind.Auto; + } + } + return type.IsReferenceType; + } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md index efefd426a96d1..bd7c3bd90f32f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md @@ -40,7 +40,6 @@ public class MarshalUsingAttribute : Attribute { public MarshalUsingAttribute(Type nativeType) {} } - ``` The `NativeMarshallingAttribute` and `MarshalUsingAttribute` attributes would require that the provided native type `TNative` is a blittable `struct` and has a subset of three methods with the following names and shapes (with the managed type named TManaged): @@ -180,6 +179,17 @@ When the source generator (either Struct, P/Invoke, Reverse P/Invoke, etc.) enco If someone actively disables the analyzer or writes their types in IL, then they have stepped out of the supported scenarios and marshalling code generated for their types may be inaccurate. +#### Exception: Generics + +Because the Roslyn compiler needs to be able to validate that there are not recursive struct definitions, reference assemblies have to contain a field of a type parameter type in the reference assembly if they do in the runtime assembly. As a result, we can inspect private generic fields reliably. + +To enable blittable generics support in this struct marshalling model, we extend `[BlittableType]` as follows: + +- In a generic type definition, we consider all type parameters that can be value types as blittable for the purposes of validating that `[BlittableType]` is only applied to blittable types. +- When the source generator discovers a generic type marked with `[BlittableType]` it will look through the fields on the type and validate that they are blittable. + +Since all fields typed with non-parameterized types are validated to be blittable at type definition time, we know that they are all blittable at type usage time. So, we only need to validate that the generic fields are instantiated with blittable types. + ### Special case: Transparent Structures There has been discussion about Transparent Structures, structure types that are treated as their underlying types when passed to native code. The support for a `Value` property on a generated marshalling type supports the transparent struct support. For example, we could support strongly typed `HRESULT` returns with this model as shown below: From 547a0d1933a97171bda157792a74413b957683cd Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Fri, 11 Sep 2020 15:11:02 -0700 Subject: [PATCH 013/161] Update docs to include convention (dotnet/runtimelab#93) Commit migrated from https://github.com/dotnet/runtimelab/commit/4eaa5d8c47ed31d59d0d806b14ce532a569dd4de --- CreateAnExperiment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CreateAnExperiment.md b/CreateAnExperiment.md index 5fd8eee24ceb3..39b089c7deee7 100644 --- a/CreateAnExperiment.md +++ b/CreateAnExperiment.md @@ -4,11 +4,11 @@ Experiments should be contained within a branch in the dotnet/runtimelab reposit ## Steps to setup a new experiment -- Pick a good name for your experiment and create branch for it in dotnet/runtimelab. +- Pick a good name for your experiment and create branch for it in dotnet/runtimelab. Branch names should be prefixed with `feature/` in order to have official build support. - If the experiment is expected to require changes of .NET runtime itself, it should be branched off of [dotnet/runtimelab:runtime-master](https://github.com/dotnet/runtimelab/tree/runtime-master) that is a manually maitained mirror of [dotnet/runtime:master](https://github.com/dotnet/runtime/tree/master). - Otherwise, the experiment should be branched off of [dotnet/runtimelab:master](https://github.com/dotnet/runtimelab/tree/master) to get the required boilerplate such as LICENSE.TXT. - Submit a PR to update the [README.MD](https://github.com/dotnet/runtimelab/blob/master/README.md#active-experimental-projects) with the name of your branch and a brief description of the experiment. Example: [#19](https://github.com/dotnet/runtimelab/pull/19/files) - Create label `area-` for tagging issues. The label should use color `#d4c5f9`. - If your experiment is branched from dotnet/runtime: - Enable CI builds by editing `eng/pipelines/runtimelab.yml` in your branch. Example: [#25](https://github.com/dotnet/runtimelab/pull/25/files) - - To avoid spurious github notifications for merges from upstream, delete `.github/CODEOWNERS` from your branch or replace it with setting specific to your experiment. Example: [#26](https://github.com/dotnet/runtimelab/pull/26/files) \ No newline at end of file + - To avoid spurious github notifications for merges from upstream, delete `.github/CODEOWNERS` from your branch or replace it with setting specific to your experiment. Example: [#26](https://github.com/dotnet/runtimelab/pull/26/files) From 6c25cca0a1e120e901e1b38d6716d9134cfef2e7 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 15 Sep 2020 22:09:00 -0700 Subject: [PATCH 014/161] Basic structure for composing stub code (dotnet/runtimelab#87) Commit migrated from https://github.com/dotnet/runtimelab/commit/e787027eafb2c40607fc46db586b7c0071c3d8ab --- .../DllImportGenerator.Test/CodeSnippets.cs | 108 +++++++-- .../gen/DllImportGenerator.Test/Compiles.cs | 68 +++++- .../gen/DllImportGenerator.Test/TestUtils.cs | 7 +- .../DllImportGenerator/DllImportGenerator.cs | 95 +++----- .../DllImportGenerator.csproj | 4 +- .../gen/DllImportGenerator/DllImportStub.cs | 122 +++++----- .../Marshalling/BoolMarshaller.cs | 105 +++++++++ .../Marshalling/Forwarder.cs | 34 +++ .../Marshalling/MarshallingGenerator.cs | 93 ++++++++ .../Marshalling/NumericMarshaller.cs | 78 +++++++ .../gen/DllImportGenerator/StubCodeContext.cs | 110 +++++++++ .../DllImportGenerator/StubCodeGenerator.cs | 210 ++++++++++++++++++ .../DllImportGenerator/TypePositionInfo.cs | 122 +++------- .../TypeSymbolExtensions.cs | 21 +- .../libraries/DllImportGenerator/Pipeline.md | 49 ++++ 15 files changed, 964 insertions(+), 262 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NumericMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs index b69856e490642..00d0ea39d94ef 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Metadata; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.InteropServices; namespace DllImportGenerator.Test { @@ -197,22 +192,6 @@ partial class Test ThrowOnUnmappableChar = !IsTrue)] public static partial void Method(); } -"; - - /// - /// Declaration with basic parameters. - /// - public static readonly string BasicParametersAndModifiers = @" -using System; -using System.Runtime.InteropServices; -partial class Test -{ - [GeneratedDllImport(""DoesNotExist"")] - public static partial void Method1(string s, IntPtr i, UIntPtr u); - - [GeneratedDllImport(""DoesNotExist"")] - public static partial void Method2(in string s, ref IntPtr i, out UIntPtr u); -} "; /// @@ -301,5 +280,90 @@ partial class Test public static partial void Method3(); } "; + + /// + /// Declaration with parameters. + /// + public static string BasicParametersAndModifiers(string typeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial {typeName} Method( + {typeName} p, + in {typeName} pIn, + ref {typeName} pRef, + out {typeName} pOut); +}}"; + + public static string BasicParametersAndModifiers() => BasicParametersAndModifiers(typeof(T).ToString()); + + /// + /// Declaration with parameters with MarshalAs. + /// + public static string MarshalAsParametersAndModifiers(string typeName, UnmanagedType unmanagedType) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.{unmanagedType})] + public static partial {typeName} Method( + [MarshalAs(UnmanagedType.{unmanagedType})] {typeName} p, + [MarshalAs(UnmanagedType.{unmanagedType})] in {typeName} pIn, + [MarshalAs(UnmanagedType.{unmanagedType})] ref {typeName} pRef, + [MarshalAs(UnmanagedType.{unmanagedType})] out {typeName} pOut); +}} +"; + + public static string MarshalAsParametersAndModifiers(UnmanagedType unmanagedType) => MarshalAsParametersAndModifiers(typeof(T).ToString(), unmanagedType); + + /// + /// Declaration with enum parameters. + /// + public static string EnumParameters => @$" +using System.Runtime.InteropServices; +using NS; + +namespace NS +{{ + enum MyEnum {{ A, B, C }} +}} + +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial MyEnum Method( + MyEnum p, + in MyEnum pIn, + ref MyEnum pRef, + out MyEnum pOut); +}}"; + + /// + /// Declaration with PreserveSig = false. + /// + public static string PreserveSigFalse(string typeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"", PreserveSig = false)] + public static partial {typeName} Method1(); + + [GeneratedDllImport(""DoesNotExist"", PreserveSig = false)] + public static partial {typeName} Method2({typeName} p); +}}"; + + public static string PreserveSigFalse() => PreserveSigFalse(typeof(T).ToString()); + + /// + /// Declaration with PreserveSig = false and void return. + /// + public static readonly string PreserveSigFalseVoidReturn = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"", PreserveSig = false)] + public static partial void Method(); +}}"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index 9e0fda1aab002..1ecd120dbf7e1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -1,5 +1,7 @@ using Microsoft.CodeAnalysis; +using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Xunit; @@ -16,10 +18,74 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.NestedTypes }; yield return new[] { CodeSnippets.UserDefinedEntryPoint }; yield return new[] { CodeSnippets.AllDllImportNamedArguments }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers }; yield return new[] { CodeSnippets.DefaultParameters }; yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.VariantBool) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; + yield return new[] { CodeSnippets.EnumParameters }; + yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs index 5e56b9d5aca3e..1b374e257e1e3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs @@ -37,15 +37,16 @@ public static void AssertPreSourceGeneratorCompilation(Compilation comp) /// /// Source to compile /// Output type + /// Whether or not use of the unsafe keyword should be allowed /// The resulting compilation - public static async Task CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) + public static async Task CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true) { var (mdRefs, ancillary) = GetReferenceAssemblies(); - + return CSharpCompilation.Create("compilation", new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, (await mdRefs.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)).Add(ancillary), - new CSharpCompilationOptions(outputKind)); + new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); } public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 35bca6a05fa6f..d81eb6ea8d3d3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -5,10 +5,12 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { @@ -53,7 +55,7 @@ public void Execute(SourceGeneratorContext context) Debug.Assert(!(dllImportAttr is null) && !(dllImportData is null)); // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData, context.CancellationToken); + var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData, context.Compilation, context.CancellationToken); // Report any diagnostics from the stub generation step. foreach (var diag in dllImportStub.Diagnostics) @@ -79,83 +81,42 @@ private void PrintGeneratedSource( DllImportStub stub, AttributeSyntax dllImportAttr) { - const string SingleDepth = " "; - var currentIndent = string.Empty; - - // Declare namespace - if (!(stub.StubTypeNamespace is null)) - { - builder.AppendLine($@"namespace {stub.StubTypeNamespace} -{{"); - currentIndent += SingleDepth; - } - - // Print type declarations - var typeIndentStack = new Stack(); - foreach (var typeDecl in stub.StubContainingTypesDecl) - { - builder.AppendLine($@"{currentIndent}{typeDecl} -{currentIndent}{{"); - - typeIndentStack.Push(currentIndent); - currentIndent += SingleDepth; - } - - // Begin declare function - builder.Append( -$@"{currentIndent}{userDeclaredMethod.Modifiers} {stub.StubReturnType} {userDeclaredMethod.Identifier}("); - - char delim = ' '; - foreach (var param in stub.StubParameters) - { - builder.Append($"{delim}{param.Type} {param.Name}"); - delim = ','; - } + // Create stub function + var stubMethod = MethodDeclaration(stub.StubReturnType, userDeclaredMethod.Identifier) + .WithModifiers(userDeclaredMethod.Modifiers) + .WithParameterList(ParameterList(SeparatedList(stub.StubParameters))) + .WithBody(stub.StubCode); - // End declare function - builder.AppendLine( -$@") -{currentIndent}{{"); - - // Insert lines into function - foreach (var line in stub.StubCode) - { - builder.AppendLine($@"{currentIndent}{SingleDepth}{line}"); - } + // Create the DllImport declaration. + // [TODO] Don't include PreserveSig=false once that is handled by the generated stub + var dllImport = stub.DllImportDeclaration.AddAttributeLists( + AttributeList( + SingletonSeparatedList(dllImportAttr))); - builder.AppendLine( -$@"{ currentIndent}}} + // Stub should have at least one containing type + Debug.Assert(stub.StubContainingTypes.Any()); -{currentIndent}[{dllImportAttr}]"); + // Add stub function and DllImport declaration to the first (innermost) containing + MemberDeclarationSyntax containingType = stub.StubContainingTypes.First() + .AddMembers(stubMethod, dllImport); - // Create the DllImport declaration. - builder.Append($"{currentIndent}extern private static {stub.DllImportReturnType} {stub.DllImportMethodName}"); - if (!stub.DllImportParameters.Any()) - { - builder.AppendLine("();"); - } - else + // Add type to the remaining containing types (skipping the first which was handled above) + foreach (var typeDecl in stub.StubContainingTypes.Skip(1)) { - delim = '('; - foreach (var paramPair in stub.DllImportParameters) - { - builder.Append($"{delim}{paramPair.Type} {paramPair.Name}"); - delim = ','; - } - builder.AppendLine(");"); + containingType = typeDecl.WithMembers( + SingletonList(containingType)); } - // Print closing type declarations - while (typeIndentStack.Count > 0) - { - builder.AppendLine($@"{typeIndentStack.Pop()}}}"); - } + MemberDeclarationSyntax toPrint = containingType; - // Close namespace + // Add type to the containing namespace if (!(stub.StubTypeNamespace is null)) { - builder.AppendLine("}"); + toPrint = NamespaceDeclaration(IdentifierName(stub.StubTypeNamespace)) + .AddMembers(toPrint); } + + builder.AppendLine(toPrint.NormalizeWhitespace().ToString()); } private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMaybe) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index e2eb6d380e83e..64514d1541cbd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -6,8 +6,10 @@ true True true - GENERATE_FORWARDER Preview + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index c5fe2532a9ec2..23f743b1dedb8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -7,6 +7,9 @@ using System.Threading; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { @@ -21,43 +24,30 @@ private DllImportStub() public string StubTypeNamespace { get; private set; } - public IEnumerable StubContainingTypesDecl { get; private set; } + public IEnumerable StubContainingTypes { get; private set; } - public string StubReturnType { get => this.returnTypeInfo.ManagedTypeDecl; } + public TypeSyntax StubReturnType { get => this.returnTypeInfo.ManagedType.AsTypeSyntax(); } - public IEnumerable<(string Type, string Name)> StubParameters + public IEnumerable StubParameters { get { foreach (var typeinfo in paramsTypeInfo) { - //if (typeinfo.ManagedIndex != TypePositionInfo.UnsetIndex) + if (typeinfo.ManagedIndex != TypePositionInfo.UnsetIndex + && typeinfo.ManagedIndex != TypePositionInfo.ReturnIndex) { - yield return (typeinfo.ManagedTypeDecl, typeinfo.InstanceIdentifier); + yield return Parameter(Identifier(typeinfo.InstanceIdentifier)) + .WithType(typeinfo.ManagedType.AsTypeSyntax()) + .WithModifiers(TokenList(Token(typeinfo.RefKindSyntax))); } } } } - public IEnumerable StubCode { get; private set; } + public BlockSyntax StubCode { get; private set; } - public string DllImportReturnType { get => this.returnTypeInfo.UnmanagedTypeDecl; } - - public string DllImportMethodName { get; private set; } - - public IEnumerable<(string Type, string Name)> DllImportParameters - { - get - { - foreach (var typeinfo in paramsTypeInfo) - { - //if (typeinfo.UnmanagedIndex != TypePositionInfo.UnsetIndex) - { - yield return (typeinfo.UnmanagedTypeDecl, typeinfo.InstanceIdentifier); - } - } - } - } + public MethodDeclarationSyntax DllImportDeclaration { get; private set; } public IEnumerable Diagnostics { get; private set; } @@ -110,6 +100,7 @@ public class GeneratedDllImportData public static DllImportStub Create( IMethodSymbol method, GeneratedDllImportData dllImportData, + Compilation compilation, CancellationToken token = default) { // Cancel early if requested @@ -123,76 +114,75 @@ public static DllImportStub Create( stubTypeNamespace = method.ContainingNamespace.ToString(); } - // Determine type - var stubContainingTypes = new List(); + // Determine containing type(s) + var containingTypes = new List(); INamedTypeSymbol currType = method.ContainingType; while (!(currType is null)) { var visibility = currType.DeclaredAccessibility switch { - Accessibility.Public => "public", - Accessibility.Private => "private", - Accessibility.Protected => "protected", - Accessibility.Internal => "internal", + Accessibility.Public => SyntaxKind.PublicKeyword, + Accessibility.Private => SyntaxKind.PrivateKeyword, + Accessibility.Protected => SyntaxKind.ProtectedKeyword, + Accessibility.Internal => SyntaxKind.InternalKeyword, _ => throw new NotSupportedException(), // [TODO] Proper error message }; - var typeKeyword = currType.TypeKind switch + TypeDeclarationSyntax typeDecl = currType.TypeKind switch { - TypeKind.Class => "class", - TypeKind.Struct => "struct", + TypeKind.Class => ClassDeclaration(currType.Name), + TypeKind.Struct => StructDeclaration(currType.Name), _ => throw new NotSupportedException(), // [TODO] Proper error message }; - stubContainingTypes.Add($"{visibility} partial {typeKeyword} {currType.Name}"); + typeDecl = typeDecl.AddModifiers( + Token(visibility), + Token(SyntaxKind.PartialKeyword)); + containingTypes.Add(typeDecl); + currType = currType.ContainingType; } - // Flip the order to that of how to declare the types - stubContainingTypes.Reverse(); - - // Determine parameter types + // Determine parameter and return types var paramsTypeInfo = new List(); - foreach (var paramSymbol in method.Parameters) + for (int i = 0; i < method.Parameters.Length; i++) { - paramsTypeInfo.Add(TypePositionInfo.CreateForParameter(paramSymbol)); + var param = method.Parameters[i]; + var typeInfo = TypePositionInfo.CreateForParameter(param, compilation); + typeInfo.ManagedIndex = i; + typeInfo.NativeIndex = paramsTypeInfo.Count; + paramsTypeInfo.Add(typeInfo); } - var retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes()); - - string dllImportName = method.Name + "__PInvoke__"; - -#if !GENERATE_FORWARDER - var dispatchCall = new StringBuilder($"throw new System.{nameof(NotSupportedException)}();"); -#else - // Forward call to generated P/Invoke - var returnMaybe = method.ReturnsVoid ? string.Empty : "return "; - - var dispatchCall = new StringBuilder($"{returnMaybe}{dllImportName}"); - if (!paramsTypeInfo.Any()) + TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), compilation); + retTypeInfo.ManagedIndex = TypePositionInfo.ReturnIndex; + retTypeInfo.NativeIndex = TypePositionInfo.ReturnIndex; + if (!dllImportData.PreserveSig) { - dispatchCall.Append("();"); + // [TODO] Create type info for native HRESULT return + // retTypeInfo = ... + + // [TODO] Create type info for native out param + // if (!method.ReturnsVoid) + // { + // TypePositionInfo nativeOutInfo = ...; + // nativeOutInfo.ManagedIndex = TypePositionInfo.ReturnIndex; + // nativeOutInfo.NativeIndex = paramsTypeInfo.Count; + // paramsTypeInfo.Add(nativeOutInfo); + // } } - else - { - char delim = '('; - foreach (var param in paramsTypeInfo) - { - dispatchCall.Append($"{delim}{param.RefKindDecl}{param.InstanceIdentifier}"); - delim = ','; - } - dispatchCall.Append(");"); - } -#endif + + // Generate stub code + var (code, dllImport) = StubCodeGenerator.GenerateSyntax(method, paramsTypeInfo, retTypeInfo); return new DllImportStub() { returnTypeInfo = retTypeInfo, paramsTypeInfo = paramsTypeInfo, StubTypeNamespace = stubTypeNamespace, - StubContainingTypesDecl = stubContainingTypes, - StubCode = new[] { dispatchCall.ToString() }, - DllImportMethodName = dllImportName, + StubContainingTypes = containingTypes, + StubCode = code, + DllImportDeclaration = dllImport, Diagnostics = Enumerable.Empty(), }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs new file mode 100644 index 0000000000000..3dfbbbbf56600 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs @@ -0,0 +1,105 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal class BoolMarshaller : IMarshallingGenerator + { + public TypeSyntax AsNativeType(TypePositionInfo info) + { + var syntax = SyntaxKind.ByteKeyword; + if (info.MarshalAsInfo != null) + { + syntax = info.MarshalAsInfo.UnmanagedType switch + { + UnmanagedType.Bool => SyntaxKind.IntKeyword, + UnmanagedType.U1 => SyntaxKind.ByteKeyword, + UnmanagedType.I1 => SyntaxKind.SByteKeyword, + UnmanagedType.VariantBool => SyntaxKind.ShortKeyword, + _ => SyntaxKind.ByteKeyword + }; + } + + return PredefinedType(Token(syntax)); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + if (info.IsManagedReturnPosition) + nativeIdentifier = context.GenerateReturnNativeIdentifier(); + + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + + break; + case StubCodeContext.Stage.Marshal: + // = ()( ? 1 : 0); + if (info.RefKind != RefKind.Out) + { + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + CastExpression( + AsNativeType(info), + ParenthesizedExpression( + ConditionalExpression(IdentifierName(managedIdentifier), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))))); + } + + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || info.IsByRef) + { + // = != 0; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + BinaryExpression( + SyntaxKind.NotEqualsExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))); + } + break; + default: + break; + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs new file mode 100644 index 0000000000000..20e02e4ae87b8 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; + +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + class Forwarder : IMarshallingGenerator + { + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return info.ManagedType.AsTypeSyntax(); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + return Parameter(Identifier(info.InstanceIdentifier)) + .WithModifiers(TokenList(Token(info.RefKindSyntax))) + .WithType(info.ManagedType.AsTypeSyntax()); + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return Argument(IdentifierName(info.InstanceIdentifier)) + .WithRefKindKeyword(Token(info.RefKindSyntax)); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + return Array.Empty(); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs new file mode 100644 index 0000000000000..47b6394f95e26 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -0,0 +1,93 @@ +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Microsoft.Interop +{ + /// + /// Interface for generation of marshalling code for P/Invoke stubs + /// + internal interface IMarshallingGenerator + { + /// + /// Get the native type syntax for + /// + /// Object to marshal + /// Type syntax for the native type representing + TypeSyntax AsNativeType(TypePositionInfo info); + + /// + /// Get the as a parameter of the P/Invoke declaration + /// + /// Object to marshal + /// Parameter syntax for + ParameterSyntax AsParameter(TypePositionInfo info); + + /// + /// Get the as an argument to be passed to the P/Invoke + /// + /// Object to marshal + /// Code generation context + /// Argument syntax for + ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context); + + /// + /// Generate code for marshalling + /// + /// Object to marshal + /// Code generation context + /// List of statements to be added to the P/Invoke stub + /// + /// The generator should return the appropriate statements based on the + /// of . + /// For , any statements not of type + /// will be ignored. + /// + IEnumerable Generate(TypePositionInfo info, StubCodeContext context); + } + + internal class MarshallingGenerators + { + public static readonly BoolMarshaller Bool = new BoolMarshaller(); + public static readonly Forwarder Forwarder = new Forwarder(); + public static readonly NumericMarshaller Numeric = new NumericMarshaller(); + + public static bool TryCreate(TypePositionInfo info, out IMarshallingGenerator generator) + { +#if GENERATE_FORWARDER + generator = MarshallingGenerators.Forwarder; + return true; +#else + if (info.IsNativeReturnPosition && !info.IsManagedReturnPosition) + { + // [TODO] Use marshaller for native HRESULT return / exception throwing + // Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Int32) + } + + switch (info.ManagedType.SpecialType) + { + case SpecialType.System_SByte: + case SpecialType.System_Byte: + case SpecialType.System_Int16: + case SpecialType.System_UInt16: + case SpecialType.System_Int32: + case SpecialType.System_UInt32: + case SpecialType.System_Int64: + case SpecialType.System_UInt64: + case SpecialType.System_Single: + case SpecialType.System_Double: + generator = MarshallingGenerators.Numeric; + return true; + + case SpecialType.System_Boolean: + generator = MarshallingGenerators.Bool; + return true; + default: + generator = MarshallingGenerators.Forwarder; + return false; + } +#endif + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NumericMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NumericMarshaller.cs new file mode 100644 index 0000000000000..616e29b1e0ea8 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NumericMarshaller.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal class NumericMarshaller : IMarshallingGenerator + { + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return info.ManagedType.AsTypeSyntax(); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(context.GetIdentifiers(info).native))); + } + + return Argument(IdentifierName(info.InstanceIdentifier)); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + if (!info.IsByRef || info.IsManagedReturnPosition) + yield break; + + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList( + VariableDeclarator(nativeIdentifier)))); + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind == RefKind.Ref) + { + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + IdentifierName(managedIdentifier))); + } + + break; + case StubCodeContext.Stage.Unmarshal: + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + IdentifierName(nativeIdentifier))); + break; + default: + break; + } + } + } + +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs new file mode 100644 index 0000000000000..0aca8cc6a2391 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -0,0 +1,110 @@ +using System; + +namespace Microsoft.Interop +{ + internal abstract class StubCodeContext + { + /// + /// Code generation stage + /// + public enum Stage + { + /// + /// Perform any setup required + /// + Setup, + + /// + /// Convert managed data to native data + /// + Marshal, + + /// + /// Pin data in preparation for calling the generated P/Invoke + /// + Pin, + + /// + /// Call the generated P/Invoke + /// + /// + /// should provide the + /// argument to pass to the P/Invoke + /// + Invoke, + + /// + /// Convert native data to managed data + /// + Unmarshal, + + /// + /// Perform any cleanup required + /// + Cleanup + } + + public Stage CurrentStage { get; protected set; } + + /// + /// Identifier for managed return value + /// + public const string ReturnIdentifier = "__retVal"; + + /// + /// Identifier for native return value + /// + /// Same as the managed identifier by default + public string ReturnNativeIdentifier { get; private set; } = ReturnIdentifier; + + private const string InvokeReturnIdentifier = "__invokeRetVal"; + private const string generatedNativeIdentifierSuffix = "_gen_native"; + + /// + /// Generate an identifier for the native return value and update the context with the new value + /// + /// Identifier for the native return value + public string GenerateReturnNativeIdentifier() + { + if (CurrentStage != Stage.Setup) + throw new InvalidOperationException(); + + // Update the native identifier for the return value + ReturnNativeIdentifier = $"{ReturnIdentifier}{generatedNativeIdentifierSuffix}"; + return ReturnNativeIdentifier; + } + + /// + /// Get managed and native instance identifiers for the + /// + /// Object for which to get identifiers + /// Managed and native identifiers + public (string managed, string native) GetIdentifiers(TypePositionInfo info) + { + string managedIdentifier; + string nativeIdentifier; + if (info.IsManagedReturnPosition && !info.IsNativeReturnPosition) + { + managedIdentifier = ReturnIdentifier; + nativeIdentifier = ReturnNativeIdentifier; + } + else if (!info.IsManagedReturnPosition && info.IsNativeReturnPosition) + { + managedIdentifier = InvokeReturnIdentifier; + nativeIdentifier = InvokeReturnIdentifier; + } + else + { + managedIdentifier = info.IsManagedReturnPosition + ? ReturnIdentifier + : info.InstanceIdentifier; + + nativeIdentifier = info.IsNativeReturnPosition + ? ReturnNativeIdentifier + : $"__{info.InstanceIdentifier}{generatedNativeIdentifierSuffix}"; + } + + return (managedIdentifier, nativeIdentifier); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs new file mode 100644 index 0000000000000..8a32f3f1c67e3 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -0,0 +1,210 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal sealed class StubCodeGenerator : StubCodeContext + { + private StubCodeGenerator(Stage stage) + { + CurrentStage = stage; + } + + public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSyntax( + IMethodSymbol stubMethod, + IEnumerable paramsTypeInfo, + TypePositionInfo retTypeInfo) + { + Debug.Assert(retTypeInfo.IsNativeReturnPosition); + + string dllImportName = stubMethod.Name + "__PInvoke__"; + var paramMarshallers = paramsTypeInfo.Select(p => GetMarshalInfo(p)).ToList(); + var retMarshaller = GetMarshalInfo(retTypeInfo); + + var context = new StubCodeGenerator(Stage.Setup); + var statements = new List(); + + foreach (var marshaller in paramMarshallers) + { + TypePositionInfo info = marshaller.TypeInfo; + if (info.RefKind != RefKind.Out || info.IsManagedReturnPosition) + continue; + + // Assign out params to default + statements.Add(ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(info.InstanceIdentifier), + LiteralExpression( + SyntaxKind.DefaultLiteralExpression, + Token(SyntaxKind.DefaultKeyword))))); + } + + bool invokeReturnsVoid = retTypeInfo.ManagedType.SpecialType == SpecialType.System_Void; + bool stubReturnsVoid = stubMethod.ReturnsVoid; + + // Stub return is not the same as invoke return + if (!stubReturnsVoid && !retTypeInfo.IsManagedReturnPosition) + { + Debug.Assert(paramsTypeInfo.Any() && paramsTypeInfo.Last().IsManagedReturnPosition); + + // Declare variable for stub return value + TypePositionInfo info = paramsTypeInfo.Last(); + statements.Add(LocalDeclarationStatement( + VariableDeclaration( + info.ManagedType.AsTypeSyntax(), + SingletonSeparatedList( + VariableDeclarator(context.GetIdentifiers(info).managed))))); + } + + if (!invokeReturnsVoid) + { + // Declare variable for invoke return value + statements.Add(LocalDeclarationStatement( + VariableDeclaration( + retTypeInfo.ManagedType.AsTypeSyntax(), + SingletonSeparatedList( + VariableDeclarator(context.GetIdentifiers(retTypeInfo).managed))))); + } + + var stages = new Stage[] + { + Stage.Setup, + Stage.Marshal, + Stage.Pin, + Stage.Invoke, + Stage.Unmarshal, + Stage.Cleanup + }; + + var invoke = InvocationExpression(IdentifierName(dllImportName)); + var fixedStatements = new List(); + foreach (var stage in stages) + { + int initialCount = statements.Count; + context.CurrentStage = stage; + + if (!invokeReturnsVoid && (stage == Stage.Setup || stage == Stage.Unmarshal)) + { + // Handle setup and unmarshalling for return + var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, context); + statements.AddRange(retStatements); + } + + // Generate code for each parameter for the current stage + foreach (var marshaller in paramMarshallers) + { + if (stage == Stage.Invoke) + { + // Get arguments for invocation + ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, context); + invoke = invoke.AddArgumentListArguments(argSyntax); + } + else + { + var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, context); + if (stage == Stage.Pin) + { + // Collect all the fixed statements. These will be used in the Invoke stage. + foreach (var statement in generatedStatements) + { + if (statement is not FixedStatementSyntax fixedStatement) + continue; + + fixedStatements.Add(fixedStatement); + } + } + else + { + statements.AddRange(generatedStatements); + } + } + } + + if (stage == Stage.Invoke) + { + StatementSyntax invokeStatement; + + // Assign to return value if necessary + if (invokeReturnsVoid) + { + invokeStatement = ExpressionStatement(invoke); + } + else + { + invokeStatement = ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(context.GetIdentifiers(retMarshaller.TypeInfo).native), + invoke)); + } + + // Nest invocation in fixed statements + if (fixedStatements.Any()) + { + fixedStatements.Reverse(); + invokeStatement = fixedStatements.First().WithStatement(Block(invokeStatement)); + foreach (var fixedStatement in fixedStatements.Skip(1)) + { + invokeStatement = fixedStatement.WithStatement(Block(invokeStatement)); + } + } + + statements.Add(invokeStatement); + } + + if (statements.Count > initialCount) + { + // Comment separating each stage + var newLeadingTrivia = TriviaList( + Comment($"//"), + Comment($"// {stage}"), + Comment($"//")); + var firstStatementInStage = statements[initialCount]; + newLeadingTrivia = newLeadingTrivia.AddRange(firstStatementInStage.GetLeadingTrivia()); + statements[initialCount] = firstStatementInStage.WithLeadingTrivia(newLeadingTrivia); + } + } + + // Return + if (!stubReturnsVoid) + statements.Add(ReturnStatement(IdentifierName(ReturnIdentifier))); + + // Wrap all statements in an unsafe block + var codeBlock = Block(UnsafeStatement(Block(statements))); + + // Define P/Invoke declaration + var dllImport = MethodDeclaration(retMarshaller.Generator.AsNativeType(retMarshaller.TypeInfo), dllImportName) + .AddModifiers( + Token(SyntaxKind.ExternKeyword), + Token(SyntaxKind.PrivateKeyword), + Token(SyntaxKind.StaticKeyword), + Token(SyntaxKind.UnsafeKeyword)) + .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); + foreach (var marshaller in paramMarshallers) + { + ParameterSyntax paramSyntax = marshaller.Generator.AsParameter(marshaller.TypeInfo); + dllImport = dllImport.AddParameterListParameters(paramSyntax); + } + + return (codeBlock, dllImport); + } + + private static (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) GetMarshalInfo(TypePositionInfo info) + { + IMarshallingGenerator generator; + if (!MarshallingGenerators.TryCreate(info, out generator)) + { + // [TODO] Report warning + } + + return (info, generator); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index c9cf380c3db9b..355b897873cce 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -1,9 +1,12 @@ -using Microsoft.CodeAnalysis; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + namespace Microsoft.Interop { /// @@ -31,36 +34,35 @@ internal sealed class TypePositionInfo private TypePositionInfo() { this.ManagedIndex = UnsetIndex; - this.UnmanagedIndex = UnsetIndex; + this.NativeIndex = UnsetIndex; this.UnmanagedLCIDConversionArgIndex = UnsetIndex; } - public ITypeSymbol TypeSymbol { get; private set; } public string InstanceIdentifier { get; private set; } + public ITypeSymbol ManagedType { get; private set; } public RefKind RefKind { get; private set; } - public string RefKindDecl { get => RefKindToString(this.RefKind); } - public string ManagedTypeDecl { get; private set; } - public string UnmanagedTypeDecl { get; private set; } + public SyntaxKind RefKindSyntax { get; private set; } + + public bool IsByRef => RefKind == RefKind.Ref || RefKind == RefKind.Out; public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } - public bool IsUnmanagedReturnPosition { get => this.UnmanagedIndex == ReturnIndex; } + public bool IsNativeReturnPosition { get => this.NativeIndex == ReturnIndex; } public int ManagedIndex { get; set; } - public int UnmanagedIndex { get; set; } + public int NativeIndex { get; set; } public int UnmanagedLCIDConversionArgIndex { get; private set; } public MarshalAsInfo MarshalAsInfo { get; private set; } - public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol) + public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, Compilation compilation) { var typeInfo = new TypePositionInfo() { - TypeSymbol = paramSymbol.Type, + ManagedType = paramSymbol.Type, InstanceIdentifier = paramSymbol.Name, - ManagedTypeDecl = ComputeTypeForManaged(paramSymbol.Type, paramSymbol.RefKind), - UnmanagedTypeDecl = ComputeTypeForUnmanaged(paramSymbol.Type, paramSymbol.RefKind), - RefKind = paramSymbol.RefKind + RefKind = paramSymbol.RefKind, + RefKindSyntax = RefKindToSyntax(paramSymbol.RefKind) }; UpdateWithAttributeData(paramSymbol.GetAttributes(), ref typeInfo); @@ -68,15 +70,14 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol) return typeInfo; } - public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes) + public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation) { var typeInfo = new TypePositionInfo() { - TypeSymbol = type, + ManagedType = type, InstanceIdentifier = string.Empty, - ManagedTypeDecl = ComputeTypeForManaged(type, RefKind.None), - UnmanagedTypeDecl = ComputeTypeForUnmanaged(type, RefKind.None), - RefKind = RefKind.None + RefKind = RefKind.None, + RefKindSyntax = SyntaxKind.None, }; UpdateWithAttributeData(attributes, ref typeInfo); @@ -147,87 +148,14 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData) } } - private static string ComputeTypeForManaged(ITypeSymbol type, RefKind refKind) - { - var typeAsString = type.SpecialType switch - { - SpecialType.System_Void => "void", - SpecialType.System_Boolean => "bool", - SpecialType.System_Char => "char", - SpecialType.System_SByte => "sbyte", - SpecialType.System_Byte => "byte", - SpecialType.System_Int16 => "short", - SpecialType.System_UInt16 => "ushort", - SpecialType.System_Int32 => "int", - SpecialType.System_UInt32 => "uint", - SpecialType.System_Int64 => "long", - SpecialType.System_UInt64 => "ulong", - SpecialType.System_Single => "float", - SpecialType.System_Double => "double", - SpecialType.System_String => "string", - SpecialType.System_IntPtr => "System.IntPtr", - SpecialType.System_UIntPtr => "System.UIntPtr", - _ => null, - }; - - var typePrefix = string.Empty; - if (typeAsString is null) - { - // Determine the namespace - if (!(type.ContainingNamespace is null) - && !type.ContainingNamespace.IsGlobalNamespace) - { - typePrefix = $"{type.ContainingNamespace}{Type.Delimiter}"; - } - - typeAsString = type.ToString(); - } - - string refKindAsString = RefKindToString(refKind); - return $"{refKindAsString}{typePrefix}{typeAsString}"; - } - - private static string ComputeTypeForUnmanaged(ITypeSymbol type, RefKind refKind) - { -#if GENERATE_FORWARDER - return ComputeTypeForManaged(type, refKind); -#else - if (!type.IsUnmanagedType) - { - return "void*"; - } - - return type.SpecialType switch - { - SpecialType.System_Void => "void", - SpecialType.System_Boolean => "byte", // [TODO] Determine marshalling default C++ bool or Windows' BOOL - SpecialType.System_Char => "ushort", // CLR character width (UTF-16) - SpecialType.System_SByte => "sbyte", - SpecialType.System_Byte => "byte", - SpecialType.System_Int16 => "short", - SpecialType.System_UInt16 => "ushort", - SpecialType.System_Int32 => "int", - SpecialType.System_UInt32 => "uint", - SpecialType.System_Int64 => "long", - SpecialType.System_UInt64 => "ulong", - SpecialType.System_Single => "float", - SpecialType.System_Double => "double", - SpecialType.System_String => "char*", // [TODO] Consider encoding here - SpecialType.System_IntPtr => "void*", - SpecialType.System_UIntPtr => "void*", - _ => "void*", - }; -#endif - } - - private static string RefKindToString(RefKind refKind) + private static SyntaxKind RefKindToSyntax(RefKind refKind) { return refKind switch { - RefKind.In => "in ", - RefKind.Ref => "ref ", - RefKind.Out => "out ", - RefKind.None => string.Empty, + RefKind.In => SyntaxKind.InKeyword, + RefKind.Ref => SyntaxKind.RefKeyword, + RefKind.Out => SyntaxKind.OutKeyword, + RefKind.None => SyntaxKind.None, _ => throw new NotImplementedException("Support for some RefKind"), }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 3145c3aec4fbf..90726c84b6430 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -1,4 +1,3 @@ -using Microsoft.CodeAnalysis; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -6,6 +5,10 @@ using System.Linq; using System.Runtime.InteropServices; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + #nullable enable namespace Microsoft.Interop @@ -44,7 +47,7 @@ public static bool HasOnlyBlittableFields(this ITypeSymbol type) } private static bool IsSpecialTypeBlittable(SpecialType specialType) - => specialType switch + => specialType switch { SpecialType.System_SByte or SpecialType.System_Byte @@ -60,14 +63,14 @@ or SpecialType.System_IntPtr or SpecialType.System_UIntPtr => true, _ => false }; - + public static bool IsConsideredBlittable(this ITypeSymbol type) { if (type.SpecialType != SpecialType.None) { return IsSpecialTypeBlittable(type.SpecialType); } - + if (!type.IsValueType || type.IsReferenceType) { return false; @@ -126,5 +129,13 @@ public static bool IsAutoLayout(this INamedTypeSymbol type, ITypeSymbol structLa } return type.IsReferenceType; } + + public static TypeSyntax AsTypeSyntax(this ITypeSymbol type) + { + // [TODO] Use ParseTypeName overload with default values for offset and consumeFullText after switching + // to Roslyn package that has the change from CSharpParseOptions -> ParseOptions in that overload + // return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), offset: 0, consumeFullText: true); + } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md new file mode 100644 index 0000000000000..d42d3a08e4d53 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -0,0 +1,49 @@ +# P/Invoke Generation Pipeline + +The P/Invoke source generator is responsible for finding all methods marked with `GeneratedDllImportAttribute` and generating code for their implementations (stubs) and corresponding P/Invokes that will be called by the stubs. For every method, the steps are: + +1. [Process the symbols and metadata](#symbols-and-metadata-processing) for the method, its parameters, and its return type. +1. [Determine the marshalling generators](#marshalling-generators) that will be responsible for generating the stub code for each parameter and return +1. [Generate the stub code](#stub-code-generation) and corresponding P/Invoke +1. Add the generated source to the compilation. + +The pipeline uses the Roslyn [Syntax APIs](https://docs.microsoft.com/dotnet/api/microsoft.codeanalysis.csharp.syntax) to create the generated code. This imposes some structure for the marshalling generators and allows for easier inspection or modification (if desired) of the generated code. + +## Symbol and metadata processing + +The generator processes the method's `GeneratedDllImportAttribute` data, the method's parameter and return types, and the metadata on them (e.g. [`LCIDConversionAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute), [`MarshalAsAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute), [struct marshalling attributes](StructMarshalling.md)). This information is used to determine the corresponding native type for each managed parameter/return type and how they will be marshalled. + +A [`TypePositionInfo`](../DllImportGenerator/TypePositionInfo.cs) is created for each type that needs to be marshalled. This includes any implicit parameter/return types that are required for the P/Invoke, but not part of the managed method signature; for example, a method with `PreserveSig=false` requires an HRESULT return type and potentially an out parameter matching the managed method's return type. + +## Marshalling generators + +Each parameter and return for the method is handled by an [`IMarshallingGenerator`](../DllImportGenerator/Marshalling/MarshallingGenerator.cs) instance. The processed information for each parameter and return type is used to determine the appropriate marshalling generator for handling that type. Support for different types can be added in the form of new implementations of `IMarshallingGenerator`. + +The marshalling generators are responsible for generating the code for each [stage](#stages) of the stub. They are intended to be stateless, such that they are given all the data ([`TypePositionInfo`](../DllImportGenerator/TypePositionInfo.cs)) for which they need to generate marshalling code and the context ([`StubCodeContext`](../DllImportGenerator/StubCodeContext.cs)) under which that code should be generated. + +## Stub code generation + +Generation of the stub code happens in stages. The marshalling generator for each parameter and return is called to generate code for each stage of the stub. The statements and syntax provided by each marshalling generator for each stage combine to form the full stub implementation. + +### Stages + +1. `Setup`: initialization that happens before marshalling any data + - If the method has a non-void return, call `Generate` on the marshalling generator for the return + - Call `Generate` on the marshalling generator for every parameter +1. `Marshal`: conversion of managed to native data + - Call `Generate` on the marshalling generator for every parameter +1. `Pin`: data pinning in preparation for calling the generated P/Invoke + - Call `Generate` on the marshalling generator for every parameter + - Ignore any statements that are not `fixed` statements +1. `Invoke`: call to the generated P/Invoke + - Call `AsArgument` on the marshalling generator for every parameter + - Create invocation statement that calls the generated P/Invoke +1. `Unmarshal`: conversion of native to managed data + - If the method has a non-void return, call `Generate` on the marshalling generator for the return + - Call `Generate` on the marshalling generator for every parameter +1. `Cleanup`: free any allocated resources + - Call `Generate` on the marshalling generator for every parameter + +### P/Invoke + +The P/Invoke called by the stub is created based on the user's original declaration of the stub. The signature is generated using the syntax returned by `AsNativeType` and `AsParameter` of the marshalling generators for the return and parameters. \ No newline at end of file From d47569df943c0b0cae9b799060780c3f841d7f39 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 16 Sep 2020 19:11:40 -0700 Subject: [PATCH 015/161] Use declaring syntax as a baseline for generated syntax for containing types. (dotnet/runtimelab#108) Commit migrated from https://github.com/dotnet/runtimelab/commit/4bb5cb0590896a2b88fd12d041d4268233220ab8 --- .../gen/DllImportGenerator/DllImportStub.cs | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 23f743b1dedb8..3218db8e00e1d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -119,25 +119,14 @@ public static DllImportStub Create( INamedTypeSymbol currType = method.ContainingType; while (!(currType is null)) { - var visibility = currType.DeclaredAccessibility switch - { - Accessibility.Public => SyntaxKind.PublicKeyword, - Accessibility.Private => SyntaxKind.PrivateKeyword, - Accessibility.Protected => SyntaxKind.ProtectedKeyword, - Accessibility.Internal => SyntaxKind.InternalKeyword, - _ => throw new NotSupportedException(), // [TODO] Proper error message - }; - - TypeDeclarationSyntax typeDecl = currType.TypeKind switch - { - TypeKind.Class => ClassDeclaration(currType.Name), - TypeKind.Struct => StructDeclaration(currType.Name), - _ => throw new NotSupportedException(), // [TODO] Proper error message - }; - - typeDecl = typeDecl.AddModifiers( - Token(visibility), - Token(SyntaxKind.PartialKeyword)); + // Use the declaring syntax as a basis for this type declaration. + // Since we're generating source for the method, we know that the current type + // has to be declared in source. + TypeDeclarationSyntax typeDecl = (TypeDeclarationSyntax)currType.DeclaringSyntaxReferences[0].GetSyntax(); + // Remove current members and attributes so we don't double declare them. + typeDecl = typeDecl.WithMembers(List()) + .WithAttributeLists(List()); + containingTypes.Add(typeDecl); currType = currType.ContainingType; From 4fce8454bff06d369aa8d9c1a9ca7e680ac0fb17 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 21 Sep 2020 16:16:22 -0700 Subject: [PATCH 016/161] Move to 3.8.0-3.final Roslyn packages (dotnet/runtimelab#119) Commit migrated from https://github.com/dotnet/runtimelab/commit/f56021b8dec78527297f97a39fa0375f6dea6619 --- .../gen/Directory.Build.props | 7 +++++++ .../DllImportGenerator.Test.csproj | 6 +++--- .../gen/DllImportGenerator.Test/TestUtils.cs | 8 +++----- .../gen/DllImportGenerator/DllImportGenerator.cs | 4 ++-- .../gen/DllImportGenerator/DllImportGenerator.csproj | 4 ++-- .../gen/DllImportGenerator/TypeSymbolExtensions.cs | 5 +---- 6 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props diff --git a/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props new file mode 100644 index 0000000000000..81194ffe87da9 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props @@ -0,0 +1,7 @@ + + + + 3.8.0-3.final + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj index 298f48c678644..75fb2cb381c85 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj @@ -7,10 +7,10 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs index 1b374e257e1e3..49ca8e625f608 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs @@ -1,7 +1,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; -using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; @@ -70,14 +69,13 @@ public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() /// The resulting compilation public static Compilation RunGenerators(Compilation comp, out ImmutableArray diagnostics, params ISourceGenerator[] generators) { - CreateDriver(comp, generators).RunFullGeneration(comp, out var d, out diagnostics); + CreateDriver(comp, generators).RunGeneratorsAndUpdateCompilation(comp, out var d, out diagnostics); return d; } private static GeneratorDriver CreateDriver(Compilation c, params ISourceGenerator[] generators) - => new CSharpGeneratorDriver(c.SyntaxTrees.First().Options, + => CSharpGeneratorDriver.Create( ImmutableArray.Create(generators), - null, - ImmutableArray.Empty); + parseOptions: (CSharpParseOptions)c.SyntaxTrees.First().Options); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index d81eb6ea8d3d3..4d9ce3989205a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -20,7 +20,7 @@ public class DllImportGenerator : ISourceGenerator private const string GeneratedDllImport = nameof(GeneratedDllImport); private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute); - public void Execute(SourceGeneratorContext context) + public void Execute(GeneratorExecutionContext context) { var synRec = context.SyntaxReceiver as SyntaxReceiver; if (synRec is null) @@ -70,7 +70,7 @@ public void Execute(SourceGeneratorContext context) context.AddSource("DllImportGenerator.g.cs", SourceText.From(generatedDllImports.ToString(), Encoding.UTF8)); } - public void Initialize(InitializationContext context) + public void Initialize(GeneratorInitializationContext context) { context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 64514d1541cbd..5e60199190e12 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -33,8 +33,8 @@ - - + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 90726c84b6430..97e6b5cf1b67d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -132,10 +132,7 @@ public static bool IsAutoLayout(this INamedTypeSymbol type, ITypeSymbol structLa public static TypeSyntax AsTypeSyntax(this ITypeSymbol type) { - // [TODO] Use ParseTypeName overload with default values for offset and consumeFullText after switching - // to Roslyn package that has the change from CSharpParseOptions -> ParseOptions in that overload - // return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), offset: 0, consumeFullText: true); + return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); } } } From d415807482a340ba87b7bb854ca21f9ed119b1b4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 25 Sep 2020 17:32:57 -0700 Subject: [PATCH 017/161] Add validation that the StackBufferSize member exists when a stackalloc constructor exists. (dotnet/runtimelab#125) Commit migrated from https://github.com/dotnet/runtimelab/commit/9e7e2219120dcce1bf7c3356269f743cfe1d1f31 --- .../ManualTypeMarshallingAnalyzerTests.cs | 28 +++++++++++++++++++ .../ManualTypeMarshallingAnalyzer.cs | 18 +++++++++++- .../DllImportGenerator/Resources.Designer.cs | 18 ++++++++++++ .../gen/DllImportGenerator/Resources.resx | 6 ++++ .../DllImportGenerator/StructMarshalling.md | 2 +- 5 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs index b4ddfcb874aed..285b4096cc303 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs @@ -564,6 +564,8 @@ class S struct Native { public Native(S s, Span buffer) {} + + public const int StackBufferSize = 0x100; }"; await VerifyCS.VerifyAnalyzerAsync(source, @@ -589,6 +591,8 @@ struct Native public Native(S s, Span buffer) {} public IntPtr Value => IntPtr.Zero; + + public const int StackBufferSize = 0x100; }"; await VerifyCS.VerifyAnalyzerAsync(source, @@ -1046,5 +1050,29 @@ struct G where U : class }"; await VerifyCS.VerifyAnalyzerAsync(source); } + + [Fact] + public async Task NativeTypeWithStackallocConstructorWithoutBufferSize_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[BlittableType] +struct Native +{ + public Native(S s) {} + public Native(S s, Span buffer) {} +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(StackallocConstructorMustHaveStackBufferSizeConstantRule).WithSpan(15, 5, 15, 45).WithArguments("Native")); + } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs index 71e7a71afedcf..9f32c5c9b2886 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -124,6 +124,16 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: new LocalizableResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackDescription), Resources.ResourceManager, typeof(Resources))); + public readonly static DiagnosticDescriptor StackallocConstructorMustHaveStackBufferSizeConstantRule = + new DiagnosticDescriptor( + "INTEROPGEN012", + "StackallocConstructorMustHaveStackBufferSizeConstant", + new LocalizableResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantMessage), Resources.ResourceManager, typeof(Resources)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantDescription), Resources.ResourceManager, typeof(Resources))); + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create( BlittableTypeMustBeBlittableRule, @@ -136,7 +146,8 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer ValuePropertyMustHaveSetterRule, ValuePropertyMustHaveGetterRule, GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, - StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule); + StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, + StackallocConstructorMustHaveStackBufferSizeConstantRule); public override void Initialize(AnalysisContext context) { @@ -309,6 +320,11 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb && SymbolEqualityComparer.Default.Equals(SpanOfByte, ctor.Parameters[1].Type)) { hasStackallocConstructor = true; + IFieldSymbol stackAllocSizeField = nativeType.GetMembers("StackBufferSize").OfType().FirstOrDefault(); + if (stackAllocSizeField is null or { DeclaredAccessibility: not Accessibility.Public } or { IsConst: false } or { Type: not { SpecialType: SpecialType.System_Int32 } }) + { + context.ReportDiagnostic(Diagnostic.Create(StackallocConstructorMustHaveStackBufferSizeConstantRule, ctor.DeclaringSyntaxReferences[0].GetSyntax()!.GetLocation(), nativeType.ToDisplayString())); + } } } 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 57a4b44d93afc..c7ccc3443b271 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -204,6 +204,24 @@ internal static string NativeTypeMustHaveRequiredShapeMessage { } } + /// + /// Looks up a localized string similar to When constructor taking a Span<byte> is specified on the native type, the type must also have a public integer constant named StackBufferSize to provide the size of the stack-allocated buffer.. + /// + internal static string StackallocConstructorMustHaveStackBufferSizeConstantDescription { + get { + return ResourceManager.GetString("StackallocConstructorMustHaveStackBufferSizeConstantDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' must have a 'public const int StackBufferSize' field that specifies the size of the stack buffer because it has a constructor that takes a stack-allocated Span<byte>.. + /// + internal static string StackallocConstructorMustHaveStackBufferSizeConstantMessage { + get { + return ResourceManager.GetString("StackallocConstructorMustHaveStackBufferSizeConstantMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to A type that supports marshalling from managed to native by stack allocation should also support marshalling from managed to native where stack allocation is impossible.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 836175ad06b9d..e21cecab2e6f7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -165,6 +165,12 @@ The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}'. + + When constructor taking a Span<byte> is specified on the native type, the type must also have a public integer constant named StackBufferSize to provide the size of the stack-allocated buffer. + + + The native type '{0}' must have a 'public const int StackBufferSize' field that specifies the size of the stack buffer because it has a constructor that takes a stack-allocated Span<byte>. + A type that supports marshalling from managed to native by stack allocation should also support marshalling from managed to native where stack allocation is impossible. diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md index bd7c3bd90f32f..95bbdd82d263b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md @@ -76,7 +76,7 @@ partial struct TNative { public TNative(TManaged managed, Span stackSpace) {} - public static const int StackBufferSize = /* */; + public const int StackBufferSize = /* */; } ``` From ced02684fb545d8db6be7f7f3e5abcfde3e05be3 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 25 Sep 2020 17:39:22 -0700 Subject: [PATCH 018/161] Consume DNNE for testing (dotnet/runtimelab#124) * Use DNNE to create native testing assets Instead of relying on a native project use DNNE to generate native exports for managed binaries. This allows us to avoid writing native code for testing code generation. * Add *.binlog to .gitignore * Force 'UseAppHost' to fix scenario on macOS. * Consume support in DNNE for adding native binary to project. Commit migrated from https://github.com/dotnet/runtimelab/commit/415c6ca78b4d38409e0d569804a504ae2b8f5dad --- .../gen/.gitignore | 3 +- .../gen/readme.md | 6 +++- .../NativeExports/NativeExports.csproj | 35 +++++++++++++++++++ .../TestAssets/NativeExports/ScalarOps.cs | 26 ++++++++++++++ .../DllImportGeneratorSample.csproj | 4 +++ .../DllImportGeneratorSample/Program.cs | 29 ++++++++++----- 6 files changed, 93 insertions(+), 10 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/ScalarOps.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/.gitignore b/src/libraries/System.Runtime.InteropServices/gen/.gitignore index 7d37c147c16be..831de0b592d4f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/.gitignore +++ b/src/libraries/System.Runtime.InteropServices/gen/.gitignore @@ -1,3 +1,4 @@ .vs/ **/bin -**/obj \ No newline at end of file +**/obj +*.binlog \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/readme.md b/src/libraries/System.Runtime.InteropServices/gen/readme.md index a765a7a51257d..9ba80ca332200 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/readme.md +++ b/src/libraries/System.Runtime.InteropServices/gen/readme.md @@ -8,13 +8,17 @@ Below are additional work items that are not presently captured in this reposito ### Required -* Add `GeneratedDllImportAttribute` to the BCL. See [`GeneratedDllImportAttribute.cs`](./DllImportGeneratorAttribute/GeneratedDllImportAttribute.cs). + +* Add `GeneratedDllImportAttribute` to the BCL. See [`GeneratedDllImportAttribute.cs`](./Ancillary.Interop/GeneratedDllImportAttribute.cs). * Add support for calling [`SetLastError()`](https://docs.microsoft.com/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror) from managed code with the expected semantics. During P/Invoke transitions the runtime manipulates the associated thread's error code and thus breaks `SetLastError()` semantics. +* APIs to handle [`SafeHandle`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.safehandle) manipulation. + ### Optional * A tool to compare the resulting IL from the generated source to that generated by the built-in IL Marshaller system. This would help with validation of what is being generated. ## Designs +- [Code generation pipeline](./designs/Pipeline.md) - [Struct Marshalling](./designs/StructMarshalling.md) diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj new file mode 100644 index 0000000000000..70e5b074e8b89 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -0,0 +1,35 @@ + + + + net5.0 + true + true + true + + + + + + + + + + + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/ScalarOps.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/ScalarOps.cs new file mode 100644 index 0000000000000..4d2bb92006f6c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/ScalarOps.cs @@ -0,0 +1,26 @@ +using System; +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public unsafe class ScalarOps + { + [UnmanagedCallersOnly(EntryPoint = "sumi")] + public static int Sum(int a, int b) + { + return a + b; + } + + [UnmanagedCallersOnly(EntryPoint = "sumouti")] + public static void SumOut(int a, int b, int* c) + { + *c = a + b; + } + + [UnmanagedCallersOnly(EntryPoint = "sumrefi")] + public static void SumRef(int a, int* b) + { + *b += a; + } + } +} diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 09299b00addba..4cee92efcd88d 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -5,11 +5,15 @@ net5.0 true preview + + + true + diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index 335cef053259e..ff7d931ccd3c8 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -1,23 +1,36 @@ using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace Demo { - partial class Kernel32 + partial class NativeExportsNE { - [GeneratedDllImport(nameof(Kernel32), EntryPoint = "QueryPerformanceCounter")] - public static partial int Method(ref long t); + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumi")] + public static partial int Sum(int a, int b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumouti")] + public static partial void Sum(int a, int b, out int c); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumrefi")] + public static partial void Sum(int a, ref int b); } unsafe class Program { static void Main(string[] args) { - var ts = (long)0; - int suc = Kernel32.Method(ref ts); - Console.WriteLine($"{suc}: 0x{ts:x}"); + int a = 12; + int b = 13; + int c = NativeExportsNE.Sum(a, b); + Console.WriteLine($"{a} + {b} = {c}"); + + c = 0; + NativeExportsNE.Sum(a, b, out c); + Console.WriteLine($"{a} + {b} = {c}"); + + c = b; + NativeExportsNE.Sum(a, ref c); + Console.WriteLine($"{a} + {b} = {c}"); } } } From 604100690b7174ae062d4e5f8460e70a93ac610b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 29 Sep 2020 11:38:06 -0700 Subject: [PATCH 019/161] Implement marshaler selection based on metadata model (dotnet/runtimelab#109) Commit migrated from https://github.com/dotnet/runtimelab/commit/ebf31e6d43e96cacf3aea98738e71663ce468099 --- .../DllImportGenerator.Test/CodeSnippets.cs | 22 +++ .../gen/DllImportGenerator.Test/Compiles.cs | 4 + .../ManualTypeMarshallingAnalyzerTests.cs | 4 +- .../gen/DllImportGenerator/LanguageSupport.cs | 10 ++ .../ManualTypeMarshallingAnalyzer.cs | 26 ++- .../ManualTypeMarshallingHelper.cs | 69 ++++++++ ...icMarshaller.cs => BlittableMarshaller.cs} | 44 ++++- .../Marshalling/BoolMarshaller.cs | 71 +++++--- .../Marshalling/DelegateMarshaller.cs | 116 ++++++++++++ .../Marshalling/Forwarder.cs | 2 + .../Marshalling/MarshallingGenerator.cs | 81 +++++++-- .../MarshallingAttributeInfo.cs | 58 ++++++ .../gen/DllImportGenerator/StubCodeContext.cs | 62 ++----- .../DllImportGenerator/StubCodeGenerator.cs | 73 +++++++- .../gen/DllImportGenerator/TypeNames.cs | 2 + .../DllImportGenerator/TypePositionInfo.cs | 165 ++++++++++++++---- 16 files changed, 648 insertions(+), 161 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs rename src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/{NumericMarshaller.cs => BlittableMarshaller.cs} (63%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs index 00d0ea39d94ef..bb3594897326c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs @@ -365,5 +365,27 @@ partial class Test [GeneratedDllImport(""DoesNotExist"", PreserveSig = false)] public static partial void Method(); }}"; + + public static string DelegateParametersAndModifiers = BasicParametersAndModifiers("MyDelegate") + @" +delegate int MyDelegate(int a);"; + public static string DelegateMarshalAsParametersAndModifiers = MarshalAsParametersAndModifiers("MyDelegate", UnmanagedType.FunctionPtr) + @" +delegate int MyDelegate(int a);"; + + public static string BlittableStructParametersAndModifiers = BasicParametersAndModifiers("MyStruct") + @" +#pragma warning disable CS0169 +[BlittableType] +struct MyStruct +{ + private int i; + private short s; +}"; + public static string GenericBlittableStructParametersAndModifiers = BasicParametersAndModifiers("MyStruct") + @" +#pragma warning disable CS0169 +[BlittableType] +struct MyStruct +{ + private T t; + private short s; +}"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index 1ecd120dbf7e1..33b741e8ad250 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -86,6 +86,10 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.DelegateParametersAndModifiers }; + yield return new[] { CodeSnippets.DelegateMarshalAsParametersAndModifiers }; + yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; + yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs index 285b4096cc303..e049ce9d4e556 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs @@ -569,7 +569,7 @@ public Native(S s, Span buffer) {} }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(11, 1, 15, 2).WithArguments("Native")); + VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(11, 1, 17, 2).WithArguments("Native")); } [Fact] @@ -596,7 +596,7 @@ public Native(S s, Span buffer) {} }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(12, 1, 17, 2).WithArguments("Native"), + VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(12, 1, 19, 2).WithArguments("Native"), VerifyCS.Diagnostic(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule).WithSpan(5, 2, 5, 35).WithArguments("S", "Native")); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs new file mode 100644 index 0000000000000..ddf2c4203111c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs @@ -0,0 +1,10 @@ +// Types defined to enable language support of various features +// in the source generator. + + +namespace System.Runtime.CompilerServices +{ + // Define IsExternalInit type to support records. + internal class IsExternalInit + {} +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs index 9f32c5c9b2886..a58c81291b7cb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -164,11 +164,11 @@ private void PrepareForAnalysis(CompilationStartAnalysisContext context) var marshalUsingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute); var spanOfByte = context.Compilation.GetTypeByMetadataName(TypeNames.System_Span)!.Construct(context.Compilation.GetSpecialType(SpecialType.System_Byte)); - if (generatedMarshallingAttribute is not null && - blittableTypeAttribute is not null && - nativeMarshallingAttribute is not null && - marshalUsingAttribute is not null && - spanOfByte is not null) + if (generatedMarshallingAttribute is not null + && blittableTypeAttribute is not null + && nativeMarshallingAttribute is not null + && marshalUsingAttribute is not null + && spanOfByte is not null) { var perCompilationAnalyzer = new PerCompilationAnalyzer( generatedMarshallingAttribute, @@ -312,12 +312,10 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb { continue; } - if (ctor.Parameters.Length == 1 && SymbolEqualityComparer.Default.Equals(type, ctor.Parameters[0].Type)) - { - hasConstructor = true; - } - if (ctor.Parameters.Length == 2 && SymbolEqualityComparer.Default.Equals(type, ctor.Parameters[0].Type) - && SymbolEqualityComparer.Default.Equals(SpanOfByte, ctor.Parameters[1].Type)) + + hasConstructor = hasConstructor || ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type); + + if (!hasStackallocConstructor && ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, SpanOfByte)) { hasStackallocConstructor = true; IFieldSymbol stackAllocSizeField = nativeType.GetMembers("StackBufferSize").OfType().FirstOrDefault(); @@ -328,9 +326,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb } } - bool hasToManaged = marshalerType.GetMembers("ToManaged") - .OfType() - .Any(m => m.Parameters.IsEmpty && !m.ReturnsByRef && !m.ReturnsByRefReadonly && SymbolEqualityComparer.Default.Equals(m.ReturnType, type) && !m.IsStatic); + bool hasToManaged = ManualTypeMarshallingHelper.HasToManagedMethod(marshalerType, type); // Validate that the native type has at least one marshalling method (either managed to native or native to managed) if (!hasConstructor && !hasStackallocConstructor && !hasToManaged) @@ -344,7 +340,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb context.ReportDiagnostic(Diagnostic.Create(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, GetSyntaxReferenceForDiagnostic(marshalerType).GetSyntax().GetLocation(), marshalerType.ToDisplayString())); } - IPropertySymbol? valueProperty = nativeType.GetMembers("Value").OfType().FirstOrDefault(); + IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); if (valueProperty is not null) { nativeType = valueProperty.Type; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs new file mode 100644 index 0000000000000..f309d3127048f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs @@ -0,0 +1,69 @@ +#nullable enable + +using System.Linq; +using Microsoft.CodeAnalysis; + +namespace Microsoft.Interop +{ + static class ManualTypeMarshallingHelper + { + public const string ValuePropertyName = "Value"; + public const string StackBufferSizeFieldName = "StackBufferSize"; + public const string ToManagedMethodName = "ToManaged"; + public const string FreeNativeMethodName = "FreeNative"; + + public static bool HasToManagedMethod(ITypeSymbol nativeType, ITypeSymbol managedType) + { + return nativeType.GetMembers(ToManagedMethodName) + .OfType() + .Any(m => m.Parameters.IsEmpty + && !m.ReturnsByRef + && !m.ReturnsByRefReadonly + && SymbolEqualityComparer.Default.Equals(m.ReturnType, managedType) + && !m.IsStatic); + } + + public static bool IsManagedToNativeConstructor(IMethodSymbol ctor, ITypeSymbol managedType) + { + return ctor.Parameters.Length == 1 + && SymbolEqualityComparer.Default.Equals(managedType, ctor.Parameters[0].Type); + } + + public static bool IsStackallocConstructor( + IMethodSymbol ctor, + ITypeSymbol managedType, + ITypeSymbol spanOfByte) + { + return ctor.Parameters.Length == 2 + && SymbolEqualityComparer.Default.Equals(managedType, ctor.Parameters[0].Type) + && SymbolEqualityComparer.Default.Equals(spanOfByte, ctor.Parameters[1].Type); + } + + public static IMethodSymbol? FindGetPinnableReference(ITypeSymbol type) + { + // Lookup a GetPinnableReference method based on the spec for the pattern-based + // fixed statement. We aren't supporting a GetPinnableReference extension method + // (which is apparently supported in the compiler). + // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.3/pattern-based-fixed + return type.GetMembers("GetPinnableReference") + .OfType() + .FirstOrDefault(m => m is { Parameters: { Length: 0 } } and + ({ ReturnsByRef: true } or { ReturnsByRefReadonly: true })); + } + + public static IPropertySymbol? FindValueProperty(ITypeSymbol type) + { + return type.GetMembers(ValuePropertyName) + .OfType() + .FirstOrDefault(p => !p.IsStatic); + } + + public static bool HasFreeNativeMethod(ITypeSymbol type) + { + return type.GetMembers(FreeNativeMethodName) + .OfType() + .Any(m => m is { Parameters: { Length: 0 } } and + ({ ReturnType: { SpecialType: SpecialType.System_Void } })); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NumericMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs similarity index 63% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NumericMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs index 616e29b1e0ea8..49143d11bf841 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NumericMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs @@ -7,7 +7,7 @@ namespace Microsoft.Interop { - internal class NumericMarshaller : IMarshallingGenerator + internal class BlittableMarshaller : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { @@ -25,23 +25,48 @@ public ParameterSyntax AsParameter(TypePositionInfo info) public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - if (info.IsByRef) + if (!info.IsByRef) { - return Argument( + return Argument(IdentifierName(info.InstanceIdentifier)); + } + else if (context.PinningSupported) + { + return Argument(IdentifierName(context.GetIdentifiers(info).native)); + + } + return Argument( PrefixUnaryExpression( SyntaxKind.AddressOfExpression, IdentifierName(context.GetIdentifiers(info).native))); - } - - return Argument(IdentifierName(info.InstanceIdentifier)); } public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { - if (!info.IsByRef || info.IsManagedReturnPosition) + if (!UsesNativeIdentifier(info, context)) yield break; (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + + if (context.PinningSupported) + { + if (context.CurrentStage == StubCodeContext.Stage.Pin) + { + yield return FixedStatement( + VariableDeclaration( + PointerType(AsNativeType(info)), + SingletonSeparatedList( + VariableDeclarator(Identifier(nativeIdentifier)) + .WithInitializer(EqualsValueClause( + PrefixUnaryExpression(SyntaxKind.AddressOfExpression, + IdentifierName(managedIdentifier)) + )) + ) + ), + EmptyStatement() + ); + } + yield break; + } switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: @@ -73,6 +98,11 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont break; } } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return info.IsByRef && !info.IsManagedReturnPosition; + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs index 3dfbbbbf56600..14599fab49d6b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics; using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; @@ -8,24 +9,23 @@ namespace Microsoft.Interop { - internal class BoolMarshaller : IMarshallingGenerator + internal abstract class BoolMarshallerBase : IMarshallingGenerator { - public TypeSyntax AsNativeType(TypePositionInfo info) + private readonly PredefinedTypeSyntax _nativeType; + private readonly int _trueValue; + private readonly int _falseValue; + + protected BoolMarshallerBase(PredefinedTypeSyntax nativeType, int trueValue, int falseValue) { - var syntax = SyntaxKind.ByteKeyword; - if (info.MarshalAsInfo != null) - { - syntax = info.MarshalAsInfo.UnmanagedType switch - { - UnmanagedType.Bool => SyntaxKind.IntKeyword, - UnmanagedType.U1 => SyntaxKind.ByteKeyword, - UnmanagedType.I1 => SyntaxKind.SByteKeyword, - UnmanagedType.VariantBool => SyntaxKind.ShortKeyword, - _ => SyntaxKind.ByteKeyword - }; - } + _nativeType = nativeType; + _trueValue = trueValue; + _falseValue = falseValue; + } - return PredefinedType(Token(syntax)); + public TypeSyntax AsNativeType(TypePositionInfo info) + { + Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Boolean); + return _nativeType; } public ParameterSyntax AsParameter(TypePositionInfo info) @@ -57,9 +57,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - if (info.IsManagedReturnPosition) - nativeIdentifier = context.GenerateReturnNativeIdentifier(); - yield return LocalDeclarationStatement( VariableDeclaration( AsNativeType(info), @@ -67,7 +64,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont break; case StubCodeContext.Stage.Marshal: - // = ()( ? 1 : 0); + // = ()( ? _trueValue : _falseValue); if (info.RefKind != RefKind.Out) { yield return ExpressionStatement( @@ -78,13 +75,13 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont AsNativeType(info), ParenthesizedExpression( ConditionalExpression(IdentifierName(managedIdentifier), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))))); + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(_trueValue)), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(_falseValue))))))); } break; case StubCodeContext.Stage.Unmarshal: - if (info.IsManagedReturnPosition || info.IsByRef) + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { // = != 0; yield return ExpressionStatement( @@ -94,12 +91,40 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont BinaryExpression( SyntaxKind.NotEqualsExpression, IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))); + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(_falseValue))))); } break; default: break; } } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + } + + internal class CBoolMarshaller : BoolMarshallerBase + { + public CBoolMarshaller() + : base(PredefinedType(Token(SyntaxKind.ByteKeyword)), 0, 1) + { + } + } + + internal class WinBoolMarshaller : BoolMarshallerBase + { + public WinBoolMarshaller() + : base(PredefinedType(Token(SyntaxKind.IntKeyword)), 0, 1) + { + } + } + + internal class VariantBoolMarshaller : BoolMarshallerBase + { + private const short VARIANT_TRUE = -1; + private const short VARIANT_FALSE = 0; + public VariantBoolMarshaller() + : base(PredefinedType(Token(SyntaxKind.ShortKeyword)), VARIANT_TRUE, VARIANT_FALSE) + { + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs new file mode 100644 index 0000000000000..bf2669ecb979a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + class DelegateMarshaller : IMarshallingGenerator + { + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return ParseTypeName("global::System.IntPtr"); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + // [TODO] Handle byrefs in a more common place? + // This pattern will become very common (arrays and strings will also use it) + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList( + VariableDeclarator(nativeIdentifier)))); + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + // = != null ? Marshal.GetFunctionPointerForDelegate() : default; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + ConditionalExpression( + BinaryExpression( + SyntaxKind.NotEqualsExpression, + IdentifierName(managedIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression) + ), + InvocationExpression( + ParseName("global::System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate"), + ArgumentList(SingletonSeparatedList(Argument(IdentifierName(managedIdentifier))))), + LiteralExpression(SyntaxKind.DefaultLiteralExpression)))); + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + // = != default : Marshal.GetDelegateForFunctionPointer<>() : null; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + ConditionalExpression( + BinaryExpression( + SyntaxKind.NotEqualsExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.DefaultLiteralExpression)), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseName("global::System.Runtime.InteropServices.Marshal"), + GenericName(Identifier("GetDelegateForFunctionPointer")) + .WithTypeArgumentList( + TypeArgumentList( + SingletonSeparatedList( + info.ManagedType.AsTypeSyntax())))), + ArgumentList(SingletonSeparatedList(Argument(IdentifierName(nativeIdentifier))))), + LiteralExpression(SyntaxKind.NullLiteralExpression)))); + } + break; + case StubCodeContext.Stage.KeepAlive: + if (info.RefKind != RefKind.Out) + { + yield return ExpressionStatement( + InvocationExpression( + ParseName("global::System.GC.KeepAlive"), + ArgumentList(SingletonSeparatedList(Argument(IdentifierName(managedIdentifier)))))); + } + break; + default: + break; + } + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs index 20e02e4ae87b8..53601890de5bf 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs @@ -30,5 +30,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont { return Array.Empty(); } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 47b6394f95e26..2e50dcc2df0d8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; - +using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -45,15 +45,27 @@ internal interface IMarshallingGenerator /// will be ignored. /// IEnumerable Generate(TypePositionInfo info, StubCodeContext context); + + /// + /// Returns whether or not this marshaller uses an identifier for the native value in addition + /// to an identifer for the managed value. + /// + /// Object to marshal + /// Code generation context + /// If the marshaller uses an identifier for the native value, true; otherwise, false. + bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); } internal class MarshallingGenerators { - public static readonly BoolMarshaller Bool = new BoolMarshaller(); + public static readonly CBoolMarshaller CBool = new CBoolMarshaller(); + public static readonly WinBoolMarshaller WinBool = new WinBoolMarshaller(); + public static readonly VariantBoolMarshaller VariantBool = new VariantBoolMarshaller(); public static readonly Forwarder Forwarder = new Forwarder(); - public static readonly NumericMarshaller Numeric = new NumericMarshaller(); + public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); + public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); - public static bool TryCreate(TypePositionInfo info, out IMarshallingGenerator generator) + public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out IMarshallingGenerator generator) { #if GENERATE_FORWARDER generator = MarshallingGenerators.Forwarder; @@ -65,26 +77,57 @@ public static bool TryCreate(TypePositionInfo info, out IMarshallingGenerator ge // Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Int32) } - switch (info.ManagedType.SpecialType) + switch (info) { - case SpecialType.System_SByte: - case SpecialType.System_Byte: - case SpecialType.System_Int16: - case SpecialType.System_UInt16: - case SpecialType.System_Int32: - case SpecialType.System_UInt32: - case SpecialType.System_Int64: - case SpecialType.System_UInt64: - case SpecialType.System_Single: - case SpecialType.System_Double: - generator = MarshallingGenerators.Numeric; + // Blittable primitives with no marshalling info or with a compatible [MarshalAs] attribute. + case { ManagedType: { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I1 } } + or { ManagedType: { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U1 } } + or { ManagedType: { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I2 } } + or { ManagedType: { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U2 } } + or { ManagedType: { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I4 } } + or { ManagedType: { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U4 } } + or { ManagedType: { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I8 } } + or { ManagedType: { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U8 } } + or { ManagedType: { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: null } + or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: null} + or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.R4 } } + or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.R8 } }: + generator = Blittable; + return true; + + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: null }: + generator = CBool; + return true; + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I1 or UnmanagedType.U1 } }: + generator = CBool; + return true; + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I4 or UnmanagedType.U4 } }: + generator = WinBool; + return true; + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.VariantBool } }: + generator = VariantBool; return true; - case SpecialType.System_Boolean: - generator = MarshallingGenerators.Bool; + case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.FunctionPtr } }: + generator = Delegate; return true; + + case { MarshallingAttributeInfo: BlittableTypeAttributeInfo _ }: + generator = Blittable; + return true; + + // Marshalling in new model + case { MarshallingAttributeInfo: NativeMarshallingAttributeInfo marshalInfo }: + generator = Forwarder; + return false; + + // Simple marshalling with new attribute model, only have type name. + case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo { NativeMarshallingFullyQualifiedTypeName: string name } }: + generator = Forwarder; + return false; + default: - generator = MarshallingGenerators.Forwarder; + generator = Forwarder; return false; } #endif diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs new file mode 100644 index 0000000000000..a4736aa155a8f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -0,0 +1,58 @@ +using Microsoft.CodeAnalysis; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; + +#nullable enable + +namespace Microsoft.Interop +{ + // The following types are modeled to fit with the current prospective spec + // for C# 10 discriminated unions. Once discriminated unions are released, + // these should be updated to be implemented as a discriminated union. + + internal abstract record MarshallingAttributeInfo {} + + /// + /// User-applied System.Runtime.InteropServices.MarshalAsAttribute + /// + internal sealed record MarshalAsInfo( + UnmanagedType UnmanagedType, + string? CustomMarshallerTypeName, + string? CustomMarshallerCookie, + UnmanagedType UnmanagedArraySubType, + int ArraySizeConst, + short ArraySizeParamIndex) : MarshallingAttributeInfo; + + /// + /// User-applied System.Runtime.InteropServices.BlittableTypeAttribute + /// or System.Runtime.InteropServices.GeneratedMarshallingAttribute on a blittable type + /// in source in this compilation. + /// + internal sealed record BlittableTypeAttributeInfo : MarshallingAttributeInfo; + + [Flags] + internal enum SupportedMarshallingMethods + { + ManagedToNative = 0x1, + NativeToManaged = 0x2, + ManagedToNativeStackalloc = 0x4, + Pinning = 0x8 + } + + /// + /// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute + /// + internal sealed record NativeMarshallingAttributeInfo( + ITypeSymbol NativeMarshallingType, + ITypeSymbol? ValuePropertyType, + SupportedMarshallingMethods MarshallingMethods) : MarshallingAttributeInfo; + + /// + /// User-applied System.Runtime.InteropServices.GeneratedMarshallingAttribute + /// on a non-blittable type in source in this compilation. + /// + internal sealed record GeneratedNativeMarshallingAttributeInfo( + string NativeMarshallingFullyQualifiedTypeName) : MarshallingAttributeInfo; +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index 0aca8cc6a2391..10c254234fcfc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -41,70 +41,30 @@ public enum Stage /// /// Perform any cleanup required /// - Cleanup + Cleanup, + + /// + /// Keep alive any managed objects that need to stay alive across the call. + /// + KeepAlive } public Stage CurrentStage { get; protected set; } - /// - /// Identifier for managed return value - /// - public const string ReturnIdentifier = "__retVal"; - - /// - /// Identifier for native return value - /// - /// Same as the managed identifier by default - public string ReturnNativeIdentifier { get; private set; } = ReturnIdentifier; - - private const string InvokeReturnIdentifier = "__invokeRetVal"; - private const string generatedNativeIdentifierSuffix = "_gen_native"; + public abstract bool PinningSupported { get; } - /// - /// Generate an identifier for the native return value and update the context with the new value - /// - /// Identifier for the native return value - public string GenerateReturnNativeIdentifier() - { - if (CurrentStage != Stage.Setup) - throw new InvalidOperationException(); + public abstract bool StackSpaceUsable { get; } - // Update the native identifier for the return value - ReturnNativeIdentifier = $"{ReturnIdentifier}{generatedNativeIdentifierSuffix}"; - return ReturnNativeIdentifier; - } + protected const string GeneratedNativeIdentifierSuffix = "_gen_native"; /// /// Get managed and native instance identifiers for the /// /// Object for which to get identifiers /// Managed and native identifiers - public (string managed, string native) GetIdentifiers(TypePositionInfo info) + public virtual (string managed, string native) GetIdentifiers(TypePositionInfo info) { - string managedIdentifier; - string nativeIdentifier; - if (info.IsManagedReturnPosition && !info.IsNativeReturnPosition) - { - managedIdentifier = ReturnIdentifier; - nativeIdentifier = ReturnNativeIdentifier; - } - else if (!info.IsManagedReturnPosition && info.IsNativeReturnPosition) - { - managedIdentifier = InvokeReturnIdentifier; - nativeIdentifier = InvokeReturnIdentifier; - } - else - { - managedIdentifier = info.IsManagedReturnPosition - ? ReturnIdentifier - : info.InstanceIdentifier; - - nativeIdentifier = info.IsNativeReturnPosition - ? ReturnNativeIdentifier - : $"__{info.InstanceIdentifier}{generatedNativeIdentifierSuffix}"; - } - - return (managedIdentifier, nativeIdentifier); + return (info.InstanceIdentifier, $"__{info.InstanceIdentifier}{GeneratedNativeIdentifierSuffix}"); } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 8a32f3f1c67e3..e7e870bf888fd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -16,20 +17,79 @@ private StubCodeGenerator(Stage stage) CurrentStage = stage; } + public override bool PinningSupported => true; + + public override bool StackSpaceUsable => true; + + /// + /// Identifier for managed return value + /// + public const string ReturnIdentifier = "__retVal"; + + /// + /// Identifier for native return value + /// + /// Same as the managed identifier by default + public string ReturnNativeIdentifier { get; private set; } = ReturnIdentifier; + + private const string InvokeReturnIdentifier = "__invokeRetVal"; + + /// + /// Generate an identifier for the native return value and update the context with the new value + /// + /// Identifier for the native return value + public void GenerateReturnNativeIdentifier() + { + if (CurrentStage != Stage.Setup) + throw new InvalidOperationException(); + + // Update the native identifier for the return value + ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; + } + + public override (string managed, string native) GetIdentifiers(TypePositionInfo info) + { + if (info.IsManagedReturnPosition && !info.IsNativeReturnPosition) + { + return (ReturnIdentifier, ReturnNativeIdentifier); + } + else if (!info.IsManagedReturnPosition && info.IsNativeReturnPosition) + { + return (InvokeReturnIdentifier, InvokeReturnIdentifier); + } + else if (info.IsManagedReturnPosition && info.IsNativeReturnPosition) + { + return (ReturnIdentifier, ReturnNativeIdentifier); + } + else + { + // If the info isn't in either the managed or native return position, + // then we can use the base implementation since we have an identifier name provided + // in the original metadata. + return base.GetIdentifiers(info); + } + } + public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSyntax( IMethodSymbol stubMethod, IEnumerable paramsTypeInfo, TypePositionInfo retTypeInfo) { Debug.Assert(retTypeInfo.IsNativeReturnPosition); + + var context = new StubCodeGenerator(Stage.Setup); string dllImportName = stubMethod.Name + "__PInvoke__"; - var paramMarshallers = paramsTypeInfo.Select(p => GetMarshalInfo(p)).ToList(); - var retMarshaller = GetMarshalInfo(retTypeInfo); + var paramMarshallers = paramsTypeInfo.Select(p => GetMarshalInfo(p, context)).ToList(); + var retMarshaller = GetMarshalInfo(retTypeInfo, context); - var context = new StubCodeGenerator(Stage.Setup); var statements = new List(); + if (retMarshaller.Generator.UsesNativeIdentifier(retTypeInfo, context)) + { + context.GenerateReturnNativeIdentifier(); + } + foreach (var marshaller in paramMarshallers) { TypePositionInfo info = marshaller.TypeInfo; @@ -79,6 +139,7 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt Stage.Marshal, Stage.Pin, Stage.Invoke, + Stage.KeepAlive, Stage.Unmarshal, Stage.Cleanup }; @@ -196,10 +257,10 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt return (codeBlock, dllImport); } - private static (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) GetMarshalInfo(TypePositionInfo info) + private static (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) GetMarshalInfo(TypePositionInfo info, StubCodeContext context) { IMarshallingGenerator generator; - if (!MarshallingGenerators.TryCreate(info, out generator)) + if (!MarshallingGenerators.TryCreate(info, context, out generator)) { // [TODO] Report warning } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 37f10eab3c795..27481eb846e80 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -17,5 +17,7 @@ static class TypeNames public const string System_Span = "System.Span`1"; public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; + + public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 355b897873cce..17badcfb34050 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -2,27 +2,13 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; - +using DllImportGenerator; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.Interop { - /// - /// Collected MarshalAsAttribute info. - /// - internal sealed class MarshalAsInfo - { - public UnmanagedType UnmanagedType { get; set; } - public string CustomMarshallerTypeName { get; set; } - public string CustomMarshallerCookie { get; set; } - - public UnmanagedType UnmanagedArraySubType { get; set; } - public int ArraySizeConst { get; set; } - public short ArraySizeParamIndex { get; set; } - } - /// /// Positional type information involved in unmanaged/managed scenarios. /// @@ -44,7 +30,7 @@ private TypePositionInfo() public RefKind RefKind { get; private set; } public SyntaxKind RefKindSyntax { get; private set; } - public bool IsByRef => RefKind == RefKind.Ref || RefKind == RefKind.Out; + public bool IsByRef => RefKind != RefKind.None; public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } public bool IsNativeReturnPosition { get => this.NativeIndex == ReturnIndex; } @@ -53,63 +39,115 @@ private TypePositionInfo() public int NativeIndex { get; set; } public int UnmanagedLCIDConversionArgIndex { get; private set; } - public MarshalAsInfo MarshalAsInfo { get; private set; } + public MarshallingAttributeInfo MarshallingAttributeInfo { get; private set; } public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, Compilation compilation) { + var marshallingInfo = GetMarshallingAttributeInfo(paramSymbol.Type, paramSymbol.GetAttributes(), compilation); var typeInfo = new TypePositionInfo() { ManagedType = paramSymbol.Type, InstanceIdentifier = paramSymbol.Name, RefKind = paramSymbol.RefKind, - RefKindSyntax = RefKindToSyntax(paramSymbol.RefKind) + RefKindSyntax = RefKindToSyntax(paramSymbol.RefKind), + MarshallingAttributeInfo = marshallingInfo }; - UpdateWithAttributeData(paramSymbol.GetAttributes(), ref typeInfo); - return typeInfo; } public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation) { + var marshallingInfo = GetMarshallingAttributeInfo(type, attributes, compilation); var typeInfo = new TypePositionInfo() { ManagedType = type, InstanceIdentifier = string.Empty, RefKind = RefKind.None, RefKindSyntax = SyntaxKind.None, + MarshallingAttributeInfo = marshallingInfo }; - UpdateWithAttributeData(attributes, ref typeInfo); - return typeInfo; } - private static void UpdateWithAttributeData(IEnumerable attributes, ref TypePositionInfo typeInfo) +#nullable enable + private static MarshallingAttributeInfo? GetMarshallingAttributeInfo(ITypeSymbol type, IEnumerable attributes, Compilation compilation) { + MarshallingAttributeInfo? marshallingInfo = null; // Look at attributes on the type. foreach (var attrData in attributes) { - string attributeName = attrData.AttributeClass.Name; + INamedTypeSymbol attributeClass = attrData.AttributeClass!; - if (nameof(MarshalAsAttribute).Equals(attributeName)) + if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) { + if (marshallingInfo is not null) + { + // TODO: diagnostic + } // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute - typeInfo.MarshalAsInfo = CreateMarshalAsInfo(attrData); + marshallingInfo = CreateMarshalAsInfo(attrData); } - else if (nameof(LCIDConversionAttribute).Equals(attributeName)) + else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) { - // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute - typeInfo.UnmanagedLCIDConversionArgIndex = (int)attrData.ConstructorArguments[0].Value; + if (marshallingInfo is not null) + { + // TODO: diagnostic + } + marshallingInfo = CreateNativeMarshallingInfo(attrData, false); + } + } + + // If we aren't overriding the marshalling at usage time, + // then fall back to the information on the element type itself. + if (marshallingInfo is null) + { + foreach (var attrData in type.GetAttributes()) + { + INamedTypeSymbol attributeClass = attrData.AttributeClass!; + + if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute), attributeClass)) + { + if (marshallingInfo is not null) + { + // TODO: diagnostic + } + marshallingInfo = new BlittableTypeAttributeInfo(); + } + else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute), attributeClass)) + { + if (marshallingInfo is not null) + { + // TODO: diagnostic + } + marshallingInfo = CreateNativeMarshallingInfo(attrData, true); + } + else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute), attributeClass)) + { + if (marshallingInfo is not null) + { + // TODO: diagnostic + } + marshallingInfo = type.IsConsideredBlittable() ? new BlittableTypeAttributeInfo() : new GeneratedNativeMarshallingAttributeInfo(null! /* TODO: determine naming convention */); + } } } + return marshallingInfo; + static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData) { - var info = new MarshalAsInfo + UnmanagedType unmanagedType = (UnmanagedType)attrData.ConstructorArguments[0].Value!; + if (unmanagedType == 0) { - UnmanagedType = (UnmanagedType)attrData.ConstructorArguments[0].Value - }; + // [TODO] diagnostic + } + string? customMarshallerTypeName = null; + string? customMarshallerCookie = null; + UnmanagedType unmanagedArraySubType = 0; + int arraySizeConst = 0; + short arraySizeParamIndex = 0; // All other data on attribute is defined as NamedArguments. foreach (var namedArg in attrData.NamedArguments) @@ -127,26 +165,77 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData) case nameof(MarshalAsAttribute.MarshalTypeRef): case nameof(MarshalAsAttribute.MarshalType): // Call ToString() to handle INamedTypeSymbol as well. - info.CustomMarshallerTypeName = namedArg.Value.Value.ToString(); + customMarshallerTypeName = namedArg.Value.Value!.ToString(); break; case nameof(MarshalAsAttribute.MarshalCookie): - info.CustomMarshallerCookie = (string)namedArg.Value.Value; + customMarshallerCookie = (string)namedArg.Value.Value!; break; case nameof(MarshalAsAttribute.ArraySubType): - info.UnmanagedArraySubType = (UnmanagedType)namedArg.Value.Value; + unmanagedArraySubType = (UnmanagedType)namedArg.Value.Value!; break; case nameof(MarshalAsAttribute.SizeConst): - info.ArraySizeConst = (int)namedArg.Value.Value; + arraySizeConst = (int)namedArg.Value.Value!; break; case nameof(MarshalAsAttribute.SizeParamIndex): - info.ArraySizeParamIndex = (short)namedArg.Value.Value; + arraySizeParamIndex = (short)namedArg.Value.Value!; break; } + + } + + return new MarshalAsInfo( + UnmanagedType: unmanagedType, + CustomMarshallerTypeName: customMarshallerTypeName, + CustomMarshallerCookie: customMarshallerCookie, + UnmanagedArraySubType: unmanagedArraySubType, + ArraySizeConst: arraySizeConst, + ArraySizeParamIndex: arraySizeParamIndex + ); + } + + NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(AttributeData attrData, bool allowGetPinnableReference) + { + ITypeSymbol spanOfByte = compilation.GetTypeByMetadataName(TypeNames.System_Span)!.Construct(compilation.GetSpecialType(SpecialType.System_Byte)); + INamedTypeSymbol nativeType = (INamedTypeSymbol)attrData.ConstructorArguments[0].Value!; + SupportedMarshallingMethods methods = 0; + IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); + foreach (var ctor in nativeType.Constructors) + { + if (ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type) + && (valueProperty is null or { GetMethod: not null })) + { + methods |= SupportedMarshallingMethods.ManagedToNative; + } + else if (ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, spanOfByte) + && (valueProperty is null or { GetMethod: not null })) + { + methods |= SupportedMarshallingMethods.ManagedToNativeStackalloc; + } + } + + if (ManualTypeMarshallingHelper.HasToManagedMethod(nativeType, type) + && (valueProperty is null or { SetMethod: not null })) + { + methods |= SupportedMarshallingMethods.NativeToManaged; + } + + if (allowGetPinnableReference && ManualTypeMarshallingHelper.FindGetPinnableReference(type) != null) + { + methods |= SupportedMarshallingMethods.Pinning; + } + + if (methods == 0) + { + // TODO: Diagnostic since no marshalling methods are supported. } - return info; + return new NativeMarshallingAttributeInfo( + nativeType, + valueProperty?.Type, + methods); } } +#nullable restore private static SyntaxKind RefKindToSyntax(RefKind refKind) { From ff96442afa196ce9f5001f01067a1c567b7bd673 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 29 Sep 2020 16:35:55 -0700 Subject: [PATCH 020/161] Fix true and false for the Bool marshaller (dotnet/runtimelab#130) Commit migrated from https://github.com/dotnet/runtimelab/commit/37705c3bd1310e59ce518bd89ce32d2a99e79d0e --- .../gen/DllImportGenerator/Marshalling/BoolMarshaller.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs index 14599fab49d6b..a0416bbf730c3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs @@ -105,7 +105,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont internal class CBoolMarshaller : BoolMarshallerBase { public CBoolMarshaller() - : base(PredefinedType(Token(SyntaxKind.ByteKeyword)), 0, 1) + : base(PredefinedType(Token(SyntaxKind.ByteKeyword)), trueValue: 1, falseValue: 0) { } } @@ -113,7 +113,7 @@ public CBoolMarshaller() internal class WinBoolMarshaller : BoolMarshallerBase { public WinBoolMarshaller() - : base(PredefinedType(Token(SyntaxKind.IntKeyword)), 0, 1) + : base(PredefinedType(Token(SyntaxKind.IntKeyword)), trueValue: 1, falseValue: 0) { } } From 40a5e2b7ce53d24a9516851f7a75445d760d287c Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Sep 2020 23:30:53 -0700 Subject: [PATCH 021/161] Update CreateAnExperiment.md Commit migrated from https://github.com/dotnet/runtimelab/commit/8497669c8d619e3164e36ab00df221e3cd8a41b0 --- CreateAnExperiment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CreateAnExperiment.md b/CreateAnExperiment.md index 39b089c7deee7..c6073628ae6cb 100644 --- a/CreateAnExperiment.md +++ b/CreateAnExperiment.md @@ -10,5 +10,5 @@ Experiments should be contained within a branch in the dotnet/runtimelab reposit - Submit a PR to update the [README.MD](https://github.com/dotnet/runtimelab/blob/master/README.md#active-experimental-projects) with the name of your branch and a brief description of the experiment. Example: [#19](https://github.com/dotnet/runtimelab/pull/19/files) - Create label `area-` for tagging issues. The label should use color `#d4c5f9`. - If your experiment is branched from dotnet/runtime: - - Enable CI builds by editing `eng/pipelines/runtimelab.yml` in your branch. Example: [#25](https://github.com/dotnet/runtimelab/pull/25/files) + - Enable CI builds by editing `eng/pipelines/runtimelab.yml` in your branch. Example: [#137](https://github.com/dotnet/runtimelab/pull/137/files) - To avoid spurious github notifications for merges from upstream, delete `.github/CODEOWNERS` from your branch or replace it with setting specific to your experiment. Example: [#26](https://github.com/dotnet/runtimelab/pull/26/files) From ea4e97959ec36f7a57fa98640137884e17e5cdb0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 5 Oct 2020 14:49:12 -0700 Subject: [PATCH 022/161] SafeHandle marshalling (dotnet/runtimelab#133) Co-authored-by: Jan Kotas Commit migrated from https://github.com/dotnet/runtimelab/commit/2cde5aa726f1b0ad08fd774d0bf84bd9eb5f7e62 --- .../gen/Directory.Build.props | 1 + .../gen/DllImportGenerator.Test/Compiles.cs | 1 + .../DllImportGenerator.Test.csproj | 2 +- .../Marshalling/MarshallingGenerator.cs | 5 + .../Marshalling/SafeHandleMarshaller.cs | 230 ++++++++++++++++++ .../MarshallingAttributeInfo.cs | 16 +- .../gen/DllImportGenerator/StubCodeContext.cs | 8 +- .../DllImportGenerator/StubCodeGenerator.cs | 3 +- .../gen/DllImportGenerator/TypeNames.cs | 6 +- .../DllImportGenerator/TypePositionInfo.cs | 28 ++- .../libraries/DllImportGenerator/Pipeline.md | 4 + .../Ancillary.Interop.csproj | 1 + .../GeneratedDllImportAttribute.cs | 3 +- .../tests/Ancillary.Interop/MarshalEx.cs | 29 +++ .../tests/TestAssets/NativeExports/Handles.cs | 54 ++++ .../DllImportGeneratorSample.csproj | 4 + .../DllImportGeneratorSample/Program.cs | 7 + .../SafeHandleTests.cs | 74 ++++++ 18 files changed, 460 insertions(+), 16 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs create mode 100644 src/samples/DllImportGeneratorSample/SafeHandleTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props index 81194ffe87da9..61ba7c1afc320 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props +++ b/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props @@ -2,6 +2,7 @@ 3.8.0-3.final + 2.4.1 diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs index 33b741e8ad250..3c66f36bbe6db 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs @@ -90,6 +90,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.DelegateMarshalAsParametersAndModifiers }; yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj index 75fb2cb381c85..cd384172bce4b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 2e50dcc2df0d8..60ef933582a81 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -64,6 +64,7 @@ internal class MarshallingGenerators public static readonly Forwarder Forwarder = new Forwarder(); public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); + public static readonly SafeHandleMarshaller SafeHandle = new SafeHandleMarshaller(); public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out IMarshallingGenerator generator) { @@ -126,6 +127,10 @@ public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out generator = Forwarder; return false; + case { MarshallingAttributeInfo: SafeHandleMarshallingInfo _}: + generator = SafeHandle; + return true; + default: generator = Forwarder; return false; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs new file mode 100644 index 0000000000000..041472a7446a3 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + class SafeHandleMarshaller : IMarshallingGenerator + { + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return ParseTypeName("global::System.IntPtr"); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + // The high level logic (note that the parameter may be in, out or both): + // 1) If this is an input parameter we need to AddRef the SafeHandle. + // 2) If this is an output parameter we need to preallocate a SafeHandle to wrap the new native handle value. We + // must allocate this before the native call to avoid a failure point when we already have a native resource + // allocated. We must allocate a new SafeHandle even if we have one on input since both input and output native + // handles need to be tracked and released by a SafeHandle. + // 3) Initialize a local IntPtr that will be passed to the native call. If we have an input SafeHandle the value + // comes from there otherwise we get it from the new SafeHandle (which is guaranteed to be initialized to an + // invalid handle value). + // 4) If this is a out parameter we also store the original handle value (that we just computed above) in a local + // variable. + // 5) If we successfully AddRef'd the incoming SafeHandle, we need to Release it before we return. + // 6) After the native call, if this is an output parameter and the handle value we passed to native differs from + // the local copy we made then the new handle value is written into the output SafeHandle and that SafeHandle + // is propagated back to the caller. + + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + string addRefdIdentifier = $"{managedIdentifier}__addRefd"; + string newHandleObjectIdentifier = info.IsManagedReturnPosition + ? managedIdentifier + : $"{managedIdentifier}__newHandle"; + string handleValueBackupIdentifier = $"{nativeIdentifier}__original"; + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList( + VariableDeclarator(nativeIdentifier)))); + if (!info.IsManagedReturnPosition && info.RefKind != RefKind.Out) + { + yield return LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.BoolKeyword)), + SingletonSeparatedList( + VariableDeclarator(addRefdIdentifier) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); + + } + if (info.IsByRef && info.RefKind != RefKind.In) + { + // We create the new handle in the Setup phase + // so we eliminate the possible failure points during unmarshalling, where we would + // leak the handle if we failed to create the handle. + yield return LocalDeclarationStatement( + VariableDeclaration( + info.ManagedType.AsTypeSyntax(), + SingletonSeparatedList( + VariableDeclarator(newHandleObjectIdentifier) + .WithInitializer(EqualsValueClause( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + GenericName(Identifier("CreateSafeHandle"), + TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), + ArgumentList())))))); + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList( + VariableDeclarator(handleValueBackupIdentifier) + .WithInitializer(EqualsValueClause( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(newHandleObjectIdentifier), + IdentifierName(nameof(SafeHandle.DangerousGetHandle))), + ArgumentList())))))); + } + else if (info.IsManagedReturnPosition) + { + yield return ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + GenericName(Identifier("CreateSafeHandle"), + TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), + ArgumentList()))); + } + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + // .DangerousAddRef(ref ); + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName(nameof(SafeHandle.DangerousAddRef))), + ArgumentList(SingletonSeparatedList( + Argument(IdentifierName(addRefdIdentifier)) + .WithRefKindKeyword(Token(SyntaxKind.RefKeyword)))))); + + + ExpressionSyntax assignHandleToNativeExpression = + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName(nameof(SafeHandle.DangerousGetHandle))), + ArgumentList())); + if (info.IsByRef && info.RefKind != RefKind.In) + { + yield return ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(handleValueBackupIdentifier), + assignHandleToNativeExpression)); + } + else + { + yield return ExpressionStatement(assignHandleToNativeExpression); + } + } + break; + case StubCodeContext.Stage.GuaranteedUnmarshal: + StatementSyntax unmarshalStatement = ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_MarshalEx), + IdentifierName("SetHandle")), + ArgumentList(SeparatedList( + new [] + { + Argument(IdentifierName(newHandleObjectIdentifier)), + Argument(IdentifierName(nativeIdentifier)) + })))); + + if(info.IsManagedReturnPosition) + { + yield return unmarshalStatement; + } + else if (info.RefKind == RefKind.Out) + { + yield return unmarshalStatement; + yield return ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + IdentifierName(newHandleObjectIdentifier))); + } + else if (info.RefKind == RefKind.Ref) + { + // Decrement refcount on original SafeHandle if we addrefd + yield return IfStatement( + IdentifierName(addRefdIdentifier), + ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName(nameof(SafeHandle.DangerousRelease))), + ArgumentList()))); + + // Do not unmarshal the handle if the value didn't change. + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(handleValueBackupIdentifier), + IdentifierName(nativeIdentifier)), + Block( + unmarshalStatement, + ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + IdentifierName(newHandleObjectIdentifier))))); + } + break; + case StubCodeContext.Stage.Cleanup: + if (!info.IsByRef || info.RefKind == RefKind.In) + { + yield return IfStatement( + IdentifierName(addRefdIdentifier), + ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName(nameof(SafeHandle.DangerousRelease))), + ArgumentList()))); + } + break; + default: + break; + } + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index a4736aa155a8f..0462c8cdd1915 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -12,7 +12,7 @@ namespace Microsoft.Interop // for C# 10 discriminated unions. Once discriminated unions are released, // these should be updated to be implemented as a discriminated union. - internal abstract record MarshallingAttributeInfo {} + internal abstract record MarshallingInfo {} /// /// User-applied System.Runtime.InteropServices.MarshalAsAttribute @@ -23,14 +23,14 @@ internal sealed record MarshalAsInfo( string? CustomMarshallerCookie, UnmanagedType UnmanagedArraySubType, int ArraySizeConst, - short ArraySizeParamIndex) : MarshallingAttributeInfo; + short ArraySizeParamIndex) : MarshallingInfo; /// /// User-applied System.Runtime.InteropServices.BlittableTypeAttribute /// or System.Runtime.InteropServices.GeneratedMarshallingAttribute on a blittable type /// in source in this compilation. /// - internal sealed record BlittableTypeAttributeInfo : MarshallingAttributeInfo; + internal sealed record BlittableTypeAttributeInfo : MarshallingInfo; [Flags] internal enum SupportedMarshallingMethods @@ -47,12 +47,18 @@ internal enum SupportedMarshallingMethods internal sealed record NativeMarshallingAttributeInfo( ITypeSymbol NativeMarshallingType, ITypeSymbol? ValuePropertyType, - SupportedMarshallingMethods MarshallingMethods) : MarshallingAttributeInfo; + SupportedMarshallingMethods MarshallingMethods) : MarshallingInfo; /// /// User-applied System.Runtime.InteropServices.GeneratedMarshallingAttribute /// on a non-blittable type in source in this compilation. /// internal sealed record GeneratedNativeMarshallingAttributeInfo( - string NativeMarshallingFullyQualifiedTypeName) : MarshallingAttributeInfo; + string NativeMarshallingFullyQualifiedTypeName) : MarshallingInfo; + + /// + /// The type of the element is a SafeHandle-derived type with no marshalling attributes. + /// + internal sealed record SafeHandleMarshallingInfo : MarshallingInfo; + } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index 10c254234fcfc..0b5f9fe0a862e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -46,7 +46,13 @@ public enum Stage /// /// Keep alive any managed objects that need to stay alive across the call. /// - KeepAlive + KeepAlive, + + /// + /// Convert native data to managed data even in the case of an exception during + /// the non-cleanup phases. + /// + GuaranteedUnmarshal } public Stage CurrentStage { get; protected set; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index e7e870bf888fd..043819bc068f3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -141,6 +141,7 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt Stage.Invoke, Stage.KeepAlive, Stage.Unmarshal, + Stage.GuaranteedUnmarshal, Stage.Cleanup }; @@ -151,7 +152,7 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt int initialCount = statements.Count; context.CurrentStage = stage; - if (!invokeReturnsVoid && (stage == Stage.Setup || stage == Stage.Unmarshal)) + if (!invokeReturnsVoid && (stage == Stage.Setup || stage == Stage.Unmarshal || stage == Stage.GuaranteedUnmarshal)) { // Handle setup and unmarshalling for return var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, context); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 27481eb846e80..284aa2a3694e3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace DllImportGenerator +namespace Microsoft.Interop { static class TypeNames { @@ -19,5 +19,9 @@ static class TypeNames public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; + + public const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; + + public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 17badcfb34050..e816f8457d794 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -39,11 +39,11 @@ private TypePositionInfo() public int NativeIndex { get; set; } public int UnmanagedLCIDConversionArgIndex { get; private set; } - public MarshallingAttributeInfo MarshallingAttributeInfo { get; private set; } + public MarshallingInfo MarshallingAttributeInfo { get; private set; } public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, Compilation compilation) { - var marshallingInfo = GetMarshallingAttributeInfo(paramSymbol.Type, paramSymbol.GetAttributes(), compilation); + var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), compilation); var typeInfo = new TypePositionInfo() { ManagedType = paramSymbol.Type, @@ -58,7 +58,7 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation) { - var marshallingInfo = GetMarshallingAttributeInfo(type, attributes, compilation); + var marshallingInfo = GetMarshallingInfo(type, attributes, compilation); var typeInfo = new TypePositionInfo() { ManagedType = type, @@ -72,9 +72,9 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation) + private static MarshallingInfo? GetMarshallingInfo(ITypeSymbol type, IEnumerable attributes, Compilation compilation) { - MarshallingAttributeInfo? marshallingInfo = null; + MarshallingInfo? marshallingInfo = null; // Look at attributes on the type. foreach (var attrData in attributes) { @@ -134,6 +134,11 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerablenet5.0 8.0 System.Runtime.InteropServices + enable diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs index 0f0d322da4dd8..42c15094915ab 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs @@ -1,5 +1,4 @@ -#nullable enable - + namespace System.Runtime.InteropServices { // [TODO] Remove once the attribute has been added to the BCL diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs new file mode 100644 index 0000000000000..95be96d868588 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -0,0 +1,29 @@ + +using System.Reflection; + +namespace System.Runtime.InteropServices +{ + /// + /// Marshalling helper methods that will likely live in S.R.IS.Marshal + /// when we integrate our APIs with dotnet/runtime. + /// + public static class MarshalEx + { + public static TSafeHandle CreateSafeHandle() + where TSafeHandle : SafeHandle + { + if (typeof(TSafeHandle).IsAbstract || typeof(TSafeHandle).GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance | BindingFlags.Instance, null, Type.EmptyTypes, null) == null) + { + throw new MissingMemberException($"The safe handle type '{typeof(TSafeHandle).FullName}' must be a non-abstract type with a parameterless constructor."); + } + + TSafeHandle safeHandle = (TSafeHandle)Activator.CreateInstance(typeof(TSafeHandle), nonPublic: true)!; + return safeHandle; + } + + public static void SetHandle(SafeHandle safeHandle, IntPtr handle) + { + typeof(SafeHandle).GetMethod("SetHandle", BindingFlags.NonPublic | BindingFlags.Instance)!.Invoke(safeHandle, new object[] { handle }); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs new file mode 100644 index 0000000000000..fae57f242fe57 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices; + + +namespace NativeExports +{ + public static unsafe class Handles + { + private const nint InvalidHandle = -1; + + private static nint LastHandle = 0; + + private static HashSet ActiveHandles = new HashSet(); + + [UnmanagedCallersOnly(EntryPoint = "alloc_handle")] + public static nint AllocateHandle() + { + return AllocateHandleCore(); + } + + private static nint AllocateHandleCore() + { + if (LastHandle == int.MaxValue) + { + return InvalidHandle; + } + + nint newHandle = ++LastHandle; + ActiveHandles.Add(newHandle); + return newHandle; + } + + [UnmanagedCallersOnly(EntryPoint = "release_handle")] + public static byte ReleaseHandle(nint handle) + { + return ActiveHandles.Remove(handle) ? 1 : 0; + } + + [UnmanagedCallersOnly(EntryPoint = "is_handle_alive")] + public static byte IsHandleAlive(nint handle) + { + return ActiveHandles.Contains(handle) ? 1 : 0; + } + + [UnmanagedCallersOnly(EntryPoint = "modify_handle")] + public static void ModifyHandle(nint* handle, byte newHandle) + { + if (newHandle != 0) + { + *handle = AllocateHandleCore(); + } + } + } +} \ No newline at end of file diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 4cee92efcd88d..fdba3fbbb3540 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index ff7d931ccd3c8..06715a76c7c09 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -31,6 +31,13 @@ static void Main(string[] args) c = b; NativeExportsNE.Sum(a, ref c); Console.WriteLine($"{a} + {b} = {c}"); + + SafeHandleTests tests = new SafeHandleTests(); + + tests.ReturnValue_CreatesSafeHandle(); + tests.ByValue_CorrectlyUnwrapsHandle(); + tests.ByRefSameValue_UsesSameHandleInstance(); + tests.ByRefDifferentValue_UsesNewHandleInstance(); } } } diff --git a/src/samples/DllImportGeneratorSample/SafeHandleTests.cs b/src/samples/DllImportGeneratorSample/SafeHandleTests.cs new file mode 100644 index 0000000000000..bb21cfb565caf --- /dev/null +++ b/src/samples/DllImportGeneratorSample/SafeHandleTests.cs @@ -0,0 +1,74 @@ + +using System.Runtime.InteropServices; +using Microsoft.Win32.SafeHandles; +using Xunit; + +namespace Demo +{ + partial class NativeExportsNE + { + public class NativeExportsSafeHandle : SafeHandleZeroOrMinusOneIsInvalid + { + private NativeExportsSafeHandle() : base(true) + { + } + + protected override bool ReleaseHandle() + { + Assert.True(NativeExportsNE.ReleaseHandle(handle)); + return true; + } + } + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "alloc_handle")] + public static partial NativeExportsSafeHandle AllocateHandle(); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "release_handle")] + [return:MarshalAs(UnmanagedType.I1)] + private static partial bool ReleaseHandle(nint handle); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "is_handle_alive")] + [return:MarshalAs(UnmanagedType.I1)] + public static partial bool IsHandleAlive(NativeExportsSafeHandle handle); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "modify_handle")] + public static partial void ModifyHandle(ref NativeExportsSafeHandle handle, [MarshalAs(UnmanagedType.I1)] bool newHandle); + } + + public class SafeHandleTests + { + [Fact] + public void ReturnValue_CreatesSafeHandle() + { + using NativeExportsNE.NativeExportsSafeHandle handle = NativeExportsNE.AllocateHandle(); + Assert.False(handle.IsClosed); + Assert.False(handle.IsInvalid); + } + + [Fact] + public void ByValue_CorrectlyUnwrapsHandle() + { + using NativeExportsNE.NativeExportsSafeHandle handle = NativeExportsNE.AllocateHandle(); + Assert.True(NativeExportsNE.IsHandleAlive(handle)); + } + + [Fact] + public void ByRefSameValue_UsesSameHandleInstance() + { + using NativeExportsNE.NativeExportsSafeHandle handleToDispose = NativeExportsNE.AllocateHandle(); + NativeExportsNE.NativeExportsSafeHandle handle = handleToDispose; + NativeExportsNE.ModifyHandle(ref handle, false); + Assert.Same(handleToDispose, handle); + } + + [Fact] + public void ByRefDifferentValue_UsesNewHandleInstance() + { + using NativeExportsNE.NativeExportsSafeHandle handleToDispose = NativeExportsNE.AllocateHandle(); + NativeExportsNE.NativeExportsSafeHandle handle = handleToDispose; + NativeExportsNE.ModifyHandle(ref handle, true); + Assert.NotSame(handleToDispose, handle); + handle.Dispose(); + } + } +} \ No newline at end of file From 04d8328555b16a721fd0bb4885b0845338ee9bb3 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 7 Oct 2020 18:47:07 -0700 Subject: [PATCH 023/161] Create test projects (dotnet/runtimelab#149) * Rename DllImportGenerator.Test to DllImportGenerator.UnitTests * Create an integration tests project. Update the SLN file. Remove SafeHandle test from Demo project. * Update readme.md Make the Demo project a user friendly example for learning about the methodology. Commit migrated from https://github.com/dotnet/runtimelab/commit/778ecfa4e1b31962318ceed823882759e1f5bf4a --- .../gen/readme.md | 31 ++++++++++++------- .../DllImportGenerator.Tests.csproj | 29 +++++++++++++++++ .../SafeHandleTests.cs | 18 +++++------ .../CodeSnippets.cs | 2 +- .../CompileFails.cs | 2 +- .../DllImportGenerator.UnitTests}/Compiles.cs | 2 +- .../DllImportGenerator.UnitTests.csproj} | 0 .../ManualTypeMarshallingAnalyzerTests.cs | 4 +-- .../TestUtils.cs | 2 +- .../Verifiers/CSharpAnalyzerVerifier.cs | 2 +- .../Verifiers/CSharpVerifierHelper.cs | 2 +- .../NativeExports/{ScalarOps.cs => Demo.cs} | 5 ++- .../tests/TestAssets/NativeExports/Handles.cs | 30 +++++++++--------- .../DllImportGeneratorSample.csproj | 4 --- .../DllImportGeneratorSample/Program.cs | 9 +----- 15 files changed, 84 insertions(+), 58 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj rename src/{samples/DllImportGeneratorSample => libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests}/SafeHandleTests.cs (84%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test => tests/DllImportGenerator.UnitTests}/CodeSnippets.cs (99%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test => tests/DllImportGenerator.UnitTests}/CompileFails.cs (96%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test => tests/DllImportGenerator.UnitTests}/Compiles.cs (99%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj => tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj} (100%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test => tests/DllImportGenerator.UnitTests}/ManualTypeMarshallingAnalyzerTests.cs (99%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test => tests/DllImportGenerator.UnitTests}/TestUtils.cs (98%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test => tests/DllImportGenerator.UnitTests}/Verifiers/CSharpAnalyzerVerifier.cs (98%) rename src/libraries/System.Runtime.InteropServices/{gen/DllImportGenerator.Test => tests/DllImportGenerator.UnitTests}/Verifiers/CSharpVerifierHelper.cs (97%) rename src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/{ScalarOps.cs => Demo.cs} (84%) diff --git a/src/libraries/System.Runtime.InteropServices/gen/readme.md b/src/libraries/System.Runtime.InteropServices/gen/readme.md index 9ba80ca332200..30e05076eb5ca 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/readme.md +++ b/src/libraries/System.Runtime.InteropServices/gen/readme.md @@ -1,24 +1,31 @@ # DllImport Generator -See [P/Invoke source generator proposal](https://github.com/dotnet/runtime/blob/master/docs/design/features/source-generator-pinvokes.md) for design and goals. +Work on this project can be tracked and discussed via the [official issue](https://github.com/dotnet/runtime/issues/43060) in `dotnet/runtime`. The [P/Invoke source generator proposal](https://github.com/dotnet/runtime/blob/master/docs/design/features/source-generator-pinvokes.md) contains additional details. -## Additional work +## Example -Below are additional work items that are not presently captured in this repository. +The [Demo project](./DllImportGenerator/Demo) is designed to be immediately consumable by everyone. It demonstrates a simple use case where the marshalling code is generated and a native function call with only [blittable types](https://docs.microsoft.com/dotnet/framework/interop/blittable-and-non-blittable-types) is made. A managed assembly with [native exports](./DllImportGenerator/TestAssets/NativeExports) is used in the P/Invoke scenario. -### Required +### Recommended scenarios: +* Step into the `Demo` application and observe the generated code for the `Sum` functions. +* Find the implementation of the `sumrefi` function and set a breakpoint. Run the debugger and explore the stack. +* Add a new export in the `NativeExports` project and update the `Demo` application to call the new export. +* Try the above scenarios when building in `Debug` or `Release`. Consider the differences. -* Add `GeneratedDllImportAttribute` to the BCL. See [`GeneratedDllImportAttribute.cs`](./Ancillary.Interop/GeneratedDllImportAttribute.cs). -* Add support for calling [`SetLastError()`](https://docs.microsoft.com/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror) from managed code with the expected semantics. During P/Invoke transitions the runtime manipulates the associated thread's error code and thus breaks `SetLastError()` semantics. +## Designs -* APIs to handle [`SafeHandle`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.safehandle) manipulation. +- [Code generation pipeline](./designs/Pipeline.md) +- [Struct Marshalling](./designs/StructMarshalling.md) -### Optional +## Workflow -* A tool to compare the resulting IL from the generated source to that generated by the built-in IL Marshaller system. This would help with validation of what is being generated. +All features of the [`dotnet` command line tool](https://docs.microsoft.com/dotnet/core/tools/) are supported for the respective project types (e.g. `build`, `run`, `test`). A consistent cross-platform inner dev loop with an IDE is available using [Visual Studio Code](https://code.visualstudio.com/) when appropriate .NET extensions are loaded. -## Designs +On Windows, loading the [solution](./DllImportGenerator.sln) in [Visual Studio](https://visualstudio.microsoft.com/) 2019 or later will enable the edit, build, debug inner dev loop. All features of Visual Studio are expected to operate correctly (e.g. Debugger, Test runner, Profiler). -- [Code generation pipeline](./designs/Pipeline.md) -- [Struct Marshalling](./designs/StructMarshalling.md) +Most of the above options have [official tutorials](https://docs.microsoft.com/dotnet/core/tutorials/). It is an aim of this project to follow canonical workflows that are intuitive to all developers. + +### Testing assets + +This project has no explicit native build system and should remain that way. The [`DNNE`](https://github.com/AaronRobinsonMSFT/DNNE/) project is used to create native exports that can be called from the P/Invokes during testing. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj new file mode 100644 index 0000000000000..2932ce632c210 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -0,0 +1,29 @@ + + + + net5.0 + false + Preview + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + diff --git a/src/samples/DllImportGeneratorSample/SafeHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs similarity index 84% rename from src/samples/DllImportGeneratorSample/SafeHandleTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs index bb21cfb565caf..fc71710057460 100644 --- a/src/samples/DllImportGeneratorSample/SafeHandleTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs @@ -1,22 +1,22 @@ - using System.Runtime.InteropServices; + using Microsoft.Win32.SafeHandles; using Xunit; -namespace Demo +namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { public class NativeExportsSafeHandle : SafeHandleZeroOrMinusOneIsInvalid { - private NativeExportsSafeHandle() : base(true) - { - } + private NativeExportsSafeHandle() : base(ownsHandle: true) + { } protected override bool ReleaseHandle() { - Assert.True(NativeExportsNE.ReleaseHandle(handle)); - return true; + bool didRelease = NativeExportsNE.ReleaseHandle(handle); + Assert.True(didRelease); + return didRelease; } } @@ -57,7 +57,7 @@ public void ByRefSameValue_UsesSameHandleInstance() { using NativeExportsNE.NativeExportsSafeHandle handleToDispose = NativeExportsNE.AllocateHandle(); NativeExportsNE.NativeExportsSafeHandle handle = handleToDispose; - NativeExportsNE.ModifyHandle(ref handle, false); + NativeExportsNE.ModifyHandle(ref handle, newHandle: false); Assert.Same(handleToDispose, handle); } @@ -66,7 +66,7 @@ public void ByRefDifferentValue_UsesNewHandleInstance() { using NativeExportsNE.NativeExportsSafeHandle handleToDispose = NativeExportsNE.AllocateHandle(); NativeExportsNE.NativeExportsSafeHandle handle = handleToDispose; - NativeExportsNE.ModifyHandle(ref handle, true); + NativeExportsNE.ModifyHandle(ref handle, newHandle: true); Assert.NotSame(handleToDispose, handle); handle.Dispose(); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs index bb3594897326c..06b8156a943c0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -1,6 +1,6 @@ using System.Runtime.InteropServices; -namespace DllImportGenerator.Test +namespace DllImportGenerator.UnitTests { internal static class CodeSnippets { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs similarity index 96% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs index 3acbdace6ced4..bf31ff47d7438 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using Xunit; -namespace DllImportGenerator.Test +namespace DllImportGenerator.UnitTests { public class CompileFails { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs index 3c66f36bbe6db..2275072099faa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Xunit; -namespace DllImportGenerator.Test +namespace DllImportGenerator.UnitTests { public class Compiles { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj similarity index 100% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/DllImportGenerator.Test.csproj rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index e049ce9d4e556..ae3aed147827c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -3,9 +3,9 @@ using Xunit; using static Microsoft.Interop.ManualTypeMarshallingAnalyzer; -using VerifyCS = DllImportGenerator.Test.Verifiers.CSharpAnalyzerVerifier; +using VerifyCS = DllImportGenerator.UnitTests.Verifiers.CSharpAnalyzerVerifier; -namespace DllImportGenerator.Test +namespace DllImportGenerator.UnitTests { public class ManualTypeMarshallingAnalyzerTests { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index 49ca8e625f608..e5d79820f9917 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Xunit; -namespace DllImportGenerator.Test +namespace DllImportGenerator.UnitTests { internal static class TestUtils { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpAnalyzerVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpAnalyzerVerifier.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs index 9ccff97f18b1d..b6bd0f5316489 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpAnalyzerVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; -namespace DllImportGenerator.Test.Verifiers +namespace DllImportGenerator.UnitTests.Verifiers { public static class CSharpAnalyzerVerifier where TAnalyzer : DiagnosticAnalyzer, new() diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpVerifierHelper.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs similarity index 97% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpVerifierHelper.cs rename to src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs index 61c0639752703..c51712a3ce0b0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator.Test/Verifiers/CSharpVerifierHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -namespace DllImportGenerator.Test.Verifiers +namespace DllImportGenerator.UnitTests.Verifiers { internal static class CSharpVerifierHelper { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/ScalarOps.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Demo.cs similarity index 84% rename from src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/ScalarOps.cs rename to src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Demo.cs index 4d2bb92006f6c..6e82b412b6b72 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/ScalarOps.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Demo.cs @@ -1,9 +1,8 @@ -using System; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace NativeExports { - public unsafe class ScalarOps + public static unsafe class Demo { [UnmanagedCallersOnly(EntryPoint = "sumi")] public static int Sum(int a, int b) diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs index fae57f242fe57..0cc2ab4f9fe95 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs @@ -1,16 +1,18 @@ using System.Collections.Generic; using System.Runtime.InteropServices; - namespace NativeExports { public static unsafe class Handles { + /// + /// Using in tests. + /// private const nint InvalidHandle = -1; private static nint LastHandle = 0; - private static HashSet ActiveHandles = new HashSet(); + private static readonly HashSet ActiveHandles = new HashSet(); [UnmanagedCallersOnly(EntryPoint = "alloc_handle")] public static nint AllocateHandle() @@ -18,18 +20,6 @@ public static nint AllocateHandle() return AllocateHandleCore(); } - private static nint AllocateHandleCore() - { - if (LastHandle == int.MaxValue) - { - return InvalidHandle; - } - - nint newHandle = ++LastHandle; - ActiveHandles.Add(newHandle); - return newHandle; - } - [UnmanagedCallersOnly(EntryPoint = "release_handle")] public static byte ReleaseHandle(nint handle) { @@ -50,5 +40,17 @@ public static void ModifyHandle(nint* handle, byte newHandle) *handle = AllocateHandleCore(); } } + + private static nint AllocateHandleCore() + { + if (LastHandle == int.MaxValue) + { + return InvalidHandle; + } + + nint newHandle = ++LastHandle; + ActiveHandles.Add(newHandle); + return newHandle; + } } } \ No newline at end of file diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index fdba3fbbb3540..4cee92efcd88d 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -16,8 +16,4 @@ - - - - diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index 06715a76c7c09..f0490390f6ac3 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -15,7 +15,7 @@ partial class NativeExportsNE public static partial void Sum(int a, ref int b); } - unsafe class Program + class Program { static void Main(string[] args) { @@ -31,13 +31,6 @@ static void Main(string[] args) c = b; NativeExportsNE.Sum(a, ref c); Console.WriteLine($"{a} + {b} = {c}"); - - SafeHandleTests tests = new SafeHandleTests(); - - tests.ReturnValue_CreatesSafeHandle(); - tests.ByValue_CorrectlyUnwrapsHandle(); - tests.ByRefSameValue_UsesSameHandleInstance(); - tests.ByRefDifferentValue_UsesNewHandleInstance(); } } } From 09e1a9de3c357029bac6610e4a47731e1cde87a9 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 9 Oct 2020 14:07:04 -0700 Subject: [PATCH 024/161] Boolean and Delegate tests (dotnet/runtimelab#152) * Boolean and Delegate tests Updated to DNNE 1.0.12 with support for C# function pointers. Renamed CBoolMarshaller to ByteBoolMarshaller. Added integration tests for all bool marshaller types. Added integration tests for delegates. Style nits. Commit migrated from https://github.com/dotnet/runtimelab/commit/6c980dff7af857ebc68518150c08a96a95a04d1d --- .../Marshalling/BoolMarshaller.cs | 46 ++++-- .../Marshalling/DelegateMarshaller.cs | 5 +- .../Marshalling/Forwarder.cs | 2 +- .../Marshalling/MarshallingGenerator.cs | 8 +- .../Marshalling/SafeHandleMarshaller.cs | 5 +- .../DllImportGenerator.Tests/BooleanTests.cs | 140 ++++++++++++++++++ .../DllImportGenerator.Tests/DelegateTests.cs | 55 +++++++ .../TestAssets/NativeExports/Booleans.cs | 31 ++++ .../DelegatesAndFunctionPointers.cs | 30 ++++ .../NativeExports/NativeExports.csproj | 23 +-- 10 files changed, 301 insertions(+), 44 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs index a0416bbf730c3..10d67e9aa761e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -14,12 +13,14 @@ internal abstract class BoolMarshallerBase : IMarshallingGenerator private readonly PredefinedTypeSyntax _nativeType; private readonly int _trueValue; private readonly int _falseValue; + private readonly bool _compareToTrue; - protected BoolMarshallerBase(PredefinedTypeSyntax nativeType, int trueValue, int falseValue) + protected BoolMarshallerBase(PredefinedTypeSyntax nativeType, int trueValue, int falseValue, bool compareToTrue) { _nativeType = nativeType; _trueValue = trueValue; _falseValue = falseValue; + _compareToTrue = compareToTrue; } public TypeSyntax AsNativeType(TypePositionInfo info) @@ -83,15 +84,19 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont case StubCodeContext.Stage.Unmarshal: if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { - // = != 0; + // = == _trueValue; + // or + // = != _falseValue; + var (binaryOp, comparand) = _compareToTrue ? (SyntaxKind.EqualsExpression, _trueValue) : (SyntaxKind.NotEqualsExpression, _falseValue); + yield return ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, IdentifierName(managedIdentifier), BinaryExpression( - SyntaxKind.NotEqualsExpression, + binaryOp, IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(_falseValue))))); + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(comparand))))); } break; default: @@ -102,28 +107,47 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; } - internal class CBoolMarshaller : BoolMarshallerBase + /// + /// Marshals a boolean value as 1 byte. + /// + /// + /// This boolean type is the natural size of a boolean in the CLR (ECMA-335 (III.1.1.2)). + /// + /// This is typically compatible with C99 + /// and C++, but those is implementation defined. + /// Consult your compiler specification. + /// + internal class ByteBoolMarshaller : BoolMarshallerBase { - public CBoolMarshaller() - : base(PredefinedType(Token(SyntaxKind.ByteKeyword)), trueValue: 1, falseValue: 0) + public ByteBoolMarshaller() + : base(PredefinedType(Token(SyntaxKind.ByteKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false) { } } + /// + /// Marshals a boolean value as a 4-byte integer. + /// + /// + /// Corresponds to the definition of BOOL. + /// internal class WinBoolMarshaller : BoolMarshallerBase { public WinBoolMarshaller() - : base(PredefinedType(Token(SyntaxKind.IntKeyword)), trueValue: 1, falseValue: 0) + : base(PredefinedType(Token(SyntaxKind.IntKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false) { } } - + + /// + /// Marshal a boolean value as a VARIANT_BOOL (Windows OLE/Automation type). + /// internal class VariantBoolMarshaller : BoolMarshallerBase { private const short VARIANT_TRUE = -1; private const short VARIANT_FALSE = 0; public VariantBoolMarshaller() - : base(PredefinedType(Token(SyntaxKind.ShortKeyword)), VARIANT_TRUE, VARIANT_FALSE) + : base(PredefinedType(Token(SyntaxKind.ShortKeyword)), trueValue: VARIANT_TRUE, falseValue: VARIANT_FALSE, compareToTrue: true) { } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs index bf2669ecb979a..060f54c47776a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -7,7 +6,7 @@ namespace Microsoft.Interop { - class DelegateMarshaller : IMarshallingGenerator + internal class DelegateMarshaller : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs index 53601890de5bf..00f307e9a324e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs @@ -6,7 +6,7 @@ namespace Microsoft.Interop { - class Forwarder : IMarshallingGenerator + internal class Forwarder : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 60ef933582a81..cebc199326041 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -58,7 +58,7 @@ internal interface IMarshallingGenerator internal class MarshallingGenerators { - public static readonly CBoolMarshaller CBool = new CBoolMarshaller(); + public static readonly ByteBoolMarshaller ByteBool = new ByteBoolMarshaller(); public static readonly WinBoolMarshaller WinBool = new WinBoolMarshaller(); public static readonly VariantBoolMarshaller VariantBool = new VariantBoolMarshaller(); public static readonly Forwarder Forwarder = new Forwarder(); @@ -97,12 +97,12 @@ public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out return true; case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: null }: - generator = CBool; + generator = WinBool; // [Compat] Matching the default for the built-in runtime marshallers. return true; case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I1 or UnmanagedType.U1 } }: - generator = CBool; + generator = ByteBool; return true; - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I4 or UnmanagedType.U4 } }: + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool } }: generator = WinBool; return true; case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.VariantBool } }: diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index 041472a7446a3..c9b7972fe7e9d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -8,7 +7,7 @@ namespace Microsoft.Interop { - class SafeHandleMarshaller : IMarshallingGenerator + internal class SafeHandleMarshaller : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs new file mode 100644 index 0000000000000..4f870d7a44a2f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bytebool_return_as_uint")] + public static partial uint ReturnByteBoolAsUInt([MarshalAs(UnmanagedType.U1)] bool input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bytebool_return_as_uint")] + public static partial uint ReturnSByteBoolAsUInt([MarshalAs(UnmanagedType.I1)] bool input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "variantbool_return_as_uint")] + public static partial uint ReturnVariantBoolAsUInt([MarshalAs(UnmanagedType.VariantBool)] bool input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + public static partial uint ReturnIntBoolAsUInt([MarshalAs(UnmanagedType.I4)] bool input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + public static partial uint ReturnUIntBoolAsUInt([MarshalAs(UnmanagedType.U4)] bool input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + public static partial uint ReturnWinBoolAsUInt([MarshalAs(UnmanagedType.Bool)] bool input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [return: MarshalAs(UnmanagedType.U1)] + public static partial bool ReturnUIntAsByteBool(uint input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [return: MarshalAs(UnmanagedType.VariantBool)] + public static partial bool ReturnUIntAsVariantBool(uint input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool ReturnUIntAsWinBool(uint input); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsRefByteBool(uint input, [MarshalAs(UnmanagedType.U1)] ref bool res); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsOutByteBool(uint input, [MarshalAs(UnmanagedType.U1)] out bool res); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsRefVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] ref bool res); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsOutVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] out bool res); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsRefWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] ref bool res); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsOutWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] out bool res); + } + + public class BooleanTests + { + // See definition of Windows' VARIANT_BOOL + const ushort VARIANT_TRUE = unchecked((ushort)-1); + const ushort VARIANT_FALSE = 0; + + [Fact] + public void ValidateBoolIsMarshalledAsExpected() + { + Assert.Equal((uint)1, NativeExportsNE.ReturnByteBoolAsUInt(true)); + Assert.Equal((uint)0, NativeExportsNE.ReturnByteBoolAsUInt(false)); + Assert.Equal((uint)1, NativeExportsNE.ReturnSByteBoolAsUInt(true)); + Assert.Equal((uint)0, NativeExportsNE.ReturnSByteBoolAsUInt(false)); + Assert.Equal(VARIANT_TRUE, NativeExportsNE.ReturnVariantBoolAsUInt(true)); + Assert.Equal(VARIANT_FALSE, NativeExportsNE.ReturnVariantBoolAsUInt(false)); + Assert.Equal((uint)1, NativeExportsNE.ReturnIntBoolAsUInt(true)); + Assert.Equal((uint)0, NativeExportsNE.ReturnIntBoolAsUInt(false)); + Assert.Equal((uint)1, NativeExportsNE.ReturnUIntBoolAsUInt(true)); + Assert.Equal((uint)0, NativeExportsNE.ReturnUIntBoolAsUInt(false)); + Assert.Equal((uint)1, NativeExportsNE.ReturnWinBoolAsUInt(true)); + Assert.Equal((uint)0, NativeExportsNE.ReturnWinBoolAsUInt(false)); + } + + [Theory] + [InlineData(new object[] { 0, false })] + [InlineData(new object[] { 1, true })] + [InlineData(new object[] { 37, true })] + [InlineData(new object[] { 0xff, true })] + [InlineData(new object[] { 0xffffff00, false })] + public void ValidateByteBoolReturns(uint value, bool expected) + { + Assert.Equal(expected, NativeExportsNE.ReturnUIntAsByteBool(value)); + + bool result = !expected; + NativeExportsNE.ReturnUIntAsRefByteBool(value, ref result); + Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsOutByteBool(value, out result); + Assert.Equal(expected, result); + } + + [Theory] + [InlineData(new object[] { 0, false })] + [InlineData(new object[] { 1, false })] + [InlineData(new object[] { 0xff, false })] + [InlineData(new object[] { VARIANT_TRUE, true })] + [InlineData(new object[] { 0xffffffff, true })] + [InlineData(new object[] { 0xffff0000, false })] + public void ValidateVariantBoolReturns(uint value, bool expected) + { + Assert.Equal(expected, NativeExportsNE.ReturnUIntAsVariantBool(value)); + + bool result = !expected; + NativeExportsNE.ReturnUIntAsRefVariantBool(value, ref result); + Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsOutVariantBool(value, out result); + Assert.Equal(expected, result); + } + + [Theory] + [InlineData(new object[] { 0, false })] + [InlineData(new object[] { 1, true})] + [InlineData(new object[] { 37, true })] + [InlineData(new object[] { 0xffffffff, true })] + [InlineData(new object[] { 0x80000000, true })] + public void ValidateWinBoolReturns(uint value, bool expected) + { + Assert.Equal(expected, NativeExportsNE.ReturnUIntAsWinBool(value)); + + bool result = !expected; + NativeExportsNE.ReturnUIntAsRefWinBool(value, ref result); + Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsOutWinBool(value, out result); + Assert.Equal(expected, result); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs new file mode 100644 index 0000000000000..24ac17cec0d0f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs @@ -0,0 +1,55 @@ +using System.Runtime.InteropServices; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public delegate void VoidVoid(); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "invoke_callback_after_gc")] + public static partial void InvokeAfterGC(VoidVoid cb); + + public delegate int IntIntInt(int a, int b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "invoke_callback_blittable_args")] + public static partial int InvokeWithBlittableArgument(IntIntInt cb, int a, int b); + } + + public class DelegateTests + { + [Fact] + public void DelegateIsKeptAliveDuringCall() + { + bool wasCalled = false; + NativeExportsNE.InvokeAfterGC(new NativeExportsNE.VoidVoid(Callback)); + Assert.True(wasCalled); + + void Callback() + { + wasCalled = true; + } + } + + [Fact] + public void DelegateIsCalledWithArgumentsInOrder() + { + const int a = 100; + const int b = 50; + int result; + + result = NativeExportsNE.InvokeWithBlittableArgument(new NativeExportsNE.IntIntInt(Callback), a, b); + Assert.Equal(Callback(a, b), result); + + result = NativeExportsNE.InvokeWithBlittableArgument(new NativeExportsNE.IntIntInt(Callback), b, a); + Assert.Equal(Callback(b, a), result); + + static int Callback(int a, int b) + { + // Use a noncommutative operation to validate passed in order. + return a - b; + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs new file mode 100644 index 0000000000000..ac729a1288217 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs @@ -0,0 +1,31 @@ +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class Booleans + { + [UnmanagedCallersOnly(EntryPoint = "bytebool_return_as_uint")] + public static uint ReturnByteAsUInt(byte input) + { + return input; + } + + [UnmanagedCallersOnly(EntryPoint = "variantbool_return_as_uint")] + public static uint ReturnUShortAsUInt(ushort input) + { + return input; + } + + [UnmanagedCallersOnly(EntryPoint = "bool_return_as_uint")] + public static uint ReturnUIntAsUInt(uint input) + { + return input; + } + + [UnmanagedCallersOnly(EntryPoint = "bool_return_as_refuint")] + public static void ReturnUIntAsRefUInt(uint input, uint* res) + { + *res = input; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs new file mode 100644 index 0000000000000..9aa19952ea31c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs @@ -0,0 +1,30 @@ +using System; +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class DelegatesAndFunctionPointers + { + [UnmanagedCallersOnly(EntryPoint = "invoke_callback_after_gc")] + public static void InvokeCallbackAfterGCCollect(delegate* unmanaged fptr) + { + // We are at the mercy of the GC to verify our delegate has been retain + // across the native function call. This is a best effort validation. + GC.Collect(); + GC.Collect(); + GC.Collect(); + GC.Collect(); + GC.Collect(); + GC.WaitForPendingFinalizers(); + + // If the corresponding Delegate was collected, the runtime will rudely abort. + fptr(); + } + + [UnmanagedCallersOnly(EntryPoint = "invoke_callback_blittable_args")] + public static int InvokeCallbackWithBlittableArgument(delegate* unmanaged fptr, int a, int b) + { + return fptr(a, b); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 70e5b074e8b89..e72f43fdabdf1 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -8,28 +8,7 @@ - + - - - - - - - - From 653aeb388e066cedf287214c09b838a0ce444d7d Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 9 Oct 2020 17:30:55 -0700 Subject: [PATCH 025/161] Report diagnostics in generator (dotnet/runtimelab#158) Commit migrated from https://github.com/dotnet/runtimelab/commit/98f55be7fed518bb93391d0d24341b4b5e7a56fd --- .../DllImportGenerator/DllImportGenerator.cs | 10 +- .../DllImportGenerator.csproj | 1 + .../gen/DllImportGenerator/DllImportStub.cs | 11 +- .../GeneratorDiagnostics.cs | 217 ++++++++++++++ .../ManualTypeMarshallingAnalyzer.cs | 2 +- .../Marshalling/MarshallingGenerator.cs | 11 +- .../DllImportGenerator/Resources.Designer.cs | 116 +++++++- .../gen/DllImportGenerator/Resources.resx | 52 +++- .../gen/DllImportGenerator/StubCodeContext.cs | 7 +- .../DllImportGenerator/StubCodeGenerator.cs | 127 ++++----- .../DllImportGenerator/TypePositionInfo.cs | 38 +-- .../DllImportGenerator/Diagnostics.md | 39 +++ .../gen/readme.md | 2 +- .../DllImportGenerator.UnitTests/Compiles.cs | 116 ++++++-- .../Diagnostics.cs | 264 ++++++++++++++++++ .../DllImportGeneratorSample.csproj | 4 + 16 files changed, 866 insertions(+), 151 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Diagnostics.md create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 4d9ce3989205a..7d7e42eacb0c7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -34,6 +34,8 @@ public void Execute(GeneratorExecutionContext context) // this caching. var syntaxToModel = new Dictionary(); + var generatorDiagnostics = new GeneratorDiagnostics(context); + var generatedDllImports = new StringBuilder(); foreach (SyntaxReference synRef in synRec.Methods) { @@ -55,13 +57,7 @@ public void Execute(GeneratorExecutionContext context) Debug.Assert(!(dllImportAttr is null) && !(dllImportData is null)); // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData, context.Compilation, context.CancellationToken); - - // Report any diagnostics from the stub generation step. - foreach (var diag in dllImportStub.Diagnostics) - { - context.ReportDiagnostic(diag); - } + var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData, context.Compilation, generatorDiagnostics, context.CancellationToken); PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub, dllImportAttr); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 5e60199190e12..20b90b8c0045d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -7,6 +7,7 @@ True true Preview + Microsoft.Interop diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 3218db8e00e1d..f062532c74097 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -49,8 +49,6 @@ public IEnumerable StubParameters public MethodDeclarationSyntax DllImportDeclaration { get; private set; } - public IEnumerable Diagnostics { get; private set; } - /// /// Flags used to indicate members on GeneratedDllImport attribute. /// @@ -101,6 +99,7 @@ public static DllImportStub Create( IMethodSymbol method, GeneratedDllImportData dllImportData, Compilation compilation, + GeneratorDiagnostics diagnostics, CancellationToken token = default) { // Cancel early if requested @@ -137,13 +136,13 @@ public static DllImportStub Create( for (int i = 0; i < method.Parameters.Length; i++) { var param = method.Parameters[i]; - var typeInfo = TypePositionInfo.CreateForParameter(param, compilation); + var typeInfo = TypePositionInfo.CreateForParameter(param, compilation, diagnostics); typeInfo.ManagedIndex = i; typeInfo.NativeIndex = paramsTypeInfo.Count; paramsTypeInfo.Add(typeInfo); } - TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), compilation); + TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), compilation, diagnostics); retTypeInfo.ManagedIndex = TypePositionInfo.ReturnIndex; retTypeInfo.NativeIndex = TypePositionInfo.ReturnIndex; if (!dllImportData.PreserveSig) @@ -162,7 +161,8 @@ public static DllImportStub Create( } // Generate stub code - var (code, dllImport) = StubCodeGenerator.GenerateSyntax(method, paramsTypeInfo, retTypeInfo); + var stubGenerator = new StubCodeGenerator(method, paramsTypeInfo, retTypeInfo, diagnostics); + var (code, dllImport) = stubGenerator.GenerateSyntax(); return new DllImportStub() { @@ -172,7 +172,6 @@ public static DllImportStub Create( StubContainingTypes = containingTypes, StubCode = code, DllImportDeclaration = dllImport, - Diagnostics = Enumerable.Empty(), }; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs new file mode 100644 index 0000000000000..17657fe4eaf53 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -0,0 +1,217 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; + +using Microsoft.CodeAnalysis; + +#nullable enable + +namespace Microsoft.Interop +{ + internal static class DiagnosticExtensions + { + public static Diagnostic CreateDiagnostic( + this ISymbol symbol, + DiagnosticDescriptor descriptor, + params object[] args) + { + IEnumerable locationsInSource = symbol.Locations.Where(l => l.IsInSource); + if (!locationsInSource.Any()) + return Diagnostic.Create(descriptor, Location.None, args); + + return Diagnostic.Create( + descriptor, + location: locationsInSource.First(), + additionalLocations: locationsInSource.Skip(1), + messageArgs: args); + } + + public static Diagnostic CreateDiagnostic( + this AttributeData attributeData, + DiagnosticDescriptor descriptor, + params object[] args) + { + SyntaxReference? syntaxReference = attributeData.ApplicationSyntaxReference; + Location location = syntaxReference is not null + ? syntaxReference.GetSyntax().GetLocation() + : Location.None; + + return Diagnostic.Create( + descriptor, + location: location.IsInSource ? location : Location.None, + messageArgs: args); + } + } + + /// + /// Class for reporting diagnostics in the DLL import generator + /// + public class GeneratorDiagnostics + { + public class Ids + { + public const string Prefix = "DLLIMPORTGEN"; + public const string TypeNotSupported = Prefix + "001"; + public const string ConfigurationNotSupported = Prefix + "002"; + } + + private const string Category = "DllImportGenerator"; + + public readonly static DiagnosticDescriptor ParameterTypeNotSupported = + new DiagnosticDescriptor( + Ids.TypeNotSupported, + GetResourceString(nameof(Resources.TypeNotSupportedTitle)), + GetResourceString(nameof(Resources.TypeNotSupportedMessageParameter)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(Resources.TypeNotSupportedDescription)); + + public readonly static DiagnosticDescriptor ReturnTypeNotSupported = + new DiagnosticDescriptor( + Ids.TypeNotSupported, + GetResourceString(nameof(Resources.TypeNotSupportedTitle)), + GetResourceString(nameof(Resources.TypeNotSupportedMessageReturn)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(Resources.TypeNotSupportedDescription)); + + public readonly static DiagnosticDescriptor ParameterConfigurationNotSupported = + new DiagnosticDescriptor( + Ids.ConfigurationNotSupported, + GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), + GetResourceString(nameof(Resources.ConfigurationNotSupportedMessageParameter)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + + public readonly static DiagnosticDescriptor ReturnConfigurationNotSupported = + new DiagnosticDescriptor( + Ids.ConfigurationNotSupported, + GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), + GetResourceString(nameof(Resources.ConfigurationNotSupportedMessageReturn)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + + public readonly static DiagnosticDescriptor ConfigurationNotSupported = + new DiagnosticDescriptor( + Ids.ConfigurationNotSupported, + GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), + GetResourceString(nameof(Resources.ConfigurationNotSupportedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + + public readonly static DiagnosticDescriptor ConfigurationValueNotSupported = + new DiagnosticDescriptor( + Ids.ConfigurationNotSupported, + GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), + GetResourceString(nameof(Resources.ConfigurationNotSupportedMessageValue)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + + private readonly GeneratorExecutionContext context; + + public GeneratorDiagnostics(GeneratorExecutionContext context) + { + this.context = context; + } + + /// + /// Report diagnostic for configuration that is not supported by the DLL import source generator + /// + /// Attribute specifying the unsupported configuration + /// Name of the configuration + /// [Optiona] Unsupported configuration value + public void ReportConfigurationNotSupported( + AttributeData attributeData, + string configurationName, + string? unsupportedValue = null) + { + if (unsupportedValue == null) + { + this.context.ReportDiagnostic( + attributeData.CreateDiagnostic( + GeneratorDiagnostics.ConfigurationNotSupported, + configurationName)); + } + else + { + this.context.ReportDiagnostic( + attributeData.CreateDiagnostic( + GeneratorDiagnostics.ConfigurationValueNotSupported, + unsupportedValue, + configurationName)); + } + } + + /// + /// Report diagnostic for marshalling of a parameter/return that is not supported + /// + /// Method with the parameter/return + /// Type info for the parameter/return + internal void ReportMarshallingNotSupported( + IMethodSymbol method, + TypePositionInfo info) + { + if (info.MarshallingAttributeInfo != null && info.MarshallingAttributeInfo is MarshalAsInfo) + { + // Report that the specified marshalling configuration is not supported. + // We don't forward marshalling attributes, so this is reported differently + // than when there is no attribute and the type itself is not supported. + if (info.IsManagedReturnPosition) + { + this.context.ReportDiagnostic( + method.CreateDiagnostic( + GeneratorDiagnostics.ReturnConfigurationNotSupported, + nameof(System.Runtime.InteropServices.MarshalAsAttribute), + method.Name)); + } + else + { + Debug.Assert(info.ManagedIndex <= method.Parameters.Length); + IParameterSymbol paramSymbol = method.Parameters[info.ManagedIndex]; + this.context.ReportDiagnostic( + paramSymbol.CreateDiagnostic( + GeneratorDiagnostics.ParameterConfigurationNotSupported, + nameof(System.Runtime.InteropServices.MarshalAsAttribute), + paramSymbol.Name)); + } + } + else + { + // Report that the type is not supported + if (info.IsManagedReturnPosition) + { + this.context.ReportDiagnostic( + method.CreateDiagnostic( + GeneratorDiagnostics.ReturnTypeNotSupported, + method.ReturnType.ToDisplayString(), + method.Name)); + } + else + { + Debug.Assert(info.ManagedIndex <= method.Parameters.Length); + IParameterSymbol paramSymbol = method.Parameters[info.ManagedIndex]; + this.context.ReportDiagnostic( + paramSymbol.CreateDiagnostic( + GeneratorDiagnostics.ParameterTypeNotSupported, + paramSymbol.Type.ToDisplayString(), + paramSymbol.Name)); + } + } + } + + private static LocalizableResourceString GetResourceString(string resourceName) + { + return new LocalizableResourceString(resourceName, Resources.ResourceManager, typeof(Resources)); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs index a58c81291b7cb..8366ca698ed99 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Immutable; using System.Linq; -using DllImportGenerator; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index cebc199326041..e2572ad6cf7b8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -53,6 +53,9 @@ internal interface IMarshallingGenerator /// Object to marshal /// Code generation context /// If the marshaller uses an identifier for the native value, true; otherwise, false. + /// + /// of may not be valid. + /// bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); } @@ -117,7 +120,7 @@ public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out generator = Blittable; return true; - // Marshalling in new model + // Marshalling in new model case { MarshallingAttributeInfo: NativeMarshallingAttributeInfo marshalInfo }: generator = Forwarder; return false; @@ -127,10 +130,14 @@ public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out generator = Forwarder; return false; - case { MarshallingAttributeInfo: SafeHandleMarshallingInfo _}: + case { MarshallingAttributeInfo: SafeHandleMarshallingInfo _}: generator = SafeHandle; return true; + case { ManagedType: { SpecialType: SpecialType.System_Void } }: + generator = Forwarder; + return true; + default: generator = Forwarder; return false; 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 c7ccc3443b271..67f0b5f785e3f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace DllImportGenerator { +namespace Microsoft.Interop { using System; @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DllImportGenerator.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Interop.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -70,7 +70,7 @@ internal static string BlittableTypeMustBeBlittableDescription { } /// - /// Looks up a localized string similar to Type '{0}' is marked with 'BlittableTypeAttribute' but is not blittable.. + /// Looks up a localized string similar to Type '{0}' is marked with 'BlittableTypeAttribute' but is not blittable. /// internal static string BlittableTypeMustBeBlittableMessage { get { @@ -96,6 +96,60 @@ internal static string CannotHaveMultipleMarshallingAttributesMessage { } } + /// + /// Looks up a localized string similar to Source-generated P/Invokes will ignore any configuration that is not supported.. + /// + internal static string ConfigurationNotSupportedDescription { + get { + return ResourceManager.GetString("ConfigurationNotSupportedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '{0}' configuration is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead.. + /// + internal static string ConfigurationNotSupportedMessage { + get { + return ResourceManager.GetString("ConfigurationNotSupportedMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified '{0}' configuration for parameter '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead.. + /// + internal static string ConfigurationNotSupportedMessageParameter { + get { + return ResourceManager.GetString("ConfigurationNotSupportedMessageParameter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified '{0}' configuration for the return value of method '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead.. + /// + internal static string ConfigurationNotSupportedMessageReturn { + get { + return ResourceManager.GetString("ConfigurationNotSupportedMessageReturn", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified value '{0}' for '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead.. + /// + internal static string ConfigurationNotSupportedMessageValue { + get { + return ResourceManager.GetString("ConfigurationNotSupportedMessageValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specified configuration is not supported by source-generated P/Invokes.. + /// + internal static string ConfigurationNotSupportedTitle { + get { + return ResourceManager.GetString("ConfigurationNotSupportedTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to The return type of 'GetPinnableReference' (after accounting for 'ref') must be blittable.. /// @@ -106,7 +160,7 @@ internal static string GetPinnableReferenceReturnTypeBlittableDescription { } /// - /// Looks up a localized string similar to The dereferenced type of the return type of the 'GetPinnableReference' method must be blittable.. + /// Looks up a localized string similar to The dereferenced type of the return type of the 'GetPinnableReference' method must be blittable. /// internal static string GetPinnableReferenceReturnTypeBlittableMessage { get { @@ -124,7 +178,7 @@ internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFal } /// - /// Looks up a localized string similar to Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible.. + /// Looks up a localized string similar to Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible. /// internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage { get { @@ -142,7 +196,7 @@ internal static string NativeTypeMustBeBlittableDescription { } /// - /// Looks up a localized string similar to The native type '{0}' for the type '{1}' is not blittable.. + /// Looks up a localized string similar to The native type '{0}' for the type '{1}' is not blittable. /// internal static string NativeTypeMustBeBlittableMessage { get { @@ -160,7 +214,7 @@ internal static string NativeTypeMustBeNonNullDescription { } /// - /// Looks up a localized string similar to The native type for the type '{0}' is null.. + /// Looks up a localized string similar to The native type for the type '{0}' is null. /// internal static string NativeTypeMustBeNonNullMessage { get { @@ -178,7 +232,7 @@ internal static string NativeTypeMustBePointerSizedDescription { } /// - /// Looks up a localized string similar to The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference' method.. + /// Looks up a localized string similar to The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference' method. /// internal static string NativeTypeMustBePointerSizedMessage { get { @@ -196,7 +250,7 @@ internal static string NativeTypeMustHaveRequiredShapeDescription { } /// - /// Looks up a localized string similar to The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}'.. + /// Looks up a localized string similar to The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}'. /// internal static string NativeTypeMustHaveRequiredShapeMessage { get { @@ -214,7 +268,7 @@ internal static string StackallocConstructorMustHaveStackBufferSizeConstantDescr } /// - /// Looks up a localized string similar to The native type '{0}' must have a 'public const int StackBufferSize' field that specifies the size of the stack buffer because it has a constructor that takes a stack-allocated Span<byte>.. + /// Looks up a localized string similar to The native type '{0}' must have a 'public const int StackBufferSize' field that specifies the size of the stack buffer because it has a constructor that takes a stack-allocated Span<byte>. /// internal static string StackallocConstructorMustHaveStackBufferSizeConstantMessage { get { @@ -232,7 +286,7 @@ internal static string StackallocMarshallingShouldSupportAllocatingMarshallingFa } /// - /// Looks up a localized string similar to Native type '{0}' has a stack-allocating constructor does not support marshalling in scenarios where stack allocation is impossible.. + /// Looks up a localized string similar to Native type '{0}' has a stack-allocating constructor does not support marshalling in scenarios where stack allocation is impossible. /// internal static string StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage { get { @@ -240,6 +294,42 @@ internal static string StackallocMarshallingShouldSupportAllocatingMarshallingFa } } + /// + /// Looks up a localized string similar to For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.. + /// + internal static string TypeNotSupportedDescription { + get { + return ResourceManager.GetString("TypeNotSupportedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter '{1}'.. + /// + internal static string TypeNotSupportedMessageParameter { + get { + return ResourceManager.GetString("TypeNotSupportedMessageParameter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of the return value of method '{1}'.. + /// + internal static string TypeNotSupportedMessageReturn { + get { + return ResourceManager.GetString("TypeNotSupportedMessageReturn", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specified type is not supported by source-generated P/Invokes. + /// + internal static string TypeNotSupportedTitle { + get { + return ResourceManager.GetString("TypeNotSupportedTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to The native type's 'Value' property must have a getter to support marshalling from managed to native.. /// @@ -250,7 +340,7 @@ internal static string ValuePropertyMustHaveGetterDescription { } /// - /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a getter.. + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a getter. /// internal static string ValuePropertyMustHaveGetterMessage { get { @@ -268,7 +358,7 @@ internal static string ValuePropertyMustHaveSetterDescription { } /// - /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a setter.. + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a setter. /// internal static string ValuePropertyMustHaveSetterMessage { get { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index e21cecab2e6f7..9568b0305d559 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -121,7 +121,7 @@ A type marked with 'BlittableTypeAttribute' must be blittable. - Type '{0}' is marked with 'BlittableTypeAttribute' but is not blittable. + Type '{0}' is marked with 'BlittableTypeAttribute' but is not blittable The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive. @@ -129,64 +129,94 @@ Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes. + + Source-generated P/Invokes will ignore any configuration that is not supported. + + + The '{0}' configuration is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead. + + + The specified '{0}' configuration for parameter '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead. + + + The specified '{0}' configuration for the return value of method '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead. + + + The specified value '{0}' for '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead. + + + Specified configuration is not supported by source-generated P/Invokes. + The return type of 'GetPinnableReference' (after accounting for 'ref') must be blittable. - The dereferenced type of the return type of the 'GetPinnableReference' method must be blittable. + The dereferenced type of the return type of the 'GetPinnableReference' method must be blittable A type that supports marshalling from managed to native by pinning should also support marshalling from managed to native where pinning is impossible. - Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible. + Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible A native type for a given type must be blittable. - The native type '{0}' for the type '{1}' is not blittable. + The native type '{0}' for the type '{1}' is not blittable A native type for a given type must be non-null. - The native type for the type '{0}' is null. + The native type for the type '{0}' is null The native type must be pointer sized so the pinned result of 'GetPinnableReference' can be cast to the native type. - The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference' method. + The native type '{0}' must be pointer sized because the managed type '{1}' has a 'GetPinnableReference' method The native type must have at least one of the two marshalling methods to enable marshalling the managed type. - The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}'. + The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}' When constructor taking a Span<byte> is specified on the native type, the type must also have a public integer constant named StackBufferSize to provide the size of the stack-allocated buffer. - The native type '{0}' must have a 'public const int StackBufferSize' field that specifies the size of the stack buffer because it has a constructor that takes a stack-allocated Span<byte>. + The native type '{0}' must have a 'public const int StackBufferSize' field that specifies the size of the stack buffer because it has a constructor that takes a stack-allocated Span<byte> A type that supports marshalling from managed to native by stack allocation should also support marshalling from managed to native where stack allocation is impossible. - Native type '{0}' has a stack-allocating constructor does not support marshalling in scenarios where stack allocation is impossible. + Native type '{0}' has a stack-allocating constructor does not support marshalling in scenarios where stack allocation is impossible + + + For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type. + + + The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter '{1}'. + + + The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of the return value of method '{1}'. + + + Specified type is not supported by source-generated P/Invokes The native type's 'Value' property must have a getter to support marshalling from managed to native. - The 'Value' property on the native type '{0}' must have a getter. + The 'Value' property on the native type '{0}' must have a getter The native type's 'Value' property must have a setter to support marshalling from native to managed. - The 'Value' property on the native type '{0}' must have a setter. + The 'Value' property on the native type '{0}' must have a setter \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index 0b5f9fe0a862e..b3618c898bfc9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -9,6 +9,11 @@ internal abstract class StubCodeContext /// public enum Stage { + /// + /// Invalid stage + /// + Invalid, + /// /// Perform any setup required /// @@ -55,7 +60,7 @@ public enum Stage GuaranteedUnmarshal } - public Stage CurrentStage { get; protected set; } + public Stage CurrentStage { get; protected set; } = Stage.Invalid; public abstract bool PinningSupported { get; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 043819bc068f3..a28c856026ac9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -12,11 +12,6 @@ namespace Microsoft.Interop { internal sealed class StubCodeGenerator : StubCodeContext { - private StubCodeGenerator(Stage stage) - { - CurrentStage = stage; - } - public override bool PinningSupported => true; public override bool StackSpaceUsable => true; @@ -34,17 +29,55 @@ private StubCodeGenerator(Stage stage) private const string InvokeReturnIdentifier = "__invokeRetVal"; - /// - /// Generate an identifier for the native return value and update the context with the new value - /// - /// Identifier for the native return value - public void GenerateReturnNativeIdentifier() + private static readonly Stage[] Stages = new Stage[] + { + Stage.Setup, + Stage.Marshal, + Stage.Pin, + Stage.Invoke, + Stage.KeepAlive, + Stage.Unmarshal, + Stage.GuaranteedUnmarshal, + Stage.Cleanup + }; + + private readonly GeneratorDiagnostics diagnostics; + + private readonly IMethodSymbol stubMethod; + private readonly List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> paramMarshallers; + private readonly (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) retMarshaller; + + public StubCodeGenerator( + IMethodSymbol stubMethod, + IEnumerable paramsTypeInfo, + TypePositionInfo retTypeInfo, + GeneratorDiagnostics generatorDiagnostics) { - if (CurrentStage != Stage.Setup) - throw new InvalidOperationException(); + Debug.Assert(retTypeInfo.IsNativeReturnPosition); + + this.stubMethod = stubMethod; + this.diagnostics = generatorDiagnostics; + + // Get marshallers for parameters + this.paramMarshallers = paramsTypeInfo.Select(p => + { + IMarshallingGenerator generator; + if (!MarshallingGenerators.TryCreate(p, this, out generator)) + { + this.diagnostics.ReportMarshallingNotSupported(this.stubMethod, p); + } - // Update the native identifier for the return value - ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; + return (p, generator); + }).ToList(); + + // Get marshaller for return + IMarshallingGenerator retGenerator; + if (!MarshallingGenerators.TryCreate(retTypeInfo, this, out retGenerator)) + { + this.diagnostics.ReportMarshallingNotSupported(this.stubMethod, retTypeInfo); + } + + this.retMarshaller = (retTypeInfo, retGenerator); } public override (string managed, string native) GetIdentifiers(TypePositionInfo info) @@ -70,24 +103,15 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } } - public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSyntax( - IMethodSymbol stubMethod, - IEnumerable paramsTypeInfo, - TypePositionInfo retTypeInfo) + public (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSyntax() { - Debug.Assert(retTypeInfo.IsNativeReturnPosition); - - var context = new StubCodeGenerator(Stage.Setup); - string dllImportName = stubMethod.Name + "__PInvoke__"; - var paramMarshallers = paramsTypeInfo.Select(p => GetMarshalInfo(p, context)).ToList(); - var retMarshaller = GetMarshalInfo(retTypeInfo, context); - var statements = new List(); - if (retMarshaller.Generator.UsesNativeIdentifier(retTypeInfo, context)) + if (retMarshaller.Generator.UsesNativeIdentifier(retMarshaller.TypeInfo, this)) { - context.GenerateReturnNativeIdentifier(); + // Update the native identifier for the return value + ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; } foreach (var marshaller in paramMarshallers) @@ -106,21 +130,21 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt Token(SyntaxKind.DefaultKeyword))))); } - bool invokeReturnsVoid = retTypeInfo.ManagedType.SpecialType == SpecialType.System_Void; + bool invokeReturnsVoid = retMarshaller.TypeInfo.ManagedType.SpecialType == SpecialType.System_Void; bool stubReturnsVoid = stubMethod.ReturnsVoid; // Stub return is not the same as invoke return - if (!stubReturnsVoid && !retTypeInfo.IsManagedReturnPosition) + if (!stubReturnsVoid && !retMarshaller.TypeInfo.IsManagedReturnPosition) { - Debug.Assert(paramsTypeInfo.Any() && paramsTypeInfo.Last().IsManagedReturnPosition); + Debug.Assert(paramMarshallers.Any() && paramMarshallers.Last().TypeInfo.IsManagedReturnPosition); // Declare variable for stub return value - TypePositionInfo info = paramsTypeInfo.Last(); + TypePositionInfo info = paramMarshallers.Last().TypeInfo; statements.Add(LocalDeclarationStatement( VariableDeclaration( info.ManagedType.AsTypeSyntax(), SingletonSeparatedList( - VariableDeclarator(context.GetIdentifiers(info).managed))))); + VariableDeclarator(this.GetIdentifiers(info).managed))))); } if (!invokeReturnsVoid) @@ -128,34 +152,22 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt // Declare variable for invoke return value statements.Add(LocalDeclarationStatement( VariableDeclaration( - retTypeInfo.ManagedType.AsTypeSyntax(), + retMarshaller.TypeInfo.ManagedType.AsTypeSyntax(), SingletonSeparatedList( - VariableDeclarator(context.GetIdentifiers(retTypeInfo).managed))))); + VariableDeclarator(this.GetIdentifiers(retMarshaller.TypeInfo).managed))))); } - var stages = new Stage[] - { - Stage.Setup, - Stage.Marshal, - Stage.Pin, - Stage.Invoke, - Stage.KeepAlive, - Stage.Unmarshal, - Stage.GuaranteedUnmarshal, - Stage.Cleanup - }; - var invoke = InvocationExpression(IdentifierName(dllImportName)); var fixedStatements = new List(); - foreach (var stage in stages) + foreach (var stage in Stages) { int initialCount = statements.Count; - context.CurrentStage = stage; + this.CurrentStage = stage; if (!invokeReturnsVoid && (stage == Stage.Setup || stage == Stage.Unmarshal || stage == Stage.GuaranteedUnmarshal)) { // Handle setup and unmarshalling for return - var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, context); + var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, this); statements.AddRange(retStatements); } @@ -165,12 +177,12 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt if (stage == Stage.Invoke) { // Get arguments for invocation - ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, context); + ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, this); invoke = invoke.AddArgumentListArguments(argSyntax); } else { - var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, context); + var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); if (stage == Stage.Pin) { // Collect all the fixed statements. These will be used in the Invoke stage. @@ -203,7 +215,7 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt invokeStatement = ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, - IdentifierName(context.GetIdentifiers(retMarshaller.TypeInfo).native), + IdentifierName(this.GetIdentifiers(retMarshaller.TypeInfo).native), invoke)); } @@ -257,16 +269,5 @@ public static (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSynt return (codeBlock, dllImport); } - - private static (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) GetMarshalInfo(TypePositionInfo info, StubCodeContext context) - { - IMarshallingGenerator generator; - if (!MarshallingGenerators.TryCreate(info, context, out generator)) - { - // [TODO] Report warning - } - - return (info, generator); - } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index e816f8457d794..ac77297b71bb7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; -using DllImportGenerator; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -29,7 +29,7 @@ private TypePositionInfo() public RefKind RefKind { get; private set; } public SyntaxKind RefKindSyntax { get; private set; } - + public bool IsByRef => RefKind != RefKind.None; public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } @@ -41,9 +41,9 @@ private TypePositionInfo() public MarshallingInfo MarshallingAttributeInfo { get; private set; } - public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, Compilation compilation) + public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, Compilation compilation, GeneratorDiagnostics diagnostics) { - var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), compilation); + var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), compilation, diagnostics); var typeInfo = new TypePositionInfo() { ManagedType = paramSymbol.Type, @@ -56,9 +56,9 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, return typeInfo; } - public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation) + public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation, GeneratorDiagnostics diagnostics) { - var marshallingInfo = GetMarshallingInfo(type, attributes, compilation); + var marshallingInfo = GetMarshallingInfo(type, attributes, compilation, diagnostics); var typeInfo = new TypePositionInfo() { ManagedType = type, @@ -72,7 +72,7 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation) + private static MarshallingInfo? GetMarshallingInfo(ITypeSymbol type, IEnumerable attributes, Compilation compilation, GeneratorDiagnostics diagnostics) { MarshallingInfo? marshallingInfo = null; // Look at attributes on the type. @@ -87,7 +87,7 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable//generated`). A managed assembly with [native exports](./DllImportGenerator/TestAssets/NativeExports) is used in the P/Invoke scenario. ### Recommended scenarios: 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 2275072099faa..815db781816b6 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -9,7 +9,7 @@ namespace DllImportGenerator.UnitTests { public class Compiles { - public static IEnumerable CodeSnippetsToCompile() + public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() { yield return new[] { CodeSnippets.TrivialClassDeclarations }; yield return new[] { CodeSnippets.TrivialStructDeclarations }; @@ -20,7 +20,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.AllDllImportNamedArguments }; yield return new[] { CodeSnippets.DefaultParameters }; yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; - yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; + //yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -32,10 +32,74 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.VariantBool) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; + //yield return new[] { CodeSnippets.EnumParameters }; + yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + //yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.DelegateParametersAndModifiers }; + yield return new[] { CodeSnippets.DelegateMarshalAsParametersAndModifiers }; + yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; + yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + } + + public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() + { + yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; + + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -51,26 +115,12 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; - yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.VariantBool) }; - yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; + yield return new[] { CodeSnippets.EnumParameters }; - yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -86,16 +136,11 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.DelegateParametersAndModifiers }; - yield return new[] { CodeSnippets.DelegateMarshalAsParametersAndModifiers }; - yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; - yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; } [Theory] - [MemberData(nameof(CodeSnippetsToCompile))] - public async Task ValidateSnippets(string source) + [MemberData(nameof(CodeSnippetsToCompile_NoDiagnostics))] + public async Task ValidateSnippets_NoDiagnostics(string source) { Compilation comp = await TestUtils.CreateCompilation(source); TestUtils.AssertPreSourceGeneratorCompilation(comp); @@ -106,5 +151,20 @@ public async Task ValidateSnippets(string source) var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompile_WithDiagnostics))] + public async Task ValidateSnippets_WithDiagnostics(string source) + { + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + Assert.NotEmpty(generatorDiags); + Assert.All(generatorDiags, d => Assert.StartsWith(Microsoft.Interop.GeneratorDiagnostics.Ids.Prefix, d.Id)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs new file mode 100644 index 0000000000000..0ba00530c7c1e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs @@ -0,0 +1,264 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Threading.Tasks; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Text; +using Microsoft.Interop; +using Xunit; + +namespace DllImportGenerator.UnitTests +{ + public class Diagnostics + { + [Fact] + public async Task ParameterTypeNotSupported_ReportsDiagnostic() + { + string source = @" +using System.Collections.Generic; +using System.Runtime.InteropServices; +namespace NS +{ + class MyClass { } +} +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method1(NS.MyClass c); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method2(int i, List list); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ParameterTypeNotSupported)) + .WithSpan(11, 51, 11, 52) + .WithArguments("NS.MyClass", "c"), + (new DiagnosticResult(GeneratorDiagnostics.ParameterTypeNotSupported)) + .WithSpan(14, 57, 14, 61) + .WithArguments("System.Collections.Generic.List", "list"), + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + [Fact] + public async Task ReturnTypeNotSupported_ReportsDiagnostic() + { + string source = @" +using System.Collections.Generic; +using System.Runtime.InteropServices; +namespace NS +{ + class MyClass { } +} +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial NS.MyClass Method1(); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial List Method2(); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ReturnTypeNotSupported)) + .WithSpan(11, 38, 11, 45) + .WithArguments("NS.MyClass", "Method1"), + (new DiagnosticResult(GeneratorDiagnostics.ReturnTypeNotSupported)) + .WithSpan(14, 37, 14, 44) + .WithArguments("System.Collections.Generic.List", "Method2"), + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + [Fact] + public async Task ParameterConfigurationNotSupported_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method1([MarshalAs(UnmanagedType.BStr)] int i1, int i2); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method2(bool b1, [MarshalAs(UnmanagedType.FunctionPtr)] bool b2); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ParameterConfigurationNotSupported)) + .WithSpan(6, 76, 6, 78) + .WithArguments(nameof(MarshalAsAttribute), "i1"), + (new DiagnosticResult(GeneratorDiagnostics.ParameterConfigurationNotSupported)) + .WithSpan(9, 93, 9, 95) + .WithArguments(nameof(MarshalAsAttribute), "b2"), + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + [Fact] + public async Task ReturnConfigurationNotSupported_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.BStr)] + public static partial int Method1(int i); + + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.FunctionPtr)] + public static partial bool Method2(bool b); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ReturnConfigurationNotSupported)) + .WithSpan(7, 31, 7, 38) + .WithArguments(nameof(MarshalAsAttribute), "Method1"), + (new DiagnosticResult(GeneratorDiagnostics.ReturnConfigurationNotSupported)) + .WithSpan(11, 32, 11, 39) + .WithArguments(nameof(MarshalAsAttribute), "Method2"), + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + [Fact] + public async Task MarshalAsUnmanagedTypeNotSupported_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(1)] + public static partial int Method1(int i); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial bool Method2([MarshalAs((short)0)] bool b); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ConfigurationValueNotSupported)) + .WithSpan(6, 14, 6, 26) + .WithArguments(1, nameof(UnmanagedType)), + (new DiagnosticResult(GeneratorDiagnostics.ReturnConfigurationNotSupported)) + .WithSpan(7, 31, 7, 38) + .WithArguments(nameof(MarshalAsAttribute), "Method1"), + (new DiagnosticResult(GeneratorDiagnostics.ConfigurationValueNotSupported)) + .WithSpan(10, 41, 10, 60) + .WithArguments(0, nameof(UnmanagedType)), + (new DiagnosticResult(GeneratorDiagnostics.ParameterConfigurationNotSupported)) + .WithSpan(10, 67, 10, 68) + .WithArguments(nameof(MarshalAsAttribute), "b"), + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + [Fact] + public async Task MarshalAsFieldNotSupported_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.I4, SafeArraySubType=VarEnum.VT_I4)] + public static partial int Method1(int i); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial bool Method2([MarshalAs(UnmanagedType.I1, IidParameterIndex = 1)] bool b); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ConfigurationNotSupported)) + .WithSpan(6, 14, 6, 73) + .WithArguments($"{nameof(MarshalAsAttribute)}{Type.Delimiter}{nameof(MarshalAsAttribute.SafeArraySubType)}"), + (new DiagnosticResult(GeneratorDiagnostics.ConfigurationNotSupported)) + .WithSpan(10, 41, 10, 91) + .WithArguments($"{nameof(MarshalAsAttribute)}{Type.Delimiter}{nameof(MarshalAsAttribute.IidParameterIndex)}"), + }; + 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); + for (var i = 0; i < expectedDiagnostics.Length; i++) + { + DiagnosticResult expected = expectedDiagnostics[i]; + Diagnostic actual = actualDiagnostics[i]; + + Assert.Equal(expected.Id, actual.Id); + Assert.Equal(expected.Message, actual.GetMessage()); + Assert.Equal(expected.Severity, actual.Severity); + if (expected.HasLocation) + { + FileLinePositionSpan expectedSpan = expected.Spans[0].Span; + FileLinePositionSpan actualSpan = actual.Location.GetLineSpan(); + Assert.Equal(expectedSpan, actualSpan); + } + } + } + + private static Diagnostic[] GetSortedDiagnostics(IEnumerable diagnostics) + { + return diagnostics + .OrderBy(d => d.Location.GetLineSpan().Path, StringComparer.Ordinal) + .ThenBy(d => d.Location.SourceSpan.Start) + .ThenBy(d => d.Location.SourceSpan.End) + .ThenBy(d => d.Id) + .ToArray(); + } + } +} diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 4cee92efcd88d..0ca8c597da9a5 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -6,6 +6,10 @@ true preview + + true + true From d4393f8761133781cd70be3e59782f823c791567 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 14 Oct 2020 09:23:46 -0700 Subject: [PATCH 026/161] Add Char marshaller (dotnet/runtimelab#212) * Support for char marshaller. Avoid supporting the built-in semantics for ANSI marshalling of char. Propagate the CharSet down to the marshallers. Convert the MarshallingGenerators.TryCreate() to a MarshallingGenerators.Create() function throwing an exception. * Add a compatibility document. * Add testing for char marshalling. Commit migrated from https://github.com/dotnet/runtimelab/commit/be3f4e8b23c3740e83b3a6b20dda7ad41a077118 --- .../gen/DllImportGenerator/DllImportStub.cs | 18 ++- .../GeneratorDiagnostics.cs | 60 ++++++++-- .../Marshalling/CharMarshaller.cs | 93 ++++++++++++++++ .../Marshalling/MarshallingGenerator.cs | 104 +++++++++++++----- .../MarshallingAttributeInfo.cs | 21 +++- .../DllImportGenerator/Resources.Designer.cs | 36 ++++++ .../gen/DllImportGenerator/Resources.resx | 12 ++ .../DllImportGenerator/StubCodeGenerator.cs | 28 +++-- .../DllImportGenerator/TypePositionInfo.cs | 45 ++++++-- .../DllImportGenerator/Compatibility.md | 24 ++++ .../CharacterTests.cs | 82 ++++++++++++++ .../CodeSnippets.cs | 19 ++++ .../CompileFails.cs | 29 +++-- .../DllImportGenerator.UnitTests/Compiles.cs | 9 +- .../TestAssets/NativeExports/Characters.cs | 25 +++++ 15 files changed, 520 insertions(+), 85 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index f062532c74097..46e35ddff34e5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -131,18 +131,32 @@ public static DllImportStub Create( currType = currType.ContainingType; } + // Compute the current default string encoding value. + var defaultEncoding = CharEncoding.Undefined; + if (dllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet)) + { + defaultEncoding = dllImportData.CharSet switch + { + CharSet.Unicode => CharEncoding.Utf16, + CharSet.Auto => CharEncoding.PlatformDefined, + _ => CharEncoding.Utf8, // [Compat] ANSI is no longer ANSI code pages on Windows and UTF-8, on non-Windows. + }; + } + + var defaultInfo = new DefaultMarshallingInfo(defaultEncoding); + // Determine parameter and return types var paramsTypeInfo = new List(); for (int i = 0; i < method.Parameters.Length; i++) { var param = method.Parameters[i]; - var typeInfo = TypePositionInfo.CreateForParameter(param, compilation, diagnostics); + var typeInfo = TypePositionInfo.CreateForParameter(param, defaultInfo, compilation, diagnostics); typeInfo.ManagedIndex = i; typeInfo.NativeIndex = paramsTypeInfo.Count; paramsTypeInfo.Add(typeInfo); } - TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), compilation, diagnostics); + TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), defaultInfo, compilation, diagnostics); retTypeInfo.ManagedIndex = TypePositionInfo.ReturnIndex; retTypeInfo.NativeIndex = TypePositionInfo.ReturnIndex; if (!dllImportData.PreserveSig) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 17657fe4eaf53..51f64e6a870e3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -65,7 +65,7 @@ public class Ids Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(Resources.TypeNotSupportedDescription)); + description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); public readonly static DiagnosticDescriptor ReturnTypeNotSupported = new DiagnosticDescriptor( @@ -75,7 +75,27 @@ public class Ids Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(Resources.TypeNotSupportedDescription)); + description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); + + public readonly static DiagnosticDescriptor ParameterTypeNotSupportedWithDetails = + new DiagnosticDescriptor( + Ids.TypeNotSupported, + GetResourceString(nameof(Resources.TypeNotSupportedTitle)), + GetResourceString(nameof(Resources.TypeNotSupportedMessageParameterWithDetails)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); + + public readonly static DiagnosticDescriptor ReturnTypeNotSupportedWithDetails = + new DiagnosticDescriptor( + Ids.TypeNotSupported, + GetResourceString(nameof(Resources.TypeNotSupportedTitle)), + GetResourceString(nameof(Resources.TypeNotSupportedMessageReturnWithDetails)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); public readonly static DiagnosticDescriptor ParameterConfigurationNotSupported = new DiagnosticDescriptor( @@ -85,7 +105,7 @@ public class Ids Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); public readonly static DiagnosticDescriptor ReturnConfigurationNotSupported = new DiagnosticDescriptor( @@ -95,7 +115,7 @@ public class Ids Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); public readonly static DiagnosticDescriptor ConfigurationNotSupported = new DiagnosticDescriptor( @@ -105,7 +125,7 @@ public class Ids Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); public readonly static DiagnosticDescriptor ConfigurationValueNotSupported = new DiagnosticDescriptor( @@ -115,7 +135,7 @@ public class Ids Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(Resources.ConfigurationNotSupportedDescription)); + description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); private readonly GeneratorExecutionContext context; @@ -157,11 +177,35 @@ public void ReportConfigurationNotSupported( /// /// Method with the parameter/return /// Type info for the parameter/return + /// [Optional] Specific reason for lack of support internal void ReportMarshallingNotSupported( IMethodSymbol method, - TypePositionInfo info) + TypePositionInfo info, + string? notSupportedDetails) { - if (info.MarshallingAttributeInfo != null && info.MarshallingAttributeInfo is MarshalAsInfo) + if (!string.IsNullOrEmpty(notSupportedDetails)) + { + // Report the specific not-supported reason. + if (info.IsManagedReturnPosition) + { + this.context.ReportDiagnostic( + method.CreateDiagnostic( + GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails, + notSupportedDetails!, + method.Name)); + } + else + { + Debug.Assert(info.ManagedIndex <= method.Parameters.Length); + IParameterSymbol paramSymbol = method.Parameters[info.ManagedIndex]; + this.context.ReportDiagnostic( + paramSymbol.CreateDiagnostic( + GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails, + notSupportedDetails!, + paramSymbol.Name)); + } + } + else if (info.MarshallingAttributeInfo != null && info.MarshallingAttributeInfo is MarshalAsInfo) { // Report that the specified marshalling configuration is not supported. // We don't forward marshalling attributes, so this is reported differently diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs new file mode 100644 index 0000000000000..4ecf0329ec816 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal class Utf16CharMarshaller : IMarshallingGenerator + { + private static readonly PredefinedTypeSyntax NativeType = PredefinedType(Token(SyntaxKind.UShortKeyword)); + + public Utf16CharMarshaller() + { + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Char); + return NativeType; + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + IdentifierName(managedIdentifier))); + } + + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + CastExpression( + PredefinedType( + Token(SyntaxKind.CharKeyword)), + IdentifierName(nativeIdentifier)))); + } + + break; + default: + break; + } + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index e2572ad6cf7b8..8a96624dd2819 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -59,21 +60,61 @@ internal interface IMarshallingGenerator bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); } + /// + /// Exception used to indicate marshalling isn't supported. + /// + internal class MarshallingNotSupportedException : Exception + { + /// + /// Construct a new instance. + /// + /// instance + /// instance + public MarshallingNotSupportedException(TypePositionInfo info, StubCodeContext context) + { + this.TypePositionInfo = info; + this.StubCodeContext = context; + } + + /// + /// Type that is being marshalled. + /// + public TypePositionInfo TypePositionInfo { get; private init; } + + /// + /// Context the marshalling is taking place. + /// + public StubCodeContext StubCodeContext { get; private init; } + + /// + /// [Optional] Specific reason marshalling of the supplied type isn't supported. + /// + public string NotSupportedDetails { get; init; } + } + internal class MarshallingGenerators { public static readonly ByteBoolMarshaller ByteBool = new ByteBoolMarshaller(); public static readonly WinBoolMarshaller WinBool = new WinBoolMarshaller(); public static readonly VariantBoolMarshaller VariantBool = new VariantBoolMarshaller(); + public static readonly Utf16CharMarshaller Utf16Char = new Utf16CharMarshaller(); public static readonly Forwarder Forwarder = new Forwarder(); public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); public static readonly SafeHandleMarshaller SafeHandle = new SafeHandleMarshaller(); - public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out IMarshallingGenerator generator) + /// + /// Create an instance to marshalling the supplied type. + /// + /// Type details + /// Metadata about the stub the type is associated with + /// A instance. + public static IMarshallingGenerator Create( + TypePositionInfo info, + StubCodeContext context) { #if GENERATE_FORWARDER - generator = MarshallingGenerators.Forwarder; - return true; + return MarshallingGenerators.Forwarder; #else if (info.IsNativeReturnPosition && !info.IsManagedReturnPosition) { @@ -96,51 +137,58 @@ public static bool TryCreate(TypePositionInfo info, StubCodeContext context, out or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: null} or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.R4 } } or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.R8 } }: - generator = Blittable; - return true; + return Blittable; case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: null }: - generator = WinBool; // [Compat] Matching the default for the built-in runtime marshallers. - return true; + return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I1 or UnmanagedType.U1 } }: - generator = ByteBool; - return true; + return ByteBool; case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool } }: - generator = WinBool; - return true; + return WinBool; case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.VariantBool } }: - generator = VariantBool; - return true; + return VariantBool; + + case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: null }: + return Utf16Char; // [Compat] Default marshalling is UTF-16. + case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I2 } }: + return Utf16Char; + case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.U2 } }: + return Utf16Char; + case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshallingInfoStringSupport { CharEncoding: CharEncoding.Utf16 } }: + return Utf16Char; + case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshallingInfoStringSupport { CharEncoding: CharEncoding.Utf8 } }: + throw new MarshallingNotSupportedException(info, context) // [Compat] See conversion from CharSet.Ansi to UTF-8. + { + NotSupportedDetails = Resources.MarshallingCharAsCharSetAnsiNotSupported + }; + case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshallingInfoStringSupport { CharEncoding: CharEncoding.PlatformDefined } }: + throw new MarshallingNotSupportedException(info, context) // [Compat] See conversion of CharSet.Auto. + { + NotSupportedDetails = Resources.MarshallingCharAsCharSetAutoNotSupported + }; case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.FunctionPtr } }: - generator = Delegate; - return true; + return Delegate; case { MarshallingAttributeInfo: BlittableTypeAttributeInfo _ }: - generator = Blittable; - return true; + return Blittable; // Marshalling in new model case { MarshallingAttributeInfo: NativeMarshallingAttributeInfo marshalInfo }: - generator = Forwarder; - return false; + return Forwarder; // Simple marshalling with new attribute model, only have type name. case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo { NativeMarshallingFullyQualifiedTypeName: string name } }: - generator = Forwarder; - return false; + return Forwarder; case { MarshallingAttributeInfo: SafeHandleMarshallingInfo _}: - generator = SafeHandle; - return true; + return SafeHandle; case { ManagedType: { SpecialType: SpecialType.System_Void } }: - generator = Forwarder; - return true; + return Forwarder; default: - generator = Forwarder; - return false; + throw new MarshallingNotSupportedException(info, context); } #endif } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 0462c8cdd1915..913de016c7b32 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -14,6 +14,24 @@ namespace Microsoft.Interop internal abstract record MarshallingInfo {} + /// + /// Character encoding enumeration. + /// + internal enum CharEncoding + { + Undefined, + Utf8, + Utf16, + PlatformDefined + } + + /// + /// Details that are required when scenario supports strings. + /// + internal record MarshallingInfoStringSupport( + CharEncoding CharEncoding + ) : MarshallingInfo; + /// /// User-applied System.Runtime.InteropServices.MarshalAsAttribute /// @@ -23,7 +41,8 @@ internal sealed record MarshalAsInfo( string? CustomMarshallerCookie, UnmanagedType UnmanagedArraySubType, int ArraySizeConst, - short ArraySizeParamIndex) : MarshallingInfo; + short ArraySizeParamIndex, + CharEncoding CharEncoding) : MarshallingInfoStringSupport(CharEncoding); /// /// User-applied System.Runtime.InteropServices.BlittableTypeAttribute 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 67f0b5f785e3f..e4f93f4bdc718 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -186,6 +186,24 @@ internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFal } } + /// + /// Looks up a localized string similar to Marshalling char with CharSet.Ansi is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. + /// + internal static string MarshallingCharAsCharSetAnsiNotSupported { + get { + return ResourceManager.GetString("MarshallingCharAsCharSetAnsiNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Marshalling char with CharSet.Auto is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. + /// + internal static string MarshallingCharAsCharSetAutoNotSupported { + get { + return ResourceManager.GetString("MarshallingCharAsCharSetAutoNotSupported", resourceCulture); + } + } + /// /// Looks up a localized string similar to A native type for a given type must be blittable.. /// @@ -312,6 +330,15 @@ internal static string TypeNotSupportedMessageParameter { } } + /// + /// Looks up a localized string similar to {0} The generated source will not handle marshalling of parameter '{1}'.. + /// + internal static string TypeNotSupportedMessageParameterWithDetails { + get { + return ResourceManager.GetString("TypeNotSupportedMessageParameterWithDetails", resourceCulture); + } + } + /// /// Looks up a localized string similar to The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of the return value of method '{1}'.. /// @@ -321,6 +348,15 @@ internal static string TypeNotSupportedMessageReturn { } } + /// + /// Looks up a localized string similar to {0} The generated source will not handle marshalling of the return value of method '{1}'.. + /// + internal static string TypeNotSupportedMessageReturnWithDetails { + get { + return ResourceManager.GetString("TypeNotSupportedMessageReturnWithDetails", resourceCulture); + } + } + /// /// Looks up a localized string similar to Specified type is not supported by source-generated P/Invokes. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 9568b0305d559..d9a0508027e96 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -159,6 +159,12 @@ Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible + + Marshalling char with CharSet.Ansi is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. + + + Marshalling char with CharSet.Auto is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. + A native type for a given type must be blittable. @@ -201,9 +207,15 @@ The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter '{1}'. + + {0} The generated source will not handle marshalling of parameter '{1}'. + The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of the return value of method '{1}'. + + {0} The generated source will not handle marshalling of the return value of method '{1}'. + Specified type is not supported by source-generated P/Invokes diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index a28c856026ac9..9d5c2763200fe 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -59,25 +59,23 @@ public StubCodeGenerator( this.diagnostics = generatorDiagnostics; // Get marshallers for parameters - this.paramMarshallers = paramsTypeInfo.Select(p => - { - IMarshallingGenerator generator; - if (!MarshallingGenerators.TryCreate(p, this, out generator)) - { - this.diagnostics.ReportMarshallingNotSupported(this.stubMethod, p); - } - - return (p, generator); - }).ToList(); + this.paramMarshallers = paramsTypeInfo.Select(p => CreateGenerator(p)).ToList(); // Get marshaller for return - IMarshallingGenerator retGenerator; - if (!MarshallingGenerators.TryCreate(retTypeInfo, this, out retGenerator)) + this.retMarshaller = CreateGenerator(retTypeInfo); + + (TypePositionInfo info, IMarshallingGenerator gen) CreateGenerator(TypePositionInfo p) { - this.diagnostics.ReportMarshallingNotSupported(this.stubMethod, retTypeInfo); + try + { + return (p, MarshallingGenerators.Create(p, this)); + } + catch (MarshallingNotSupportedException e) + { + this.diagnostics.ReportMarshallingNotSupported(this.stubMethod, p, e.NotSupportedDetails); + return (p, MarshallingGenerators.Forwarder); + } } - - this.retMarshaller = (retTypeInfo, retGenerator); } public override (string managed, string native) GetIdentifiers(TypePositionInfo info) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index ac77297b71bb7..2ef1705dcbeb5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -9,6 +9,13 @@ namespace Microsoft.Interop { + /// + /// Type used to pass on default marshalling details. + /// + internal sealed record DefaultMarshallingInfo ( + CharEncoding CharEncoding + ); + /// /// Positional type information involved in unmanaged/managed scenarios. /// @@ -41,9 +48,9 @@ private TypePositionInfo() public MarshallingInfo MarshallingAttributeInfo { get; private set; } - public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, Compilation compilation, GeneratorDiagnostics diagnostics) + public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { - var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), compilation, diagnostics); + var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), defaultInfo, compilation, diagnostics); var typeInfo = new TypePositionInfo() { ManagedType = paramSymbol.Type, @@ -56,9 +63,9 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, return typeInfo; } - public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation, GeneratorDiagnostics diagnostics) + public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { - var marshallingInfo = GetMarshallingInfo(type, attributes, compilation, diagnostics); + var marshallingInfo = GetMarshallingInfo(type, attributes, defaultInfo, compilation, diagnostics); var typeInfo = new TypePositionInfo() { ManagedType = type, @@ -72,10 +79,11 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, Compilation compilation, GeneratorDiagnostics diagnostics) + private static MarshallingInfo? GetMarshallingInfo(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { MarshallingInfo? marshallingInfo = null; - // Look at attributes on the type. + + // Look at attributes passed in - usage specific. foreach (var attrData in attributes) { INamedTypeSymbol attributeClass = attrData.AttributeClass!; @@ -87,7 +95,7 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable CharacterMappings() + { + yield return new object[] { 'A', 0x41 }; + yield return new object[] { 'E', 0x45 }; + yield return new object[] { 'J', 0x4a }; + yield return new object[] { 'ß', 0xdf }; + yield return new object[] { '✅', 0x2705 }; + yield return new object[] { '鸟', 0x9e1f }; + } + + [Theory] + [MemberData(nameof(CharacterMappings))] + public void ValidateUnicodeCharIsMarshalledAsExpected(char value, uint expected) + { + Assert.Equal(expected, NativeExportsNE.ReturnDefaultAsUInt(value)); + Assert.Equal(expected, NativeExportsNE.ReturnUnicodeAsUInt(value)); + } + + [Theory] + [MemberData(nameof(CharacterMappings))] + public void ValidateUnicodeReturns(char expected, uint value) + { + Assert.Equal(expected, NativeExportsNE.ReturnUIntAsDefault(value)); + Assert.Equal(expected, NativeExportsNE.ReturnUIntAsUnicode(value)); + + char result = '\u0000'; + NativeExportsNE.ReturnUIntAsRefUnicode(value, ref result); + Assert.Equal(expected, result); + + result = '\u0000'; + NativeExportsNE.ReturnUIntAsOutUnicode(value, out result); + Assert.Equal(expected, result); + } + + [Theory] + [MemberData(nameof(CharacterMappings))] + public void ValidateIgnoreCharSet(char value, uint expectedUInt) + { + char expected = (char)expectedUInt; + Assert.Equal(expected, NativeExportsNE.ReturnU2AsU2IgnoreCharSet(value)); + Assert.Equal(expected, NativeExportsNE.ReturnI2AsI2IgnoreCharSet(value)); + } + } +} 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 06b8156a943c0..cf9bbeba577c1 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -281,6 +281,25 @@ partial class Test } "; + /// + /// Declaration with parameters with set. + /// + public static string BasicParametersAndModifiersWithCharSet(string typename, CharSet value) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"", CharSet = CharSet.{value})] + public static partial {typename} Method( + {typename} p, + in {typename} pIn, + ref {typename} pRef, + out {typename} pOut); +}} +"; + + public static string BasicParametersAndModifiersWithCharSet(CharSet value) => + BasicParametersAndModifiersWithCharSet(typeof(T).ToString(), value); + /// /// 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 bf31ff47d7438..3f49dec885d69 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -1,5 +1,7 @@ using Microsoft.CodeAnalysis; using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Xunit; @@ -9,32 +11,29 @@ public class CompileFails { public static IEnumerable CodeSnippetsToCompile() { - yield return new object[] { CodeSnippets.UserDefinedPrefixedAttributes, 3 }; + yield return new object[] { CodeSnippets.UserDefinedPrefixedAttributes, 0, 3 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto), 5, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.None), 5, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi), 5, 0 }; + yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1), 5, 0 }; + yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.U1), 5, 0 }; } [Theory] [MemberData(nameof(CodeSnippetsToCompile))] - public async Task ValidateSnippets(string source, int failCount) + public async Task ValidateSnippets(string source, int expectedGeneratorErrors, int expectedCompilerErrors) { Compilation comp = await TestUtils.CreateCompilation(source); TestUtils.AssertPreSourceGeneratorCompilation(comp); var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); - Assert.Empty(generatorDiags); - var newCompDiags = newComp.GetDiagnostics(); + // Verify the compilation failed with errors. + int generatorErrors = generatorDiags.Count(d => d.Severity == DiagnosticSeverity.Error); + Assert.Equal(expectedGeneratorErrors, generatorErrors); - // Verify the compilation failed with missing impl. - int missingImplCount = 0; - foreach (var diag in newCompDiags) - { - if ("CS8795".Equals(diag.Id)) - { - missingImplCount++; - } - } - - Assert.Equal(failCount, missingImplCount); + int compilerErrors = newComp.GetDiagnostics().Count(d => d.Severity == DiagnosticSeverity.Error); + Assert.Equal(expectedCompilerErrors, compilerErrors); } } } 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 815db781816b6..f9ba148e046f4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -32,7 +32,7 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -51,9 +51,12 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.VariantBool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I2) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.U2) }; //yield return new[] { CodeSnippets.EnumParameters }; yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -67,7 +70,7 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.PreserveSigFalse() }; //yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -97,7 +100,6 @@ public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() { yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -118,7 +120,6 @@ public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() yield return new[] { CodeSnippets.EnumParameters }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs new file mode 100644 index 0000000000000..768b276b43e23 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs @@ -0,0 +1,25 @@ +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class Characters + { + [UnmanagedCallersOnly(EntryPoint = "unicode_return_as_uint")] + public static uint ReturnUnicodeAsUInt(ushort input) + { + return input; + } + + [UnmanagedCallersOnly(EntryPoint = "char_return_as_uint")] + public static uint ReturnUIntAsUInt(uint input) + { + return input; + } + + [UnmanagedCallersOnly(EntryPoint = "char_return_as_refuint")] + public static void ReturnUIntAsRefUInt(uint input, uint* res) + { + *res = input; + } + } +} From 9e6fb96ad71f2924b5191ad045642272eae4a396 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 14 Oct 2020 11:53:06 -0700 Subject: [PATCH 027/161] Fix warnings for analyzer release (dotnet/runtimelab#227) * Fix some warnings about analyzer authoring Commit migrated from https://github.com/dotnet/runtimelab/commit/c89fc418755eadc8dc457a298a032caa45273b8c --- .../AnalyzerReleases.Shipped.md | 20 +++++++++++++++ .../GeneratorDiagnostics.cs | 2 +- .../ManualTypeMarshallingAnalyzer.cs | 25 ++++++++++--------- 3 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md new file mode 100644 index 0000000000000..449faf2f65ef3 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md @@ -0,0 +1,20 @@ +## Release 1.0 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +DLLIMPORTGEN001 | Usage | Error +DLLIMPORTGEN002 | Usage | Error +DLLIMPORTGENANALYZER001 | Usage | Error +DLLIMPORTGENANALYZER002 | Usage | Error +DLLIMPORTGENANALYZER003 | Usage | Error +DLLIMPORTGENANALYZER004 | Usage | Error +DLLIMPORTGENANALYZER005 | Usage | Error +DLLIMPORTGENANALYZER006 | Usage | Error +DLLIMPORTGENANALYZER007 | Usage | Error +DLLIMPORTGENANALYZER008 | Usage | Error +DLLIMPORTGENANALYZER009 | Usage | Error +DLLIMPORTGENANALYZER010 | Usage | Warning +DLLIMPORTGENANALYZER011 | Usage | Warning +DLLIMPORTGENANALYZER012 | Usage | Error diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 51f64e6a870e3..b4b29420052fb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -55,7 +55,7 @@ public class Ids public const string ConfigurationNotSupported = Prefix + "002"; } - private const string Category = "DllImportGenerator"; + private const string Category = "SourceGeneration"; public readonly static DiagnosticDescriptor ParameterTypeNotSupported = new DiagnosticDescriptor( diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs index 8366ca698ed99..0cc4f2beb5fd9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -12,10 +12,11 @@ namespace Microsoft.Interop [DiagnosticAnalyzer(LanguageNames.CSharp)] public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer { + public const string Prefix = "DLLIMPORTGENANALYZER"; private const string Category = "Usage"; public readonly static DiagnosticDescriptor BlittableTypeMustBeBlittableRule = new DiagnosticDescriptor( - "INTEROPGEN001", + Prefix + "001", "BlittableTypeMustBeBlittable", new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -25,7 +26,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor CannotHaveMultipleMarshallingAttributesRule = new DiagnosticDescriptor( - "INTEROPGEN002", + Prefix + "002", "CannotHaveMultipleMarshallingAttributes", new LocalizableResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -36,7 +37,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustBeNonNullRule = new DiagnosticDescriptor( - "INTEROPGEN003", + Prefix + "003", "NativeTypeMustBeNonNull", new LocalizableResourceString(nameof(Resources.NativeTypeMustBeNonNullMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -46,7 +47,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustBeBlittableRule = new DiagnosticDescriptor( - "INTEROPGEN004", + Prefix + "004", "NativeTypeMustBeBlittable", new LocalizableResourceString(nameof(Resources.NativeTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -56,7 +57,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor GetPinnableReferenceReturnTypeBlittableRule = new DiagnosticDescriptor( - "INTEROPGEN005", + Prefix + "005", "GetPinnableReferenceReturnTypeBlittable", new LocalizableResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -66,7 +67,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustBePointerSizedRule = new DiagnosticDescriptor( - "INTEROPGEN006", + Prefix + "006", "NativeTypeMustBePointerSized", new LocalizableResourceString(nameof(Resources.NativeTypeMustBePointerSizedMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -76,7 +77,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustHaveRequiredShapeRule = new DiagnosticDescriptor( - "INTEROPGEN007", + Prefix + "007", "NativeTypeMustHaveRequiredShape", new LocalizableResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -86,7 +87,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor ValuePropertyMustHaveSetterRule = new DiagnosticDescriptor( - "INTEROPGEN008", + Prefix + "008", "ValuePropertyMustHaveSetter", new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveSetterMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -96,7 +97,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor ValuePropertyMustHaveGetterRule = new DiagnosticDescriptor( - "INTEROPGEN009", + Prefix + "009", "ValuePropertyMustHaveGetter", new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveGetterMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -106,7 +107,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( - "INTEROPGEN010", + Prefix + "010", "GetPinnableReferenceShouldSupportAllocatingMarshallingFallback", new LocalizableResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -116,7 +117,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( - "INTEROPGEN011", + Prefix + "011", "StackallocMarshallingShouldSupportAllocatingMarshallingFallback", new LocalizableResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -126,7 +127,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor StackallocConstructorMustHaveStackBufferSizeConstantRule = new DiagnosticDescriptor( - "INTEROPGEN012", + Prefix + "012", "StackallocConstructorMustHaveStackBufferSizeConstant", new LocalizableResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantMessage), Resources.ResourceManager, typeof(Resources)), Category, From 25be33e186a01a37ecaa04c87ad3950d9bae26b4 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Thu, 8 Oct 2020 20:41:21 -0700 Subject: [PATCH 028/161] Create branch template for standalone templates. Commit migrated from https://github.com/dotnet/runtimelab/commit/891d530a4b46bafd3fbb1146ce4e8553dbce36e3 --- CreateAnExperiment.md | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 CreateAnExperiment.md diff --git a/CreateAnExperiment.md b/CreateAnExperiment.md deleted file mode 100644 index c6073628ae6cb..0000000000000 --- a/CreateAnExperiment.md +++ /dev/null @@ -1,14 +0,0 @@ -# Create an experiment - -Experiments should be contained within a branch in the dotnet/runtimelab repository. Keeping all experiments branches in one repository helps with community visibility. - -## Steps to setup a new experiment - -- Pick a good name for your experiment and create branch for it in dotnet/runtimelab. Branch names should be prefixed with `feature/` in order to have official build support. - - If the experiment is expected to require changes of .NET runtime itself, it should be branched off of [dotnet/runtimelab:runtime-master](https://github.com/dotnet/runtimelab/tree/runtime-master) that is a manually maitained mirror of [dotnet/runtime:master](https://github.com/dotnet/runtime/tree/master). - - Otherwise, the experiment should be branched off of [dotnet/runtimelab:master](https://github.com/dotnet/runtimelab/tree/master) to get the required boilerplate such as LICENSE.TXT. -- Submit a PR to update the [README.MD](https://github.com/dotnet/runtimelab/blob/master/README.md#active-experimental-projects) with the name of your branch and a brief description of the experiment. Example: [#19](https://github.com/dotnet/runtimelab/pull/19/files) -- Create label `area-` for tagging issues. The label should use color `#d4c5f9`. -- If your experiment is branched from dotnet/runtime: - - Enable CI builds by editing `eng/pipelines/runtimelab.yml` in your branch. Example: [#137](https://github.com/dotnet/runtimelab/pull/137/files) - - To avoid spurious github notifications for merges from upstream, delete `.github/CODEOWNERS` from your branch or replace it with setting specific to your experiment. Example: [#26](https://github.com/dotnet/runtimelab/pull/26/files) From 6bb8819ca6d0f9fc24ca174778f60f1ebe1abc62 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 20 Oct 2020 11:19:47 -0700 Subject: [PATCH 029/161] Enable nullability checks across DllImportGenerator (dotnet/runtimelab#213) Commit migrated from https://github.com/dotnet/runtimelab/commit/7b2591d6531af56420092d0ae136911ae507e218 --- .../DllImportGenerator/DllImportGenerator.cs | 36 +++++++++---------- .../DllImportGenerator.csproj | 1 + .../gen/DllImportGenerator/DllImportStub.cs | 13 ++++--- .../ManualTypeMarshallingAnalyzer.cs | 2 -- .../ManualTypeMarshallingHelper.cs | 1 - .../Marshalling/MarshallingGenerator.cs | 2 +- .../MarshallingAttributeInfo.cs | 2 -- .../DllImportGenerator/TypePositionInfo.cs | 9 +++-- .../TypeSymbolExtensions.cs | 2 -- .../GeneratedMarshallingAttribute.cs | 1 - .../DllImportGenerator.Tests.csproj | 1 + .../DllImportGenerator.UnitTests.csproj | 1 + .../Verifiers/CSharpAnalyzerVerifier.cs | 4 +-- .../DllImportGeneratorSample.csproj | 1 + 14 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 7d7e42eacb0c7..1b4588f3fc05a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -49,17 +49,17 @@ public void Execute(GeneratorExecutionContext context) } // Process the method syntax and get its SymbolInfo. - var methodSymbolInfo = sm.GetDeclaredSymbol(methodSyntax, context.CancellationToken); + var methodSymbolInfo = sm.GetDeclaredSymbol(methodSyntax, context.CancellationToken)!; // Process the attributes on the method. DllImportStub.GeneratedDllImportData dllImportData; AttributeSyntax dllImportAttr = this.ProcessAttributes(methodSymbolInfo, context.CancellationToken, out dllImportData); - Debug.Assert(!(dllImportAttr is null) && !(dllImportData is null)); + Debug.Assert((dllImportAttr is not null) && (dllImportData is not null)); // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData, context.Compilation, generatorDiagnostics, context.CancellationToken); + var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData!, context.Compilation, generatorDiagnostics, context.CancellationToken); - PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub, dllImportAttr); + PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub, dllImportAttr!); } Debug.WriteLine(generatedDllImports.ToString()); // [TODO] Find some way to emit this for debugging - logs? @@ -161,7 +161,7 @@ private AttributeSyntax ProcessAttributes( // Found the GeneratedDllImport, but it has an error so report the error. // This is most likely an issue with targeting an incorrect TFM. - if (attrData.AttributeClass.TypeKind == TypeKind.Error) + if (attrData.AttributeClass?.TypeKind is null or TypeKind.Error) { // [TODO] Report GeneratedDllImport has an error - corrupt metadata? throw new InvalidProgramException(); @@ -170,7 +170,7 @@ private AttributeSyntax ProcessAttributes( var newAttributeArgs = new List(); // Populate the DllImport data from the GeneratedDllImportAttribute attribute. - dllImportData.ModuleName = attrData.ConstructorArguments[0].Value.ToString(); + dllImportData.ModuleName = attrData.ConstructorArguments[0].Value!.ToString(); newAttributeArgs.Add(SyntaxFactory.AttributeArgument(SyntaxFactory.LiteralExpression( SyntaxKind.StringLiteralExpression, @@ -179,60 +179,60 @@ private AttributeSyntax ProcessAttributes( // All other data on attribute is defined as NamedArguments. foreach (var namedArg in attrData.NamedArguments) { - ExpressionSyntax expSyntaxMaybe = null; + ExpressionSyntax? expSyntaxMaybe = null; switch (namedArg.Key) { default: Debug.Fail($"An unknown member was found on {GeneratedDllImport}"); continue; case nameof(DllImportStub.GeneratedDllImportData.BestFitMapping): - dllImportData.BestFitMapping = (bool)namedArg.Value.Value; + dllImportData.BestFitMapping = (bool)namedArg.Value.Value!; expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.BestFitMapping); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.BestFitMapping; break; case nameof(DllImportStub.GeneratedDllImportData.CallingConvention): - dllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value; + dllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value!; expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CallingConvention); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CallingConvention; break; case nameof(DllImportStub.GeneratedDllImportData.CharSet): - dllImportData.CharSet = (CharSet)namedArg.Value.Value; + dllImportData.CharSet = (CharSet)namedArg.Value.Value!; expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CharSet); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CharSet; break; case nameof(DllImportStub.GeneratedDllImportData.EntryPoint): - dllImportData.EntryPoint = (string)namedArg.Value.Value; - expSyntaxMaybe = CreateStringExpressionSyntax(dllImportData.EntryPoint); + dllImportData.EntryPoint = (string)namedArg.Value.Value!; + expSyntaxMaybe = CreateStringExpressionSyntax(dllImportData.EntryPoint!); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.EntryPoint; break; case nameof(DllImportStub.GeneratedDllImportData.ExactSpelling): - dllImportData.ExactSpelling = (bool)namedArg.Value.Value; + dllImportData.ExactSpelling = (bool)namedArg.Value.Value!; expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ExactSpelling); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ExactSpelling; break; case nameof(DllImportStub.GeneratedDllImportData.PreserveSig): - dllImportData.PreserveSig = (bool)namedArg.Value.Value; + dllImportData.PreserveSig = (bool)namedArg.Value.Value!; expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.PreserveSig); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.PreserveSig; break; case nameof(DllImportStub.GeneratedDllImportData.SetLastError): - dllImportData.SetLastError = (bool)namedArg.Value.Value; + dllImportData.SetLastError = (bool)namedArg.Value.Value!; expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.SetLastError); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.SetLastError; break; case nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar): - dllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value; + dllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value!; expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ThrowOnUnmappableChar); dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ThrowOnUnmappableChar; break; } - Debug.Assert(!(expSyntaxMaybe is null)); + Debug.Assert(expSyntaxMaybe is not null); // Defer the name equals syntax till we know the value means something. If we created // an expression we know the key value was valid. NameEqualsSyntax nameSyntax = SyntaxFactory.NameEquals(namedArg.Key); - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe)); + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe!)); } // If the EntryPoint property is not set, we will compute and diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 20b90b8c0045d..b64ed81b96b47 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -7,6 +7,7 @@ True true Preview + enable Microsoft.Interop diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 46e35ddff34e5..a5295ac416027 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -18,11 +18,16 @@ internal class DllImportStub private TypePositionInfo returnTypeInfo; private IEnumerable paramsTypeInfo; +// We don't need the warnings around not setting the various +// non-nullable fields/properties on this type in the constructor +// since we always use a property initializer. +#pragma warning disable 8618 private DllImportStub() { } +#pragma warning restore - public string StubTypeNamespace { get; private set; } + public string? StubTypeNamespace { get; private set; } public IEnumerable StubContainingTypes { get; private set; } @@ -75,7 +80,7 @@ public enum DllImportMember /// public class GeneratedDllImportData { - public string ModuleName { get; set; } + public string ModuleName { get; set; } = null!; /// /// Value set by the user on the original declaration. @@ -88,7 +93,7 @@ public class GeneratedDllImportData public bool BestFitMapping { get; set; } = true; public CallingConvention CallingConvention { get; set; } = CallingConvention.Winapi; public CharSet CharSet { get; set; } = CharSet.Ansi; - public string EntryPoint { get; set; } = null; + public string EntryPoint { get; set; } = null!; public bool ExactSpelling { get; set; } = false; // VB has different and unusual default behavior here. public bool PreserveSig { get; set; } = true; public bool SetLastError { get; set; } = false; @@ -106,7 +111,7 @@ public static DllImportStub Create( token.ThrowIfCancellationRequested(); // Determine the namespace - string stubTypeNamespace = null; + string? stubTypeNamespace = null; if (!(method.ContainingNamespace is null) && !method.ContainingNamespace.IsGlobalNamespace) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs index 0cc4f2beb5fd9..9cb682d1d38c9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -5,8 +5,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -#nullable enable - namespace Microsoft.Interop { [DiagnosticAnalyzer(LanguageNames.CSharp)] diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs index f309d3127048f..665e14a80b856 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs @@ -1,4 +1,3 @@ -#nullable enable using System.Linq; using Microsoft.CodeAnalysis; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 8a96624dd2819..cbeb703b8b27a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -89,7 +89,7 @@ public MarshallingNotSupportedException(TypePositionInfo info, StubCodeContext c /// /// [Optional] Specific reason marshalling of the supplied type isn't supported. /// - public string NotSupportedDetails { get; init; } + public string? NotSupportedDetails { get; init; } } internal class MarshallingGenerators diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 913de016c7b32..51e1241bb6ac9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -4,8 +4,6 @@ using System.Diagnostics; using System.Runtime.InteropServices; -#nullable enable - namespace Microsoft.Interop { // The following types are modeled to fit with the current prospective spec diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 2ef1705dcbeb5..61c0cd246def7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -24,12 +24,17 @@ internal sealed class TypePositionInfo public const int UnsetIndex = int.MinValue; public const int ReturnIndex = UnsetIndex + 1; +// We don't need the warnings around not setting the various +// non-nullable fields/properties on this type in the constructor +// since we always use a property initializer. +#pragma warning disable 8618 private TypePositionInfo() { this.ManagedIndex = UnsetIndex; this.NativeIndex = UnsetIndex; this.UnmanagedLCIDConversionArgIndex = UnsetIndex; } +#pragma warning restore public string InstanceIdentifier { get; private set; } public ITypeSymbol ManagedType { get; private set; } @@ -46,7 +51,7 @@ private TypePositionInfo() public int NativeIndex { get; set; } public int UnmanagedLCIDConversionArgIndex { get; private set; } - public MarshallingInfo MarshallingAttributeInfo { get; private set; } + public MarshallingInfo? MarshallingAttributeInfo { get; private set; } public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { @@ -78,7 +83,6 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { MarshallingInfo? marshallingInfo = null; @@ -276,7 +280,6 @@ static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol ty return null; } } -#nullable restore private static SyntaxKind RefKindToSyntax(RefKind refKind) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 97e6b5cf1b67d..753ffc636ca0c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -9,8 +9,6 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -#nullable enable - namespace Microsoft.Interop { static class TypeSymbolExtensions diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs index a483c22c19159..11e1b29639fb6 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs @@ -1,4 +1,3 @@ -#nullable enable namespace System.Runtime.InteropServices { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 2932ce632c210..0992142a39e61 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -5,6 +5,7 @@ false Preview true + enable diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index cd384172bce4b..e7b9271727f28 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -4,6 +4,7 @@ net5.0 false Preview + enable diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs index b6bd0f5316489..be1f1f4e7368e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs @@ -48,8 +48,8 @@ public Test() ReferenceAssemblies = refAssem; SolutionTransforms.Add((solution, projectId) => { - var project = solution.GetProject(projectId); - var compilationOptions = project.CompilationOptions; + var project = solution.GetProject(projectId)!; + var compilationOptions = project.CompilationOptions!; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 0ca8c597da9a5..65978093bd2de 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -5,6 +5,7 @@ net5.0 true preview + enable From 791a2a6257a4f0688997058bbf37796a95b0fba5 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 21 Oct 2020 11:30:25 -0700 Subject: [PATCH 030/161] String marshallers for UTF-16 and UTF-8 (dotnet/runtimelab#249) Commit migrated from https://github.com/dotnet/runtimelab/commit/ac6762f9ef20577d4847b6a55de4df7f84f2f74e --- .../gen/DllImportGenerator/DllImportStub.cs | 3 +- .../Marshalling/MarshallingGenerator.cs | 107 +++++-- .../Marshalling/StringMarshaller.Utf16.cs | 298 ++++++++++++++++++ .../Marshalling/StringMarshaller.Utf8.cs | 287 +++++++++++++++++ .../MarshallingAttributeInfo.cs | 1 + .../DllImportGenerator/Resources.Designer.cs | 12 +- .../gen/DllImportGenerator/Resources.resx | 8 +- .../gen/DllImportGenerator/TypeNames.cs | 4 +- .../DllImportGenerator/Compatibility.md | 19 +- .../CharacterTests.cs | 8 - .../DllImportGenerator.Tests/StringTests.cs | 259 +++++++++++++++ .../CompileFails.cs | 19 +- .../DllImportGenerator.UnitTests/Compiles.cs | 20 +- .../Diagnostics.cs | 69 +++- .../tests/TestAssets/NativeExports/Strings.cs | 151 +++++++++ 15 files changed, 1213 insertions(+), 52 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index a5295ac416027..52a95efc2fdbe 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -144,7 +144,8 @@ public static DllImportStub Create( { CharSet.Unicode => CharEncoding.Utf16, CharSet.Auto => CharEncoding.PlatformDefined, - _ => CharEncoding.Utf8, // [Compat] ANSI is no longer ANSI code pages on Windows and UTF-8, on non-Windows. + CharSet.Ansi => CharEncoding.Ansi, + _ => CharEncoding.Undefined, // [Compat] Do not assume a specific value for None }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index cbeb703b8b27a..e5e4698a323df 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -98,6 +98,8 @@ internal class MarshallingGenerators public static readonly WinBoolMarshaller WinBool = new WinBoolMarshaller(); public static readonly VariantBoolMarshaller VariantBool = new VariantBoolMarshaller(); public static readonly Utf16CharMarshaller Utf16Char = new Utf16CharMarshaller(); + public static readonly Utf16StringMarshaller Utf16String = new Utf16StringMarshaller(); + public static readonly Utf8StringMarshaller Utf8String = new Utf8StringMarshaller(); public static readonly Forwarder Forwarder = new Forwarder(); public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); @@ -148,24 +150,11 @@ public static IMarshallingGenerator Create( case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.VariantBool } }: return VariantBool; - case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: null }: - return Utf16Char; // [Compat] Default marshalling is UTF-16. - case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I2 } }: - return Utf16Char; - case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.U2 } }: - return Utf16Char; - case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshallingInfoStringSupport { CharEncoding: CharEncoding.Utf16 } }: - return Utf16Char; - case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshallingInfoStringSupport { CharEncoding: CharEncoding.Utf8 } }: - throw new MarshallingNotSupportedException(info, context) // [Compat] See conversion from CharSet.Ansi to UTF-8. - { - NotSupportedDetails = Resources.MarshallingCharAsCharSetAnsiNotSupported - }; - case { ManagedType: { SpecialType: SpecialType.System_Char }, MarshallingAttributeInfo: MarshallingInfoStringSupport { CharEncoding: CharEncoding.PlatformDefined } }: - throw new MarshallingNotSupportedException(info, context) // [Compat] See conversion of CharSet.Auto. - { - NotSupportedDetails = Resources.MarshallingCharAsCharSetAutoNotSupported - }; + case { ManagedType: { SpecialType: SpecialType.System_Char } }: + return CreateCharMarshaller(info, context); + + case { ManagedType: { SpecialType: SpecialType.System_String } }: + return CreateStringMarshaller(info, context); case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.FunctionPtr } }: return Delegate; @@ -192,5 +181,87 @@ public static IMarshallingGenerator Create( } #endif } + + private static IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeContext context) + { + MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + if (marshalInfo == null) + { + // [Compat] Require explicit marshalling information. + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.MarshallingStringOrCharAsUndefinedNotSupported + }; + } + + // Explicit MarshalAs takes precedence over string encoding info + if (marshalInfo is MarshalAsInfo marshalAsInfo) + { + switch (marshalAsInfo.UnmanagedType) + { + case UnmanagedType.I2: + case UnmanagedType.U2: + return Utf16Char; + } + } + else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) + { + switch (marshalStringInfo.CharEncoding) + { + case CharEncoding.Utf16: + return Utf16Char; + case CharEncoding.Ansi: + throw new MarshallingNotSupportedException(info, context) // [Compat] ANSI is not supported for char + { + 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) + }; + } + } + + throw new MarshallingNotSupportedException(info, context); + } + + private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, StubCodeContext context) + { + MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + if (marshalInfo == null) + { + // [Compat] Require explicit marshalling information. + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.MarshallingStringOrCharAsUndefinedNotSupported + }; + } + + // Explicit MarshalAs takes precedence over string encoding info + if (marshalInfo is MarshalAsInfo marshalAsInfo) + { + switch (marshalAsInfo.UnmanagedType) + { + case UnmanagedType.LPTStr: + case UnmanagedType.LPWStr: + return Utf16String; + case (UnmanagedType)0x30:// UnmanagedType.LPUTF8Str + return Utf8String; + } + } + else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) + { + switch (marshalStringInfo.CharEncoding) + { + case CharEncoding.Utf16: + return Utf16String; + case CharEncoding.Utf8: + return Utf8String; + } + } + + throw new MarshallingNotSupportedException(info, context); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs new file mode 100644 index 0000000000000..d1dd8510373ac --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -0,0 +1,298 @@ +using System.Collections.Generic; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal class Utf16StringMarshaller : IMarshallingGenerator + { + // [Compat] Equivalent of MAX_PATH on Windows to match built-in system + // The assumption is file paths are the most common case for marshalling strings, + // so the threshold for optimized allocation is based on that length. + private const int StackAllocBytesThreshold = 260 * sizeof(ushort); + + private static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); + private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.UShortKeyword))); + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + // & + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + else if (context.PinningSupported) + { + // (ushort*) + return Argument( + CastExpression( + AsNativeType(info), + IdentifierName(identifier))); + } + + // + return Argument(IdentifierName(identifier)); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + // ushort* + return NativeType; + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + // ushort** + // or + // ushort* + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + if (context.PinningSupported && !info.IsByRef && !info.IsManagedReturnPosition) + { + if (context.CurrentStage == StubCodeContext.Stage.Pin) + { + // fixed (char* = ) + yield return FixedStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.CharKeyword))), + SingletonSeparatedList( + VariableDeclarator(Identifier(nativeIdentifier)) + .WithInitializer(EqualsValueClause(IdentifierName(managedIdentifier))))), + EmptyStatement()); + } + + yield break; + } + + string usedCoTaskMemIdentifier = $"{managedIdentifier}__usedCoTaskMem"; + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + // ushort* + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + // = (ushort*)Marshal.StringToCoTaskMemUni() + var coTaskMemAlloc = ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + CastExpression( + AsNativeType(info), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("StringToCoTaskMemUni")), + ArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(managedIdentifier)))))))); + if (info.IsByRef && info.RefKind != RefKind.In) + { + yield return coTaskMemAlloc; + } + else + { + // = false; + yield return LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.BoolKeyword)), + SingletonSeparatedList( + VariableDeclarator(usedCoTaskMemIdentifier) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); + + string stackAllocPtrIdentifier = $"{managedIdentifier}__stackalloc"; + string byteLenIdentifier = $"{managedIdentifier}__byteLen"; + + // .Length + 1 + ExpressionSyntax lengthWithNullTerminator = BinaryExpression( + SyntaxKind.AddExpression, + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName("Length")), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))); + + // Code block for stackalloc if string is below threshold size + var marshalOnStack = Block( + // ushort* = stackalloc ushort[.Length + 1]; + LocalDeclarationStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.UShortKeyword))), + SingletonSeparatedList( + VariableDeclarator(stackAllocPtrIdentifier) + .WithInitializer(EqualsValueClause( + StackAllocArrayCreationExpression( + ArrayType( + PredefinedType(Token(SyntaxKind.UShortKeyword)), + SingletonList( + ArrayRankSpecifier(SingletonSeparatedList(lengthWithNullTerminator)))))))))), + // ((ReadOnlySpan)).CopyTo(new Span(, .Length + 1)); + ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParenthesizedExpression( + CastExpression( + GenericName(Identifier("System.ReadOnlySpan"), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.CharKeyword))))), + IdentifierName(managedIdentifier))), + IdentifierName("CopyTo")), + ArgumentList( + SeparatedList(new ArgumentSyntax[] { + Argument( + ObjectCreationExpression( + GenericName(Identifier("System.Span"), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.CharKeyword))))), + ArgumentList( + SeparatedList(new ArgumentSyntax[]{ + Argument(IdentifierName(stackAllocPtrIdentifier)), + Argument(lengthWithNullTerminator)})), + initializer: null))})))), + // = ; + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + IdentifierName(stackAllocPtrIdentifier)))); + + // if ( == null) + // { + // = null; + // } + // else + // { + // int = (.Length + 1) * sizeof(ushort); + // if ( > ) + // { + // = (ushort*)Marshal.StringToCoTaskMemUni(); + // = true; + // } + // else + // { + // ushort* = stackalloc ushort[.Length + 1]; + // ((ReadOnlySpan)).CopyTo(new Span(, .Length + 1)); + // = ; + // } + // } + yield return IfStatement( + BinaryExpression( + SyntaxKind.EqualsExpression, + IdentifierName(managedIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block( + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)))), + ElseClause( + Block( + LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.IntKeyword)), + SingletonSeparatedList( + VariableDeclarator(Identifier(byteLenIdentifier)) + .WithInitializer(EqualsValueClause( + BinaryExpression( + SyntaxKind.MultiplyExpression, + ParenthesizedExpression(lengthWithNullTerminator), + SizeOfExpression(PredefinedType(Token(SyntaxKind.UShortKeyword))))))))), + IfStatement( + BinaryExpression( + SyntaxKind.GreaterThanExpression, + IdentifierName(byteLenIdentifier), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(StackAllocBytesThreshold))), + Block( + coTaskMemAlloc, + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(usedCoTaskMemIdentifier), + LiteralExpression(SyntaxKind.TrueLiteralExpression)))), + ElseClause(marshalOnStack))))); + } + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + // = == null ? null : new string((char*)); + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + ConditionalExpression( + BinaryExpression( + SyntaxKind.EqualsExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + LiteralExpression(SyntaxKind.NullLiteralExpression), + ObjectCreationExpression( + PredefinedType(Token(SyntaxKind.StringKeyword)), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + PointerType(PredefinedType(Token(SyntaxKind.CharKeyword))), + IdentifierName(nativeIdentifier))))), + initializer: null)))); + } + break; + case StubCodeContext.Stage.Cleanup: + // Marshal.FreeCoTaskMem((IntPtr)) + var freeCoTaskMem = ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("FreeCoTaskMem")), + ArgumentList( + SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(nativeIdentifier))))))); + + if (info.IsByRef && info.RefKind != RefKind.In) + { + yield return freeCoTaskMem; + } + else + { + // if () + // { + // Marshal.FreeCoTaskMem((IntPtr)) + // } + yield return IfStatement( + IdentifierName(usedCoTaskMemIdentifier), + Block(freeCoTaskMem)); + } + + break; + } + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs new file mode 100644 index 0000000000000..7eee10d2b7f14 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs @@ -0,0 +1,287 @@ +using System.Collections.Generic; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal sealed class Utf8StringMarshaller : IMarshallingGenerator + { + // [Compat] Equivalent of MAX_PATH on Windows to match built-in system + // The assumption is file paths are the most common case for marshalling strings, + // so the threshold for optimized allocation is based on that length. + private const int StackAllocBytesThreshold = 260; + + // Conversion from a 2-byte 'char' in UTF-16 to bytes in UTF-8 has a maximum of 3 bytes per 'char' + // Two bytes ('char') in UTF-16 can be either: + // - Code point in the Basic Multilingual Plane: all 16 bits are that of the code point + // - Part of a pair for a code point in the Supplementary Planes: 10 bits are that of the code point + // In UTF-8, 3 bytes are need to represent the code point in first and 4 bytes in the second. Thus, the + // maximum number of bytes per 'char' is 3. + private const int MaxByteCountPerChar = 3; + + private static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); + private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); + private static readonly TypeSyntax UTF8EncodingType = ParseTypeName("System.Text.Encoding.UTF8"); + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) => NativeType; + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + string usedCoTaskMemIdentifier = $"{managedIdentifier}__usedCoTaskMem"; + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + // = (byte*)Marshal.StringToCoTaskMemUTF8(); + var coTaskMemAlloc = ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + CastExpression( + NativeType, + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("StringToCoTaskMemUTF8")), + ArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(managedIdentifier)))))))); + if (info.IsByRef && info.RefKind != RefKind.In) + { + yield return coTaskMemAlloc; + } + else + { + // = false; + yield return LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.BoolKeyword)), + SingletonSeparatedList( + VariableDeclarator(usedCoTaskMemIdentifier) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); + + string stackAllocPtrIdentifier = $"{managedIdentifier}__stackalloc"; + string byteLenIdentifier = $"{managedIdentifier}__byteLen"; + + // Code block for stackalloc if string is below threshold size + var marshalOnStack = Block( + // byte* = stackalloc byte[]; + LocalDeclarationStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))), + SingletonSeparatedList( + VariableDeclarator(stackAllocPtrIdentifier) + .WithInitializer(EqualsValueClause( + StackAllocArrayCreationExpression( + ArrayType( + PredefinedType(Token(SyntaxKind.ByteKeyword)), + SingletonList( + ArrayRankSpecifier(SingletonSeparatedList( + IdentifierName(byteLenIdentifier))))))))))), + // = Encoding.UTF8.GetBytes(, new Span(, )); + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(byteLenIdentifier), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + UTF8EncodingType, + IdentifierName("GetBytes")), + ArgumentList( + SeparatedList(new ArgumentSyntax[] { + Argument(IdentifierName(managedIdentifier)), + Argument( + ObjectCreationExpression( + GenericName(Identifier("System.Span"), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.ByteKeyword))))), + ArgumentList( + SeparatedList(new ArgumentSyntax[]{ + Argument(IdentifierName(stackAllocPtrIdentifier)), + Argument(IdentifierName(byteLenIdentifier))})), + initializer: null))}))))), + // [] = 0; + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + ElementAccessExpression( + IdentifierName(stackAllocPtrIdentifier), + BracketedArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(byteLenIdentifier))))), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))), + // = ; + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + CastExpression( + NativeType, + IdentifierName(stackAllocPtrIdentifier))))); + + // if ( == null) + // { + // = null; + // } + // else + // { + // // + 1 for number of characters in case left over high surrogate is ? + // // * (3 for UTF-8) + // // +1 for null terminator + // int = (.Length + 1) * 3 + 1; + // if ( > ) + // { + // = (byte*)Marshal.StringToCoTaskMemUTF8(); + // } + // else + // { + // byte* = stackalloc byte[]; + // = Encoding.UTF8.GetBytes(, new Span(, )); + // [] = 0; + // = (byte*); + // } + // } + yield return IfStatement( + BinaryExpression( + SyntaxKind.EqualsExpression, + IdentifierName(managedIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block( + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)))), + ElseClause( + Block( + // + 1 for number of characters in case left over high surrogate is ? + // * (3 for UTF-8) + // +1 for null terminator + // int = (.Length + 1) * 3 + 1; + LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.IntKeyword)), + SingletonSeparatedList( + VariableDeclarator(Identifier(byteLenIdentifier)) + .WithInitializer(EqualsValueClause( + BinaryExpression( + SyntaxKind.AddExpression, + BinaryExpression( + SyntaxKind.MultiplyExpression, + ParenthesizedExpression( + BinaryExpression( + SyntaxKind.AddExpression, + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName("Length")), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(MaxByteCountPerChar))), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))))))), + IfStatement( + BinaryExpression( + SyntaxKind.GreaterThanExpression, + IdentifierName(byteLenIdentifier), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(StackAllocBytesThreshold))), + Block( + coTaskMemAlloc, + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(usedCoTaskMemIdentifier), + LiteralExpression(SyntaxKind.TrueLiteralExpression)))), + ElseClause(marshalOnStack))))); + } + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + // = Marshal.PtrToStringUTF8((IntPtr)); + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("PtrToStringUTF8")), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(nativeIdentifier)))))))); + } + break; + case StubCodeContext.Stage.Cleanup: + // Marshal.FreeCoTaskMem((IntPtr)) + var freeCoTaskMem = ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("FreeCoTaskMem")), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(nativeIdentifier))))))); + + if (info.IsByRef && info.RefKind != RefKind.In) + { + yield return freeCoTaskMem; + } + else + { + // if () + // { + // Marshal.FreeCoTaskMem((IntPtr)) + // } + yield return IfStatement( + IdentifierName(usedCoTaskMemIdentifier), + Block(freeCoTaskMem)); + } + + break; + } + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 51e1241bb6ac9..55dc4e3afb1de 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -20,6 +20,7 @@ internal enum CharEncoding Undefined, Utf8, Utf16, + Ansi, PlatformDefined } 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 e4f93f4bdc718..2bf13584e5655 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -187,20 +187,20 @@ internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFal } /// - /// Looks up a localized string similar to Marshalling char with CharSet.Ansi is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. + /// Looks up a localized string similar to Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. /// - internal static string MarshallingCharAsCharSetAnsiNotSupported { + internal static string MarshallingCharAsSpecifiedCharSetNotSupported { get { - return ResourceManager.GetString("MarshallingCharAsCharSetAnsiNotSupported", resourceCulture); + return ResourceManager.GetString("MarshallingCharAsSpecifiedCharSetNotSupported", resourceCulture); } } /// - /// Looks up a localized string similar to Marshalling char with CharSet.Auto is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. + /// Looks up a localized string similar to Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'.. /// - internal static string MarshallingCharAsCharSetAutoNotSupported { + internal static string MarshallingStringOrCharAsUndefinedNotSupported { get { - return ResourceManager.GetString("MarshallingCharAsCharSetAutoNotSupported", resourceCulture); + return ResourceManager.GetString("MarshallingStringOrCharAsUndefinedNotSupported", resourceCulture); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index d9a0508027e96..c42041ed776fe 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -159,11 +159,11 @@ Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible - - Marshalling char with CharSet.Ansi is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. + + Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. - - Marshalling char with CharSet.Auto is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. + + Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'. A native type for a given type must be blittable. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 284aa2a3694e3..6471dd3e867b3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -20,8 +20,10 @@ static class TypeNames public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; + public const string System_Runtime_InteropServices_Marshal = "System.Runtime.InteropServices.Marshal"; + public const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; - + public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index 4753255a7a634..a618504106076 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -8,16 +8,31 @@ The focus of version 1 is to support `NetCoreApp`. This implies that anything no ### Semantic changes compared to `DllImportAttribute` -The default value of the `CharSet` property is `CharSet.Unicode`. +The default value of `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. + +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. ### `char` marshaller -The marshalling of `char` as [`CharSet.Ansi`, `CharSet.None`, or `CharSet.Auto`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.charset) will not be supported. +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. + - [`UnmangedType.U1` or `UnmangedType.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) 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. 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` marshaller + +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) + - [`UnmangedType.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) + +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. ## Verison 0 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 ea67f2e1217ba..b8a547904c820 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs @@ -7,12 +7,6 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "unicode_return_as_uint")] - public static partial uint ReturnDefaultAsUInt(char input); - - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_uint")] - public static partial char ReturnUIntAsDefault(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "unicode_return_as_uint", CharSet = CharSet.Unicode)] public static partial uint ReturnUnicodeAsUInt(char input); @@ -50,7 +44,6 @@ public static IEnumerable CharacterMappings() [MemberData(nameof(CharacterMappings))] public void ValidateUnicodeCharIsMarshalledAsExpected(char value, uint expected) { - Assert.Equal(expected, NativeExportsNE.ReturnDefaultAsUInt(value)); Assert.Equal(expected, NativeExportsNE.ReturnUnicodeAsUInt(value)); } @@ -58,7 +51,6 @@ public void ValidateUnicodeCharIsMarshalledAsExpected(char value, uint expected) [MemberData(nameof(CharacterMappings))] public void ValidateUnicodeReturns(char expected, uint value) { - Assert.Equal(expected, NativeExportsNE.ReturnUIntAsDefault(value)); Assert.Equal(expected, NativeExportsNE.ReturnUIntAsUnicode(value)); char result = '\u0000'; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs new file mode 100644 index 0000000000000..793e76c8e5607 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public partial class Unicode + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort", CharSet = CharSet.Unicode)] + public static partial int ReturnLength(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_ushort", CharSet = CharSet.Unicode)] + public static partial string Reverse_Return(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_ushort", CharSet = CharSet.Unicode)] + public static partial void Reverse_Out(string s, out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort", CharSet = CharSet.Unicode)] + public static partial void Reverse_Ref(ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort", CharSet = CharSet.Unicode)] + public static partial void Reverse_In(in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort", CharSet = CharSet.Unicode)] + public static partial void Reverse_Replace_Ref(ref string s); + } + + public partial class LPTStr + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort")] + public static partial int ReturnLength([MarshalAs(UnmanagedType.LPTStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort", CharSet = CharSet.None)] + public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPTStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_ushort")] + [return: MarshalAs(UnmanagedType.LPTStr)] + public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPTStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_ushort")] + public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPTStr)] string s, [MarshalAs(UnmanagedType.LPTStr)] out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + public static partial void Reverse_In([MarshalAs(UnmanagedType.LPTStr)] in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort")] + public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); + } + + public partial class LPWStr + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort")] + public static partial int ReturnLength([MarshalAs(UnmanagedType.LPWStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort", CharSet = CharSet.None)] + public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPWStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_ushort")] + [return: MarshalAs(UnmanagedType.LPWStr)] + public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPWStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_ushort")] + public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPWStr)] string s, [MarshalAs(UnmanagedType.LPWStr)] out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + public static partial void Reverse_In([MarshalAs(UnmanagedType.LPWStr)] in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort")] + public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); + } + + public partial class LPUTF8Str + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_byte")] + public static partial int ReturnLength([MarshalAs(UnmanagedType.LPUTF8Str)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_byte", CharSet = CharSet.None)] + public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPUTF8Str)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_byte")] + [return: MarshalAs(UnmanagedType.LPUTF8Str)] + public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPUTF8Str)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_byte")] + public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPUTF8Str)] string s, [MarshalAs(UnmanagedType.LPUTF8Str)] out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_byte")] + public static partial void Reverse_In([MarshalAs(UnmanagedType.LPUTF8Str)] in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_byte")] + public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_byte")] + public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); + } + } + + public class StringTests + { + public static IEnumerable UnicodeStrings() => new [] + { + new object[] { "ABCdef 123$%^" }, + new object[] { "🍜 !! 🍜 !!"}, + new object[] { "🌲 木 🔥 火 🌾 土 🛡 金 🌊 水" }, + new object[] { "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae posuere mauris, sed ultrices leo. Suspendisse potenti. Mauris enim enim, blandit tincidunt consequat in, varius sit amet neque. Morbi eget porttitor ex. Duis mattis aliquet ante quis imperdiet. Duis sit." }, + new object[] { string.Empty }, + new object[] { null }, + }; + + [Theory] + [MemberData(nameof(UnicodeStrings))] + public void UnicodeStringMarshalledAsExpected(string value) + { + int expectedLen = value != null ? value.Length : -1; + Assert.Equal(expectedLen, NativeExportsNE.Unicode.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)); + } + + [Theory] + [MemberData(nameof(UnicodeStrings))] + public void UnicodeStringReturn(string value) + { + string expected = ReverseChars(value); + + Assert.Equal(expected, NativeExportsNE.Unicode.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); + Assert.Equal(expected, ret); + + ret = null; + NativeExportsNE.LPWStr.Reverse_Out(value, out ret); + Assert.Equal(expected, ret); + + ret = null; + NativeExportsNE.LPWStr.Reverse_Out(value, out ret); + Assert.Equal(expected, ret); + } + + [Theory] + [MemberData(nameof(UnicodeStrings))] + public void UnicodeStringByRef(string value) + { + string refValue = value; + string expected = ReverseChars(value); + + NativeExportsNE.Unicode.Reverse_In(in refValue); + Assert.Equal(value, refValue); // Should not be updated when using 'in' + + NativeExportsNE.LPWStr.Reverse_In(in refValue); + Assert.Equal(value, refValue); // Should not be updated when using 'in' + + NativeExportsNE.LPTStr.Reverse_In(in refValue); + Assert.Equal(value, refValue); // Should not be updated when using 'in' + + refValue = value; + NativeExportsNE.Unicode.Reverse_Ref(ref refValue); + Assert.Equal(expected, refValue); + + refValue = value; + NativeExportsNE.LPWStr.Reverse_Ref(ref refValue); + Assert.Equal(expected, refValue); + + refValue = value; + NativeExportsNE.LPTStr.Reverse_Ref(ref refValue); + Assert.Equal(expected, refValue); + + refValue = value; + NativeExportsNE.Unicode.Reverse_Replace_Ref(ref refValue); + Assert.Equal(expected, refValue); + + refValue = value; + NativeExportsNE.LPWStr.Reverse_Replace_Ref(ref refValue); + Assert.Equal(expected, refValue); + + refValue = value; + NativeExportsNE.LPTStr.Reverse_Replace_Ref(ref refValue); + Assert.Equal(expected, refValue); + } + + [Theory] + [MemberData(nameof(UnicodeStrings))] + 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)); + } + + [Theory] + [MemberData(nameof(UnicodeStrings))] + public void UTF8StringReturn(string value) + { + string expected = ReverseBytes(value, Encoding.UTF8); + + Assert.Equal(expected, NativeExportsNE.LPUTF8Str.Reverse_Return(value)); + + string ret; + NativeExportsNE.LPUTF8Str.Reverse_Out(value, out ret); + Assert.Equal(expected, ret); + } + + [Theory] + [MemberData(nameof(UnicodeStrings))] + public void UTF8StringByRef(string value) + { + string refValue = value; + string expected = ReverseBytes(value, Encoding.UTF8); + + NativeExportsNE.LPUTF8Str.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.LPUTF8Str.Reverse_Replace_Ref(ref refValue); + Assert.Equal(expected, refValue); + } + + private static string ReverseChars(string value) + { + if (value == null) + return null; + + var chars = value.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + + private static string ReverseBytes(string value, Encoding encoding) + { + if (value == null) + return null; + + byte[] bytes = encoding.GetBytes(value); + Array.Reverse(bytes); + return encoding.GetString(bytes); + } + } +} 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 3f49dec885d69..57dd9a23c7b25 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -1,8 +1,9 @@ -using Microsoft.CodeAnalysis; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; + +using Microsoft.CodeAnalysis; using Xunit; namespace DllImportGenerator.UnitTests @@ -11,10 +12,22 @@ public class CompileFails { public static IEnumerable CodeSnippetsToCompile() { + // Not GeneratedDllImportAttribute yield return new object[] { CodeSnippets.UserDefinedPrefixedAttributes, 0, 3 }; + + // No explicit marshalling for char or string + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; + yield return new object[] { CodeSnippets.PreserveSigFalse(), 3, 0 }; + yield return new object[] { CodeSnippets.PreserveSigFalse(), 3, 0 }; + + // Unsupported CharSet yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto), 5, 0 }; - yield return new object[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.None), 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 UnmanagedType yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1), 5, 0 }; yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.U1), 5, 0 }; } 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 f9ba148e046f4..c601f5f88edea 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -32,8 +32,6 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -52,11 +50,18 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; 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) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.VariantBool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I2) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.U2) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPWStr) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPTStr) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPUTF8Str) }; + //yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; //yield return new[] { CodeSnippets.EnumParameters }; yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -70,8 +75,6 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; //yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -100,8 +103,6 @@ public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() { yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -118,9 +119,12 @@ public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.EnumParameters }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi) }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto) }; + + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.EnumParameters }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; 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 0ba00530c7c1e..4f53f44339b1d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs @@ -90,6 +90,65 @@ partial class Test Assert.Empty(newCompDiags); } + [Fact] + public async Task ParameterTypeNotSupportedWithDetails_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(char c, string s); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails)) + .WithSpan(6, 44, 6, 45), + (new DiagnosticResult(GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails)) + .WithSpan(6, 54, 6, 55), + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + [Fact] + public async Task ReturnTypeNotSupportedWithDetails_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial char Method1(); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial string Method2(); +} +"; + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + (new DiagnosticResult(GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails)) + .WithSpan(6, 32, 6, 39), + (new DiagnosticResult(GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails)) + .WithSpan(9, 34, 9, 41), + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + [Fact] public async Task ParameterConfigurationNotSupported_ReportsDiagnostic() { @@ -240,7 +299,6 @@ private static void VerifyDiagnostics(DiagnosticResult[] expectedDiagnostics, Di Diagnostic actual = actualDiagnostics[i]; Assert.Equal(expected.Id, actual.Id); - Assert.Equal(expected.Message, actual.GetMessage()); Assert.Equal(expected.Severity, actual.Severity); if (expected.HasLocation) { @@ -248,6 +306,15 @@ private static void VerifyDiagnostics(DiagnosticResult[] expectedDiagnostics, Di FileLinePositionSpan actualSpan = actual.Location.GetLineSpan(); Assert.Equal(expectedSpan, actualSpan); } + + if (expected.MessageArguments is null) + { + Assert.Equal(expected.MessageFormat, actual.Descriptor.MessageFormat); + } + else + { + Assert.Equal(expected.Message, actual.GetMessage()); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs new file mode 100644 index 0000000000000..ac5fa7d9ac5bd --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs @@ -0,0 +1,151 @@ +using System; +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class Strings + { + [UnmanagedCallersOnly(EntryPoint = "return_length_ushort")] + public static int ReturnLengthUShort(ushort* input) + { + if (input == null) + return -1; + + return GetLength(input); + } + + [UnmanagedCallersOnly(EntryPoint = "return_length_byte")] + public static int ReturnLengthByte(byte* input) + { + if (input == null) + return -1; + + return GetLength(input); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_return_ushort")] + public static ushort* ReverseReturnUShort(ushort* input) + { + return Reverse(input); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_return_byte")] + public static byte* ReverseReturnByte(byte* input) + { + return Reverse(input); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_out_ushort")] + public static void ReverseReturnAsOutUShort(ushort* input, ushort** ret) + { + *ret = Reverse(input); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_out_byte")] + public static void ReverseReturnAsOutByte(byte* input, byte** ret) + { + *ret = Reverse(input); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_inplace_ref_ushort")] + public static void ReverseInPlaceUShort(ushort** refInput) + { + if (*refInput == null) + return; + + int len = GetLength(*refInput); + var span = new Span(*refInput, len); + span.Reverse(); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_inplace_ref_byte")] + public static void ReverseInPlaceByte(byte** refInput) + { + int len = GetLength(*refInput); + var span = new Span(*refInput, len); + span.Reverse(); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_replace_ref_ushort")] + public static void ReverseReplaceRefUShort(ushort** s) + { + if (*s == null) + return; + + ushort* ret = Reverse(*s); + Marshal.FreeCoTaskMem((IntPtr)(*s)); + *s = ret; + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_replace_ref_byte")] + public static void ReverseReplaceRefByte(byte** s) + { + if (*s == null) + return; + + byte* ret = Reverse(*s); + Marshal.FreeCoTaskMem((IntPtr)(*s)); + *s = ret; + } + + private static ushort* Reverse(ushort *s) + { + if (s == null) + return null; + + int len = GetLength(s); + ushort* ret = (ushort*)Marshal.AllocCoTaskMem((len + 1) * sizeof(ushort)); + var span = new Span(ret, len); + + new Span(s, len).CopyTo(span); + span.Reverse(); + ret[len] = 0; + return ret; + } + + private static byte* Reverse(byte* s) + { + if (s == null) + return null; + + int len = GetLength(s); + byte* ret = (byte*)Marshal.AllocCoTaskMem((len + 1) * sizeof(byte)); + var span = new Span(ret, len); + + new Span(s, len).CopyTo(span); + span.Reverse(); + ret[len] = 0; + return ret; + } + + private static int GetLength(ushort* input) + { + if (input == null) + return 0; + + int len = 0; + while (*input != 0) + { + input++; + len++; + } + + return len; + } + + private static int GetLength(byte* input) + { + if (input == null) + return 0; + + int len = 0; + while (*input != 0) + { + input++; + len++; + } + + return len; + } + } +} From b57e347a7d212ec449295361376e2c9d25637e90 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 21 Oct 2020 12:19:07 -0700 Subject: [PATCH 031/161] Disable nullable checks in integration tests (dotnet/runtimelab#253) Fix nullability warnings in generator Commit migrated from https://github.com/dotnet/runtimelab/commit/7bb0f191c7659b270e5f7d792922193adde7d0cc --- .../DllImportGenerator/Marshalling/MarshallingGenerator.cs | 4 ++-- .../DllImportGenerator.Tests/DllImportGenerator.Tests.csproj | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index e5e4698a323df..fb53d5c8ac62c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -184,7 +184,7 @@ public static IMarshallingGenerator Create( private static IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeContext context) { - MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + MarshallingInfo? marshalInfo = info.MarshallingAttributeInfo; if (marshalInfo == null) { // [Compat] Require explicit marshalling information. @@ -228,7 +228,7 @@ private static IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, StubCodeContext context) { - MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + MarshallingInfo? marshalInfo = info.MarshallingAttributeInfo; if (marshalInfo == null) { // [Compat] Require explicit marshalling information. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 0992142a39e61..2932ce632c210 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -5,7 +5,6 @@ false Preview true - enable From 8f84066fee60a3f8db994e161391780e3255989f Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 21 Oct 2020 13:50:45 -0700 Subject: [PATCH 032/161] Remove support for the custom marshaller on MarshalAsAttribute. (dotnet/runtimelab#255) * Remove support for the custom marshaller on MarshalAsAttribute. * Update compat document. Commit migrated from https://github.com/dotnet/runtimelab/commit/5a0e1d94fb123008623c8ef9c26513ff57d3481e --- .../MarshallingAttributeInfo.cs | 4 +--- .../gen/DllImportGenerator/TypePositionInfo.cs | 14 +++----------- .../DllImportGenerator/Compatibility.md | 4 ++++ .../DllImportGenerator.UnitTests/CodeSnippets.cs | 16 ++++++---------- .../DllImportGenerator.UnitTests/CompileFails.cs | 4 ++++ .../DllImportGenerator.UnitTests/Compiles.cs | 3 --- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 55dc4e3afb1de..df4b3739db812 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -35,9 +35,7 @@ CharEncoding CharEncoding /// User-applied System.Runtime.InteropServices.MarshalAsAttribute /// internal sealed record MarshalAsInfo( - UnmanagedType UnmanagedType, - string? CustomMarshallerTypeName, - string? CustomMarshallerCookie, + UnmanagedType UnmanagedType, UnmanagedType UnmanagedArraySubType, int ArraySizeConst, short ArraySizeParamIndex, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 61c0cd246def7..d6001dc968037 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -171,12 +171,11 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData, DefaultMarshall UnmanagedType unmanagedType = unmanagedTypeObj is short ? (UnmanagedType)(short)unmanagedTypeObj : (UnmanagedType)unmanagedTypeObj; - if (!Enum.IsDefined(typeof(UnmanagedType), unmanagedType)) + if (!Enum.IsDefined(typeof(UnmanagedType), unmanagedType) + || unmanagedType == UnmanagedType.CustomMarshaler) { diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); } - string? customMarshallerTypeName = null; - string? customMarshallerCookie = null; UnmanagedType unmanagedArraySubType = 0; int arraySizeConst = 0; short arraySizeParamIndex = 0; @@ -192,15 +191,10 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData, DefaultMarshall case nameof(MarshalAsAttribute.SafeArraySubType): case nameof(MarshalAsAttribute.SafeArrayUserDefinedSubType): case nameof(MarshalAsAttribute.IidParameterIndex): - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); - break; case nameof(MarshalAsAttribute.MarshalTypeRef): case nameof(MarshalAsAttribute.MarshalType): - // Call ToString() to handle INamedTypeSymbol as well. - customMarshallerTypeName = namedArg.Value.Value!.ToString(); - break; case nameof(MarshalAsAttribute.MarshalCookie): - customMarshallerCookie = (string)namedArg.Value.Value!; + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); break; case nameof(MarshalAsAttribute.ArraySubType): unmanagedArraySubType = (UnmanagedType)namedArg.Value.Value!; @@ -216,8 +210,6 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData, DefaultMarshall return new MarshalAsInfo( UnmanagedType: unmanagedType, - CustomMarshallerTypeName: customMarshallerTypeName, - CustomMarshallerCookie: customMarshallerCookie, UnmanagedArraySubType: unmanagedArraySubType, ArraySizeConst: arraySizeConst, ArraySizeParamIndex: arraySizeParamIndex, diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index a618504106076..f1f9b1160ae4a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -34,6 +34,10 @@ When converting from native to managed, the built-in system would throw a [`Mars 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. +### Custom marshaller support + +Using a custom marshaller (i.e. [`ICustomMarshaler`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.icustommarshaler)) with the `UnmanagedType.CustomMarshaler` value on `MarshalAsAttribute` is not supported. This also implies `MarshalAsAttribute` fields: [`MarshalTypeRef`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltyperef), [`MarshalType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltype), and [`MarshalCookie`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshalcookie) are unsupported. + ## Verison 0 This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. \ No newline at end of file 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 cf9bbeba577c1..1b083d66be9f2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -207,9 +207,9 @@ partial class Test "; /// - /// Apply MarshalAsAttribute to parameters and return types. + /// Define a MarshalAsAttribute with a customer marshaller to parameters and return types. /// - public static readonly string MarshalAsAttributeOnTypes = @" + public static readonly string MarshalAsCustomMarshalerOnTypes = @" using System; using System.Runtime.InteropServices; namespace NS @@ -239,16 +239,12 @@ public object MarshalNativeToManaged(IntPtr pNativeData) partial class Test { [GeneratedDllImport(""DoesNotExist"")] - [return: MarshalAs(UnmanagedType.LPWStr)] - public static partial string Method1([MarshalAs(UnmanagedType.LPStr)]string t); + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NS.MyCustomMarshaler), MarshalCookie=""COOKIE1"")] + public static partial bool Method1([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NS.MyCustomMarshaler), MarshalCookie=""COOKIE2"")]bool t); [GeneratedDllImport(""DoesNotExist"")] - [return: MarshalAs(UnmanagedType.LPWStr)] - public static partial string Method2([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NS.MyCustomMarshaler), MarshalCookie=""COOKIE1"")]string t); - - [GeneratedDllImport(""DoesNotExist"")] - [return: MarshalAs(UnmanagedType.LPWStr)] - public static partial string Method3([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = ""NS.MyCustomMarshaler"", MarshalCookie=""COOKIE2"")]string t); + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = ""NS.MyCustomMarshaler"", MarshalCookie=""COOKIE3"")] + public static partial bool Method2([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = ""NS.MyCustomMarshaler"", MarshalCookie=""COOKIE4"")]bool t); } "; 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 57dd9a23c7b25..6c85c6c3d8be7 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -30,6 +30,10 @@ public static IEnumerable CodeSnippetsToCompile() // Unsupported UnmanagedType yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1), 5, 0 }; yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.U1), 5, 0 }; + + // Unsupported MarshalAsAttribute usage + // * UnmanagedType.CustomMarshaler, MarshalTypeRef, MarshalType, MarshalCookie + yield return new object[] { CodeSnippets.MarshalAsCustomMarshalerOnTypes, 16, 0 }; } [Theory] 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 c601f5f88edea..a42501a3ab169 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -20,7 +20,6 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.AllDllImportNamedArguments }; yield return new[] { CodeSnippets.DefaultParameters }; yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; - //yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -101,8 +100,6 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() { - yield return new[] { CodeSnippets.MarshalAsAttributeOnTypes }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; From c5d750f87445aaf85b7ae9cb4bd371f7e3f8d550 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 21 Oct 2020 15:58:32 -0700 Subject: [PATCH 033/161] Add initial blittable struct test (dotnet/runtimelab#230) Create SharedTypes project to shared between NativeExports and integration tests. Update DNNE to 1.0.13 for custom native argument signature support. Commit migrated from https://github.com/dotnet/runtimelab/commit/acff10602714c8133275c17de9791304dd6cf740 --- .../BlittableStructTests.cs | 66 +++++++++++++++++++ .../DllImportGenerator.Tests.csproj | 1 + .../NativeExports/BlittableStructs.cs | 37 +++++++++++ .../NativeExports/NativeExports.csproj | 6 +- .../tests/TestAssets/SharedTypes/Blittable.cs | 13 ++++ .../tests/TestAssets/SharedTypes/DNNE.cs | 11 ++++ .../TestAssets/SharedTypes/SharedTypes.csproj | 11 ++++ 7 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs new file mode 100644 index 0000000000000..558f596b38634 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs @@ -0,0 +1,66 @@ +using System.Runtime.InteropServices; + +using SharedTypes; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_byref")] + public static partial void DoubleIntFieldsByRef(ref IntFields result); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_refreturn")] + public static partial void DoubleIntFieldsRefReturn( + IntFields input, + ref IntFields result); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_refreturn")] + public static partial void DoubleIntFieldsOutReturn( + IntFields input, + out IntFields result); + } + + public class BlittableStructTests + { + [Fact] + public void ValidateBlittableStruct() + { + const int A = 24, B = 37, C = 59; + var initial = new IntFields() + { + a = A, + b = B, + c = C, + }; + var expected = new IntFields() + { + a = initial.a * 2, + b = initial.b * 2, + c = initial.c * 2, + }; + + var input = initial; + { + var result = new IntFields(); + NativeExportsNE.DoubleIntFieldsRefReturn(input, ref result); + Assert.Equal(initial, input); + Assert.Equal(expected, result); + } + + { + IntFields result; + NativeExportsNE.DoubleIntFieldsOutReturn(input, out result); + Assert.Equal(initial, input); + Assert.Equal(expected, result); + } + + { + input = initial; + NativeExportsNE.DoubleIntFieldsByRef(ref input); + Assert.Equal(expected, input); + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 2932ce632c210..b1e8ddc50400f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -24,6 +24,7 @@ + diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs new file mode 100644 index 0000000000000..30c19dab6a39a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +using SharedTypes; + +namespace NativeExports +{ + public static unsafe class BlittableStructs + { + [UnmanagedCallersOnly(EntryPoint = "blittablestructs_return_instance")] + [DNNE.C99DeclCode("struct int_fields { int a; int b; int c; };")] + [return: DNNE.C99Type("struct int_fields")] + public static IntFields DoubleIntFields([DNNE.C99Type("struct int_fields")] IntFields input) + { + //return input; + throw new System.NotSupportedException( "This is currently not supported due to: https://github.com/dotnet/runtime/issues/35928"); + } + + [UnmanagedCallersOnly(EntryPoint = "blittablestructs_double_intfields_byref")] + public static void DoubleIntFieldsByRef( + [DNNE.C99Type("struct int_fields*")] IntFields* result) + { + result->a *= 2; + result->b *= 2; + result->c *= 2; + } + + [UnmanagedCallersOnly(EntryPoint = "blittablestructs_double_intfields_refreturn")] + public static void DoubleIntFieldsRefReturn( + [DNNE.C99Type("struct int_fields")] IntFields input, + [DNNE.C99Type("struct int_fields*")] IntFields* result) + { + result->a = input.a * 2; + result->b = input.b * 2; + result->c = input.c * 2; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index e72f43fdabdf1..7327cb1d19690 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -8,7 +8,11 @@ - + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs new file mode 100644 index 0000000000000..cdc00dfd0d33e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs @@ -0,0 +1,13 @@ +using System; +using System.Runtime.InteropServices; + +namespace SharedTypes +{ + [BlittableType] + public struct IntFields + { + public int a; + public int b; + public int c; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs new file mode 100644 index 0000000000000..85f4a6e527285 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs @@ -0,0 +1,11 @@ +namespace DNNE +{ + public class C99DeclCodeAttribute : System.Attribute + { + public C99DeclCodeAttribute(string code) { } + } + public class C99TypeAttribute : System.Attribute + { + public C99TypeAttribute(string code) { } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj new file mode 100644 index 0000000000000..368e3d0ee61b5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj @@ -0,0 +1,11 @@ + + + + net5.0 + + + + + + + From e3a0ede08956c6a6e41b63126d1437b214eade63 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Wed, 21 Oct 2020 16:15:53 -0700 Subject: [PATCH 034/161] Add standalone template for experiments that don't need runtime features (dotnet/runtimelab#238) * Add arcade common files * Add standalone library template for experiments that don't need runtime features * Add documentation to README.md * PR Feedback. Co-authored-by: Jan Kotas * Quick fixups in README.md * PR Feedback * Simplify yml templates Co-authored-by: Jan Kotas Commit migrated from https://github.com/dotnet/runtimelab/commit/0809d8118490cdc32b8b89c43479697a76c22e66 --- Experiment.sln | 48 ++++++++++++++++++++ src/Experiment/src/Experiment.csproj | 7 +++ src/Experiment/src/MyClass.cs | 9 ++++ src/Experiment/tests/Experiment.Tests.csproj | 9 ++++ src/Experiment/tests/MyClassTests.cs | 14 ++++++ 5 files changed, 87 insertions(+) create mode 100644 Experiment.sln create mode 100644 src/Experiment/src/Experiment.csproj create mode 100644 src/Experiment/src/MyClass.cs create mode 100644 src/Experiment/tests/Experiment.Tests.csproj create mode 100644 src/Experiment/tests/MyClassTests.cs diff --git a/Experiment.sln b/Experiment.sln new file mode 100644 index 0000000000000..ff3e8c0e68324 --- /dev/null +++ b/Experiment.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experiment", "src\Experiment\src\Experiment.csproj", "{B7977360-6671-4707-9A1C-1C29D5BE2674}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experiment.Tests", "src\Experiment\tests\Experiment.Tests.csproj", "{CE81B6BD-CCCC-4223-9069-B28435A4A5C1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x64.ActiveCfg = Debug|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x64.Build.0 = Debug|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x86.ActiveCfg = Debug|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x86.Build.0 = Debug|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|Any CPU.Build.0 = Release|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x64.ActiveCfg = Release|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x64.Build.0 = Release|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x86.ActiveCfg = Release|Any CPU + {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x86.Build.0 = Release|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x64.ActiveCfg = Debug|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x64.Build.0 = Debug|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x86.ActiveCfg = Debug|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x86.Build.0 = Debug|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|Any CPU.Build.0 = Release|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x64.ActiveCfg = Release|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x64.Build.0 = Release|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x86.ActiveCfg = Release|Any CPU + {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/Experiment/src/Experiment.csproj b/src/Experiment/src/Experiment.csproj new file mode 100644 index 0000000000000..f208d303c9811 --- /dev/null +++ b/src/Experiment/src/Experiment.csproj @@ -0,0 +1,7 @@ + + + + net5.0 + + + diff --git a/src/Experiment/src/MyClass.cs b/src/Experiment/src/MyClass.cs new file mode 100644 index 0000000000000..b0121b4015cc7 --- /dev/null +++ b/src/Experiment/src/MyClass.cs @@ -0,0 +1,9 @@ +using System; + +namespace Experiment +{ + public class MyClass + { + public static bool ReturnTrue => true; + } +} diff --git a/src/Experiment/tests/Experiment.Tests.csproj b/src/Experiment/tests/Experiment.Tests.csproj new file mode 100644 index 0000000000000..1f38944a6987b --- /dev/null +++ b/src/Experiment/tests/Experiment.Tests.csproj @@ -0,0 +1,9 @@ + + + net5.0 + + + + + + diff --git a/src/Experiment/tests/MyClassTests.cs b/src/Experiment/tests/MyClassTests.cs new file mode 100644 index 0000000000000..14d4e5e501049 --- /dev/null +++ b/src/Experiment/tests/MyClassTests.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace Experiment.Tests +{ + public class MyClassTests + { + [Fact] + public void Test1() + { + Assert.True(MyClass.ReturnTrue); + } + } +} From 247b204b05b43e0372abe49bf959b42f06c5f001 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 23 Oct 2020 10:57:39 -0700 Subject: [PATCH 035/161] Factor out some nullability uses (dotnet/runtimelab#259) * Factor out some nullability uses Commit migrated from https://github.com/dotnet/runtimelab/commit/915905c549e8cd74e22c9e880b2de2718b04d9e9 --- .../GeneratorDiagnostics.cs | 2 +- .../Marshalling/MarshallingGenerator.cs | 36 ++++----- .../MarshallingAttributeInfo.cs | 11 ++- .../DllImportGenerator/TypePositionInfo.cs | 78 +++++++------------ 4 files changed, 56 insertions(+), 71 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index b4b29420052fb..68a25c936a432 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -205,7 +205,7 @@ internal void ReportMarshallingNotSupported( paramSymbol.Name)); } } - else if (info.MarshallingAttributeInfo != null && info.MarshallingAttributeInfo is MarshalAsInfo) + else if (info.MarshallingAttributeInfo is MarshalAsInfo) { // Report that the specified marshalling configuration is not supported. // We don't forward marshalling attributes, so this is reported differently diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index fb53d5c8ac62c..e698bece7029c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -127,21 +127,21 @@ public static IMarshallingGenerator Create( switch (info) { // Blittable primitives with no marshalling info or with a compatible [MarshalAs] attribute. - case { ManagedType: { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I1 } } - or { ManagedType: { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U1 } } - or { ManagedType: { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I2 } } - or { ManagedType: { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U2 } } - or { ManagedType: { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I4 } } - or { ManagedType: { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U4 } } - or { ManagedType: { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.I8 } } - or { ManagedType: { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.U8 } } - or { ManagedType: { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: null } - or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: null} - or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.R4 } } - or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.R8 } }: + case { ManagedType: { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I1 } } + or { ManagedType: { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U1 } } + or { ManagedType: { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I2 } } + or { ManagedType: { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U2 } } + or { ManagedType: { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I4 } } + or { ManagedType: { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U4 } } + or { ManagedType: { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I8 } } + or { ManagedType: { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U8 } } + or { ManagedType: { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo } + or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo} + or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.R4 } } + or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.R8 } }: return Blittable; - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: null }: + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I1 or UnmanagedType.U1 } }: return ByteBool; @@ -156,7 +156,7 @@ public static IMarshallingGenerator Create( case { ManagedType: { SpecialType: SpecialType.System_String } }: return CreateStringMarshaller(info, context); - case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: null or MarshalAsInfo { UnmanagedType: UnmanagedType.FunctionPtr } }: + case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.FunctionPtr } }: return Delegate; case { MarshallingAttributeInfo: BlittableTypeAttributeInfo _ }: @@ -184,8 +184,8 @@ public static IMarshallingGenerator Create( private static IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeContext context) { - MarshallingInfo? marshalInfo = info.MarshallingAttributeInfo; - if (marshalInfo == null) + MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + if (marshalInfo is NoMarshallingInfo) { // [Compat] Require explicit marshalling information. throw new MarshallingNotSupportedException(info, context) @@ -228,8 +228,8 @@ private static IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, StubCodeContext context) { - MarshallingInfo? marshalInfo = info.MarshallingAttributeInfo; - if (marshalInfo == null) + MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + if (marshalInfo is NoMarshallingInfo) { // [Compat] Require explicit marshalling information. throw new MarshallingNotSupportedException(info, context) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index df4b3739db812..c44695265771a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -10,7 +10,16 @@ namespace Microsoft.Interop // for C# 10 discriminated unions. Once discriminated unions are released, // these should be updated to be implemented as a discriminated union. - internal abstract record MarshallingInfo {} + internal abstract record MarshallingInfo + { + } + + internal sealed record NoMarshallingInfo : MarshallingInfo + { + public static readonly MarshallingInfo Instance = new NoMarshallingInfo(); + + private NoMarshallingInfo() { } + } /// /// Character encoding enumeration. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index d6001dc968037..b92813214e663 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -51,7 +51,7 @@ private TypePositionInfo() public int NativeIndex { get; set; } public int UnmanagedLCIDConversionArgIndex { get; private set; } - public MarshallingInfo? MarshallingAttributeInfo { get; private set; } + public MarshallingInfo MarshallingAttributeInfo { get; private set; } public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { @@ -83,10 +83,8 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) + private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { - MarshallingInfo? marshallingInfo = null; - // Look at attributes passed in - usage specific. foreach (var attrData in attributes) { @@ -94,76 +92,52 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable Date: Fri, 23 Oct 2020 12:52:34 -0700 Subject: [PATCH 036/161] Add event for marking the Start/Stop of source generation (dotnet/runtimelab#258) * Add event for marking the Start/Stop of source generation Commit migrated from https://github.com/dotnet/runtimelab/commit/1e3819b16572dd8750947f3979d4cf4b8dfedefa --- .../DllImportGenerator/Diagnostics/Events.cs | 63 +++++++++++++++++++ .../DllImportGenerator/DllImportGenerator.cs | 3 + 2 files changed, 66 insertions(+) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs new file mode 100644 index 0000000000000..ef78d0bc86b43 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs @@ -0,0 +1,63 @@ +using System; +using System.Diagnostics.Tracing; + +namespace Microsoft.Interop.Diagnostics +{ + [EventSource(Name = "Microsoft-Interop-SourceGeneration-Events")] + internal sealed class Events : EventSource + { + public static class Keywords + { + public const EventKeywords SourceGeneration = (EventKeywords)1; + } + + public static readonly Events Logger = new Events(); + + private const int StartSourceGenerationEventId = 1; + private const int StopSourceGenerationEventId = StartSourceGenerationEventId + 1; + + private Events() + { } + + /// + /// Utility function that wraps emitting start/stop events for the source generation event. + /// + /// The number of methods being generated + /// An instance that will fire the "stop" event when Disposed. + [NonEvent] + public static IDisposable SourceGenerationStartStop(int methodCount) + { + return new StartStopEvent(methodCount); + } + + // N.B. The 'Start' and 'Stop' suffixes for event names (i.e. "xxxStart" and "xxxStop") + // have special meaning in EventSource. They enable creating 'activities' if they are + // paired and the Stop event's ID is +1 the Start event's ID. + // See https://blogs.msdn.microsoft.com/vancem/2015/09/14/exploring-eventsource-activity-correlation-and-causation-features/ + + /// + /// Indicates the interop's DllImport Roslyn Source Generator has started source generation. + /// + /// The number of methods being generated + [Event(StartSourceGenerationEventId, Level = EventLevel.Informational, Keywords = Keywords.SourceGeneration)] + public void SourceGenerationStart(int methodCount) + { + this.WriteEvent(StartSourceGenerationEventId, methodCount); + } + + /// + /// Indicates the interop's DllImport Roslyn Source Generator has stopped source generation. + /// + [Event(StopSourceGenerationEventId, Level = EventLevel.Informational, Keywords = Keywords.SourceGeneration)] + public void SourceGenerationStop() + { + this.WriteEvent(StopSourceGenerationEventId); + } + + private class StartStopEvent : IDisposable + { + public StartStopEvent(int methodCount) => Logger.SourceGenerationStart(methodCount); + public void Dispose() => Logger.SourceGenerationStop(); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 1b4588f3fc05a..141ff64b409b1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -28,6 +28,9 @@ public void Execute(GeneratorExecutionContext context) return; } + // Fire the start/stop pair for source generation + using var _ = Diagnostics.Events.SourceGenerationStartStop(synRec.Methods.Count); + // Store a mapping between SyntaxTree and SemanticModel. // SemanticModels cache results and since we could be looking at // method declarations in the same SyntaxTree we want to benefit from From 0a073bdf9b180325e2c0b41e5251f7bb81c5a4ee Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 29 Oct 2020 23:40:14 -0700 Subject: [PATCH 037/161] Report generator diagnostic when trying to target pre-.NET 5.0 (dotnet/runtimelab#276) Commit migrated from https://github.com/dotnet/runtimelab/commit/87da2fd706f1e3097c3e471fdf0a5a55758f29bf --- .../AnalyzerReleases.Shipped.md | 21 +---- .../AnalyzerReleases.Unshipped.md | 19 +++++ .../DllImportGenerator/DllImportGenerator.cs | 26 +++++- .../GeneratorDiagnostics.cs | 29 ++++++- .../DllImportGenerator/Resources.Designer.cs | 27 ++++++ .../gen/DllImportGenerator/Resources.resx | 11 +++ .../DllImportGenerator/Diagnostics.md | 12 ++- .../Diagnostics.cs | 82 ++++++++++++++++++- .../DllImportGenerator.UnitTests/TestUtils.cs | 16 ++++ 9 files changed, 216 insertions(+), 27 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md index 449faf2f65ef3..2bf479656968a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Shipped.md @@ -1,20 +1 @@ -## Release 1.0 - -### New Rules - -Rule ID | Category | Severity | Notes ---------|----------|----------|------- -DLLIMPORTGEN001 | Usage | Error -DLLIMPORTGEN002 | Usage | Error -DLLIMPORTGENANALYZER001 | Usage | Error -DLLIMPORTGENANALYZER002 | Usage | Error -DLLIMPORTGENANALYZER003 | Usage | Error -DLLIMPORTGENANALYZER004 | Usage | Error -DLLIMPORTGENANALYZER005 | Usage | Error -DLLIMPORTGENANALYZER006 | Usage | Error -DLLIMPORTGENANALYZER007 | Usage | Error -DLLIMPORTGENANALYZER008 | Usage | Error -DLLIMPORTGENANALYZER009 | Usage | Error -DLLIMPORTGENANALYZER010 | Usage | Warning -DLLIMPORTGENANALYZER011 | Usage | Warning -DLLIMPORTGENANALYZER012 | Usage | Error +; 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 new file mode 100644 index 0000000000000..5d3bd28c144ba --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md @@ -0,0 +1,19 @@ +### 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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 141ff64b409b1..619c5be892b67 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -20,10 +20,12 @@ public class DllImportGenerator : ISourceGenerator private const string GeneratedDllImport = nameof(GeneratedDllImport); private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute); + private static readonly Version MinimumSupportedFrameworkVersion = new Version(5, 0); + public void Execute(GeneratorExecutionContext context) { var synRec = context.SyntaxReceiver as SyntaxReceiver; - if (synRec is null) + if (synRec is null || !synRec.Methods.Any()) { return; } @@ -38,6 +40,13 @@ public void Execute(GeneratorExecutionContext context) var syntaxToModel = new Dictionary(); var generatorDiagnostics = new GeneratorDiagnostics(context); + if (!IsSupportedTargetFramework(context.Compilation)) + { + // We don't return early here, letting the source generation continue. + // This allows a user to copy generated source and use it as a starting point + // for manual marshalling if desired. + generatorDiagnostics.ReportTargetFrameworkNotSupported(MinimumSupportedFrameworkVersion); + } var generatedDllImports = new StringBuilder(); foreach (SyntaxReference synRef in synRec.Methods) @@ -118,6 +127,21 @@ private void PrintGeneratedSource( builder.AppendLine(toPrint.NormalizeWhitespace().ToString()); } + private static bool IsSupportedTargetFramework(Compilation compilation) + { + IAssemblySymbol systemAssembly = compilation.GetSpecialType(SpecialType.System_Object).ContainingAssembly; + return systemAssembly.Identity.Name switch + { + // .NET Framework + "mscorlib" => false, + // .NET Standard + "netstandard" => false, + // .NET Core (when version < 5.0) or .NET + "System.Runtime" => systemAssembly.Identity.Version >= MinimumSupportedFrameworkVersion, + _ => false, + }; + } + private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMaybe) { var attrName = attrSyntaxMaybe.Name.ToString(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 68a25c936a432..9c5d7952fa6b9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -1,11 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis; -#nullable enable - namespace Microsoft.Interop { internal static class DiagnosticExtensions @@ -53,6 +52,7 @@ public class Ids public const string Prefix = "DLLIMPORTGEN"; public const string TypeNotSupported = Prefix + "001"; public const string ConfigurationNotSupported = Prefix + "002"; + public const string TargetFrameworkNotSupported = Prefix + "003"; } private const string Category = "SourceGeneration"; @@ -137,6 +137,16 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); + public readonly static DiagnosticDescriptor TargetFrameworkNotSupported = + new DiagnosticDescriptor( + Ids.TargetFrameworkNotSupported, + GetResourceString(nameof(Resources.TargetFrameworkNotSupportedTitle)), + GetResourceString(nameof(Resources.TargetFrameworkNotSupportedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.TargetFrameworkNotSupportedDescription))); + private readonly GeneratorExecutionContext context; public GeneratorDiagnostics(GeneratorExecutionContext context) @@ -253,6 +263,19 @@ internal void ReportMarshallingNotSupported( } } + /// + /// Report diagnostic for targeting a framework that is not supported + /// + /// Minimum supported version of .NET + public void ReportTargetFrameworkNotSupported(Version minimumSupportedVersion) + { + this.context.ReportDiagnostic( + Diagnostic.Create( + TargetFrameworkNotSupported, + Location.None, + minimumSupportedVersion.ToString(2))); + } + 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 2bf13584e5655..e869f95775f51 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -312,6 +312,33 @@ internal static string StackallocMarshallingShouldSupportAllocatingMarshallingFa } } + /// + /// Looks up a localized string similar to P/Invoke source generation is only supported on .NET {0} or above. The generated source will not be compatible with other frameworks.. + /// + internal static string TargetFrameworkNotSupportedDescription { + get { + return ResourceManager.GetString("TargetFrameworkNotSupportedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 'GeneratedDllImportAttribute' cannot be used for source-generated P/Invokes on the current target framework. Source-generated P/Invokes require .NET {0} or above.. + /// + internal static string TargetFrameworkNotSupportedMessage { + get { + return ResourceManager.GetString("TargetFrameworkNotSupportedMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Current target framework is not supported by source-generated P/Invokes. + /// + internal static string TargetFrameworkNotSupportedTitle { + get { + return ResourceManager.GetString("TargetFrameworkNotSupportedTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index c42041ed776fe..00c92d9dcb97f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -201,6 +201,17 @@ Native type '{0}' has a stack-allocating constructor does not support marshalling in scenarios where stack allocation is impossible + + P/Invoke source generation is only supported on .NET {0} or above. The generated source will not be compatible with other frameworks. + {0} is a version number + + + 'GeneratedDllImportAttribute' cannot be used for source-generated P/Invokes on the current target framework. Source-generated P/Invokes require .NET {0} or above. + {0} is a version number + + + Current target framework is not supported by source-generated P/Invokes + For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Diagnostics.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Diagnostics.md index d69d633022b09..d04a385191478 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Diagnostics.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Diagnostics.md @@ -4,7 +4,7 @@ For all [Roslyn diagnostics](https://docs.microsoft.com/dotnet/api/microsoft.cod | Setting | Value | | -------- | ------------------ | -| Category | DllImportGenerator | +| Category | SourceGeneration | | Severity | Error | | Enabled | True | @@ -36,4 +36,12 @@ public static partial void Method([MarshalAs(UnmanagedType.SafeArray, SafeArrayS // Unsupported combination of MarshalAs and type being marshalled [GeneratedDllImport("NativeLib")] public static partial void Method([MarshalAs(UnmanagedType.LPStr)] bool b); -``` \ No newline at end of file +``` + +## `DLLIMPORTGEN003`: Current target framework is not supported by source-generated P/Invokes + +The `GeneratedDllImport` is being used when targeting a framework that is not supported by source-generated P/Invokes. The generated code is currently only compatible with .NET 5.0 or above. + +# Analyzer Diagnostics + +The P/Invoke source generator library also contains analyzers that emit diagnostics. These diagnostics flag issues around usage (i.e. of P/Invoke and marshalling attributes) rather than the source generation scenario support issues flagged by the generator itself. 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 4f53f44339b1d..335df5d4d345c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs @@ -6,7 +6,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Text; using Microsoft.Interop; using Xunit; @@ -14,6 +13,75 @@ namespace DllImportGenerator.UnitTests { public class Diagnostics { + public enum TargetFramework + { + Framework, + Core, + Standard, + Net + } + + [Theory] + [InlineData(TargetFramework.Framework)] + [InlineData(TargetFramework.Core)] + [InlineData(TargetFramework.Standard)] + public async Task TargetFrameworkNotSupported_ReportsDiagnostic(TargetFramework targetFramework) + { + string source = @" +using System.Runtime.InteropServices; +namespace System.Runtime.InteropServices +{ + // Define attribute for pre-.NET 5.0 + sealed class GeneratedDllImportAttribute : System.Attribute + { + public GeneratedDllImportAttribute(string a) { } + } +} +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(); +} +"; + Compilation comp = await TestUtils.CreateCompilationWithReferenceAssemblies(source, GetReferenceAssemblies(targetFramework)); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + DiagnosticResult[] expectedDiags = new DiagnosticResult[] + { + new DiagnosticResult(GeneratorDiagnostics.TargetFrameworkNotSupported) + .WithArguments("5.0") + }; + VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + [Theory] + [InlineData(TargetFramework.Framework)] + [InlineData(TargetFramework.Core)] + [InlineData(TargetFramework.Standard)] + public async Task TargetFrameworkNotSupported_NoGeneratedDllImport_NoDiagnostic(TargetFramework targetFramework) + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [DllImport(""DoesNotExist"")] + public static extern void Method(); +} +"; + Compilation comp = await TestUtils.CreateCompilationWithReferenceAssemblies(source, GetReferenceAssemblies(targetFramework)); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(generatorDiags); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + [Fact] public async Task ParameterTypeNotSupported_ReportsDiagnostic() { @@ -327,5 +395,17 @@ private static Diagnostic[] GetSortedDiagnostics(IEnumerable diagnos .ThenBy(d => d.Id) .ToArray(); } + + private static ReferenceAssemblies GetReferenceAssemblies(TargetFramework targetFramework) + { + return targetFramework switch + { + TargetFramework.Framework => ReferenceAssemblies.NetFramework.Net48.Default, + TargetFramework.Standard => ReferenceAssemblies.NetStandard.NetStandard21, + TargetFramework.Core => ReferenceAssemblies.NetCore.NetCoreApp31, + TargetFramework.Net => ReferenceAssemblies.NetCore.NetCoreApp50, + _ => ReferenceAssemblies.Default + }; + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index e5d79820f9917..c847e9e1f3b51 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -48,6 +48,22 @@ public static async Task CreateCompilation(string source, OutputKin new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); } + /// + /// Create a compilation given source and reference assemblies + /// + /// Source to compile + /// Reference assemblies to include + /// Output type + /// Whether or not use of the unsafe keyword should be allowed + /// The resulting compilation + public static async Task CreateCompilationWithReferenceAssemblies(string source, ReferenceAssemblies referenceAssemblies, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true) + { + return CSharpCompilation.Create("compilation", + new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, + (await referenceAssemblies.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)), + new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); + } + public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() { // TODO: When .NET 5.0 releases, we can simplify this. From 3cef35023d60906f81be1d02ddf46633780565c1 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 2 Nov 2020 09:45:48 -0800 Subject: [PATCH 038/161] Add analyzer for GeneratedDllImport attribute usage (dotnet/runtimelab#277) Commit migrated from https://github.com/dotnet/runtimelab/commit/c7a6be69e7c31b932eed4067ecc2afc246bf1040 --- .../AnalyzerReleases.Unshipped.md | 1 + .../Analyzers/AnalyzerDiagnostics.cs | 37 +++++ .../Analyzers/GeneratedDllImportAnalyzer.cs | 81 ++++++++++ .../ManualTypeMarshallingAnalyzer.cs | 80 +++++----- .../DllImportGenerator/Resources.Designer.cs | 27 ++++ .../gen/DllImportGenerator/Resources.resx | 9 ++ .../gen/DllImportGenerator/TypeNames.cs | 2 + .../GeneratedDllImportAnalyzerTests.cs | 143 ++++++++++++++++++ .../ManualTypeMarshallingAnalyzerTests.cs | 4 +- 9 files changed, 343 insertions(+), 41 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs rename src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/{ => Analyzers}/ManualTypeMarshallingAnalyzer.cs (82%) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md index 5d3bd28c144ba..08bea59ab561b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md @@ -17,3 +17,4 @@ DLLIMPORTGENANALYZER009 | Usage | Error | ValuePropertyMustHaveGet DLLIMPORTGENANALYZER010 | Usage | Warning | GetPinnableReferenceShouldSupportAllocatingMarshallingFallback DLLIMPORTGENANALYZER011 | Usage | Warning | StackallocMarshallingShouldSupportAllocatingMarshallingFallback DLLIMPORTGENANALYZER012 | Usage | Error | StackallocConstructorMustHaveStackBufferSizeConstant +DLLIMPORTGENANALYZER013 | Usage | Warning | GeneratedDllImportMissingRequiredModifiers diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs new file mode 100644 index 0000000000000..6bc7db892db43 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs @@ -0,0 +1,37 @@ +using Microsoft.CodeAnalysis; + +namespace Microsoft.Interop.Analyzers +{ + internal static class AnalyzerDiagnostics + { + /// + /// Analyzer rule IDs + /// + public static class Ids + { + public const string Prefix = "DLLIMPORTGENANALYZER"; + + // ManualTypeMarshalling + public const string BlittableTypeMustBeBlittable = Prefix + "001"; + public const string CannotHaveMultipleMarshallingAttributes = Prefix + "002"; + public const string NativeTypeMustBeNonNull = Prefix + "003"; + public const string NativeTypeMustBeBlittable = Prefix + "004"; + public const string GetPinnableReferenceReturnTypeBlittable = Prefix + "005"; + public const string NativeTypeMustBePointerSized = Prefix + "006"; + public const string NativeTypeMustHaveRequiredShape = Prefix + "007"; + public const string ValuePropertyMustHaveSetter = Prefix + "008"; + public const string ValuePropertyMustHaveGetter = Prefix + "009"; + public const string GetPinnableReferenceShouldSupportAllocatingMarshallingFallback = Prefix + "010"; + public const string StackallocMarshallingShouldSupportAllocatingMarshallingFallback = Prefix + "011"; + public const string StackallocConstructorMustHaveStackBufferSizeConstant = Prefix + "012"; + + // GeneratedDllImport + public const string GeneratedDllImportMissingRequiredModifiers = Prefix + "013"; + } + + internal static LocalizableResourceString GetResourceString(string resourceName) + { + return new LocalizableResourceString(resourceName, Resources.ResourceManager, typeof(Resources)); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs new file mode 100644 index 0000000000000..3bedc018cf583 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs @@ -0,0 +1,81 @@ +using System.Collections.Immutable; +using System.Linq; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; + +using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics; + +namespace Microsoft.Interop.Analyzers +{ + [DiagnosticAnalyzer(LanguageNames.CSharp)] + public class GeneratedDllImportAnalyzer : DiagnosticAnalyzer + { + private const string Category = "Usage"; + + public readonly static DiagnosticDescriptor GeneratedDllImportMissingModifiers = + new DiagnosticDescriptor( + Ids.GeneratedDllImportMissingRequiredModifiers, + GetResourceString(nameof(Resources.GeneratedDllImportMissingModifiersTitle)), + GetResourceString(nameof(Resources.GeneratedDllImportMissingModifiersMessage)), + Category, + DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.GeneratedDllImportMissingModifiersDescription))); + + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(GeneratedDllImportMissingModifiers); + + public override void Initialize(AnalysisContext context) + { + // Don't analyze generated code + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + context.RegisterCompilationStartAction( + compilationContext => + { + INamedTypeSymbol? generatedDllImportAttributeType = compilationContext.Compilation.GetTypeByMetadataName(TypeNames.GeneratedDllImportAttribute); + if (generatedDllImportAttributeType == null) + return; + + compilationContext.RegisterSymbolAction(symbolContext => AnalyzeSymbol(symbolContext, generatedDllImportAttributeType), SymbolKind.Method); + }); + } + + private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbol generatedDllImportAttributeType) + { + var methodSymbol = (IMethodSymbol)context.Symbol; + + // Check if method is marked with GeneratedDllImportAttribute + ImmutableArray attributes = methodSymbol.GetAttributes(); + if (!attributes.Any(attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, generatedDllImportAttributeType))) + return; + + if (!methodSymbol.IsStatic) + { + // Must be marked static + context.ReportDiagnostic(methodSymbol.CreateDiagnostic(GeneratedDllImportMissingModifiers, methodSymbol.Name)); + } + else + { + // Make sure declarations are marked partial. Technically, we can just check one + // declaration, since Roslyn would error on inconsistent partial declarations. + foreach (var reference in methodSymbol.DeclaringSyntaxReferences) + { + var syntax = reference.GetSyntax(context.CancellationToken); + var methodSyntax = syntax as MethodDeclarationSyntax; + if (methodSyntax == null) + continue; + + if (!methodSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) + { + // Must be marked partial + context.ReportDiagnostic(methodSymbol.CreateDiagnostic(GeneratedDllImportMissingModifiers, methodSymbol.Name)); + break; + } + } + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs similarity index 82% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs rename to src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 9cb682d1d38c9..04e7fb065e342 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -5,133 +5,134 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -namespace Microsoft.Interop +using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics; + +namespace Microsoft.Interop.Analyzers { [DiagnosticAnalyzer(LanguageNames.CSharp)] public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer { - public const string Prefix = "DLLIMPORTGENANALYZER"; private const string Category = "Usage"; + public readonly static DiagnosticDescriptor BlittableTypeMustBeBlittableRule = new DiagnosticDescriptor( - Prefix + "001", + Ids.BlittableTypeMustBeBlittable, "BlittableTypeMustBeBlittable", - new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.BlittableTypeMustBeBlittableMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription))); public readonly static DiagnosticDescriptor CannotHaveMultipleMarshallingAttributesRule = new DiagnosticDescriptor( - Prefix + "002", + Ids.CannotHaveMultipleMarshallingAttributes, "CannotHaveMultipleMarshallingAttributes", - new LocalizableResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesDescription))); - public readonly static DiagnosticDescriptor NativeTypeMustBeNonNullRule = new DiagnosticDescriptor( - Prefix + "003", + Ids.NativeTypeMustBeNonNull, "NativeTypeMustBeNonNull", - new LocalizableResourceString(nameof(Resources.NativeTypeMustBeNonNullMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.NativeTypeMustBeNonNullMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.NativeTypeMustBeNonNullDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.NativeTypeMustBeNonNullDescription))); public readonly static DiagnosticDescriptor NativeTypeMustBeBlittableRule = new DiagnosticDescriptor( - Prefix + "004", + Ids.NativeTypeMustBeBlittable, "NativeTypeMustBeBlittable", - new LocalizableResourceString(nameof(Resources.NativeTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.NativeTypeMustBeBlittableMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription))); public readonly static DiagnosticDescriptor GetPinnableReferenceReturnTypeBlittableRule = new DiagnosticDescriptor( - Prefix + "005", + Ids.GetPinnableReferenceReturnTypeBlittable, "GetPinnableReferenceReturnTypeBlittable", - new LocalizableResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableDescription))); public readonly static DiagnosticDescriptor NativeTypeMustBePointerSizedRule = new DiagnosticDescriptor( - Prefix + "006", + Ids.NativeTypeMustBePointerSized, "NativeTypeMustBePointerSized", - new LocalizableResourceString(nameof(Resources.NativeTypeMustBePointerSizedMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.NativeTypeMustBePointerSizedMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.NativeTypeMustBePointerSizedDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.NativeTypeMustBePointerSizedDescription))); public readonly static DiagnosticDescriptor NativeTypeMustHaveRequiredShapeRule = new DiagnosticDescriptor( - Prefix + "007", + Ids.NativeTypeMustHaveRequiredShape, "NativeTypeMustHaveRequiredShape", - new LocalizableResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeDescription))); public readonly static DiagnosticDescriptor ValuePropertyMustHaveSetterRule = new DiagnosticDescriptor( - Prefix + "008", + Ids.ValuePropertyMustHaveSetter, "ValuePropertyMustHaveSetter", - new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveSetterMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.ValuePropertyMustHaveSetterMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveSetterDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.ValuePropertyMustHaveSetterDescription))); public readonly static DiagnosticDescriptor ValuePropertyMustHaveGetterRule = new DiagnosticDescriptor( - Prefix + "009", + Ids.ValuePropertyMustHaveGetter, "ValuePropertyMustHaveGetter", - new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveGetterMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.ValuePropertyMustHaveGetterMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveGetterDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.ValuePropertyMustHaveGetterDescription))); public readonly static DiagnosticDescriptor GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( - Prefix + "010", + Ids.GetPinnableReferenceShouldSupportAllocatingMarshallingFallback, "GetPinnableReferenceShouldSupportAllocatingMarshallingFallback", - new LocalizableResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage)), Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackDescription))); public readonly static DiagnosticDescriptor StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( - Prefix + "011", + Ids.StackallocMarshallingShouldSupportAllocatingMarshallingFallback, "StackallocMarshallingShouldSupportAllocatingMarshallingFallback", - new LocalizableResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage)), Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackDescription))); public readonly static DiagnosticDescriptor StackallocConstructorMustHaveStackBufferSizeConstantRule = new DiagnosticDescriptor( - Prefix + "012", + Ids.StackallocConstructorMustHaveStackBufferSizeConstant, "StackallocConstructorMustHaveStackBufferSizeConstant", - new LocalizableResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantMessage), Resources.ResourceManager, typeof(Resources)), + GetResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantDescription), Resources.ResourceManager, typeof(Resources))); + description: GetResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantDescription))); public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create( @@ -150,6 +151,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { + // Don't analyze generated code context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); context.RegisterCompilationStartAction(PrepareForAnalysis); 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 e869f95775f51..ecae163a53a4d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -150,6 +150,33 @@ internal static string ConfigurationNotSupportedTitle { } } + /// + /// Looks up a localized string similar to Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'.. + /// + internal static string GeneratedDllImportMissingModifiersDescription { + get { + return ResourceManager.GetString("GeneratedDllImportMissingModifiersDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Method '{0}' should be 'static' and 'partial' when marked with 'GeneratedDllImportAttribute'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'.. + /// + internal static string GeneratedDllImportMissingModifiersMessage { + get { + return ResourceManager.GetString("GeneratedDllImportMissingModifiersMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Method marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. + /// + internal static string GeneratedDllImportMissingModifiersTitle { + get { + return ResourceManager.GetString("GeneratedDllImportMissingModifiersTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to The return type of 'GetPinnableReference' (after accounting for 'ref') must be blittable.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 00c92d9dcb97f..bf7b4e58a3c87 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -147,6 +147,15 @@ Specified configuration is not supported by source-generated P/Invokes. + + Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'. + + + Method '{0}' should be 'static' and 'partial' when marked with 'GeneratedDllImportAttribute'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'. + + + Method marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial' + The return type of 'GetPinnableReference' (after accounting for 'ref') must be blittable. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 6471dd3e867b3..ec347dc44c789 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -6,6 +6,8 @@ namespace Microsoft.Interop { static class TypeNames { + public const string GeneratedDllImportAttribute = "System.Runtime.InteropServices.GeneratedDllImportAttribute"; + public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute"; public const string BlittableTypeAttribute = "System.Runtime.InteropServices.BlittableTypeAttribute"; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs new file mode 100644 index 0000000000000..e05b24cf64fa9 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs @@ -0,0 +1,143 @@ +using System.Threading.Tasks; +using Xunit; +using static Microsoft.Interop.Analyzers.GeneratedDllImportAnalyzer; + +using VerifyCS = DllImportGenerator.UnitTests.Verifiers.CSharpAnalyzerVerifier; + +namespace DllImportGenerator.UnitTests +{ + public class GeneratedDllImportAnalyzerTests + { + [Fact] + public async Task NonPartialMethod_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static void {|#0:Method1|}() { } + + [GeneratedDllImport(""DoesNotExist"")] + static void {|#1:Method2|}() { } + + [GeneratedDllImport(""DoesNotExist"")] + public static extern void {|#2:ExternMethod1|}(); + + [GeneratedDllImport(""DoesNotExist"")] + static extern void {|#3:ExternMethod2|}(); +} +"; + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(0) + .WithArguments("Method1"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(1) + .WithArguments("Method2"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(2) + .WithArguments("ExternMethod1"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(3) + .WithArguments("ExternMethod2")); + } + + [Fact] + public async Task NonStaticMethod_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public partial void {|#0:Method1|}(); + + [GeneratedDllImport(""DoesNotExist"")] + partial void {|#1:Method2|}(); +} + +partial class Test +{ + public partial void {|#3:Method1|}() { } +} +"; + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(0) + .WithArguments("Method1"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(1) + .WithArguments("Method2"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(3) + .WithArguments("Method1")); + } + + [Fact] + public async Task NonPartialNonStaticMethod_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public void {|#0:Method1|}() { } + + [GeneratedDllImport(""DoesNotExist"")] + void {|#1:Method2|}() { } + + [GeneratedDllImport(""DoesNotExist"")] + public extern void {|#2:ExternMethod1|}(); + + [GeneratedDllImport(""DoesNotExist"")] + extern void {|#3:ExternMethod2|}(); +} +"; + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(0) + .WithArguments("Method1"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(1) + .WithArguments("Method2"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(2) + .WithArguments("ExternMethod1"), + VerifyCS.Diagnostic(GeneratedDllImportMissingModifiers) + .WithLocation(3) + .WithArguments("ExternMethod2")); + } + + [Fact] + public async Task NotGeneratedDllImport_NoDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + public void Method1() { } + partial void Method2(); +} +"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task StaticPartialMethod_NoDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + static partial void Method2(); +} +"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index ae3aed147827c..342ee1e0a5694 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Threading.Tasks; using Xunit; -using static Microsoft.Interop.ManualTypeMarshallingAnalyzer; +using static Microsoft.Interop.Analyzers.ManualTypeMarshallingAnalyzer; -using VerifyCS = DllImportGenerator.UnitTests.Verifiers.CSharpAnalyzerVerifier; +using VerifyCS = DllImportGenerator.UnitTests.Verifiers.CSharpAnalyzerVerifier; namespace DllImportGenerator.UnitTests { From c9fdb1b6e8a943619d17f479af0cd297df025c67 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 2 Nov 2020 16:42:40 -0800 Subject: [PATCH 039/161] Array marshalling support (dotnet/runtimelab#272) Commit migrated from https://github.com/dotnet/runtimelab/commit/bfd398c97a48a66929554af33736057b6fc7b5cf --- .../ManualTypeMarshallingAnalyzer.cs | 2 +- .../ArrayMarshallingCodeContext.cs | 48 +++ .../gen/DllImportGenerator/DllImportStub.cs | 14 +- .../Marshalling/BlittableArrayMarshaller.cs | 238 ++++++++++++++ .../Marshalling/BlittableMarshaller.cs | 5 +- ...nditionalStackallocMarshallingGenerator.cs | 217 +++++++++++++ .../Marshalling/MarshallerHelpers.cs | 45 +++ .../Marshalling/MarshallingGenerator.cs | 118 +++++-- .../NonBlittableArrayMarshaller.cs | 198 ++++++++++++ .../Marshalling/StringMarshaller.Utf16.cs | 275 ++++++---------- .../Marshalling/StringMarshaller.Utf8.cs | 306 +++++++----------- .../MarshallingAttributeInfo.cs | 33 +- .../DllImportGenerator/Resources.Designer.cs | 27 ++ .../gen/DllImportGenerator/Resources.resx | 9 + .../gen/DllImportGenerator/StubCodeContext.cs | 4 + .../DllImportGenerator/StubCodeGenerator.cs | 16 + .../gen/DllImportGenerator/TypeNames.cs | 5 +- .../DllImportGenerator/TypePositionInfo.cs | 72 +++-- .../TypeSymbolExtensions.cs | 18 ++ .../DllImportGenerator/Compatibility.md | 10 + .../libraries/DllImportGenerator/Pipeline.md | 31 ++ .../DllImportGenerator.Tests/ArrayTests.cs | 164 ++++++++++ .../CodeSnippets.cs | 44 +++ .../CompileFails.cs | 1 + .../DllImportGenerator.UnitTests/Compiles.cs | 55 +++- .../tests/TestAssets/NativeExports/Arrays.cs | 124 +++++++ .../tests/TestAssets/NativeExports/Strings.cs | 4 +- 27 files changed, 1647 insertions(+), 436 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 04e7fb065e342..2d9c0669ea773 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -163,7 +163,7 @@ private void PrepareForAnalysis(CompilationStartAnalysisContext context) var blittableTypeAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute); var nativeMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute); var marshalUsingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute); - var spanOfByte = context.Compilation.GetTypeByMetadataName(TypeNames.System_Span)!.Construct(context.Compilation.GetSpecialType(SpecialType.System_Byte)); + var spanOfByte = context.Compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(context.Compilation.GetSpecialType(SpecialType.System_Byte)); if (generatedMarshallingAttribute is not null && blittableTypeAttribute is not null diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs new file mode 100644 index 0000000000000..705d5d7b418bf --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal sealed class ArrayMarshallingCodeContext : StubCodeContext + { + private readonly string indexerIdentifier; + private readonly StubCodeContext parentContext; + + public override bool PinningSupported => false; + + public override bool StackSpaceUsable => false; + + public override bool CanUseAdditionalTemporaryState => false; + + public ArrayMarshallingCodeContext(Stage currentStage, string indexerIdentifier, StubCodeContext parentContext) + { + CurrentStage = currentStage; + this.indexerIdentifier = indexerIdentifier; + this.parentContext = parentContext; + } + + /// + /// Get managed and native instance identifiers for the + /// + /// Object for which to get identifiers + /// Managed and native identifiers + public override (string managed, string native) GetIdentifiers(TypePositionInfo info) + { + var (managed, native) = parentContext.GetIdentifiers(info); + return ($"{managed}[{indexerIdentifier}]", $"{native}[{indexerIdentifier}]"); + } + + public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) + { + // We don't have parameters to look at when we're in the middle of marshalling an array. + return null; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 52a95efc2fdbe..8a11d17dac917 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -157,14 +157,20 @@ public static DllImportStub Create( { var param = method.Parameters[i]; var typeInfo = TypePositionInfo.CreateForParameter(param, defaultInfo, compilation, diagnostics); - typeInfo.ManagedIndex = i; - typeInfo.NativeIndex = paramsTypeInfo.Count; + typeInfo = typeInfo with + { + ManagedIndex = i, + NativeIndex = paramsTypeInfo.Count + }; paramsTypeInfo.Add(typeInfo); } TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), defaultInfo, compilation, diagnostics); - retTypeInfo.ManagedIndex = TypePositionInfo.ReturnIndex; - retTypeInfo.NativeIndex = TypePositionInfo.ReturnIndex; + retTypeInfo = retTypeInfo with + { + ManagedIndex = TypePositionInfo.ReturnIndex, + NativeIndex = TypePositionInfo.ReturnIndex + }; if (!dllImportData.PreserveSig) { // [TODO] Create type info for native HRESULT return diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs new file mode 100644 index 0000000000000..b1d12ef346944 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs @@ -0,0 +1,238 @@ +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal class BlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator + { + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of small array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + private const int StackAllocBytesThreshold = 0x200; + private readonly ExpressionSyntax _numElementsExpr; + + public BlittableArrayMarshaller(ExpressionSyntax numElementsExpr) + { + _numElementsExpr = numElementsExpr; + } + + private TypeSyntax GetElementTypeSyntax(TypePositionInfo info) + { + return ((IArrayTypeSymbol)info.ManagedType).ElementType.AsTypeSyntax(); + } + + public override TypeSyntax AsNativeType(TypePositionInfo info) + { + return PointerType(GetElementTypeSyntax(info)); + } + + public override ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return info.IsByRef + ? Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(context.GetIdentifiers(info).native))) + : Argument(IdentifierName(context.GetIdentifiers(info).native)); + } + + public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); + if (!info.IsByRef && !info.IsManagedReturnPosition && context.PinningSupported) + { + if (context.CurrentStage == StubCodeContext.Stage.Pin) + { + // fixed ( = &MemoryMarshal.GetArrayDataReference()) + yield return FixedStatement( + VariableDeclaration(AsNativeType(info), SingletonSeparatedList( + VariableDeclarator(nativeIdentifier) + .WithInitializer(EqualsValueClause( + PrefixUnaryExpression(SyntaxKind.AddressOfExpression, + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), + IdentifierName("GetArrayDataReference")), + ArgumentList( + SingletonSeparatedList(Argument(IdentifierName(managedIdentifer))) + ))))))), + EmptyStatement()); + } + yield break; + } + + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + foreach (var statement in GenerateConditionalAllocationSyntax( + info, + context, + StackAllocBytesThreshold)) + { + yield return statement; + } + + // new Span(managedIdentifier).CopyTo(new Span(nativeIdentifier, managedIdentifier.Length)); + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ObjectCreationExpression( + GenericName(Identifier(TypeNames.System_Span), + TypeArgumentList( + SingletonSeparatedList( + GetElementTypeSyntax(info))))) + .WithArgumentList( + ArgumentList(SingletonSeparatedList( + Argument(IdentifierName(managedIdentifer))))), + IdentifierName("CopyTo"))) + .WithArgumentList( + ArgumentList( + SingletonSeparatedList( + Argument( + ObjectCreationExpression( + GenericName(TypeNames.System_Span) + .WithTypeArgumentList( + TypeArgumentList( + SingletonSeparatedList( + GetElementTypeSyntax(info))))) + .WithArgumentList( + ArgumentList( + SeparatedList( + new []{ + Argument( + IdentifierName(nativeIdentifier)), + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifer), + IdentifierName("Length")))})))))))); + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block( + // = new []; + ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + ArrayCreationExpression( + ArrayType(GetElementTypeSyntax(info), + SingletonList(ArrayRankSpecifier( + SingletonSeparatedList(_numElementsExpr))))))), + // new Span(nativeIdentifier, managedIdentifier.Length).CopyTo(managedIdentifier); + ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ObjectCreationExpression( + GenericName(Identifier(TypeNames.System_Span), + TypeArgumentList( + SingletonSeparatedList( + GetElementTypeSyntax(info))))) + .WithArgumentList( + ArgumentList( + SeparatedList( + new[]{ + Argument( + IdentifierName(nativeIdentifier)), + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifer), + IdentifierName("Length")))}))), + IdentifierName("CopyTo"))) + .WithArgumentList( + ArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(managedIdentifer))))))), + ElseClause( + ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + LiteralExpression(SyntaxKind.NullLiteralExpression))))); + } + break; + case StubCodeContext.Stage.Cleanup: + yield return GenerateConditionalAllocationFreeSyntax(info, context); + break; + } + } + + public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return (info.IsByRef || info.IsManagedReturnPosition) || !context.PinningSupported; + } + + protected override ExpressionSyntax GenerateAllocationExpression(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, out bool allocationRequiresByteLength) + { + allocationRequiresByteLength = true; + // ()Marshal.AllocCoTaskMem() + return CastExpression(AsNativeType(info), + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), + IdentifierName("AllocCoTaskMem")), + ArgumentList(SingletonSeparatedList(Argument(IdentifierName(byteLengthIdentifier)))))); + } + + protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) + { + // sizeof() * .Length + return BinaryExpression(SyntaxKind.MultiplyExpression, + SizeOfExpression(GetElementTypeSyntax(info)), + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(context.GetIdentifiers(info).managed), + IdentifierName("Length") + )); + } + + protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) + { + return EmptyStatement(); + } + + protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info, StubCodeContext context) + { + // Marshal.FreeCoTaskMem((IntPtr)) + return InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), + IdentifierName("FreeCoTaskMem")), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(context.GetIdentifiers(info).native)))))); + } + } + +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs index 49143d11bf841..1a975bd0e13dc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs @@ -42,7 +42,7 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { - if (!UsesNativeIdentifier(info, context)) + if (!info.IsByRef || info.IsManagedReturnPosition) yield break; (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); @@ -67,6 +67,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } yield break; } + switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: @@ -101,7 +102,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return info.IsByRef && !info.IsManagedReturnPosition; + return info.IsByRef && !info.IsManagedReturnPosition && !context.PinningSupported; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs new file mode 100644 index 0000000000000..a17c763d75c10 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -0,0 +1,217 @@ +using System.Collections.Generic; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal abstract class ConditionalStackallocMarshallingGenerator : IMarshallingGenerator + { + private static string GetAllocationMarkerIdentifier(string managedIdentifier) => $"{managedIdentifier}__allocated"; + + private static string GetByteLengthIdentifier(string managedIdentifier) => $"{managedIdentifier}__bytelen"; + + private static string GetStackAllocIdentifier(string managedIdentifier) => $"{managedIdentifier}__stackptr"; + + protected IEnumerable GenerateConditionalAllocationSyntax( + TypePositionInfo info, + StubCodeContext context, + int stackallocMaxSize) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + + string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(managedIdentifier); + string byteLenIdentifier = GetByteLengthIdentifier(managedIdentifier); + string stackAllocPtrIdentifier = GetStackAllocIdentifier(managedIdentifier); + // = ; + var allocationStatement = ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + GenerateAllocationExpression(info, context, Identifier(byteLenIdentifier), out bool allocationRequiresByteLength))); + + // int = ; + var byteLenAssignment = LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.IntKeyword)), + SingletonSeparatedList( + VariableDeclarator(byteLenIdentifier) + .WithInitializer(EqualsValueClause( + GenerateByteLengthCalculationExpression(info, context)))))); + + if (!context.CanUseAdditionalTemporaryState || !context.StackSpaceUsable || (info.IsByRef && info.RefKind != RefKind.In)) + { + List statements = new List(); + if (allocationRequiresByteLength) + { + statements.Add(byteLenAssignment); + } + statements.Add(allocationStatement); + yield return ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression))); + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(managedIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block(statements)); + yield break; + } + // = false; + yield return LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.BoolKeyword)), + SingletonSeparatedList( + VariableDeclarator(allocationMarkerIdentifier) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); + + // Code block for stackalloc if number of bytes is below threshold size + var marshalOnStack = Block( + // byte* = stackalloc byte[]; + LocalDeclarationStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))), + SingletonSeparatedList( + VariableDeclarator(stackAllocPtrIdentifier) + .WithInitializer(EqualsValueClause( + StackAllocArrayCreationExpression( + ArrayType( + PredefinedType(Token(SyntaxKind.ByteKeyword)), + SingletonList( + ArrayRankSpecifier(SingletonSeparatedList( + IdentifierName(byteLenIdentifier))))))))))), + GenerateStackallocOnlyValueMarshalling(info, context, Identifier(byteLenIdentifier), Identifier(stackAllocPtrIdentifier)), + // = ; + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + CastExpression( + AsNativeType(info), + IdentifierName(stackAllocPtrIdentifier))))); + + // if ( > ) + // { + // ; + // } + // else + // { + // byte* = stackalloc byte[]; + // ; + // = (); + // } + var allocBlock = IfStatement( + BinaryExpression( + SyntaxKind.GreaterThanExpression, + IdentifierName(byteLenIdentifier), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(stackallocMaxSize))), + Block( + allocationStatement, + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(allocationMarkerIdentifier), + LiteralExpression(SyntaxKind.TrueLiteralExpression)))), + ElseClause(marshalOnStack)); + + yield return IfStatement( + BinaryExpression( + SyntaxKind.EqualsExpression, + IdentifierName(managedIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block( + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)))), + ElseClause(Block(byteLenAssignment, allocBlock))); + } + + protected StatementSyntax GenerateConditionalAllocationFreeSyntax( + TypePositionInfo info, + StubCodeContext context) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(managedIdentifier); + if (!context.CanUseAdditionalTemporaryState || (info.IsByRef && info.RefKind != RefKind.In)) + { + return ExpressionStatement(GenerateFreeExpression(info, context)); + } + else + { + // if () + // { + // ; + // } + return IfStatement( + IdentifierName(allocationMarkerIdentifier), + Block(ExpressionStatement(GenerateFreeExpression(info, context)))); + } + } + + /// + /// Generate an expression that allocates memory for the native representation of the object. + /// + /// Object to marshal + /// Code generation context + /// An identifier that represents how many bytes must be allocated. + /// If the allocation expression uses , true; otherwise false. + /// An expression that allocates memory for the native representation of the object. + protected abstract ExpressionSyntax GenerateAllocationExpression( + TypePositionInfo info, + StubCodeContext context, + SyntaxToken byteLengthIdentifier, + out bool allocationRequiresByteLength); + + /// + /// Generates an expression that represents the number of bytes that need to be allocated. + /// + /// Object to marshal + /// Code generation context + /// An expression that results in the number of bytes to allocate as a C# int. + protected abstract ExpressionSyntax GenerateByteLengthCalculationExpression( + TypePositionInfo info, + StubCodeContext context); + + /// + /// Generate a statement that is only executed when memory is stack allocated. + /// + /// Object to marshal + /// Code generation context + /// An identifier that represents the number of bytes allocated. + /// An identifier that represents a pointer to the stack allocated memory (of type byte*). + /// A statement that is only executed when memory is stack allocated. + protected abstract StatementSyntax GenerateStackallocOnlyValueMarshalling( + TypePositionInfo info, + StubCodeContext context, + SyntaxToken byteLengthIdentifier, + SyntaxToken stackAllocPtrIdentifier); + + /// + /// Generate code to free native allocated memory used during marshalling. + /// + /// Object to marshal + /// Code generation context + /// An expression that frees allocated memory. + protected abstract ExpressionSyntax GenerateFreeExpression( + TypePositionInfo info, + StubCodeContext context); + + /// + public abstract TypeSyntax AsNativeType(TypePositionInfo info); + + /// + public abstract ParameterSyntax AsParameter(TypePositionInfo info); + + /// + public abstract ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context); + + /// + public abstract IEnumerable Generate(TypePositionInfo info, StubCodeContext context); + + /// + public abstract bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs new file mode 100644 index 0000000000000..e461f5e964bde --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal static class MarshallerHelpers + { + public static ForStatementSyntax GetForLoop(string collectionIdentifier, string indexerIdentifier) + { + // for(int = 0; < .Length; ++) + // ; + return ForStatement(EmptyStatement()) + .WithDeclaration( + VariableDeclaration( + PredefinedType( + Token(SyntaxKind.IntKeyword))) + .WithVariables( + SingletonSeparatedList( + VariableDeclarator( + Identifier(indexerIdentifier)) + .WithInitializer( + EqualsValueClause( + LiteralExpression( + SyntaxKind.NumericLiteralExpression, + Literal(0))))))) + .WithCondition( + BinaryExpression( + SyntaxKind.LessThanExpression, + IdentifierName(indexerIdentifier), + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(collectionIdentifier), + IdentifierName("Length")))) + .WithIncrementors( + SingletonSeparatedList( + PrefixUnaryExpression( + SyntaxKind.PreIncrementExpression, + IdentifierName(indexerIdentifier)))); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index e698bece7029c..04769a24bc291 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { @@ -127,27 +129,27 @@ public static IMarshallingGenerator Create( switch (info) { // Blittable primitives with no marshalling info or with a compatible [MarshalAs] attribute. - case { ManagedType: { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I1 } } - or { ManagedType: { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U1 } } - or { ManagedType: { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I2 } } - or { ManagedType: { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U2 } } - or { ManagedType: { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I4 } } - or { ManagedType: { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U4 } } - or { ManagedType: { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.I8 } } - or { ManagedType: { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.U8 } } + case { ManagedType: { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I1, _) } + or { ManagedType: { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U1, _) } + or { ManagedType: { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I2, _) } + or { ManagedType: { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U2, _) } + or { ManagedType: { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I4, _) } + or { ManagedType: { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U4, _) } + or { ManagedType: { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I8, _) } + or { ManagedType: { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U8, _) } or { ManagedType: { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo } - or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo} - or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.R4 } } - or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.R8 } }: + or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo } + or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } + or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: return Blittable; case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I1 or UnmanagedType.U1 } }: + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: return ByteBool; - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool } }: + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool, _) }: return WinBool; - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo { UnmanagedType: UnmanagedType.VariantBool } }: + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: return VariantBool; case { ManagedType: { SpecialType: SpecialType.System_Char } }: @@ -156,10 +158,10 @@ public static IMarshallingGenerator Create( case { ManagedType: { SpecialType: SpecialType.System_String } }: return CreateStringMarshaller(info, context); - case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo { UnmanagedType: UnmanagedType.FunctionPtr } }: + case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: return Delegate; - case { MarshallingAttributeInfo: BlittableTypeAttributeInfo _ }: + case { MarshallingAttributeInfo: BlittableTypeAttributeInfo }: return Blittable; // Marshalling in new model @@ -167,12 +169,26 @@ public static IMarshallingGenerator Create( return Forwarder; // Simple marshalling with new attribute model, only have type name. - case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo { NativeMarshallingFullyQualifiedTypeName: string name } }: + case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo(string nativeTypeName) }: return Forwarder; - case { MarshallingAttributeInfo: SafeHandleMarshallingInfo _}: + case { MarshallingAttributeInfo: SafeHandleMarshallingInfo }: + if (!context.CanUseAdditionalTemporaryState) + { + throw new MarshallingNotSupportedException(info, context); + } return SafeHandle; + case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType : ITypeSymbol elementType } , MarshallingAttributeInfo: NoMarshallingInfo}: + return CreateArrayMarshaller(info, context, elementType, NoMarshallingInfo.Instance); + + case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType : ITypeSymbol elementType } , MarshallingAttributeInfo: ArrayMarshalAsInfo marshalAsInfo }: + if (marshalAsInfo.UnmanagedArrayType != UnmanagedArrayType.LPArray) + { + throw new MarshallingNotSupportedException(info, context); + } + return CreateArrayMarshaller(info, context, elementType, marshalAsInfo.CreateArraySubTypeMarshalAsInfo()); + case { ManagedType: { SpecialType: SpecialType.System_Void } }: return Forwarder; @@ -263,5 +279,71 @@ private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo inf throw new MarshallingNotSupportedException(info, context); } + + private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, StubCodeContext context) + { + ExpressionSyntax numElementsExpression; + if (info.MarshallingAttributeInfo is not ArrayMarshalAsInfo marshalAsInfo) + { + throw new MarshallingNotSupportedException(info, context); + } + + LiteralExpressionSyntax? constSizeExpression = marshalAsInfo.ArraySizeConst != ArrayMarshalAsInfo.UnspecifiedData + ? LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(marshalAsInfo.ArraySizeConst)) + : null; + ExpressionSyntax? sizeParamIndexExpression = null; + if (marshalAsInfo.ArraySizeParamIndex != ArrayMarshalAsInfo.UnspecifiedData) + { + TypePositionInfo? paramIndexInfo = context.GetTypePositionInfoForManagedIndex(marshalAsInfo.ArraySizeParamIndex); + if (paramIndexInfo is null) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.ArraySizeParamIndexOutOfRange + }; + } + else if (!paramIndexInfo.ManagedType.IsIntegralType()) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.ArraySizeParamTypeMustBeIntegral + }; + } + else + { + var (managed, native) = context.GetIdentifiers(paramIndexInfo); + string identifier = Create(paramIndexInfo, context).UsesNativeIdentifier(paramIndexInfo, context) ? native : managed; + sizeParamIndexExpression = CastExpression( + PredefinedType(Token(SyntaxKind.IntKeyword)), + IdentifierName(identifier)); + } + } + numElementsExpression = (constSizeExpression, sizeParamIndexExpression) switch + { + (null, null) => throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.ArraySizeMustBeSpecified + }, + (not null, null) => constSizeExpression!, + (null, not null) => CheckedExpression(SyntaxKind.CheckedExpression, sizeParamIndexExpression!), + (not null, not null) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, constSizeExpression!, sizeParamIndexExpression!)) + }; + return numElementsExpression; + } + + private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info, StubCodeContext context, ITypeSymbol elementType, MarshallingInfo elementMarshallingInfo) + { + var elementMarshaller = Create(TypePositionInfo.CreateForType(elementType, elementMarshallingInfo), context); + ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + // In this case, we need a numElementsExpression supplied from metadata, so we'll calculate it here. + numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, context); + } + + return elementMarshaller == Blittable + ? new BlittableArrayMarshaller(numElementsExpression) + : new NonBlittableArrayMarshaller(elementMarshaller, numElementsExpression); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs new file mode 100644 index 0000000000000..4373601d5e6f4 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs @@ -0,0 +1,198 @@ +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal class NonBlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator + { + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of small array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + private const int StackAllocBytesThreshold = 0x200; + + private IMarshallingGenerator _elementMarshaller; + private readonly ExpressionSyntax _numElementsExpr; + + public NonBlittableArrayMarshaller(IMarshallingGenerator elementMarshaller, ExpressionSyntax numElementsExpr) + { + _elementMarshaller = elementMarshaller; + _numElementsExpr = numElementsExpr; + } + + private ITypeSymbol GetElementTypeSymbol(TypePositionInfo info) + { + return ((IArrayTypeSymbol)info.ManagedType).ElementType; + } + + private TypeSyntax GetNativeElementTypeSyntax(TypePositionInfo info) + { + return _elementMarshaller.AsNativeType(TypePositionInfo.CreateForType(GetElementTypeSymbol(info), NoMarshallingInfo.Instance)); + } + + public override TypeSyntax AsNativeType(TypePositionInfo info) + { + return PointerType(GetNativeElementTypeSyntax(info)); + } + + public override ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return info.IsByRef + ? Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(context.GetIdentifiers(info).native))) + : Argument(IdentifierName(context.GetIdentifiers(info).native)); + } + + public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); + + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + foreach (var statement in GenerateConditionalAllocationSyntax( + info, + context, + StackAllocBytesThreshold)) + { + yield return statement; + } + + // Iterate through the elements of the array to marshal them + string indexerIdentifier = "i"; + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, indexerIdentifier, context); + yield return IfStatement(BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(managedIdentifer), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + MarshallerHelpers.GetForLoop(managedIdentifer, indexerIdentifier) + .WithStatement(Block( + List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext))))); + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + string indexerIdentifier = "i"; + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, indexerIdentifier, context); + + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block( + // = new []; + ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + ArrayCreationExpression( + ArrayType(GetElementTypeSymbol(info).AsTypeSyntax(), + SingletonList(ArrayRankSpecifier( + SingletonSeparatedList(_numElementsExpr))))))), + // Iterate through the elements of the native array to unmarshal them + MarshallerHelpers.GetForLoop(managedIdentifer, indexerIdentifier) + .WithStatement(Block( + List(_elementMarshaller.Generate( + info with { ManagedType = GetElementTypeSymbol(info) }, + arraySubContext))))), + ElseClause( + ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + LiteralExpression(SyntaxKind.NullLiteralExpression))))); + } + break; + case StubCodeContext.Stage.Cleanup: + { + string indexerIdentifier = "i"; + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, indexerIdentifier, context); + var elementCleanup = List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext)); + if (elementCleanup.Count != 0) + { + // Iterate through the elements of the native array to clean up any unmanaged resources. + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(managedIdentifer), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + MarshallerHelpers.GetForLoop(managedIdentifer, indexerIdentifier) + .WithStatement(Block(elementCleanup))); + } + yield return GenerateConditionalAllocationFreeSyntax(info, context); + } + break; + } + } + + public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return true; + } + + + protected override ExpressionSyntax GenerateAllocationExpression(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, out bool allocationRequiresByteLength) + { + allocationRequiresByteLength = true; + // (*)Marshal.AllocCoTaskMem() + return CastExpression(AsNativeType(info), + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), + IdentifierName("AllocCoTaskMem")), + ArgumentList(SingletonSeparatedList(Argument(IdentifierName(byteLengthIdentifier)))))); + } + + protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) + { + // sizeof() * .Length + return BinaryExpression(SyntaxKind.MultiplyExpression, + SizeOfExpression(GetNativeElementTypeSyntax(info)), + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(context.GetIdentifiers(info).managed), + IdentifierName("Length") + )); + } + + protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) + { + return EmptyStatement(); + } + + protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info, StubCodeContext context) + { + // Marshal.FreeCoTaskMem((IntPtr)) + return InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), + IdentifierName("FreeCoTaskMem")), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(context.GetIdentifiers(info).native)))))); + } + } + +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs index d1dd8510373ac..3d367c030119e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -6,7 +6,7 @@ namespace Microsoft.Interop { - internal class Utf16StringMarshaller : IMarshallingGenerator + internal class Utf16StringMarshaller : ConditionalStackallocMarshallingGenerator { // [Compat] Equivalent of MAX_PATH on Windows to match built-in system // The assumption is file paths are the most common case for marshalling strings, @@ -16,7 +16,7 @@ internal class Utf16StringMarshaller : IMarshallingGenerator private static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.UShortKeyword))); - public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { string identifier = context.GetIdentifiers(info).native; if (info.IsByRef) @@ -40,13 +40,13 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) return Argument(IdentifierName(identifier)); } - public TypeSyntax AsNativeType(TypePositionInfo info) + public override TypeSyntax AsNativeType(TypePositionInfo info) { // ushort* return NativeType; } - public ParameterSyntax AsParameter(TypePositionInfo info) + public override ParameterSyntax AsParameter(TypePositionInfo info) { // ushort** // or @@ -58,7 +58,7 @@ public ParameterSyntax AsParameter(TypePositionInfo info) .WithType(type); } - public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); if (context.PinningSupported && !info.IsByRef && !info.IsManagedReturnPosition) @@ -78,7 +78,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont yield break; } - string usedCoTaskMemIdentifier = $"{managedIdentifier}__usedCoTaskMem"; switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: @@ -91,147 +90,12 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) { - // = (ushort*)Marshal.StringToCoTaskMemUni() - var coTaskMemAlloc = ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - CastExpression( - AsNativeType(info), - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("StringToCoTaskMemUni")), - ArgumentList( - SingletonSeparatedList( - Argument(IdentifierName(managedIdentifier)))))))); - if (info.IsByRef && info.RefKind != RefKind.In) + foreach (var statement in GenerateConditionalAllocationSyntax( + info, + context, + StackAllocBytesThreshold)) { - yield return coTaskMemAlloc; - } - else - { - // = false; - yield return LocalDeclarationStatement( - VariableDeclaration( - PredefinedType(Token(SyntaxKind.BoolKeyword)), - SingletonSeparatedList( - VariableDeclarator(usedCoTaskMemIdentifier) - .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); - - string stackAllocPtrIdentifier = $"{managedIdentifier}__stackalloc"; - string byteLenIdentifier = $"{managedIdentifier}__byteLen"; - - // .Length + 1 - ExpressionSyntax lengthWithNullTerminator = BinaryExpression( - SyntaxKind.AddExpression, - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifier), - IdentifierName("Length")), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))); - - // Code block for stackalloc if string is below threshold size - var marshalOnStack = Block( - // ushort* = stackalloc ushort[.Length + 1]; - LocalDeclarationStatement( - VariableDeclaration( - PointerType(PredefinedType(Token(SyntaxKind.UShortKeyword))), - SingletonSeparatedList( - VariableDeclarator(stackAllocPtrIdentifier) - .WithInitializer(EqualsValueClause( - StackAllocArrayCreationExpression( - ArrayType( - PredefinedType(Token(SyntaxKind.UShortKeyword)), - SingletonList( - ArrayRankSpecifier(SingletonSeparatedList(lengthWithNullTerminator)))))))))), - // ((ReadOnlySpan)).CopyTo(new Span(, .Length + 1)); - ExpressionStatement( - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ParenthesizedExpression( - CastExpression( - GenericName(Identifier("System.ReadOnlySpan"), - TypeArgumentList(SingletonSeparatedList( - PredefinedType(Token(SyntaxKind.CharKeyword))))), - IdentifierName(managedIdentifier))), - IdentifierName("CopyTo")), - ArgumentList( - SeparatedList(new ArgumentSyntax[] { - Argument( - ObjectCreationExpression( - GenericName(Identifier("System.Span"), - TypeArgumentList(SingletonSeparatedList( - PredefinedType(Token(SyntaxKind.CharKeyword))))), - ArgumentList( - SeparatedList(new ArgumentSyntax[]{ - Argument(IdentifierName(stackAllocPtrIdentifier)), - Argument(lengthWithNullTerminator)})), - initializer: null))})))), - // = ; - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - IdentifierName(stackAllocPtrIdentifier)))); - - // if ( == null) - // { - // = null; - // } - // else - // { - // int = (.Length + 1) * sizeof(ushort); - // if ( > ) - // { - // = (ushort*)Marshal.StringToCoTaskMemUni(); - // = true; - // } - // else - // { - // ushort* = stackalloc ushort[.Length + 1]; - // ((ReadOnlySpan)).CopyTo(new Span(, .Length + 1)); - // = ; - // } - // } - yield return IfStatement( - BinaryExpression( - SyntaxKind.EqualsExpression, - IdentifierName(managedIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block( - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)))), - ElseClause( - Block( - LocalDeclarationStatement( - VariableDeclaration( - PredefinedType(Token(SyntaxKind.IntKeyword)), - SingletonSeparatedList( - VariableDeclarator(Identifier(byteLenIdentifier)) - .WithInitializer(EqualsValueClause( - BinaryExpression( - SyntaxKind.MultiplyExpression, - ParenthesizedExpression(lengthWithNullTerminator), - SizeOfExpression(PredefinedType(Token(SyntaxKind.UShortKeyword))))))))), - IfStatement( - BinaryExpression( - SyntaxKind.GreaterThanExpression, - IdentifierName(byteLenIdentifier), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(StackAllocBytesThreshold))), - Block( - coTaskMemAlloc, - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(usedCoTaskMemIdentifier), - LiteralExpression(SyntaxKind.TrueLiteralExpression)))), - ElseClause(marshalOnStack))))); + yield return statement; } } break; @@ -260,39 +124,100 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } break; case StubCodeContext.Stage.Cleanup: - // Marshal.FreeCoTaskMem((IntPtr)) - var freeCoTaskMem = ExpressionStatement( - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("FreeCoTaskMem")), - ArgumentList( - SingletonSeparatedList( - Argument( - CastExpression( - ParseTypeName("System.IntPtr"), - IdentifierName(nativeIdentifier))))))); - - if (info.IsByRef && info.RefKind != RefKind.In) - { - yield return freeCoTaskMem; - } - else - { - // if () - // { - // Marshal.FreeCoTaskMem((IntPtr)) - // } - yield return IfStatement( - IdentifierName(usedCoTaskMemIdentifier), - Block(freeCoTaskMem)); - } + yield return GenerateConditionalAllocationFreeSyntax(info ,context); break; } } - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + + protected override ExpressionSyntax GenerateAllocationExpression( + TypePositionInfo info, + StubCodeContext context, + SyntaxToken byteLengthIdentifier, + out bool allocationRequiresByteLength) + { + allocationRequiresByteLength = false; + // (byte*)Marshal.StringToCoTaskMemUni() + return CastExpression( + AsNativeType(info), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("StringToCoTaskMemUni")), + ArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(context.GetIdentifiers(info).managed)))))); + } + + protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) + { + // +1 for null terminator + // *2 for number of bytes per char + // int = (.Length + 1) * 2; + return + BinaryExpression( + SyntaxKind.MultiplyExpression, + BinaryExpression( + SyntaxKind.AddExpression, + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(context.GetIdentifiers(info).managed), + IdentifierName("Length")), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(2))); + } + + protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( + TypePositionInfo info, + StubCodeContext context, + SyntaxToken byteLengthIdentifier, + SyntaxToken stackAllocPtrIdentifier) + { + // ((ReadOnlySpan)).CopyTo(new Span(, .Length + 1)); + return + ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParenthesizedExpression( + CastExpression( + GenericName(Identifier("System.ReadOnlySpan"), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.CharKeyword))))), + IdentifierName(context.GetIdentifiers(info).managed))), + IdentifierName("CopyTo")), + ArgumentList( + SeparatedList(new [] { + Argument( + ObjectCreationExpression( + GenericName(Identifier("System.Span"), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.CharKeyword))))), + ArgumentList( + SeparatedList(new []{ + Argument(IdentifierName(stackAllocPtrIdentifier)), + Argument(IdentifierName(byteLengthIdentifier))})), + initializer: null))})))); + } + + protected override ExpressionSyntax GenerateFreeExpression( + TypePositionInfo info, + StubCodeContext context) + { + // Marshal.FreeCoTaskMem((IntPtr)) + return InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("FreeCoTaskMem")), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(context.GetIdentifiers(info).native)))))); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs index 7eee10d2b7f14..1b47d067f624c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs @@ -6,7 +6,7 @@ namespace Microsoft.Interop { - internal sealed class Utf8StringMarshaller : IMarshallingGenerator + internal sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator { // [Compat] Equivalent of MAX_PATH on Windows to match built-in system // The assumption is file paths are the most common case for marshalling strings, @@ -25,7 +25,7 @@ internal sealed class Utf8StringMarshaller : IMarshallingGenerator private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); private static readonly TypeSyntax UTF8EncodingType = ParseTypeName("System.Text.Encoding.UTF8"); - public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { string identifier = context.GetIdentifiers(info).native; if (info.IsByRef) @@ -39,9 +39,9 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) return Argument(IdentifierName(identifier)); } - public TypeSyntax AsNativeType(TypePositionInfo info) => NativeType; + public override TypeSyntax AsNativeType(TypePositionInfo info) => NativeType; - public ParameterSyntax AsParameter(TypePositionInfo info) + public override ParameterSyntax AsParameter(TypePositionInfo info) { var type = info.IsByRef ? PointerType(AsNativeType(info)) @@ -50,10 +50,9 @@ public ParameterSyntax AsParameter(TypePositionInfo info) .WithType(type); } - public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); - string usedCoTaskMemIdentifier = $"{managedIdentifier}__usedCoTaskMem"; switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: @@ -65,167 +64,12 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) { - // = (byte*)Marshal.StringToCoTaskMemUTF8(); - var coTaskMemAlloc = ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - CastExpression( - NativeType, - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("StringToCoTaskMemUTF8")), - ArgumentList( - SingletonSeparatedList( - Argument(IdentifierName(managedIdentifier)))))))); - if (info.IsByRef && info.RefKind != RefKind.In) - { - yield return coTaskMemAlloc; - } - else + foreach (var statement in GenerateConditionalAllocationSyntax( + info, + context, + StackAllocBytesThreshold)) { - // = false; - yield return LocalDeclarationStatement( - VariableDeclaration( - PredefinedType(Token(SyntaxKind.BoolKeyword)), - SingletonSeparatedList( - VariableDeclarator(usedCoTaskMemIdentifier) - .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); - - string stackAllocPtrIdentifier = $"{managedIdentifier}__stackalloc"; - string byteLenIdentifier = $"{managedIdentifier}__byteLen"; - - // Code block for stackalloc if string is below threshold size - var marshalOnStack = Block( - // byte* = stackalloc byte[]; - LocalDeclarationStatement( - VariableDeclaration( - PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))), - SingletonSeparatedList( - VariableDeclarator(stackAllocPtrIdentifier) - .WithInitializer(EqualsValueClause( - StackAllocArrayCreationExpression( - ArrayType( - PredefinedType(Token(SyntaxKind.ByteKeyword)), - SingletonList( - ArrayRankSpecifier(SingletonSeparatedList( - IdentifierName(byteLenIdentifier))))))))))), - // = Encoding.UTF8.GetBytes(, new Span(, )); - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(byteLenIdentifier), - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - UTF8EncodingType, - IdentifierName("GetBytes")), - ArgumentList( - SeparatedList(new ArgumentSyntax[] { - Argument(IdentifierName(managedIdentifier)), - Argument( - ObjectCreationExpression( - GenericName(Identifier("System.Span"), - TypeArgumentList(SingletonSeparatedList( - PredefinedType(Token(SyntaxKind.ByteKeyword))))), - ArgumentList( - SeparatedList(new ArgumentSyntax[]{ - Argument(IdentifierName(stackAllocPtrIdentifier)), - Argument(IdentifierName(byteLenIdentifier))})), - initializer: null))}))))), - // [] = 0; - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - ElementAccessExpression( - IdentifierName(stackAllocPtrIdentifier), - BracketedArgumentList( - SingletonSeparatedList( - Argument(IdentifierName(byteLenIdentifier))))), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))), - // = ; - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - CastExpression( - NativeType, - IdentifierName(stackAllocPtrIdentifier))))); - - // if ( == null) - // { - // = null; - // } - // else - // { - // // + 1 for number of characters in case left over high surrogate is ? - // // * (3 for UTF-8) - // // +1 for null terminator - // int = (.Length + 1) * 3 + 1; - // if ( > ) - // { - // = (byte*)Marshal.StringToCoTaskMemUTF8(); - // } - // else - // { - // byte* = stackalloc byte[]; - // = Encoding.UTF8.GetBytes(, new Span(, )); - // [] = 0; - // = (byte*); - // } - // } - yield return IfStatement( - BinaryExpression( - SyntaxKind.EqualsExpression, - IdentifierName(managedIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block( - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)))), - ElseClause( - Block( - // + 1 for number of characters in case left over high surrogate is ? - // * (3 for UTF-8) - // +1 for null terminator - // int = (.Length + 1) * 3 + 1; - LocalDeclarationStatement( - VariableDeclaration( - PredefinedType(Token(SyntaxKind.IntKeyword)), - SingletonSeparatedList( - VariableDeclarator(Identifier(byteLenIdentifier)) - .WithInitializer(EqualsValueClause( - BinaryExpression( - SyntaxKind.AddExpression, - BinaryExpression( - SyntaxKind.MultiplyExpression, - ParenthesizedExpression( - BinaryExpression( - SyntaxKind.AddExpression, - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifier), - IdentifierName("Length")), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(MaxByteCountPerChar))), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))))))), - IfStatement( - BinaryExpression( - SyntaxKind.GreaterThanExpression, - IdentifierName(byteLenIdentifier), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(StackAllocBytesThreshold))), - Block( - coTaskMemAlloc, - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(usedCoTaskMemIdentifier), - LiteralExpression(SyntaxKind.TrueLiteralExpression)))), - ElseClause(marshalOnStack))))); + yield return statement; } } break; @@ -250,38 +94,112 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } break; case StubCodeContext.Stage.Cleanup: - // Marshal.FreeCoTaskMem((IntPtr)) - var freeCoTaskMem = ExpressionStatement( - InvocationExpression( + yield return GenerateConditionalAllocationFreeSyntax(info, context); + break; + } + } + + public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + + protected override ExpressionSyntax GenerateAllocationExpression( + TypePositionInfo info, + StubCodeContext context, + SyntaxToken byteLengthIdentifier, + out bool allocationRequiresByteLength) + { + allocationRequiresByteLength = false; + // (byte*)Marshal.StringToCoTaskMemUTF8() + return CastExpression( + AsNativeType(info), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("StringToCoTaskMemUTF8")), + ArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(context.GetIdentifiers(info).managed)))))); + } + + protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) + { + // + 1 for number of characters in case left over high surrogate is ? + // * (3 for UTF-8) + // +1 for null terminator + // int = (.Length + 1) * 3 + 1; + return BinaryExpression( + SyntaxKind.AddExpression, + BinaryExpression( + SyntaxKind.MultiplyExpression, + ParenthesizedExpression( + BinaryExpression( + SyntaxKind.AddExpression, MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("FreeCoTaskMem")), - ArgumentList(SingletonSeparatedList( - Argument( - CastExpression( - ParseTypeName("System.IntPtr"), - IdentifierName(nativeIdentifier))))))); - - if (info.IsByRef && info.RefKind != RefKind.In) - { - yield return freeCoTaskMem; - } - else - { - // if () - // { - // Marshal.FreeCoTaskMem((IntPtr)) - // } - yield return IfStatement( - IdentifierName(usedCoTaskMemIdentifier), - Block(freeCoTaskMem)); - } + IdentifierName(context.GetIdentifiers(info).managed), + IdentifierName("Length")), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(MaxByteCountPerChar))), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))); + } - break; - } + protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( + TypePositionInfo info, + StubCodeContext context, + SyntaxToken byteLengthIdentifier, + SyntaxToken stackAllocPtrIdentifier) + { + return Block( + // = Encoding.UTF8.GetBytes(, new Span(, )); + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(byteLengthIdentifier), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + UTF8EncodingType, + IdentifierName("GetBytes")), + ArgumentList( + SeparatedList(new ArgumentSyntax[] { + Argument(IdentifierName(context.GetIdentifiers(info).managed)), + Argument( + ObjectCreationExpression( + GenericName(Identifier("System.Span"), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.ByteKeyword))))), + ArgumentList( + SeparatedList(new ArgumentSyntax[]{ + Argument(IdentifierName(stackAllocPtrIdentifier)), + Argument(IdentifierName(byteLengthIdentifier))})), + initializer: null))}))))), + // [] = 0; + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + ElementAccessExpression( + IdentifierName(stackAllocPtrIdentifier), + BracketedArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(byteLengthIdentifier))))), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))); } - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + protected override ExpressionSyntax GenerateFreeExpression( + TypePositionInfo info, + StubCodeContext context) + { + // Marshal.FreeCoTaskMem((IntPtr)) + return InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("FreeCoTaskMem")), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(context.GetIdentifiers(info).native)))))); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index c44695265771a..2db9549800e0e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -41,14 +41,41 @@ CharEncoding CharEncoding ) : MarshallingInfo; /// - /// User-applied System.Runtime.InteropServices.MarshalAsAttribute + /// Simple User-application of System.Runtime.InteropServices.MarshalAsAttribute /// - internal sealed record MarshalAsInfo( + internal record MarshalAsInfo( UnmanagedType UnmanagedType, + CharEncoding CharEncoding) : MarshallingInfoStringSupport(CharEncoding) + { + } + + enum UnmanagedArrayType + { + LPArray = UnmanagedType.LPArray, + ByValArray = UnmanagedType.ByValArray + } + + /// + /// User-applied System.Runtime.InteropServices.MarshalAsAttribute with array marshalling info + /// + internal sealed record ArrayMarshalAsInfo( + UnmanagedArrayType UnmanagedArrayType, UnmanagedType UnmanagedArraySubType, int ArraySizeConst, short ArraySizeParamIndex, - CharEncoding CharEncoding) : MarshallingInfoStringSupport(CharEncoding); + CharEncoding CharEncoding) : MarshalAsInfo((UnmanagedType)UnmanagedArrayType, CharEncoding) + { + public MarshallingInfo CreateArraySubTypeMarshalAsInfo() + { + if (UnmanagedArraySubType == (UnmanagedType)UnspecifiedData) + { + return NoMarshallingInfo.Instance; + } + return new MarshalAsInfo(UnmanagedArraySubType, CharEncoding); + } + + public const short UnspecifiedData = -1; + } /// /// User-applied System.Runtime.InteropServices.BlittableTypeAttribute 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 ecae163a53a4d..40e8ebd70f4a7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -60,6 +60,33 @@ internal Resources() { } } + /// + /// Looks up a localized string similar to {0} Marshalling the array parameter '{1}' from unmanaged to managed requires either the SizeParamIndex or SizeConst fields to be set on a MarshalAs attribute.. + /// + internal static string ArraySizeMustBeSpecified { + get { + return ResourceManager.GetString("ArraySizeMustBeSpecified", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} The SizeParamIndex value in the MarshalAs attribute on '{1}' is out of range.. + /// + internal static string ArraySizeParamIndexOutOfRange { + get { + return ResourceManager.GetString("ArraySizeParamIndexOutOfRange", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} The specified array size parameter for the array '{1}' must be an integer type.. + /// + internal static string ArraySizeParamTypeMustBeIntegral { + get { + return ResourceManager.GetString("ArraySizeParamTypeMustBeIntegral", resourceCulture); + } + } + /// /// Looks up a localized string similar to A type marked with 'BlittableTypeAttribute' must be blittable.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index bf7b4e58a3c87..1475b4bfbb6e6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -117,6 +117,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + {0} Marshalling the array parameter '{1}' from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a MarshalAs attribute. + + + {0} The 'SizeParamIndex' value in the 'MarshalAsAttribute' attribute on '{1}' is out of range. + + + {0} The specified array size parameter for the array '{1}' must be an integer type. + A type marked with 'BlittableTypeAttribute' must be blittable. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index b3618c898bfc9..ea84f868b16a6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -66,6 +66,8 @@ public enum Stage public abstract bool StackSpaceUsable { get; } + public abstract bool CanUseAdditionalTemporaryState { get; } + protected const string GeneratedNativeIdentifierSuffix = "_gen_native"; /// @@ -77,5 +79,7 @@ public virtual (string managed, string native) GetIdentifiers(TypePositionInfo i { return (info.InstanceIdentifier, $"__{info.InstanceIdentifier}{GeneratedNativeIdentifierSuffix}"); } + + public abstract TypePositionInfo? GetTypePositionInfoForManagedIndex(int index); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 9d5c2763200fe..aaa893dad2dd2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -16,6 +16,8 @@ internal sealed class StubCodeGenerator : StubCodeContext public override bool StackSpaceUsable => true; + public override bool CanUseAdditionalTemporaryState => true; + /// /// Identifier for managed return value /// @@ -44,6 +46,7 @@ internal sealed class StubCodeGenerator : StubCodeContext private readonly GeneratorDiagnostics diagnostics; private readonly IMethodSymbol stubMethod; + private readonly IEnumerable paramsTypeInfo; private readonly List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> paramMarshallers; private readonly (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) retMarshaller; @@ -56,6 +59,7 @@ public StubCodeGenerator( Debug.Assert(retTypeInfo.IsNativeReturnPosition); this.stubMethod = stubMethod; + this.paramsTypeInfo = paramsTypeInfo.ToList(); this.diagnostics = generatorDiagnostics; // Get marshallers for parameters @@ -267,5 +271,17 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo return (codeBlock, dllImport); } + + public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) + { + foreach (var info in paramsTypeInfo) + { + if (info.ManagedIndex == index) + { + return info; + } + } + return null; + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index ec347dc44c789..44a1f163d07e9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -16,7 +16,8 @@ static class TypeNames public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute"; - public const string System_Span = "System.Span`1"; + public const string System_Span_Metadata = "System.Span`1"; + public const string System_Span = "System.Span"; public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; @@ -25,6 +26,8 @@ static class TypeNames public const string System_Runtime_InteropServices_Marshal = "System.Runtime.InteropServices.Marshal"; public const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; + + public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal"; public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index b92813214e663..f38a30bb9afd6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -19,7 +19,7 @@ CharEncoding CharEncoding /// /// Positional type information involved in unmanaged/managed scenarios. /// - internal sealed class TypePositionInfo + internal sealed record TypePositionInfo { public const int UnsetIndex = int.MinValue; public const int ReturnIndex = UnsetIndex + 1; @@ -36,22 +36,22 @@ private TypePositionInfo() } #pragma warning restore - public string InstanceIdentifier { get; private set; } - public ITypeSymbol ManagedType { get; private set; } + public string InstanceIdentifier { get; init; } + public ITypeSymbol ManagedType { get; init; } - public RefKind RefKind { get; private set; } - public SyntaxKind RefKindSyntax { get; private set; } + public RefKind RefKind { get; init; } + public SyntaxKind RefKindSyntax { get; init; } public bool IsByRef => RefKind != RefKind.None; public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } public bool IsNativeReturnPosition { get => this.NativeIndex == ReturnIndex; } - public int ManagedIndex { get; set; } - public int NativeIndex { get; set; } - public int UnmanagedLCIDConversionArgIndex { get; private set; } + public int ManagedIndex { get; init; } + public int NativeIndex { get; init; } + public int UnmanagedLCIDConversionArgIndex { get; init; } - public MarshallingInfo MarshallingAttributeInfo { get; private set; } + public MarshallingInfo MarshallingAttributeInfo { get; init; } public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { @@ -83,6 +83,20 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { // Look at attributes passed in - usage specific. @@ -146,13 +160,15 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData, DefaultMarshall ? (UnmanagedType)(short)unmanagedTypeObj : (UnmanagedType)unmanagedTypeObj; if (!Enum.IsDefined(typeof(UnmanagedType), unmanagedType) - || unmanagedType == UnmanagedType.CustomMarshaler) + || unmanagedType == UnmanagedType.CustomMarshaler + || unmanagedType == UnmanagedType.SafeArray) { diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); } - UnmanagedType unmanagedArraySubType = 0; - int arraySizeConst = 0; - short arraySizeParamIndex = 0; + bool isArrayType = unmanagedType == UnmanagedType.LPArray || unmanagedType == UnmanagedType.ByValArray; + UnmanagedType unmanagedArraySubType = (UnmanagedType)ArrayMarshalAsInfo.UnspecifiedData; + int arraySizeConst = ArrayMarshalAsInfo.UnspecifiedData; + short arraySizeParamIndex = ArrayMarshalAsInfo.UnspecifiedData; // All other data on attribute is defined as NamedArguments. foreach (var namedArg in attrData.NamedArguments) @@ -171,29 +187,43 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData, DefaultMarshall diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); break; case nameof(MarshalAsAttribute.ArraySubType): + if (!isArrayType) + { + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + } unmanagedArraySubType = (UnmanagedType)namedArg.Value.Value!; break; case nameof(MarshalAsAttribute.SizeConst): + if (!isArrayType) + { + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + } arraySizeConst = (int)namedArg.Value.Value!; break; case nameof(MarshalAsAttribute.SizeParamIndex): + if (!isArrayType) + { + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + } arraySizeParamIndex = (short)namedArg.Value.Value!; break; } } - return new MarshalAsInfo( - UnmanagedType: unmanagedType, - UnmanagedArraySubType: unmanagedArraySubType, - ArraySizeConst: arraySizeConst, - ArraySizeParamIndex: arraySizeParamIndex, - CharEncoding: defaultInfo.CharEncoding - ); + return isArrayType + ? new ArrayMarshalAsInfo( + UnmanagedArrayType: (UnmanagedArrayType)unmanagedType, + UnmanagedArraySubType: unmanagedArraySubType, + ArraySizeConst: arraySizeConst, + ArraySizeParamIndex: arraySizeParamIndex, + CharEncoding: defaultInfo.CharEncoding + ) + : new MarshalAsInfo(unmanagedType, defaultInfo.CharEncoding); } static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol type, Compilation compilation, AttributeData attrData, bool allowGetPinnableReference) { - ITypeSymbol spanOfByte = compilation.GetTypeByMetadataName(TypeNames.System_Span)!.Construct(compilation.GetSpecialType(SpecialType.System_Byte)); + ITypeSymbol spanOfByte = compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(compilation.GetSpecialType(SpecialType.System_Byte)); INamedTypeSymbol nativeType = (INamedTypeSymbol)attrData.ConstructorArguments[0].Value!; SupportedMarshallingMethods methods = 0; IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 753ffc636ca0c..3539cefbadc72 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -132,5 +132,23 @@ public static TypeSyntax AsTypeSyntax(this ITypeSymbol type) { return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); } + + public static bool IsIntegralType(this ITypeSymbol type) + { + return type.SpecialType switch + { + SpecialType.System_SByte + or SpecialType.System_Byte + or SpecialType.System_Int16 + or SpecialType.System_UInt16 + or SpecialType.System_Int32 + or SpecialType.System_UInt32 + or SpecialType.System_Int64 + or SpecialType.System_UInt64 + or SpecialType.System_IntPtr + or SpecialType.System_UIntPtr => true, + _ => false + }; + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index f1f9b1160ae4a..cf52693a97f46 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -38,6 +38,16 @@ In the built-in system, marshalling a `string` contains an optimization for para Using a custom marshaller (i.e. [`ICustomMarshaler`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.icustommarshaler)) with the `UnmanagedType.CustomMarshaler` value on `MarshalAsAttribute` is not supported. This also implies `MarshalAsAttribute` fields: [`MarshalTypeRef`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltyperef), [`MarshalType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltype), and [`MarshalCookie`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshalcookie) are unsupported. +### Array marshaller support + +Marshalling of arrays will not be supported when using [`UnmangedType.SafeArray`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.unmanagedtype). This implies that the following `MarshalAsAttribute` fields are unsupported: [`SafeArraySubType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.safearraysubtype) and [`SafeArrayUserDefinedSubType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.safearrayuserdefinedsubtype) + +Specifying array-specific marshalling members on the `MarshalAsAttribute` such as [`SizeConst`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.sizeconst), [`ArraySubType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.arraysubtype), and [`SizeParamIndex`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.sizeparamindex) with non-array `UnmanagedType` types is unsupported. + +Only single-dimensional arrays are supported for source generated marshalling. + +In the source-generated marshalling, arrays will be allocated on the stack (instead of through [`AllocCoTaskMem`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.alloccotaskmem)) if they are passed by value or by read-only reference if they contain at most 256 bytes of data. The built-in system does not support this optimization for arrays. + ## Verison 0 This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md index d34be0159c250..bba8c946a85d2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -48,6 +48,37 @@ Generation of the stub code happens in stages. The marshalling generator for eac 1. `Cleanup`: free any allocated resources - Call `Generate` on the marshalling generator for every parameter +### Stub conditional features + +Some marshalling optimizations are only available in specific scenarios. Generally, there are 4 basic marshalling contexts: + +- P/Invoke +- Reverse P/Invoke +- User-defined structure marshalling +- Non-blittable array marshalling + +This experiment generally is currently only focusing on two of the concepts: P/Invoke and non-blittable array marshalling (in the context of a P/Invoke). + +There are three categories for specialized marshalling features that may only be available in some contexts: + +- Pinning to marshal data without copying (the `fixed` statement) +- Stack allocation across the native context (using the `stackalloc` keyword or https://github.com/dotnet/runtime/issues/25423) +- Storing additional temporary state in extra local variables + +Support for these features is indicated in code by various `bool` properties on the `StubCodeContext`-derived type. + +These various scenarios have different levels of support for these three features: + + +| Scenarios |Pinning | Stack allocation across the native context | Storing additional temporary state in locals | +|------|-----|-----|---------| +| P/Invoke | supported | supported | supported | +| Reverse P/Invoke | unsupported | unsupported | supported | +| User-defined structures | unsupported | unsupported for individual members | unsupported | +| non-blittable array marshalling in a P/Invoke | unsupported | unsupported (supportable with https://github.com/dotnet/runtime/issues/25423) | unuspported | +| non-blittable array marshalling not in a P/Invoke | unsupported | unsupported | unuspported | + + ### P/Invoke The P/Invoke called by the stub is created based on the user's original declaration of the stub. The signature is generated using the syntax returned by `AsNativeType` and `AsParameter` of the marshalling generators for the return and parameters. \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs new file mode 100644 index 0000000000000..14874d436432c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public partial class Arrays + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_int_array")] + public static partial int Sum(int[] values, int numValues); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_int_array_ref")] + public static partial int SumInArray(in int[] values, int numValues); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "duplicate_int_array")] + public static partial void Duplicate([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ref int[] values, int numValues); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "create_range_array")] + [return:MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + public static partial int[] CreateRange(int start, int end, out int numValues); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_string_lengths")] + public static partial int SumStringLengths([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_strings")] + public static partial void ReverseStrings([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] ref string[] strArray, out int numElements); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "get_long_bytes")] + [return:MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(long))] + public static partial byte[] GetLongBytes(long l); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "append_int_to_array")] + public static partial void Append([MarshalAs(UnmanagedType.LPArray, SizeConst = 1, SizeParamIndex = 1)] ref int[] values, int numOriginalValues, int newValue); + } + } + + public class ArrayTests + { + [Fact] + public void IntArrayMarshalledToNativeAsExpected() + { + var array = new [] { 1, 5, 79, 165, 32, 3 }; + Assert.Equal(array.Sum(), NativeExportsNE.Arrays.Sum(array, array.Length)); + } + + [Fact] + public void ZeroLengthArrayMarshalledAsNonNull() + { + var array = new int[0]; + Assert.Equal(0, NativeExportsNE.Arrays.Sum(array, array.Length)); + } + + [Fact] + public void IntArrayInParameter() + { + var array = new[] { 1, 5, 79, 165, 32, 3 }; + Assert.Equal(array.Sum(), NativeExportsNE.Arrays.SumInArray(array, array.Length)); + } + + [Fact] + public void IntArrayRefParameter() + { + var array = new [] { 1, 5, 79, 165, 32, 3 }; + var newArray = array; + NativeExportsNE.Arrays.Duplicate(ref newArray, array.Length); + Assert.Equal((IEnumerable)array, newArray); + } + + [Fact] + public void ArraysReturnedFromNative() + { + int start = 5; + + int end = 20; + + Assert.Equal(Enumerable.Range(start, end - start), NativeExportsNE.Arrays.CreateRange(start, end, out _)); + } + + [Fact] + public void NullArrayReturnedFromNative() + { + Assert.Null(NativeExportsNE.Arrays.CreateRange(1, 0, out _)); + } + + private static string[] GetStringArray() + { + return new [] + { + "ABCdef 123$%^", + "🍜 !! 🍜 !!", + "🌲 木 🔥 火 🌾 土 🛡 金 🌊 水" , + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae posuere mauris, sed ultrices leo. Suspendisse potenti. Mauris enim enim, blandit tincidunt consequat in, varius sit amet neque. Morbi eget porttitor ex. Duis mattis aliquet ante quis imperdiet. Duis sit.", + string.Empty, + null + }; + } + + [Fact] + public void ByValueArrayWithElementMarshalling() + { + var strings = GetStringArray(); + Assert.Equal(strings.Sum(str => str?.Length ?? 0), NativeExportsNE.Arrays.SumStringLengths(strings)); + } + + [Fact] + public void ByValueNullArrayWithElementMarshalling() + { + Assert.Equal(0, NativeExportsNE.Arrays.SumStringLengths(null)); + } + + [Fact] + public void ByRefArrayWithElementMarshalling() + { + var strings = GetStringArray(); + var expectedStrings = strings.Select(s => ReverseChars(s)).ToArray(); + NativeExportsNE.Arrays.ReverseStrings(ref strings, out _); + + Assert.Equal((IEnumerable)expectedStrings, strings); + } + + [Fact] + public void ByRefNullArrayWithElementMarshalling() + { + string[] strings = null; + NativeExportsNE.Arrays.ReverseStrings(ref strings, out _); + + Assert.Null(strings); + } + + [Fact] + public void ConstantSizeArray() + { + var longVal = 0x12345678ABCDEF10L; + + Assert.Equal(longVal, MemoryMarshal.Read(NativeExportsNE.Arrays.GetLongBytes(longVal))); + } + + [Fact] + public void DynamicSizedArrayWithConstantComponent() + { + var array = new [] { 1, 5, 79, 165, 32, 3 }; + int newValue = 42; + var newArray = array; + NativeExportsNE.Arrays.Append(ref newArray, array.Length, newValue); + Assert.Equal(array.Concat(new [] { newValue }), newArray); + } + + private static string ReverseChars(string value) + { + if (value == null) + return null; + + var chars = value.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + } +} 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 1b083d66be9f2..9acc2c7f19223 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -402,5 +402,49 @@ struct MyStruct private T t; private short s; }"; + + public static string ArrayParametersAndModifiers(string elementType) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + [return:MarshalAs(UnmanagedType.LPArray, SizeConst=10)] + public static partial {elementType}[] Method( + {elementType}[] p, + in {elementType}[] pIn, + int pRefSize, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] ref {elementType}[] pRef, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=5, SizeConst=4)] out {elementType}[] pOut, + out int pOutSize + ); +}}"; + + public static string ArrayParametersAndModifiers() => ArrayParametersAndModifiers(typeof(T).ToString()); + + public static string ArrayParameterWithSizeParam(string sizeParamType, bool isByRef) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + {(isByRef ? "ref" : "")} {sizeParamType} pRefSize, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] ref int[] pRef + ); +}}"; + + public static string ArrayParameterWithSizeParam(bool isByRef) => ArrayParameterWithSizeParam(typeof(T).ToString(), isByRef); + + + public static string ArrayParameterWithNestedMarshalInfo(string elementType, UnmanagedType nestedMarshalInfo) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.{nestedMarshalInfo})] {elementType}[] pRef + ); +}}"; + + public static string ArrayParameterWithNestedMarshalInfo(UnmanagedType nestedMarshalType) => ArrayParameterWithNestedMarshalInfo(typeof(T).ToString(), nestedMarshalType); } } 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 6c85c6c3d8be7..7fdb0ffcfb51d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -30,6 +30,7 @@ public static IEnumerable CodeSnippetsToCompile() // Unsupported UnmanagedType yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1), 5, 0 }; yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.U1), 5, 0 }; + yield return new object[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.SafeArray), 10, 0 }; // Unsupported MarshalAsAttribute usage // * UnmanagedType.CustomMarshaler, MarshalTypeRef, MarshalType, MarshalCookie 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 a42501a3ab169..5e1dc98cd807e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -33,21 +33,39 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - //yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode) }; yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode) }; //yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi) }; @@ -61,6 +79,8 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPTStr) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPUTF8Str) }; //yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; + yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPWStr) }; + yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPUTF8Str) }; //yield return new[] { CodeSnippets.EnumParameters }; yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -115,11 +135,16 @@ public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi) }; yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; + yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; yield return new[] { CodeSnippets.EnumParameters }; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs new file mode 100644 index 0000000000000..97d09ef53e663 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class Arrays + { + [UnmanagedCallersOnly(EntryPoint = "sum_int_array")] + public static int Sum(int* values, int numValues) + { + if (values == null) + { + return -1; + } + + int sum = 0; + for (int i = 0; i < numValues; i++) + { + sum += values[i]; + } + return sum; + } + + [UnmanagedCallersOnly(EntryPoint = "sum_int_array_ref")] + public static int SumInArray(int** values, int numValues) + { + if (*values == null) + { + return -1; + } + + int sum = 0; + for (int i = 0; i < numValues; i++) + { + sum += (*values)[i]; + } + return sum; + } + + [UnmanagedCallersOnly(EntryPoint = "duplicate_int_array")] + public static void Duplicate(int** values, int numValues) + { + int* newArray = (int*)Marshal.AllocCoTaskMem(sizeof(int) * numValues); + new Span(*values, numValues).CopyTo(new Span(newArray, numValues)); + Marshal.FreeCoTaskMem((IntPtr)(*values)); + *values = newArray; + } + + [UnmanagedCallersOnly(EntryPoint = "create_range_array")] + public static int* CreateRange(int start, int end, int* numValues) + { + if (start >= end) + { + *numValues = 0; + return null; + } + + *numValues = end - start; + + int* retVal = (int*)Marshal.AllocCoTaskMem(sizeof(int) * (*numValues)); + for (int i = start; i < end; i++) + { + retVal[i - start] = i; + } + + return retVal; + } + + [UnmanagedCallersOnly(EntryPoint = "sum_string_lengths")] + public static int SumStringLengths(ushort** strArray) + { + if (strArray == null) + { + return 0; + } + int length = 0; + for (int i = 0; (nint)strArray[i] != 0; i++) + { + length += new string((char*)strArray[i]).Length; + } + return length; + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_strings")] + public static void ReverseStrings(ushort*** strArray, int* numValues) + { + if (*strArray == null) + { + *numValues = 0; + return; + } + List newStrings = new List(); + for (int i = 0; (nint)(*strArray)[i] != 0; i++) + { + newStrings.Add((IntPtr)Strings.Reverse((*strArray)[i])); + } + newStrings.Add(IntPtr.Zero); + Marshal.FreeCoTaskMem((IntPtr)(*strArray)); + *strArray = (ushort**)Marshal.AllocCoTaskMem(sizeof(ushort*) * newStrings.Count); + CollectionsMarshal.AsSpan(newStrings).CopyTo(new Span((IntPtr*)(*strArray), newStrings.Count)); + *numValues = newStrings.Count; + } + + [UnmanagedCallersOnly(EntryPoint = "get_long_bytes")] + public static byte* GetLongBytes(long l) + { + const int NumBytesInLong = sizeof(long); + + byte* bytes = (byte*)Marshal.AllocCoTaskMem(NumBytesInLong); + MemoryMarshal.Write(new Span(bytes, NumBytesInLong), ref l); + return bytes; + } + + [UnmanagedCallersOnly(EntryPoint = "append_int_to_array")] + public static void Append(int** values, int numOriginalValues, int newValue) + { + int* newArray = (int*)Marshal.AllocCoTaskMem(sizeof(int) * (numOriginalValues + 1)); + new Span(*values, numOriginalValues).CopyTo(new Span(newArray, numOriginalValues)); + newArray[numOriginalValues] = newValue; + *values = newArray; + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs index ac5fa7d9ac5bd..44458182ce311 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs @@ -88,7 +88,7 @@ public static void ReverseReplaceRefByte(byte** s) *s = ret; } - private static ushort* Reverse(ushort *s) + internal static ushort* Reverse(ushort *s) { if (s == null) return null; @@ -103,7 +103,7 @@ public static void ReverseReplaceRefByte(byte** s) return ret; } - private static byte* Reverse(byte* s) + internal static byte* Reverse(byte* s) { if (s == null) return null; From d746fcb99a936c49dc13eea707fdd23f491519e3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 2 Nov 2020 22:38:25 -0800 Subject: [PATCH 040/161] Fix byte length calculation for UTF-16 strings (dotnet/runtimelab#285) Commit migrated from https://github.com/dotnet/runtimelab/commit/a3579c09d520c44eda899847860c5e1a476cbc32 --- .../Marshalling/StringMarshaller.Utf16.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs index 3d367c030119e..bca31969fba42 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -160,13 +160,14 @@ protected override ExpressionSyntax GenerateByteLengthCalculationExpression(Type return BinaryExpression( SyntaxKind.MultiplyExpression, - BinaryExpression( - SyntaxKind.AddExpression, - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(context.GetIdentifiers(info).managed), - IdentifierName("Length")), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))), + ParenthesizedExpression( + BinaryExpression( + SyntaxKind.AddExpression, + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(context.GetIdentifiers(info).managed), + IdentifierName("Length")), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))), LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(2))); } From 01a1930a82bd62b3ff3702c6e483ae426204d5e3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 4 Nov 2020 16:03:09 -0800 Subject: [PATCH 041/161] Add string marshallers for ANSI and platform-defined (dotnet/runtimelab#288) * Update to latest version of analyzer test package * Add string marshaller for CharSet.Ansi * Add string marshaller for CharSet.Auto * Update compatibility doc Commit migrated from https://github.com/dotnet/runtimelab/commit/ebbd0b2672c13861a2d53a2e7cd8676d67b680e7 --- .../Marshalling/BlittableArrayMarshaller.cs | 4 + ...nditionalStackallocMarshallingGenerator.cs | 43 ++- .../Marshalling/MarshallerHelpers.cs | 51 +++ .../Marshalling/MarshallingGenerator.cs | 10 + .../NonBlittableArrayMarshaller.cs | 4 + .../Marshalling/StringMarshaller.Ansi.cs | 168 ++++++++ .../StringMarshaller.PlatformDefined.cs | 181 +++++++++ .../Marshalling/StringMarshaller.Utf16.cs | 41 +- .../Marshalling/StringMarshaller.Utf8.cs | 29 +- .../DllImportGenerator/Compatibility.md | 8 +- .../DllImportGenerator.Tests/StringTests.cs | 359 ++++++++++++++++-- .../DllImportGenerator.UnitTests/Compiles.cs | 15 +- .../Diagnostics.cs | 2 +- .../DllImportGenerator.UnitTests.csproj | 2 +- .../DllImportGenerator.UnitTests/TestUtils.cs | 2 +- 15 files changed, 820 insertions(+), 99 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs index b1d12ef346944..a5839a8a0089f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs @@ -83,6 +83,10 @@ public override IEnumerable Generate(TypePositionInfo info, Stu VariableDeclaration( AsNativeType(info), SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + + if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) + yield return conditionalAllocSetup; + break; case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs index a17c763d75c10..7250c4f8e8cea 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -8,12 +8,39 @@ namespace Microsoft.Interop { internal abstract class ConditionalStackallocMarshallingGenerator : IMarshallingGenerator { - private static string GetAllocationMarkerIdentifier(string managedIdentifier) => $"{managedIdentifier}__allocated"; + protected static string GetAllocationMarkerIdentifier(string managedIdentifier) => $"{managedIdentifier}__allocated"; private static string GetByteLengthIdentifier(string managedIdentifier) => $"{managedIdentifier}__bytelen"; private static string GetStackAllocIdentifier(string managedIdentifier) => $"{managedIdentifier}__stackptr"; + protected bool UsesConditionalStackAlloc(TypePositionInfo info, StubCodeContext context) + { + return context.CanUseAdditionalTemporaryState + && context.StackSpaceUsable + && (!info.IsByRef || info.RefKind == RefKind.In) + && !info.IsManagedReturnPosition; + } + + protected bool TryGenerateSetupSyntax(TypePositionInfo info, StubCodeContext context, out StatementSyntax statement) + { + statement = EmptyStatement(); + + if (!UsesConditionalStackAlloc(info, context)) + return false; + + string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(context.GetIdentifiers(info).managed); + + // bool = false; + statement = LocalDeclarationStatement( + VariableDeclaration( + PredefinedType(Token(SyntaxKind.BoolKeyword)), + SingletonSeparatedList( + VariableDeclarator(allocationMarkerIdentifier) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); + return true; + } + protected IEnumerable GenerateConditionalAllocationSyntax( TypePositionInfo info, StubCodeContext context, @@ -39,8 +66,8 @@ protected IEnumerable GenerateConditionalAllocationSyntax( VariableDeclarator(byteLenIdentifier) .WithInitializer(EqualsValueClause( GenerateByteLengthCalculationExpression(info, context)))))); - - if (!context.CanUseAdditionalTemporaryState || !context.StackSpaceUsable || (info.IsByRef && info.RefKind != RefKind.In)) + + if (!UsesConditionalStackAlloc(info, context)) { List statements = new List(); if (allocationRequiresByteLength) @@ -58,13 +85,6 @@ protected IEnumerable GenerateConditionalAllocationSyntax( Block(statements)); yield break; } - // = false; - yield return LocalDeclarationStatement( - VariableDeclaration( - PredefinedType(Token(SyntaxKind.BoolKeyword)), - SingletonSeparatedList( - VariableDeclarator(allocationMarkerIdentifier) - .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); // Code block for stackalloc if number of bytes is below threshold size var marshalOnStack = Block( @@ -94,6 +114,7 @@ protected IEnumerable GenerateConditionalAllocationSyntax( // if ( > ) // { // ; + // = true; // } // else // { @@ -135,7 +156,7 @@ protected StatementSyntax GenerateConditionalAllocationFreeSyntax( { (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(managedIdentifier); - if (!context.CanUseAdditionalTemporaryState || (info.IsByRef && info.RefKind != RefKind.In)) + if (!UsesConditionalStackAlloc(info, context)) { return ExpressionStatement(GenerateFreeExpression(info, context)); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs index e461f5e964bde..58b225760f805 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs @@ -9,6 +9,14 @@ namespace Microsoft.Interop { internal static class MarshallerHelpers { + public static readonly ExpressionSyntax IsWindows = InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName("System.OperatingSystem"), + IdentifierName("IsWindows"))); + + public static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); + public static ForStatementSyntax GetForLoop(string collectionIdentifier, string indexerIdentifier) { // for(int = 0; < .Length; ++) @@ -41,5 +49,48 @@ public static ForStatementSyntax GetForLoop(string collectionIdentifier, string SyntaxKind.PreIncrementExpression, IdentifierName(indexerIdentifier)))); } + + public static class StringMarshaller + { + public static ExpressionSyntax AllocationExpression(CharEncoding encoding, string managedIdentifier) + { + string methodName = encoding switch + { + CharEncoding.Utf8 => "StringToCoTaskMemUTF8", + CharEncoding.Utf16 => "StringToCoTaskMemUni", + CharEncoding.Ansi => "StringToCoTaskMemAnsi", + _ => throw new System.ArgumentOutOfRangeException(nameof(encoding)) + }; + + // Marshal.StringToCoTaskMemUTF8() + // or + // Marshal.StringToCoTaskMemUni() + // or + // Marshal.StringToCoTaskMemAnsi() + return InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName(methodName)), + ArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(managedIdentifier))))); + } + + public static ExpressionSyntax FreeExpression(string nativeIdentifier) + { + // Marshal.FreeCoTaskMem((IntPtr)) + return InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InteropServicesMarshalType, + IdentifierName("FreeCoTaskMem")), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + ParseTypeName("System.IntPtr"), + IdentifierName(nativeIdentifier)))))); + } + } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 04769a24bc291..66ff34681e888 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -99,9 +99,13 @@ internal class MarshallingGenerators public static readonly ByteBoolMarshaller ByteBool = new ByteBoolMarshaller(); public static readonly WinBoolMarshaller WinBool = new WinBoolMarshaller(); public static readonly VariantBoolMarshaller VariantBool = new VariantBoolMarshaller(); + public static readonly Utf16CharMarshaller Utf16Char = new Utf16CharMarshaller(); public static readonly Utf16StringMarshaller Utf16String = new Utf16StringMarshaller(); public static readonly Utf8StringMarshaller Utf8String = new Utf8StringMarshaller(); + public static readonly AnsiStringMarshaller AnsiString = new AnsiStringMarshaller(Utf8String); + public static readonly PlatformDefinedStringMarshaller PlatformDefinedString = new PlatformDefinedStringMarshaller(Utf16String, Utf8String); + public static readonly Forwarder Forwarder = new Forwarder(); public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); @@ -259,6 +263,8 @@ private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo inf { switch (marshalAsInfo.UnmanagedType) { + case UnmanagedType.LPStr: + return AnsiString; case UnmanagedType.LPTStr: case UnmanagedType.LPWStr: return Utf16String; @@ -270,10 +276,14 @@ private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo inf { switch (marshalStringInfo.CharEncoding) { + case CharEncoding.Ansi: + return AnsiString; case CharEncoding.Utf16: return Utf16String; case CharEncoding.Utf8: return Utf8String; + case CharEncoding.PlatformDefined: + return PlatformDefinedString; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs index 4373601d5e6f4..b4966aa0dfe7a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs @@ -70,6 +70,10 @@ public override IEnumerable Generate(TypePositionInfo info, Stu VariableDeclaration( AsNativeType(info), SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + + if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) + yield return conditionalAllocSetup; + break; case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs new file mode 100644 index 0000000000000..7192bb545a2c2 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +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 +{ + internal sealed class AnsiStringMarshaller : ConditionalStackallocMarshallingGenerator + { + private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); + + private readonly Utf8StringMarshaller utf8StringMarshaller; + + public AnsiStringMarshaller(Utf8StringMarshaller utf8StringMarshaller) + { + this.utf8StringMarshaller = utf8StringMarshaller; + } + + public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + // & + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + // + return Argument(IdentifierName(identifier)); + } + + public override TypeSyntax AsNativeType(TypePositionInfo info) + { + // byte* + return NativeType; + } + + public override ParameterSyntax AsParameter(TypePositionInfo info) + { + // byte** + // or + // byte* + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + // byte* ; + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + + if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) + yield return conditionalAllocSetup; + + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + // = (byte*)Marshal.StringToCoTaskMemAnsi(); + var windowsBlock = Block( + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + CastExpression( + AsNativeType(info), + StringMarshaller.AllocationExpression(CharEncoding.Ansi, managedIdentifier))))); + + // Set the allocation marker to true if it is being used + if (UsesConditionalStackAlloc(info, context)) + { + // = true + windowsBlock.AddStatements( + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(GetAllocationMarkerIdentifier(managedIdentifier)), + LiteralExpression(SyntaxKind.TrueLiteralExpression)))); + } + + // [Compat] The generated source for ANSI string marshalling does not optimize for + // allocating on the stack based on the string length. It always uses AllocCoTaskMem. + // if (OperatingSystem.IsWindows()) + // { + // = (byte*)Marshal.StringToCoTaskMemAnsi(); + // } + // else + // { + // << marshal as UTF-8 >> + // } + yield return IfStatement(IsWindows, + windowsBlock, + ElseClause( + Block(this.utf8StringMarshaller.Generate(info, context)))); + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + // if (OperatingSystem.IsWindows()) + // { + // = == null ? null : new string((sbyte*)); + // } + // else + // { + // << unmarshal as UTF-8 >> + // } + yield return IfStatement(IsWindows, + Block( + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + ConditionalExpression( + BinaryExpression( + SyntaxKind.EqualsExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + LiteralExpression(SyntaxKind.NullLiteralExpression), + ObjectCreationExpression( + PredefinedType(Token(SyntaxKind.StringKeyword)), + ArgumentList(SingletonSeparatedList( + Argument( + CastExpression( + PointerType(PredefinedType(Token(SyntaxKind.SByteKeyword))), + IdentifierName(nativeIdentifier))))), + initializer: null))))), + ElseClause( + Block(this.utf8StringMarshaller.Generate(info, context)))); + } + break; + case StubCodeContext.Stage.Cleanup: + yield return GenerateConditionalAllocationFreeSyntax(info, context); + break; + } + } + + public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + + // This marshaller only uses the conditional allocaction base for setup and cleanup. + // It always allocates for ANSI (Windows) and relies on the UTF-8 (non-Windows) string marshaller 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); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs new file mode 100644 index 0000000000000..b4c74c647d34e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs @@ -0,0 +1,181 @@ +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 +{ + internal sealed class PlatformDefinedStringMarshaller : ConditionalStackallocMarshallingGenerator + { + private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))); + + private readonly IMarshallingGenerator windowsMarshaller; + private readonly IMarshallingGenerator nonWindowsMarshaller; + + public PlatformDefinedStringMarshaller(IMarshallingGenerator windowsMarshaller, IMarshallingGenerator nonWindowsMarshaller) + { + this.windowsMarshaller = windowsMarshaller; + this.nonWindowsMarshaller = nonWindowsMarshaller; + } + + public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + var windowsExpr = this.windowsMarshaller.AsArgument(info, context).Expression; + var nonWindowsExpr = this.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 NativeType; + } + + public override ParameterSyntax AsParameter(TypePositionInfo info) + { + // void** + // or + // void* + var 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: + // void* + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList(VariableDeclarator(context.GetIdentifiers(info).native) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.NullLiteralExpression)))))); + + if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) + yield return conditionalAllocSetup; + + break; + case StubCodeContext.Stage.Marshal: + if (info.RefKind != RefKind.Out) + { + if (this.TryGetConditionalBlockForStatements( + this.windowsMarshaller.Generate(info, context), + this.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 (var s in this.windowsMarshaller.Generate(info, context)) + yield return s; + + foreach (var s in this.nonWindowsMarshaller.Generate(info, context)) + yield return s; + + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + if (this.TryGetConditionalBlockForStatements( + this.windowsMarshaller.Generate(info, context), + this.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; + + // 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) + { + var 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/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs index bca31969fba42..40c51d9b2f68e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -4,18 +4,21 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Microsoft.Interop.MarshallerHelpers; + namespace Microsoft.Interop { - internal class Utf16StringMarshaller : ConditionalStackallocMarshallingGenerator + internal sealed class Utf16StringMarshaller : ConditionalStackallocMarshallingGenerator { // [Compat] Equivalent of MAX_PATH on Windows to match built-in system // The assumption is file paths are the most common case for marshalling strings, // so the threshold for optimized allocation is based on that length. private const int StackAllocBytesThreshold = 260 * sizeof(ushort); - private static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.UShortKeyword))); + private static string PinnedIdentifier(string nativeIdentifier) => $"{nativeIdentifier}__pinned"; + public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { string identifier = context.GetIdentifiers(info).native; @@ -29,11 +32,11 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext } else if (context.PinningSupported) { - // (ushort*) + // (ushort*) return Argument( CastExpression( AsNativeType(info), - IdentifierName(identifier))); + IdentifierName(PinnedIdentifier(identifier)))); } // @@ -65,12 +68,12 @@ public override IEnumerable Generate(TypePositionInfo info, Stu { if (context.CurrentStage == StubCodeContext.Stage.Pin) { - // fixed (char* = ) + // fixed (char* = ) yield return FixedStatement( VariableDeclaration( PointerType(PredefinedType(Token(SyntaxKind.CharKeyword))), SingletonSeparatedList( - VariableDeclarator(Identifier(nativeIdentifier)) + VariableDeclarator(Identifier(PinnedIdentifier(nativeIdentifier))) .WithInitializer(EqualsValueClause(IdentifierName(managedIdentifier))))), EmptyStatement()); } @@ -86,6 +89,10 @@ public override IEnumerable Generate(TypePositionInfo info, Stu VariableDeclaration( AsNativeType(info), SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + + if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) + yield return conditionalAllocSetup; + break; case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) @@ -139,17 +146,9 @@ protected override ExpressionSyntax GenerateAllocationExpression( out bool allocationRequiresByteLength) { allocationRequiresByteLength = false; - // (byte*)Marshal.StringToCoTaskMemUni() return CastExpression( AsNativeType(info), - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("StringToCoTaskMemUni")), - ArgumentList( - SingletonSeparatedList( - Argument(IdentifierName(context.GetIdentifiers(info).managed)))))); + StringMarshaller.AllocationExpression(CharEncoding.Utf16, context.GetIdentifiers(info).managed)); } protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) @@ -208,17 +207,7 @@ protected override ExpressionSyntax GenerateFreeExpression( TypePositionInfo info, StubCodeContext context) { - // Marshal.FreeCoTaskMem((IntPtr)) - return InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("FreeCoTaskMem")), - ArgumentList(SingletonSeparatedList( - Argument( - CastExpression( - ParseTypeName("System.IntPtr"), - IdentifierName(context.GetIdentifiers(info).native)))))); + return StringMarshaller.FreeExpression(context.GetIdentifiers(info).native); } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs index 1b47d067f624c..c9c25468b4b20 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs @@ -4,6 +4,8 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Microsoft.Interop.MarshallerHelpers; + namespace Microsoft.Interop { internal sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator @@ -21,7 +23,6 @@ internal sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGen // maximum number of bytes per 'char' is 3. private const int MaxByteCountPerChar = 3; - private static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); private static readonly TypeSyntax UTF8EncodingType = ParseTypeName("System.Text.Encoding.UTF8"); @@ -60,6 +61,10 @@ public override IEnumerable Generate(TypePositionInfo info, Stu VariableDeclaration( AsNativeType(info), SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); + + if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) + yield return conditionalAllocSetup; + break; case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) @@ -108,17 +113,9 @@ protected override ExpressionSyntax GenerateAllocationExpression( out bool allocationRequiresByteLength) { allocationRequiresByteLength = false; - // (byte*)Marshal.StringToCoTaskMemUTF8() return CastExpression( AsNativeType(info), - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("StringToCoTaskMemUTF8")), - ArgumentList( - SingletonSeparatedList( - Argument(IdentifierName(context.GetIdentifiers(info).managed)))))); + StringMarshaller.AllocationExpression(CharEncoding.Utf8, context.GetIdentifiers(info).managed)); } protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) @@ -189,17 +186,7 @@ protected override ExpressionSyntax GenerateFreeExpression( TypePositionInfo info, StubCodeContext context) { - // Marshal.FreeCoTaskMem((IntPtr)) - return InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - InteropServicesMarshalType, - IdentifierName("FreeCoTaskMem")), - ArgumentList(SingletonSeparatedList( - Argument( - CastExpression( - ParseTypeName("System.IntPtr"), - IdentifierName(context.GetIdentifiers(info).native)))))); + return StringMarshaller.FreeExpression(context.GetIdentifiers(info).native); } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index cf52693a97f46..9d4c399ef5a4c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -8,7 +8,7 @@ The focus of version 1 is to support `NetCoreApp`. This implies that anything no ### Semantic changes compared to `DllImportAttribute` -The default value of `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. +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. 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. @@ -34,6 +34,12 @@ When converting from native to managed, the built-in system would throw a [`Mars 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`, `CharSet.Auto`, or `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. + ### Custom marshaller support Using a custom marshaller (i.e. [`ICustomMarshaler`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.icustommarshaler)) with the `UnmanagedType.CustomMarshaler` value on `MarshalAsAttribute` is not supported. This also implies `MarshalAsAttribute` fields: [`MarshalTypeRef`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltyperef), [`MarshalType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltype), and [`MarshalCookie`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshalcookie) are unsupported. 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 793e76c8e5607..e35bfd671e463 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs @@ -9,101 +9,222 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { + private class EntryPoints + { + private const string ReturnLength = "return_length"; + private const string ReverseReturn = "reverse_return"; + private const string ReverseOut = "reverse_out"; + private const string ReverseInplace = "reverse_inplace_ref"; + private const string ReverseReplace = "reverse_replace_ref"; + + private const string UShortSuffix = "_ushort"; + private const string ByteSuffix = "_byte"; + + public class Byte + { + public const string ReturnLength = EntryPoints.ReturnLength + ByteSuffix; + public const string ReverseReturn = EntryPoints.ReverseReturn + ByteSuffix; + public const string ReverseOut = EntryPoints.ReverseOut + ByteSuffix; + public const string ReverseInplace = EntryPoints.ReverseInplace + ByteSuffix; + public const string ReverseReplace = EntryPoints.ReverseReplace + ByteSuffix; + } + + public class UShort + { + public const string ReturnLength = EntryPoints.ReturnLength + UShortSuffix; + public const string ReverseReturn = EntryPoints.ReverseReturn + UShortSuffix; + public const string ReverseOut = EntryPoints.ReverseOut + UShortSuffix; + public const string ReverseInplace = EntryPoints.ReverseInplace + UShortSuffix; + public const string ReverseReplace = EntryPoints.ReverseReplace + UShortSuffix; + } + } + public partial class Unicode { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort", CharSet = CharSet.Unicode)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Unicode)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_ushort", CharSet = CharSet.Unicode)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Unicode)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_ushort", CharSet = CharSet.Unicode)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Unicode)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort", CharSet = CharSet.Unicode)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort", CharSet = CharSet.Unicode)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort", CharSet = CharSet.Unicode)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReplace, CharSet = CharSet.Unicode)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class LPTStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort", CharSet = CharSet.None)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPTStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPTStr)] string s, [MarshalAs(UnmanagedType.LPTStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPTStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); } public partial class LPWStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort", CharSet = CharSet.None)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPWStr)] string s, [MarshalAs(UnmanagedType.LPWStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPWStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); } public partial class LPUTF8Str { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_byte")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_byte", CharSet = CharSet.None)] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_return_byte")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPUTF8Str)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_out_byte")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPUTF8Str)] string s, [MarshalAs(UnmanagedType.LPUTF8Str)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_byte")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPUTF8Str)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_inplace_ref_byte")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_byte")] + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); } + + public partial class Ansi + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Ansi)] + public static partial int ReturnLength(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Ansi)] + public static partial string Reverse_Return(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Ansi)] + public static partial void Reverse_Out(string s, out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + public static partial void Reverse_Ref(ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + public static partial void Reverse_In(in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + public static partial void Reverse_Replace_Ref(ref string s); + } + + public partial class LPStr + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength)] + public static partial int ReturnLength([MarshalAs(UnmanagedType.LPStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] + public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn)] + [return: MarshalAs(UnmanagedType.LPStr)] + public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPStr)] string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut)] + public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPStr)] string s, [MarshalAs(UnmanagedType.LPStr)] out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + public static partial void Reverse_In([MarshalAs(UnmanagedType.LPStr)] in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), 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(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Auto)] + public static partial int ReturnLength(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Auto)] + public static partial string Reverse_Return(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Auto)] + public static partial void Reverse_Out(string s, out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + public static partial void Reverse_Ref(ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + public static partial void Reverse_In(in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + public static partial void Reverse_Replace_Ref(ref string s); + } + + public partial class Windows + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Auto)] + public static partial int ReturnLength(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Auto)] + public static partial string Reverse_Return(string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Auto)] + public static partial void Reverse_Out(string s, out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + public static partial void Reverse_Ref(ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + public static partial void Reverse_In(in string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + public static partial void Reverse_Replace_Ref(ref string s); + } + } } public class StringTests @@ -236,6 +357,145 @@ public void UTF8StringByRef(string value) Assert.Equal(expected, refValue); } + [Theory] + [MemberData(nameof(UnicodeStrings))] + public void AnsiStringMarshalledAsExpected(string value) + { + int expectedLen = value != null + ? 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)); + } + + [Theory] + [MemberData(nameof(UnicodeStrings))] + 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); + } + + [Theory] + [MemberData(nameof(UnicodeStrings))] + 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) @@ -255,5 +515,50 @@ private static string ReverseBytes(string value, Encoding encoding) Array.Reverse(bytes); return encoding.GetString(bytes); } + + public static string ReverseAnsi(string value) + { + if (value == null) + return null; + + string ansi; + IntPtr ptr = Marshal.StringToCoTaskMemAnsi(value); + + try + { + unsafe + { + ansi = new string((sbyte*)ptr.ToPointer()); + } + } + finally + { + Marshal.FreeCoTaskMem(ptr); + } + + return ReverseChars(ansi); + } + + public static int GetLengthAnsi(string value) + { + int len = 0; + IntPtr ptr = Marshal.StringToCoTaskMemAnsi(value); + + try + { + byte nextByte = Marshal.ReadByte(ptr, len); + while (nextByte != '\0') + { + len++; + nextByte = Marshal.ReadByte(ptr, len); + } + } + finally + { + Marshal.FreeCoTaskMem(ptr); + } + + return len; + } } } 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 5e1dc98cd807e..c0e467ba6f0cb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -68,8 +68,8 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; 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) }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi) }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.VariantBool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; @@ -78,9 +78,10 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPWStr) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPTStr) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPUTF8Str) }; - //yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPWStr) }; yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPUTF8Str) }; + yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; //yield return new[] { CodeSnippets.EnumParameters }; yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -135,17 +136,11 @@ public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - + yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Ansi) }; - yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Auto) }; - - yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; - yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; - yield return new[] { CodeSnippets.EnumParameters }; yield return new[] { CodeSnippets.PreserveSigFalse() }; 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 335df5d4d345c..8aa83bae201eb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs @@ -403,7 +403,7 @@ private static ReferenceAssemblies GetReferenceAssemblies(TargetFramework target TargetFramework.Framework => ReferenceAssemblies.NetFramework.Net48.Default, TargetFramework.Standard => ReferenceAssemblies.NetStandard.NetStandard21, TargetFramework.Core => ReferenceAssemblies.NetCore.NetCoreApp31, - TargetFramework.Net => ReferenceAssemblies.NetCore.NetCoreApp50, + TargetFramework.Net => ReferenceAssemblies.Net.Net50, _ => ReferenceAssemblies.Default }; } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index e7b9271727f28..b94f3f9eafe09 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -10,7 +10,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index c847e9e1f3b51..80b39053c3ffe 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -67,7 +67,7 @@ public static async Task CreateCompilationWithReferenceAssemblies(s public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() { // TODO: When .NET 5.0 releases, we can simplify this. - var referenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp50; + var referenceAssemblies = ReferenceAssemblies.Net.Net50; // Include the assembly containing the new attribute and all of its references. // [TODO] Remove once the attribute has been added to the BCL From e756fa140838294175aae2fe3381313bd1983a1e Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 4 Nov 2020 20:22:33 -0800 Subject: [PATCH 042/161] Report diagnostic for `BestFitMapping`, `ThrowOnUnmappableChar`, and `LCIDConversion` (dotnet/runtimelab#291) Commit migrated from https://github.com/dotnet/runtimelab/commit/633f08d813a2109f390c196465063eef744fe20f --- .../DllImportGenerator/DllImportGenerator.cs | 233 ++++++++++-------- .../gen/DllImportGenerator/TypeNames.cs | 2 + .../DllImportGenerator/TypePositionInfo.cs | 2 - .../DllImportGenerator/Compatibility.md | 12 +- .../CodeSnippets.cs | 50 +++- .../CompileFails.cs | 7 + .../DllImportGenerator.UnitTests/Compiles.cs | 2 +- 7 files changed, 191 insertions(+), 117 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 619c5be892b67..a8e8c572b5003 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -30,6 +30,13 @@ public void Execute(GeneratorExecutionContext context) return; } + // Get the symbol for GeneratedDllImportAttribute. If it doesn't exist in the compilation, the generator has nothing to do. + INamedTypeSymbol? generatedDllImportAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.GeneratedDllImportAttribute); + if (generatedDllImportAttrType == null) + return; + + INamedTypeSymbol? lcidConversionAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.LCIDConversionAttribute); + // Fire the start/stop pair for source generation using var _ = Diagnostics.Events.SourceGenerationStartStop(synRec.Methods.Count); @@ -63,11 +70,45 @@ public void Execute(GeneratorExecutionContext context) // Process the method syntax and get its SymbolInfo. var methodSymbolInfo = sm.GetDeclaredSymbol(methodSyntax, context.CancellationToken)!; - // Process the attributes on the method. + // Get any attributes of interest on the method + AttributeData? generatedDllImportAttr = null; + AttributeData? lcidConversionAttr = null; + foreach (var attr in methodSymbolInfo.GetAttributes()) + { + if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, generatedDllImportAttrType)) + { + generatedDllImportAttr = attr; + } + else if (lcidConversionAttrType != null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, lcidConversionAttrType)) + { + lcidConversionAttr = attr; + } + } + + if (generatedDllImportAttr == null) + continue; + + // Process the GeneratedDllImport attribute DllImportStub.GeneratedDllImportData dllImportData; - AttributeSyntax dllImportAttr = this.ProcessAttributes(methodSymbolInfo, context.CancellationToken, out dllImportData); + AttributeSyntax dllImportAttr = this.ProcessGeneratedDllImportAttribute(methodSymbolInfo, generatedDllImportAttr, out dllImportData); Debug.Assert((dllImportAttr is not null) && (dllImportData is not null)); + if (dllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) + { + generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.BestFitMapping)); + } + + if (dllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) + { + generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar)); + } + + if (lcidConversionAttr != null) + { + // Using LCIDConversion with GeneratedDllImport is not supported + generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(TypeNames.LCIDConversionAttribute)); + } + // Create the stub. var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData!, context.Compilation, generatorDiagnostics, context.CancellationToken); @@ -163,127 +204,107 @@ private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMayb || attrName.EndsWith(PrefixedGeneratedDllImportAttribute); } - private AttributeSyntax ProcessAttributes( + private AttributeSyntax ProcessGeneratedDllImportAttribute( IMethodSymbol method, - CancellationToken cancelToken, + AttributeData attrData, out DllImportStub.GeneratedDllImportData dllImportData) { dllImportData = new DllImportStub.GeneratedDllImportData(); - // Process all attributes - foreach (AttributeData attrData in method.GetAttributes()) + // Found the GeneratedDllImport, but it has an error so report the error. + // This is most likely an issue with targeting an incorrect TFM. + if (attrData.AttributeClass?.TypeKind is null or TypeKind.Error) { - if (attrData.ApplicationSyntaxReference is null) - { - continue; - } - - var attrSyntax = (AttributeSyntax)attrData.ApplicationSyntaxReference.GetSyntax(cancelToken); - - // Skip the attribute if not GeneratedDllImport. - if (!IsGeneratedDllImportAttribute(attrSyntax)) - { - continue; - } - - // Found the GeneratedDllImport, but it has an error so report the error. - // This is most likely an issue with targeting an incorrect TFM. - if (attrData.AttributeClass?.TypeKind is null or TypeKind.Error) - { - // [TODO] Report GeneratedDllImport has an error - corrupt metadata? - throw new InvalidProgramException(); - } + // [TODO] Report GeneratedDllImport has an error - corrupt metadata? + throw new InvalidProgramException(); + } - var newAttributeArgs = new List(); + var newAttributeArgs = new List(); - // Populate the DllImport data from the GeneratedDllImportAttribute attribute. - dllImportData.ModuleName = attrData.ConstructorArguments[0].Value!.ToString(); + // Populate the DllImport data from the GeneratedDllImportAttribute attribute. + dllImportData.ModuleName = attrData.ConstructorArguments[0].Value!.ToString(); - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(SyntaxFactory.LiteralExpression( - SyntaxKind.StringLiteralExpression, - SyntaxFactory.Literal(dllImportData.ModuleName)))); + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(SyntaxFactory.LiteralExpression( + SyntaxKind.StringLiteralExpression, + SyntaxFactory.Literal(dllImportData.ModuleName)))); - // All other data on attribute is defined as NamedArguments. - foreach (var namedArg in attrData.NamedArguments) + // All other data on attribute is defined as NamedArguments. + foreach (var namedArg in attrData.NamedArguments) + { + ExpressionSyntax? expSyntaxMaybe = null; + switch (namedArg.Key) { - ExpressionSyntax? expSyntaxMaybe = null; - switch (namedArg.Key) - { - default: - Debug.Fail($"An unknown member was found on {GeneratedDllImport}"); - continue; - case nameof(DllImportStub.GeneratedDllImportData.BestFitMapping): - dllImportData.BestFitMapping = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.BestFitMapping); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.BestFitMapping; - break; - case nameof(DllImportStub.GeneratedDllImportData.CallingConvention): - dllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value!; - expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CallingConvention); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CallingConvention; - break; - case nameof(DllImportStub.GeneratedDllImportData.CharSet): - dllImportData.CharSet = (CharSet)namedArg.Value.Value!; - expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CharSet); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CharSet; - break; - case nameof(DllImportStub.GeneratedDllImportData.EntryPoint): - dllImportData.EntryPoint = (string)namedArg.Value.Value!; - expSyntaxMaybe = CreateStringExpressionSyntax(dllImportData.EntryPoint!); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.EntryPoint; - break; - case nameof(DllImportStub.GeneratedDllImportData.ExactSpelling): - dllImportData.ExactSpelling = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ExactSpelling); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ExactSpelling; - break; - case nameof(DllImportStub.GeneratedDllImportData.PreserveSig): - dllImportData.PreserveSig = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.PreserveSig); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.PreserveSig; - break; - case nameof(DllImportStub.GeneratedDllImportData.SetLastError): - dllImportData.SetLastError = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.SetLastError); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.SetLastError; - break; - case nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar): - dllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ThrowOnUnmappableChar); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ThrowOnUnmappableChar; - break; - } - - Debug.Assert(expSyntaxMaybe is not null); - - // Defer the name equals syntax till we know the value means something. If we created - // an expression we know the key value was valid. - NameEqualsSyntax nameSyntax = SyntaxFactory.NameEquals(namedArg.Key); - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe!)); + default: + Debug.Fail($"An unknown member was found on {GeneratedDllImport}"); + continue; + case nameof(DllImportStub.GeneratedDllImportData.BestFitMapping): + dllImportData.BestFitMapping = (bool)namedArg.Value.Value!; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.BestFitMapping); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.BestFitMapping; + break; + case nameof(DllImportStub.GeneratedDllImportData.CallingConvention): + dllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value!; + expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CallingConvention); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CallingConvention; + break; + case nameof(DllImportStub.GeneratedDllImportData.CharSet): + dllImportData.CharSet = (CharSet)namedArg.Value.Value!; + expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CharSet); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CharSet; + break; + case nameof(DllImportStub.GeneratedDllImportData.EntryPoint): + dllImportData.EntryPoint = (string)namedArg.Value.Value!; + expSyntaxMaybe = CreateStringExpressionSyntax(dllImportData.EntryPoint!); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.EntryPoint; + break; + case nameof(DllImportStub.GeneratedDllImportData.ExactSpelling): + dllImportData.ExactSpelling = (bool)namedArg.Value.Value!; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ExactSpelling); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ExactSpelling; + break; + case nameof(DllImportStub.GeneratedDllImportData.PreserveSig): + dllImportData.PreserveSig = (bool)namedArg.Value.Value!; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.PreserveSig); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.PreserveSig; + break; + case nameof(DllImportStub.GeneratedDllImportData.SetLastError): + dllImportData.SetLastError = (bool)namedArg.Value.Value!; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.SetLastError); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.SetLastError; + break; + case nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar): + dllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value!; + expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ThrowOnUnmappableChar); + dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ThrowOnUnmappableChar; + break; } - // If the EntryPoint property is not set, we will compute and - // add it based on existing semantics (i.e. method name). - // - // N.B. The export discovery logic is identical regardless of where - // the name is defined (i.e. method name vs EntryPoint property). - if (!dllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) - { - var entryPointName = SyntaxFactory.NameEquals(nameof(DllImportAttribute.EntryPoint)); + Debug.Assert(expSyntaxMaybe is not null); - // The name of the method is the entry point name to use. - var entryPointValue = CreateStringExpressionSyntax(method.Name); - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(entryPointName, null, entryPointValue)); - } + // Defer the name equals syntax till we know the value means something. If we created + // an expression we know the key value was valid. + NameEqualsSyntax nameSyntax = SyntaxFactory.NameEquals(namedArg.Key); + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe!)); + } + + // If the EntryPoint property is not set, we will compute and + // add it based on existing semantics (i.e. method name). + // + // N.B. The export discovery logic is identical regardless of where + // the name is defined (i.e. method name vs EntryPoint property). + if (!dllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) + { + var entryPointName = SyntaxFactory.NameEquals(nameof(DllImportAttribute.EntryPoint)); - // Create new attribute - return SyntaxFactory.Attribute( - SyntaxFactory.ParseName(typeof(DllImportAttribute).FullName), - SyntaxFactory.AttributeArgumentList(SyntaxFactory.SeparatedList(newAttributeArgs))); + // The name of the method is the entry point name to use. + var entryPointValue = CreateStringExpressionSyntax(method.Name); + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(entryPointName, null, entryPointValue)); } - // [TODO] Report the missing GeneratedDllImportAttribute - throw new NotSupportedException(); + // Create new attribute + return SyntaxFactory.Attribute( + SyntaxFactory.ParseName(typeof(DllImportAttribute).FullName), + SyntaxFactory.AttributeArgumentList(SyntaxFactory.SeparatedList(newAttributeArgs))); static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 44a1f163d07e9..1ec4e75018310 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -16,6 +16,8 @@ static class TypeNames public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute"; + public const string LCIDConversionAttribute = "System.Runtime.InteropServices.LCIDConversionAttribute"; + public const string System_Span_Metadata = "System.Span`1"; public const string System_Span = "System.Span"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index f38a30bb9afd6..e8b726fd598c1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -32,7 +32,6 @@ private TypePositionInfo() { this.ManagedIndex = UnsetIndex; this.NativeIndex = UnsetIndex; - this.UnmanagedLCIDConversionArgIndex = UnsetIndex; } #pragma warning restore @@ -49,7 +48,6 @@ private TypePositionInfo() public int ManagedIndex { get; init; } public int NativeIndex { get; init; } - public int UnmanagedLCIDConversionArgIndex { get; init; } public MarshallingInfo MarshallingAttributeInfo { get; init; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index 9d4c399ef5a4c..cea5adb2d918a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -12,7 +12,9 @@ The default value of [`CharSet`](https://docs.microsoft.com/dotnet/api/system.ru 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. -### `char` marshaller +[`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. + +### `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. @@ -23,7 +25,7 @@ For `CharSet.Ansi` and `CharSet.None`, the built-in system used the [system defa 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` marshaller +### `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) @@ -44,7 +46,7 @@ On Windows, marshalling using `CharSet.Auto` is treated as UTF-16. When marshall Using a custom marshaller (i.e. [`ICustomMarshaler`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.icustommarshaler)) with the `UnmanagedType.CustomMarshaler` value on `MarshalAsAttribute` is not supported. This also implies `MarshalAsAttribute` fields: [`MarshalTypeRef`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltyperef), [`MarshalType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshaltype), and [`MarshalCookie`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.marshalcookie) are unsupported. -### Array marshaller support +### Array marshalling Marshalling of arrays will not be supported when using [`UnmangedType.SafeArray`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.unmanagedtype). This implies that the following `MarshalAsAttribute` fields are unsupported: [`SafeArraySubType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.safearraysubtype) and [`SafeArrayUserDefinedSubType`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute.safearrayuserdefinedsubtype) @@ -54,6 +56,10 @@ Only single-dimensional arrays are supported for source generated marshalling. In the source-generated marshalling, arrays will be allocated on the stack (instead of through [`AllocCoTaskMem`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.alloccotaskmem)) if they are passed by value or by read-only reference if they contain at most 256 bytes of data. The built-in system does not support this optimization for arrays. +### `LCIDConversion` support + +[`LCIDConversionAttribute`](`https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute`) will not be supported for methods marked with `GeneratedDllImportAttribute`. + ## Verison 0 This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. \ No newline at end of file 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 9acc2c7f19223..35d78f864ac10 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -168,6 +168,24 @@ partial class Test ThrowOnUnmappableChar = true)] public static partial void Method(); } +"; + + /// + /// Declaration with all supported DllImport named arguments. + /// + public static readonly string AllSupportedDllImportNamedArguments = @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"", + CallingConvention = CallingConvention.Cdecl, + CharSet = CharSet.Unicode, + EntryPoint = ""UserDefinedEntryPoint"", + ExactSpelling = true, + PreserveSig = false, + SetLastError = true)] + public static partial void Method(); +} "; /// @@ -180,17 +198,26 @@ partial class Test private const bool IsTrue = true; private const bool IsFalse = false; private const string EntryPointName = nameof(Test) + nameof(IsFalse); + private const int One = 1; + private const int Two = 2; [GeneratedDllImport(nameof(Test), - BestFitMapping = 0 != 1, CallingConvention = (CallingConvention)1, CharSet = (CharSet)2, EntryPoint = EntryPointName, - ExactSpelling = IsTrue, + ExactSpelling = 0 != 1, PreserveSig = IsFalse, - SetLastError = !IsFalse, - ThrowOnUnmappableChar = !IsTrue)] - public static partial void Method(); + SetLastError = IsTrue)] + public static partial void Method1(); + + [GeneratedDllImport(nameof(Test), + CallingConvention = (CallingConvention)One, + CharSet = (CharSet)Two, + EntryPoint = EntryPointName, + ExactSpelling = One != Two, + PreserveSig = !IsFalse, + SetLastError = !IsTrue)] + public static partial void Method2(); } "; @@ -204,6 +231,19 @@ partial class Test [GeneratedDllImport(""DoesNotExist"")] public static partial void Method(int t = 0); } +"; + + /// + /// Declaration with LCIDConversionAttribute. + /// + public static readonly string LCIDConversionAttribute = @" +using System.Runtime.InteropServices; +partial class Test +{ + [LCIDConversion(0)] + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method(); +} "; /// 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 7fdb0ffcfb51d..a9719b28db1b2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -35,6 +35,13 @@ public static IEnumerable CodeSnippetsToCompile() // Unsupported MarshalAsAttribute usage // * UnmanagedType.CustomMarshaler, MarshalTypeRef, MarshalType, MarshalCookie yield return new object[] { CodeSnippets.MarshalAsCustomMarshalerOnTypes, 16, 0 }; + + // Unsupported named arguments + // * BestFitMapping, ThrowOnUnmappableChar + yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 2, 0 }; + + // LCIDConversion + yield return new object[] { CodeSnippets.LCIDConversionAttribute, 1, 0 }; } [Theory] 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 c0e467ba6f0cb..bea88906e3eb7 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -17,7 +17,7 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.NestedNamespace }; yield return new[] { CodeSnippets.NestedTypes }; yield return new[] { CodeSnippets.UserDefinedEntryPoint }; - yield return new[] { CodeSnippets.AllDllImportNamedArguments }; + yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; yield return new[] { CodeSnippets.DefaultParameters }; yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; From 2e93e69ec33e984088e1dfaed69be35926f8a6a4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 5 Nov 2020 14:58:27 -0800 Subject: [PATCH 043/161] Apply changes to integrate standalone experiment CI/CD pipeline with DllImportGenerator Commit migrated from https://github.com/dotnet/runtimelab/commit/4956f113781bf92428a7c2676d7a6f97a1a2b8fe --- Experiment.sln | 48 ------------------- src/Experiment/src/Experiment.csproj | 7 --- src/Experiment/src/MyClass.cs | 9 ---- src/Experiment/tests/Experiment.Tests.csproj | 9 ---- src/Experiment/tests/MyClassTests.cs | 14 ------ .../gen/Directory.Build.props | 8 ---- .../DllImportGenerator.csproj | 8 +--- .../DllImportGenerator.Tests.csproj | 6 --- .../DllImportGenerator.UnitTests.csproj | 6 --- .../NativeExports/NativeExports.csproj | 2 +- 10 files changed, 3 insertions(+), 114 deletions(-) delete mode 100644 Experiment.sln delete mode 100644 src/Experiment/src/Experiment.csproj delete mode 100644 src/Experiment/src/MyClass.cs delete mode 100644 src/Experiment/tests/Experiment.Tests.csproj delete mode 100644 src/Experiment/tests/MyClassTests.cs delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props diff --git a/Experiment.sln b/Experiment.sln deleted file mode 100644 index ff3e8c0e68324..0000000000000 --- a/Experiment.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 -MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experiment", "src\Experiment\src\Experiment.csproj", "{B7977360-6671-4707-9A1C-1C29D5BE2674}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experiment.Tests", "src\Experiment\tests\Experiment.Tests.csproj", "{CE81B6BD-CCCC-4223-9069-B28435A4A5C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x64.ActiveCfg = Debug|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x64.Build.0 = Debug|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x86.ActiveCfg = Debug|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Debug|x86.Build.0 = Debug|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|Any CPU.Build.0 = Release|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x64.ActiveCfg = Release|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x64.Build.0 = Release|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x86.ActiveCfg = Release|Any CPU - {B7977360-6671-4707-9A1C-1C29D5BE2674}.Release|x86.Build.0 = Release|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x64.ActiveCfg = Debug|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x64.Build.0 = Debug|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x86.ActiveCfg = Debug|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Debug|x86.Build.0 = Debug|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|Any CPU.Build.0 = Release|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x64.ActiveCfg = Release|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x64.Build.0 = Release|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x86.ActiveCfg = Release|Any CPU - {CE81B6BD-CCCC-4223-9069-B28435A4A5C1}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/src/Experiment/src/Experiment.csproj b/src/Experiment/src/Experiment.csproj deleted file mode 100644 index f208d303c9811..0000000000000 --- a/src/Experiment/src/Experiment.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - net5.0 - - - diff --git a/src/Experiment/src/MyClass.cs b/src/Experiment/src/MyClass.cs deleted file mode 100644 index b0121b4015cc7..0000000000000 --- a/src/Experiment/src/MyClass.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Experiment -{ - public class MyClass - { - public static bool ReturnTrue => true; - } -} diff --git a/src/Experiment/tests/Experiment.Tests.csproj b/src/Experiment/tests/Experiment.Tests.csproj deleted file mode 100644 index 1f38944a6987b..0000000000000 --- a/src/Experiment/tests/Experiment.Tests.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - net5.0 - - - - - - diff --git a/src/Experiment/tests/MyClassTests.cs b/src/Experiment/tests/MyClassTests.cs deleted file mode 100644 index 14d4e5e501049..0000000000000 --- a/src/Experiment/tests/MyClassTests.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Xunit; - -namespace Experiment.Tests -{ - public class MyClassTests - { - [Fact] - public void Test1() - { - Assert.True(MyClass.ReturnTrue); - } - } -} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props deleted file mode 100644 index 61ba7c1afc320..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - 3.8.0-3.final - 2.4.1 - - - diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index b64ed81b96b47..860f0304186f5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -15,13 +15,9 @@ - DllImportGenerator - 1.0.0.0 Microsoft - http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE - http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE - http://ICON_URL_HERE_OR_DELETE_THIS_LINE - http://REPOSITORY_URL_HERE_OR_DELETE_THIS_LINE + https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator + https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator false DllImportGenerator Summary of changes made in this release of the package. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index b1e8ddc50400f..6b3469c88b343 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -8,12 +8,6 @@ - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index e7b9271727f28..200cd1c8c8d0a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -15,12 +15,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 7327cb1d19690..3dd73baa45126 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -8,7 +8,7 @@ - + From 36da5aed7bfdca87225deff7e0e0bb48941f4696 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 5 Nov 2020 16:39:10 -0800 Subject: [PATCH 044/161] Upgrade DNNE to 1.0.16 Signed-off-by: Jeremy Koritzinsky Commit migrated from https://github.com/dotnet/runtimelab/commit/106540b833576e479efdcd236e73d499dfe9b0b3 --- .../tests/TestAssets/NativeExports/NativeExports.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 3dd73baa45126..301246364e87f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -8,7 +8,7 @@ - + From 996b4f84eb383ae38a851c7b5889dd5c8f89f328 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 5 Nov 2020 17:11:55 -0800 Subject: [PATCH 045/161] Let enums and pointers go through blittable marshaller (dotnet/runtimelab#303) Commit migrated from https://github.com/dotnet/runtimelab/commit/7ae2d22408bb1ef598f8a73ad7b7fac904b3e157 --- .../Marshalling/MarshallingGenerator.cs | 14 +++ .../DllImportGenerator.Tests/EnumTests.cs | 114 ++++++++++++++++++ .../DllImportGenerator.Tests/PointerTests.cs | 66 ++++++++++ .../CodeSnippets.cs | 15 +++ .../DllImportGenerator.UnitTests/Compiles.cs | 17 ++- .../tests/TestAssets/NativeExports/Numeric.cs | 43 +++++++ 6 files changed, 266 insertions(+), 3 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 66ff34681e888..523578ba63c22 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -147,6 +147,20 @@ public static IMarshallingGenerator Create( or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: return Blittable; + // Enum with no marshalling info + case { ManagedType: { TypeKind: TypeKind.Enum }, MarshallingAttributeInfo: NoMarshallingInfo }: + // Check that the underlying type is not bool or char. C# does not allow this, but ECMA-335 does. + var underlyingSpecialType = ((INamedTypeSymbol)info.ManagedType).EnumUnderlyingType!.SpecialType; + if (underlyingSpecialType == SpecialType.System_Boolean || underlyingSpecialType == SpecialType.System_Char) + { + throw new MarshallingNotSupportedException(info, context); + } + return Blittable; + + // Pointer with no marshalling info + case { ManagedType: { TypeKind: TypeKind.Pointer }, MarshallingAttributeInfo: NoMarshallingInfo }: + return Blittable; + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs new file mode 100644 index 0000000000000..1ad4397724c0a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs @@ -0,0 +1,114 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public partial class IntEnum + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_return_int")] + public static partial EnumTests.IntEnum Subtract_Return(EnumTests.IntEnum a, EnumTests.IntEnum b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_out_int")] + public static partial void Subtract_Out(EnumTests.IntEnum a, EnumTests.IntEnum b, out EnumTests.IntEnum c); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + public static partial void Subtract_Ref(EnumTests.IntEnum a, ref EnumTests.IntEnum b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + public static partial void Subtract_In(EnumTests.IntEnum a, in EnumTests.IntEnum b); + } + + public partial class ByteEnum + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_return_byte")] + public static partial EnumTests.ByteEnum Subtract_Return(EnumTests.ByteEnum a, EnumTests.ByteEnum b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_out_byte")] + public static partial void Subtract_Out(EnumTests.ByteEnum a, EnumTests.ByteEnum b, out EnumTests.ByteEnum c); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + public static partial void Subtract_Ref(EnumTests.ByteEnum a, ref EnumTests.ByteEnum b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + public static partial void Subtract_In(EnumTests.ByteEnum a, in EnumTests.ByteEnum b); + } + } + + public class EnumTests + { + internal enum IntEnum + { + Zero, + One, + Two, + Three, + Max = int.MaxValue + } + + internal enum ByteEnum : byte + { + Zero, + One, + Two, + Three, + Max = byte.MaxValue + } + + [Fact] + public void EnumByValue() + { + { + IntEnum ret = NativeExportsNE.IntEnum.Subtract_Return(IntEnum.Max, IntEnum.Zero); + Assert.Equal(IntEnum.Max, ret); + } + { + ByteEnum ret = NativeExportsNE.ByteEnum.Subtract_Return(ByteEnum.Max, ByteEnum.Zero); + Assert.Equal(ByteEnum.Max, ret); + } + } + + [Fact] + public void EnumByRef() + { + { + IntEnum a = IntEnum.Three; + IntEnum b = IntEnum.Two; + IntEnum expected = IntEnum.One; + + IntEnum ret; + NativeExportsNE.IntEnum.Subtract_Out(a, b, out ret); + Assert.Equal(expected, ret); + + IntEnum refValue = b; + NativeExportsNE.IntEnum.Subtract_In(a, in refValue); + Assert.Equal(expected, refValue); // Value is updated even when passed with in keyword (matches built-in system) + + refValue = b; + NativeExportsNE.IntEnum.Subtract_Ref(a, ref refValue); + Assert.Equal(expected, refValue); + } + + { + ByteEnum a = ByteEnum.Three; + ByteEnum b = ByteEnum.Two; + ByteEnum expected = ByteEnum.One; + + ByteEnum ret; + NativeExportsNE.ByteEnum.Subtract_Out(a, b, out ret); + Assert.Equal(expected, ret); + + ByteEnum refValue = b; + NativeExportsNE.ByteEnum.Subtract_In(a, in refValue); + Assert.Equal(expected, refValue); // Value is updated even when passed with in keyword (matches built-in system) + + refValue = b; + NativeExportsNE.ByteEnum.Subtract_Ref(a, ref refValue); + Assert.Equal(expected, refValue); + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs new file mode 100644 index 0000000000000..121ff0e254e5e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs @@ -0,0 +1,66 @@ +using System.Runtime.InteropServices; + +using SharedTypes; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + public static unsafe partial void Subtract_Int_Ptr(int a, int* b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + public static unsafe partial void Subtract_Byte_Ptr(byte a, byte* b); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_byref")] + public static unsafe partial void DoubleIntFields_Ptr(IntFields* result); + } + + public class PointerTests + { + [Fact] + public unsafe void BlittablePrimitive() + { + { + int a = int.MaxValue; + int b = 10; + int expected = a - b; + NativeExportsNE.Subtract_Int_Ptr(a, &b); + Assert.Equal(expected, b); + } + { + byte a = byte.MaxValue; + byte b = 10; + byte expected = (byte)(a - b); + NativeExportsNE.Subtract_Byte_Ptr(a, &b); + Assert.Equal(expected, b); + } + } + + [Fact] + public unsafe void BlittableStruct() + { + const int A = 24, B = 37, C = 59; + var initial = new IntFields() + { + a = A, + b = B, + c = C, + }; + var expected = new IntFields() + { + a = initial.a * 2, + b = initial.b * 2, + c = initial.c * 2, + }; + + var input = initial; + { + NativeExportsNE.DoubleIntFields_Ptr(&input); + Assert.Equal(expected, input); + } + } + } +} 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 35d78f864ac10..10a17c70af78c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -394,6 +394,21 @@ public static partial MyEnum Method( out MyEnum pOut); }}"; + /// + /// Declaration with pointer parameters. + /// + public static string PointerParameters() => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static unsafe partial {typeof(T)}* Method( + {typeof(T)}* p, + in {typeof(T)}* pIn, + ref {typeof(T)}* pRef, + out {typeof(T)}* pOut); +}}"; + /// /// Declaration with PreserveSig = false. /// 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 bea88906e3eb7..57a911f537422 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -82,7 +82,20 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPWStr) }; yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPUTF8Str) }; yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; - //yield return new[] { CodeSnippets.EnumParameters }; + yield return new[] { CodeSnippets.EnumParameters }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.PointerParameters() }; yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -141,8 +154,6 @@ public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.EnumParameters }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs new file mode 100644 index 0000000000000..2fde4b3ac0a21 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs @@ -0,0 +1,43 @@ +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class Numeric + { + [UnmanagedCallersOnly(EntryPoint = "subtract_return_byte")] + public static byte SubtractReturnByte(byte a, byte b) + { + return (byte)(a - b); + } + + [UnmanagedCallersOnly(EntryPoint = "subtract_out_byte")] + public static void SubtractReturnAsOutByte(byte a, byte b, byte* ret) + { + *ret = (byte)(a - b); + } + + [UnmanagedCallersOnly(EntryPoint = "subtract_ref_byte")] + public static void SubtractRefByte(byte a, byte* b) + { + *b = (byte)(a - *b); + } + + [UnmanagedCallersOnly(EntryPoint = "subtract_return_int")] + public static int SubtractReturnInt(int a, int b) + { + return a - b; + } + + [UnmanagedCallersOnly(EntryPoint = "subtract_out_int")] + public static void SubtractReturnAsOutInt(int a, int b, int* ret) + { + *ret = a - b; + } + + [UnmanagedCallersOnly(EntryPoint = "subtract_ref_int")] + public static void SubtractRefInt(int a, int* b) + { + *b = a - *b; + } + } +} From 8aafa2385ae09cd34175d7a7fdb2d5f8ee6f6509 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 9 Nov 2020 18:28:49 -0800 Subject: [PATCH 046/161] Disable packing Demo app, tools, and test assets. (dotnet/runtimelab#327) Commit migrated from https://github.com/dotnet/runtimelab/commit/93372b1a309f215001f22cdde6b240454585521f --- .../tests/TestAssets/Directory.Build.props | 6 ++++++ .../DllImportGeneratorSample.csproj | 1 + 2 files changed, 7 insertions(+) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props new file mode 100644 index 0000000000000..76d5ca907662f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 65978093bd2de..02bf56ecd0fb3 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -13,6 +13,7 @@ true + false From 1719a7cc0fdf1354260e6f5ed600fa1a4192ea15 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 12 Nov 2020 17:33:29 -0800 Subject: [PATCH 047/161] Fix formatting for some diagnostic messages (dotnet/runtimelab#311) Commit migrated from https://github.com/dotnet/runtimelab/commit/3e23af10ec81a7715c1d5c151debe920d1e80c9a --- .../Marshalling/MarshallingGenerator.cs | 7 +++-- .../DllImportGenerator/Resources.Designer.cs | 6 ++--- .../gen/DllImportGenerator/Resources.resx | 10 ++++--- .../CompileFails.cs | 26 ++++++++++++++++++- .../DllImportGenerator.UnitTests/Compiles.cs | 20 -------------- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 523578ba63c22..c5a4f4a57d453 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -84,7 +84,7 @@ public MarshallingNotSupportedException(TypePositionInfo info, StubCodeContext c public TypePositionInfo TypePositionInfo { get; private init; } /// - /// Context the marshalling is taking place. + /// Context in which the marshalling is taking place. /// public StubCodeContext StubCodeContext { get; private init; } @@ -309,7 +309,10 @@ private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(Type ExpressionSyntax numElementsExpression; if (info.MarshallingAttributeInfo is not ArrayMarshalAsInfo marshalAsInfo) { - throw new MarshallingNotSupportedException(info, context); + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.ArraySizeMustBeSpecified + }; } LiteralExpressionSyntax? constSizeExpression = marshalAsInfo.ArraySizeConst != ArrayMarshalAsInfo.UnspecifiedData 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 40e8ebd70f4a7..62bedac0d294c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Looks up a localized string similar to {0} Marshalling the array parameter '{1}' from unmanaged to managed requires either the SizeParamIndex or SizeConst fields to be set on a MarshalAs attribute.. + /// Looks up a localized string similar to Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute'.. /// internal static string ArraySizeMustBeSpecified { get { @@ -70,7 +70,7 @@ internal static string ArraySizeMustBeSpecified { } /// - /// Looks up a localized string similar to {0} The SizeParamIndex value in the MarshalAs attribute on '{1}' is out of range.. + /// Looks up a localized string similar to The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range.. /// internal static string ArraySizeParamIndexOutOfRange { get { @@ -79,7 +79,7 @@ internal static string ArraySizeParamIndexOutOfRange { } /// - /// Looks up a localized string similar to {0} The specified array size parameter for the array '{1}' must be an integer type.. + /// Looks up a localized string similar to The specified array size parameter for an array must be an integer type.. /// internal static string ArraySizeParamTypeMustBeIntegral { get { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 1475b4bfbb6e6..41f62bbe62ff6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -118,13 +118,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - {0} Marshalling the array parameter '{1}' from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a MarshalAs attribute. + Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute'. - {0} The 'SizeParamIndex' value in the 'MarshalAsAttribute' attribute on '{1}' is out of range. + The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range. - {0} The specified array size parameter for the array '{1}' must be an integer type. + The specified array size parameter for an array must be an integer type. A type marked with 'BlittableTypeAttribute' must be blittable. @@ -238,12 +238,16 @@ {0} The generated source will not handle marshalling of parameter '{1}'. + {0} is a message containing additional details about what is not supported +{1} is the name of the parameter The type '{0}' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of the return value of method '{1}'. {0} The generated source will not handle marshalling of the return value of method '{1}'. + {0} is a message containing additional details about what is not supported +{1} is the name of the method Specified type is not supported by source-generated P/Invokes 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 a9719b28db1b2..50e430b22de10 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; @@ -18,6 +19,8 @@ public static IEnumerable CodeSnippetsToCompile() // No explicit marshalling for char or string yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 5, 0 }; yield return new object[] { CodeSnippets.PreserveSigFalse(), 3, 0 }; yield return new object[] { CodeSnippets.PreserveSigFalse(), 3, 0 }; @@ -42,6 +45,27 @@ public static IEnumerable CodeSnippetsToCompile() // LCIDConversion yield return new object[] { CodeSnippets.LCIDConversionAttribute, 1, 0 }; + + // No size information for array marshalling from unmanaged to managed + // * return, out, ref + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; + + // Array with non-integer size param + yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; } [Theory] 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 57a911f537422..15707f0b8d398 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -134,26 +134,6 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() { - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; - - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; From a17d5d5ec287ffc481e94ce25e4869ed8428b413 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 13 Nov 2020 22:14:10 -0800 Subject: [PATCH 048/161] Handle PreserveSig=false (dotnet/runtimelab#323) * Handle PreserveSig=false * Flag SetLastError=true as unsupported until we add support for it * Add try-finally to generated code * Update doc Commit migrated from https://github.com/dotnet/runtimelab/commit/4562fa702e3cd56ce293dee960ffdf1bef7c68c8 --- .../DllImportGenerator/DllImportGenerator.cs | 38 ++- .../gen/DllImportGenerator/DllImportStub.cs | 46 +-- .../Marshalling/BlittableArrayMarshaller.cs | 5 - .../Marshalling/BlittableMarshaller.cs | 7 +- .../Marshalling/BoolMarshaller.cs | 5 - .../Marshalling/CharMarshaller.cs | 5 - .../Marshalling/DelegateMarshaller.cs | 5 - .../Marshalling/HResultExceptionMarshaller.cs | 46 +++ .../Marshalling/MarshallerHelpers.cs | 24 +- .../Marshalling/MarshallingGenerator.cs | 6 +- .../NonBlittableArrayMarshaller.cs | 22 +- .../Marshalling/SafeHandleMarshaller.cs | 62 ++-- .../Marshalling/StringMarshaller.Ansi.cs | 6 - .../StringMarshaller.PlatformDefined.cs | 7 - .../Marshalling/StringMarshaller.Utf16.cs | 6 - .../Marshalling/StringMarshaller.Utf8.cs | 5 - .../DllImportGenerator/StubCodeGenerator.cs | 112 ++++++-- .../libraries/DllImportGenerator/Pipeline.md | 141 +++++++++- .../PreserveSigTests.cs | 264 ++++++++++++++++++ .../CodeSnippets.cs | 19 +- .../CompileFails.cs | 3 +- .../DllImportGenerator.UnitTests/Compiles.cs | 77 ++--- .../tests/TestAssets/NativeExports/HResult.cs | 67 +++++ 23 files changed, 779 insertions(+), 199 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index a8e8c572b5003..73da797fafb97 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -103,6 +103,12 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar)); } + // [TODO] Remove once we support SetLastError=true + if (dllImportData.SetLastError) + { + generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.SetLastError), "true"); + } + if (lcidConversionAttr != null) { // Using LCIDConversion with GeneratedDllImport is not supported @@ -137,7 +143,6 @@ private void PrintGeneratedSource( .WithBody(stub.StubCode); // Create the DllImport declaration. - // [TODO] Don't include PreserveSig=false once that is handled by the generated stub var dllImport = stub.DllImportDeclaration.AddAttributeLists( AttributeList( SingletonSeparatedList(dllImportAttr))); @@ -281,10 +286,13 @@ private AttributeSyntax ProcessGeneratedDllImportAttribute( Debug.Assert(expSyntaxMaybe is not null); - // Defer the name equals syntax till we know the value means something. If we created - // an expression we know the key value was valid. - NameEqualsSyntax nameSyntax = SyntaxFactory.NameEquals(namedArg.Key); - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe!)); + if (PassThroughToDllImportAttribute(namedArg.Key)) + { + // Defer the name equals syntax till we know the value means something. If we created + // an expression we know the key value was valid. + NameEqualsSyntax nameSyntax = SyntaxFactory.NameEquals(namedArg.Key); + newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe!)); + } } // If the EntryPoint property is not set, we will compute and @@ -328,6 +336,26 @@ static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum SyntaxFactory.IdentifierName(typeof(T).FullName), SyntaxFactory.IdentifierName(value.ToString())); } + + static bool PassThroughToDllImportAttribute(string argName) + { +#if GENERATE_FORWARDER + return true; +#else + // Certain fields on DllImport will prevent inlining. Their functionality should be handled by the + // generated source, so the generated DllImport declaration should not include these fields. + return argName switch + { + // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig + // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. + nameof(DllImportStub.GeneratedDllImportData.PreserveSig) => false, + // 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. + nameof(DllImportStub.GeneratedDllImportData.SetLastError) => false, + _ => true + }; +#endif + } } private class SyntaxReceiver : ISyntaxReceiver diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 8a11d17dac917..d52865eee2066 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -27,9 +27,9 @@ private DllImportStub() } #pragma warning restore - public string? StubTypeNamespace { get; private set; } + public string? StubTypeNamespace { get; init; } - public IEnumerable StubContainingTypes { get; private set; } + public IEnumerable StubContainingTypes { get; init; } public TypeSyntax StubReturnType { get => this.returnTypeInfo.ManagedType.AsTypeSyntax(); } @@ -50,9 +50,9 @@ public IEnumerable StubParameters } } - public BlockSyntax StubCode { get; private set; } + public BlockSyntax StubCode { get; init; } - public MethodDeclarationSyntax DllImportDeclaration { get; private set; } + public MethodDeclarationSyntax DllImportDeclaration { get; init; } /// /// Flags used to indicate members on GeneratedDllImport attribute. @@ -171,28 +171,40 @@ public static DllImportStub Create( ManagedIndex = TypePositionInfo.ReturnIndex, NativeIndex = TypePositionInfo.ReturnIndex }; + + var managedRetTypeInfo = retTypeInfo; if (!dllImportData.PreserveSig) { - // [TODO] Create type info for native HRESULT return - // retTypeInfo = ... - - // [TODO] Create type info for native out param - // if (!method.ReturnsVoid) - // { - // TypePositionInfo nativeOutInfo = ...; - // nativeOutInfo.ManagedIndex = TypePositionInfo.ReturnIndex; - // nativeOutInfo.NativeIndex = paramsTypeInfo.Count; - // paramsTypeInfo.Add(nativeOutInfo); - // } + // Create type info for native HRESULT return + retTypeInfo = TypePositionInfo.CreateForType(compilation.GetSpecialType(SpecialType.System_Int32), NoMarshallingInfo.Instance); + retTypeInfo = retTypeInfo with + { + NativeIndex = TypePositionInfo.ReturnIndex + }; + + // Create type info for native out param + if (!method.ReturnsVoid) + { + // Transform the managed return type info into an out parameter and add it as the last param + TypePositionInfo nativeOutInfo = managedRetTypeInfo with + { + InstanceIdentifier = StubCodeGenerator.ReturnIdentifier, + RefKind = RefKind.Out, + RefKindSyntax = SyntaxKind.OutKeyword, + ManagedIndex = TypePositionInfo.ReturnIndex, + NativeIndex = paramsTypeInfo.Count + }; + paramsTypeInfo.Add(nativeOutInfo); + } } // Generate stub code - var stubGenerator = new StubCodeGenerator(method, paramsTypeInfo, retTypeInfo, diagnostics); + var stubGenerator = new StubCodeGenerator(method, dllImportData, paramsTypeInfo, retTypeInfo, diagnostics); var (code, dllImport) = stubGenerator.GenerateSyntax(); return new DllImportStub() { - returnTypeInfo = retTypeInfo, + returnTypeInfo = managedRetTypeInfo, paramsTypeInfo = paramsTypeInfo, StubTypeNamespace = stubTypeNamespace, StubContainingTypes = containingTypes, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs index a5839a8a0089f..31638278ac036 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs @@ -79,11 +79,6 @@ public override IEnumerable Generate(TypePositionInfo info, Stu switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); - if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) yield return conditionalAllocSetup; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs index 1a975bd0e13dc..bca6a7db58633 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs @@ -29,7 +29,7 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { return Argument(IdentifierName(info.InstanceIdentifier)); } - else if (context.PinningSupported) + else if (context.PinningSupported && !info.IsManagedReturnPosition) { return Argument(IdentifierName(context.GetIdentifiers(info).native)); @@ -71,11 +71,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList( - VariableDeclarator(nativeIdentifier)))); break; case StubCodeContext.Stage.Marshal: if (info.RefKind == RefKind.Ref) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs index 10d67e9aa761e..ea9fbea51a555 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs @@ -58,11 +58,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); - break; case StubCodeContext.Stage.Marshal: // = ()( ? _trueValue : _falseValue); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs index 4ecf0329ec816..43026da60abc8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs @@ -52,11 +52,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); - break; case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs index 060f54c47776a..7145ceb2e9918 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs @@ -44,11 +44,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList( - VariableDeclarator(nativeIdentifier)))); break; case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs new file mode 100644 index 0000000000000..0cc935e089746 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs @@ -0,0 +1,46 @@ +using System; +using System.Diagnostics; +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal sealed class HResultExceptionMarshaller : IMarshallingGenerator + { + private static readonly TypeSyntax NativeType = PredefinedType(Token(SyntaxKind.IntKeyword)); + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Int32); + return NativeType; + } + + // Should only be used for return value + public ParameterSyntax AsParameter(TypePositionInfo info) => throw new InvalidOperationException(); + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) => throw new InvalidOperationException(); + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + if (context.CurrentStage != StubCodeContext.Stage.Unmarshal) + yield break; + + // Marshal.ThrowExceptionForHR() + string identifier = context.GetIdentifiers(info).managed; + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + MarshallerHelpers.InteropServicesMarshalType, + IdentifierName(nameof(System.Runtime.InteropServices.Marshal.ThrowExceptionForHR))), + ArgumentList(SingletonSeparatedList( + Argument(IdentifierName(identifier)))))); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; + } + +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs index 58b225760f805..2de9b1ecc3202 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs @@ -1,6 +1,3 @@ -using System.Collections.Generic; - -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; @@ -50,15 +47,28 @@ public static ForStatementSyntax GetForLoop(string collectionIdentifier, string IdentifierName(indexerIdentifier)))); } + public static LocalDeclarationStatementSyntax DeclareWithDefault(TypeSyntax typeSyntax, string identifier) + { + // = default; + return LocalDeclarationStatement( + VariableDeclaration( + typeSyntax, + SingletonSeparatedList( + VariableDeclarator(identifier) + .WithInitializer( + EqualsValueClause( + LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); + } + public static class StringMarshaller { public static ExpressionSyntax AllocationExpression(CharEncoding encoding, string managedIdentifier) { string methodName = encoding switch { - CharEncoding.Utf8 => "StringToCoTaskMemUTF8", - CharEncoding.Utf16 => "StringToCoTaskMemUni", - CharEncoding.Ansi => "StringToCoTaskMemAnsi", + CharEncoding.Utf8 => "StringToCoTaskMemUTF8", // Not in .NET Standard 2.0, so we use the hard-coded name + CharEncoding.Utf16 => nameof(System.Runtime.InteropServices.Marshal.StringToCoTaskMemUni), + CharEncoding.Ansi => nameof(System.Runtime.InteropServices.Marshal.StringToCoTaskMemAnsi), _ => throw new System.ArgumentOutOfRangeException(nameof(encoding)) }; @@ -84,7 +94,7 @@ public static ExpressionSyntax FreeExpression(string nativeIdentifier) MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, InteropServicesMarshalType, - IdentifierName("FreeCoTaskMem")), + IdentifierName(nameof(System.Runtime.InteropServices.Marshal.FreeCoTaskMem))), ArgumentList(SingletonSeparatedList( Argument( CastExpression( diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index c5a4f4a57d453..57b26e56730e3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -110,6 +110,7 @@ internal class MarshallingGenerators public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); public static readonly SafeHandleMarshaller SafeHandle = new SafeHandleMarshaller(); + public static readonly HResultExceptionMarshaller HResultException = new HResultExceptionMarshaller(); /// /// Create an instance to marshalling the supplied type. @@ -126,8 +127,9 @@ public static IMarshallingGenerator Create( #else if (info.IsNativeReturnPosition && !info.IsManagedReturnPosition) { - // [TODO] Use marshaller for native HRESULT return / exception throwing - // Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Int32) + // Use marshaller for native HRESULT return / exception throwing + System.Diagnostics.Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Int32); + return HResultException; } switch (info) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs index b4966aa0dfe7a..6fe2811efcbdd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs @@ -16,6 +16,8 @@ internal class NonBlittableArrayMarshaller : ConditionalStackallocMarshallingGen /// private const int StackAllocBytesThreshold = 0x200; + private const string IndexerIdentifier = "__i"; + private IMarshallingGenerator _elementMarshaller; private readonly ExpressionSyntax _numElementsExpr; @@ -66,11 +68,6 @@ public override IEnumerable Generate(TypePositionInfo info, Stu switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); - if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) yield return conditionalAllocSetup; @@ -87,12 +84,11 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } // Iterate through the elements of the array to marshal them - string indexerIdentifier = "i"; - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, indexerIdentifier, context); + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context); yield return IfStatement(BinaryExpression(SyntaxKind.NotEqualsExpression, IdentifierName(managedIdentifer), LiteralExpression(SyntaxKind.NullLiteralExpression)), - MarshallerHelpers.GetForLoop(managedIdentifer, indexerIdentifier) + MarshallerHelpers.GetForLoop(managedIdentifer, IndexerIdentifier) .WithStatement(Block( List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext))))); } @@ -100,8 +96,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu case StubCodeContext.Stage.Unmarshal: if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { - string indexerIdentifier = "i"; - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, indexerIdentifier, context); + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context); yield return IfStatement( BinaryExpression(SyntaxKind.NotEqualsExpression, @@ -117,7 +112,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu SingletonList(ArrayRankSpecifier( SingletonSeparatedList(_numElementsExpr))))))), // Iterate through the elements of the native array to unmarshal them - MarshallerHelpers.GetForLoop(managedIdentifer, indexerIdentifier) + MarshallerHelpers.GetForLoop(managedIdentifer, IndexerIdentifier) .WithStatement(Block( List(_elementMarshaller.Generate( info with { ManagedType = GetElementTypeSymbol(info) }, @@ -130,8 +125,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu break; case StubCodeContext.Stage.Cleanup: { - string indexerIdentifier = "i"; - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, indexerIdentifier, context); + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context); var elementCleanup = List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext)); if (elementCleanup.Count != 0) { @@ -140,7 +134,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu BinaryExpression(SyntaxKind.NotEqualsExpression, IdentifierName(managedIdentifer), LiteralExpression(SyntaxKind.NullLiteralExpression)), - MarshallerHelpers.GetForLoop(managedIdentifer, indexerIdentifier) + MarshallerHelpers.GetForLoop(managedIdentifer, IndexerIdentifier) .WithStatement(Block(elementCleanup))); } yield return GenerateConditionalAllocationFreeSyntax(info, context); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index c9b7972fe7e9d..1ecece16c8144 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -9,9 +9,11 @@ namespace Microsoft.Interop { internal class SafeHandleMarshaller : IMarshallingGenerator { + private static readonly TypeSyntax NativeType = ParseTypeName("global::System.IntPtr"); + public TypeSyntax AsNativeType(TypePositionInfo info) { - return ParseTypeName("global::System.IntPtr"); + return NativeType; } public ParameterSyntax AsParameter(TypePositionInfo info) @@ -64,11 +66,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList( - VariableDeclarator(nativeIdentifier)))); if (!info.IsManagedReturnPosition && info.RefKind != RefKind.Out) { yield return LocalDeclarationStatement( @@ -79,7 +76,19 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); } - if (info.IsByRef && info.RefKind != RefKind.In) + if (info.IsManagedReturnPosition) + { + yield return ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + GenericName(Identifier("CreateSafeHandle"), + TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), + ArgumentList()))); + } + else if (info.IsByRef && info.RefKind != RefKind.In) { // We create the new handle in the Setup phase // so we eliminate the possible failure points during unmarshalling, where we would @@ -95,30 +104,21 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), GenericName(Identifier("CreateSafeHandle"), TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), - ArgumentList())))))); - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList( - VariableDeclarator(handleValueBackupIdentifier) - .WithInitializer(EqualsValueClause( - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(newHandleObjectIdentifier), - IdentifierName(nameof(SafeHandle.DangerousGetHandle))), ArgumentList())))))); - } - else if (info.IsManagedReturnPosition) - { - yield return ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifier), - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), - GenericName(Identifier("CreateSafeHandle"), - TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), - ArgumentList()))); + if (info.RefKind != RefKind.Out) + { + yield return LocalDeclarationStatement( + VariableDeclaration( + AsNativeType(info), + SingletonSeparatedList( + VariableDeclarator(handleValueBackupIdentifier) + .WithInitializer(EqualsValueClause( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(newHandleObjectIdentifier), + IdentifierName(nameof(SafeHandle.DangerousGetHandle))), + ArgumentList())))))); + } } break; case StubCodeContext.Stage.Marshal: @@ -169,7 +169,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont Argument(IdentifierName(nativeIdentifier)) })))); - if(info.IsManagedReturnPosition) + if (info.IsManagedReturnPosition) { yield return unmarshalStatement; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs index 7192bb545a2c2..47392b5bcf889 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs @@ -60,12 +60,6 @@ public override IEnumerable Generate(TypePositionInfo info, Stu switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - // byte* ; - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); - if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) yield return conditionalAllocSetup; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs index b4c74c647d34e..aa3d6ff83452c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs @@ -63,13 +63,6 @@ public override IEnumerable Generate(TypePositionInfo info, Stu switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - // void* - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(context.GetIdentifiers(info).native) - .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.NullLiteralExpression)))))); - if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) yield return conditionalAllocSetup; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs index 40c51d9b2f68e..69e7fa146f3a0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -84,12 +84,6 @@ public override IEnumerable Generate(TypePositionInfo info, Stu switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - // ushort* - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); - if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) yield return conditionalAllocSetup; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs index c9c25468b4b20..88172c2378240 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs @@ -57,11 +57,6 @@ public override IEnumerable Generate(TypePositionInfo info, Stu switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - yield return LocalDeclarationStatement( - VariableDeclaration( - AsNativeType(info), - SingletonSeparatedList(VariableDeclarator(nativeIdentifier)))); - if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) yield return conditionalAllocSetup; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index aaa893dad2dd2..7b5dc53f92290 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -46,12 +46,14 @@ internal sealed class StubCodeGenerator : StubCodeContext private readonly GeneratorDiagnostics diagnostics; private readonly IMethodSymbol stubMethod; + private readonly DllImportStub.GeneratedDllImportData dllImportData; private readonly IEnumerable paramsTypeInfo; private readonly List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> paramMarshallers; private readonly (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) retMarshaller; public StubCodeGenerator( IMethodSymbol stubMethod, + DllImportStub.GeneratedDllImportData dllImportData, IEnumerable paramsTypeInfo, TypePositionInfo retTypeInfo, GeneratorDiagnostics generatorDiagnostics) @@ -59,6 +61,7 @@ public StubCodeGenerator( Debug.Assert(retTypeInfo.IsNativeReturnPosition); this.stubMethod = stubMethod; + this.dllImportData = dllImportData; this.paramsTypeInfo = paramsTypeInfo.ToList(); this.diagnostics = generatorDiagnostics; @@ -108,7 +111,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo public (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSyntax() { string dllImportName = stubMethod.Name + "__PInvoke__"; - var statements = new List(); + var setupStatements = new List(); if (retMarshaller.Generator.UsesNativeIdentifier(retMarshaller.TypeInfo, this)) { @@ -119,17 +122,23 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo foreach (var marshaller in paramMarshallers) { TypePositionInfo info = marshaller.TypeInfo; - if (info.RefKind != RefKind.Out || info.IsManagedReturnPosition) + if (info.IsManagedReturnPosition) continue; - // Assign out params to default - statements.Add(ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(info.InstanceIdentifier), - LiteralExpression( - SyntaxKind.DefaultLiteralExpression, - Token(SyntaxKind.DefaultKeyword))))); + if (info.RefKind == RefKind.Out) + { + // Assign out params to default + setupStatements.Add(ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(info.InstanceIdentifier), + LiteralExpression( + SyntaxKind.DefaultLiteralExpression, + Token(SyntaxKind.DefaultKeyword))))); + } + + // Declare variables for parameters + AppendVariableDeclations(setupStatements, info, marshaller.Generator); } bool invokeReturnsVoid = retMarshaller.TypeInfo.ManagedType.SpecialType == SpecialType.System_Void; @@ -138,31 +147,36 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo // Stub return is not the same as invoke return if (!stubReturnsVoid && !retMarshaller.TypeInfo.IsManagedReturnPosition) { - Debug.Assert(paramMarshallers.Any() && paramMarshallers.Last().TypeInfo.IsManagedReturnPosition); - - // Declare variable for stub return value - TypePositionInfo info = paramMarshallers.Last().TypeInfo; - statements.Add(LocalDeclarationStatement( - VariableDeclaration( - info.ManagedType.AsTypeSyntax(), - SingletonSeparatedList( - VariableDeclarator(this.GetIdentifiers(info).managed))))); + // Should only happen when PreserveSig=false + Debug.Assert(!dllImportData.PreserveSig, "Expected PreserveSig=false when invoke return is not the stub return"); + + // Stub return should be the last parameter for the invoke + Debug.Assert(paramMarshallers.Any() && paramMarshallers.Last().TypeInfo.IsManagedReturnPosition, "Expected stub return to be the last parameter for the invoke"); + + (TypePositionInfo stubRetTypeInfo, IMarshallingGenerator stubRetGenerator) = paramMarshallers.Last(); + if (stubRetGenerator.UsesNativeIdentifier(stubRetTypeInfo, this)) + { + // Update the native identifier for the return value + ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; + } + + // Declare variables for stub return value + AppendVariableDeclations(setupStatements, stubRetTypeInfo, stubRetGenerator); } if (!invokeReturnsVoid) { - // Declare variable for invoke return value - statements.Add(LocalDeclarationStatement( - VariableDeclaration( - retMarshaller.TypeInfo.ManagedType.AsTypeSyntax(), - SingletonSeparatedList( - VariableDeclarator(this.GetIdentifiers(retMarshaller.TypeInfo).managed))))); + // Declare variables for invoke return value + AppendVariableDeclations(setupStatements, retMarshaller.TypeInfo, retMarshaller.Generator); } + var tryStatements = new List(); + var finallyStatements = new List(); var invoke = InvocationExpression(IdentifierName(dllImportName)); var fixedStatements = new List(); foreach (var stage in Stages) { + var statements = GetStatements(stage); int initialCount = statements.Count; this.CurrentStage = stage; @@ -248,12 +262,24 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } } + List allStatements = setupStatements; + if (finallyStatements.Count > 0) + { + // Add try-finally block if there are any statements in the finally block + allStatements.Add( + TryStatement(Block(tryStatements), default, FinallyClause(Block(finallyStatements)))); + } + else + { + allStatements.AddRange(tryStatements); + } + // Return if (!stubReturnsVoid) - statements.Add(ReturnStatement(IdentifierName(ReturnIdentifier))); + allStatements.Add(ReturnStatement(IdentifierName(ReturnIdentifier))); // Wrap all statements in an unsafe block - var codeBlock = Block(UnsafeStatement(Block(statements))); + var codeBlock = Block(UnsafeStatement(Block(allStatements))); // Define P/Invoke declaration var dllImport = MethodDeclaration(retMarshaller.Generator.AsNativeType(retMarshaller.TypeInfo), dllImportName) @@ -270,6 +296,17 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } return (codeBlock, dllImport); + + List GetStatements(Stage stage) + { + return stage switch + { + Stage.Setup => setupStatements, + Stage.Marshal or Stage.Pin or Stage.Invoke or Stage.KeepAlive or Stage.Unmarshal => tryStatements, + Stage.GuaranteedUnmarshal or Stage.Cleanup => finallyStatements, + _ => throw new ArgumentOutOfRangeException(nameof(stage)) + }; + } } public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) @@ -283,5 +320,26 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } return null; } + + private void AppendVariableDeclations(List statementsToUpdate, TypePositionInfo info, IMarshallingGenerator generator) + { + var (managed, native) = GetIdentifiers(info); + + // Declare variable for return value + if (info.IsManagedReturnPosition || info.IsNativeReturnPosition) + { + statementsToUpdate.Add(MarshallerHelpers.DeclareWithDefault( + info.ManagedType.AsTypeSyntax(), + managed)); + } + + // Declare variable with native type for parameter or return value + if (generator.UsesNativeIdentifier(info, this)) + { + statementsToUpdate.Add(MarshallerHelpers.DeclareWithDefault( + generator.AsNativeType(info), + native)); + } + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md index bba8c946a85d2..6ff67b39ad69c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -4,16 +4,51 @@ The P/Invoke source generator is responsible for finding all methods marked with 1. [Process the symbols and metadata](#symbols-and-metadata-processing) for the method, its parameters, and its return type. 1. [Determine the marshalling generators](#marshalling-generators) that will be responsible for generating the stub code for each parameter and return -1. [Generate the stub code](#stub-code-generation) and corresponding P/Invoke +1. [Generate the stub code](#stub-code-generation) +1. [Generate the corresponding P/Invoke](#p/invoke) 1. Add the generated source to the compilation. The pipeline uses the Roslyn [Syntax APIs](https://docs.microsoft.com/dotnet/api/microsoft.codeanalysis.csharp.syntax) to create the generated code. This imposes some structure for the marshalling generators and allows for easier inspection or modification (if desired) of the generated code. ## Symbol and metadata processing -The generator processes the method's `GeneratedDllImportAttribute` data, the method's parameter and return types, and the metadata on them (e.g. [`LCIDConversionAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute), [`MarshalAsAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute), [struct marshalling attributes](StructMarshalling.md)). This information is used to determine the corresponding native type for each managed parameter/return type and how they will be marshalled. +The generator processes the method's `GeneratedDllImportAttribute` data, the method's parameter and return types, and the metadata on them (e.g. [`LCIDConversionAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute), [`MarshalAsAttribute`][MarshalAsAttribute], [struct marshalling attributes](StructMarshalling.md)). This information is used to determine the corresponding native type for each managed parameter/return type and how they will be marshalled. -A [`TypePositionInfo`](../DllImportGenerator/TypePositionInfo.cs) is created for each type that needs to be marshalled. This includes any implicit parameter/return types that are required for the P/Invoke, but not part of the managed method signature; for example, a method with `PreserveSig=false` requires an HRESULT return type and potentially an out parameter matching the managed method's return type. +A [`TypePositionInfo`](../DllImportGenerator/TypePositionInfo.cs) is created for each type that needs to be marshalled. For each parameter and return type, this captures the managed type, managed and native positions (return or index in parameter list), and marshalling information. + +The marshalling information is represented by various subclasses of [`MarshallingInfo`](../DllImportGenerator/MarshallingAttributeInfo.cs) and represents all user-defined marshalling information for the specific parameter or return type. These classes are intended to simply capture any specified marshalling information, not interpret what that information means in terms of marshalling behaviour; that is handled when determining the [marshalling generator](#marshalling-generators) for each `TypePositionInfo`. + +The processing step also includes handling any implicit parameter/return types that are required for the P/Invoke, but not part of the managed method signature; for example, a method with [`PreserveSig=false`][PreserveSig] requires an HRESULT return type and potentially an out parameter matching the managed method's return type. + +### `PreserveSig=false` + +The below signature indicates that the native function returns an HRESULT, but has no other return value (out parameter). + +```C# +[GeneratedDllImport("Lib", PreserveSig = false)] +static partial void Method(); +``` +Processing the above signature would create a `TypePositionInfo` for the HRESULT return type for native call, with properties indicating that it is in the native return position and has no managed position. The actual P/Invoke would be: + +```C# +[DllImport("Lib", EntryPoint = "Method")] +static partial int Method__PInvoke__(); +``` + +The below signature indicates that the native function returns an HRESULT and also has an out parameter to be used as the managed return value. + +```C# +[GeneratedDllImport("Lib", PreserveSig = false)] +[return: MarshalAs(UnmanagedType.U1)] +static partial bool MethodWithReturn(); +``` + +Processing the above signature would create a `TypePositionInfo` for the HRESULT return type for native call, with properties indicating that it is in the native return position and has no managed position. The `TypePositionInfo` representing the `bool` return on the managed method would have properties indicating it is the last parameter for the native call and is in the managed return position. The actual P/Invoke would be: + +```C# +[DllImport("Lib", EntryPoint = "MethodWithReturn")] +static partial int MethodWithReturn__PInvoke__(byte* retVal); +``` ## Marshalling generators @@ -25,6 +60,11 @@ The marshalling generators are responsible for generating the code for each [sta Generation of the stub code happens in stages. The marshalling generator for each parameter and return is called to generate code for each stage of the stub. The statements and syntax provided by each marshalling generator for each stage combine to form the full stub implementation. +The stub code generator itself will handle some initial setup and variable declarations: +- Assign `out` parameters to `default` +- Declare variable for managed representation of return value +- Declare variables for native representation of parameters and return value (if necessary) + ### Stages 1. `Setup`: initialization that happens before marshalling any data @@ -48,6 +88,27 @@ Generation of the stub code happens in stages. The marshalling generator for eac 1. `Cleanup`: free any allocated resources - Call `Generate` on the marshalling generator for every parameter +Generated P/Invoke structure (if no code is generated for `GuaranteedUnmarshal` and `Cleanup`, the `try-finally` is omitted): +```C# +<< Variable Declarations >> +<< Setup >> +try +{ + << Marshal >> + << Pin >> (fixed) + { + << Invoke >> + } + << Keep Alive >> + << Unmarshal >> +} +finally +{ + << GuaranteedUnmarshal >> + << Cleanup >> +} +``` + ### Stub conditional features Some marshalling optimizations are only available in specific scenarios. Generally, there are 4 basic marshalling contexts: @@ -78,7 +139,73 @@ These various scenarios have different levels of support for these three feature | non-blittable array marshalling in a P/Invoke | unsupported | unsupported (supportable with https://github.com/dotnet/runtime/issues/25423) | unuspported | | non-blittable array marshalling not in a P/Invoke | unsupported | unsupported | unuspported | - -### P/Invoke - -The P/Invoke called by the stub is created based on the user's original declaration of the stub. The signature is generated using the syntax returned by `AsNativeType` and `AsParameter` of the marshalling generators for the return and parameters. \ No newline at end of file +## P/Invoke + +The P/Invoke called by the stub is created based on the user's original declaration of the stub. The signature is generated using the syntax returned by `AsNativeType` and `AsParameter` of the marshalling generators for the return and parameters. Any marshalling attributes on the return and parameters of the managed method - [`MarshalAsAttribute`][MarshalAsAttribute], [`InAttribute`][InAttribute], [`OutAttribute`][OutAttribute] - are dropped. + +The fields of the [`DllImportAttribute`][DllImportAttribute] are set based on the fields of `GeneratedDllImportAttribute` as follows: + +| Field | Behaviour | +| ------------------------------------------------- | --------- | +| [`BestFitMapping`][BestFitMapping] | Not supported. See [Compatibility](Compatibility.md). +| [`CallingConvention`][CallingConvention] | Passed through to `DllImport`. +| [`CharSet`][CharSet] | Passed through to `DllImport`. +| [`EntryPoint`][EntryPoint] | If set, passed through to `DllImport`. If not set, explicitly set to method name. +| [`ExactSpelling`][ExactSpelling] | Passed through to `DllImport`. +| [`PreserveSig`][PreserveSig] | Handled by generated source. Not on generated `DllImport`. +| [`SetLastError`][SetLastError] | Handled by generated source. Not on generated `DllImport`. +| [`ThrowOnUnmappableChar`][ThrowOnUnmappableChar] | Not supported. See [Compatibility](Compatibility.md). + +### Examples + +Explicit `EntryPoint`: + +```C# +// Original declaration +[GeneratedDllImport("Lib")] +static partial void Method(out int i); + +// Generated P/Invoke +[DllImport("Lib", EntryPoint = "Method")] +static partial void Method__PInvoke__(int* i); +``` + +Passed through: + +```C# +// Original declaration +[GeneratedDllImport("Lib", EntryPoint = "EntryPoint", CharSet = CharSet.Unicode)] +static partial int Method(string s); + +// Generated P/Invoke +[DllImport("Lib", EntryPoint = "EntryPoint", CharSet = CharSet.Unicode)] +static partial int Method__PInvoke__(ushort* s); +``` + +Handled by generated source (dropped from `DllImport`): + +```C# +// Original declaration +[GeneratedDllImport("Lib", SetLastError = true)] +[return: [MarshalAs(UnmanagedType.U1)] +static partial bool Method([In][MarshasAs(UnmanagedType.LPWStr)] string s); + +// Generated P/Invoke +[DllImport("Lib", EntryPoint = "Method")] +static partial byte Method__PInvoke__(ushort* s); +``` + + +[DllImportAttribute]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute +[MarshalAsAttribute]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute +[InAttribute]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.inattribute +[OutAttribute]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.outattribute + +[BestFitMapping]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.bestfitmapping +[CallingConvention]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.callingconvention +[CharSet]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.charset +[EntryPoint]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.entrypoint +[ExactSpelling]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.exactspelling +[PreserveSig]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig +[SetLastError]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.setlasterror +[ThrowOnUnmappableChar]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.throwonunmappablechar diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs new file mode 100644 index 0000000000000..2422192a9a307 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs @@ -0,0 +1,264 @@ +using System; +using System.Runtime.InteropServices; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public partial class PreserveSig + { + public partial class False + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_return", PreserveSig = false)] + public static partial void NoReturnValue(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + public static partial void Int_Out(int i, out int ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + public static partial int Int_AsReturn(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + public static partial void Bool_Out(int i, [MarshalAs(UnmanagedType.U4)] out bool ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [return: MarshalAs(UnmanagedType.U4)] + public static partial bool Bool_AsReturn(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort", PreserveSig = false)] + public static partial void Char_Out(int i, [MarshalAs(UnmanagedType.U2)] out char ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort", PreserveSig = false)] + [return: MarshalAs(UnmanagedType.U2)] + public static partial char Char_AsReturn(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] + public static partial void String_Out(int i, [MarshalAs(UnmanagedType.LPWStr)] out string ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] + [return: MarshalAs(UnmanagedType.LPWStr)] + public static partial string String_AsReturn(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int_array", PreserveSig = false)] + public static partial void IntArray_Out(int i, [MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(int))] out int[] ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int_array", PreserveSig = false)] + [return: MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(int))] + public static partial int[] IntArray_AsReturn(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] + public static partial void StringArray_Out(int i, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = sizeof(int))] out string[] ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] + [return: MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = sizeof(int))] + public static partial string[] StringArray_AsReturn(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_handle", PreserveSig = false)] + public static partial void SafeHandle_Out(int hr, out DummySafeHandle ret); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_handle", PreserveSig = false)] + public static partial DummySafeHandle SafeHandle_AsReturn(int hr); + + } + + public class DummySafeHandle : Microsoft.Win32.SafeHandles.SafeHandleMinusOneIsInvalid + { + private DummySafeHandle() : base(ownsHandle: true) { } + protected override bool ReleaseHandle() => true; + } + + public partial class True + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_return", PreserveSig = true)] + public static partial int NoReturnValue(int i); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = true)] + public static partial int Int_Out(int i, out int ret); + } + } + } + + public class PreserveSigTests + { + private const int E_INVALIDARG = unchecked((int)0x80070057); + private const int COR_E_NOTSUPPORTED = unchecked((int)0x80131515); + private const int S_OK = 0; + private const int S_FALSE = 1; + + [Theory] + [InlineData(E_INVALIDARG)] + [InlineData(COR_E_NOTSUPPORTED)] + [InlineData(-1)] + public void PreserveSigFalse_Error(int input) + { + Exception exception = Marshal.GetExceptionForHR(input); + Assert.NotNull(exception); + + int expectedHR = input; + var exceptionType = exception.GetType(); + Assert.Equal(expectedHR, exception.HResult); + Exception ex; + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.NoReturnValue(input)); + Assert.Equal(expectedHR, ex.HResult); + + { + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.Int_Out(input, out int ret)); + Assert.Equal(expectedHR, ex.HResult); + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.Int_AsReturn(input)); + Assert.Equal(expectedHR, ex.HResult); + } + { + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.Bool_Out(input, out bool ret)); + Assert.Equal(expectedHR, ex.HResult); + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.Bool_AsReturn(input)); + Assert.Equal(expectedHR, ex.HResult); + } + { + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.Char_Out(input, out char ret)); + Assert.Equal(expectedHR, ex.HResult); + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.Char_AsReturn(input)); + Assert.Equal(expectedHR, ex.HResult); + } + { + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.String_Out(input, out string ret)); + Assert.Equal(expectedHR, ex.HResult); + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.String_AsReturn(input)); + Assert.Equal(expectedHR, ex.HResult); + } + { + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.IntArray_Out(input, out int[] ret)); + Assert.Equal(expectedHR, ex.HResult); + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.IntArray_AsReturn(input)); + Assert.Equal(expectedHR, ex.HResult); + } + { + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.StringArray_Out(input, out string[] ret)); + Assert.Equal(expectedHR, ex.HResult); + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.StringArray_AsReturn(input)); + Assert.Equal(expectedHR, ex.HResult); + } + { + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.SafeHandle_Out(input, out NativeExportsNE.PreserveSig.DummySafeHandle ret)); + Assert.Equal(expectedHR, ex.HResult); + + ex = Assert.Throws(exceptionType, () => NativeExportsNE.PreserveSig.False.SafeHandle_AsReturn(input)); + Assert.Equal(expectedHR, ex.HResult); + } + } + + [Theory] + [InlineData(S_OK)] + [InlineData(S_FALSE)] + [InlineData(10)] + public void PreserveSigFalse_Success(int input) + { + Assert.True(input >= 0); + + NativeExportsNE.PreserveSig.False.NoReturnValue(input); + + { + int expected = input; + + int ret; + NativeExportsNE.PreserveSig.False.Int_Out(input, out ret); + Assert.Equal(expected, ret); + + ret = NativeExportsNE.PreserveSig.False.Int_AsReturn(input); + Assert.Equal(expected, ret); + } + { + bool expected = input != 0; + + bool ret; + NativeExportsNE.PreserveSig.False.Bool_Out(input, out ret); + Assert.Equal(expected, ret); + + ret = NativeExportsNE.PreserveSig.False.Bool_AsReturn(input); + Assert.Equal(expected, ret); + } + { + char expected = (char)input; + + char ret; + NativeExportsNE.PreserveSig.False.Char_Out(input, out ret); + Assert.Equal(expected, ret); + + ret = NativeExportsNE.PreserveSig.False.Char_AsReturn(input); + Assert.Equal(expected, ret); + } + { + string expected = input.ToString(); + + string ret; + NativeExportsNE.PreserveSig.False.String_Out(input, out ret); + Assert.Equal(expected, ret); + + ret = NativeExportsNE.PreserveSig.False.String_AsReturn(input); + Assert.Equal(expected, ret); + } + { + int[] expected = new int[sizeof(int)]; + Array.Fill(expected, input); + + int[] ret; + NativeExportsNE.PreserveSig.False.IntArray_Out(input, out ret); + Assert.Equal(expected, ret); + + ret = NativeExportsNE.PreserveSig.False.IntArray_AsReturn(input); + Assert.Equal(expected, ret); + } + { + string[] expected = new string[sizeof(int)]; + Array.Fill(expected, input.ToString()); + + string[] ret; + NativeExportsNE.PreserveSig.False.StringArray_Out(input, out ret); + Assert.Equal(expected, ret); + + ret = NativeExportsNE.PreserveSig.False.StringArray_AsReturn(input); + Assert.Equal(expected, ret); + } + { + nint expected = input; + + NativeExportsNE.PreserveSig.DummySafeHandle ret; + NativeExportsNE.PreserveSig.False.SafeHandle_Out(input, out ret); + Assert.Equal(expected, (nint)ret.DangerousGetHandle()); + ret.Dispose(); + + ret = NativeExportsNE.PreserveSig.False.SafeHandle_AsReturn(input); + Assert.Equal(expected, (nint)ret.DangerousGetHandle()); + ret.Dispose(); + } + } + + [Theory] + [InlineData(S_OK)] + [InlineData(S_FALSE)] + [InlineData(E_INVALIDARG)] + [InlineData(COR_E_NOTSUPPORTED)] + [InlineData(-1)] + public void PreserveSigTrue(int input) + { + int expected = input; + int hr; + + hr = NativeExportsNE.PreserveSig.True.NoReturnValue(input); + Assert.Equal(expected, hr); + + int ret; + hr = NativeExportsNE.PreserveSig.True.Int_Out(input, out ret); + Assert.Equal(expected, hr); + Assert.Equal(expected, ret); + } + } +} 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 10a17c70af78c..e5df7449b3c59 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -206,8 +206,8 @@ partial class Test CharSet = (CharSet)2, EntryPoint = EntryPointName, ExactSpelling = 0 != 1, - PreserveSig = IsFalse, - SetLastError = IsTrue)] + PreserveSig = IsTrue, + SetLastError = IsFalse)] public static partial void Method1(); [GeneratedDllImport(nameof(Test), @@ -501,5 +501,20 @@ public static partial void Method( }}"; public static string ArrayParameterWithNestedMarshalInfo(UnmanagedType nestedMarshalType) => ArrayParameterWithNestedMarshalInfo(typeof(T).ToString(), nestedMarshalType); + + public static string ArrayPreserveSigFalse(string elementType) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"", PreserveSig = false)] + [return:MarshalAs(UnmanagedType.LPArray, SizeConst=10)] + public static partial {elementType}[] Method1(); + + [GeneratedDllImport(""DoesNotExist"", PreserveSig = false)] + [return:MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] + public static partial {elementType}[] Method2(int i); +}}"; + + public static string ArrayPreserveSigFalse() => ArrayPreserveSigFalse(typeof(T).ToString()); } } 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 50e430b22de10..5146414748788 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -41,7 +41,8 @@ public static IEnumerable CodeSnippetsToCompile() // Unsupported named arguments // * BestFitMapping, ThrowOnUnmappableChar - yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 2, 0 }; + // [TODO]: Expected diagnostic count should be 2 once we support SetLastError + yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 3, 0 }; // LCIDConversion yield return new object[] { CodeSnippets.LCIDConversionAttribute, 1, 0 }; 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 15707f0b8d398..d41dc38eb183b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -17,9 +17,11 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.NestedNamespace }; yield return new[] { CodeSnippets.NestedTypes }; yield return new[] { CodeSnippets.UserDefinedEntryPoint }; - yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; + //yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; yield return new[] { CodeSnippets.DefaultParameters }; yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; + + // Parameter / return types yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; @@ -33,6 +35,8 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + + // Arrays yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; @@ -66,10 +70,14 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(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) }; + + // MarshalAs yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.Bool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.VariantBool) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; @@ -82,7 +90,11 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPWStr) }; yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPUTF8Str) }; yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; + + // Enums yield return new[] { CodeSnippets.EnumParameters }; + + // Pointers yield return new[] { CodeSnippets.PointerParameters() }; yield return new[] { CodeSnippets.PointerParameters() }; yield return new[] { CodeSnippets.PointerParameters() }; @@ -96,6 +108,19 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.PointerParameters() }; yield return new[] { CodeSnippets.PointerParameters() }; yield return new[] { CodeSnippets.PointerParameters() }; + + // Delegates + yield return new[] { CodeSnippets.DelegateParametersAndModifiers }; + yield return new[] { CodeSnippets.DelegateMarshalAsParametersAndModifiers }; + + // Structs + yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; + yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; + + // SafeHandle + yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + + // PreserveSig yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; @@ -110,45 +135,25 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - //yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.DelegateParametersAndModifiers }; - yield return new[] { CodeSnippets.DelegateMarshalAsParametersAndModifiers }; - yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; - yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; - yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + yield return new[] { CodeSnippets.PreserveSigFalse("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; } public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() { - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; - yield return new[] { CodeSnippets.PreserveSigFalse() }; + yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs new file mode 100644 index 0000000000000..f960887e747f5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs @@ -0,0 +1,67 @@ +using System; +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class HResult + { + [UnmanagedCallersOnly(EntryPoint = "hresult_return")] + public static int Return(int hr) + { + return hr; + } + + [UnmanagedCallersOnly(EntryPoint = "hresult_out_int")] + public static int ReturnAsOutInt(int hr, int* ret) + { + *ret = hr; + return hr; + } + + [UnmanagedCallersOnly(EntryPoint = "hresult_out_ushort")] + public static int ReturnAsOutShort(int hr, ushort* ret) + { + *ret = (ushort)hr; + return hr; + } + + [UnmanagedCallersOnly(EntryPoint = "hresult_out_ushort_string")] + public static int ReturnAsOutString(int hr, ushort** ret) + { + string str = hr.ToString(); + *ret = (ushort*)Marshal.StringToCoTaskMemUni(str); + return hr; + } + + [UnmanagedCallersOnly(EntryPoint = "hresult_out_int_array")] + public static int ReturnAsOutIntArray(int hr, int** ret) + { + const int NumBytesInInt = sizeof(int); + *ret = (int*)Marshal.AllocCoTaskMem(sizeof(int) * NumBytesInInt); + new Span(*ret, NumBytesInInt).Fill(hr); + return hr; + } + + [UnmanagedCallersOnly(EntryPoint = "hresult_out_ushort_string_array")] + public static int ReturnAsOutStringArray(int hr, ushort*** ret) + { + const int NumBytesInInt = sizeof(int); + string str = hr.ToString(); + + *ret = (ushort**)Marshal.AllocCoTaskMem(sizeof(ushort*) * NumBytesInInt); + for (int i = 0; i < NumBytesInInt; i++) + { + (*ret)[i] = (ushort*)Marshal.StringToCoTaskMemUni(str); + } + + return hr; + } + + [UnmanagedCallersOnly(EntryPoint = "hresult_out_handle")] + public static int ReturnAsOutHandle(int hr, nint* handle) + { + *handle = hr; + return hr; + } + } +} From 80349fb3dfd0ea303aaa03eb1152b2663b96c47d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 19 Nov 2020 10:50:16 -0800 Subject: [PATCH 049/161] Implement the non-blittable type marshalling proposal (dotnet/runtimelab#302) Commit migrated from https://github.com/dotnet/runtimelab/commit/fee212a30a6b4aa468fb28a403c86e622988e3bc --- .../AnalyzerReleases.Unshipped.md | 1 + .../Analyzers/AnalyzerDiagnostics.cs | 1 + .../ManualTypeMarshallingAnalyzer.cs | 71 ++-- .../ManualTypeMarshallingHelper.cs | 3 +- .../Marshalling/CustomNativeTypeMarshaller.cs | 270 ++++++++++++++ .../Marshalling/MarshallingGenerator.cs | 94 ++++- .../MarshallingAttributeInfo.cs | 5 +- .../DllImportGenerator/Resources.Designer.cs | 36 ++ .../gen/DllImportGenerator/Resources.resx | 12 + .../DllImportGenerator/TypePositionInfo.cs | 11 +- .../TypeSymbolExtensions.cs | 5 + .../DllImportGenerator/StructMarshalling.md | 29 +- .../CustomMarshallingTests.cs | 172 +++++++++ .../CodeSnippets.cs | 351 +++++++++++++++++- .../CompileFails.cs | 7 + .../DllImportGenerator.UnitTests/Compiles.cs | 10 + .../ManualTypeMarshallingAnalyzerTests.cs | 98 ++++- .../NativeExports/CustomMarshalling.cs | 63 ++++ .../TestAssets/SharedTypes/NonBlittable.cs | 200 ++++++++++ .../TestAssets/SharedTypes/SharedTypes.csproj | 1 + 20 files changed, 1387 insertions(+), 53 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md index 08bea59ab561b..69b50f973213f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md @@ -18,3 +18,4 @@ DLLIMPORTGENANALYZER010 | Usage | Warning | GetPinnableReferenceShou DLLIMPORTGENANALYZER011 | Usage | Warning | StackallocMarshallingShouldSupportAllocatingMarshallingFallback DLLIMPORTGENANALYZER012 | Usage | Error | StackallocConstructorMustHaveStackBufferSizeConstant DLLIMPORTGENANALYZER013 | Usage | Warning | GeneratedDllImportMissingRequiredModifiers +DLLIMPORTGENANALYZER014 | Usage | Error | RefValuePropertyUnsupported diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs index 6bc7db892db43..84ef67fab449f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs @@ -24,6 +24,7 @@ public static class Ids public const string GetPinnableReferenceShouldSupportAllocatingMarshallingFallback = Prefix + "010"; public const string StackallocMarshallingShouldSupportAllocatingMarshallingFallback = Prefix + "011"; public const string StackallocConstructorMustHaveStackBufferSizeConstant = Prefix + "012"; + public const string RefValuePropertyUnsupported = Prefix + "014"; // GeneratedDllImport public const string GeneratedDllImportMissingRequiredModifiers = Prefix + "013"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 2d9c0669ea773..2a00d1efa5feb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -134,6 +134,16 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantDescription))); + public readonly static DiagnosticDescriptor RefValuePropertyUnsupportedRule = + new DiagnosticDescriptor( + Ids.RefValuePropertyUnsupported, + "RefValuePropertyUnsupported", + GetResourceString(nameof(Resources.RefValuePropertyUnsupportedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.RefValuePropertyUnsupportedDescription))); + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create( BlittableTypeMustBeBlittableRule, @@ -147,7 +157,8 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer ValuePropertyMustHaveGetterRule, GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, - StackallocConstructorMustHaveStackBufferSizeConstantRule); + StackallocConstructorMustHaveStackBufferSizeConstantRule, + RefValuePropertyUnsupportedRule); public override void Initialize(AnalysisContext context) { @@ -242,7 +253,7 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) } else if (nativeMarshallingAttributeData is not null) { - AnalyzeNativeMarshalerType(context, type, nativeMarshallingAttributeData, validateGetPinnableReference: true, validateAllScenarioSupport: true); + AnalyzeNativeMarshalerType(context, type, nativeMarshallingAttributeData, validateManagedGetPinnableReference: true, validateAllScenarioSupport: true); } } @@ -283,7 +294,7 @@ public void AnalyzeReturnType(SymbolAnalysisContext context) } } - private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymbol type, AttributeData nativeMarshalerAttributeData, bool validateGetPinnableReference, bool validateAllScenarioSupport) + private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymbol type, AttributeData nativeMarshalerAttributeData, bool validateManagedGetPinnableReference, bool validateAllScenarioSupport) { if (nativeMarshalerAttributeData.ConstructorArguments[0].IsNull) { @@ -342,6 +353,14 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb } IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); + bool valuePropertyIsRefReturn = valueProperty is { ReturnsByRef : true } or { ReturnsByRefReadonly: true }; + + if (valuePropertyIsRefReturn) + { + context.ReportDiagnostic(Diagnostic.Create(RefValuePropertyUnsupportedRule, GetSyntaxReferenceForDiagnostic(valueProperty!).GetSyntax().GetLocation(), + marshalerType.ToDisplayString())); + } + if (valueProperty is not null) { nativeType = valueProperty.Type; @@ -370,34 +389,42 @@ valueProperty is not null type.ToDisplayString())); } - IMethodSymbol? getPinnableReferenceMethod = type.GetMembers("GetPinnableReference") - .OfType() - .FirstOrDefault(m => m is { Parameters: { Length: 0 } } and ({ ReturnsByRef: true } or { ReturnsByRefReadonly: true })); - if (validateGetPinnableReference && getPinnableReferenceMethod is not null) + IMethodSymbol? managedGetPinnableReferenceMethod = ManualTypeMarshallingHelper.FindGetPinnableReference(type); + if (validateManagedGetPinnableReference && managedGetPinnableReferenceMethod is not null) { - if (!getPinnableReferenceMethod.ReturnType.IsConsideredBlittable()) + if (!managedGetPinnableReferenceMethod.ReturnType.IsConsideredBlittable()) + { + context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceReturnTypeBlittableRule, managedGetPinnableReferenceMethod.DeclaringSyntaxReferences[0].GetSyntax().GetLocation())); + } + // Validate that our marshaler supports scenarios where GetPinnableReference cannot be used. + if (validateAllScenarioSupport && (!hasConstructor || valueProperty is { GetMethod: null })) { - context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceReturnTypeBlittableRule, getPinnableReferenceMethod.DeclaringSyntaxReferences[0].GetSyntax().GetLocation())); + context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); } + } + + if ((validateManagedGetPinnableReference && managedGetPinnableReferenceMethod is not null) + || ManualTypeMarshallingHelper.FindGetPinnableReference(marshalerType) is not null) + { // Validate that the Value property is a pointer-sized primitive type. - if (valueProperty is null || - valueProperty.Type is not ( + if (valueProperty is null + || (valueProperty.Type is not ( IPointerTypeSymbol _ or { SpecialType: SpecialType.System_IntPtr } or - { SpecialType: SpecialType.System_UIntPtr })) + { SpecialType: SpecialType.System_UIntPtr }))) { + ITypeSymbol typeWithGetPinnableReference = managedGetPinnableReferenceMethod is not null + ? type + : marshalerType; + context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustBePointerSizedRule, valueProperty is not null - ? GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation() - : GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), - nativeType.ToDisplayString(), - type.ToDisplayString())); - } - - // Validate that our marshaler supports scenarios where GetPinnableReference cannot be used. - if (validateAllScenarioSupport && (!hasConstructor || valueProperty is { GetMethod: null })) - { - context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + ? GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation() + : GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), + valuePropertyIsRefReturn + ? $"ref {nativeType.ToDisplayString()}" + : nativeType.ToDisplayString(), + typeWithGetPinnableReference.ToDisplayString())); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs index 665e14a80b856..eb825f1c7a619 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs @@ -7,6 +7,7 @@ namespace Microsoft.Interop static class ManualTypeMarshallingHelper { public const string ValuePropertyName = "Value"; + public const string GetPinnableReferenceName = "GetPinnableReference"; public const string StackBufferSizeFieldName = "StackBufferSize"; public const string ToManagedMethodName = "ToManaged"; public const string FreeNativeMethodName = "FreeNative"; @@ -44,7 +45,7 @@ public static bool IsStackallocConstructor( // fixed statement. We aren't supporting a GetPinnableReference extension method // (which is apparently supported in the compiler). // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.3/pattern-based-fixed - return type.GetMembers("GetPinnableReference") + return type.GetMembers(GetPinnableReferenceName) .OfType() .FirstOrDefault(m => m is { Parameters: { Length: 0 } } and ({ ReturnsByRef: true } or { ReturnsByRefReadonly: true })); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs new file mode 100644 index 0000000000000..4278cd6a9c9f0 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs @@ -0,0 +1,270 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + class CustomNativeTypeMarshaller : IMarshallingGenerator + { + private const string MarshalerLocalSuffix = "__marshaler"; + private readonly TypeSyntax _nativeTypeSyntax; + private readonly TypeSyntax _nativeLocalTypeSyntax; + private readonly SupportedMarshallingMethods _marshallingMethods; + private readonly bool _hasFreeNative; + private readonly bool _useValueProperty; + private readonly bool _marshalerTypePinnable; + + public CustomNativeTypeMarshaller(NativeMarshallingAttributeInfo marshallingInfo) + { + ITypeSymbol nativeType = marshallingInfo.ValuePropertyType ?? marshallingInfo.NativeMarshallingType; + _nativeTypeSyntax = ParseTypeName(nativeType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + _nativeLocalTypeSyntax = ParseTypeName(marshallingInfo.NativeMarshallingType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + _marshallingMethods = marshallingInfo.MarshallingMethods; + _hasFreeNative = ManualTypeMarshallingHelper.HasFreeNativeMethod(marshallingInfo.NativeMarshallingType); + _useValueProperty = marshallingInfo.ValuePropertyType != null; + _marshalerTypePinnable = marshallingInfo.NativeTypePinnable; + } + + public CustomNativeTypeMarshaller(GeneratedNativeMarshallingAttributeInfo marshallingInfo) + { + _nativeTypeSyntax = _nativeLocalTypeSyntax = ParseTypeName(marshallingInfo.NativeMarshallingFullyQualifiedTypeName); + _marshallingMethods = SupportedMarshallingMethods.ManagedToNative | SupportedMarshallingMethods.NativeToManaged; + _hasFreeNative = true; + _useValueProperty = false; + _marshalerTypePinnable = false; + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return _nativeTypeSyntax; + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + if (context.PinningSupported && (_marshallingMethods & SupportedMarshallingMethods.Pinning) != 0) + { + return Argument(CastExpression(AsNativeType(info), IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + string marshalerIdentifier = _useValueProperty ? nativeIdentifier + MarshalerLocalSuffix : nativeIdentifier; + if (!info.IsManagedReturnPosition + && !info.IsByRef + && context.PinningSupported + && (_marshallingMethods & SupportedMarshallingMethods.Pinning) != 0) + { + if (context.CurrentStage == StubCodeContext.Stage.Pin) + { + yield return FixedStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))), + SingletonSeparatedList( + VariableDeclarator(Identifier(nativeIdentifier)) + .WithInitializer(EqualsValueClause( + IdentifierName(managedIdentifier) + )) + ) + ), + EmptyStatement() + ); + } + yield break; + } + + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + if (_useValueProperty) + { + yield return LocalDeclarationStatement( + VariableDeclaration( + _nativeLocalTypeSyntax, + SingletonSeparatedList( + VariableDeclarator(marshalerIdentifier) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); + } + break; + case StubCodeContext.Stage.Marshal: + if (!info.IsManagedReturnPosition && info.RefKind != RefKind.Out) + { + // Stack space must be usable and the marshaler must support stackalloc to use stackalloc. + // We also require pinning to be supported to enable users to pass the stackalloc'd Span + // to native code by having the marshaler type return a byref to the Span's elements + // in its GetPinnableReference method. + bool scenarioSupportsStackalloc = context.StackSpaceUsable + && (_marshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0 + && context.PinningSupported; + + List arguments = new List + { + Argument(IdentifierName(managedIdentifier)) + }; + + if (scenarioSupportsStackalloc && (!info.IsByRef || info.RefKind == RefKind.In)) + { + string stackallocIdentifier = $"{managedIdentifier}__stackptr"; + // byte* __stackptr = stackalloc byte[<_nativeLocalType>.StackBufferSize]; + yield return LocalDeclarationStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))), + SingletonSeparatedList( + VariableDeclarator(stackallocIdentifier) + .WithInitializer(EqualsValueClause( + StackAllocArrayCreationExpression( + ArrayType( + PredefinedType(Token(SyntaxKind.ByteKeyword)), + SingletonList(ArrayRankSpecifier(SingletonSeparatedList( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + _nativeLocalTypeSyntax, + IdentifierName(ManualTypeMarshallingHelper.StackBufferSizeFieldName)) + )))))))))); + + // new Span(__stackptr, <_nativeLocalType>.StackBufferSize) + arguments.Add(Argument( + ObjectCreationExpression( + GenericName(Identifier(TypeNames.System_Span), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.ByteKeyword)))))) + .WithArgumentList( + ArgumentList(SeparatedList(new ArgumentSyntax[] + { + Argument(IdentifierName(stackallocIdentifier)), + Argument(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + _nativeLocalTypeSyntax, + IdentifierName(ManualTypeMarshallingHelper.StackBufferSizeFieldName))) + }))))); + } + + // = new <_nativeLocalType>(); + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(marshalerIdentifier), + ObjectCreationExpression(_nativeLocalTypeSyntax) + .WithArgumentList(ArgumentList(SeparatedList(arguments))))); + + bool skipValueProperty = _marshalerTypePinnable && (!info.IsByRef || info.RefKind == RefKind.In); + + if (_useValueProperty && !skipValueProperty) + { + // = .Value; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(nativeIdentifier), + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(marshalerIdentifier), + IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)))); + } + } + break; + case StubCodeContext.Stage.Pin: + if (_marshalerTypePinnable && (!info.IsByRef || info.RefKind == RefKind.In)) + { + // fixed (<_nativeTypeSyntax> = &) + yield return FixedStatement( + VariableDeclaration( + _nativeTypeSyntax, + SingletonSeparatedList( + VariableDeclarator(nativeIdentifier) + .WithInitializer(EqualsValueClause( + PrefixUnaryExpression(SyntaxKind.AddressOfExpression, + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(marshalerIdentifier), + IdentifierName(ManualTypeMarshallingHelper.GetPinnableReferenceName)), + ArgumentList())))))), + EmptyStatement()); + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + if (_useValueProperty) + { + // .Value = ; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(marshalerIdentifier), + IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)), + IdentifierName(nativeIdentifier))); + } + + // = .ToManaged(); + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(marshalerIdentifier), + IdentifierName(ManualTypeMarshallingHelper.ToManagedMethodName))))); + } + break; + case StubCodeContext.Stage.Cleanup: + if (info.RefKind != RefKind.Out && _hasFreeNative) + { + // .FreeNative(); + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(marshalerIdentifier), + IdentifierName(ManualTypeMarshallingHelper.FreeNativeMethodName)))); + } + break; + // TODO: Determine how to keep alive delegates that are in struct fields. + default: + break; + } + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + if (info.IsManagedReturnPosition || info.IsByRef && info.RefKind != RefKind.In) + { + return true; + } + if (context.PinningSupported) + { + if (!info.IsByRef && (_marshallingMethods & SupportedMarshallingMethods.Pinning) != 0) + { + return false; + } + else if (_marshalerTypePinnable) + { + return false; + } + } + return true; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 57b26e56730e3..d4c2409e61d8e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -172,26 +172,9 @@ public static IMarshallingGenerator Create( case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: return VariantBool; - case { ManagedType: { SpecialType: SpecialType.System_Char } }: - return CreateCharMarshaller(info, context); - - case { ManagedType: { SpecialType: SpecialType.System_String } }: - return CreateStringMarshaller(info, context); - case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: return Delegate; - case { MarshallingAttributeInfo: BlittableTypeAttributeInfo }: - return Blittable; - - // Marshalling in new model - case { MarshallingAttributeInfo: NativeMarshallingAttributeInfo marshalInfo }: - return Forwarder; - - // Simple marshalling with new attribute model, only have type name. - case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo(string nativeTypeName) }: - return Forwarder; - case { MarshallingAttributeInfo: SafeHandleMarshallingInfo }: if (!context.CanUseAdditionalTemporaryState) { @@ -199,16 +182,35 @@ public static IMarshallingGenerator Create( } return SafeHandle; - case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType : ITypeSymbol elementType } , MarshallingAttributeInfo: NoMarshallingInfo}: + case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType: ITypeSymbol elementType }, MarshallingAttributeInfo: NoMarshallingInfo }: return CreateArrayMarshaller(info, context, elementType, NoMarshallingInfo.Instance); - case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType : ITypeSymbol elementType } , MarshallingAttributeInfo: ArrayMarshalAsInfo marshalAsInfo }: + case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType: ITypeSymbol elementType }, MarshallingAttributeInfo: ArrayMarshalAsInfo marshalAsInfo }: if (marshalAsInfo.UnmanagedArrayType != UnmanagedArrayType.LPArray) { throw new MarshallingNotSupportedException(info, context); } return CreateArrayMarshaller(info, context, elementType, marshalAsInfo.CreateArraySubTypeMarshalAsInfo()); + // Marshalling in new model. + // Must go before the cases that do not explicitly check for marshalling info to support + // the user overridding the default marshalling rules with a MarshalUsing attribute. + case { MarshallingAttributeInfo: NativeMarshallingAttributeInfo marshalInfo }: + return CreateCustomNativeTypeMarshaller(info, context, marshalInfo); + + case { MarshallingAttributeInfo: BlittableTypeAttributeInfo }: + return Blittable; + + // Simple generated marshalling with new attribute model, only have type name. + case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo(string nativeTypeName) }: + return Forwarder; + + case { ManagedType: { SpecialType: SpecialType.System_Char } }: + return CreateCharMarshaller(info, context); + + case { ManagedType: { SpecialType: SpecialType.System_String } }: + return CreateStringMarshaller(info, context); + case { ManagedType: { SpecialType: SpecialType.System_Void } }: return Forwarder; @@ -374,5 +376,59 @@ private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info ? new BlittableArrayMarshaller(numElementsExpression) : new NonBlittableArrayMarshaller(elementMarshaller, numElementsExpression); } + + private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) + { + // The marshalling method for this type doesn't support marshalling from native to managed, + // but our scenario requires marshalling from native to managed. + if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.NativeToManaged) == 0) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingNativeToManagedUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + }; + } + // The marshalling method for this type doesn't support marshalling from managed to native by value, + // but our scenario requires marshalling from managed to native by value. + // Pinning is required for the stackalloc marshalling to enable users to safely pass the stackalloc Span's byref + // to native if we ever start using a conditional stackalloc method and cannot guarantee that the Span we provide + // the user with is backed by stack allocated memory. + else if (!info.IsByRef + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 + && !(context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) == 0) + && !(context.StackSpaceUsable && context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) == 0)) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + }; + } + // The marshalling method for this type doesn't support marshalling from managed to native by reference, + // but our scenario requires marshalling from managed to native by reference. + // "in" byref supports stack marshalling. + else if (info.RefKind == RefKind.In + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 + && !(context.StackSpaceUsable && context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0)) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + }; + } + // The marshalling method for this type doesn't support marshalling from managed to native by reference, + // but our scenario requires marshalling from managed to native by reference. + // "ref" byref marshalling doesn't support stack marshalling + else if (info.RefKind == RefKind.Ref + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + }; + } + + return new CustomNativeTypeMarshaller(marshalInfo); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 2db9549800e0e..40998a3ba64f4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -90,7 +90,7 @@ internal enum SupportedMarshallingMethods ManagedToNative = 0x1, NativeToManaged = 0x2, ManagedToNativeStackalloc = 0x4, - Pinning = 0x8 + Pinning = 0x8, } /// @@ -99,7 +99,8 @@ internal enum SupportedMarshallingMethods internal sealed record NativeMarshallingAttributeInfo( ITypeSymbol NativeMarshallingType, ITypeSymbol? ValuePropertyType, - SupportedMarshallingMethods MarshallingMethods) : MarshallingInfo; + SupportedMarshallingMethods MarshallingMethods, + bool NativeTypePinnable) : MarshallingInfo; /// /// User-applied System.Runtime.InteropServices.GeneratedMarshallingAttribute 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 62bedac0d294c..d64b2f4e427a4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -177,6 +177,24 @@ internal static string ConfigurationNotSupportedTitle { } } + /// + /// Looks up a localized string similar to The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it.. + /// + internal static string CustomTypeMarshallingManagedToNativeUnsupported { + get { + return ResourceManager.GetString("CustomTypeMarshallingManagedToNativeUnsupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it.. + /// + internal static string CustomTypeMarshallingNativeToManagedUnsupported { + get { + return ResourceManager.GetString("CustomTypeMarshallingNativeToManagedUnsupported", resourceCulture); + } + } + /// /// Looks up a localized string similar to Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'.. /// @@ -330,6 +348,24 @@ internal static string NativeTypeMustHaveRequiredShapeMessage { } } + /// + /// Looks up a localized string similar to The 'Value' property must not be a 'ref' or 'readonly ref' property.. + /// + internal static string RefValuePropertyUnsupportedDescription { + get { + return ResourceManager.GetString("RefValuePropertyUnsupportedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must not be a 'ref' or 'readonly ref' property.. + /// + internal static string RefValuePropertyUnsupportedMessage { + get { + return ResourceManager.GetString("RefValuePropertyUnsupportedMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to When constructor taking a Span<byte> is specified on the native type, the type must also have a public integer constant named StackBufferSize to provide the size of the stack-allocated buffer.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 41f62bbe62ff6..64b0a29098a36 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -156,6 +156,12 @@ Specified configuration is not supported by source-generated P/Invokes. + + The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it. + + + The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it. + Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'. @@ -207,6 +213,12 @@ The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}' + + The 'Value' property must not be a 'ref' or 'readonly ref' property. + + + The 'Value' property on the native type '{0}' must not be a 'ref' or 'readonly ref' property. + When constructor taking a Span<byte> is specified on the native type, the type must also have a public integer constant named StackBufferSize to provide the size of the stack-allocated buffer. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index e8b726fd598c1..bb9cfde5b81b9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -258,16 +258,17 @@ static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol ty return new NativeMarshallingAttributeInfo( nativeType, valueProperty?.Type, - methods); + methods, + NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null); } static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, Compilation compilation, out MarshallingInfo marshallingInfo) { var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); - if (conversion.Exists && - conversion.IsImplicit && - conversion.IsReference && - !type.IsAbstract) + if (conversion.Exists + && conversion.IsImplicit + && conversion.IsReference + && !type.IsAbstract) { marshallingInfo = new SafeHandleMarshallingInfo(); return true; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 3539cefbadc72..21a807ebbd39f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -74,6 +74,11 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) return false; } + if (type is IPointerTypeSymbol { PointedAtType: ITypeSymbol pointedAtType }) + { + return pointedAtType.IsConsideredBlittable(); + } + bool hasNativeMarshallingAttribute = false; bool hasGeneratedMarshallingAttribute = false; // [TODO]: Match attributes on full name or symbol, not just on type name. diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md index 95bbdd82d263b..a3aac4efe7bba 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md @@ -61,6 +61,29 @@ The analyzer will report an error if neither the construtor nor the ToManaged me If the native type `TNative` also has a public `Value` property, then the value of the `Value` property will be passed to native code instead of the `TNative` value itself. As a result, the type `TNative` will be allowed to be non-blittable and the type of the `Value` property will be required to be blittable. If the `Value` property is settable, then when marshalling in the native-to-managed direction, a default value of `TNative` will have its `Value` property set to the native value. If `Value` does not have a setter, then marshalling from native to managed is not supported. +A `ref` or `ref readonly` typed `Value` property is unsupported. If a ref-return is required, the type author can supply a `GetPinnableReference` method on the native type. If a `GetPinnableReference` method is supplied, then the `Value` property must have a pointer-sized primitive type. + +```csharp +[NativeMarshalling(typeof(TMarshaler))] +public struct TManaged +{ + // ... +} + +public struct TMarshaler +{ + public TNative(TManaged managed) {} + public TManaged ToManaged() {} + + public void FreeNative() {} + + public ref TNative GetPinnableReference() {} + + public TNative Value { get; set; } +} + +``` + ### Performance features #### Pinning @@ -80,7 +103,9 @@ partial struct TNative } ``` -When these members are both present, the source generator will call the two-parameter constructor with a stack-allocated buffer of `StackBufferSize` bytes when a stack-allocated buffer is usable. As this buffer is guaranteed to be stack allocated and not on the GC heap, it is safe to use `Unsafe.AsPointer` to get a pointer to the stack buffer to pass to native code. As a stack-allocated buffer is not usable in all scenarios, for example Reverse P/Invoke and struct marshalling, a one-parameter constructor must also be provided for usage in those scenarios. This may also be provided by providing a two-parameter constructor with a default value for the second parameter. +When these members are both present, the source generator will call the two-parameter constructor with a possibly stack-allocated buffer of `StackBufferSize` bytes when a stack-allocated buffer is usable. As a stack-allocated buffer is not usable in all scenarios, for example Reverse P/Invoke and struct marshalling, a one-parameter constructor must also be provided for usage in those scenarios. This may also be provided by providing a two-parameter constructor with a default value for the second parameter. + +Type authors can pass down the `stackSpace` pointer to native code by defining a `GetPinnableReference` method on the native type that returns a reference to the first element of the span. ### Usage @@ -221,7 +246,7 @@ In this case, the underlying native type would actually be an `int`, but the use > :question: Should we support transparent structures on manually annotated blittable types? If we do, we should do so in an opt-in manner to make it possible to have a `Value` property on the blittable type. -#### Special case: ComWrappers marshalling with Transparent Structures +#### Example: ComWrappers marshalling with Transparent Structures Building on this Transparent Structures support, we can also support ComWrappers marshalling with this proposal via the manually-decorated types approach: diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs new file mode 100644 index 0000000000000..1dab47e72a271 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs @@ -0,0 +1,172 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using SharedTypes; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "stringcontainer_deepduplicate")] + public static partial void DeepDuplicateStrings(StringContainer strings, out StringContainer pStringsOut); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "stringcontainer_reverse_strings")] + public static partial void ReverseStrings(ref StringContainer strings); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "get_long_bytes_as_double")] + public static partial double GetLongBytesAsDouble([MarshalUsing(typeof(DoubleToLongMarshaler))] double d); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "negate_bools")] + public static partial void NegateBools( + BoolStruct boolStruct, + out BoolStruct pBoolStructOut); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "and_bools_ref")] + [return: MarshalAs(UnmanagedType.U1)] + public static partial bool AndBoolsRef(in BoolStruct boolStruct); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "double_int_ref")] + public static partial IntWrapper DoubleIntRef(IntWrapper pInt); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort")] + public static partial void ReverseReplaceString([MarshalUsing(typeof(Utf16StringMarshaler))] ref string s); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort")] + public static partial int ReturnStringLength([MarshalUsing(typeof(Utf16StringMarshaler))] string s); + } + + public class CustomMarshallingTests + { + [Fact] + public void NonBlittableStructWithFree() + { + var stringContainer = new StringContainer + { + str1 = "Foo", + str2 = "Bar" + }; + + NativeExportsNE.DeepDuplicateStrings(stringContainer, out var stringContainer2); + + Assert.Equal(stringContainer, stringContainer2); + } + + [Fact] + public void MarshalUsing() + { + double d = 1234.56789; + + Assert.Equal(d, NativeExportsNE.GetLongBytesAsDouble(d)); + } + + [Fact] + public void NonBlittableStructWithoutAllocation() + { + var boolStruct = new BoolStruct + { + b1 = true, + b2 = false, + b3 = true + }; + + NativeExportsNE.NegateBools(boolStruct, out BoolStruct boolStructNegated); + + Assert.Equal(!boolStruct.b1, boolStructNegated.b1); + Assert.Equal(!boolStruct.b2, boolStructNegated.b2); + Assert.Equal(!boolStruct.b3, boolStructNegated.b3); + } + + [Fact] + public void GetPinnableReferenceMarshalling() + { + int originalValue = 42; + var wrapper = new IntWrapper { i = originalValue }; + + var retVal = NativeExportsNE.DoubleIntRef(wrapper); + + Assert.Equal(originalValue * 2, wrapper.i); + Assert.Equal(originalValue * 2, retVal.i); + } + + [Fact] + public void NonBlittableStructRef() + { + var stringContainer = new StringContainer + { + str1 = "Foo", + str2 = "Bar" + }; + + var expected = new StringContainer + { + str1 = ReverseUTF8Bytes(stringContainer.str1), + str2 = ReverseUTF8Bytes(stringContainer.str2) + }; + + var stringContainerCopy = stringContainer; + + NativeExportsNE.ReverseStrings(ref stringContainerCopy); + + Assert.Equal(expected, stringContainerCopy); + } + + [Theory] + [InlineData(true, true, true)] + [InlineData(true, true, false)] + [InlineData(true, false, true)] + [InlineData(true, false, false)] + [InlineData(false, true, true)] + [InlineData(false, true, false)] + [InlineData(false, false, true)] + [InlineData(false, false, false)] + public void NonBlittableStructIn(bool b1, bool b2, bool b3) + { + var container = new BoolStruct + { + b1 = b1, + b2 = b2, + b3 = b3 + }; + + Assert.Equal(b1 && b2 && b3, NativeExportsNE.AndBoolsRef(container)); + } + + [Fact] + public void NonBlittableStructStackallocPinnableNativeMarshalling() + { + string str = "Hello world!"; + Assert.Equal(str.Length, NativeExportsNE.ReturnStringLength(str)); + } + + [Fact] + public void NonBlittableStructPinnableMarshalerPassByRef() + { + string str = "Hello world!"; + string expected = ReverseChars(str); + NativeExportsNE.ReverseReplaceString(ref str); + Assert.Equal(expected, str); + } + + private static string ReverseChars(string value) + { + if (value == null) + return null; + + var chars = value.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + + private static string ReverseUTF8Bytes(string value) + { + if (value == null) + return null; + + byte[] bytes = Encoding.UTF8.GetBytes(value); + Array.Reverse(bytes); + return Encoding.UTF8.GetString(bytes); + } + } +} 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 e5df7449b3c59..3933c1528ae9e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -351,6 +351,20 @@ partial class Test out {typeName} pOut); }}"; + /// + /// Declaration with parameters. + /// + public static string BasicParametersAndModifiersNoRef(string typeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial {typeName} Method( + {typeName} p, + in {typeName} pIn, + out {typeName} pOut); +}}"; + public static string BasicParametersAndModifiers() => BasicParametersAndModifiers(typeof(T).ToString()); /// @@ -501,7 +515,7 @@ public static partial void Method( }}"; public static string ArrayParameterWithNestedMarshalInfo(UnmanagedType nestedMarshalType) => ArrayParameterWithNestedMarshalInfo(typeof(T).ToString(), nestedMarshalType); - + public static string ArrayPreserveSigFalse(string elementType) => $@" using System.Runtime.InteropServices; partial class Test @@ -516,5 +530,340 @@ partial class Test }}"; public static string ArrayPreserveSigFalse() => ArrayPreserveSigFalse(typeof(T).ToString()); + + /// + /// Declaration with parameters with MarshalAs. + /// + public static string MarshalUsingParametersAndModifiers(string typeName, string nativeTypeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalUsing(typeof({nativeTypeName}))] + public static partial {typeName} Method( + [MarshalUsing(typeof({nativeTypeName}))] {typeName} p, + [MarshalUsing(typeof({nativeTypeName}))] in {typeName} pIn, + [MarshalUsing(typeof({nativeTypeName}))] ref {typeName} pRef, + [MarshalUsing(typeof({nativeTypeName}))] out {typeName} pOut); +}} +"; + + public static string CustomStructMarshallingParametersAndModifiers = BasicParametersAndModifiers("S") + @" +[NativeMarshalling(typeof(Native))] +struct S +{ + public bool b; +} + +struct Native +{ + private int i; + public Native(S s) + { + i = s.b ? 1 : 0; + } + + public S ToManaged() => new S { b = i != 0 }; +} +"; + + public static string CustomStructMarshallingMarshalUsingParametersAndModifiers = MarshalUsingParametersAndModifiers("S", "Native") + @" +struct S +{ + public bool b; +} + +struct Native +{ + private int i; + public Native(S s) + { + i = s.b ? 1 : 0; + } + + public S ToManaged() => new S { b = i != 0 }; +} +"; + + public static string CustomStructMarshallingStackallocParametersAndModifiersNoRef = BasicParametersAndModifiersNoRef("S") + @" +[NativeMarshalling(typeof(Native))] +struct S +{ + public bool b; +} + +struct Native +{ + private int i; + public Native(S s, System.Span b) + { + i = s.b ? 1 : 0; + } + + public S ToManaged() => new S { b = i != 0 }; + + public const int StackBufferSize = 1; +} +"; + public static string CustomStructMarshallingStackallocOnlyRefParameter = BasicParameterWithByRefModifier("ref", "S") + @" +[NativeMarshalling(typeof(Native))] +struct S +{ + public bool b; +} + +struct Native +{ + private int i; + public Native(S s, System.Span b) + { + i = s.b ? 1 : 0; + } + + public S ToManaged() => new S { b = i != 0 }; + + public const int StackBufferSize = 1; +} +"; + public static string CustomStructMarshallingOptionalStackallocParametersAndModifiers = BasicParametersAndModifiers("S") + @" +[NativeMarshalling(typeof(Native))] +struct S +{ + public bool b; +} + +struct Native +{ + private int i; + public Native(S s, System.Span b) + { + i = s.b ? 1 : 0; + } + public Native(S s) + { + i = s.b ? 1 : 0; + } + + public S ToManaged() => new S { b = i != 0 }; + + public const int StackBufferSize = 1; +} +"; + + public static string CustomStructMarshallingStackallocValuePropertyParametersAndModifiersNoRef = BasicParametersAndModifiersNoRef("S") + @" +[NativeMarshalling(typeof(Native))] +struct S +{ + public bool b; +} + +struct Native +{ + public Native(S s, System.Span b) + { + Value = s.b ? 1 : 0; + } + + public S ToManaged() => new S { b = Value != 0 }; + + public int Value { get; set; } + + public const int StackBufferSize = 1; +} +"; + public static string CustomStructMarshallingValuePropertyParametersAndModifiers = BasicParametersAndModifiers("S") + @" +[NativeMarshalling(typeof(Native))] +struct S +{ + public bool b; +} + +struct Native +{ + public Native(S s) + { + Value = s.b ? 1 : 0; + } + + public S ToManaged() => new S { b = Value != 0 }; + + public int Value { get; set; } +} +"; + public static string CustomStructMarshallingPinnableParametersAndModifiers = BasicParametersAndModifiers("S") + @" +[NativeMarshalling(typeof(Native))] +class S +{ + public int i; + + public ref int GetPinnableReference() => ref i; +} + +unsafe struct Native +{ + private int* ptr; + public Native(S s) + { + ptr = (int*)Marshal.AllocHGlobal(sizeof(int)); + *ptr = s.i; + } + + public S ToManaged() => new S { i = *ptr }; + + public nint Value + { + get => (nint)ptr; + set => ptr = (int*)value; + } +} +"; + + public static string CustomStructMarshallingNativeTypePinnable = @" +using System.Runtime.InteropServices; +using System; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +unsafe ref struct Native +{ + private byte* ptr; + private Span stackBuffer; + + public Native(S s) : this() + { + ptr = (byte*)Marshal.AllocCoTaskMem(sizeof(byte)); + *ptr = s.c; + } + + public Native(S s, Span buffer) : this() + { + stackBuffer = buffer; + stackBuffer[0] = s.c; + } + + public ref byte GetPinnableReference() => ref (ptr != null ? ref *ptr : ref stackBuffer.GetPinnableReference()); + + public S ToManaged() + { + return new S { c = *ptr }; + } + + public byte* Value + { + get => ptr != null ? ptr : throw new InvalidOperationException(); + set => ptr = value; + } + + public void FreeNative() + { + if (ptr != null) + { + Marshal.FreeCoTaskMem((IntPtr)ptr); + } + } + + public const int StackBufferSize = 1; +} + +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + S s, + in S sIn); +} +"; + + public static string CustomStructMarshallingByRefValueProperty = BasicParametersAndModifiers("S") + @" +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c = 0; +} + +unsafe struct Native +{ + private S value; + + public Native(S s) : this() + { + value = s; + } + + public ref byte Value { get => ref value.c; } +} +"; + + public static string BasicParameterWithByRefModifier(string byRefKind, string typeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + {byRefKind} {typeName} p); +}}"; + + public static string BasicReturnType(string typeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial {typeName} Method(); +}}"; + + public static string CustomStructMarshallingManagedToNativeOnlyOutParameter => BasicParameterWithByRefModifier("out", "S") + @" +[NativeMarshalling(typeof(Native))] +[StructLayout(LayoutKind.Sequential)] +struct S +{ + public bool b; +} + +struct Native +{ + private int i; + public Native(S s) + { + i = s.b ? 1 : 0; + } +} +"; + + public static string CustomStructMarshallingManagedToNativeOnlyReturnValue => BasicReturnType("S") + @" +[NativeMarshalling(typeof(Native))] +[StructLayout(LayoutKind.Sequential)] +struct S +{ + public bool b; +} + +struct Native +{ + private int i; + public Native(S s) + { + i = s.b ? 1 : 0; + } +} +"; + + public static string CustomStructMarshallingNativeToManagedOnlyInParameter => BasicParameterWithByRefModifier("in", "S") + @" +[NativeMarshalling(typeof(Native))] +struct S +{ + public bool b; +} + +[StructLayout(LayoutKind.Sequential)] +struct Native +{ + private int i; + public S ToManaged() => new S { b = i != 0 }; +} +"; } } 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 5146414748788..7500d50464ce3 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -67,6 +67,13 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + + // Custom type marshalling with invalid members + yield return new object[] { CodeSnippets.CustomStructMarshallingByRefValueProperty, 3, 0 }; + yield return new object[] { CodeSnippets.CustomStructMarshallingManagedToNativeOnlyOutParameter, 1, 0 }; + yield return new object[] { CodeSnippets.CustomStructMarshallingManagedToNativeOnlyReturnValue, 1, 0 }; + yield return new object[] { CodeSnippets.CustomStructMarshallingNativeToManagedOnlyInParameter, 1, 0 }; + yield return new object[] { CodeSnippets.CustomStructMarshallingStackallocOnlyRefParameter, 1, 0 }; } [Theory] 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 d41dc38eb183b..8737deda32248 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -149,6 +149,16 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; + + // Custom type marshalling + yield return new[] { CodeSnippets.CustomStructMarshallingParametersAndModifiers }; + yield return new[] { CodeSnippets.CustomStructMarshallingStackallocParametersAndModifiersNoRef }; + yield return new[] { CodeSnippets.CustomStructMarshallingStackallocValuePropertyParametersAndModifiersNoRef }; + yield return new[] { CodeSnippets.CustomStructMarshallingOptionalStackallocParametersAndModifiers }; + yield return new[] { CodeSnippets.CustomStructMarshallingValuePropertyParametersAndModifiers }; + yield return new[] { CodeSnippets.CustomStructMarshallingPinnableParametersAndModifiers }; + yield return new[] { CodeSnippets.CustomStructMarshallingNativeTypePinnable }; + yield return new[] { CodeSnippets.CustomStructMarshallingMarshalUsingParametersAndModifiers }; } public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index 342ee1e0a5694..fde897ec1b669 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -432,7 +432,7 @@ public Native(S s) : this() await VerifyCS.VerifyAnalyzerAsync(source); } - + [Fact] public async Task TypeWithGetPinnableReferenceNonPointerReturnType_ReportsDiagnostic() { @@ -466,6 +466,102 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithSpan(24, 5, 24, 42).WithArguments("int", "S")); } + [Fact] + public async Task TypeWithGetPinnableReferencePointerReturnType_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; + + public ref byte GetPinnableReference() => ref c; +} + +unsafe struct Native +{ + private IntPtr value; + + public Native(S s) : this() + { + value = IntPtr.Zero; + } + + public S ToManaged() => new S(); + + public int* Value { get => null; set {} } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task TypeWithGetPinnableReferenceByRefReturnType_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; + + public ref byte GetPinnableReference() => ref c; +} + +unsafe struct Native +{ + private S value; + + public Native(S s) : this() + { + value = s; + } + + public ref byte Value { get => ref value.GetPinnableReference(); } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithSpan(22, 5, 22, 71).WithArguments("ref byte", "S"), + VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithSpan(22, 5, 22, 71).WithArguments("Native")); + } + + [Fact] + public async Task NativeTypeWithGetPinnableReferenceByRefReturnType_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +unsafe struct Native +{ + private S value; + + public Native(S s) : this() + { + value = s; + } + + public ref byte GetPinnableReference() => ref value.c; + + public ref byte Value { get => ref GetPinnableReference(); } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithSpan(22, 5, 22, 65).WithArguments("ref byte", "Native"), + VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithSpan(22, 5, 22, 65).WithArguments("Native")); + } + [Fact] public async Task BlittableValueTypeWithNoFields_DoesNotReportDiagnostic() { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs new file mode 100644 index 0000000000000..0547fc87d62f8 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs @@ -0,0 +1,63 @@ +using System; +using System.Runtime.InteropServices; +using SharedTypes; + +namespace NativeExports +{ + public static unsafe class CustomMarshalling + { + [UnmanagedCallersOnly(EntryPoint = "stringcontainer_deepduplicate")] + [DNNE.C99DeclCode("struct string_container { char* str1; char* str2; };")] + public static void DeepDuplicateStrings( + [DNNE.C99Type("struct string_container")] StringContainerNative strings, + [DNNE.C99Type("struct string_container*")] StringContainerNative* pStringsOut) + { + // Round trip through the managed view to allocate a new native instance. + *pStringsOut = new StringContainerNative(strings.ToManaged()); + } + + [UnmanagedCallersOnly(EntryPoint = "stringcontainer_reverse_strings")] + public static void ReverseStrings( + [DNNE.C99Type("struct string_container*")] StringContainerNative* strings) + { + strings->str1 = (IntPtr)Strings.Reverse((byte*)strings->str1); + strings->str2 = (IntPtr)Strings.Reverse((byte*)strings->str2); + } + + [UnmanagedCallersOnly(EntryPoint = "get_long_bytes_as_double")] + public static double GetLongBytesAsDouble(long l) + { + return *(double*)&l; + } + + [UnmanagedCallersOnly(EntryPoint = "negate_bools")] + [DNNE.C99DeclCode("struct bool_struct { int8_t b1; int8_t b2; int8_t b3; };")] + public static void NegateBools( + [DNNE.C99Type("struct bool_struct")] BoolStructNative boolStruct, + [DNNE.C99Type("struct bool_struct*")] BoolStructNative* pBoolStructOut) + { + *pBoolStructOut = new BoolStructNative + { + b1 = boolStruct.b1 != 0 ? 0 : 1, + b2 = boolStruct.b2 != 0 ? 0 : 1, + b3 = boolStruct.b3 != 0 ? 0 : 1, + }; + } + + [UnmanagedCallersOnly(EntryPoint = "and_bools_ref")] + public static byte AndBoolsRef( + [DNNE.C99Type("struct bool_struct*")] BoolStructNative* boolStruct) + { + return boolStruct->b1 != 0 && boolStruct->b2 != 0 && boolStruct->b3 != 0 ? 1 : 0; + } + + [UnmanagedCallersOnly(EntryPoint = "double_int_ref")] + public static int* DoubleIntRef(int* pInt) + { + *pInt *= 2; + int* retVal = (int*)Marshal.AllocCoTaskMem(sizeof(int)); + *retVal = *pInt; + return retVal; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs new file mode 100644 index 0000000000000..349cb2b93e0fb --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs @@ -0,0 +1,200 @@ +using System; +using System.Runtime.InteropServices; + +namespace SharedTypes +{ + [NativeMarshalling(typeof(StringContainerNative))] + public struct StringContainer + { + public string str1; + public string str2; + } + + [BlittableType] + public struct StringContainerNative + { + public IntPtr str1; + public IntPtr str2; + + public StringContainerNative(StringContainer managed) + { + str1 = Marshal.StringToCoTaskMemUTF8(managed.str1); + str2 = Marshal.StringToCoTaskMemUTF8(managed.str2); + } + + public StringContainer ToManaged() + { + return new StringContainer + { + str1 = Marshal.PtrToStringUTF8(str1), + str2 = Marshal.PtrToStringUTF8(str2) + }; + } + + public void FreeNative() + { + Marshal.FreeCoTaskMem(str1); + Marshal.FreeCoTaskMem(str2); + } + } + + public struct DoubleToLongMarshaler + { + public long l; + + public DoubleToLongMarshaler(double d) + { + l = MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref d, 1))[0]; + } + + public double ToManaged() => MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref l, 1))[0]; + + public long Value + { + get => l; + set => l = value; + } + } + + [NativeMarshalling(typeof(BoolStructNative))] + public struct BoolStruct + { + public bool b1; + public bool b2; + public bool b3; + } + + [BlittableType] + public struct BoolStructNative + { + public byte b1; + public byte b2; + public byte b3; + public BoolStructNative(BoolStruct bs) + { + b1 = bs.b1 ? 1 : 0; + b2 = bs.b2 ? 1 : 0; + b3 = bs.b3 ? 1 : 0; + } + + public BoolStruct ToManaged() + { + return new BoolStruct + { + b1 = b1 != 0, + b2 = b2 != 0, + b3 = b3 != 0 + }; + } + } + + [NativeMarshalling(typeof(IntWrapperMarshaler))] + public class IntWrapper + { + public int i; + + public ref int GetPinnableReference() => ref i; + } + + public unsafe struct IntWrapperMarshaler + { + public IntWrapperMarshaler(IntWrapper managed) + { + Value = (int*)Marshal.AllocCoTaskMem(sizeof(int)); + *Value = managed.i; + } + + public int* Value { get; set; } + + public IntWrapper ToManaged() => new IntWrapper { i = *Value }; + + public void FreeNative() + { + Marshal.FreeCoTaskMem((IntPtr)Value); + } + } + + public unsafe ref struct Utf16StringMarshaler + { + private ushort* ptr; + private Span span; + + public Utf16StringMarshaler(string str) + { + ptr = str is null ? null : (ushort*)Marshal.StringToCoTaskMemUni(str); + span = default; + } + + public Utf16StringMarshaler(string str, Span buffer) + { + if (str is null) + { + ptr = null; + span = default; + } + else if (str.Length < StackBufferSize) + { + span = MemoryMarshal.Cast(buffer); + str.AsSpan().CopyTo(MemoryMarshal.Cast(buffer)); + ptr = null; + } + else + { + span = default; + ptr = (ushort*)Marshal.StringToCoTaskMemUni(str); + } + } + + public ref ushort GetPinnableReference() + { + if (ptr != null) + { + return ref *ptr; + } + return ref span.GetPinnableReference(); + } + + public ushort* Value + { + get + { + if (ptr == null && span != default) + { + throw new InvalidOperationException(); + } + return ptr; + } + set + { + ptr = value; + span = default; + } + } + + public string ToManaged() + { + if (ptr == null && span == default) + { + return null; + } + else if (ptr != null) + { + return Marshal.PtrToStringUni((IntPtr)ptr); + } + else + { + return MemoryMarshal.Cast(span).ToString(); + } + } + + public void FreeNative() + { + if (ptr != null) + { + Marshal.FreeCoTaskMem((IntPtr)ptr); + } + } + + public const int StackBufferSize = 0x100; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj index 368e3d0ee61b5..692e17b9e0630 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj @@ -2,6 +2,7 @@ net5.0 + true From e82452d2fac9471097a573d634bfad5c218d6856 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 20 Nov 2020 19:43:40 -0800 Subject: [PATCH 050/161] Add DynamicallyAccessedMembers attribute to CreateSafeHandle API (dotnet/runtimelab#373) Commit migrated from https://github.com/dotnet/runtimelab/commit/e4bdc07d100804a08b00c5419e259ba2ef7a211f --- .../GeneratedDllImportAttribute.cs | 9 ++++++++- .../tests/Ancillary.Interop/MarshalEx.cs | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs index 42c15094915ab..73f012f86a415 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs @@ -1,7 +1,14 @@  namespace System.Runtime.InteropServices { - // [TODO] Remove once the attribute has been added to the BCL + /// + /// Indicates that method will be generated at compile time and invoke into an unmanaged library entry point + /// + /// + /// IL linker/trimming currently has special handling of P/Invokes (pinvokeimpl): + /// - https://github.com/mono/linker/blob/bfab847356063d21eb15e79f2b6c03df5bd6ef3d/src/linker/Linker.Steps/MarkStep.cs#L2623 + /// We may want to make the linker aware of this attribute as well. + /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public sealed class GeneratedDllImportAttribute : Attribute { diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs index 95be96d868588..2633bd26e273d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -1,4 +1,5 @@ +using System.Diagnostics.CodeAnalysis; using System.Reflection; namespace System.Runtime.InteropServices @@ -9,7 +10,15 @@ namespace System.Runtime.InteropServices /// public static class MarshalEx { - public static TSafeHandle CreateSafeHandle() + /// + /// Create an instance of the given . + /// + /// Type of the SafeHandle + /// New instance of + /// + /// The must be non-abstract and have a parameterless constructor. + /// + public static TSafeHandle CreateSafeHandle<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.NonPublicConstructors)]TSafeHandle>() where TSafeHandle : SafeHandle { if (typeof(TSafeHandle).IsAbstract || typeof(TSafeHandle).GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance | BindingFlags.Instance, null, Type.EmptyTypes, null) == null) @@ -21,6 +30,11 @@ public static TSafeHandle CreateSafeHandle() return safeHandle; } + /// + /// Sets the handle of to the specified . + /// + /// instance to update + /// Pre-existing handle public static void SetHandle(SafeHandle safeHandle, IntPtr handle) { typeof(SafeHandle).GetMethod("SetHandle", BindingFlags.NonPublic | BindingFlags.Instance)!.Invoke(safeHandle, new object[] { handle }); From 8a324f2e8480c87c9a4621c4c1865ac0ecff2982 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 23 Nov 2020 10:28:56 -0800 Subject: [PATCH 051/161] Apply SkipLocalsInitAttribute to generated stubs. (dotnet/runtimelab#377) * Apply SkipLocalsInitAttribute to generated stubs. Commit migrated from https://github.com/dotnet/runtimelab/commit/7ab9caf38b78fd854fe49ce06f85b383edff59a7 --- .../DllImportGenerator/DllImportGenerator.cs | 15 +++++--- .../gen/DllImportGenerator/DllImportStub.cs | 35 +++++++++++++++---- .../gen/DllImportGenerator/TypeNames.cs | 2 ++ .../DllImportGenerator/StructMarshalling.md | 2 ++ .../DllImportGenerator.UnitTests/Compiles.cs | 2 +- .../TestAssets/SharedTypes/NonBlittable.cs | 5 ++- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 73da797fafb97..993a7b358e3ee 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -47,7 +47,10 @@ public void Execute(GeneratorExecutionContext context) var syntaxToModel = new Dictionary(); var generatorDiagnostics = new GeneratorDiagnostics(context); - if (!IsSupportedTargetFramework(context.Compilation)) + + Version targetFrameworkVersion; + bool isSupported = IsSupportedTargetFramework(context.Compilation, out targetFrameworkVersion); + if (!isSupported) { // We don't return early here, letting the source generation continue. // This allows a user to copy generated source and use it as a starting point @@ -55,6 +58,7 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportTargetFrameworkNotSupported(MinimumSupportedFrameworkVersion); } + var env = new StubEnvironment(context.Compilation, isSupported, targetFrameworkVersion); var generatedDllImports = new StringBuilder(); foreach (SyntaxReference synRef in synRec.Methods) { @@ -116,7 +120,7 @@ public void Execute(GeneratorExecutionContext context) } // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData!, context.Compilation, generatorDiagnostics, context.CancellationToken); + var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData!, env, generatorDiagnostics, context.CancellationToken); PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub, dllImportAttr!); } @@ -138,6 +142,7 @@ private void PrintGeneratedSource( { // Create stub function var stubMethod = MethodDeclaration(stub.StubReturnType, userDeclaredMethod.Identifier) + .AddAttributeLists(stub.AdditionalAttributes) .WithModifiers(userDeclaredMethod.Modifiers) .WithParameterList(ParameterList(SeparatedList(stub.StubParameters))) .WithBody(stub.StubCode); @@ -173,9 +178,11 @@ private void PrintGeneratedSource( builder.AppendLine(toPrint.NormalizeWhitespace().ToString()); } - private static bool IsSupportedTargetFramework(Compilation compilation) + private static bool IsSupportedTargetFramework(Compilation compilation, out Version version) { IAssemblySymbol systemAssembly = compilation.GetSpecialType(SpecialType.System_Object).ContainingAssembly; + version = systemAssembly.Identity.Version; + return systemAssembly.Identity.Name switch { // .NET Framework @@ -183,7 +190,7 @@ private static bool IsSupportedTargetFramework(Compilation compilation) // .NET Standard "netstandard" => false, // .NET Core (when version < 5.0) or .NET - "System.Runtime" => systemAssembly.Identity.Version >= MinimumSupportedFrameworkVersion, + "System.Runtime" => version >= MinimumSupportedFrameworkVersion, _ => false, }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index d52865eee2066..d51fe9ff6e016 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; using System.Threading; using Microsoft.CodeAnalysis; @@ -13,6 +10,11 @@ namespace Microsoft.Interop { + internal record StubEnvironment( + Compilation Compilation, + bool SupportedTargetFramework, + Version TargetFrameworkVersion); + internal class DllImportStub { private TypePositionInfo returnTypeInfo; @@ -54,6 +56,8 @@ public IEnumerable StubParameters public MethodDeclarationSyntax DllImportDeclaration { get; init; } + public AttributeListSyntax[] AdditionalAttributes { get; init; } + /// /// Flags used to indicate members on GeneratedDllImport attribute. /// @@ -103,7 +107,7 @@ public class GeneratedDllImportData public static DllImportStub Create( IMethodSymbol method, GeneratedDllImportData dllImportData, - Compilation compilation, + StubEnvironment env, GeneratorDiagnostics diagnostics, CancellationToken token = default) { @@ -156,7 +160,7 @@ public static DllImportStub Create( for (int i = 0; i < method.Parameters.Length; i++) { var param = method.Parameters[i]; - var typeInfo = TypePositionInfo.CreateForParameter(param, defaultInfo, compilation, diagnostics); + var typeInfo = TypePositionInfo.CreateForParameter(param, defaultInfo, env.Compilation, diagnostics); typeInfo = typeInfo with { ManagedIndex = i, @@ -165,7 +169,7 @@ public static DllImportStub Create( paramsTypeInfo.Add(typeInfo); } - TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), defaultInfo, compilation, diagnostics); + TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), defaultInfo, env.Compilation, diagnostics); retTypeInfo = retTypeInfo with { ManagedIndex = TypePositionInfo.ReturnIndex, @@ -176,7 +180,7 @@ public static DllImportStub Create( if (!dllImportData.PreserveSig) { // Create type info for native HRESULT return - retTypeInfo = TypePositionInfo.CreateForType(compilation.GetSpecialType(SpecialType.System_Int32), NoMarshallingInfo.Instance); + retTypeInfo = TypePositionInfo.CreateForType(env.Compilation.GetSpecialType(SpecialType.System_Int32), NoMarshallingInfo.Instance); retTypeInfo = retTypeInfo with { NativeIndex = TypePositionInfo.ReturnIndex @@ -202,6 +206,22 @@ public static DllImportStub Create( var stubGenerator = new StubCodeGenerator(method, dllImportData, paramsTypeInfo, retTypeInfo, diagnostics); var (code, dllImport) = stubGenerator.GenerateSyntax(); + var additionalAttrs = new List(); + + // Define additional attributes for the stub definition. + if (env.TargetFrameworkVersion >= new Version(5, 0)) + { + additionalAttrs.Add( + AttributeList( + SeparatedList(new [] + { + // Adding the skip locals init indiscriminately since the source generator is + // targeted at non-blittable method signatures which typically will contain locals + // in the generated code. + Attribute(ParseName(TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute)) + }))); + } + return new DllImportStub() { returnTypeInfo = managedRetTypeInfo, @@ -210,6 +230,7 @@ public static DllImportStub Create( StubContainingTypes = containingTypes, StubCode = code, DllImportDeclaration = dllImport, + AdditionalAttributes = additionalAttrs.ToArray(), }; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 1ec4e75018310..e998b90956c68 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -32,5 +32,7 @@ static class TypeNames public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal"; public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; + + public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md index a3aac4efe7bba..79d5e9bd769d8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md @@ -123,6 +123,8 @@ The P/Invoke source generator (as well as the struct source generator when neste If a structure type does not have either the `BlittableTypeAttribute` or the `NativeMarshallingAttribute` applied at the type definition, the user can supply a `MarshalUsingAttribute` at the marshalling location (field, parameter, or return value) with a native type matching the same requirements as `NativeMarshallingAttribute`'s native type. +All generated stubs will be marked with [`SkipLocalsInitAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.compilerservices.skiplocalsinitattribute) on supported frameworks. This does require attention when performing custom marshalling as the state of stub allocated memory will be in an undefined state. + ### Why do we need `BlittableTypeAttribute`? Based on the design above, it seems that we wouldn't need `BlittableTypeAttribute`. However, due to the ref assembly issue above in combination with the desire to enable manual interop, we need to provide a way for users to signal that a given type should be blittable and that the source generator should not generate marshalling code. 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 8737deda32248..c51787baa1a69 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -149,7 +149,7 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; yield return new[] { CodeSnippets.ArrayPreserveSigFalse() }; - + // Custom type marshalling yield return new[] { CodeSnippets.CustomStructMarshallingParametersAndModifiers }; yield return new[] { CodeSnippets.CustomStructMarshallingStackallocParametersAndModifiersNoRef }; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs index 349cb2b93e0fb..86289c66e0d92 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs @@ -132,10 +132,13 @@ public Utf16StringMarshaler(string str, Span buffer) ptr = null; span = default; } - else if (str.Length < StackBufferSize) + else if ((str.Length + 1) < StackBufferSize) { span = MemoryMarshal.Cast(buffer); str.AsSpan().CopyTo(MemoryMarshal.Cast(buffer)); + // Supplied memory is in an undefined state so ensure + // there is a trailing null in the buffer. + span[str.Length] = '\0'; ptr = null; } else From 10d3f8a090ac2bc2e1cb34c31b00e3d394bf864e Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 23 Nov 2020 13:40:59 -0800 Subject: [PATCH 052/161] Fix setting of allocation marker in ANSI string marshaller (dotnet/runtimelab#375) Commit migrated from https://github.com/dotnet/runtimelab/commit/f775098ae51c22f920d842769985d0a0c6917c85 --- .../gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs index 47392b5bcf889..0c3756791d8e8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs @@ -81,7 +81,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu if (UsesConditionalStackAlloc(info, context)) { // = true - windowsBlock.AddStatements( + windowsBlock = windowsBlock.AddStatements( ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, From 47007229997216749a6fea744e8c26465b0d36c3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 30 Nov 2020 10:41:11 -0800 Subject: [PATCH 053/161] Handle SetLastError=true (dotnet/runtimelab#360) Commit migrated from https://github.com/dotnet/runtimelab/commit/b36b0b8adc4d5c3e7f2927381ea800444f870f96 --- .../DllImportGenerator/DllImportGenerator.cs | 6 -- .../DllImportGenerator/StubCodeGenerator.cs | 53 ++++++++++- .../libraries/DllImportGenerator/Pipeline.md | 15 +++ .../Ancillary.Interop.csproj | 1 + .../tests/Ancillary.Interop/MarshalEx.cs | 74 +++++++++++++++ .../SetLastErrorTests.cs | 94 +++++++++++++++++++ .../CompileFails.cs | 3 +- .../DllImportGenerator.UnitTests/Compiles.cs | 28 +----- .../tests/TestAssets/NativeExports/Error.cs | 66 +++++++++++++ 9 files changed, 307 insertions(+), 33 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 993a7b358e3ee..86bb2467ab17c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -107,12 +107,6 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar)); } - // [TODO] Remove once we support SetLastError=true - if (dllImportData.SetLastError) - { - generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.SetLastError), "true"); - } - if (lcidConversionAttr != null) { // Using LCIDConversion with GeneratedDllImport is not supported diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 7b5dc53f92290..e11337b791e1e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -30,6 +30,10 @@ internal sealed class StubCodeGenerator : StubCodeContext public string ReturnNativeIdentifier { get; private set; } = ReturnIdentifier; private const string InvokeReturnIdentifier = "__invokeRetVal"; + private const string LastErrorIdentifier = "__lastError"; + + // Error code representing success. This maps to S_OK for Windows HRESULT semantics and 0 for POSIX errno semantics. + private const int SuccessErrorCode = 0; private static readonly Stage[] Stages = new Stage[] { @@ -170,6 +174,14 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo AppendVariableDeclations(setupStatements, retMarshaller.TypeInfo, retMarshaller.Generator); } + if (this.dllImportData.SetLastError) + { + // Declare variable for last error + setupStatements.Add(MarshallerHelpers.DeclareWithDefault( + PredefinedType(Token(SyntaxKind.IntKeyword)), + LastErrorIdentifier)); + } + var tryStatements = new List(); var finallyStatements = new List(); var invoke = InvocationExpression(IdentifierName(dllImportName)); @@ -235,11 +247,37 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo invoke)); } + if (this.dllImportData.SetLastError) + { + // Marshal.SetLastSystemError(0); + var clearLastError = ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + IdentifierName("SetLastSystemError")), + ArgumentList(SingletonSeparatedList( + Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(SuccessErrorCode))))))); + + // = Marshal.GetLastSystemError(); + var getLastError = ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(LastErrorIdentifier), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + IdentifierName("GetLastSystemError"))))); + + invokeStatement = Block(clearLastError, invokeStatement, getLastError); + } + // Nest invocation in fixed statements if (fixedStatements.Any()) { fixedStatements.Reverse(); - invokeStatement = fixedStatements.First().WithStatement(Block(invokeStatement)); + invokeStatement = fixedStatements.First().WithStatement(invokeStatement); foreach (var fixedStatement in fixedStatements.Skip(1)) { invokeStatement = fixedStatement.WithStatement(Block(invokeStatement)); @@ -274,6 +312,19 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo allStatements.AddRange(tryStatements); } + if (this.dllImportData.SetLastError) + { + // Marshal.SetLastWin32Error(); + allStatements.Add(ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + IdentifierName("SetLastWin32Error")), + ArgumentList(SingletonSeparatedList( + Argument(IdentifierName(LastErrorIdentifier))))))); + } + // Return if (!stubReturnsVoid) allStatements.Add(ReturnStatement(IdentifierName(ReturnIdentifier))); diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md index 6ff67b39ad69c..a751257bcee7f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -139,6 +139,21 @@ These various scenarios have different levels of support for these three feature | non-blittable array marshalling in a P/Invoke | unsupported | unsupported (supportable with https://github.com/dotnet/runtime/issues/25423) | unuspported | | non-blittable array marshalling not in a P/Invoke | unsupported | unsupported | unuspported | +### `SetLastError=true` + +The stub code generation also handles [`SetLastError=true`][SetLastError] behaviour. This configuration indicates that system error code ([`errno`](https://en.wikipedia.org/wiki/Errno.h) on Unix, [`GetLastError`](https://docs.microsoft.com/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror) on Windows) should be stored after the native invocation, such that it can be retrieved using [`Marshal.GetLastWin32Error`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.getlastwin32error). + +This means that, rather than simply invoke the native method, the generated stub will: + +1. Clear the system error by setting it to 0 +2. Invoke the native method +3. Get the system error +4. Set the stored error for the P/Invoke (accessible via `Marshal.GetLastWin32Error`) + +A core requirement of this functionality is that the P/Invoke called in (2) is blittable (the purpose of the P/Invoke source generator), such that there will be no additional operations (e.g unmarshalling) after the invocation that could change the system error that is retrieved in (3). Similarly, (3) must not involve any operations before getting the system error that could change the system error. This also relies on the runtime itself handling preserving the last error (see `BEGIN/END_PRESERVE_LAST_ERROR` macros) during JIT and P/Invoke resolution. + +Clearing the system error (1) is necessary because the native method may not set the error at all on success and the system error would retain its value from a previous operation. The developer should be able to check `Marshal.GetLastWin32Error` after a P/Inovke to determine success or failure, so the stub explicitly clears the error before the native invocation, such that the last error will indicate success if the native call does not change it. + ## P/Invoke The P/Invoke called by the stub is created based on the user's original declaration of the stub. The signature is generated using the syntax returned by `AsNativeType` and `AsParameter` of the marshalling generators for the return and parameters. Any marshalling attributes on the return and parameters of the managed method - [`MarshalAsAttribute`][MarshalAsAttribute], [`InAttribute`][InAttribute], [`OutAttribute`][OutAttribute] - are dropped. 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 e9063db196bec..642e04fe9e5d5 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 @@ -5,6 +5,7 @@ 8.0 System.Runtime.InteropServices enable + true diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs index 2633bd26e273d..a5ad55f72e687 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -39,5 +39,79 @@ public static void SetHandle(SafeHandle safeHandle, IntPtr handle) { typeof(SafeHandle).GetMethod("SetHandle", BindingFlags.NonPublic | BindingFlags.Instance)!.Invoke(safeHandle, new object[] { handle }); } + + /// + /// Set the last platform invoke error on the thread + /// + public static void SetLastWin32Error(int error) + { + typeof(Marshal).GetMethod("SetLastWin32Error", BindingFlags.NonPublic | BindingFlags.Static)!.Invoke(null, new object[] { error }); + } + + /// + /// Get the last system error on the current thread (errno on Unix, GetLastError on Windows) + /// + public static unsafe int GetLastSystemError() + { + // Would be internal call that handles getting the last error for the thread using the PAL + + if (OperatingSystem.IsWindows()) + { + return Kernel32.GetLastError(); + } + else if (OperatingSystem.IsMacOS()) + { + return *libc.__error(); + } + else if (OperatingSystem.IsLinux()) + { + return *libc.__errno_location(); + } + + throw new NotImplementedException(); + } + + /// + /// Set the last system error on the current thread (errno on Unix, SetLastError on Windows) + /// + public static unsafe void SetLastSystemError(int error) + { + // Would be internal call that handles setting the last error for the thread using the PAL + + if (OperatingSystem.IsWindows()) + { + Kernel32.SetLastError(error); + } + else if (OperatingSystem.IsMacOS()) + { + *libc.__error() = error; + } + else if (OperatingSystem.IsLinux()) + { + *libc.__errno_location() = error; + } + else + { + throw new NotImplementedException(); + } + } + + private class Kernel32 + { + [DllImport(nameof(Kernel32))] + public static extern void SetLastError(int error); + + [DllImport(nameof(Kernel32))] + public static extern int GetLastError(); + } + + private class libc + { + [DllImport(nameof(libc))] + internal static unsafe extern int* __errno_location(); + + [DllImport(nameof(libc))] + internal static unsafe extern int* __error(); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs new file mode 100644 index 0000000000000..ba59f95803a4b --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -0,0 +1,94 @@ +using System; +using System.Runtime.InteropServices; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + [BlittableType] + public struct SetLastErrorMarshaller + { + public int val; + + public SetLastErrorMarshaller(int i) + { + val = i; + } + + public int ToManaged() + { + // Explicity set the last error to something else on unmarshalling + MarshalEx.SetLastWin32Error(val * 2); + return val; + } + } + + partial class NativeExportsNE + { + public partial class SetLastError + { + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error", SetLastError = true)] + public static partial int SetError(int error, byte shouldSetError); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error_return_string", SetLastError = true)] + [return: MarshalUsing(typeof(SetLastErrorMarshaller))] + public static partial int SetError_CustomMarshallingSetsError(int error, byte shouldSetError); + + [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error_return_string", SetLastError = true)] + [return: MarshalAs(UnmanagedType.LPWStr)] + public static partial string SetError_NonBlittableSignature(int error, [MarshalAs(UnmanagedType.U1)] bool shouldSetError, [MarshalAs(UnmanagedType.LPWStr)] string errorString); + } + } + + public class SetLastErrorTests + { + [Theory] + [InlineData(0)] + [InlineData(2)] + [InlineData(-5)] + public void LastWin32Error_HasExpectedValue(int error) + { + string errorString = error.ToString(); + string ret = NativeExportsNE.SetLastError.SetError_NonBlittableSignature(error, shouldSetError: true, errorString); + Assert.Equal(error, Marshal.GetLastWin32Error()); + Assert.Equal(errorString, ret); + + // Clear the last error + MarshalEx.SetLastWin32Error(0); + + NativeExportsNE.SetLastError.SetError(error, shouldSetError: 1); + Assert.Equal(error, Marshal.GetLastWin32Error()); + + MarshalEx.SetLastWin32Error(0); + + // Custom marshalling sets the last error on unmarshalling. + // Last error should reflect error from native call, not unmarshalling. + NativeExportsNE.SetLastError.SetError_CustomMarshallingSetsError(error, shouldSetError: 1); + Assert.Equal(error, Marshal.GetLastWin32Error()); + } + + [Fact] + public void ClearPreviousError() + { + int error = 100; + MarshalEx.SetLastWin32Error(error); + + // Don't actually set the error in the native call. SetLastError=true should clear any existing error. + string errorString = error.ToString(); + string ret = NativeExportsNE.SetLastError.SetError_NonBlittableSignature(error, shouldSetError: false, errorString); + Assert.Equal(0, Marshal.GetLastWin32Error()); + Assert.Equal(errorString, ret); + + MarshalEx.SetLastWin32Error(error); + + // Don't actually set the error in the native call. SetLastError=true should clear any existing error. + NativeExportsNE.SetLastError.SetError(error, shouldSetError: 0); + Assert.Equal(0, Marshal.GetLastWin32Error()); + + // Don't actually set the error in the native call. Custom marshalling still sets the last error. + // SetLastError=true should clear any existing error and ignore error set by custom marshalling. + NativeExportsNE.SetLastError.SetError_CustomMarshallingSetsError(error, shouldSetError: 0); + Assert.Equal(0, Marshal.GetLastWin32Error()); + } + } +} 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 7500d50464ce3..d050b72617d9e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -41,8 +41,7 @@ public static IEnumerable CodeSnippetsToCompile() // Unsupported named arguments // * BestFitMapping, ThrowOnUnmappableChar - // [TODO]: Expected diagnostic count should be 2 once we support SetLastError - yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 3, 0 }; + yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 2, 0 }; // LCIDConversion yield return new object[] { CodeSnippets.LCIDConversionAttribute, 1, 0 }; 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 c51787baa1a69..07fef3b9500e1 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -9,7 +9,7 @@ namespace DllImportGenerator.UnitTests { public class Compiles { - public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() + public static IEnumerable CodeSnippetsToCompile() { yield return new[] { CodeSnippets.TrivialClassDeclarations }; yield return new[] { CodeSnippets.TrivialStructDeclarations }; @@ -17,7 +17,7 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.NestedNamespace }; yield return new[] { CodeSnippets.NestedTypes }; yield return new[] { CodeSnippets.UserDefinedEntryPoint }; - //yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; + yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; yield return new[] { CodeSnippets.DefaultParameters }; yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; @@ -161,14 +161,9 @@ public static IEnumerable CodeSnippetsToCompile_NoDiagnostics() yield return new[] { CodeSnippets.CustomStructMarshallingMarshalUsingParametersAndModifiers }; } - public static IEnumerable CodeSnippetsToCompile_WithDiagnostics() - { - yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; - } - [Theory] - [MemberData(nameof(CodeSnippetsToCompile_NoDiagnostics))] - public async Task ValidateSnippets_NoDiagnostics(string source) + [MemberData(nameof(CodeSnippetsToCompile))] + public async Task ValidateSnippets(string source) { Compilation comp = await TestUtils.CreateCompilation(source); TestUtils.AssertPreSourceGeneratorCompilation(comp); @@ -179,20 +174,5 @@ public async Task ValidateSnippets_NoDiagnostics(string source) var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); } - - [Theory] - [MemberData(nameof(CodeSnippetsToCompile_WithDiagnostics))] - public async Task ValidateSnippets_WithDiagnostics(string source) - { - Compilation comp = await TestUtils.CreateCompilation(source); - TestUtils.AssertPreSourceGeneratorCompilation(comp); - - var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); - Assert.NotEmpty(generatorDiags); - Assert.All(generatorDiags, d => Assert.StartsWith(Microsoft.Interop.GeneratorDiagnostics.Ids.Prefix, d.Id)); - - var newCompDiags = newComp.GetDiagnostics(); - Assert.Empty(newCompDiags); - } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs new file mode 100644 index 0000000000000..8963c8138712d --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs @@ -0,0 +1,66 @@ +using System; +using System.Runtime.InteropServices; + +namespace NativeExports +{ + public static unsafe class Error + { + private class Kernel32 + { + [DllImport(nameof(Kernel32))] + public static extern void SetLastError(int error); + + [DllImport(nameof(Kernel32))] + public static extern int GetLastError(); + } + + private class libc + { + [DllImport(nameof(libc))] + internal static unsafe extern int* __errno_location(); + + [DllImport(nameof(libc))] + internal static unsafe extern int* __error(); + } + + [UnmanagedCallersOnly(EntryPoint = "set_error")] + public static int SetError(int error, byte shouldSetError) + { + if (shouldSetError != 0) + SetLastError(error); + + return error; + } + + [UnmanagedCallersOnly(EntryPoint = "set_error_return_string")] + public static ushort* SetErrorReturnString(int error, byte shouldSetError, ushort* errorString) + { + ushort* ret = (ushort*)Marshal.StringToCoTaskMemUni(new string((char*)errorString)); + + if (shouldSetError != 0) + SetLastError(error); + + return ret; + } + + private static void SetLastError(int error) + { + if (OperatingSystem.IsWindows()) + { + Kernel32.SetLastError(error); + } + else if (OperatingSystem.IsMacOS()) + { + *libc.__error() = error; + } + else if (OperatingSystem.IsLinux()) + { + *libc.__errno_location() = error; + } + else + { + throw new NotImplementedException(); + } + } + } +} From 67e674bc62c1b8f7a5a662c0ceade45d58c3cb04 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 1 Dec 2020 11:59:26 -0800 Subject: [PATCH 054/161] Add analyzer to flag converting from DllImport to GeneratedDllImport (dotnet/runtimelab#367) Commit migrated from https://github.com/dotnet/runtimelab/commit/a7ccdd83e4bda565c9a3870ffe48427c23782902 --- .../AnalyzerReleases.Unshipped.md | 1 + .../Analyzers/AnalyzerDiagnostics.cs | 3 + .../ConvertToGeneratedDllImportAnalyzer.cs | 125 ++++++++++++++ .../DllImportGenerator/Resources.Designer.cs | 29 +++- .../gen/DllImportGenerator/Resources.resx | 9 + ...onvertToGeneratedDllImportAnalyzerTests.cs | 159 ++++++++++++++++++ .../Verifiers/CSharpAnalyzerVerifier.cs | 31 +++- .../DllImportGeneratorSample/.editorconfig | 4 + 8 files changed, 358 insertions(+), 3 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs create mode 100644 src/samples/DllImportGeneratorSample/.editorconfig diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md index 69b50f973213f..60a8e6c34eeb4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md @@ -19,3 +19,4 @@ DLLIMPORTGENANALYZER011 | Usage | Warning | StackallocMarshallingSho DLLIMPORTGENANALYZER012 | Usage | Error | StackallocConstructorMustHaveStackBufferSizeConstant DLLIMPORTGENANALYZER013 | Usage | Warning | GeneratedDllImportMissingRequiredModifiers DLLIMPORTGENANALYZER014 | Usage | Error | RefValuePropertyUnsupported +DLLIMPORTGENANALYZER015 | Interoperability | Disabled | ConvertToGeneratedDllImportAnalyzer diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs index 84ef67fab449f..c4dd6109cb507 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs @@ -28,6 +28,9 @@ public static class Ids // GeneratedDllImport public const string GeneratedDllImportMissingRequiredModifiers = Prefix + "013"; + + // Migration from DllImport to GeneratedDllImport + public const string ConvertToGeneratedDllImport = Prefix + "015"; } internal static LocalizableResourceString GetResourceString(string resourceName) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs new file mode 100644 index 0000000000000..2df44242463ee --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs @@ -0,0 +1,125 @@ +using System.Collections.Immutable; +using System.Diagnostics; +using System.Runtime.InteropServices; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics; + +namespace Microsoft.Interop.Analyzers +{ + [DiagnosticAnalyzer(LanguageNames.CSharp)] + public class ConvertToGeneratedDllImportAnalyzer : DiagnosticAnalyzer + { + private const string Category = "Interoperability"; + + public readonly static DiagnosticDescriptor ConvertToGeneratedDllImport = + new DiagnosticDescriptor( + Ids.ConvertToGeneratedDllImport, + GetResourceString(nameof(Resources.ConvertToGeneratedDllImportTitle)), + GetResourceString(nameof(Resources.ConvertToGeneratedDllImportMessage)), + Category, + DiagnosticSeverity.Info, + isEnabledByDefault: false, + description: GetResourceString(nameof(Resources.ConvertToGeneratedDllImportDescription))); + + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(ConvertToGeneratedDllImport); + + public override void Initialize(AnalysisContext context) + { + // Don't analyze generated code + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + context.RegisterCompilationStartAction( + compilationContext => + { + // Nothing to do if the GeneratedDllImportAttribute is not in the compilation + INamedTypeSymbol? generatedDllImportAttrType = compilationContext.Compilation.GetTypeByMetadataName(TypeNames.GeneratedDllImportAttribute); + if (generatedDllImportAttrType == null) + return; + + INamedTypeSymbol? dllImportAttrType = compilationContext.Compilation.GetTypeByMetadataName(typeof(DllImportAttribute).FullName); + if (dllImportAttrType == null) + return; + + compilationContext.RegisterSymbolAction(symbolContext => AnalyzeSymbol(symbolContext, dllImportAttrType), SymbolKind.Method); + }); + } + + private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbol dllImportAttrType) + { + var method = (IMethodSymbol)context.Symbol; + + // Check if method is a DllImport + DllImportData? dllImportData = method.GetDllImportData(); + if (dllImportData == null) + return; + + // Ignore QCalls + if (dllImportData.ModuleName == "QCall") + return; + + if (RequiresMarshalling(method, dllImportData, dllImportAttrType)) + { + context.ReportDiagnostic(method.CreateDiagnostic(ConvertToGeneratedDllImport, method.Name)); + } + } + + private static bool RequiresMarshalling(IMethodSymbol method, DllImportData dllImportData, INamedTypeSymbol dllImportAttrType) + { + // SetLastError=true requires marshalling + if (dllImportData.SetLastError) + return true; + + // Check if return value requires marshalling + if (!method.ReturnsVoid && RequiresMarshalling(method.ReturnType)) + return true; + + // Check if parameters require marshalling + foreach (IParameterSymbol paramType in method.Parameters) + { + if (paramType.RefKind != RefKind.None) + return true; + + if (RequiresMarshalling(paramType.Type)) + return true; + } + + // DllImportData does not expose all information (e.g. PreserveSig), so we still need to get the attribute data + AttributeData? dllImportAttr = null; + foreach (AttributeData attr in method.GetAttributes()) + { + if (!SymbolEqualityComparer.Default.Equals(attr.AttributeClass, dllImportAttrType)) + continue; + + dllImportAttr = attr; + break; + } + + Debug.Assert(dllImportAttr != null); + foreach (var namedArg in dllImportAttr!.NamedArguments) + { + if (namedArg.Key != nameof(DllImportAttribute.PreserveSig)) + continue; + + // PreserveSig=false requires marshalling + if (!(bool)namedArg.Value.Value!) + return true; + } + + return false; + } + + private static bool RequiresMarshalling(ITypeSymbol typeSymbol) + { + if (typeSymbol.TypeKind == TypeKind.Enum) + return false; + + if (typeSymbol.TypeKind == TypeKind.Pointer) + return false; + + return !typeSymbol.IsConsideredBlittable(); + } + } +} 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 d64b2f4e427a4..2123b4d92ff1a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -176,7 +176,32 @@ internal static string ConfigurationNotSupportedTitle { return ResourceManager.GetString("ConfigurationNotSupportedTitle", resourceCulture); } } + + /// Looks up a localized string similar to Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time. + /// + internal static string ConvertToGeneratedDllImportDescription { + get { + return ResourceManager.GetString("ConvertToGeneratedDllImportDescription", resourceCulture); + } + } + /// Looks up a localized string similar to Mark the method '{0}' with 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time. + /// + internal static string ConvertToGeneratedDllImportMessage { + get { + return ResourceManager.GetString("ConvertToGeneratedDllImportMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time. + /// + internal static string ConvertToGeneratedDllImportTitle { + get { + return ResourceManager.GetString("ConvertToGeneratedDllImportTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it.. /// @@ -185,7 +210,7 @@ internal static string CustomTypeMarshallingManagedToNativeUnsupported { return ResourceManager.GetString("CustomTypeMarshallingManagedToNativeUnsupported", resourceCulture); } } - + /// /// Looks up a localized string similar to The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it.. /// @@ -194,7 +219,7 @@ internal static string CustomTypeMarshallingNativeToManagedUnsupported { return ResourceManager.GetString("CustomTypeMarshallingNativeToManagedUnsupported", resourceCulture); } } - + /// /// Looks up a localized string similar to Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 64b0a29098a36..5e4d1bc8c9c05 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -156,6 +156,15 @@ Specified configuration is not supported by source-generated P/Invokes. + + Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + + + Mark the method '{0}' with 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + + + Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs new file mode 100644 index 0000000000000..fe7824b312256 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using static Microsoft.Interop.Analyzers.ConvertToGeneratedDllImportAnalyzer; + +using VerifyCS = DllImportGenerator.UnitTests.Verifiers.CSharpAnalyzerVerifier; + +namespace DllImportGenerator.UnitTests +{ + public class ConvertToGeneratedDllImportAnalyzerTests + { + public static IEnumerable MarshallingRequiredTypes() => new[] + { + new object[] { typeof(bool) }, + new object[] { typeof(char) }, + new object[] { typeof(string) }, + new object[] { typeof(int[]) }, + new object[] { typeof(string[]) }, + new object[] { typeof(ConsoleKeyInfo) }, // struct + }; + + public static IEnumerable NoMarshallingRequiredTypes() => new[] + { + new object[] { typeof(byte) }, + new object[] { typeof(int) }, + new object[] { typeof(byte*) }, + new object[] { typeof(int*) }, + new object[] { typeof(bool*) }, + new object[] { typeof(char*) }, + new object[] { typeof(IntPtr) }, + new object[] { typeof(ConsoleKey) }, // enum + }; + + [Theory] + [MemberData(nameof(MarshallingRequiredTypes))] + public async Task TypeRequiresMarshalling_ReportsDiagnostic(Type type) + { + string source = DllImportWithType(type.FullName!); + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(ConvertToGeneratedDllImport) + .WithLocation(0) + .WithArguments("Method_Parameter"), + VerifyCS.Diagnostic(ConvertToGeneratedDllImport) + .WithLocation(1) + .WithArguments("Method_Return")); + } + + [Theory] + [MemberData(nameof(MarshallingRequiredTypes))] + [MemberData(nameof(NoMarshallingRequiredTypes))] + public async Task ByRef_ReportsDiagnostic(Type type) + { + string typeName = type.FullName!; + string source = @$" +using System.Runtime.InteropServices; +unsafe partial class Test +{{ + [DllImport(""DoesNotExist"")] + public static extern void {{|#0:Method_In|}}(in {typeName} p); + + [DllImport(""DoesNotExist"")] + public static extern void {{|#1:Method_Out|}}(out {typeName} p); + + [DllImport(""DoesNotExist"")] + public static extern void {{|#2:Method_Ref|}}(ref {typeName} p); +}} +"; + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(ConvertToGeneratedDllImport) + .WithLocation(0) + .WithArguments("Method_In"), + VerifyCS.Diagnostic(ConvertToGeneratedDllImport) + .WithLocation(1) + .WithArguments("Method_Out"), + VerifyCS.Diagnostic(ConvertToGeneratedDllImport) + .WithLocation(2) + .WithArguments("Method_Ref")); + } + + [Fact] + public async Task PreserveSigFalse_ReportsDiagnostic() + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [DllImport(""DoesNotExist"", PreserveSig = false)] + public static extern void {{|#0:Method1|}}(); + + [DllImport(""DoesNotExist"", PreserveSig = true)] + public static extern void Method2(); +}} +"; + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(ConvertToGeneratedDllImport) + .WithLocation(0) + .WithArguments("Method1")); + } + + [Fact] + public async Task SetLastErrorTrue_ReportsDiagnostic() + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [DllImport(""DoesNotExist"", SetLastError = false)] + public static extern void Method1(); + + [DllImport(""DoesNotExist"", SetLastError = true)] + public static extern void {{|#0:Method2|}}(); +}} +"; + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(ConvertToGeneratedDllImport) + .WithLocation(0) + .WithArguments("Method2")); + } + + [Theory] + [MemberData(nameof(NoMarshallingRequiredTypes))] + public async Task BlittablePrimitive_NoDiagnostic(Type type) + { + string source = DllImportWithType(type.FullName!); + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task NotDllImport_NoDiagnostic() + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + public static extern bool Method1(bool p, in bool pIn, ref bool pRef, out bool pOut); + public static extern int Method2(int p, in int pIn, ref int pRef, out int pOut); +}} +"; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + private static string DllImportWithType(string typeName) => @$" +using System.Runtime.InteropServices; +unsafe partial class Test +{{ + [DllImport(""DoesNotExist"")] + public static extern void {{|#0:Method_Parameter|}}({typeName} p); + + [DllImport(""DoesNotExist"")] + public static extern {typeName} {{|#1:Method_Return|}}(); +}} +"; + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs index be1f1f4e7368e..33cbfb8805312 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs @@ -50,8 +50,37 @@ public Test() { var project = solution.GetProject(projectId)!; var compilationOptions = project.CompilationOptions!; + + var diagnosticOptions = compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings); + + // Explicitly enable diagnostics that are not enabled by default + var enableAnalyzersOptions = new System.Collections.Generic.Dictionary(); + foreach (var analyzer in GetDiagnosticAnalyzers().ToImmutableArray()) + { + foreach (var diagnostic in analyzer.SupportedDiagnostics) + { + if (diagnostic.IsEnabledByDefault) + continue; + + // Map the default severity to the reporting behaviour. + // We cannot simply use ReportDiagnostic.Default here, as diagnostics that are not enabled by default + // are treated as suppressed (regardless of their default severity). + var report = diagnostic.DefaultSeverity switch + { + DiagnosticSeverity.Error => ReportDiagnostic.Error, + DiagnosticSeverity.Warning => ReportDiagnostic.Warn, + DiagnosticSeverity.Info => ReportDiagnostic.Info, + DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden, + _ => ReportDiagnostic.Default + }; + enableAnalyzersOptions.Add(diagnostic.Id, report); + } + } + compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( - compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); + compilationOptions.SpecificDiagnosticOptions + .SetItems(CSharpVerifierHelper.NullableWarnings) + .AddRange(enableAnalyzersOptions)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); solution = solution.WithProjectMetadataReferences(projectId, project.MetadataReferences.Concat(ImmutableArray.Create(ancillary))); solution = solution.WithProjectParseOptions(projectId, ((CSharpParseOptions)project.ParseOptions!).WithLanguageVersion(LanguageVersion.Preview)); diff --git a/src/samples/DllImportGeneratorSample/.editorconfig b/src/samples/DllImportGeneratorSample/.editorconfig new file mode 100644 index 0000000000000..0c2c63edc1ba7 --- /dev/null +++ b/src/samples/DllImportGeneratorSample/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# DLLIMPORTGENANALYZER015: Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time +dotnet_diagnostic.DLLIMPORTGENANALYZER015.severity = default From 15c62720cacffd814257ff8966eaca8268c3ed59 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 4 Dec 2020 16:28:28 -0800 Subject: [PATCH 055/161] Reliability improvements for array marshalling (dotnet/runtimelab#384) Commit migrated from https://github.com/dotnet/runtimelab/commit/5a78d17b2ec1f9364446c016a60ca93a449d7e26 --- .../ArrayMarshallingCodeContext.cs | 26 ++++- .../Marshalling/BlittableArrayMarshaller.cs | 14 +-- ...nditionalStackallocMarshallingGenerator.cs | 35 ++++--- .../NonBlittableArrayMarshaller.cs | 98 ++++++++++++++----- 4 files changed, 124 insertions(+), 49 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs index 705d5d7b418bf..30e262e03e23f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs @@ -12,8 +12,11 @@ namespace Microsoft.Interop { internal sealed class ArrayMarshallingCodeContext : StubCodeContext { + public const string LocalManagedIdentifierSuffix = "_local"; + private readonly string indexerIdentifier; private readonly StubCodeContext parentContext; + private readonly bool appendLocalManagedIdentifierSuffix; public override bool PinningSupported => false; @@ -21,11 +24,28 @@ internal sealed class ArrayMarshallingCodeContext : StubCodeContext public override bool CanUseAdditionalTemporaryState => false; - public ArrayMarshallingCodeContext(Stage currentStage, string indexerIdentifier, StubCodeContext parentContext) + /// + /// Create a for marshalling elements of an array. + /// + /// The current marshalling stage. + /// The indexer in the loop to get the element to marshal from the array. + /// The parent context. + /// + /// For array marshalling, we sometimes cache the array in a local to avoid multithreading issues. + /// Set this to true to add the to the managed identifier when + /// marshalling the array elements to ensure that we use the local copy instead of the managed identifier + /// when marshalling elements. + /// + public ArrayMarshallingCodeContext( + Stage currentStage, + string indexerIdentifier, + StubCodeContext parentContext, + bool appendLocalManagedIdentifierSuffix) { CurrentStage = currentStage; this.indexerIdentifier = indexerIdentifier; this.parentContext = parentContext; + this.appendLocalManagedIdentifierSuffix = appendLocalManagedIdentifierSuffix; } /// @@ -36,6 +56,10 @@ public ArrayMarshallingCodeContext(Stage currentStage, string indexerIdentifier, public override (string managed, string native) GetIdentifiers(TypePositionInfo info) { var (managed, native) = parentContext.GetIdentifiers(info); + if (appendLocalManagedIdentifierSuffix) + { + managed += LocalManagedIdentifierSuffix; + } return ($"{managed}[{indexerIdentifier}]", $"{native}[{indexerIdentifier}]"); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs index 31638278ac036..033aa7b7d71a1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs @@ -204,13 +204,13 @@ protected override ExpressionSyntax GenerateAllocationExpression(TypePositionInf protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) { - // sizeof() * .Length - return BinaryExpression(SyntaxKind.MultiplyExpression, - SizeOfExpression(GetElementTypeSyntax(info)), - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(context.GetIdentifiers(info).managed), - IdentifierName("Length") - )); + // checked(sizeof() * .Length) + return CheckedExpression(SyntaxKind.CheckedExpression, + BinaryExpression(SyntaxKind.MultiplyExpression, + SizeOfExpression(GetElementTypeSyntax(info)), + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(context.GetIdentifiers(info).managed), + IdentifierName("Length")))); } protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs index 7250c4f8e8cea..7bc2a943e45b5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -79,9 +79,7 @@ protected IEnumerable GenerateConditionalAllocationSyntax( IdentifierName(nativeIdentifier), LiteralExpression(SyntaxKind.NullLiteralExpression))); yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), + GenerateNullCheckExpression(info, context), Block(statements)); yield break; } @@ -137,24 +135,15 @@ protected IEnumerable GenerateConditionalAllocationSyntax( ElseClause(marshalOnStack)); yield return IfStatement( - BinaryExpression( - SyntaxKind.EqualsExpression, - IdentifierName(managedIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block( - ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)))), - ElseClause(Block(byteLenAssignment, allocBlock))); + GenerateNullCheckExpression(info, context), + Block(byteLenAssignment, allocBlock)); } protected StatementSyntax GenerateConditionalAllocationFreeSyntax( TypePositionInfo info, StubCodeContext context) { - (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + (string managedIdentifier, _) = context.GetIdentifiers(info); string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(managedIdentifier); if (!UsesConditionalStackAlloc(info, context)) { @@ -219,6 +208,22 @@ protected abstract StatementSyntax GenerateStackallocOnlyValueMarshalling( protected abstract ExpressionSyntax GenerateFreeExpression( TypePositionInfo info, StubCodeContext context); + + /// + /// Generate code to check if the managed value is not null. + /// + /// Object to marshal + /// Code generation context + /// An expression that checks if the managed value is not null. + protected virtual ExpressionSyntax GenerateNullCheckExpression( + TypePositionInfo info, + StubCodeContext context) + { + return BinaryExpression( + SyntaxKind.NotEqualsExpression, + IdentifierName(context.GetIdentifiers(info).managed), + LiteralExpression(SyntaxKind.NullLiteralExpression)); + } /// public abstract TypeSyntax AsNativeType(TypePositionInfo info); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs index 6fe2811efcbdd..d4f9beebe406e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; - +using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -18,7 +18,7 @@ internal class NonBlittableArrayMarshaller : ConditionalStackallocMarshallingGen private const string IndexerIdentifier = "__i"; - private IMarshallingGenerator _elementMarshaller; + private readonly IMarshallingGenerator _elementMarshaller; private readonly ExpressionSyntax _numElementsExpr; public NonBlittableArrayMarshaller(IMarshallingGenerator elementMarshaller, ExpressionSyntax numElementsExpr) @@ -64,6 +64,8 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); + bool cacheManagedValue = ShouldCacheManagedValue(info, context); + string managedLocal = !cacheManagedValue ? managedIdentifer : managedIdentifer + ArrayMarshallingCodeContext.LocalManagedIdentifierSuffix; switch (context.CurrentStage) { @@ -71,70 +73,91 @@ public override IEnumerable Generate(TypePositionInfo info, Stu if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) yield return conditionalAllocSetup; + if (cacheManagedValue) + { + yield return LocalDeclarationStatement( + VariableDeclaration( + info.ManagedType.AsTypeSyntax(), + SingletonSeparatedList( + VariableDeclarator(managedLocal) + .WithInitializer(EqualsValueClause( + IdentifierName(managedIdentifer)))))); + } break; case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) { foreach (var statement in GenerateConditionalAllocationSyntax( - info, - context, - StackAllocBytesThreshold)) + info, + context, + StackAllocBytesThreshold)) { yield return statement; } // Iterate through the elements of the array to marshal them - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context); + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); yield return IfStatement(BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedIdentifer), + IdentifierName(managedLocal), LiteralExpression(SyntaxKind.NullLiteralExpression)), - MarshallerHelpers.GetForLoop(managedIdentifer, IndexerIdentifier) + MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) .WithStatement(Block( - List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext))))); + List(_elementMarshaller.Generate( + info with { ManagedType = GetElementTypeSymbol(info) }, + arraySubContext))))); } break; case StubCodeContext.Stage.Unmarshal: if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context); - + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); + yield return IfStatement( BinaryExpression(SyntaxKind.NotEqualsExpression, IdentifierName(nativeIdentifier), LiteralExpression(SyntaxKind.NullLiteralExpression)), Block( - // = new []; + // = new []; ExpressionStatement( AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifer), + IdentifierName(managedLocal), ArrayCreationExpression( ArrayType(GetElementTypeSymbol(info).AsTypeSyntax(), SingletonList(ArrayRankSpecifier( SingletonSeparatedList(_numElementsExpr))))))), // Iterate through the elements of the native array to unmarshal them - MarshallerHelpers.GetForLoop(managedIdentifer, IndexerIdentifier) + MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) .WithStatement(Block( List(_elementMarshaller.Generate( info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext))))), ElseClause( ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifer), + IdentifierName(managedLocal), LiteralExpression(SyntaxKind.NullLiteralExpression))))); + + if (cacheManagedValue) + { + yield return ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + IdentifierName(managedLocal)) + ); + } } break; case StubCodeContext.Stage.Cleanup: { - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context); + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); var elementCleanup = List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext)); if (elementCleanup.Count != 0) { // Iterate through the elements of the native array to clean up any unmanaged resources. yield return IfStatement( BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedIdentifer), + IdentifierName(managedLocal), LiteralExpression(SyntaxKind.NullLiteralExpression)), - MarshallerHelpers.GetForLoop(managedIdentifer, IndexerIdentifier) + MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) .WithStatement(Block(elementCleanup))); } yield return GenerateConditionalAllocationFreeSyntax(info, context); @@ -143,6 +166,11 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } } + private static bool ShouldCacheManagedValue(TypePositionInfo info, StubCodeContext context) + { + return info.IsByRef && context.CanUseAdditionalTemporaryState; + } + public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { return true; @@ -163,13 +191,18 @@ protected override ExpressionSyntax GenerateAllocationExpression(TypePositionInf protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) { - // sizeof() * .Length - return BinaryExpression(SyntaxKind.MultiplyExpression, - SizeOfExpression(GetNativeElementTypeSyntax(info)), - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(context.GetIdentifiers(info).managed), - IdentifierName("Length") - )); + string managedIdentifier = context.GetIdentifiers(info).managed; + if (ShouldCacheManagedValue(info, context)) + { + managedIdentifier += ArrayMarshallingCodeContext.LocalManagedIdentifierSuffix; + } + // checked(sizeof() * .Length) + return CheckedExpression(SyntaxKind.CheckedExpression, + BinaryExpression(SyntaxKind.MultiplyExpression, + SizeOfExpression(GetNativeElementTypeSyntax(info)), + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName("Length")))); } protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) @@ -191,6 +224,19 @@ protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info ParseTypeName("System.IntPtr"), IdentifierName(context.GetIdentifiers(info).native)))))); } - } + protected override ExpressionSyntax GenerateNullCheckExpression(TypePositionInfo info, StubCodeContext context) + { + string managedIdentifier = context.GetIdentifiers(info).managed; + if (ShouldCacheManagedValue(info, context)) + { + managedIdentifier += ArrayMarshallingCodeContext.LocalManagedIdentifierSuffix; + } + + return BinaryExpression( + SyntaxKind.NotEqualsExpression, + IdentifierName(managedIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)); + } + } } From f037d9ea4ad13449a3436ea8b490e7fec17835ed Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 7 Dec 2020 12:05:27 -0800 Subject: [PATCH 056/161] Update prefix of packages and published assemblies (dotnet/runtimelab#423) * Prefix all packages and and published assemblies with "Microsoft.Interop.*" Commit migrated from https://github.com/dotnet/runtimelab/commit/e87c78ea898614339f7f043791f1af07d1abf785 --- .../DllImportGenerator.csproj | 1 + .../Ancillary.Interop.csproj | 1 + .../DllImportGenerator.Tests/ArrayTests.cs | 16 +-- .../BlittableStructTests.cs | 6 +- .../DllImportGenerator.Tests/BooleanTests.cs | 30 ++--- .../CharacterTests.cs | 12 +- .../DllImportGenerator.Tests/Constants.cs | 7 ++ .../CustomMarshallingTests.cs | 16 +-- .../DllImportGenerator.Tests/DelegateTests.cs | 4 +- .../DllImportGenerator.Tests/EnumTests.cs | 16 +-- .../DllImportGenerator.Tests/PointerTests.cs | 6 +- .../PreserveSigTests.cs | 34 +++--- .../SafeHandleTests.cs | 8 +- .../SetLastErrorTests.cs | 6 +- .../DllImportGenerator.Tests/StringTests.cs | 104 +++++++++--------- .../NativeExports/NativeExports.csproj | 1 + .../DllImportGeneratorSample/Program.cs | 8 +- 17 files changed, 144 insertions(+), 132 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 860f0304186f5..c27c6653a738f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -1,6 +1,7 @@  + Microsoft.Interop.DllImportGenerator netstandard2.0 false true 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 642e04fe9e5d5..e223452209455 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 @@ -1,6 +1,7 @@ + Microsoft.Interop.Ancillary net5.0 8.0 System.Runtime.InteropServices 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 14874d436432c..778e30b6bfd4a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -12,30 +12,30 @@ partial class NativeExportsNE { public partial class Arrays { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_int_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum(int[] values, int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_int_array_ref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] public static partial int SumInArray(in int[] values, int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "duplicate_int_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] public static partial void Duplicate([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ref int[] values, int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "create_range_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] [return:MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] public static partial int[] CreateRange(int start, int end, out int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_string_lengths")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")] public static partial int SumStringLengths([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_strings")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings")] public static partial void ReverseStrings([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] ref string[] strArray, out int numElements); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "get_long_bytes")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] [return:MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(long))] public static partial byte[] GetLongBytes(long l); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "append_int_to_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "append_int_to_array")] public static partial void Append([MarshalAs(UnmanagedType.LPArray, SizeConst = 1, SizeParamIndex = 1)] ref int[] values, int numOriginalValues, int newValue); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs index 558f596b38634..7c8c7130f4bdc 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs @@ -8,15 +8,15 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_byref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static partial void DoubleIntFieldsByRef(ref IntFields result); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_refreturn")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] public static partial void DoubleIntFieldsRefReturn( IntFields input, ref IntFields result); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_refreturn")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] public static partial void DoubleIntFieldsOutReturn( IntFields input, out IntFields result); diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs index 4f870d7a44a2f..673e7647b5302 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs @@ -7,52 +7,52 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bytebool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] public static partial uint ReturnByteBoolAsUInt([MarshalAs(UnmanagedType.U1)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bytebool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] public static partial uint ReturnSByteBoolAsUInt([MarshalAs(UnmanagedType.I1)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "variantbool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "variantbool_return_as_uint")] public static partial uint ReturnVariantBoolAsUInt([MarshalAs(UnmanagedType.VariantBool)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] public static partial uint ReturnIntBoolAsUInt([MarshalAs(UnmanagedType.I4)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] public static partial uint ReturnUIntBoolAsUInt([MarshalAs(UnmanagedType.U4)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] public static partial uint ReturnWinBoolAsUInt([MarshalAs(UnmanagedType.Bool)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool ReturnUIntAsByteBool(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] [return: MarshalAs(UnmanagedType.VariantBool)] public static partial bool ReturnUIntAsVariantBool(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool ReturnUIntAsWinBool(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsRefByteBool(uint input, [MarshalAs(UnmanagedType.U1)] ref bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsOutByteBool(uint input, [MarshalAs(UnmanagedType.U1)] out bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsRefVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] ref bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsOutVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] out bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsRefWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] ref bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsOutWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] out bool res); } 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 b8a547904c820..1ca56d1197adf 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs @@ -7,23 +7,23 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "unicode_return_as_uint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "unicode_return_as_uint", CharSet = CharSet.Unicode)] public static partial uint ReturnUnicodeAsUInt(char input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_uint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.Unicode)] public static partial char ReturnUIntAsUnicode(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] public static partial void ReturnUIntAsRefUnicode(uint input, ref char res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] public static partial void ReturnUIntAsOutUnicode(uint input, out char res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_uint", CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.None)] [return: MarshalAs(UnmanagedType.U2)] public static partial char ReturnU2AsU2IgnoreCharSet([MarshalAs(UnmanagedType.U2)] char input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_uint", CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I2)] public static partial char ReturnI2AsI2IgnoreCharSet([MarshalAs(UnmanagedType.I2)] char input); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs new file mode 100644 index 0000000000000..8c5a2812d08af --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs @@ -0,0 +1,7 @@ +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE); + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs index 1dab47e72a271..a52aae7029e80 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs @@ -9,31 +9,31 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "stringcontainer_deepduplicate")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_deepduplicate")] public static partial void DeepDuplicateStrings(StringContainer strings, out StringContainer pStringsOut); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "stringcontainer_reverse_strings")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_reverse_strings")] public static partial void ReverseStrings(ref StringContainer strings); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "get_long_bytes_as_double")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes_as_double")] public static partial double GetLongBytesAsDouble([MarshalUsing(typeof(DoubleToLongMarshaler))] double d); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "negate_bools")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "negate_bools")] public static partial void NegateBools( BoolStruct boolStruct, out BoolStruct pBoolStructOut); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "and_bools_ref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_bools_ref")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool AndBoolsRef(in BoolStruct boolStruct); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "double_int_ref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "double_int_ref")] public static partial IntWrapper DoubleIntRef(IntWrapper pInt); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_replace_ref_ushort")] public static partial void ReverseReplaceString([MarshalUsing(typeof(Utf16StringMarshaler))] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "return_length_ushort")] public static partial int ReturnStringLength([MarshalUsing(typeof(Utf16StringMarshaler))] string s); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs index 24ac17cec0d0f..72160892d97e3 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs @@ -8,12 +8,12 @@ partial class NativeExportsNE { public delegate void VoidVoid(); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "invoke_callback_after_gc")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] public static partial void InvokeAfterGC(VoidVoid cb); public delegate int IntIntInt(int a, int b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "invoke_callback_blittable_args")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] public static partial int InvokeWithBlittableArgument(IntIntInt cb, int a, int b); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs index 1ad4397724c0a..d39b3805abc43 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs @@ -9,31 +9,31 @@ partial class NativeExportsNE { public partial class IntEnum { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_return_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_int")] public static partial EnumTests.IntEnum Subtract_Return(EnumTests.IntEnum a, EnumTests.IntEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_out_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_int")] public static partial void Subtract_Out(EnumTests.IntEnum a, EnumTests.IntEnum b, out EnumTests.IntEnum c); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static partial void Subtract_Ref(EnumTests.IntEnum a, ref EnumTests.IntEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static partial void Subtract_In(EnumTests.IntEnum a, in EnumTests.IntEnum b); } public partial class ByteEnum { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_return_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_byte")] public static partial EnumTests.ByteEnum Subtract_Return(EnumTests.ByteEnum a, EnumTests.ByteEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_out_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_byte")] public static partial void Subtract_Out(EnumTests.ByteEnum a, EnumTests.ByteEnum b, out EnumTests.ByteEnum c); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static partial void Subtract_Ref(EnumTests.ByteEnum a, ref EnumTests.ByteEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static partial void Subtract_In(EnumTests.ByteEnum a, in EnumTests.ByteEnum b); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs index 121ff0e254e5e..8a15c7ce36ef7 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs @@ -8,13 +8,13 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static unsafe partial void Subtract_Int_Ptr(int a, int* b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static unsafe partial void Subtract_Byte_Ptr(byte a, byte* b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_byref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static unsafe partial void DoubleIntFields_Ptr(IntFields* result); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs index 2422192a9a307..079f1d17bb9ba 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs @@ -11,54 +11,54 @@ public partial class PreserveSig { public partial class False { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_return", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_return", PreserveSig = false)] public static partial void NoReturnValue(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] public static partial void Int_Out(int i, out int ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] public static partial int Int_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] public static partial void Bool_Out(int i, [MarshalAs(UnmanagedType.U4)] out bool ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] [return: MarshalAs(UnmanagedType.U4)] public static partial bool Bool_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort", PreserveSig = false)] public static partial void Char_Out(int i, [MarshalAs(UnmanagedType.U2)] out char ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort", PreserveSig = false)] [return: MarshalAs(UnmanagedType.U2)] public static partial char Char_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] public static partial void String_Out(int i, [MarshalAs(UnmanagedType.LPWStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string String_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int_array", PreserveSig = false)] public static partial void IntArray_Out(int i, [MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(int))] out int[] ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int_array", PreserveSig = false)] [return: MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(int))] public static partial int[] IntArray_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] public static partial void StringArray_Out(int i, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = sizeof(int))] out string[] ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] [return: MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = sizeof(int))] public static partial string[] StringArray_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_handle", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_handle", PreserveSig = false)] public static partial void SafeHandle_Out(int hr, out DummySafeHandle ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_handle", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_handle", PreserveSig = false)] public static partial DummySafeHandle SafeHandle_AsReturn(int hr); } @@ -71,10 +71,10 @@ private DummySafeHandle() : base(ownsHandle: true) { } public partial class True { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_return", PreserveSig = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_return", PreserveSig = true)] public static partial int NoReturnValue(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = true)] public static partial int Int_Out(int i, out int ret); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs index fc71710057460..94903b3430185 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs @@ -20,18 +20,18 @@ protected override bool ReleaseHandle() } } - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "alloc_handle")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] public static partial NativeExportsSafeHandle AllocateHandle(); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "release_handle")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "release_handle")] [return:MarshalAs(UnmanagedType.I1)] private static partial bool ReleaseHandle(nint handle); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "is_handle_alive")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "is_handle_alive")] [return:MarshalAs(UnmanagedType.I1)] public static partial bool IsHandleAlive(NativeExportsSafeHandle handle); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "modify_handle")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "modify_handle")] public static partial void ModifyHandle(ref NativeExportsSafeHandle handle, [MarshalAs(UnmanagedType.I1)] bool newHandle); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs index ba59f95803a4b..45407ce0222b8 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -27,14 +27,14 @@ partial class NativeExportsNE { public partial class SetLastError { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error", SetLastError = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] public static partial int SetError(int error, byte shouldSetError); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error_return_string", SetLastError = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error_return_string", SetLastError = true)] [return: MarshalUsing(typeof(SetLastErrorMarshaller))] public static partial int SetError_CustomMarshallingSetsError(int error, byte shouldSetError); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error_return_string", SetLastError = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error_return_string", SetLastError = true)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string SetError_NonBlittableSignature(int error, [MarshalAs(UnmanagedType.U1)] bool shouldSetError, [MarshalAs(UnmanagedType.LPWStr)] string errorString); } 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 e35bfd671e463..cb2b9cb6853cb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs @@ -41,143 +41,143 @@ public class UShort public partial class Unicode { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Unicode)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Unicode)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Unicode)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReplace, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, CharSet = CharSet.Unicode)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class LPTStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPTStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPTStr)] string s, [MarshalAs(UnmanagedType.LPTStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPTStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); } public partial class LPWStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPWStr)] string s, [MarshalAs(UnmanagedType.LPWStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPWStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); } public partial class LPUTF8Str { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPUTF8Str)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPUTF8Str)] string s, [MarshalAs(UnmanagedType.LPUTF8Str)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPUTF8Str)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); } public partial class Ansi { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Ansi)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Ansi)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Ansi)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class LPStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPStr)] string s, [MarshalAs(UnmanagedType.LPStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s); } @@ -185,43 +185,43 @@ public partial class Auto { public partial class Unix { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Auto)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Auto)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Auto)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + [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(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Auto)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Auto)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Auto)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_Replace_Ref(ref string s); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 301246364e87f..85da2e62d45b8 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -1,6 +1,7 @@  + Microsoft.Interop.Tests.NativeExports net5.0 true true diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index f0490390f6ac3..6e2f1defd97c7 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -5,13 +5,15 @@ namespace Demo { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumi")] + public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sumi")] public static partial int Sum(int a, int b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumouti")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sumouti")] public static partial void Sum(int a, int b, out int c); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumrefi")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sumrefi")] public static partial void Sum(int a, ref int b); } From d24260a37fc02e15e0a34cb410da2708495c9f85 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 9 Dec 2020 17:42:28 -0800 Subject: [PATCH 057/161] Support arrays of types with simple custom marshalling (dotnet/runtimelab#379) Commit migrated from https://github.com/dotnet/runtimelab/commit/ada198fa6f8b04e735867b3dcd64e1342dbd13db --- .../ArrayMarshallingCodeContext.cs | 9 ++++ .../Marshalling/BlittableArrayMarshaller.cs | 20 ++++++--- .../Marshalling/MarshallingGenerator.cs | 35 ++++++++++----- .../NonBlittableArrayMarshaller.cs | 37 +++++++++++++-- .../MarshallingAttributeInfo.cs | 22 ++++----- .../DllImportGenerator/Resources.Designer.cs | 9 ++++ .../gen/DllImportGenerator/Resources.resx | 3 ++ .../gen/DllImportGenerator/StubCodeContext.cs | 16 +++++++ .../DllImportGenerator/TypePositionInfo.cs | 45 +++++++++++++------ .../DllImportGenerator/Compatibility.md | 2 + .../DllImportGenerator.Tests/ArrayTests.cs | 37 ++++++++++++++- .../CodeSnippets.cs | 40 +++++++++++++++++ .../CompileFails.cs | 3 ++ .../DllImportGenerator.UnitTests/Compiles.cs | 1 + .../tests/TestAssets/NativeExports/Arrays.cs | 14 ++++++ 15 files changed, 246 insertions(+), 47 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs index 30e262e03e23f..9e8d1ab5a2002 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs @@ -22,6 +22,15 @@ internal sealed class ArrayMarshallingCodeContext : StubCodeContext public override bool StackSpaceUsable => false; + /// + /// Additional variables other than the {managedIdentifier} and {nativeIdentifier} variables + /// can be added to the stub to track additional state for the marshaller in the stub. + /// + /// + /// Currently, array scenarios do not support declaring additional temporary variables to support + /// marshalling. This can be accomplished in the future with some additional infrastructure to support + /// declaring arrays additional arrays in the stub to support the temporary state. + /// public override bool CanUseAdditionalTemporaryState => false; /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs index 033aa7b7d71a1..2a7e54ac1b154 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs @@ -75,6 +75,13 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } yield break; } + + TypeSyntax spanElementTypeSyntax = GetElementTypeSyntax(info); + if (spanElementTypeSyntax is PointerTypeSyntax) + { + // Pointers cannot be passed to generics, so use IntPtr for this case. + spanElementTypeSyntax = ParseTypeName("System.IntPtr"); + } switch (context.CurrentStage) { @@ -116,14 +123,15 @@ public override IEnumerable Generate(TypePositionInfo info, Stu GenericName(TypeNames.System_Span) .WithTypeArgumentList( TypeArgumentList( - SingletonSeparatedList( - GetElementTypeSyntax(info))))) + SingletonSeparatedList(spanElementTypeSyntax)))) .WithArgumentList( ArgumentList( SeparatedList( new []{ Argument( - IdentifierName(nativeIdentifier)), + CastExpression( + PointerType(spanElementTypeSyntax), + IdentifierName(nativeIdentifier))), Argument( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, @@ -156,13 +164,15 @@ public override IEnumerable Generate(TypePositionInfo info, Stu GenericName(Identifier(TypeNames.System_Span), TypeArgumentList( SingletonSeparatedList( - GetElementTypeSyntax(info))))) + spanElementTypeSyntax)))) .WithArgumentList( ArgumentList( SeparatedList( new[]{ Argument( - IdentifierName(nativeIdentifier)), + CastExpression( + PointerType(spanElementTypeSyntax), + IdentifierName(nativeIdentifier))), Argument( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index d4c2409e61d8e..d2dd817bd3ec9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -182,16 +182,6 @@ public static IMarshallingGenerator Create( } return SafeHandle; - case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType: ITypeSymbol elementType }, MarshallingAttributeInfo: NoMarshallingInfo }: - return CreateArrayMarshaller(info, context, elementType, NoMarshallingInfo.Instance); - - case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType: ITypeSymbol elementType }, MarshallingAttributeInfo: ArrayMarshalAsInfo marshalAsInfo }: - if (marshalAsInfo.UnmanagedArrayType != UnmanagedArrayType.LPArray) - { - throw new MarshallingNotSupportedException(info, context); - } - return CreateArrayMarshaller(info, context, elementType, marshalAsInfo.CreateArraySubTypeMarshalAsInfo()); - // Marshalling in new model. // Must go before the cases that do not explicitly check for marshalling info to support // the user overridding the default marshalling rules with a MarshalUsing attribute. @@ -205,11 +195,16 @@ public static IMarshallingGenerator Create( case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo(string nativeTypeName) }: return Forwarder; + // Cases that just match on type must come after the checks that match only on marshalling attribute info. + // The checks below do not account for generic marshalling overrides like [MarshalUsing], so those checks must come first. case { ManagedType: { SpecialType: SpecialType.System_Char } }: return CreateCharMarshaller(info, context); case { ManagedType: { SpecialType: SpecialType.System_String } }: return CreateStringMarshaller(info, context); + + case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType: ITypeSymbol elementType } }: + return CreateArrayMarshaller(info, context, elementType); case { ManagedType: { SpecialType: SpecialType.System_Void } }: return Forwarder; @@ -362,9 +357,17 @@ private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(Type return numElementsExpression; } - private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info, StubCodeContext context, ITypeSymbol elementType, MarshallingInfo elementMarshallingInfo) + private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info, StubCodeContext context, ITypeSymbol elementType) { - var elementMarshaller = Create(TypePositionInfo.CreateForType(elementType, elementMarshallingInfo), context); + var elementMarshallingInfo = info.MarshallingAttributeInfo switch + { + ArrayMarshalAsInfo(UnmanagedType.LPArray, _) marshalAs => marshalAs.ElementMarshallingInfo, + ArrayMarshallingInfo marshalInfo => marshalInfo.ElementMarshallingInfo, + NoMarshallingInfo _ => NoMarshallingInfo.Instance, + _ => throw new MarshallingNotSupportedException(info, context) + }; + + var elementMarshaller = Create(TypePositionInfo.CreateForType(elementType, elementMarshallingInfo), new ArrayMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context, false)); ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { @@ -379,6 +382,14 @@ private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) { + if (marshalInfo.ValuePropertyType is not null && !context.CanUseAdditionalTemporaryState) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.ValuePropertyMarshallingRequiresAdditionalState + }; + } + // The marshalling method for this type doesn't support marshalling from native to managed, // but our scenario requires marshalling from native to managed. if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs index d4f9beebe406e..95b7fa1707668 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs @@ -95,16 +95,47 @@ public override IEnumerable Generate(TypePositionInfo info, Stu yield return statement; } + TypeSyntax spanElementTypeSyntax = GetNativeElementTypeSyntax(info); + if (spanElementTypeSyntax is PointerTypeSyntax) + { + // Pointers cannot be passed to generics, so use IntPtr for this case. + spanElementTypeSyntax = ParseTypeName("System.IntPtr"); + } + // Iterate through the elements of the array to marshal them var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); yield return IfStatement(BinaryExpression(SyntaxKind.NotEqualsExpression, IdentifierName(managedLocal), LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block( + // new Span(, .Length).Clear(); + ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ObjectCreationExpression( + GenericName(TypeNames.System_Span) + .WithTypeArgumentList( + TypeArgumentList( + SingletonSeparatedList(spanElementTypeSyntax)))) + .WithArgumentList( + ArgumentList( + SeparatedList( + new []{ + Argument( + CastExpression( + PointerType(spanElementTypeSyntax), + IdentifierName(nativeIdentifier))), + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifer), + IdentifierName("Length"))) + }))), + IdentifierName("Clear")), + ArgumentList())), MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) .WithStatement(Block( - List(_elementMarshaller.Generate( - info with { ManagedType = GetElementTypeSymbol(info) }, - arraySubContext))))); + List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext)))))); } break; case StubCodeContext.Stage.Unmarshal: diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 40998a3ba64f4..891eed70a4ac0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -60,20 +60,11 @@ enum UnmanagedArrayType /// internal sealed record ArrayMarshalAsInfo( UnmanagedArrayType UnmanagedArrayType, - UnmanagedType UnmanagedArraySubType, int ArraySizeConst, short ArraySizeParamIndex, - CharEncoding CharEncoding) : MarshalAsInfo((UnmanagedType)UnmanagedArrayType, CharEncoding) - { - public MarshallingInfo CreateArraySubTypeMarshalAsInfo() - { - if (UnmanagedArraySubType == (UnmanagedType)UnspecifiedData) - { - return NoMarshallingInfo.Instance; - } - return new MarshalAsInfo(UnmanagedArraySubType, CharEncoding); - } - + CharEncoding CharEncoding, + MarshallingInfo ElementMarshallingInfo) : MarshalAsInfo((UnmanagedType)UnmanagedArrayType, CharEncoding) + { public const short UnspecifiedData = -1; } @@ -113,5 +104,10 @@ internal sealed record GeneratedNativeMarshallingAttributeInfo( /// The type of the element is a SafeHandle-derived type with no marshalling attributes. /// internal sealed record SafeHandleMarshallingInfo : MarshallingInfo; - + + + /// + /// Default marshalling for arrays + /// + internal sealed record ArrayMarshallingInfo(MarshallingInfo ElementMarshallingInfo) : MarshallingInfo; } 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 2123b4d92ff1a..d7e9b3f4bc202 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -508,6 +508,15 @@ internal static string TypeNotSupportedTitle { } } + /// + /// Looks up a localized string similar to Marshalling a value between managed and native with a native type with a 'Value' property requires extra state, which is not supported in this context.. + /// + internal static string ValuePropertyMarshallingRequiresAdditionalState { + get { + return ResourceManager.GetString("ValuePropertyMarshallingRequiresAdditionalState", resourceCulture); + } + } + /// /// Looks up a localized string similar to The native type's 'Value' property must have a getter to support marshalling from managed to native.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 5e4d1bc8c9c05..a524a25381e88 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -273,6 +273,9 @@ Specified type is not supported by source-generated P/Invokes + + Marshalling a value between managed and native with a native type with a 'Value' property requires extra state, which is not supported in this context. + The native type's 'Value' property must have a getter to support marshalling from managed to native. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index ea84f868b16a6..3ddef8d5e331f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -62,10 +62,26 @@ public enum Stage public Stage CurrentStage { get; protected set; } = Stage.Invalid; + /// + /// A fixed statement can be used on an individual value and the pointer + /// can be passed to native code. + /// public abstract bool PinningSupported { get; } + /// + /// Memory can be allocated via the stackalloc keyword and will live through + /// the full native context of the call. + /// public abstract bool StackSpaceUsable { get; } + /// + /// Additional variables other than the {managedIdentifier} and {nativeIdentifier} variables + /// can be added to the stub to track additional state for the marshaller in the stub. + /// + /// + /// In scenarios where the stub is defined within a single function, additional local variables + /// can be defined. + /// public abstract bool CanUseAdditionalTemporaryState { get; } protected const string GeneratedNativeIdentifierSuffix = "_gen_native"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index bb9cfde5b81b9..92e909b62ff31 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -105,7 +105,7 @@ private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable< if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) { // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute - return CreateMarshalAsInfo(attrData, defaultInfo, diagnostics); + return CreateMarshalAsInfo(type, attrData, defaultInfo, compilation, diagnostics); } else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) { @@ -135,7 +135,7 @@ private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable< // If the type doesn't have custom attributes that dictate marshalling, // then consider the type itself. - if (TryCreateTypeBasedMarshallingInfo(type, compilation, out MarshallingInfo infoMaybe)) + if (TryCreateTypeBasedMarshallingInfo(type, defaultInfo, compilation, diagnostics, out MarshallingInfo infoMaybe)) { return infoMaybe; } @@ -151,7 +151,7 @@ private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable< return NoMarshallingInfo.Instance; - static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData, DefaultMarshallingInfo defaultInfo, GeneratorDiagnostics diagnostics) + static MarshalAsInfo CreateMarshalAsInfo(ITypeSymbol type, AttributeData attrData, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) { object unmanagedTypeObj = attrData.ConstructorArguments[0].Value!; UnmanagedType unmanagedType = unmanagedTypeObj is short @@ -208,15 +208,28 @@ static MarshalAsInfo CreateMarshalAsInfo(AttributeData attrData, DefaultMarshall } } - return isArrayType - ? new ArrayMarshalAsInfo( - UnmanagedArrayType: (UnmanagedArrayType)unmanagedType, - UnmanagedArraySubType: unmanagedArraySubType, - ArraySizeConst: arraySizeConst, - ArraySizeParamIndex: arraySizeParamIndex, - CharEncoding: defaultInfo.CharEncoding - ) - : new MarshalAsInfo(unmanagedType, defaultInfo.CharEncoding); + if (!isArrayType) + { + return new MarshalAsInfo(unmanagedType, defaultInfo.CharEncoding); + } + + MarshallingInfo elementMarshallingInfo = NoMarshallingInfo.Instance; + if (unmanagedArraySubType != (UnmanagedType)ArrayMarshalAsInfo.UnspecifiedData) + { + elementMarshallingInfo = new MarshalAsInfo(unmanagedArraySubType, defaultInfo.CharEncoding); + } + else if (type is IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) + { + elementMarshallingInfo = GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics); + } + + return new ArrayMarshalAsInfo( + UnmanagedArrayType: (UnmanagedArrayType)unmanagedType, + ArraySizeConst: arraySizeConst, + ArraySizeParamIndex: arraySizeParamIndex, + CharEncoding: defaultInfo.CharEncoding, + ElementMarshallingInfo: elementMarshallingInfo + ); } static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol type, Compilation compilation, AttributeData attrData, bool allowGetPinnableReference) @@ -262,7 +275,7 @@ static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol ty NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null); } - static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, Compilation compilation, out MarshallingInfo marshallingInfo) + static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, out MarshallingInfo marshallingInfo) { var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); if (conversion.Exists @@ -273,6 +286,12 @@ static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, Compilation comp marshallingInfo = new SafeHandleMarshallingInfo(); return true; } + + if (type is IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) + { + marshallingInfo = new ArrayMarshallingInfo(GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics)); + return true; + } marshallingInfo = NoMarshallingInfo.Instance; return false; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index cea5adb2d918a..7579d77fff19e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -54,6 +54,8 @@ Specifying array-specific marshalling members on the `MarshalAsAttribute` such a Only single-dimensional arrays are supported for source generated marshalling. +Jagged arrays (arrays of arrays) are technically unsupported as was the case in the built-in marshalling system, but currently are not explicitly blocked by the source generator since they are not blocked at an architectural level, which was the case in the built-in system. + In the source-generated marshalling, arrays will be allocated on the stack (instead of through [`AllocCoTaskMem`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.alloccotaskmem)) if they are passed by value or by read-only reference if they contain at most 256 bytes of data. The built-in system does not support this optimization for arrays. ### `LCIDConversion` support 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 778e30b6bfd4a..7a7b738e71dc0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -1,4 +1,5 @@ -using System; +using SharedTypes; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; @@ -37,6 +38,10 @@ public partial class Arrays [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "append_int_to_array")] public static partial void Append([MarshalAs(UnmanagedType.LPArray, SizeConst = 1, SizeParamIndex = 1)] ref int[] values, int numOriginalValues, int newValue); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] + [return:MarshalAs(UnmanagedType.U1)] + public static partial bool AndAllMembers(BoolStruct[] pArray, int length); } } @@ -151,6 +156,36 @@ public void DynamicSizedArrayWithConstantComponent() Assert.Equal(array.Concat(new [] { newValue }), newArray); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public void ArrayWithSimpleNonBlittableTypeMarshalling(bool result) + { + var boolValues = new[] + { + new BoolStruct + { + b1 = true, + b2 = true, + b3 = true, + }, + new BoolStruct + { + b1 = true, + b2 = true, + b3 = true, + }, + new BoolStruct + { + b1 = true, + b2 = true, + b3 = result, + }, + }; + + Assert.Equal(result, NativeExportsNE.Arrays.AndAllMembers(boolValues, boolValues.Length)); + } + 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 3933c1528ae9e..214537e518e1a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -864,6 +864,46 @@ struct Native private int i; public S ToManaged() => new S { b = i != 0 }; } +"; + + public static string ArrayMarshallingWithCustomStructElementWithValueProperty => ArrayParametersAndModifiers("IntStructWrapper") + @" +[NativeMarshalling(typeof(IntStructWrapperNative))] +public struct IntStructWrapper +{ + public int Value; +} + +public struct IntStructWrapperNative +{ + public IntStructWrapperNative(IntStructWrapper managed) + { + Value = managed.Value; + } + + public int Value { get; set; } + + public IntStructWrapper ToManaged() => new IntStructWrapper { Value = Value }; +} +"; + + public static string ArrayMarshallingWithCustomStructElement => ArrayParametersAndModifiers("IntStructWrapper") + @" +[NativeMarshalling(typeof(IntStructWrapperNative))] +public struct IntStructWrapper +{ + public int Value; +} + +public struct IntStructWrapperNative +{ + private int value; + + public IntStructWrapperNative(IntStructWrapper managed) + { + value = managed.Value; + } + + public IntStructWrapper ToManaged() => new IntStructWrapper { Value = value }; +} "; } } 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 d050b72617d9e..41fe64dc27c85 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -73,6 +73,9 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.CustomStructMarshallingManagedToNativeOnlyReturnValue, 1, 0 }; yield return new object[] { CodeSnippets.CustomStructMarshallingNativeToManagedOnlyInParameter, 1, 0 }; yield return new object[] { CodeSnippets.CustomStructMarshallingStackallocOnlyRefParameter, 1, 0 }; + + // Custom type marshalling in arrays (complex case with Value property) + yield return new object[] { CodeSnippets.ArrayMarshallingWithCustomStructElementWithValueProperty, 5, 0 }; } [Theory] 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 07fef3b9500e1..c44f97ea528ab 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -159,6 +159,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.CustomStructMarshallingPinnableParametersAndModifiers }; yield return new[] { CodeSnippets.CustomStructMarshallingNativeTypePinnable }; yield return new[] { CodeSnippets.CustomStructMarshallingMarshalUsingParametersAndModifiers }; + yield return new[] { CodeSnippets.ArrayMarshallingWithCustomStructElement }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs index 97d09ef53e663..c48e1241cc079 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs @@ -1,3 +1,4 @@ +using SharedTypes; using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -120,5 +121,18 @@ public static void Append(int** values, int numOriginalValues, int newValue) newArray[numOriginalValues] = newValue; *values = newArray; } + + [UnmanagedCallersOnly(EntryPoint = "and_all_members")] + [DNNE.C99DeclCode("struct bool_struct;")] + public static byte AndAllMembers([DNNE.C99Type("struct bool_struct*")] BoolStructNative* pArray, int length) + { + bool result = true; + for (int i = 0; i < length; i++) + { + BoolStruct managed = pArray[i].ToManaged(); + result &= managed.b1 && managed.b2 && managed.b3; + } + return result ? 1 : 0; + } } } \ No newline at end of file From 9bc3120d563ed7062a79b5d1004fb7fe374bd53b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 4 Jan 2021 12:28:47 -0800 Subject: [PATCH 058/161] Implement support for configurable generator options. (dotnet/runtimelab#458) Commit migrated from https://github.com/dotnet/runtimelab/commit/9649d4319d518db34d531b8111610343f3573e62 --- .../DllImportGenerator/DllImportGenerator.cs | 13 ++-- .../DllImportGenerator.csproj | 4 +- .../gen/DllImportGenerator/DllImportStub.cs | 10 ++- .../Marshalling/MarshallingGenerator.cs | 31 ++++---- .../Marshalling/SafeHandleMarshaller.cs | 13 +++- ...Microsoft.Interop.DllImportGenerator.props | 19 +++++ .../gen/DllImportGenerator/OptionsHelper.cs | 26 +++++++ .../DllImportGenerator/StubCodeGenerator.cs | 25 ++++--- .../gen/DllImportGenerator/TypeNames.cs | 8 ++- .../DllImportGenerator.Tests.csproj | 1 + .../DllImportGenerator.UnitTests/Compiles.cs | 63 ++++++++++++++++ .../DllImportGeneratorOptionsProvider.cs | 71 +++++++++++++++++++ .../DllImportGenerator.UnitTests/TestUtils.cs | 39 +++++++--- 13 files changed, 274 insertions(+), 49 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 86bb2467ab17c..1e012f8b69fa6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -58,7 +58,7 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportTargetFrameworkNotSupported(MinimumSupportedFrameworkVersion); } - var env = new StubEnvironment(context.Compilation, isSupported, targetFrameworkVersion); + var env = new StubEnvironment(context.Compilation, isSupported, targetFrameworkVersion, context.AnalyzerConfigOptions.GlobalOptions); var generatedDllImports = new StringBuilder(); foreach (SyntaxReference synRef in synRec.Methods) { @@ -94,7 +94,7 @@ public void Execute(GeneratorExecutionContext context) // Process the GeneratedDllImport attribute DllImportStub.GeneratedDllImportData dllImportData; - AttributeSyntax dllImportAttr = this.ProcessGeneratedDllImportAttribute(methodSymbolInfo, generatedDllImportAttr, out dllImportData); + AttributeSyntax dllImportAttr = this.ProcessGeneratedDllImportAttribute(methodSymbolInfo, generatedDllImportAttr, context.AnalyzerConfigOptions.GlobalOptions.GenerateForwarders(), out dllImportData); Debug.Assert((dllImportAttr is not null) && (dllImportData is not null)); if (dllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) @@ -213,6 +213,7 @@ private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMayb private AttributeSyntax ProcessGeneratedDllImportAttribute( IMethodSymbol method, AttributeData attrData, + bool generateForwarders, out DllImportStub.GeneratedDllImportData dllImportData) { dllImportData = new DllImportStub.GeneratedDllImportData(); @@ -287,7 +288,9 @@ private AttributeSyntax ProcessGeneratedDllImportAttribute( Debug.Assert(expSyntaxMaybe is not null); - if (PassThroughToDllImportAttribute(namedArg.Key)) + // If we're generating a forwarder stub, then all parameters on the GenerateDllImport attribute + // must also be added to the generated DllImport attribute. + if (generateForwarders || PassThroughToDllImportAttribute(namedArg.Key)) { // Defer the name equals syntax till we know the value means something. If we created // an expression we know the key value was valid. @@ -340,9 +343,6 @@ static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum static bool PassThroughToDllImportAttribute(string argName) { -#if GENERATE_FORWARDER - return true; -#else // Certain fields on DllImport will prevent inlining. Their functionality should be handled by the // generated source, so the generated DllImport declaration should not include these fields. return argName switch @@ -355,7 +355,6 @@ static bool PassThroughToDllImportAttribute(string argName) nameof(DllImportStub.GeneratedDllImportData.SetLastError) => false, _ => true }; -#endif } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index c27c6653a738f..108713c4eddeb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -10,9 +10,6 @@ Preview enable Microsoft.Interop - - - @@ -42,6 +39,7 @@ + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index d51fe9ff6e016..9fe488f7dae2b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -13,7 +14,8 @@ namespace Microsoft.Interop internal record StubEnvironment( Compilation Compilation, bool SupportedTargetFramework, - Version TargetFrameworkVersion); + Version TargetFrameworkVersion, + AnalyzerConfigOptions Options); internal class DllImportStub { @@ -177,7 +179,9 @@ public static DllImportStub Create( }; var managedRetTypeInfo = retTypeInfo; - if (!dllImportData.PreserveSig) + // Do not manually handle PreserveSig when generating forwarders. + // We want the runtime to handle everything. + if (!dllImportData.PreserveSig && !env.Options.GenerateForwarders()) { // Create type info for native HRESULT return retTypeInfo = TypePositionInfo.CreateForType(env.Compilation.GetSpecialType(SpecialType.System_Int32), NoMarshallingInfo.Instance); @@ -203,7 +207,7 @@ public static DllImportStub Create( } // Generate stub code - var stubGenerator = new StubCodeGenerator(method, dllImportData, paramsTypeInfo, retTypeInfo, diagnostics); + var stubGenerator = new StubCodeGenerator(method, dllImportData, paramsTypeInfo, retTypeInfo, diagnostics, env.Options); var (code, dllImport) = stubGenerator.GenerateSyntax(); var additionalAttrs = new List(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index d2dd817bd3ec9..16428f1a482f3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -109,7 +110,6 @@ internal class MarshallingGenerators public static readonly Forwarder Forwarder = new Forwarder(); public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); - public static readonly SafeHandleMarshaller SafeHandle = new SafeHandleMarshaller(); public static readonly HResultExceptionMarshaller HResultException = new HResultExceptionMarshaller(); /// @@ -120,11 +120,14 @@ internal class MarshallingGenerators /// A instance. public static IMarshallingGenerator Create( TypePositionInfo info, - StubCodeContext context) + StubCodeContext context, + AnalyzerConfigOptions options) { -#if GENERATE_FORWARDER - return MarshallingGenerators.Forwarder; -#else + if (options.GenerateForwarders()) + { + return MarshallingGenerators.Forwarder; + } + if (info.IsNativeReturnPosition && !info.IsManagedReturnPosition) { // Use marshaller for native HRESULT return / exception throwing @@ -180,7 +183,7 @@ public static IMarshallingGenerator Create( { throw new MarshallingNotSupportedException(info, context); } - return SafeHandle; + return new SafeHandleMarshaller(options); // Marshalling in new model. // Must go before the cases that do not explicitly check for marshalling info to support @@ -204,7 +207,7 @@ public static IMarshallingGenerator Create( return CreateStringMarshaller(info, context); case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType: ITypeSymbol elementType } }: - return CreateArrayMarshaller(info, context, elementType); + return CreateArrayMarshaller(info, context, options, elementType); case { ManagedType: { SpecialType: SpecialType.System_Void } }: return Forwarder; @@ -212,7 +215,6 @@ public static IMarshallingGenerator Create( default: throw new MarshallingNotSupportedException(info, context); } -#endif } private static IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeContext context) @@ -303,7 +305,7 @@ private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo inf throw new MarshallingNotSupportedException(info, context); } - private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, StubCodeContext context) + private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, StubCodeContext context, AnalyzerConfigOptions options) { ExpressionSyntax numElementsExpression; if (info.MarshallingAttributeInfo is not ArrayMarshalAsInfo marshalAsInfo) @@ -338,7 +340,7 @@ private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(Type else { var (managed, native) = context.GetIdentifiers(paramIndexInfo); - string identifier = Create(paramIndexInfo, context).UsesNativeIdentifier(paramIndexInfo, context) ? native : managed; + string identifier = Create(paramIndexInfo, context, options).UsesNativeIdentifier(paramIndexInfo, context) ? native : managed; sizeParamIndexExpression = CastExpression( PredefinedType(Token(SyntaxKind.IntKeyword)), IdentifierName(identifier)); @@ -357,7 +359,7 @@ private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(Type return numElementsExpression; } - private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info, StubCodeContext context, ITypeSymbol elementType) + private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info, StubCodeContext context, AnalyzerConfigOptions options, ITypeSymbol elementType) { var elementMarshallingInfo = info.MarshallingAttributeInfo switch { @@ -367,12 +369,15 @@ private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info _ => throw new MarshallingNotSupportedException(info, context) }; - var elementMarshaller = Create(TypePositionInfo.CreateForType(elementType, elementMarshallingInfo), new ArrayMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context, false)); + var elementMarshaller = Create( + TypePositionInfo.CreateForType(elementType, elementMarshallingInfo), + new ArrayMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context, false), + options); ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { // In this case, we need a numElementsExpression supplied from metadata, so we'll calculate it here. - numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, context); + numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, context, options); } return elementMarshaller == Blittable diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index 1ecece16c8144..76bd092761318 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -3,6 +3,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -10,6 +11,12 @@ namespace Microsoft.Interop internal class SafeHandleMarshaller : IMarshallingGenerator { private static readonly TypeSyntax NativeType = ParseTypeName("global::System.IntPtr"); + private readonly AnalyzerConfigOptions options; + + public SafeHandleMarshaller(AnalyzerConfigOptions options) + { + this.options = options; + } public TypeSyntax AsNativeType(TypePositionInfo info) { @@ -83,7 +90,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont IdentifierName(managedIdentifier), InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + ParseName(TypeNames.MarshalEx(options)), GenericName(Identifier("CreateSafeHandle"), TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), ArgumentList()))); @@ -101,7 +108,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont .WithInitializer(EqualsValueClause( InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + ParseName(TypeNames.MarshalEx(options)), GenericName(Identifier("CreateSafeHandle"), TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), ArgumentList())))))); @@ -160,7 +167,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont StatementSyntax unmarshalStatement = ExpressionStatement( InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_InteropServices_MarshalEx), + ParseTypeName(TypeNames.MarshalEx(options)), IdentifierName("SetHandle")), ArgumentList(SeparatedList( new [] diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props new file mode 100644 index 0000000000000..bf6b2d4a0d0ca --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs new file mode 100644 index 0000000000000..39f2fdc80c1ec --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs @@ -0,0 +1,26 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace Microsoft.Interop +{ + public static class OptionsHelper + { + public const string UseMarshalTypeOption = "build_property.DllImportGenerator_UseMarshalType"; + public const string GenerateForwardersOption = "build_property.DllImportGenerator_GenerateForwarders"; + + private static bool GetBoolOption(this AnalyzerConfigOptions options, string key) + { + return options.TryGetValue(key, out string? value) + && bool.TryParse(value, out bool result) + && result; + } + + internal static bool UseMarshalType(this AnalyzerConfigOptions options) => options.GetBoolOption(UseMarshalTypeOption); + + internal static bool GenerateForwarders(this AnalyzerConfigOptions options) => options.GetBoolOption(GenerateForwardersOption); + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index e11337b791e1e..4a5f15ede8d4e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -48,7 +49,7 @@ internal sealed class StubCodeGenerator : StubCodeContext }; private readonly GeneratorDiagnostics diagnostics; - + private readonly AnalyzerConfigOptions options; private readonly IMethodSymbol stubMethod; private readonly DllImportStub.GeneratedDllImportData dllImportData; private readonly IEnumerable paramsTypeInfo; @@ -60,7 +61,8 @@ public StubCodeGenerator( DllImportStub.GeneratedDllImportData dllImportData, IEnumerable paramsTypeInfo, TypePositionInfo retTypeInfo, - GeneratorDiagnostics generatorDiagnostics) + GeneratorDiagnostics generatorDiagnostics, + AnalyzerConfigOptions options) { Debug.Assert(retTypeInfo.IsNativeReturnPosition); @@ -68,6 +70,7 @@ public StubCodeGenerator( this.dllImportData = dllImportData; this.paramsTypeInfo = paramsTypeInfo.ToList(); this.diagnostics = generatorDiagnostics; + this.options = options; // Get marshallers for parameters this.paramMarshallers = paramsTypeInfo.Select(p => CreateGenerator(p)).ToList(); @@ -79,7 +82,7 @@ public StubCodeGenerator( { try { - return (p, MarshallingGenerators.Create(p, this)); + return (p, MarshallingGenerators.Create(p, this, options)); } catch (MarshallingNotSupportedException e) { @@ -174,7 +177,9 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo AppendVariableDeclations(setupStatements, retMarshaller.TypeInfo, retMarshaller.Generator); } - if (this.dllImportData.SetLastError) + // Do not manually handle SetLastError when generating forwarders. + // We want the runtime to handle everything. + if (this.dllImportData.SetLastError && !options.GenerateForwarders()) { // Declare variable for last error setupStatements.Add(MarshallerHelpers.DeclareWithDefault( @@ -247,14 +252,16 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo invoke)); } - if (this.dllImportData.SetLastError) + // Do not manually handle SetLastError when generating forwarders. + // We want the runtime to handle everything. + if (this.dllImportData.SetLastError && !options.GenerateForwarders()) { // Marshal.SetLastSystemError(0); var clearLastError = ExpressionStatement( InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + ParseName(TypeNames.MarshalEx(options)), IdentifierName("SetLastSystemError")), ArgumentList(SingletonSeparatedList( Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(SuccessErrorCode))))))); @@ -267,7 +274,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + ParseName(TypeNames.MarshalEx(options)), IdentifierName("GetLastSystemError"))))); invokeStatement = Block(clearLastError, invokeStatement, getLastError); @@ -312,14 +319,14 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo allStatements.AddRange(tryStatements); } - if (this.dllImportData.SetLastError) + if (this.dllImportData.SetLastError && !options.GenerateForwarders()) { // Marshal.SetLastWin32Error(); allStatements.Add(ExpressionStatement( InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_MarshalEx), + ParseName(TypeNames.MarshalEx(options)), IdentifierName("SetLastWin32Error")), ArgumentList(SingletonSeparatedList( Argument(IdentifierName(LastErrorIdentifier))))))); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index e998b90956c68..a504b3b2bf43a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using Microsoft.CodeAnalysis.Diagnostics; namespace Microsoft.Interop { @@ -27,7 +28,12 @@ static class TypeNames public const string System_Runtime_InteropServices_Marshal = "System.Runtime.InteropServices.Marshal"; - public const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; + private const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; + + public static string MarshalEx(AnalyzerConfigOptions options) + { + return options.UseMarshalType() ? System_Runtime_InteropServices_Marshal : System_Runtime_InteropServices_MarshalEx; + } public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal"; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 6b3469c88b343..092c17338e2c5 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -1,4 +1,5 @@  + net5.0 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 c44f97ea528ab..9321046649308 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -175,5 +175,68 @@ public async Task ValidateSnippets(string source) var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); } + + public static IEnumerable CodeSnippetsToCompileWithForwarder() + { + yield return new[] { CodeSnippets.UserDefinedEntryPoint }; + yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; + + // Parameter / return types (supported in DllImportGenerator) + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + // Parameter / return types (not supported in DllImportGenerator) + yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; + } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompileWithForwarder))] + public async Task ValidateSnippetsWithForwarder(string source) + { + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators( + comp, + new DllImportGeneratorOptionsProvider(useMarshalType: false, generateForwarders: true), + out var generatorDiags, + new Microsoft.Interop.DllImportGenerator()); + + Assert.Empty(generatorDiags); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } + + public static IEnumerable CodeSnippetsToCompileWithMarshalType() + { + // SetLastError + yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; + + // SafeHandle + yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompileWithMarshalType))] + public async Task ValidateSnippetsWithMarshalType(string source) + { + Compilation comp = await TestUtils.CreateCompilation(source); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators( + comp, + new DllImportGeneratorOptionsProvider(useMarshalType: true, generateForwarders: false), + out var generatorDiags, + new Microsoft.Interop.DllImportGenerator()); + + Assert.Empty(generatorDiags); + + var newCompDiags = newComp.GetDiagnostics(); + + Assert.All(newCompDiags, diag => + { + Assert.Equal("CS0117", diag.Id); + Assert.StartsWith("'Marshal' does not contain a definition for ", diag.GetMessage()); + }); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs new file mode 100644 index 0000000000000..a774bd2ef353c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs @@ -0,0 +1,71 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.Interop; + +namespace DllImportGenerator.UnitTests +{ + /// + /// An implementation of that provides configuration in code + /// of the options supported by the DllImportGenerator source generator. Used for testing various configurations. + /// + internal class DllImportGeneratorOptionsProvider : AnalyzerConfigOptionsProvider + { + public DllImportGeneratorOptionsProvider(bool useMarshalType, bool generateForwarders) + { + GlobalOptions = new GlobalGeneratorOptions(useMarshalType, generateForwarders); + } + + public override AnalyzerConfigOptions GlobalOptions { get; } + + public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) + { + return EmptyOptions.Instance; + } + + public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) + { + return EmptyOptions.Instance; + } + + private class GlobalGeneratorOptions : AnalyzerConfigOptions + { + private readonly bool _useMarshalType = false; + private readonly bool _generateForwarders = false; + public GlobalGeneratorOptions(bool useMarshalType, bool generateForwarders) + { + _useMarshalType = useMarshalType; + _generateForwarders = generateForwarders; + } + + public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value) + { + switch (key) + { + case OptionsHelper.UseMarshalTypeOption: + value = _useMarshalType.ToString(); + return true; + + case OptionsHelper.GenerateForwardersOption: + value = _generateForwarders.ToString(); + return true; + + default: + value = null; + return false; + } + } + } + + private class EmptyOptions : AnalyzerConfigOptions + { + public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value) + { + value = null; + return false; + } + + public static AnalyzerConfigOptions Instance = new EmptyOptions(); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index 80b39053c3ffe..a57aca5cf62fb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -1,6 +1,8 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; @@ -20,15 +22,18 @@ internal static class TestUtils /// public static void AssertPreSourceGeneratorCompilation(Compilation comp) { + var allowedDiagnostics = new HashSet() + { + "CS8795", // Partial method impl missing + "CS0234", // Missing type or namespace - GeneratedDllImportAttribute + "CS0246", // Missing type or namespace - GeneratedDllImportAttribute + "CS8019", // Unnecessary using + }; var compDiags = comp.GetDiagnostics(); - foreach (var diag in compDiags) + Assert.All(compDiags, diag => { - Assert.True( - "CS8795".Equals(diag.Id) // Partial method impl missing - || "CS0234".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute - || "CS0246".Equals(diag.Id) // Missing type or namespace - GeneratedDllImportAttribute - || "CS8019".Equals(diag.Id)); // Unnecessary using - } + Assert.Subset(allowedDiagnostics, new HashSet { diag.Id }); + }); } /// @@ -85,13 +90,27 @@ public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() /// The resulting compilation public static Compilation RunGenerators(Compilation comp, out ImmutableArray diagnostics, params ISourceGenerator[] generators) { - CreateDriver(comp, generators).RunGeneratorsAndUpdateCompilation(comp, out var d, out diagnostics); + CreateDriver(comp, null, generators).RunGeneratorsAndUpdateCompilation(comp, out var d, out diagnostics); + return d; + } + + /// + /// Run the supplied generators on the compilation. + /// + /// Compilation target + /// Resulting diagnostics + /// Source generator instances + /// The resulting compilation + public static Compilation RunGenerators(Compilation comp, AnalyzerConfigOptionsProvider options, out ImmutableArray diagnostics, params ISourceGenerator[] generators) + { + CreateDriver(comp, options, generators).RunGeneratorsAndUpdateCompilation(comp, out var d, out diagnostics); return d; } - private static GeneratorDriver CreateDriver(Compilation c, params ISourceGenerator[] generators) + private static GeneratorDriver CreateDriver(Compilation c, AnalyzerConfigOptionsProvider? options, ISourceGenerator[] generators) => CSharpGeneratorDriver.Create( ImmutableArray.Create(generators), - parseOptions: (CSharpParseOptions)c.SyntaxTrees.First().Options); + parseOptions: (CSharpParseOptions)c.SyntaxTrees.First().Options, + optionsProvider: options); } } From 6f0fd0d1df13c675da6aa0ff7c7f162a1270b2ad Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 4 Jan 2021 14:29:27 -0800 Subject: [PATCH 059/161] Add handling for [In, Out] attributes. (dotnet/runtimelab#380) Commit migrated from https://github.com/dotnet/runtimelab/commit/18aa6f1961aa891569e384ef9c12e631ce4939d7 --- .../Marshalling/BlittableArrayMarshaller.cs | 179 ++++++++++-------- .../Marshalling/BlittableMarshaller.cs | 2 + .../Marshalling/BoolMarshaller.cs | 2 + .../Marshalling/CharMarshaller.cs | 2 + ...nditionalStackallocMarshallingGenerator.cs | 3 + .../Marshalling/CustomNativeTypeMarshaller.cs | 2 + .../Marshalling/DelegateMarshaller.cs | 2 + .../Marshalling/Forwarder.cs | 2 + .../Marshalling/HResultExceptionMarshaller.cs | 2 + .../Marshalling/MarshallerHelpers.cs | 13 ++ .../Marshalling/MarshallingGenerator.cs | 52 ++++- .../NonBlittableArrayMarshaller.cs | 64 ++++++- .../Marshalling/SafeHandleMarshaller.cs | 2 + .../Marshalling/StringMarshaller.Ansi.cs | 2 + .../StringMarshaller.PlatformDefined.cs | 2 + .../Marshalling/StringMarshaller.Utf16.cs | 2 + .../Marshalling/StringMarshaller.Utf8.cs | 2 + .../DllImportGenerator/Resources.Designer.cs | 44 +++++ .../gen/DllImportGenerator/Resources.resx | 15 ++ .../gen/DllImportGenerator/TypeNames.cs | 4 + .../DllImportGenerator/TypePositionInfo.cs | 56 +++++- .../DllImportGenerator/Compatibility.md | 4 + .../DllImportGenerator.Tests/ArrayTests.cs | 30 +++ .../CodeSnippets.cs | 14 ++ .../CompileFails.cs | 16 ++ .../DllImportGenerator.UnitTests/Compiles.cs | 5 + .../tests/TestAssets/NativeExports/Arrays.cs | 29 ++- .../TestAssets/SharedTypes/NonBlittable.cs | 17 ++ 28 files changed, 481 insertions(+), 88 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs index 2a7e54ac1b154..8e7291f9158b3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs @@ -101,92 +101,116 @@ public override IEnumerable Generate(TypePositionInfo info, Stu yield return statement; } - // new Span(managedIdentifier).CopyTo(new Span(nativeIdentifier, managedIdentifier.Length)); - yield return ExpressionStatement( - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ObjectCreationExpression( - GenericName(Identifier(TypeNames.System_Span), - TypeArgumentList( - SingletonSeparatedList( - GetElementTypeSyntax(info))))) - .WithArgumentList( - ArgumentList(SingletonSeparatedList( - Argument(IdentifierName(managedIdentifer))))), - IdentifierName("CopyTo"))) - .WithArgumentList( - ArgumentList( - SingletonSeparatedList( + // new Span(nativeIdentifier, managedIdentifier.Length) + var nativeSpan = ObjectCreationExpression( + GenericName(TypeNames.System_Span) + .WithTypeArgumentList( + TypeArgumentList( + SingletonSeparatedList(spanElementTypeSyntax)))) + .WithArgumentList( + ArgumentList( + SeparatedList( + new []{ Argument( - ObjectCreationExpression( - GenericName(TypeNames.System_Span) - .WithTypeArgumentList( - TypeArgumentList( - SingletonSeparatedList(spanElementTypeSyntax)))) - .WithArgumentList( - ArgumentList( - SeparatedList( - new []{ - Argument( - CastExpression( - PointerType(spanElementTypeSyntax), - IdentifierName(nativeIdentifier))), - Argument( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifer), - IdentifierName("Length")))})))))))); - } - break; - case StubCodeContext.Stage.Unmarshal: - if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) - { + CastExpression( + PointerType(spanElementTypeSyntax), + IdentifierName(nativeIdentifier))), + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifer), + IdentifierName("Length"))) + }))); + + // new Span(managedIdentifier).CopyTo(); yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block( - // = new []; - ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifer), - ArrayCreationExpression( - ArrayType(GetElementTypeSyntax(info), - SingletonList(ArrayRankSpecifier( - SingletonSeparatedList(_numElementsExpr))))))), - // new Span(nativeIdentifier, managedIdentifier.Length).CopyTo(managedIdentifier); + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(managedIdentifer), + LiteralExpression(SyntaxKind.NullLiteralExpression)), ExpressionStatement( InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ObjectCreationExpression( - GenericName(Identifier(TypeNames.System_Span), - TypeArgumentList( - SingletonSeparatedList( - spanElementTypeSyntax)))) - .WithArgumentList( - ArgumentList( - SeparatedList( - new[]{ - Argument( - CastExpression( - PointerType(spanElementTypeSyntax), - IdentifierName(nativeIdentifier))), - Argument( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifer), - IdentifierName("Length")))}))), + ObjectCreationExpression( + GenericName(Identifier(TypeNames.System_Span), + TypeArgumentList( + SingletonSeparatedList( + spanElementTypeSyntax)))) + .WithArgumentList( + ArgumentList(SingletonSeparatedList( + Argument(IdentifierName(managedIdentifer))))), IdentifierName("CopyTo"))) .WithArgumentList( ArgumentList( SingletonSeparatedList( - Argument(IdentifierName(managedIdentifer))))))), - ElseClause( - ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + Argument(nativeSpan)))))); + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition + || (info.IsByRef && info.RefKind != RefKind.In) + || info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) + { + // new Span(nativeIdentifier, managedIdentifier.Length).CopyTo(managedIdentifier); + var unmarshalContentsStatement = + ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ObjectCreationExpression( + GenericName(Identifier(TypeNames.System_Span), + TypeArgumentList( + SingletonSeparatedList( + spanElementTypeSyntax)))) + .WithArgumentList( + ArgumentList( + SeparatedList( + new[]{ + Argument(CastExpression( + PointerType(spanElementTypeSyntax), + IdentifierName(nativeIdentifier))), + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifer), + IdentifierName("Length"))) + }))), + IdentifierName("CopyTo"))) + .WithArgumentList( + ArgumentList( + SingletonSeparatedList( + Argument(IdentifierName(managedIdentifer)))))); + + if (info.IsManagedReturnPosition || info.IsByRef) + { + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(nativeIdentifier), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block( + // = new []; + ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + ArrayCreationExpression( + ArrayType(GetElementTypeSyntax(info), + SingletonList(ArrayRankSpecifier( + SingletonSeparatedList(_numElementsExpr))))))), + unmarshalContentsStatement), + ElseClause( + ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + LiteralExpression(SyntaxKind.NullLiteralExpression))))); + } + else + { + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, IdentifierName(managedIdentifer), - LiteralExpression(SyntaxKind.NullLiteralExpression))))); + LiteralExpression(SyntaxKind.NullLiteralExpression)), + unmarshalContentsStatement); + } + } break; case StubCodeContext.Stage.Cleanup: @@ -242,6 +266,11 @@ protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info ParseTypeName("System.IntPtr"), IdentifierName(context.GetIdentifiers(info).native)))))); } + + public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) + { + return !context.PinningSupported && marshalKind.HasFlag(ByValueContentsMarshalKind.Out); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs index bca6a7db58633..df59478466fa4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs @@ -99,6 +99,8 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { return info.IsByRef && !info.IsManagedReturnPosition && !context.PinningSupported; } + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs index ea9fbea51a555..b659ccbda4b78 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs @@ -100,6 +100,8 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs index 43026da60abc8..b3279390da77f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs @@ -84,5 +84,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs index 7bc2a943e45b5..f071d153d9bbb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -239,5 +239,8 @@ protected virtual ExpressionSyntax GenerateNullCheckExpression( /// public abstract bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); + + /// + public abstract bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs index 4278cd6a9c9f0..c2f70b702b8f0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs @@ -266,5 +266,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) } return true; } + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs index 7145ceb2e9918..b874ba0d1c6b5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs @@ -106,5 +106,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs index 00f307e9a324e..4921ae92ec640 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs @@ -32,5 +32,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => true; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs index 0cc935e089746..4b56c8a310725 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs @@ -41,6 +41,8 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs index 2de9b1ecc3202..fd2b8c6200b30 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs @@ -1,3 +1,4 @@ +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; @@ -60,6 +61,18 @@ public static LocalDeclarationStatementSyntax DeclareWithDefault(TypeSyntax type LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); } + public static RefKind GetRefKindForByValueContentsKind(this ByValueContentsMarshalKind byValue) + { + return byValue switch + { + ByValueContentsMarshalKind.Default => RefKind.None, + ByValueContentsMarshalKind.In => RefKind.In, + ByValueContentsMarshalKind.InOut => RefKind.Ref, + ByValueContentsMarshalKind.Out => RefKind.Out, + _ => throw new System.ArgumentOutOfRangeException(nameof(byValue)) + }; + } + public static class StringMarshaller { public static ExpressionSyntax AllocationExpression(CharEncoding encoding, string managedIdentifier) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 16428f1a482f3..9982ab0afb873 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -61,6 +61,15 @@ internal interface IMarshallingGenerator /// of may not be valid. /// bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); + + /// + /// Returns if the given ByValueContentsMarshalKind is supported in the current marshalling context. + /// A supported marshal kind has a different behavior than the default behavior. + /// + /// The marshal kind. + /// The marshalling context. + /// + bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); } /// @@ -113,7 +122,7 @@ internal class MarshallingGenerators public static readonly HResultExceptionMarshaller HResultException = new HResultExceptionMarshaller(); /// - /// Create an instance to marshalling the supplied type. + /// Create an instance for marshalling the supplied type in the given position. /// /// Type details /// Metadata about the stub the type is associated with @@ -122,6 +131,47 @@ public static IMarshallingGenerator Create( TypePositionInfo info, StubCodeContext context, AnalyzerConfigOptions options) + { + return ValidateByValueMarshalKind(context, info, CreateCore(info, context, options)); + } + + private static IMarshallingGenerator ValidateByValueMarshalKind(StubCodeContext context, TypePositionInfo info, IMarshallingGenerator generator) + { + if (info.IsByRef && info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.InOutAttributeByRefNotSupported + }; + } + else if (info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.In) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.InAttributeNotSupportedWithoutOut + }; + } + else if (info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default + && !generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, context)) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.InOutAttributeMarshalerNotSupported + }; + } + return generator; + } + + /// + /// Create an instance to marshalling the supplied type. + /// + /// Type details + /// Metadata about the stub the type is associated with + /// A instance. + private static IMarshallingGenerator CreateCore( + TypePositionInfo info, + StubCodeContext context, + AnalyzerConfigOptions options) { if (options.GenerateForwarders()) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs index 95b7fa1707668..40d793c731018 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis; @@ -64,6 +65,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); + RefKind elementRefKind = info.IsByRef ? info.RefKind : info.ByValueContentsMarshalKind.GetRefKindForByValueContentsKind(); bool cacheManagedValue = ShouldCacheManagedValue(info, context); string managedLocal = !cacheManagedValue ? managedIdentifer : managedIdentifer + ArrayMarshallingCodeContext.LocalManagedIdentifierSuffix; @@ -95,6 +97,8 @@ public override IEnumerable Generate(TypePositionInfo info, Stu yield return statement; } + var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); + TypeSyntax spanElementTypeSyntax = GetNativeElementTypeSyntax(info); if (spanElementTypeSyntax is PointerTypeSyntax) { @@ -102,8 +106,14 @@ public override IEnumerable Generate(TypePositionInfo info, Stu spanElementTypeSyntax = ParseTypeName("System.IntPtr"); } + if (info is { IsByRef: false, ByValueContentsMarshalKind: ByValueContentsMarshalKind.Out }) + { + // We don't marshal values from managed to native for [Out] by value arrays, + // we only allocate the buffer. + yield break; + } + // Iterate through the elements of the array to marshal them - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); yield return IfStatement(BinaryExpression(SyntaxKind.NotEqualsExpression, IdentifierName(managedLocal), LiteralExpression(SyntaxKind.NullLiteralExpression)), @@ -135,13 +145,46 @@ public override IEnumerable Generate(TypePositionInfo info, Stu ArgumentList())), MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) .WithStatement(Block( - List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext)))))); + List(_elementMarshaller.Generate( + info with { ManagedType = GetElementTypeSymbol(info), RefKind = elementRefKind }, + arraySubContext)))))); } break; case StubCodeContext.Stage.Unmarshal: - if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + if (info.IsManagedReturnPosition + || (info.IsByRef && info.RefKind != RefKind.In) + || info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) { var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); + // Iterate through the elements of the native array to unmarshal them + StatementSyntax unmarshalContentsStatement = + MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) + .WithStatement(Block( + List(_elementMarshaller.Generate( + info with { ManagedType = GetElementTypeSymbol(info), RefKind = elementRefKind }, + arraySubContext)))); + + if (!info.IsByRef) + { + if (info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) + { + yield return IfStatement( + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(managedLocal), + LiteralExpression(SyntaxKind.NullLiteralExpression)), + unmarshalContentsStatement); + + if (cacheManagedValue) + { + yield return ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifer), + IdentifierName(managedLocal)) + ); + } + yield break; + } + } yield return IfStatement( BinaryExpression(SyntaxKind.NotEqualsExpression, @@ -156,12 +199,8 @@ public override IEnumerable Generate(TypePositionInfo info, Stu ArrayType(GetElementTypeSymbol(info).AsTypeSyntax(), SingletonList(ArrayRankSpecifier( SingletonSeparatedList(_numElementsExpr))))))), - // Iterate through the elements of the native array to unmarshal them - MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) - .WithStatement(Block( - List(_elementMarshaller.Generate( - info with { ManagedType = GetElementTypeSymbol(info) }, - arraySubContext))))), + unmarshalContentsStatement + ), ElseClause( ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(managedLocal), @@ -180,7 +219,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu case StubCodeContext.Stage.Cleanup: { var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); - var elementCleanup = List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info) }, arraySubContext)); + var elementCleanup = List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info), RefKind = elementRefKind }, arraySubContext)); if (elementCleanup.Count != 0) { // Iterate through the elements of the native array to clean up any unmanaged resources. @@ -256,6 +295,11 @@ protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info IdentifierName(context.GetIdentifiers(info).native)))))); } + public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) + { + return marshalKind.HasFlag(ByValueContentsMarshalKind.Out); + } + protected override ExpressionSyntax GenerateNullCheckExpression(TypePositionInfo info, StubCodeContext context) { string managedIdentifier = context.GetIdentifiers(info).managed; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index 76bd092761318..5ff9b53c66cd2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -232,5 +232,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs index 0c3756791d8e8..b12dcfcd0231b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs @@ -147,6 +147,8 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } 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 always allocates for ANSI (Windows) and relies on the UTF-8 (non-Windows) string marshaller for allocation/marshalling. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs index aa3d6ff83452c..a9b665f88b094 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs @@ -109,6 +109,8 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } 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. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs index 69e7fa146f3a0..ffe989fddd2e2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -133,6 +133,8 @@ public override IEnumerable Generate(TypePositionInfo info, Stu public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; + protected override ExpressionSyntax GenerateAllocationExpression( TypePositionInfo info, StubCodeContext context, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs index 88172c2378240..a4c52bffa9a2f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs @@ -101,6 +101,8 @@ public override IEnumerable Generate(TypePositionInfo info, Stu public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; + protected override ExpressionSyntax GenerateAllocationExpression( TypePositionInfo info, StubCodeContext context, 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 d7e9b3f4bc202..5a033df756ec2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -283,6 +283,32 @@ internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFal } } + /// + /// Looks up a localized string similar to The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior.. + /// + internal static string InAttributeNotSupportedWithoutOut { + get { + return ResourceManager.GetString("InAttributeNotSupportedWithoutOut", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.. + /// + internal static string InOutAttributeByRefNotSupported { + get { + return ResourceManager.GetString("InOutAttributeByRefNotSupported", resourceCulture); + } + } + /// + /// Looks up a localized string similar to The '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter.. + /// + internal static string InOutAttributeMarshalerNotSupported { + get { + return ResourceManager.GetString("InOutAttributeMarshalerNotSupported", resourceCulture); + } + } + /// /// Looks up a localized string similar to Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. /// @@ -373,6 +399,24 @@ internal static string NativeTypeMustHaveRequiredShapeMessage { } } + /// + /// Looks up a localized string similar to The '[Out]' attribute is only supported on array parameters.. + /// + internal static string OutByValueNotSupportedDescription { + get { + return ResourceManager.GetString("OutByValueNotSupportedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '[Out]' attribute is not supported on the '{0}' parameter.. + /// + internal static string OutByValueNotSupportedMessage { + get { + return ResourceManager.GetString("OutByValueNotSupportedMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to The 'Value' property must not be a 'ref' or 'readonly ref' property.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index a524a25381e88..4fe08e2f600c1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -192,6 +192,15 @@ Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible + + The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior. + + + The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead. + + + The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter. + Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. @@ -222,6 +231,12 @@ The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}' + + The '[Out]' attribute is only supported on array parameters. + + + The '[Out]' attribute is not supported on the '{0}' parameter. + The 'Value' property must not be a 'ref' or 'readonly ref' property. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index a504b3b2bf43a..de5670fba75e4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -39,6 +39,10 @@ public static string MarshalEx(AnalyzerConfigOptions options) public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; + public const string System_Runtime_InteropServices_OutAttribute = "System.Runtime.InteropServices.OutAttribute"; + + public const string System_Runtime_InteropServices_InAttribute = "System.Runtime.InteropServices.InAttribute"; + public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 92e909b62ff31..10c707d9c68f9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -16,6 +16,35 @@ internal sealed record DefaultMarshallingInfo ( CharEncoding CharEncoding ); + /// + /// Describes how to marshal the contents of a value in comparison to the value itself. + /// Only makes sense for array-like types. For example, an "out" array doesn't change the + /// pointer to the array value, but it marshals the contents of the native array back to the + /// contents of the managed array. + /// + [Flags] + internal enum ByValueContentsMarshalKind + { + /// + /// Marshal contents from managed to native only. + /// This is the default behavior. + /// + Default = 0x0, + /// + /// Marshal contents from managed to native only. + /// This is the default behavior. + /// + In = 0x1, + /// + /// Marshal contents from native to managed only. + /// + Out = 0x2, + /// + /// Marshal contents both to and from native. + /// + InOut = In | Out + } + /// /// Positional type information involved in unmanaged/managed scenarios. /// @@ -43,6 +72,8 @@ private TypePositionInfo() public bool IsByRef => RefKind != RefKind.None; + public ByValueContentsMarshalKind ByValueContentsMarshalKind { get; init; } + public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } public bool IsNativeReturnPosition { get => this.NativeIndex == ReturnIndex; } @@ -60,7 +91,8 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, InstanceIdentifier = paramSymbol.Name, RefKind = paramSymbol.RefKind, RefKindSyntax = RefKindToSyntax(paramSymbol.RefKind), - MarshallingAttributeInfo = marshallingInfo + MarshallingAttributeInfo = marshallingInfo, + ByValueContentsMarshalKind = GetByValueContentsMarshalKind(paramSymbol.GetAttributes(), compilation) }; return typeInfo; @@ -297,6 +329,28 @@ static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshalli } } + private static ByValueContentsMarshalKind GetByValueContentsMarshalKind(IEnumerable attributes, Compilation compilation) + { + INamedTypeSymbol outAttributeType = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_OutAttribute)!; + INamedTypeSymbol inAttributeType = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_InAttribute)!; + + ByValueContentsMarshalKind marshalKind = ByValueContentsMarshalKind.Default; + + foreach (var attr in attributes) + { + if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, outAttributeType)) + { + marshalKind |= ByValueContentsMarshalKind.Out; + } + else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, inAttributeType)) + { + marshalKind |= ByValueContentsMarshalKind.In; + } + } + + return marshalKind; + } + private static SyntaxKind RefKindToSyntax(RefKind refKind) { return refKind switch diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index 7579d77fff19e..417feaedeaf5f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -62,6 +62,10 @@ In the source-generated marshalling, arrays will be allocated on the stack (inst [`LCIDConversionAttribute`](`https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute`) will not be supported for methods marked with `GeneratedDllImportAttribute`. +### `[In, Out]` Attributes + +In the source generated marshalling, the `[In]` and `[Out]` attributes will only be supported on parameters passed by value. For by-ref parameters, users should use the `in`, `ref`, or `out` keywords respectively. Additionally, they will only be supported in scenarios where applying them would result in behavior different from the default, such as applying `[Out]` or `[In, Out]` to a by-value non-blittable array parameter. This is in contrast to the built-in system which will allow them in all cases even when they have no effect. + ## Verison 0 This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. \ No newline at end of file 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 7a7b738e71dc0..5bc7629218315 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -39,6 +39,13 @@ public partial class Arrays [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "append_int_to_array")] public static partial void Append([MarshalAs(UnmanagedType.LPArray, SizeConst = 1, SizeParamIndex = 1)] ref int[] values, int numOriginalValues, int newValue); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "fill_range_array")] + [return: MarshalAs(UnmanagedType.U1)] + public static partial bool FillRangeArray([Out] IntStructWrapper[] array, int length, int start); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "double_values")] + public static partial bool DoubleValues([In, Out] IntStructWrapper[] array, int length); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] [return:MarshalAs(UnmanagedType.U1)] public static partial bool AndAllMembers(BoolStruct[] pArray, int length); @@ -156,6 +163,29 @@ public void DynamicSizedArrayWithConstantComponent() Assert.Equal(array.Concat(new [] { newValue }), newArray); } + [Fact] + public void ArrayByValueOutParameter() + { + var testArray = new IntStructWrapper[10]; + int start = 5; + + NativeExportsNE.Arrays.FillRangeArray(testArray, testArray.Length, start); + + Assert.Equal(Enumerable.Range(start, 10), testArray.Select(wrapper => wrapper.Value)); + } + + [Fact] + public void ArrayByValueInOutParameter() + { + var testValues = Enumerable.Range(42, 15).Select(i => new IntStructWrapper { Value = i }); + + var testArray = testValues.ToArray(); + + NativeExportsNE.Arrays.DoubleValues(testArray, testArray.Length); + + Assert.Equal(testValues.Select(wrapper => wrapper.Value * 2), testArray.Select(wrapper => wrapper.Value)); + } + [Theory] [InlineData(true)] [InlineData(false)] 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 214537e518e1a..324b66ece1353 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -367,6 +367,20 @@ partial class Test public static string BasicParametersAndModifiers() => BasicParametersAndModifiers(typeof(T).ToString()); + /// + /// Declaration with [In, Out] style attributes on a by-value parameter. + /// + public static string ByValueParameterWithModifier(string typeName, string attributeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [{attributeName}] {typeName} p); +}}"; + + public static string ByValueParameterWithModifier(string attributeName) => ByValueParameterWithModifier(typeof(T).ToString(), attributeName); + /// /// Declaration with parameters with MarshalAs. /// 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 41fe64dc27c85..61f98f45fff8d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -39,6 +39,22 @@ public static IEnumerable CodeSnippetsToCompile() // * UnmanagedType.CustomMarshaler, MarshalTypeRef, MarshalType, MarshalCookie yield return new object[] { CodeSnippets.MarshalAsCustomMarshalerOnTypes, 16, 0 }; + // Unsupported [In, Out] attributes usage + // Blittable array + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("Out"), 1, 0 }; + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("In, Out"), 1, 0 }; + + // By ref with [In, Out] attributes + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("in int", "In"), 1, 0 }; + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("ref int", "In"), 1, 0 }; + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("ref int", "In, Out"), 1, 0 }; + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("out int", "Out"), 1, 0 }; + + // By value non-array with [In, Out] attributes + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("In"), 1, 0 }; + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("Out"), 1, 0 }; + yield return new object[] { CodeSnippets.ByValueParameterWithModifier("In, Out"), 1, 0 }; + // Unsupported named arguments // * BestFitMapping, ThrowOnUnmappableChar yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 2, 0 }; 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 9321046649308..1db8e4b0ead8e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -91,6 +91,11 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPUTF8Str) }; yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; + // [In, Out] attributes + // By value non-blittable array + yield return new[] { CodeSnippets.ByValueParameterWithModifier("Out") }; + yield return new[] { CodeSnippets.ByValueParameterWithModifier("In, Out") }; + // Enums yield return new[] { CodeSnippets.EnumParameters }; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs index c48e1241cc079..4dc800685151d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs @@ -67,7 +67,34 @@ public static void Duplicate(int** values, int numValues) return retVal; } - + + [UnmanagedCallersOnly(EntryPoint = "fill_range_array")] + [DNNE.C99DeclCode("struct int_struct_wrapper;")] + public static byte FillRange([DNNE.C99Type("struct int_struct_wrapper*")] IntStructWrapperNative* numValues, int length, int start) + { + if (numValues == null) + { + return 0; + } + + for (int i = 0; i < length; i++, start++) + { + numValues[i] = new IntStructWrapperNative { value = start }; + } + + return 1; + } + + [UnmanagedCallersOnly(EntryPoint = "double_values")] + [DNNE.C99DeclCode("struct int_struct_wrapper { int value; };")] + public static void DoubleValues([DNNE.C99Type("struct int_struct_wrapper*")] IntStructWrapperNative* numValues, int length) + { + for (int i = 0; i < length; i++) + { + numValues[i].value *= 2; + } + } + [UnmanagedCallersOnly(EntryPoint = "sum_string_lengths")] public static int SumStringLengths(ushort** strArray) { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs index 86289c66e0d92..823f1da0334f9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs @@ -200,4 +200,21 @@ public void FreeNative() public const int StackBufferSize = 0x100; } + + [NativeMarshalling(typeof(IntStructWrapperNative))] + public struct IntStructWrapper + { + public int Value; + } + + public struct IntStructWrapperNative + { + public int value; + public IntStructWrapperNative(IntStructWrapper managed) + { + value = managed.Value; + } + + public IntStructWrapper ToManaged() => new IntStructWrapper { Value = value }; + } } From c64f379a0779ec6eff431b8ba97fa9448817dc39 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 11 Jan 2021 11:27:07 -0800 Subject: [PATCH 060/161] Update Compatibility doc for struct marshalling (dotnet/runtimelab#548) Commit migrated from https://github.com/dotnet/runtimelab/commit/e73c5de99907e5c362bc5290f3b1e2fb942a8e60 --- .../design/libraries/DllImportGenerator/Compatibility.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md index 417feaedeaf5f..c8f143f520c7f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -66,6 +66,10 @@ In the source-generated marshalling, arrays will be allocated on the stack (inst In the source generated marshalling, the `[In]` and `[Out]` attributes will only be supported on parameters passed by value. For by-ref parameters, users should use the `in`, `ref`, or `out` keywords respectively. Additionally, they will only be supported in scenarios where applying them would result in behavior different from the default, such as applying `[Out]` or `[In, Out]` to a by-value non-blittable array parameter. This is in contrast to the built-in system which will allow them in all cases even when they have no effect. +### Struct marshalling + +Support for struct marshalling in the source-generated marshalling is described in [StructMarshalling.md](StructMarshalling.md). + ## Verison 0 -This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. \ No newline at end of file +This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. From 14ae6205ca67c26c255aa886f3df7af4c174823c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 11 Jan 2021 14:11:45 -0800 Subject: [PATCH 061/161] Add Benchmarks project. (dotnet/runtimelab#538) Commit migrated from https://github.com/dotnet/runtimelab/commit/54321e38193b175b4b62b3e2399d4c50a22af5a6 --- src/libraries/System.Runtime.InteropServices/gen/.gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/.gitignore b/src/libraries/System.Runtime.InteropServices/gen/.gitignore index 831de0b592d4f..6b22273110c17 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/.gitignore +++ b/src/libraries/System.Runtime.InteropServices/gen/.gitignore @@ -1,4 +1,5 @@ .vs/ **/bin **/obj -*.binlog \ No newline at end of file +*.binlog +BenchmarkDotNet.Artifacts \ No newline at end of file From 8ba6bf0bfa837a82faffb9b5b6ea9a6041ef464b Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 11 Jan 2021 14:57:23 -0800 Subject: [PATCH 062/161] Test fill-in (dotnet/runtimelab#535) - array: out byref, return/out with element marshalling - bool: in by ref, default marshalling - char: in by ref - SafeHandle: out by ref Commit migrated from https://github.com/dotnet/runtimelab/commit/a072658ef3ab7d46b4adffbc3d7a89bf211bf667 --- .../DllImportGenerator.Tests/ArrayTests.cs | 53 +++++++++-- .../BlittableStructTests.cs | 9 ++ .../DllImportGenerator.Tests/BooleanTests.cs | 85 ++++++++++++++--- .../CharacterTests.cs | 20 ++-- .../SafeHandleTests.cs | 13 +++ .../tests/TestAssets/NativeExports/Arrays.cs | 94 +++++++++++++------ .../tests/TestAssets/NativeExports/Handles.cs | 6 ++ 7 files changed, 225 insertions(+), 55 deletions(-) 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 5bc7629218315..d535c13d7691c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -26,11 +26,21 @@ public partial class Arrays [return:MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] public static partial int[] CreateRange(int start, int end, out int numValues); + [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_string_lengths")] public static partial int SumStringLengths([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings")] - public static partial void ReverseStrings([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] ref string[] strArray, out int numElements); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_replace")] + public static partial void ReverseStrings_Ref([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] ref string[] strArray, out int numElements); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_return")] + [return: MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] + public static partial string[] ReverseStrings_Return([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray, out int numElements); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_out")] + public static partial void ReverseStrings_Out([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray, out int numElements, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] out string[] res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] [return:MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(long))] @@ -88,16 +98,24 @@ public void IntArrayRefParameter() public void ArraysReturnedFromNative() { int start = 5; - int end = 20; - Assert.Equal(Enumerable.Range(start, end - start), NativeExportsNE.Arrays.CreateRange(start, end, out _)); + IEnumerable expected = Enumerable.Range(start, end - start); + Assert.Equal(expected, NativeExportsNE.Arrays.CreateRange(start, end, out _)); + + int[] res; + NativeExportsNE.Arrays.CreateRange_Out(start, end, out _, out res); + Assert.Equal(expected, res); } [Fact] public void NullArrayReturnedFromNative() { Assert.Null(NativeExportsNE.Arrays.CreateRange(1, 0, out _)); + + int[] res; + NativeExportsNE.Arrays.CreateRange_Out(1, 0, out _, out res); + Assert.Null(res); } private static string[] GetStringArray() @@ -131,20 +149,43 @@ public void ByRefArrayWithElementMarshalling() { var strings = GetStringArray(); var expectedStrings = strings.Select(s => ReverseChars(s)).ToArray(); - NativeExportsNE.Arrays.ReverseStrings(ref strings, out _); + NativeExportsNE.Arrays.ReverseStrings_Ref(ref strings, out _); Assert.Equal((IEnumerable)expectedStrings, strings); } + [Fact] + public void ReturnArrayWithElementMarshalling() + { + var strings = GetStringArray(); + var expectedStrings = strings.Select(s => ReverseChars(s)).ToArray(); + Assert.Equal(expectedStrings, NativeExportsNE.Arrays.ReverseStrings_Return(strings, out _)); + + string[] res; + NativeExportsNE.Arrays.ReverseStrings_Out(strings, out _, out res); + Assert.Equal(expectedStrings, res); + } + [Fact] public void ByRefNullArrayWithElementMarshalling() { string[] strings = null; - NativeExportsNE.Arrays.ReverseStrings(ref strings, out _); + NativeExportsNE.Arrays.ReverseStrings_Ref(ref strings, out _); Assert.Null(strings); } + [Fact] + public void ReturnNullArrayWithElementMarshalling() + { + string[] strings = null; + Assert.Null(NativeExportsNE.Arrays.ReverseStrings_Return(strings, out _)); + + string[] res; + NativeExportsNE.Arrays.ReverseStrings_Out(strings, out _, out res); + Assert.Null(res); + } + [Fact] public void ConstantSizeArray() { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs index 7c8c7130f4bdc..26a0cbd16306a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs @@ -11,6 +11,9 @@ partial class NativeExportsNE [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static partial void DoubleIntFieldsByRef(ref IntFields result); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] + public static partial void DoubleIntFieldsByRefIn(in IntFields result); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] public static partial void DoubleIntFieldsRefReturn( IntFields input, @@ -61,6 +64,12 @@ public void ValidateBlittableStruct() NativeExportsNE.DoubleIntFieldsByRef(ref input); Assert.Equal(expected, input); } + + { + input = initial; + NativeExportsNE.DoubleIntFieldsByRefIn(in input); + Assert.Equal(expected, input); // Updated even when passed with in keyword (matches built-in system) + } } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs index 673e7647b5302..40dbb9f1a653b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs @@ -25,6 +25,9 @@ partial class NativeExportsNE [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] public static partial uint ReturnWinBoolAsUInt([MarshalAs(UnmanagedType.Bool)] bool input); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] + public static partial uint ReturnDefaultBoolAsUInt(bool input); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool ReturnUIntAsByteBool(uint input); @@ -37,23 +40,44 @@ partial class NativeExportsNE [return: MarshalAs(UnmanagedType.Bool)] public static partial bool ReturnUIntAsWinBool(uint input); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] + public static partial bool ReturnUIntAsDefaultBool(uint input); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsByteBool_Ref(uint input, [MarshalAs(UnmanagedType.U1)] ref bool res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsByteBool_Out(uint input, [MarshalAs(UnmanagedType.U1)] out bool res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsByteBool_In(uint input, [MarshalAs(UnmanagedType.U1)] in bool res); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] - public static partial void ReturnUIntAsRefByteBool(uint input, [MarshalAs(UnmanagedType.U1)] ref bool res); + public static partial void ReturnUIntAsVariantBool_Ref(uint input, [MarshalAs(UnmanagedType.VariantBool)] ref bool res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] - public static partial void ReturnUIntAsOutByteBool(uint input, [MarshalAs(UnmanagedType.U1)] out bool res); + public static partial void ReturnUIntAsVariantBool_Out(uint input, [MarshalAs(UnmanagedType.VariantBool)] out bool res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] - public static partial void ReturnUIntAsRefVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] ref bool res); + public static partial void ReturnUIntAsVariantBool_In(uint input, [MarshalAs(UnmanagedType.VariantBool)] in bool res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] - public static partial void ReturnUIntAsOutVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] out bool res); + public static partial void ReturnUIntAsWinBool_Ref(uint input, [MarshalAs(UnmanagedType.Bool)] ref bool res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] - public static partial void ReturnUIntAsRefWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] ref bool res); + public static partial void ReturnUIntAsWinBool_Out(uint input, [MarshalAs(UnmanagedType.Bool)] out bool res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] - public static partial void ReturnUIntAsOutWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] out bool res); + public static partial void ReturnUIntAsWinBool_In(uint input, [MarshalAs(UnmanagedType.Bool)] in bool res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsDefaultBool_Ref(uint input, ref bool res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsDefaultBool_Out(uint input, out bool res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] + public static partial void ReturnUIntAsDefaultBool_In(uint input, in bool res); } public class BooleanTests @@ -77,6 +101,8 @@ public void ValidateBoolIsMarshalledAsExpected() Assert.Equal((uint)0, NativeExportsNE.ReturnUIntBoolAsUInt(false)); Assert.Equal((uint)1, NativeExportsNE.ReturnWinBoolAsUInt(true)); Assert.Equal((uint)0, NativeExportsNE.ReturnWinBoolAsUInt(false)); + Assert.Equal((uint)1, NativeExportsNE.ReturnDefaultBoolAsUInt(true)); + Assert.Equal((uint)0, NativeExportsNE.ReturnDefaultBoolAsUInt(false)); } [Theory] @@ -90,12 +116,16 @@ public void ValidateByteBoolReturns(uint value, bool expected) Assert.Equal(expected, NativeExportsNE.ReturnUIntAsByteBool(value)); bool result = !expected; - NativeExportsNE.ReturnUIntAsRefByteBool(value, ref result); + NativeExportsNE.ReturnUIntAsByteBool_Ref(value, ref result); Assert.Equal(expected, result); result = !expected; - NativeExportsNE.ReturnUIntAsOutByteBool(value, out result); + NativeExportsNE.ReturnUIntAsByteBool_Out(value, out result); Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsByteBool_In(value, in result); + Assert.Equal(!expected, result); // Should not be updated when using 'in' } [Theory] @@ -110,12 +140,16 @@ public void ValidateVariantBoolReturns(uint value, bool expected) Assert.Equal(expected, NativeExportsNE.ReturnUIntAsVariantBool(value)); bool result = !expected; - NativeExportsNE.ReturnUIntAsRefVariantBool(value, ref result); + NativeExportsNE.ReturnUIntAsVariantBool_Ref(value, ref result); Assert.Equal(expected, result); result = !expected; - NativeExportsNE.ReturnUIntAsOutVariantBool(value, out result); + NativeExportsNE.ReturnUIntAsVariantBool_Out(value, out result); Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsVariantBool_In(value, in result); + Assert.Equal(!expected, result); // Should not be updated when using 'in' } [Theory] @@ -129,12 +163,39 @@ public void ValidateWinBoolReturns(uint value, bool expected) Assert.Equal(expected, NativeExportsNE.ReturnUIntAsWinBool(value)); bool result = !expected; - NativeExportsNE.ReturnUIntAsRefWinBool(value, ref result); + NativeExportsNE.ReturnUIntAsWinBool_Ref(value, ref result); Assert.Equal(expected, result); result = !expected; - NativeExportsNE.ReturnUIntAsOutWinBool(value, out result); + NativeExportsNE.ReturnUIntAsWinBool_Out(value, out result); Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsWinBool_In(value, in result); + Assert.Equal(!expected, result); // Should not be updated when using 'in' + } + + [Theory] + [InlineData(new object[] { 0, false })] + [InlineData(new object[] { 1, true })] + [InlineData(new object[] { 37, true })] + [InlineData(new object[] { 0xffffffff, true })] + [InlineData(new object[] { 0x80000000, true })] + public void ValidateDefaultBoolReturns(uint value, bool expected) + { + Assert.Equal(expected, NativeExportsNE.ReturnUIntAsDefaultBool(value)); + + bool result = !expected; + NativeExportsNE.ReturnUIntAsDefaultBool_Ref(value, ref result); + Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsDefaultBool_Out(value, out result); + Assert.Equal(expected, result); + + result = !expected; + NativeExportsNE.ReturnUIntAsDefaultBool_In(value, in result); + Assert.Equal(!expected, result); // Should not be updated when using 'in' } } } 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 1ca56d1197adf..432f05f5482c9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs @@ -14,10 +14,13 @@ partial class NativeExportsNE public static partial char ReturnUIntAsUnicode(uint input); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] - public static partial void ReturnUIntAsRefUnicode(uint input, ref char res); + public static partial void ReturnUIntAsUnicode_Ref(uint input, ref char res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] - public static partial void ReturnUIntAsOutUnicode(uint input, out char res); + public static partial void ReturnUIntAsUnicode_Out(uint input, out char res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] + public static partial void ReturnUIntAsUnicode_In(uint input, in char res); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.None)] [return: MarshalAs(UnmanagedType.U2)] @@ -53,13 +56,18 @@ public void ValidateUnicodeReturns(char expected, uint value) { Assert.Equal(expected, NativeExportsNE.ReturnUIntAsUnicode(value)); - char result = '\u0000'; - NativeExportsNE.ReturnUIntAsRefUnicode(value, ref result); + char initial = '\u0000'; + char result = initial; + NativeExportsNE.ReturnUIntAsUnicode_Ref(value, ref result); Assert.Equal(expected, result); - result = '\u0000'; - NativeExportsNE.ReturnUIntAsOutUnicode(value, out result); + result = initial; + NativeExportsNE.ReturnUIntAsUnicode_Out(value, out result); Assert.Equal(expected, result); + + result = initial; + NativeExportsNE.ReturnUIntAsUnicode_In(value, in result); + Assert.Equal(initial, result); // Should not be updated when using 'in' } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs index 94903b3430185..1a6b47a63bed0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs @@ -23,6 +23,9 @@ protected override bool ReleaseHandle() [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] public static partial NativeExportsSafeHandle AllocateHandle(); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle_out")] + public static partial void AllocateHandle(out NativeExportsSafeHandle handle); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "release_handle")] [return:MarshalAs(UnmanagedType.I1)] private static partial bool ReleaseHandle(nint handle); @@ -52,6 +55,16 @@ public void ByValue_CorrectlyUnwrapsHandle() Assert.True(NativeExportsNE.IsHandleAlive(handle)); } + [Fact] + public void ByRefOut_CreatesSafeHandle() + { + NativeExportsNE.NativeExportsSafeHandle handle; + NativeExportsNE.AllocateHandle(out handle); + Assert.False(handle.IsClosed); + Assert.False(handle.IsInvalid); + handle.Dispose(); + } + [Fact] public void ByRefSameValue_UsesSameHandleInstance() { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs index 4dc800685151d..81665752a1740 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs @@ -51,21 +51,13 @@ public static void Duplicate(int** values, int numValues) [UnmanagedCallersOnly(EntryPoint = "create_range_array")] public static int* CreateRange(int start, int end, int* numValues) { - if (start >= end) - { - *numValues = 0; - return null; - } - - *numValues = end - start; - - int* retVal = (int*)Marshal.AllocCoTaskMem(sizeof(int) * (*numValues)); - for (int i = start; i < end; i++) - { - retVal[i - start] = i; - } + return CreateRangeImpl(start, end, numValues); + } - return retVal; + [UnmanagedCallersOnly(EntryPoint = "create_range_array_out")] + public static void CreateRangeAsOut(int start, int end, int* numValues, int** res) + { + *res = CreateRangeImpl(start, end, numValues); } [UnmanagedCallersOnly(EntryPoint = "fill_range_array")] @@ -110,24 +102,24 @@ public static int SumStringLengths(ushort** strArray) return length; } - [UnmanagedCallersOnly(EntryPoint = "reverse_strings")] - public static void ReverseStrings(ushort*** strArray, int* numValues) + [UnmanagedCallersOnly(EntryPoint = "reverse_strings_return")] + public static ushort** ReverseStrings(ushort** strArray, int* numValues) { - if (*strArray == null) - { - *numValues = 0; - return; - } - List newStrings = new List(); - for (int i = 0; (nint)(*strArray)[i] != 0; i++) - { - newStrings.Add((IntPtr)Strings.Reverse((*strArray)[i])); - } - newStrings.Add(IntPtr.Zero); + return ReverseStringsImpl(strArray, numValues); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_strings_out")] + public static void ReverseStringsAsOut(ushort** strArray, int* numValues, ushort*** res) + { + *res = ReverseStringsImpl(strArray, numValues); + } + + [UnmanagedCallersOnly(EntryPoint = "reverse_strings_replace")] + public static void ReverseStringsReplace(ushort*** strArray, int* numValues) + { + ushort** res = ReverseStringsImpl(*strArray, numValues); Marshal.FreeCoTaskMem((IntPtr)(*strArray)); - *strArray = (ushort**)Marshal.AllocCoTaskMem(sizeof(ushort*) * newStrings.Count); - CollectionsMarshal.AsSpan(newStrings).CopyTo(new Span((IntPtr*)(*strArray), newStrings.Count)); - *numValues = newStrings.Count; + *strArray = res; } [UnmanagedCallersOnly(EntryPoint = "get_long_bytes")] @@ -139,7 +131,7 @@ public static void ReverseStrings(ushort*** strArray, int* numValues) MemoryMarshal.Write(new Span(bytes, NumBytesInLong), ref l); return bytes; } - + [UnmanagedCallersOnly(EntryPoint = "append_int_to_array")] public static void Append(int** values, int numOriginalValues, int newValue) { @@ -161,5 +153,45 @@ public static byte AndAllMembers([DNNE.C99Type("struct bool_struct*")] BoolStruc } return result ? 1 : 0; } + + private static int* CreateRangeImpl(int start, int end, int* numValues) + { + if (start >= end) + { + *numValues = 0; + return null; + } + + *numValues = end - start; + + int* retVal = (int*)Marshal.AllocCoTaskMem(sizeof(int) * (*numValues)); + for (int i = start; i < end; i++) + { + retVal[i - start] = i; + } + + return retVal; + } + + private static ushort** ReverseStringsImpl(ushort** strArray, int* numValues) + { + if (strArray == null) + { + *numValues = 0; + return null; + } + + List newStrings = new List(); + for (int i = 0; (nint)strArray[i] != 0; i++) + { + newStrings.Add((IntPtr)Strings.Reverse(strArray[i])); + } + newStrings.Add(IntPtr.Zero); + + ushort** res = (ushort**)Marshal.AllocCoTaskMem(sizeof(ushort*) * newStrings.Count); + CollectionsMarshal.AsSpan(newStrings).CopyTo(new Span((IntPtr*)(res), newStrings.Count)); + *numValues = newStrings.Count; + return res; + } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs index 0cc2ab4f9fe95..588e00ae625e0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs @@ -20,6 +20,12 @@ public static nint AllocateHandle() return AllocateHandleCore(); } + [UnmanagedCallersOnly(EntryPoint = "alloc_handle_out")] + public static void AllocateHandleOut(nint* handle) + { + *handle = AllocateHandleCore(); + } + [UnmanagedCallersOnly(EntryPoint = "release_handle")] public static byte ReleaseHandle(nint handle) { From 5a89cbb95532cabd45d657dbf73ce8bc37b6d98c Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 15 Jan 2021 15:29:49 -0800 Subject: [PATCH 063/161] Handle enums when checking if type is considered blittable (dotnet/runtimelab#563) Commit migrated from https://github.com/dotnet/runtimelab/commit/c41c1171061920c5cdfa54633cb590bc6417d2e3 --- .../TypeSymbolExtensions.cs | 5 ++++ .../ManualTypeMarshallingAnalyzerTests.cs | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 21a807ebbd39f..f12bbe46ee19a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -79,6 +79,11 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) return pointedAtType.IsConsideredBlittable(); } + if (type is INamedTypeSymbol { TypeKind: TypeKind.Enum, EnumUnderlyingType: ITypeSymbol underlyingType }) + { + return underlyingType!.IsConsideredBlittable(); + } + bool hasNativeMarshallingAttribute = false; bool hasGeneratedMarshallingAttribute = false; // [TODO]: Match attributes on full name or symbol, not just on type name. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index fde897ec1b669..51a1e002af653 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -61,7 +61,7 @@ public async Task NonBlittableTypeMarkedBlittable_ReportsDiagnostic(string sourc } [Fact] - public async Task TypeWithBlittablePrimitiveFieldsMarkedBlittableNoDiagnostic() + public async Task BlittablePrimitiveFields_MarkedBlittable_NoDiagnostic() { string source = @" @@ -73,12 +73,29 @@ struct S public int field; } "; + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task BlittableEnumFields_MarkedBlittable_NoDiagnostic() + { + + string source = @" +using System.Runtime.InteropServices; +enum E { Zero, One, Two } + +[BlittableType] +struct S +{ + public E field; +} +"; await VerifyCS.VerifyAnalyzerAsync(source); } [Fact] - public async Task TypeWithBlittableStructFieldsMarkedBlittableNoDiagnostic() + public async Task BlittableStructFields_MarkedBlittable_NoDiagnostic() { string source = @" using System.Runtime.InteropServices; @@ -95,12 +112,11 @@ struct T public int field; } "; - await VerifyCS.VerifyAnalyzerAsync(source); } [Fact] - public async Task TypeMarkedBlittableWithNonBlittableFieldsMarkedBlittableReportDiagnosticOnFieldTypeDefinition() + public async Task NonBlittableFields_MarkedBlittable_ReportDiagnosticOnFieldTypeDefinition() { string source = @" using System.Runtime.InteropServices; From 7d5caa00a67fce3c68964a9514b893270fc28b67 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 20 Jan 2021 10:58:45 -0800 Subject: [PATCH 064/161] Add fixer for converting to GeneratedDllImport (dotnet/runtimelab#564) Commit migrated from https://github.com/dotnet/runtimelab/commit/dd810614463b99d14972fe1f4f54f3215212e4e9 --- .../ConvertToGeneratedDllImportFixer.cs | 228 ++++++++++++++ .../DllImportGenerator.csproj | 2 +- .../DllImportGenerator/Resources.Designer.cs | 42 ++- .../gen/DllImportGenerator/Resources.resx | 10 + .../ConvertToGeneratedDllImportFixerTests.cs | 280 ++++++++++++++++++ .../DllImportGenerator.UnitTests.csproj | 1 + .../Verifiers/CSharpAnalyzerVerifier.cs | 58 +--- .../Verifiers/CSharpCodeFixVerifier.cs | 119 ++++++++ 8 files changed, 679 insertions(+), 61 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs new file mode 100644 index 0000000000000..c08c90c32162d --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs @@ -0,0 +1,228 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editing; + +using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics; + +namespace Microsoft.Interop.Analyzers +{ + [ExportCodeFixProvider(LanguageNames.CSharp)] + public sealed class ConvertToGeneratedDllImportFixer : CodeFixProvider + { + public override ImmutableArray FixableDiagnosticIds => ImmutableArray.Create(Ids.ConvertToGeneratedDllImport); + + public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer; + + public const string NoPreprocessorDefinesKey = "ConvertToGeneratedDllImport"; + public const string WithPreprocessorDefinesKey = "ConvertToGeneratedDllImportPreprocessor"; + + public override async Task RegisterCodeFixesAsync(CodeFixContext context) + { + // Get the syntax root and semantic model + Document doc = context.Document; + SyntaxNode? root = await doc.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); + SemanticModel? model = await doc.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); + if (root == null || model == null) + return; + + // Nothing to do if the GeneratedDllImportAttribute is not in the compilation + INamedTypeSymbol? generatedDllImportAttrType = model.Compilation.GetTypeByMetadataName(TypeNames.GeneratedDllImportAttribute); + if (generatedDllImportAttrType == null) + return; + + INamedTypeSymbol? dllImportAttrType = model.Compilation.GetTypeByMetadataName(typeof(DllImportAttribute).FullName); + if (dllImportAttrType == null) + return; + + // Get the syntax node tied to the diagnostic and check that it is a method declaration + if (root.FindNode(context.Span) is not MethodDeclarationSyntax methodSyntax) + return; + + if (model.GetDeclaredSymbol(methodSyntax, context.CancellationToken) is not IMethodSymbol methodSymbol) + return; + + // Make sure the method has the DllImportAttribute + AttributeData? dllImportAttr; + if (!TryGetAttribute(methodSymbol, dllImportAttrType, out dllImportAttr)) + return; + + // Register code fixes with two options for the fix - using preprocessor or not. + context.RegisterCodeFix( + CodeAction.Create( + Resources.ConvertToGeneratedDllImportNoPreprocessor, + cancelToken => ConvertToGeneratedDllImport( + context.Document, + methodSyntax, + methodSymbol, + dllImportAttr!, + generatedDllImportAttrType, + usePreprocessorDefines: false, + cancelToken), + equivalenceKey: NoPreprocessorDefinesKey), + context.Diagnostics); + + context.RegisterCodeFix( + CodeAction.Create( + Resources.ConvertToGeneratedDllImportWithPreprocessor, + cancelToken => ConvertToGeneratedDllImport( + context.Document, + methodSyntax, + methodSymbol, + dllImportAttr!, + generatedDllImportAttrType, + usePreprocessorDefines: true, + cancelToken), + equivalenceKey: WithPreprocessorDefinesKey), + context.Diagnostics); + } + + private async Task ConvertToGeneratedDllImport( + Document doc, + MethodDeclarationSyntax methodSyntax, + IMethodSymbol methodSymbol, + AttributeData dllImportAttr, + INamedTypeSymbol generatedDllImportAttrType, + bool usePreprocessorDefines, + CancellationToken cancellationToken) + { + DocumentEditor editor = await DocumentEditor.CreateAsync(doc, cancellationToken).ConfigureAwait(false); + SyntaxGenerator generator = editor.Generator; + + var dllImportSyntax = (AttributeSyntax)dllImportAttr!.ApplicationSyntaxReference!.GetSyntax(cancellationToken); + + // Create GeneratedDllImport attribute based on the DllImport attribute + var generatedDllImportSyntax = GetGeneratedDllImportAttribute( + generator, + dllImportSyntax, + methodSymbol.GetDllImportData()!, + generatedDllImportAttrType); + + // Add annotation about potential behavioural and compatibility changes + generatedDllImportSyntax = generatedDllImportSyntax.WithAdditionalAnnotations( + WarningAnnotation.Create(string.Format(Resources.ConvertToGeneratedDllImportWarning, "[TODO] Documentation link"))); + + // Replace DllImport with GeneratedDllImport + SyntaxNode generatedDeclaration = generator.ReplaceNode(methodSyntax, dllImportSyntax, generatedDllImportSyntax); + + // Replace extern keyword with partial keyword + generatedDeclaration = generator.WithModifiers( + generatedDeclaration, + generator.GetModifiers(methodSyntax) + .WithIsExtern(false) + .WithPartial(true)); + + if (!usePreprocessorDefines) + { + // Replace the original method with the updated one + editor.ReplaceNode(methodSyntax, generatedDeclaration); + } + else + { + // #if NET + generatedDeclaration = generatedDeclaration.WithLeadingTrivia( + generatedDeclaration.GetLeadingTrivia() + .AddRange(new[] { + SyntaxFactory.Trivia(SyntaxFactory.IfDirectiveTrivia(SyntaxFactory.IdentifierName("NET"), isActive: true, branchTaken: true, conditionValue: true)), + SyntaxFactory.ElasticMarker + })); + + // #else + generatedDeclaration = generatedDeclaration.WithTrailingTrivia( + generatedDeclaration.GetTrailingTrivia() + .AddRange(new[] { + SyntaxFactory.Trivia(SyntaxFactory.ElseDirectiveTrivia(isActive: false, branchTaken: false)), + SyntaxFactory.ElasticMarker + })); + + // Remove existing leading trivia - it will be on the GeneratedDllImport method + var updatedDeclaration = methodSyntax.WithLeadingTrivia(); + + // #endif + updatedDeclaration = updatedDeclaration.WithTrailingTrivia( + methodSyntax.GetTrailingTrivia() + .AddRange(new[] { + SyntaxFactory.Trivia(SyntaxFactory.EndIfDirectiveTrivia(isActive: true)), + SyntaxFactory.ElasticMarker + })); + + // Add the GeneratedDllImport method + editor.InsertBefore(methodSyntax, generatedDeclaration); + + // Replace the original method with the updated DllImport method + editor.ReplaceNode(methodSyntax, updatedDeclaration); + } + + return editor.GetChangedDocument(); + } + + private SyntaxNode GetGeneratedDllImportAttribute( + SyntaxGenerator generator, + AttributeSyntax dllImportSyntax, + DllImportData dllImportData, + INamedTypeSymbol generatedDllImportAttrType) + { + // Create GeneratedDllImport based on the DllImport attribute + var generatedDllImportSyntax = generator.ReplaceNode(dllImportSyntax, + dllImportSyntax.Name, + generator.TypeExpression(generatedDllImportAttrType)); + + // Update attribute arguments for GeneratedDllImport + List argumentsToRemove = new List(); + foreach (SyntaxNode argument in generator.GetAttributeArguments(generatedDllImportSyntax)) + { + if (argument is not AttributeArgumentSyntax attrArg) + continue; + + if (dllImportData.BestFitMapping != null + && !dllImportData.BestFitMapping.Value + && IsMatchingNamedArg(attrArg, nameof(DllImportAttribute.BestFitMapping))) + { + // BestFitMapping=false is explicitly set + // GeneratedDllImport does not support setting BestFitMapping. The generated code + // has the equivalent behaviour of BestFitMapping=false, so we can remove the argument. + argumentsToRemove.Add(argument); + } + else if (dllImportData.ThrowOnUnmappableCharacter != null + && !dllImportData.ThrowOnUnmappableCharacter.Value + && IsMatchingNamedArg(attrArg, nameof(DllImportAttribute.ThrowOnUnmappableChar))) + { + // ThrowOnUnmappableChar=false is explicitly set + // GeneratedDllImport does not support setting ThrowOnUnmappableChar. The generated code + // has the equivalent behaviour of ThrowOnUnmappableChar=false, so we can remove the argument. + argumentsToRemove.Add(argument); + } + } + + return generator.RemoveNodes(generatedDllImportSyntax, argumentsToRemove); + } + + private static bool TryGetAttribute(IMethodSymbol method, INamedTypeSymbol attributeType, out AttributeData? attr) + { + attr = default; + foreach (var attrLocal in method.GetAttributes()) + { + if (SymbolEqualityComparer.Default.Equals(attrLocal.AttributeClass, attributeType)) + { + attr = attrLocal; + return true; + } + } + + return false; + } + + private static bool IsMatchingNamedArg(AttributeArgumentSyntax arg, string nameToMatch) + { + return arg.NameEquals != null && arg.NameEquals.Name.Identifier.Text == nameToMatch; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 108713c4eddeb..9d92212ea0b20 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -29,7 +29,7 @@ - + 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 5a033df756ec2..071ce9c6328b5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -176,7 +176,8 @@ internal static string ConfigurationNotSupportedTitle { return ResourceManager.GetString("ConfigurationNotSupportedTitle", resourceCulture); } } - + + /// /// Looks up a localized string similar to Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time. /// internal static string ConvertToGeneratedDllImportDescription { @@ -185,6 +186,7 @@ internal static string ConvertToGeneratedDllImportDescription { } } + /// /// Looks up a localized string similar to Mark the method '{0}' with 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time. /// internal static string ConvertToGeneratedDllImportMessage { @@ -192,7 +194,16 @@ internal static string ConvertToGeneratedDllImportMessage { return ResourceManager.GetString("ConvertToGeneratedDllImportMessage", resourceCulture); } } - + + /// + /// Looks up a localized string similar to Convert to 'GeneratedDllImport'. + /// + internal static string ConvertToGeneratedDllImportNoPreprocessor { + get { + return ResourceManager.GetString("ConvertToGeneratedDllImportNoPreprocessor", resourceCulture); + } + } + /// /// Looks up a localized string similar to Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time. /// @@ -201,7 +212,25 @@ internal static string ConvertToGeneratedDllImportTitle { return ResourceManager.GetString("ConvertToGeneratedDllImportTitle", resourceCulture); } } - + + /// + /// Looks up a localized string similar to Conversion to 'GeneratedDllImport' may change behavior and compatibility. See {0} for more information.. + /// + internal static string ConvertToGeneratedDllImportWarning { + get { + return ResourceManager.GetString("ConvertToGeneratedDllImportWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Convert to 'GeneratedDllImport' under a preprocessor define. + /// + internal static string ConvertToGeneratedDllImportWithPreprocessor { + get { + return ResourceManager.GetString("ConvertToGeneratedDllImportWithPreprocessor", resourceCulture); + } + } + /// /// Looks up a localized string similar to The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it.. /// @@ -210,7 +239,7 @@ internal static string CustomTypeMarshallingManagedToNativeUnsupported { return ResourceManager.GetString("CustomTypeMarshallingManagedToNativeUnsupported", resourceCulture); } } - + /// /// Looks up a localized string similar to The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it.. /// @@ -219,7 +248,7 @@ internal static string CustomTypeMarshallingNativeToManagedUnsupported { return ResourceManager.GetString("CustomTypeMarshallingNativeToManagedUnsupported", resourceCulture); } } - + /// /// Looks up a localized string similar to Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'.. /// @@ -300,8 +329,9 @@ internal static string InOutAttributeByRefNotSupported { return ResourceManager.GetString("InOutAttributeByRefNotSupported", resourceCulture); } } + /// - /// Looks up a localized string similar to The '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter.. + /// Looks up a localized string similar to The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter.. /// internal static string InOutAttributeMarshalerNotSupported { get { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 4fe08e2f600c1..7f41f03a9b989 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -162,9 +162,19 @@ Mark the method '{0}' with 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + + Convert to 'GeneratedDllImport' + Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + + Conversion to 'GeneratedDllImport' may change behavior and compatibility. See {0} for more information. + {0} is a documentation link + + + Convert to 'GeneratedDllImport' under a preprocessor define + The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs new file mode 100644 index 0000000000000..ddad1cc5c67e5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs @@ -0,0 +1,280 @@ +using System.Threading.Tasks; +using Xunit; +using static Microsoft.Interop.Analyzers.ConvertToGeneratedDllImportFixer; + +using VerifyCS = DllImportGenerator.UnitTests.Verifiers.CSharpCodeFixVerifier< + Microsoft.Interop.Analyzers.ConvertToGeneratedDllImportAnalyzer, + Microsoft.Interop.Analyzers.ConvertToGeneratedDllImportFixer>; + +namespace DllImportGenerator.UnitTests +{ + public class ConvertToGeneratedDllImportFixerTests + { + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task Basic(bool usePreprocessorDefines) + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [DllImport(""DoesNotExist"")] + public static extern int [|Method|](out int ret); +}}"; + // Fixed source will have CS8795 (Partial method must have an implementation) without generator run + string fixedSource = usePreprocessorDefines + ? @$" +using System.Runtime.InteropServices; +partial class Test +{{ +#if NET + [GeneratedDllImport(""DoesNotExist"")] + public static partial int {{|CS8795:Method|}}(out int ret); +#else + [DllImport(""DoesNotExist"")] + public static extern int Method(out int ret); +#endif +}}" + : @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial int {{|CS8795:Method|}}(out int ret); +}}"; + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task Comments(bool usePreprocessorDefines) + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + // P/Invoke + [DllImport(/*name*/""DoesNotExist"")] // comment + public static extern int [|Method1|](out int ret); + + /** P/Invoke **/ + [DllImport(""DoesNotExist"") /*name*/] + // < ... > + public static extern int [|Method2|](out int ret); +}}"; + // Fixed source will have CS8795 (Partial method must have an implementation) without generator run + string fixedSource = usePreprocessorDefines + ? @$" +using System.Runtime.InteropServices; +partial class Test +{{ + // P/Invoke +#if NET + [GeneratedDllImport(/*name*/""DoesNotExist"")] // comment + public static partial int {{|CS8795:Method1|}}(out int ret); +#else + [DllImport(/*name*/""DoesNotExist"")] // comment + public static extern int Method1(out int ret); +#endif + + /** P/Invoke **/ +#if NET + [GeneratedDllImport(""DoesNotExist"") /*name*/] + // < ... > + public static partial int {{|CS8795:Method2|}}(out int ret); +#else + [DllImport(""DoesNotExist"") /*name*/] + // < ... > + public static extern int Method2(out int ret); +#endif +}}" + : @$" +using System.Runtime.InteropServices; +partial class Test +{{ + // P/Invoke + [GeneratedDllImport(/*name*/""DoesNotExist"")] // comment + public static partial int {{|CS8795:Method1|}}(out int ret); + + /** P/Invoke **/ + [GeneratedDllImport(""DoesNotExist"") /*name*/] + // < ... > + public static partial int {{|CS8795:Method2|}}(out int ret); +}}"; + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task MultipleAttributes(bool usePreprocessorDefines) + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [System.ComponentModel.Description(""Test""), DllImport(""DoesNotExist"")] + public static extern int [|Method1|](out int ret); + + [System.ComponentModel.Description(""Test"")] + [DllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.I4)] + public static extern int [|Method2|](out int ret); +}}"; + // Fixed source will have CS8795 (Partial method must have an implementation) without generator run + string fixedSource = usePreprocessorDefines + ? @$" +using System.Runtime.InteropServices; +partial class Test +{{ +#if NET + [System.ComponentModel.Description(""Test""), GeneratedDllImport(""DoesNotExist"")] + public static partial int {{|CS8795:Method1|}}(out int ret); +#else + [System.ComponentModel.Description(""Test""), DllImport(""DoesNotExist"")] + public static extern int Method1(out int ret); +#endif + +#if NET + [System.ComponentModel.Description(""Test"")] + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.I4)] + public static partial int {{|CS8795:Method2|}}(out int ret); +#else + [System.ComponentModel.Description(""Test"")] + [DllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.I4)] + public static extern int Method2(out int ret); +#endif +}}" + : @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [System.ComponentModel.Description(""Test""), GeneratedDllImport(""DoesNotExist"")] + public static partial int {{|CS8795:Method1|}}(out int ret); + + [System.ComponentModel.Description(""Test"")] + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.I4)] + public static partial int {{|CS8795:Method2|}}(out int ret); +}}"; + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task NamedArguments(bool usePreprocessorDefines) + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [DllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + public static extern int [|Method1|](out int ret); + + [DllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Unicode)] + public static extern int [|Method2|](out int ret); +}}"; + // Fixed source will have CS8795 (Partial method must have an implementation) without generator run + string fixedSource = usePreprocessorDefines + ? @$" +using System.Runtime.InteropServices; +partial class Test +{{ +#if NET + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + public static partial int {{|CS8795:Method1|}}(out int ret); +#else + [DllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + public static extern int Method1(out int ret); +#endif + +#if NET + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Unicode)] + public static partial int {{|CS8795:Method2|}}(out int ret); +#else + [DllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Unicode)] + public static extern int Method2(out int ret); +#endif +}}" : @$" +using System.Runtime.InteropServices; +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); +}}"; + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task RemoveableNamedArguments(bool usePreprocessorDefines) + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [DllImport(""DoesNotExist"", BestFitMapping = false, EntryPoint = ""Entry"")] + public static extern int [|Method1|](out int ret); + + [DllImport(""DoesNotExist"", ThrowOnUnmappableChar = false)] + public static extern int [|Method2|](out int ret); +}}"; + // Fixed source will have CS8795 (Partial method must have an implementation) without generator run + string fixedSource = usePreprocessorDefines + ? @$" +using System.Runtime.InteropServices; +partial class Test +{{ +#if NET + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + public static partial int {{|CS8795:Method1|}}(out int ret); +#else + [DllImport(""DoesNotExist"", BestFitMapping = false, EntryPoint = ""Entry"")] + public static extern int Method1(out int ret); +#endif + +#if NET + [GeneratedDllImport(""DoesNotExist"")] + public static partial int {{|CS8795:Method2|}}(out int ret); +#else + [DllImport(""DoesNotExist"", ThrowOnUnmappableChar = false)] + public static extern int Method2(out int ret); +#endif +}}" : @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + public static partial int {{|CS8795:Method1|}}(out int ret); + + [GeneratedDllImport(""DoesNotExist"")] + public static partial int {{|CS8795:Method2|}}(out int ret); +}}"; + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index 2caf2103354ed..c1ed94a205ff0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -11,6 +11,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs index 33cbfb8805312..bb0a07677ca23 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs @@ -1,15 +1,10 @@ -using System.Collections.Immutable; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.CSharp.Testing.XUnit; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; namespace DllImportGenerator.UnitTests.Verifiers { @@ -40,54 +35,9 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes await test.RunAsync(CancellationToken.None); } - internal class Test : CSharpAnalyzerTest - { - public Test() - { - var (refAssem, ancillary) = TestUtils.GetReferenceAssemblies(); - ReferenceAssemblies = refAssem; - SolutionTransforms.Add((solution, projectId) => - { - var project = solution.GetProject(projectId)!; - var compilationOptions = project.CompilationOptions!; - - var diagnosticOptions = compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings); - - // Explicitly enable diagnostics that are not enabled by default - var enableAnalyzersOptions = new System.Collections.Generic.Dictionary(); - foreach (var analyzer in GetDiagnosticAnalyzers().ToImmutableArray()) - { - foreach (var diagnostic in analyzer.SupportedDiagnostics) - { - if (diagnostic.IsEnabledByDefault) - continue; - - // Map the default severity to the reporting behaviour. - // We cannot simply use ReportDiagnostic.Default here, as diagnostics that are not enabled by default - // are treated as suppressed (regardless of their default severity). - var report = diagnostic.DefaultSeverity switch - { - DiagnosticSeverity.Error => ReportDiagnostic.Error, - DiagnosticSeverity.Warning => ReportDiagnostic.Warn, - DiagnosticSeverity.Info => ReportDiagnostic.Info, - DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden, - _ => ReportDiagnostic.Default - }; - enableAnalyzersOptions.Add(diagnostic.Id, report); - } - } - - compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( - compilationOptions.SpecificDiagnosticOptions - .SetItems(CSharpVerifierHelper.NullableWarnings) - .AddRange(enableAnalyzersOptions)); - solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); - solution = solution.WithProjectMetadataReferences(projectId, project.MetadataReferences.Concat(ImmutableArray.Create(ancillary))); - solution = solution.WithProjectParseOptions(projectId, ((CSharpParseOptions)project.ParseOptions!).WithLanguageVersion(LanguageVersion.Preview)); - - return solution; - }); - } - } + // Code fix tests support both analyzer and code fix testing. This test class is derived from the code fix test + // to avoid the need to maintain duplicate copies of the customization work. + internal class Test : CSharpCodeFixVerifier.Test + { } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs new file mode 100644 index 0000000000000..2d04e5497a18e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs @@ -0,0 +1,119 @@ + +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.CSharp.Testing.XUnit; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Testing.Verifiers; + +namespace DllImportGenerator.UnitTests.Verifiers +{ + public static class CSharpCodeFixVerifier + where TAnalyzer : DiagnosticAnalyzer, new() + where TCodeFix : CodeFixProvider, new() + { + /// + public static DiagnosticResult Diagnostic() + => CodeFixVerifier.Diagnostic(); + + /// + public static DiagnosticResult Diagnostic(string diagnosticId) + => CodeFixVerifier.Diagnostic(diagnosticId); + + /// + public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) + => CodeFixVerifier.Diagnostic(descriptor); + + /// + public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) + { + var test = new Test + { + TestCode = source, + }; + + test.ExpectedDiagnostics.AddRange(expected); + await test.RunAsync(CancellationToken.None); + } + + /// + public static async Task VerifyCodeFixAsync(string source, string fixedSource, string? codeActionEquivalenceKey = null) + => await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource, codeActionEquivalenceKey); + + /// + public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource, string? codeActionEquivalenceKey = null) + => await VerifyCodeFixAsync(source, new[] { expected }, fixedSource, codeActionEquivalenceKey); + + /// + public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource, string? codeActionEquivalenceKey = null) + { + var test = new Test + { + TestCode = source, + FixedCode = fixedSource, + CodeActionEquivalenceKey = codeActionEquivalenceKey, + CodeActionValidationMode = CodeActionValidationMode.None, + }; + + test.ExpectedDiagnostics.AddRange(expected); + await test.RunAsync(CancellationToken.None); + } + + internal class Test : CSharpCodeFixTest + { + public Test() + { + var (refAssem, ancillary) = TestUtils.GetReferenceAssemblies(); + ReferenceAssemblies = refAssem; + SolutionTransforms.Add((solution, projectId) => + { + var project = solution.GetProject(projectId)!; + var compilationOptions = project.CompilationOptions!; + var diagnosticOptions = compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings); + + // Explicitly enable diagnostics that are not enabled by default + var enableAnalyzersOptions = new System.Collections.Generic.Dictionary(); + foreach (var analyzer in GetDiagnosticAnalyzers().ToImmutableArray()) + { + foreach (var diagnostic in analyzer.SupportedDiagnostics) + { + if (diagnostic.IsEnabledByDefault) + continue; + + // Map the default severity to the reporting behaviour. + // We cannot simply use ReportDiagnostic.Default here, as diagnostics that are not enabled by default + // are treated as suppressed (regardless of their default severity). + var report = diagnostic.DefaultSeverity switch + { + DiagnosticSeverity.Error => ReportDiagnostic.Error, + DiagnosticSeverity.Warning => ReportDiagnostic.Warn, + DiagnosticSeverity.Info => ReportDiagnostic.Info, + DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden, + _ => ReportDiagnostic.Default + }; + enableAnalyzersOptions.Add(diagnostic.Id, report); + } + } + + compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( + compilationOptions.SpecificDiagnosticOptions + .SetItems(CSharpVerifierHelper.NullableWarnings) + .AddRange(enableAnalyzersOptions)); + solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); + solution = solution.WithProjectMetadataReferences(projectId, project.MetadataReferences.Concat(ImmutableArray.Create(ancillary))); + solution = solution.WithProjectParseOptions(projectId, ((CSharpParseOptions)project.ParseOptions!).WithLanguageVersion(LanguageVersion.Preview)); + return solution; + }); + } + + protected override ParseOptions CreateParseOptions() + => ((CSharpParseOptions)base.CreateParseOptions()).WithPreprocessorSymbols("NET"); + } + } +} \ No newline at end of file From a4330b4c2c369c61abbc01781c7f8385f093bd9e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 20 Jan 2021 11:06:24 -0800 Subject: [PATCH 065/161] Update SafeHandle codegen to match the approved API. (dotnet/runtimelab#570) Commit migrated from https://github.com/dotnet/runtimelab/commit/0c64a2aa529dff4ef3ad15b17663b5314f55145b --- .../gen/DllImportGenerator/DllImportStub.cs | 9 ++-- .../Marshalling/SafeHandleMarshaller.cs | 44 ++++++++++++------- .../MarshallingAttributeInfo.cs | 2 +- .../gen/DllImportGenerator/TypeNames.cs | 2 + .../DllImportGenerator/TypePositionInfo.cs | 36 ++++++++++----- .../tests/Ancillary.Interop/MarshalEx.cs | 22 +--------- .../SafeHandleTests.cs | 16 ++++++- .../CodeSnippets.cs | 10 +++++ .../DllImportGenerator.UnitTests/Compiles.cs | 2 + 9 files changed, 89 insertions(+), 54 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 9fe488f7dae2b..85ac9bef9b577 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -133,9 +133,10 @@ public static DllImportStub Create( // Since we're generating source for the method, we know that the current type // has to be declared in source. TypeDeclarationSyntax typeDecl = (TypeDeclarationSyntax)currType.DeclaringSyntaxReferences[0].GetSyntax(); - // Remove current members and attributes so we don't double declare them. + // Remove current members, attributes, and base list so we don't double declare them. typeDecl = typeDecl.WithMembers(List()) - .WithAttributeLists(List()); + .WithAttributeLists(List()) + .WithBaseList(null); containingTypes.Add(typeDecl); @@ -162,7 +163,7 @@ public static DllImportStub Create( for (int i = 0; i < method.Parameters.Length; i++) { var param = method.Parameters[i]; - var typeInfo = TypePositionInfo.CreateForParameter(param, defaultInfo, env.Compilation, diagnostics); + var typeInfo = TypePositionInfo.CreateForParameter(param, defaultInfo, env.Compilation, diagnostics, method.ContainingType); typeInfo = typeInfo with { ManagedIndex = i, @@ -171,7 +172,7 @@ public static DllImportStub Create( paramsTypeInfo.Add(typeInfo); } - TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), defaultInfo, env.Compilation, diagnostics); + TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), defaultInfo, env.Compilation, diagnostics, method.ContainingType); retTypeInfo = retTypeInfo with { ManagedIndex = TypePositionInfo.ReturnIndex, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index 5ff9b53c66cd2..ba80a029e843f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -81,19 +81,39 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont SingletonSeparatedList( VariableDeclarator(addRefdIdentifier) .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); - } + + var safeHandleCreationExpression = ((SafeHandleMarshallingInfo)info.MarshallingAttributeInfo).AccessibleDefaultConstructor + ? (ExpressionSyntax)ObjectCreationExpression(info.ManagedType.AsTypeSyntax(), ArgumentList(), initializer: null) + : CastExpression( + info.ManagedType.AsTypeSyntax(), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Activator), + IdentifierName("CreateInstance"))) + .WithArgumentList( + ArgumentList( + SeparatedList( + new []{ + Argument( + TypeOfExpression( + info.ManagedType.AsTypeSyntax())), + Argument( + LiteralExpression( + SyntaxKind.TrueLiteralExpression)) + .WithNameColon( + NameColon( + IdentifierName("nonPublic"))) + })))); + if (info.IsManagedReturnPosition) { yield return ExpressionStatement( AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(managedIdentifier), - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.MarshalEx(options)), - GenericName(Identifier("CreateSafeHandle"), - TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), - ArgumentList()))); + safeHandleCreationExpression + )); } else if (info.IsByRef && info.RefKind != RefKind.In) { @@ -105,13 +125,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont info.ManagedType.AsTypeSyntax(), SingletonSeparatedList( VariableDeclarator(newHandleObjectIdentifier) - .WithInitializer(EqualsValueClause( - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.MarshalEx(options)), - GenericName(Identifier("CreateSafeHandle"), - TypeArgumentList(SingletonSeparatedList(info.ManagedType.AsTypeSyntax())))), - ArgumentList())))))); + .WithInitializer(EqualsValueClause(safeHandleCreationExpression))))); if (info.RefKind != RefKind.Out) { yield return LocalDeclarationStatement( @@ -168,7 +182,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, ParseTypeName(TypeNames.MarshalEx(options)), - IdentifierName("SetHandle")), + IdentifierName("InitHandle")), ArgumentList(SeparatedList( new [] { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 891eed70a4ac0..a9c036948d56f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -103,7 +103,7 @@ internal sealed record GeneratedNativeMarshallingAttributeInfo( /// /// The type of the element is a SafeHandle-derived type with no marshalling attributes. /// - internal sealed record SafeHandleMarshallingInfo : MarshallingInfo; + internal sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor) : MarshallingInfo; /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index de5670fba75e4..457a4db0386a5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -22,6 +22,8 @@ static class TypeNames public const string System_Span_Metadata = "System.Span`1"; public const string System_Span = "System.Span"; + public const string System_Activator = "System.Activator"; + public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 10c707d9c68f9..9cb216590cc03 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -82,9 +82,9 @@ private TypePositionInfo() public MarshallingInfo MarshallingAttributeInfo { get; init; } - public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) + public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) { - var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), defaultInfo, compilation, diagnostics); + var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), defaultInfo, compilation, diagnostics, scopeSymbol); var typeInfo = new TypePositionInfo() { ManagedType = paramSymbol.Type, @@ -98,9 +98,9 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, return typeInfo; } - public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) + public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) { - var marshallingInfo = GetMarshallingInfo(type, attributes, defaultInfo, compilation, diagnostics); + var marshallingInfo = GetMarshallingInfo(type, attributes, defaultInfo, compilation, diagnostics, scopeSymbol); var typeInfo = new TypePositionInfo() { ManagedType = type, @@ -127,7 +127,7 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, MarshallingInfo m return typeInfo; } - private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) + private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) { // Look at attributes passed in - usage specific. foreach (var attrData in attributes) @@ -137,7 +137,7 @@ private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable< if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) { // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute - return CreateMarshalAsInfo(type, attrData, defaultInfo, compilation, diagnostics); + return CreateMarshalAsInfo(type, attrData, defaultInfo, compilation, diagnostics, scopeSymbol); } else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) { @@ -167,7 +167,7 @@ private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable< // If the type doesn't have custom attributes that dictate marshalling, // then consider the type itself. - if (TryCreateTypeBasedMarshallingInfo(type, defaultInfo, compilation, diagnostics, out MarshallingInfo infoMaybe)) + if (TryCreateTypeBasedMarshallingInfo(type, defaultInfo, compilation, diagnostics, scopeSymbol, out MarshallingInfo infoMaybe)) { return infoMaybe; } @@ -183,7 +183,7 @@ private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable< return NoMarshallingInfo.Instance; - static MarshalAsInfo CreateMarshalAsInfo(ITypeSymbol type, AttributeData attrData, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics) + static MarshalAsInfo CreateMarshalAsInfo(ITypeSymbol type, AttributeData attrData, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) { object unmanagedTypeObj = attrData.ConstructorArguments[0].Value!; UnmanagedType unmanagedType = unmanagedTypeObj is short @@ -252,7 +252,7 @@ static MarshalAsInfo CreateMarshalAsInfo(ITypeSymbol type, AttributeData attrDat } else if (type is IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) { - elementMarshallingInfo = GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics); + elementMarshallingInfo = GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics, scopeSymbol); } return new ArrayMarshalAsInfo( @@ -307,7 +307,7 @@ static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol ty NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null); } - static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, out MarshallingInfo marshallingInfo) + static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol, out MarshallingInfo marshallingInfo) { var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); if (conversion.Exists @@ -315,13 +315,25 @@ static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshalli && conversion.IsReference && !type.IsAbstract) { - marshallingInfo = new SafeHandleMarshallingInfo(); + bool hasAccessibleDefaultConstructor = false; + if (type is INamedTypeSymbol named && named.InstanceConstructors.Length > 0) + { + foreach (var ctor in named.InstanceConstructors) + { + if (ctor.Parameters.Length == 0) + { + hasAccessibleDefaultConstructor = compilation.IsSymbolAccessibleWithin(ctor, scopeSymbol); + break; + } + } + } + marshallingInfo = new SafeHandleMarshallingInfo(hasAccessibleDefaultConstructor); return true; } if (type is IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) { - marshallingInfo = new ArrayMarshallingInfo(GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics)); + marshallingInfo = new ArrayMarshallingInfo(GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics, scopeSymbol)); return true; } marshallingInfo = NoMarshallingInfo.Instance; diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs index a5ad55f72e687..8a53af07090d9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -10,32 +10,12 @@ namespace System.Runtime.InteropServices /// public static class MarshalEx { - /// - /// Create an instance of the given . - /// - /// Type of the SafeHandle - /// New instance of - /// - /// The must be non-abstract and have a parameterless constructor. - /// - public static TSafeHandle CreateSafeHandle<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.NonPublicConstructors)]TSafeHandle>() - where TSafeHandle : SafeHandle - { - if (typeof(TSafeHandle).IsAbstract || typeof(TSafeHandle).GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance | BindingFlags.Instance, null, Type.EmptyTypes, null) == null) - { - throw new MissingMemberException($"The safe handle type '{typeof(TSafeHandle).FullName}' must be a non-abstract type with a parameterless constructor."); - } - - TSafeHandle safeHandle = (TSafeHandle)Activator.CreateInstance(typeof(TSafeHandle), nonPublic: true)!; - return safeHandle; - } - /// /// Sets the handle of to the specified . /// /// instance to update /// Pre-existing handle - public static void SetHandle(SafeHandle safeHandle, IntPtr handle) + public static void InitHandle(SafeHandle safeHandle, IntPtr handle) { typeof(SafeHandle).GetMethod("SetHandle", BindingFlags.NonPublic | BindingFlags.Instance)!.Invoke(safeHandle, new object[] { handle }); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs index 1a6b47a63bed0..fda3852b3d885 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs @@ -7,7 +7,7 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - public class NativeExportsSafeHandle : SafeHandleZeroOrMinusOneIsInvalid + public partial class NativeExportsSafeHandle : SafeHandleZeroOrMinusOneIsInvalid { private NativeExportsSafeHandle() : base(ownsHandle: true) { } @@ -18,6 +18,12 @@ protected override bool ReleaseHandle() Assert.True(didRelease); return didRelease; } + + public static NativeExportsSafeHandle CreateNewHandle() => AllocateHandle(); + + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] + private static partial NativeExportsSafeHandle AllocateHandle(); } [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] @@ -48,6 +54,14 @@ public void ReturnValue_CreatesSafeHandle() Assert.False(handle.IsInvalid); } + [Fact] + public void ReturnValue_CreatesSafeHandle_DirectConstructorCall() + { + using NativeExportsNE.NativeExportsSafeHandle handle = NativeExportsNE.NativeExportsSafeHandle.CreateNewHandle(); + Assert.False(handle.IsClosed); + Assert.False(handle.IsInvalid); + } + [Fact] public void ByValue_CorrectlyUnwrapsHandle() { 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 324b66ece1353..f27cd84671858 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -919,5 +919,15 @@ public IntStructWrapperNative(IntStructWrapper managed) public IntStructWrapper ToManaged() => new IntStructWrapper { Value = value }; } "; + + public static string SafeHandleWithCustomDefaultConstructorAccessibility(bool privateCtor) => BasicParametersAndModifiers("MySafeHandle") + $@" +class MySafeHandle : SafeHandle +{{ + {(privateCtor ? "private" : "public")} MySafeHandle() : base(System.IntPtr.Zero, true) {{ }} + + public override bool IsInvalid => handle == System.IntPtr.Zero; + + protected override bool ReleaseHandle() => true; +}}"; } } 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 1db8e4b0ead8e..004d2a01627f2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -124,6 +124,8 @@ public static IEnumerable CodeSnippetsToCompile() // SafeHandle yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + yield return new[] { CodeSnippets.SafeHandleWithCustomDefaultConstructorAccessibility(privateCtor: false) }; + yield return new[] { CodeSnippets.SafeHandleWithCustomDefaultConstructorAccessibility(privateCtor: true) }; // PreserveSig yield return new[] { CodeSnippets.PreserveSigFalseVoidReturn }; From 06f70500d93cda8be01ba000d8b7e72b95c9d11f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 9 Apr 2021 15:52:26 -0700 Subject: [PATCH 066/161] Fix build errors from an updated SDK/compiler and floating package versions. (dotnet/runtimelab#944) Centralize package versions in Versions.props so we have one point for updating a given package across the whole repo. Commit migrated from https://github.com/dotnet/runtimelab/commit/9aac13827fc9dcef80dfb44a3dab729a331762ae --- .../gen/DllImportGenerator/DllImportGenerator.csproj | 2 +- .../DllImportGenerator.Tests.csproj | 2 +- .../DllImportGenerator.UnitTests.csproj | 8 ++++---- .../tests/TestAssets/NativeExports/Arrays.cs | 2 +- .../tests/TestAssets/NativeExports/CustomMarshalling.cs | 8 ++++---- .../tests/TestAssets/NativeExports/Handles.cs | 4 ++-- .../tests/TestAssets/NativeExports/NativeExports.csproj | 2 +- .../tests/TestAssets/SharedTypes/NonBlittable.cs | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 9d92212ea0b20..dbc6bd335afea 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 092c17338e2c5..666f80ffa56b4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -9,7 +9,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index c1ed94a205ff0..4193397b9df01 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -9,14 +9,14 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs index 81665752a1740..b73c636423340 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs @@ -151,7 +151,7 @@ public static byte AndAllMembers([DNNE.C99Type("struct bool_struct*")] BoolStruc BoolStruct managed = pArray[i].ToManaged(); result &= managed.b1 && managed.b2 && managed.b3; } - return result ? 1 : 0; + return (byte)(result ? 1 : 0); } private static int* CreateRangeImpl(int start, int end, int* numValues) diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs index 0547fc87d62f8..539b8d45b8c26 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs @@ -38,9 +38,9 @@ public static void NegateBools( { *pBoolStructOut = new BoolStructNative { - b1 = boolStruct.b1 != 0 ? 0 : 1, - b2 = boolStruct.b2 != 0 ? 0 : 1, - b3 = boolStruct.b3 != 0 ? 0 : 1, + b1 = (byte)(boolStruct.b1 != 0 ? 0 : 1), + b2 = (byte)(boolStruct.b2 != 0 ? 0 : 1), + b3 = (byte)(boolStruct.b3 != 0 ? 0 : 1), }; } @@ -48,7 +48,7 @@ public static void NegateBools( public static byte AndBoolsRef( [DNNE.C99Type("struct bool_struct*")] BoolStructNative* boolStruct) { - return boolStruct->b1 != 0 && boolStruct->b2 != 0 && boolStruct->b3 != 0 ? 1 : 0; + return (byte)(boolStruct->b1 != 0 && boolStruct->b2 != 0 && boolStruct->b3 != 0 ? 1 : 0); } [UnmanagedCallersOnly(EntryPoint = "double_int_ref")] diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs index 588e00ae625e0..e17447659afae 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs @@ -29,13 +29,13 @@ public static void AllocateHandleOut(nint* handle) [UnmanagedCallersOnly(EntryPoint = "release_handle")] public static byte ReleaseHandle(nint handle) { - return ActiveHandles.Remove(handle) ? 1 : 0; + return (byte)(ActiveHandles.Remove(handle) ? 1 : 0); } [UnmanagedCallersOnly(EntryPoint = "is_handle_alive")] public static byte IsHandleAlive(nint handle) { - return ActiveHandles.Contains(handle) ? 1 : 0; + return (byte)(ActiveHandles.Contains(handle) ? 1 : 0); } [UnmanagedCallersOnly(EntryPoint = "modify_handle")] diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 85da2e62d45b8..73385d35112a1 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs index 823f1da0334f9..aee951b165ea9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs @@ -72,9 +72,9 @@ public struct BoolStructNative public byte b3; public BoolStructNative(BoolStruct bs) { - b1 = bs.b1 ? 1 : 0; - b2 = bs.b2 ? 1 : 0; - b3 = bs.b3 ? 1 : 0; + b1 = (byte)(bs.b1 ? 1 : 0); + b2 = (byte)(bs.b2 ? 1 : 0); + b3 = (byte)(bs.b3 ? 1 : 0); } public BoolStruct ToManaged() From 59aa9c7d37cb3c12d34017918116c495b0fdc7ff Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 12 Apr 2021 16:48:28 -0700 Subject: [PATCH 067/161] Fix cases when preprocessor definitions are surrounding the method we are generating. (dotnet/runtimelab#947) Commit migrated from https://github.com/dotnet/runtimelab/commit/600ff5af94ad6d1793787e62af75a7bf8ec7142a --- .../DllImportGenerator/DllImportGenerator.cs | 29 ++++++-- .../CodeSnippets.cs | 68 +++++++++++++++++++ .../DllImportGenerator.UnitTests/Compiles.cs | 26 +++++++ .../DllImportGenerator.UnitTests/TestUtils.cs | 4 +- 4 files changed, 120 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 1e012f8b69fa6..f022e8fac881a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -128,6 +128,25 @@ public void Initialize(GeneratorInitializationContext context) context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); } + private SyntaxTokenList StripTriviaFromModifiers(SyntaxTokenList tokenList) + { + SyntaxToken[] strippedTokens = new SyntaxToken[tokenList.Count]; + for (int i = 0; i < tokenList.Count; i++) + { + strippedTokens[i] = tokenList[i].WithoutTrivia(); + } + return new SyntaxTokenList(strippedTokens); + } + + private TypeDeclarationSyntax CreateTypeDeclarationWithoutTrivia(TypeDeclarationSyntax typeDeclaration) + { + return TypeDeclaration( + typeDeclaration.Kind(), + typeDeclaration.Identifier) + .WithTypeParameterList(typeDeclaration.TypeParameterList) + .WithModifiers(typeDeclaration.Modifiers); + } + private void PrintGeneratedSource( StringBuilder builder, MethodDeclarationSyntax userDeclaredMethod, @@ -137,27 +156,27 @@ private void PrintGeneratedSource( // Create stub function var stubMethod = MethodDeclaration(stub.StubReturnType, userDeclaredMethod.Identifier) .AddAttributeLists(stub.AdditionalAttributes) - .WithModifiers(userDeclaredMethod.Modifiers) + .WithModifiers(StripTriviaFromModifiers(userDeclaredMethod.Modifiers)) .WithParameterList(ParameterList(SeparatedList(stub.StubParameters))) .WithBody(stub.StubCode); // Create the DllImport declaration. var dllImport = stub.DllImportDeclaration.AddAttributeLists( AttributeList( - SingletonSeparatedList(dllImportAttr))); + SingletonSeparatedList(dllImportAttr))); // Stub should have at least one containing type Debug.Assert(stub.StubContainingTypes.Any()); // Add stub function and DllImport declaration to the first (innermost) containing - MemberDeclarationSyntax containingType = stub.StubContainingTypes.First() + MemberDeclarationSyntax containingType = CreateTypeDeclarationWithoutTrivia(stub.StubContainingTypes.First()) .AddMembers(stubMethod, dllImport); // Add type to the remaining containing types (skipping the first which was handled above) foreach (var typeDecl in stub.StubContainingTypes.Skip(1)) { - containingType = typeDecl.WithMembers( - SingletonList(containingType)); + containingType = CreateTypeDeclarationWithoutTrivia(typeDecl) + .WithMembers(SingletonList(containingType)); } MemberDeclarationSyntax toPrint = containingType; 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 f27cd84671858..76443d06f7ce8 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -929,5 +929,73 @@ class MySafeHandle : SafeHandle protected override bool ReleaseHandle() => true; }}"; + + public static string PreprocessorIfAroundFullFunctionDefinition(string define) => + @$" +partial class Test +{{ +#if {define} + [System.Runtime.InteropServices.GeneratedDllImport(""DoesNotExist"")] + public static partial int Method( + int p, + in int pIn, + out int pOut); +#endif +}}"; + + public static string PreprocessorIfAroundFullFunctionDefinitionWithFollowingFunction(string define) => + @$" +using System.Runtime.InteropServices; +partial class Test +{{ +#if {define} + [GeneratedDllImport(""DoesNotExist"")] + public static partial int Method( + int p, + in int pIn, + out int pOut); +#endif + public static int Method2( + SafeHandle p) => throw null; +}}"; + + public static string PreprocessorIfAfterAttributeAroundFunction(string define) => + @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] +#if {define} + public static partial int Method( + int p, + in int pIn, + out int pOut); +#else + public static partial int Method2( + int p, + in int pIn, + out int pOut); +#endif +}}"; + + public static string PreprocessorIfAfterAttributeAroundFunctionAdditionalFunctionAfter(string define) => + @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] +#if {define} + public static partial int Method( + int p, + in int pIn, + out int pOut); +#else + public static partial int Method2( + int p, + in int pIn, + out int pOut); +#endif + public static int Foo() => throw null; +}}"; } } 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 004d2a01627f2..dd931758c857d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -182,6 +182,32 @@ public async Task ValidateSnippets(string source) var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); } + + public static IEnumerable CodeSnippetsToCompileWithPreprocessorSymbols() + { + yield return new object[] { CodeSnippets.PreprocessorIfAroundFullFunctionDefinition("Foo"), new string[] { "Foo" } }; + yield return new object[] { CodeSnippets.PreprocessorIfAroundFullFunctionDefinition("Foo"), Array.Empty() }; + yield return new object[] { CodeSnippets.PreprocessorIfAroundFullFunctionDefinitionWithFollowingFunction("Foo"), new string[] { "Foo" } }; + yield return new object[] { CodeSnippets.PreprocessorIfAroundFullFunctionDefinitionWithFollowingFunction("Foo"), Array.Empty() }; + yield return new object[] { CodeSnippets.PreprocessorIfAfterAttributeAroundFunction("Foo"), new string[] { "Foo" } }; + yield return new object[] { CodeSnippets.PreprocessorIfAfterAttributeAroundFunction("Foo"), Array.Empty() }; + yield return new object[] { CodeSnippets.PreprocessorIfAfterAttributeAroundFunctionAdditionalFunctionAfter("Foo"), new string[] { "Foo" } }; + yield return new object[] { CodeSnippets.PreprocessorIfAfterAttributeAroundFunctionAdditionalFunctionAfter("Foo"), Array.Empty() }; + } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompileWithPreprocessorSymbols))] + public async Task ValidateSnippetsWithPreprocessorDefintions(string source, IEnumerable preprocessorSymbols) + { + Compilation comp = await TestUtils.CreateCompilation(source, preprocessorSymbols: preprocessorSymbols); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(generatorDiags); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } public static IEnumerable CodeSnippetsToCompileWithForwarder() { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index a57aca5cf62fb..ff7133257cf85 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -43,12 +43,12 @@ public static void AssertPreSourceGeneratorCompilation(Compilation comp) /// Output type /// Whether or not use of the unsafe keyword should be allowed /// The resulting compilation - public static async Task CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true) + public static async Task CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true, IEnumerable? preprocessorSymbols = null) { var (mdRefs, ancillary) = GetReferenceAssemblies(); return CSharpCompilation.Create("compilation", - new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, + new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview, preprocessorSymbols: preprocessorSymbols)) }, (await mdRefs.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)).Add(ancillary), new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); } From 842956952e12361390ad92960b6124738500272a Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 23 Apr 2021 17:16:02 -0700 Subject: [PATCH 068/161] Rename MarshalEx.SetLastWin32Error -> SetLastPInvokeError (dotnet/runtimelab#1007) Commit migrated from https://github.com/dotnet/runtimelab/commit/82735dd0fef4886ae2f0886267ef30822e17ee8a --- .../gen/DllImportGenerator/StubCodeGenerator.cs | 4 ++-- .../tests/Ancillary.Interop/MarshalEx.cs | 10 ++++++++-- .../DllImportGenerator.Tests/SetLastErrorTests.cs | 10 +++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 4a5f15ede8d4e..343f767a0b8f3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -321,13 +321,13 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo if (this.dllImportData.SetLastError && !options.GenerateForwarders()) { - // Marshal.SetLastWin32Error(); + // Marshal.SetLastPInvokeError(); allStatements.Add(ExpressionStatement( InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, ParseName(TypeNames.MarshalEx(options)), - IdentifierName("SetLastWin32Error")), + IdentifierName("SetLastPInvokeError")), ArgumentList(SingletonSeparatedList( Argument(IdentifierName(LastErrorIdentifier))))))); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs index 8a53af07090d9..716dcf28eece6 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -23,9 +23,15 @@ public static void InitHandle(SafeHandle safeHandle, IntPtr handle) /// /// Set the last platform invoke error on the thread /// - public static void SetLastWin32Error(int error) + public static void SetLastPInvokeError(int error) { - typeof(Marshal).GetMethod("SetLastWin32Error", BindingFlags.NonPublic | BindingFlags.Static)!.Invoke(null, new object[] { error }); + MethodInfo? method = typeof(Marshal).GetMethod("SetLastWin32Error", BindingFlags.NonPublic | BindingFlags.Static); + if (method == null) + { + method = typeof(Marshal).GetMethod("SetLastPInvokeError", BindingFlags.Public | BindingFlags.Static); + } + + method!.Invoke(null, new object[] { error }); } /// diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs index 45407ce0222b8..04542c7f8f487 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -18,7 +18,7 @@ public SetLastErrorMarshaller(int i) public int ToManaged() { // Explicity set the last error to something else on unmarshalling - MarshalEx.SetLastWin32Error(val * 2); + MarshalEx.SetLastPInvokeError(val * 2); return val; } } @@ -54,12 +54,12 @@ public void LastWin32Error_HasExpectedValue(int error) Assert.Equal(errorString, ret); // Clear the last error - MarshalEx.SetLastWin32Error(0); + MarshalEx.SetLastPInvokeError(0); NativeExportsNE.SetLastError.SetError(error, shouldSetError: 1); Assert.Equal(error, Marshal.GetLastWin32Error()); - MarshalEx.SetLastWin32Error(0); + MarshalEx.SetLastPInvokeError(0); // Custom marshalling sets the last error on unmarshalling. // Last error should reflect error from native call, not unmarshalling. @@ -71,7 +71,7 @@ public void LastWin32Error_HasExpectedValue(int error) public void ClearPreviousError() { int error = 100; - MarshalEx.SetLastWin32Error(error); + MarshalEx.SetLastPInvokeError(error); // Don't actually set the error in the native call. SetLastError=true should clear any existing error. string errorString = error.ToString(); @@ -79,7 +79,7 @@ public void ClearPreviousError() Assert.Equal(0, Marshal.GetLastWin32Error()); Assert.Equal(errorString, ret); - MarshalEx.SetLastWin32Error(error); + MarshalEx.SetLastPInvokeError(error); // Don't actually set the error in the native call. SetLastError=true should clear any existing error. NativeExportsNE.SetLastError.SetError(error, shouldSetError: 0); From 01325b1c4cede28a9716a3569d44c6d6d573b935 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 26 Apr 2021 12:44:48 -0700 Subject: [PATCH 069/161] Update to Arcade 6.0.0-beta.21222.1 (dotnet/runtimelab#1008) * Update to Arcade 6.0.0-beta.21222.1 * Set DNNE roll forward to Major so that we can build with 6.0 SDK Commit migrated from https://github.com/dotnet/runtimelab/commit/cd7b25b549a8719809d85f9d6292683f1a0a117e --- .../tests/TestAssets/NativeExports/NativeExports.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 73385d35112a1..b9e61a1a0de0a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -6,6 +6,7 @@ true true true + Major From c6ccabba674c2598d487f0af59b740bcf37915e2 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 26 Apr 2021 16:57:42 -0700 Subject: [PATCH 070/161] Stop using myget feed (dotnet/runtimelab#1022) Commit migrated from https://github.com/dotnet/runtimelab/commit/984f900636a641529213035839fd872833ec1121 --- .../DllImportGenerator.UnitTests.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index 4193397b9df01..080e1bae8e96c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -26,8 +26,4 @@ - - - https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json ;$(RestoreAdditionalProjectSources) - From 27ab2e996b311e45e4083df074d4ce3426aa1f85 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 27 Apr 2021 17:12:08 -0700 Subject: [PATCH 071/161] Update analysis warning location model to new syntax and clean up analyzer warning locations. (dotnet/runtimelab#984) Commit migrated from https://github.com/dotnet/runtimelab/commit/88a78946cf8a246348d48e7c42c6666cf57d68c3 --- .../AnalyzerReleases.Unshipped.md | 1 + .../Analyzers/AnalyzerDiagnostics.cs | 1 + .../ManualTypeMarshallingAnalyzer.cs | 174 +++++++++++------- .../DllImportGenerator/Resources.Designer.cs | 18 ++ .../gen/DllImportGenerator/Resources.resx | 6 + .../ManualTypeMarshallingAnalyzerTests.cs | 150 ++++++++------- 6 files changed, 224 insertions(+), 126 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md index 60a8e6c34eeb4..2e88786cee8fa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md @@ -20,3 +20,4 @@ DLLIMPORTGENANALYZER012 | Usage | Error | StackallocConstructorMus DLLIMPORTGENANALYZER013 | Usage | Warning | GeneratedDllImportMissingRequiredModifiers DLLIMPORTGENANALYZER014 | Usage | Error | RefValuePropertyUnsupported DLLIMPORTGENANALYZER015 | Interoperability | Disabled | ConvertToGeneratedDllImportAnalyzer +DLLIMPORTGENANALYZER016 | Usage | Error | GenericTypeMustBeClosed diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs index c4dd6109cb507..17a03e0447524 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs @@ -25,6 +25,7 @@ public static class Ids public const string StackallocMarshallingShouldSupportAllocatingMarshallingFallback = Prefix + "011"; public const string StackallocConstructorMustHaveStackBufferSizeConstant = Prefix + "012"; public const string RefValuePropertyUnsupported = Prefix + "014"; + public const string NativeGenericTypeMustBeClosed = Prefix + "016"; // GeneratedDllImport public const string GeneratedDllImportMissingRequiredModifiers = Prefix + "013"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 2a00d1efa5feb..97bc59387711f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -9,7 +9,7 @@ namespace Microsoft.Interop.Analyzers { - [DiagnosticAnalyzer(LanguageNames.CSharp)] + [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer { private const string Category = "Usage"; @@ -144,6 +144,16 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.RefValuePropertyUnsupportedDescription))); + public readonly static DiagnosticDescriptor NativeGenericTypeMustBeClosedRule = + new DiagnosticDescriptor( + Ids.NativeGenericTypeMustBeClosed, + "GenericTypeMustBeClosed", + GetResourceString(nameof(Resources.NativeGenericTypeMustBeClosedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.NativeGenericTypeMustBeClosedDescription))); + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create( BlittableTypeMustBeBlittableRule, @@ -158,7 +168,8 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, StackallocConstructorMustHaveStackBufferSizeConstantRule, - RefValuePropertyUnsupportedRule); + RefValuePropertyUnsupportedRule, + NativeGenericTypeMustBeClosedRule); public override void Initialize(AnalysisContext context) { @@ -245,11 +256,17 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) if (HasMultipleMarshallingAttributes(blittableTypeAttributeData, nativeMarshallingAttributeData)) { - context.ReportDiagnostic(Diagnostic.Create(CannotHaveMultipleMarshallingAttributesRule, blittableTypeAttributeData!.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + context.ReportDiagnostic( + blittableTypeAttributeData!.CreateDiagnostic( + CannotHaveMultipleMarshallingAttributesRule, + type.ToDisplayString())); } else if (blittableTypeAttributeData is not null && (!type.HasOnlyBlittableFields() || type.IsAutoLayout(StructLayoutAttribute))) { - context.ReportDiagnostic(Diagnostic.Create(BlittableTypeMustBeBlittableRule, blittableTypeAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + context.ReportDiagnostic( + blittableTypeAttributeData.CreateDiagnostic( + BlittableTypeMustBeBlittableRule, + type.ToDisplayString())); } else if (nativeMarshallingAttributeData is not null) { @@ -298,21 +315,43 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb { if (nativeMarshalerAttributeData.ConstructorArguments[0].IsNull) { - context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustBeNonNullRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + context.ReportDiagnostic( + nativeMarshalerAttributeData.CreateDiagnostic( + NativeTypeMustBeNonNullRule, + type.ToDisplayString())); return; } ITypeSymbol nativeType = (ITypeSymbol)nativeMarshalerAttributeData.ConstructorArguments[0].Value!; + ISymbol nativeTypeDiagnosticsTargetSymbol = nativeType; if (!nativeType.IsValueType) { - context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustHaveRequiredShapeRule, GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), nativeType.ToDisplayString(), type.ToDisplayString())); + context.ReportDiagnostic( + nativeType.CreateDiagnostic( + NativeTypeMustHaveRequiredShapeRule, + nativeType.ToDisplayString(), + type.ToDisplayString())); return; } if (nativeType is not INamedTypeSymbol marshalerType) { - context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustHaveRequiredShapeRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), nativeType.ToDisplayString(), type.ToDisplayString())); + context.ReportDiagnostic( + nativeMarshalerAttributeData.CreateDiagnostic( + NativeTypeMustHaveRequiredShapeRule, + nativeType.ToDisplayString(), + type.ToDisplayString())); + return; + } + + if (marshalerType.IsUnboundGenericType) + { + context.ReportDiagnostic( + nativeMarshalerAttributeData.CreateDiagnostic( + NativeGenericTypeMustBeClosedRule, + nativeType.ToDisplayString(), + type.ToDisplayString())); return; } @@ -333,7 +372,10 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb IFieldSymbol stackAllocSizeField = nativeType.GetMembers("StackBufferSize").OfType().FirstOrDefault(); if (stackAllocSizeField is null or { DeclaredAccessibility: not Accessibility.Public } or { IsConst: false } or { Type: not { SpecialType: SpecialType.System_Int32 } }) { - context.ReportDiagnostic(Diagnostic.Create(StackallocConstructorMustHaveStackBufferSizeConstantRule, ctor.DeclaringSyntaxReferences[0].GetSyntax()!.GetLocation(), nativeType.ToDisplayString())); + context.ReportDiagnostic( + ctor.CreateDiagnostic( + StackallocConstructorMustHaveStackBufferSizeConstantRule, + nativeType.ToDisplayString())); } } } @@ -343,27 +385,37 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb // Validate that the native type has at least one marshalling method (either managed to native or native to managed) if (!hasConstructor && !hasStackallocConstructor && !hasToManaged) { - context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustHaveRequiredShapeRule, GetSyntaxReferenceForDiagnostic(marshalerType).GetSyntax().GetLocation(), marshalerType.ToDisplayString(), type.ToDisplayString())); + context.ReportDiagnostic( + marshalerType.CreateDiagnostic( + NativeTypeMustHaveRequiredShapeRule, + marshalerType.ToDisplayString(), + type.ToDisplayString())); } // Validate that this type can support marshalling when stackalloc is not usable. if (validateAllScenarioSupport && hasStackallocConstructor && !hasConstructor) { - context.ReportDiagnostic(Diagnostic.Create(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, GetSyntaxReferenceForDiagnostic(marshalerType).GetSyntax().GetLocation(), marshalerType.ToDisplayString())); + context.ReportDiagnostic( + marshalerType.CreateDiagnostic( + StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, + marshalerType.ToDisplayString())); } IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); - bool valuePropertyIsRefReturn = valueProperty is { ReturnsByRef : true } or { ReturnsByRefReadonly: true }; - - if (valuePropertyIsRefReturn) - { - context.ReportDiagnostic(Diagnostic.Create(RefValuePropertyUnsupportedRule, GetSyntaxReferenceForDiagnostic(valueProperty!).GetSyntax().GetLocation(), - marshalerType.ToDisplayString())); - } + bool valuePropertyIsRefReturn = valueProperty is { ReturnsByRef: true } or { ReturnsByRefReadonly: true }; if (valueProperty is not null) { + if (valuePropertyIsRefReturn) + { + context.ReportDiagnostic( + valueProperty.CreateDiagnostic( + RefValuePropertyUnsupportedRule, + marshalerType.ToDisplayString())); + } + nativeType = valueProperty.Type; + nativeTypeDiagnosticsTargetSymbol = valueProperty; // Validate that we don't have partial implementations. // We error if either of the conditions below are partially met but not fully met: @@ -371,73 +423,67 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb // - a ToManaged method and a Value property setter if ((hasConstructor || hasStackallocConstructor) && valueProperty.GetMethod is null) { - context.ReportDiagnostic(Diagnostic.Create(ValuePropertyMustHaveGetterRule, GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation(), marshalerType.ToDisplayString())); + context.ReportDiagnostic( + valueProperty.CreateDiagnostic( + ValuePropertyMustHaveGetterRule, + marshalerType.ToDisplayString())); } if (hasToManaged && valueProperty.SetMethod is null) { - context.ReportDiagnostic(Diagnostic.Create(ValuePropertyMustHaveSetterRule, GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation(), marshalerType.ToDisplayString())); + context.ReportDiagnostic( + valueProperty.CreateDiagnostic( + ValuePropertyMustHaveSetterRule, + marshalerType.ToDisplayString())); } } - + if (!nativeType.IsConsideredBlittable()) { - context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustBeBlittableRule, - valueProperty is not null - ? GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation() - : GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), - nativeType.ToDisplayString(), - type.ToDisplayString())); + context.ReportDiagnostic( + nativeTypeDiagnosticsTargetSymbol.CreateDiagnostic( + NativeTypeMustBeBlittableRule, + nativeType.ToDisplayString(), + type.ToDisplayString())); } - IMethodSymbol? managedGetPinnableReferenceMethod = ManualTypeMarshallingHelper.FindGetPinnableReference(type); - if (validateManagedGetPinnableReference && managedGetPinnableReferenceMethod is not null) + // Use a tuple here instead of an anonymous type so we can do the reassignment and pattern matching below. + var getPinnableReferenceMethods = new { - if (!managedGetPinnableReferenceMethod.ReturnType.IsConsideredBlittable()) + Managed = validateManagedGetPinnableReference? ManualTypeMarshallingHelper.FindGetPinnableReference(type) : null, + Marshaler = ManualTypeMarshallingHelper.FindGetPinnableReference(marshalerType) + }; + + if (getPinnableReferenceMethods.Managed is not null) + { + if (!getPinnableReferenceMethods.Managed.ReturnType.IsConsideredBlittable()) { - context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceReturnTypeBlittableRule, managedGetPinnableReferenceMethod.DeclaringSyntaxReferences[0].GetSyntax().GetLocation())); + context.ReportDiagnostic(getPinnableReferenceMethods.Managed.CreateDiagnostic(GetPinnableReferenceReturnTypeBlittableRule)); } // Validate that our marshaler supports scenarios where GetPinnableReference cannot be used. if (validateAllScenarioSupport && (!hasConstructor || valueProperty is { GetMethod: null })) { - context.ReportDiagnostic(Diagnostic.Create(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, nativeMarshalerAttributeData.ApplicationSyntaxReference!.GetSyntax().GetLocation(), type.ToDisplayString())); + context.ReportDiagnostic( + nativeMarshalerAttributeData.CreateDiagnostic( + GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, + type.ToDisplayString())); } } - if ((validateManagedGetPinnableReference && managedGetPinnableReferenceMethod is not null) - || ManualTypeMarshallingHelper.FindGetPinnableReference(marshalerType) is not null) + if ((getPinnableReferenceMethods.Managed is not null + || getPinnableReferenceMethods.Marshaler is not null) + && !valuePropertyIsRefReturn // Ref returns are already reported above as invalid, so don't issue another warning here about them + && nativeType is not ( + IPointerTypeSymbol _ or + { SpecialType: SpecialType.System_IntPtr } or + { SpecialType: SpecialType.System_UIntPtr })) { - // Validate that the Value property is a pointer-sized primitive type. - if (valueProperty is null - || (valueProperty.Type is not ( - IPointerTypeSymbol _ or - { SpecialType: SpecialType.System_IntPtr } or - { SpecialType: SpecialType.System_UIntPtr }))) - { - ITypeSymbol typeWithGetPinnableReference = managedGetPinnableReferenceMethod is not null - ? type - : marshalerType; - - context.ReportDiagnostic(Diagnostic.Create(NativeTypeMustBePointerSizedRule, - valueProperty is not null - ? GetSyntaxReferenceForDiagnostic(valueProperty).GetSyntax().GetLocation() - : GetSyntaxReferenceForDiagnostic(nativeType).GetSyntax().GetLocation(), - valuePropertyIsRefReturn - ? $"ref {nativeType.ToDisplayString()}" - : nativeType.ToDisplayString(), - typeWithGetPinnableReference.ToDisplayString())); - } - } + IMethodSymbol getPinnableReferenceMethodToMention = getPinnableReferenceMethods.Managed ?? getPinnableReferenceMethods.Marshaler!; - SyntaxReference GetSyntaxReferenceForDiagnostic(ISymbol targetSymbol) - { - if (targetSymbol.DeclaringSyntaxReferences.IsEmpty) - { - return nativeMarshalerAttributeData.ApplicationSyntaxReference!; - } - else - { - return targetSymbol.DeclaringSyntaxReferences[0]; - } + context.ReportDiagnostic( + nativeTypeDiagnosticsTargetSymbol.CreateDiagnostic( + NativeTypeMustBePointerSizedRule, + nativeType.ToDisplayString(), + getPinnableReferenceMethodToMention.ContainingType.ToDisplayString())); } } } 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 071ce9c6328b5..e86940b256c65 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -357,6 +357,24 @@ internal static string MarshallingStringOrCharAsUndefinedNotSupported { } } + /// + /// Looks up a localized string similar to The native type '{0}' must be a closed generic so the emitted code can use a specific instantiation.. + /// + internal static string NativeGenericTypeMustBeClosedDescription { + get { + return ResourceManager.GetString("NativeGenericTypeMustBeClosedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' for managed type '{1}' must be a closed generic type.. + /// + internal static string NativeGenericTypeMustBeClosedMessage { + get { + return ResourceManager.GetString("NativeGenericTypeMustBeClosedMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to A native type for a given type must be blittable.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 7f41f03a9b989..c6a5491493395 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -217,6 +217,12 @@ Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'. + + The native type '{0}' must be a closed generic so the emitted code can use a specific instantiation. + + + The native type '{0}' for managed type '{1}' must be a closed generic type. + A native type for a given type must be blittable. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index 51a1e002af653..0aae34ff49539 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -17,7 +17,7 @@ public static IEnumerable NonBlittableTypeMarkedBlittable_ReportsDiagn @" using System.Runtime.InteropServices; -[BlittableType] +[{|#0:BlittableType|}] struct S { public bool field; @@ -29,7 +29,7 @@ struct S @" using System.Runtime.InteropServices; -[BlittableType] +[{|#0:BlittableType|}] struct S { public char field; @@ -38,11 +38,11 @@ struct S }; yield return new object[] { - + @" using System.Runtime.InteropServices; -[BlittableType] +[{|#0:BlittableType|}] struct S { public string field; @@ -56,7 +56,7 @@ struct S [Theory] public async Task NonBlittableTypeMarkedBlittable_ReportsDiagnostic(string source) { - var diagnostic = VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S"); + var diagnostic = VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S"); await VerifyCS.VerifyAnalyzerAsync(source, diagnostic); } @@ -127,13 +127,13 @@ struct S public T field; } -[BlittableType] +[{|#0:BlittableType|}] struct T { public bool field; } "; - var diagnostic = VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(10, 2, 10, 15).WithArguments("T"); + var diagnostic = VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("T"); await VerifyCS.VerifyAnalyzerAsync(source, diagnostic); } @@ -149,14 +149,14 @@ struct S public T field; } -[BlittableType] +[{|#0:BlittableType|}] struct T { public string field; } "; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(10, 2, 10, 15).WithArguments("T")); + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("T")); } [Fact] @@ -181,14 +181,14 @@ public async Task NullNativeType_ReportsDiagnostic() string source = @" using System.Runtime.InteropServices; -[NativeMarshalling(null)] +[{|#0:NativeMarshalling(null)|}] struct S { public string s; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBeNonNullRule).WithSpan(4, 2, 4, 25).WithArguments("S")); + VerifyCS.Diagnostic(NativeTypeMustBeNonNullRule).WithLocation(0).WithArguments("S")); } [Fact] @@ -197,14 +197,14 @@ public async Task NonNamedNativeType_ReportsDiagnostic() string source = @" using System.Runtime.InteropServices; -[NativeMarshalling(typeof(int*))] +[{|#0:NativeMarshalling(typeof(int*))|}] struct S { public string s; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(4, 2, 4, 33).WithArguments("int*", "S")); + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("int*", "S")); } [Fact] @@ -219,7 +219,7 @@ struct S public string s; } -struct Native +struct {|#0:Native|} { private string value; @@ -231,7 +231,7 @@ public Native(S s) public S ToManaged() => new S { s = value }; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 20, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } [Fact] @@ -247,7 +247,7 @@ struct S public string s; } -class Native +class {|#0:Native|} { private IntPtr value; @@ -258,7 +258,7 @@ public Native(S s) public S ToManaged() => new S(); }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(11, 1, 20, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } [Fact] @@ -315,11 +315,11 @@ public Native(S s) public S ToManaged() => new S(); - public string Value { get => null; set {} } + public string {|#0:Value|} { get => null; set {} } }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(23, 5, 23, 48).WithArguments("string", "S")); + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("string", "S")); } [Fact] @@ -365,7 +365,7 @@ struct S public string s; } -class Native +class {|#0:Native|} { private string value; @@ -380,7 +380,7 @@ public Native(S s) }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(11, 1, 23, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } [Fact] @@ -395,7 +395,7 @@ class S { public char c; - public ref char GetPinnableReference() => ref c; + public ref char {|#0:GetPinnableReference|}() => ref c; } unsafe struct Native @@ -413,7 +413,7 @@ public Native(S s) }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(GetPinnableReferenceReturnTypeBlittableRule).WithSpan(10, 5, 10, 53)); + VerifyCS.Diagnostic(GetPinnableReferenceReturnTypeBlittableRule).WithLocation(0)); } @@ -475,11 +475,11 @@ public Native(S s) : this() public S ToManaged() => new S(); - public int Value { get => 0; set {} } + public int {|#0:Value|} { get => 0; set {} } }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithSpan(24, 5, 24, 42).WithArguments("int", "S")); + VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithLocation(0).WithArguments("int", "S")); } [Fact] @@ -538,12 +538,11 @@ public Native(S s) : this() value = s; } - public ref byte Value { get => ref value.GetPinnableReference(); } + public ref byte {|#0:Value|} { get => ref value.GetPinnableReference(); } }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithSpan(22, 5, 22, 71).WithArguments("ref byte", "S"), - VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithSpan(22, 5, 22, 71).WithArguments("Native")); + VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithLocation(0).WithArguments("Native")); } [Fact] @@ -570,12 +569,11 @@ public Native(S s) : this() public ref byte GetPinnableReference() => ref value.c; - public ref byte Value { get => ref GetPinnableReference(); } + public ref byte {|#0:Value|} { get => ref GetPinnableReference(); } }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithSpan(22, 5, 22, 65).WithArguments("ref byte", "Native"), - VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithSpan(22, 5, 22, 65).WithArguments("Native")); + VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithLocation(0).WithArguments("Native")); } [Fact] @@ -607,12 +605,12 @@ class S } [BlittableType] -struct Native +struct {|#0:Native|} { }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithSpan(11, 1, 14, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } [Fact] @@ -673,7 +671,7 @@ class S } [BlittableType] -struct Native +struct {|#0:Native|} { public Native(S s, Span buffer) {} @@ -681,7 +679,7 @@ public Native(S s, Span buffer) {} }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(11, 1, 17, 2).WithArguments("Native")); + VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithLocation(0).WithArguments("Native")); } [Fact] @@ -691,14 +689,14 @@ public async Task TypeWithOnlyNativeStackallocConstructorAndGetPinnableReference using System; using System.Runtime.InteropServices; -[NativeMarshalling(typeof(Native))] +[{|#0:NativeMarshalling(typeof(Native))|}] class S { public byte c; public ref byte GetPinnableReference() => ref c; } -struct Native +struct {|#1:Native|} { public Native(S s, Span buffer) {} @@ -708,8 +706,8 @@ public Native(S s, Span buffer) {} }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithSpan(12, 1, 19, 2).WithArguments("Native"), - VerifyCS.Diagnostic(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule).WithSpan(5, 2, 5, 35).WithArguments("S", "Native")); + VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithLocation(1).WithArguments("Native"), + VerifyCS.Diagnostic(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule).WithLocation(0).WithArguments("S", "Native")); } [Fact] @@ -729,11 +727,11 @@ struct Native { public Native(S s) {} - public IntPtr Value { set {} } + public IntPtr {|#0:Value|} { set {} } }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(ValuePropertyMustHaveGetterRule).WithSpan(15, 5, 15, 35).WithArguments("Native")); + VerifyCS.Diagnostic(ValuePropertyMustHaveGetterRule).WithLocation(0).WithArguments("Native")); } [Fact] @@ -753,11 +751,11 @@ struct Native { public S ToManaged() => new S(); - public IntPtr Value => IntPtr.Zero; + public IntPtr {|#0:Value|} => IntPtr.Zero; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(ValuePropertyMustHaveSetterRule).WithSpan(15, 5, 15, 40).WithArguments("Native")); + VerifyCS.Diagnostic(ValuePropertyMustHaveSetterRule).WithLocation(0).WithArguments("Native")); } [Fact] @@ -807,7 +805,7 @@ struct S public string s; } -struct Native +struct {|#0:Native|} { private string value; @@ -826,7 +824,7 @@ static void Foo([MarshalUsing(typeof(Native))] S s) } "; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 19, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } [Fact] @@ -841,7 +839,7 @@ struct S public string s; } -struct Native +struct {|#0:Native|} { private string value; @@ -860,7 +858,7 @@ static class Test } "; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 19, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } [Fact] @@ -875,7 +873,7 @@ struct S public string s; } -struct Native +struct {|#0:Native|} { private string value; @@ -894,7 +892,7 @@ struct Test } "; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithSpan(10, 1, 19, 2).WithArguments("Native", "S")); + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } @@ -928,7 +926,7 @@ public Native(T s) [Fact] public async Task GenericNativeTypeWithGenericMemberInstantiatedWithBlittable_DoesNotReportDiagnostic() { - + string source = @" using System.Runtime.InteropServices; @@ -953,6 +951,34 @@ public Native(S s) await VerifyCS.VerifyAnalyzerAsync(source); } + [Fact] + public async Task UninstantiatedGenericNativeType_ReportsDiagnostic() + { + + string source = @" +using System.Runtime.InteropServices; + +[{|#0:NativeMarshalling(typeof(Native<>))|}] +struct S +{ + public string s; +} + +struct Native + where T : new() +{ + public Native(S s) + { + Value = new T(); + } + + public S ToManaged() => new S(); + + public T Value { get; set; } +}"; + await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeGenericTypeMustBeClosedRule).WithLocation(0).WithArguments("Native<>", "S")); + } + [Fact] public async Task ValueTypeContainingPointerBlittableType_DoesNotReportDiagnostic() { @@ -973,13 +999,13 @@ public async Task ValueTypeContainingPointerToNonBlittableType_ReportsDiagnostic var source = @" using System.Runtime.InteropServices; -[BlittableType] +[{|#0:BlittableType|}] unsafe struct S { private bool* ptr; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S")); + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S")); } [Fact] @@ -1004,14 +1030,14 @@ public async Task NonBlittableValueTypeContainingPointerToSelf_ReportsDiagnostic var source = @" using System.Runtime.InteropServices; -[BlittableType] +[{|#0:BlittableType|}] unsafe struct S { private bool fld; private S* ptr; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("S")); + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S")); } [Fact] @@ -1061,13 +1087,13 @@ struct G T fld; } -[BlittableType] +[{|#0:BlittableType|}] unsafe struct S { private G field; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(10, 2, 10, 15).WithArguments("S")); + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S")); } [Fact] @@ -1076,13 +1102,13 @@ public async Task BlittableGenericTypeTypeParameterReferenceType_ReportsDiagnost var source = @" using System.Runtime.InteropServices; -[BlittableType] +[{|#0:BlittableType|}] struct G where T : class { T fld; }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(4, 2, 4, 15).WithArguments("G")); + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("G")); } [Fact] @@ -1138,7 +1164,7 @@ public async Task BlittableNestedGenericTypeWithReferenceTypeGenericParameter_Do struct C where T : class { - [BlittableType] + [{|#0:BlittableType|}] struct G { T fld; @@ -1146,7 +1172,7 @@ struct G } "; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithSpan(6, 6, 6, 19).WithArguments("C.G")); + VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("C.G")); } [Fact] @@ -1180,11 +1206,11 @@ class S struct Native { public Native(S s) {} - public Native(S s, Span buffer) {} + public {|#0:Native|}(S s, Span buffer) {} }"; await VerifyCS.VerifyAnalyzerAsync(source, - VerifyCS.Diagnostic(StackallocConstructorMustHaveStackBufferSizeConstantRule).WithSpan(15, 5, 15, 45).WithArguments("Native")); + VerifyCS.Diagnostic(StackallocConstructorMustHaveStackBufferSizeConstantRule).WithLocation(0).WithArguments("Native")); } } } \ No newline at end of file From a20fbed73bbd796ad3239799b61fb2e57fee3546 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 27 Apr 2021 20:09:23 -0700 Subject: [PATCH 072/161] Merge latest standalone-template into feature/DllImportGenerator (dotnet/runtimelab#1031) * Fix runsettings generation * Update standalone-template for recent infrastructure changes (dotnet/runtimelab#1024) * Update to Arcade 6.0.0-beta.21226.16 * Update dependency for using custom runtime version * Update README * Don't use custom runtime in Ancillary.Interop Co-authored-by: Santiago Fernandez Madero Commit migrated from https://github.com/dotnet/runtimelab/commit/57b11ae82fd1f4fbde9a98e415082db6087d0142 --- .../tests/Ancillary.Interop/Ancillary.Interop.csproj | 1 + 1 file changed, 1 insertion(+) 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 e223452209455..07df8f73d0df1 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 @@ -7,6 +7,7 @@ System.Runtime.InteropServices enable true + false From f524afa1f44407a474e29b4fbe8b28cd93921ccc Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 28 Apr 2021 11:26:34 -0700 Subject: [PATCH 073/161] Move docs to top-level directory (dotnet/runtimelab#1034) Commit migrated from https://github.com/dotnet/runtimelab/commit/4a232c1a38dcb88a2dd6755672e5c419f241eeff --- .../DllImportGenerator/Compatibility.md | 0 .../DllImportGenerator/Diagnostics.md | 0 .../libraries/DllImportGenerator/Pipeline.md | 15 ++++++--- .../DllImportGenerator/StructMarshalling.md | 0 .../gen/readme.md | 31 ------------------- 5 files changed, 10 insertions(+), 36 deletions(-) rename {src/libraries/System.Runtime.InteropServices/gen/docs => docs}/design/libraries/DllImportGenerator/Compatibility.md (100%) rename {src/libraries/System.Runtime.InteropServices/gen/docs => docs}/design/libraries/DllImportGenerator/Diagnostics.md (100%) rename {src/libraries/System.Runtime.InteropServices/gen/docs => docs}/design/libraries/DllImportGenerator/Pipeline.md (89%) rename {src/libraries/System.Runtime.InteropServices/gen/docs => docs}/design/libraries/DllImportGenerator/StructMarshalling.md (100%) delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/readme.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md b/docs/design/libraries/DllImportGenerator/Compatibility.md similarity index 100% rename from src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Compatibility.md rename to docs/design/libraries/DllImportGenerator/Compatibility.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Diagnostics.md b/docs/design/libraries/DllImportGenerator/Diagnostics.md similarity index 100% rename from src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Diagnostics.md rename to docs/design/libraries/DllImportGenerator/Diagnostics.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md b/docs/design/libraries/DllImportGenerator/Pipeline.md similarity index 89% rename from src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md rename to docs/design/libraries/DllImportGenerator/Pipeline.md index a751257bcee7f..d9e4acb0b758a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/Pipeline.md +++ b/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -14,11 +14,11 @@ The pipeline uses the Roslyn [Syntax APIs](https://docs.microsoft.com/dotnet/api The generator processes the method's `GeneratedDllImportAttribute` data, the method's parameter and return types, and the metadata on them (e.g. [`LCIDConversionAttribute`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute), [`MarshalAsAttribute`][MarshalAsAttribute], [struct marshalling attributes](StructMarshalling.md)). This information is used to determine the corresponding native type for each managed parameter/return type and how they will be marshalled. -A [`TypePositionInfo`](../DllImportGenerator/TypePositionInfo.cs) is created for each type that needs to be marshalled. For each parameter and return type, this captures the managed type, managed and native positions (return or index in parameter list), and marshalling information. +A [`TypePositionInfo`][src-TypePositionInfo] is created for each type that needs to be marshalled. For each parameter and return type, this captures the managed type, managed and native positions (return or index in parameter list), and marshalling information. -The marshalling information is represented by various subclasses of [`MarshallingInfo`](../DllImportGenerator/MarshallingAttributeInfo.cs) and represents all user-defined marshalling information for the specific parameter or return type. These classes are intended to simply capture any specified marshalling information, not interpret what that information means in terms of marshalling behaviour; that is handled when determining the [marshalling generator](#marshalling-generators) for each `TypePositionInfo`. +The marshalling information is represented by various subclasses of [`MarshallingInfo`][src-MarshallingAttributeInfo] and represents all user-defined marshalling information for the specific parameter or return type. These classes are intended to simply capture any specified marshalling information, not interpret what that information means in terms of marshalling behaviour; that is handled when determining the [marshalling generator](#marshalling-generators) for each `TypePositionInfo`. -The processing step also includes handling any implicit parameter/return types that are required for the P/Invoke, but not part of the managed method signature; for example, a method with [`PreserveSig=false`][PreserveSig] requires an HRESULT return type and potentially an out parameter matching the managed method's return type. +The processing step also includes handling any implicit parameter/return types that are required for the P/Invoke, but not part of the managed method signature; for example, a method with [`PreserveSig=false`][PreserveSig] requires an HRESULT return type and potentially an out parameter matching the managed method's return type. ### `PreserveSig=false` @@ -52,9 +52,9 @@ static partial int MethodWithReturn__PInvoke__(byte* retVal); ## Marshalling generators -Each parameter and return for the method is handled by an [`IMarshallingGenerator`](../DllImportGenerator/Marshalling/MarshallingGenerator.cs) instance. The processed information for each parameter and return type is used to determine the appropriate marshalling generator for handling that type. Support for different types can be added in the form of new implementations of `IMarshallingGenerator`. +Each parameter and return for the method is handled by an [`IMarshallingGenerator`][src-MarshallingGenerator] instance. The processed information for each parameter and return type is used to determine the appropriate marshalling generator for handling that type. Support for different types can be added in the form of new implementations of `IMarshallingGenerator`. -The marshalling generators are responsible for generating the code for each [stage](#stages) of the stub. They are intended to be stateless, such that they are given all the data ([`TypePositionInfo`](../DllImportGenerator/TypePositionInfo.cs)) for which they need to generate marshalling code and the context ([`StubCodeContext`](../DllImportGenerator/StubCodeContext.cs)) under which that code should be generated. +The marshalling generators are responsible for generating the code for each [stage](#stages) of the stub. They are intended to be stateless, such that they are given all the data ([`TypePositionInfo`][src_TypePositionInfo]) for which they need to generate marshalling code and the context ([`StubCodeContext`][src-StubCodeContext]) under which that code should be generated. ## Stub code generation @@ -211,6 +211,11 @@ static partial byte Method__PInvoke__(ushort* s); ``` +[src-MarshallingAttributeInfo]: ../DllImportGenerator/DllImportGenerator/MarshallingAttributeInfo.cs +[src-MarshallingGenerator]: ../DllImportGenerator/DllImportGenerator/Marshalling/MarshallingGenerator.cs +[src-StubCodeContext]: ../DllImportGenerator/DllImportGenerator/StubCodeContext.cs +[src-TypePositionInfo]: ../DllImportGenerator/DllImportGenerator/TypePositionInfo.cs + [DllImportAttribute]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute [MarshalAsAttribute]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute [InAttribute]: https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.inattribute diff --git a/src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/docs/design/libraries/DllImportGenerator/StructMarshalling.md similarity index 100% rename from src/libraries/System.Runtime.InteropServices/gen/docs/design/libraries/DllImportGenerator/StructMarshalling.md rename to docs/design/libraries/DllImportGenerator/StructMarshalling.md diff --git a/src/libraries/System.Runtime.InteropServices/gen/readme.md b/src/libraries/System.Runtime.InteropServices/gen/readme.md deleted file mode 100644 index e4b19e8da00fb..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/gen/readme.md +++ /dev/null @@ -1,31 +0,0 @@ -# DllImport Generator - -Work on this project can be tracked and discussed via the [official issue](https://github.com/dotnet/runtime/issues/43060) in `dotnet/runtime`. The [P/Invoke source generator proposal](https://github.com/dotnet/runtime/blob/master/docs/design/features/source-generator-pinvokes.md) contains additional details. - -## Example - -The [Demo project](./DllImportGenerator/Demo) is designed to be immediately consumable by everyone. It demonstrates a simple use case where the marshalling code is generated and a native function call with only [blittable types](https://docs.microsoft.com/dotnet/framework/interop/blittable-and-non-blittable-types) is made. The project is configured to output the generated source to disk; the files can be found in the project's intermediate directory (`obj///generated`). A managed assembly with [native exports](./DllImportGenerator/TestAssets/NativeExports) is used in the P/Invoke scenario. - -### Recommended scenarios: - -* Step into the `Demo` application and observe the generated code for the `Sum` functions. -* Find the implementation of the `sumrefi` function and set a breakpoint. Run the debugger and explore the stack. -* Add a new export in the `NativeExports` project and update the `Demo` application to call the new export. -* Try the above scenarios when building in `Debug` or `Release`. Consider the differences. - -## Designs - -- [Code generation pipeline](./designs/Pipeline.md) -- [Struct Marshalling](./designs/StructMarshalling.md) - -## Workflow - -All features of the [`dotnet` command line tool](https://docs.microsoft.com/dotnet/core/tools/) are supported for the respective project types (e.g. `build`, `run`, `test`). A consistent cross-platform inner dev loop with an IDE is available using [Visual Studio Code](https://code.visualstudio.com/) when appropriate .NET extensions are loaded. - -On Windows, loading the [solution](./DllImportGenerator.sln) in [Visual Studio](https://visualstudio.microsoft.com/) 2019 or later will enable the edit, build, debug inner dev loop. All features of Visual Studio are expected to operate correctly (e.g. Debugger, Test runner, Profiler). - -Most of the above options have [official tutorials](https://docs.microsoft.com/dotnet/core/tutorials/). It is an aim of this project to follow canonical workflows that are intuitive to all developers. - -### Testing assets - -This project has no explicit native build system and should remain that way. The [`DNNE`](https://github.com/AaronRobinsonMSFT/DNNE/) project is used to create native exports that can be called from the P/Invokes during testing. From d7a6a6f9e51d43e2df5c55a65653642f0f2115e3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 30 Apr 2021 10:39:30 -0700 Subject: [PATCH 074/161] Add DLLIMPORTGENERATOR_ENABLED when DllImportGenerator package is referenced (dotnet/runtimelab#1050) Commit migrated from https://github.com/dotnet/runtimelab/commit/e1116095420cecf0d28f04d8e422653761fc37dc --- .../ConvertToGeneratedDllImportFixer.cs | 4 ++-- .../DllImportGenerator/DllImportGenerator.cs | 2 +- .../Microsoft.Interop.DllImportGenerator.props | 3 +++ .../ConvertToGeneratedDllImportFixerTests.cs | 18 +++++++++--------- .../Verifiers/CSharpCodeFixVerifier.cs | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) 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 c08c90c32162d..d21b12e6e9037 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs @@ -127,11 +127,11 @@ private async Task ConvertToGeneratedDllImport( } else { - // #if NET + // #if DLLIMPORTGENERATOR_ENABLED generatedDeclaration = generatedDeclaration.WithLeadingTrivia( generatedDeclaration.GetLeadingTrivia() .AddRange(new[] { - SyntaxFactory.Trivia(SyntaxFactory.IfDirectiveTrivia(SyntaxFactory.IdentifierName("NET"), isActive: true, branchTaken: true, conditionValue: true)), + SyntaxFactory.Trivia(SyntaxFactory.IfDirectiveTrivia(SyntaxFactory.IdentifierName("DLLIMPORTGENERATOR_ENABLED"), isActive: true, branchTaken: true, conditionValue: true)), SyntaxFactory.ElasticMarker })); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index f022e8fac881a..0a342621345f1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -203,7 +203,7 @@ private static bool IsSupportedTargetFramework(Compilation compilation, out Vers // .NET Standard "netstandard" => false, // .NET Core (when version < 5.0) or .NET - "System.Runtime" => version >= MinimumSupportedFrameworkVersion, + "System.Runtime" or "System.Private.CoreLib" => version >= MinimumSupportedFrameworkVersion, _ => false, }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props index bf6b2d4a0d0ca..13f7ad3690bf2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props @@ -16,4 +16,7 @@ --> + + $(DefineConstants);DLLIMPORTGENERATOR_ENABLED + 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 ddad1cc5c67e5..ebd3b3cdc6bb4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs @@ -28,7 +28,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ -#if NET +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(""DoesNotExist"")] public static partial int {{|CS8795:Method|}}(out int ret); #else @@ -74,7 +74,7 @@ partial class Test partial class Test {{ // P/Invoke -#if NET +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(/*name*/""DoesNotExist"")] // comment public static partial int {{|CS8795:Method1|}}(out int ret); #else @@ -83,7 +83,7 @@ partial class Test #endif /** P/Invoke **/ -#if NET +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(""DoesNotExist"") /*name*/] // < ... > public static partial int {{|CS8795:Method2|}}(out int ret); @@ -135,7 +135,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ -#if NET +#if DLLIMPORTGENERATOR_ENABLED [System.ComponentModel.Description(""Test""), GeneratedDllImport(""DoesNotExist"")] public static partial int {{|CS8795:Method1|}}(out int ret); #else @@ -143,7 +143,7 @@ partial class Test public static extern int Method1(out int ret); #endif -#if NET +#if DLLIMPORTGENERATOR_ENABLED [System.ComponentModel.Description(""Test"")] [GeneratedDllImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.I4)] @@ -194,7 +194,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ -#if NET +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial int {{|CS8795:Method1|}}(out int ret); #else @@ -202,7 +202,7 @@ partial class Test public static extern int Method1(out int ret); #endif -#if NET +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", CharSet = CharSet.Unicode)] public static partial int {{|CS8795:Method2|}}(out int ret); #else @@ -246,7 +246,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ -#if NET +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial int {{|CS8795:Method1|}}(out int ret); #else @@ -254,7 +254,7 @@ partial class Test public static extern int Method1(out int ret); #endif -#if NET +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(""DoesNotExist"")] public static partial int {{|CS8795:Method2|}}(out int ret); #else diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs index 2d04e5497a18e..9074cc753c1af 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs @@ -113,7 +113,7 @@ public Test() } protected override ParseOptions CreateParseOptions() - => ((CSharpParseOptions)base.CreateParseOptions()).WithPreprocessorSymbols("NET"); + => ((CSharpParseOptions)base.CreateParseOptions()).WithPreprocessorSymbols("DLLIMPORTGENERATOR_ENABLED"); } } -} \ No newline at end of file +} From 016ae6f1d8294dbabfff6762a8d9f51f46c6be82 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 30 Apr 2021 10:42:52 -0700 Subject: [PATCH 075/161] Switch to the now-built-in Marshal APIs from MarshalEx (dotnet/runtimelab#1042) Commit migrated from https://github.com/dotnet/runtimelab/commit/26dec3e1ca3fac21946bfbcc3031bd2017929c10 --- .../Marshalling/SafeHandleMarshaller.cs | 2 +- .../DllImportGenerator/StubCodeGenerator.cs | 6 +- .../Ancillary.Interop.csproj | 3 +- .../tests/Ancillary.Interop/MarshalEx.cs | 91 +------------------ .../DllImportGenerator.Tests.csproj | 2 +- .../SetLastErrorTests.cs | 10 +- .../DllImportGenerator.UnitTests.csproj | 2 +- .../DllImportGenerator.UnitTests/TestUtils.cs | 10 +- .../NativeExports/NativeExports.csproj | 2 +- .../TestAssets/SharedTypes/SharedTypes.csproj | 2 +- .../DllImportGeneratorSample.csproj | 5 +- 11 files changed, 25 insertions(+), 110 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index ba80a029e843f..7fa6513186c18 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -181,7 +181,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont StatementSyntax unmarshalStatement = ExpressionStatement( InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.MarshalEx(options)), + ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), IdentifierName("InitHandle")), ArgumentList(SeparatedList( new [] diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 343f767a0b8f3..696cac760ffa2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -261,7 +261,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.MarshalEx(options)), + ParseName(TypeNames.System_Runtime_InteropServices_Marshal), IdentifierName("SetLastSystemError")), ArgumentList(SingletonSeparatedList( Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(SuccessErrorCode))))))); @@ -274,7 +274,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.MarshalEx(options)), + ParseName(TypeNames.System_Runtime_InteropServices_Marshal), IdentifierName("GetLastSystemError"))))); invokeStatement = Block(clearLastError, invokeStatement, getLastError); @@ -326,7 +326,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.MarshalEx(options)), + ParseName(TypeNames.System_Runtime_InteropServices_Marshal), IdentifierName("SetLastPInvokeError")), ArgumentList(SingletonSeparatedList( Argument(IdentifierName(LastErrorIdentifier))))))); 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 07df8f73d0df1..7af1a40c40bcd 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 @@ -2,12 +2,11 @@ Microsoft.Interop.Ancillary - net5.0 + net6.0 8.0 System.Runtime.InteropServices enable true - false diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs index 716dcf28eece6..4260b311ac02c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -7,97 +7,10 @@ namespace System.Runtime.InteropServices /// /// Marshalling helper methods that will likely live in S.R.IS.Marshal /// when we integrate our APIs with dotnet/runtime. + /// When referencing this type in a source-generator, make sure to use + /// the TypeNames.MarshalEx method to enable configuration when dogfooding. /// public static class MarshalEx { - /// - /// Sets the handle of to the specified . - /// - /// instance to update - /// Pre-existing handle - public static void InitHandle(SafeHandle safeHandle, IntPtr handle) - { - typeof(SafeHandle).GetMethod("SetHandle", BindingFlags.NonPublic | BindingFlags.Instance)!.Invoke(safeHandle, new object[] { handle }); - } - - /// - /// Set the last platform invoke error on the thread - /// - public static void SetLastPInvokeError(int error) - { - MethodInfo? method = typeof(Marshal).GetMethod("SetLastWin32Error", BindingFlags.NonPublic | BindingFlags.Static); - if (method == null) - { - method = typeof(Marshal).GetMethod("SetLastPInvokeError", BindingFlags.Public | BindingFlags.Static); - } - - method!.Invoke(null, new object[] { error }); - } - - /// - /// Get the last system error on the current thread (errno on Unix, GetLastError on Windows) - /// - public static unsafe int GetLastSystemError() - { - // Would be internal call that handles getting the last error for the thread using the PAL - - if (OperatingSystem.IsWindows()) - { - return Kernel32.GetLastError(); - } - else if (OperatingSystem.IsMacOS()) - { - return *libc.__error(); - } - else if (OperatingSystem.IsLinux()) - { - return *libc.__errno_location(); - } - - throw new NotImplementedException(); - } - - /// - /// Set the last system error on the current thread (errno on Unix, SetLastError on Windows) - /// - public static unsafe void SetLastSystemError(int error) - { - // Would be internal call that handles setting the last error for the thread using the PAL - - if (OperatingSystem.IsWindows()) - { - Kernel32.SetLastError(error); - } - else if (OperatingSystem.IsMacOS()) - { - *libc.__error() = error; - } - else if (OperatingSystem.IsLinux()) - { - *libc.__errno_location() = error; - } - else - { - throw new NotImplementedException(); - } - } - - private class Kernel32 - { - [DllImport(nameof(Kernel32))] - public static extern void SetLastError(int error); - - [DllImport(nameof(Kernel32))] - public static extern int GetLastError(); - } - - private class libc - { - [DllImport(nameof(libc))] - internal static unsafe extern int* __errno_location(); - - [DllImport(nameof(libc))] - internal static unsafe extern int* __error(); - } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 666f80ffa56b4..4588c962fc817 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -2,7 +2,7 @@ - net5.0 + net6.0 false Preview true diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs index 04542c7f8f487..6d6dca8cb8712 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -18,7 +18,7 @@ public SetLastErrorMarshaller(int i) public int ToManaged() { // Explicity set the last error to something else on unmarshalling - MarshalEx.SetLastPInvokeError(val * 2); + Marshal.SetLastPInvokeError(val * 2); return val; } } @@ -54,12 +54,12 @@ public void LastWin32Error_HasExpectedValue(int error) Assert.Equal(errorString, ret); // Clear the last error - MarshalEx.SetLastPInvokeError(0); + Marshal.SetLastPInvokeError(0); NativeExportsNE.SetLastError.SetError(error, shouldSetError: 1); Assert.Equal(error, Marshal.GetLastWin32Error()); - MarshalEx.SetLastPInvokeError(0); + Marshal.SetLastPInvokeError(0); // Custom marshalling sets the last error on unmarshalling. // Last error should reflect error from native call, not unmarshalling. @@ -71,7 +71,7 @@ public void LastWin32Error_HasExpectedValue(int error) public void ClearPreviousError() { int error = 100; - MarshalEx.SetLastPInvokeError(error); + Marshal.SetLastPInvokeError(error); // Don't actually set the error in the native call. SetLastError=true should clear any existing error. string errorString = error.ToString(); @@ -79,7 +79,7 @@ public void ClearPreviousError() Assert.Equal(0, Marshal.GetLastWin32Error()); Assert.Equal(errorString, ret); - MarshalEx.SetLastPInvokeError(error); + Marshal.SetLastPInvokeError(error); // Don't actually set the error in the native call. SetLastError=true should clear any existing error. NativeExportsNE.SetLastError.SetError(error, shouldSetError: 0); diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index 080e1bae8e96c..7fd03c53f8c10 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 false Preview enable diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index ff7133257cf85..3be5e32aadcf0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis.Testing; using System.Collections.Generic; using System.Collections.Immutable; +using System.IO; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; @@ -71,8 +72,13 @@ public static async Task CreateCompilationWithReferenceAssemblies(s public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() { - // TODO: When .NET 5.0 releases, we can simplify this. - var referenceAssemblies = ReferenceAssemblies.Net.Net50; + // TODO: When .NET 6.0 releases, we can simplify this. + var referenceAssemblies = new ReferenceAssemblies( + "net6.0", + new PackageIdentity( + "Microsoft.NETCore.App.Ref", + "6.0.0-preview.5.21226.5"), + Path.Combine("ref", "net6.0")); // Include the assembly containing the new attribute and all of its references. // [TODO] Remove once the attribute has been added to the BCL diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index b9e61a1a0de0a..84af876234cf0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -2,7 +2,7 @@ Microsoft.Interop.Tests.NativeExports - net5.0 + net6.0 true true true diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj index 692e17b9e0630..d1c676b06d7ee 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 true diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 02bf56ecd0fb3..11805179e79d0 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 true preview enable @@ -10,9 +10,6 @@ true - - - true false From 5a0fc0640b598163dc1526a8289fee9035e9caa2 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 30 Apr 2021 12:20:21 -0700 Subject: [PATCH 076/161] Handle function pointers (dotnet/runtimelab#1043) Commit migrated from https://github.com/dotnet/runtimelab/commit/a33df5c87196361a4a7d13b7d77e440aae5706f8 --- .../Marshalling/MarshallingGenerator.cs | 8 +- .../TypeSymbolExtensions.cs | 5 + .../FunctionPointerTests.cs | 116 ++++++++++++++++++ .../CodeSnippets.cs | 44 +++++-- .../DllImportGenerator.UnitTests/Compiles.cs | 17 ++- ...onvertToGeneratedDllImportAnalyzerTests.cs | 3 +- .../DelegatesAndFunctionPointers.cs | 11 +- 7 files changed, 181 insertions(+), 23 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 9982ab0afb873..e9d81561b75a3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -196,8 +196,8 @@ private static IMarshallingGenerator CreateCore( or { ManagedType: { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U4, _) } or { ManagedType: { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I8, _) } or { ManagedType: { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U8, _) } - or { ManagedType: { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo } - or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo } + or { ManagedType: { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysInt, _) } + or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysUInt, _) } or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: return Blittable; @@ -216,6 +216,10 @@ private static IMarshallingGenerator CreateCore( case { ManagedType: { TypeKind: TypeKind.Pointer }, MarshallingAttributeInfo: NoMarshallingInfo }: return Blittable; + // Function pointer with no marshalling info + case { ManagedType: { TypeKind: TypeKind.FunctionPointer }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: + return Blittable; + case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index f12bbe46ee19a..745f861f61019 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -69,6 +69,11 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) return IsSpecialTypeBlittable(type.SpecialType); } + if (type.TypeKind == TypeKind.FunctionPointer) + { + return true; + } + if (!type.IsValueType || type.IsReferenceType) { return false; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs new file mode 100644 index 0000000000000..9de487153f724 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs @@ -0,0 +1,116 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public partial class FunctionPointer + { + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + public static unsafe partial void InvokeAfterGC(delegate* cb); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + public static unsafe partial void InvokeAfterGC(delegate* unmanaged cb); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + public static unsafe partial void InvokeAfterGC(delegate* unmanaged[Stdcall] cb); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + public static unsafe partial int InvokeWithBlittableArgument(delegate* cb, int a, int b); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + public static unsafe partial int InvokeWithBlittableArgument(delegate* unmanaged cb, int a, int b); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + public static unsafe partial int InvokeWithBlittableArgument(delegate* unmanaged[Stdcall] cb, int a, int b); + } + } + + public class FunctionPointerTests + { + private static bool wasCalled; + + [Fact] + public unsafe void InvokedAfterGC() + { + wasCalled = false; + NativeExportsNE.FunctionPointer.InvokeAfterGC(&Callback); + Assert.True(wasCalled); + + wasCalled = false; + NativeExportsNE.FunctionPointer.InvokeAfterGC(&CallbackUnmanaged); + Assert.True(wasCalled); + + wasCalled = false; + NativeExportsNE.FunctionPointer.InvokeAfterGC(&CallbackUnmanagedStdcall); + Assert.True(wasCalled); + + static void Callback() + { + wasCalled = true; + } + + [UnmanagedCallersOnly] + static void CallbackUnmanaged() + { + wasCalled = true; + } + + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvStdcall) })] + static void CallbackUnmanagedStdcall() + { + wasCalled = true; + } + } + + [Fact] + public unsafe void CalledWithArgumentsInOrder() + { + const int a = 100; + const int b = 50; + int result; + + int expected = Callback(a, b); + result = NativeExportsNE.FunctionPointer.InvokeWithBlittableArgument(&Callback, a, b); + Assert.Equal(expected, result); + + result = NativeExportsNE.FunctionPointer.InvokeWithBlittableArgument(&CallbackUnmanaged, a, b); + Assert.Equal(expected, result); + + result = NativeExportsNE.FunctionPointer.InvokeWithBlittableArgument(&CallbackUnmanagedStdcall, a, b); + Assert.Equal(expected, result); + + expected = Callback(b, a); + result = NativeExportsNE.FunctionPointer.InvokeWithBlittableArgument(&Callback, b, a); + Assert.Equal(expected, result); + + result = NativeExportsNE.FunctionPointer.InvokeWithBlittableArgument(&CallbackUnmanaged, b, a); + Assert.Equal(expected, result); + + result = NativeExportsNE.FunctionPointer.InvokeWithBlittableArgument(&CallbackUnmanagedStdcall, b, a); + Assert.Equal(expected, result); + + static int Callback(int a, int b) + { + // Use a noncommutative operation to validate passed in order. + return a - b; + } + + [UnmanagedCallersOnly] + static int CallbackUnmanaged(int a, int b) + { + return Callback(a, b); + } + + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvStdcall) })] + static int CallbackUnmanagedStdcall(int a, int b) + { + return Callback(a, b); + } + } + } +} 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 76443d06f7ce8..8d630f9c2b62f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -365,6 +365,21 @@ partial class Test out {typeName} pOut); }}"; + /// + /// Declaration with parameters and unsafe. + /// + public static string BasicParametersAndModifiersUnsafe(string typeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static unsafe partial {typeName} Method( + {typeName} p, + in {typeName} pIn, + ref {typeName} pRef, + out {typeName} pOut); +}}"; + public static string BasicParametersAndModifiers() => BasicParametersAndModifiers(typeof(T).ToString()); /// @@ -396,6 +411,23 @@ partial class Test [MarshalAs(UnmanagedType.{unmanagedType})] ref {typeName} pRef, [MarshalAs(UnmanagedType.{unmanagedType})] out {typeName} pOut); }} +"; + + /// + /// Declaration with parameters with MarshalAs. + /// + public static string MarshalAsParametersAndModifiersUnsafe(string typeName, UnmanagedType unmanagedType) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + [return: MarshalAs(UnmanagedType.{unmanagedType})] + public static unsafe partial {typeName} Method( + [MarshalAs(UnmanagedType.{unmanagedType})] {typeName} p, + [MarshalAs(UnmanagedType.{unmanagedType})] in {typeName} pIn, + [MarshalAs(UnmanagedType.{unmanagedType})] ref {typeName} pRef, + [MarshalAs(UnmanagedType.{unmanagedType})] out {typeName} pOut); +}} "; public static string MarshalAsParametersAndModifiers(UnmanagedType unmanagedType) => MarshalAsParametersAndModifiers(typeof(T).ToString(), unmanagedType); @@ -425,17 +457,7 @@ public static partial MyEnum Method( /// /// Declaration with pointer parameters. /// - public static string PointerParameters() => @$" -using System.Runtime.InteropServices; -partial class Test -{{ - [GeneratedDllImport(""DoesNotExist"")] - public static unsafe partial {typeof(T)}* Method( - {typeof(T)}* p, - in {typeof(T)}* pIn, - ref {typeof(T)}* pRef, - out {typeof(T)}* pOut); -}}"; + public static string PointerParameters() => BasicParametersAndModifiersUnsafe($"{typeof(T)}*"); /// /// Declaration with PreserveSig = false. 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 dd931758c857d..60d61de1d0b58 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -83,6 +83,8 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I1) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.I2) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.U2) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.SysInt) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.SysUInt) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPWStr) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPTStr) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPUTF8Str) }; @@ -113,11 +115,20 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.PointerParameters() }; yield return new[] { CodeSnippets.PointerParameters() }; yield return new[] { CodeSnippets.PointerParameters() }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersUnsafe("void*") }; // Delegates yield return new[] { CodeSnippets.DelegateParametersAndModifiers }; yield return new[] { CodeSnippets.DelegateMarshalAsParametersAndModifiers }; + // Function pointers + yield return new[] { CodeSnippets.BasicParametersAndModifiersUnsafe("delegate* ") }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersUnsafe("delegate* unmanaged") }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersUnsafe("delegate* unmanaged") }; + yield return new[] { CodeSnippets.BasicParametersAndModifiersUnsafe("delegate* unmanaged[Stdcall]") }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiersUnsafe("delegate* ", UnmanagedType.FunctionPtr) }; + yield return new[] { CodeSnippets.MarshalAsParametersAndModifiersUnsafe("delegate* unmanaged", UnmanagedType.FunctionPtr) }; + // Structs yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; @@ -208,12 +219,12 @@ public async Task ValidateSnippetsWithPreprocessorDefintions(string source, IEnu var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); } - + public static IEnumerable CodeSnippetsToCompileWithForwarder() { yield return new[] { CodeSnippets.UserDefinedEntryPoint }; yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; - + // Parameter / return types (supported in DllImportGenerator) yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; // Parameter / return types (not supported in DllImportGenerator) @@ -243,7 +254,7 @@ public static IEnumerable CodeSnippetsToCompileWithMarshalType() { // SetLastError yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; - + // SafeHandle yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs index fe7824b312256..2f7b0efc79615 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs @@ -28,6 +28,7 @@ public static IEnumerable NoMarshallingRequiredTypes() => new[] new object[] { typeof(int*) }, new object[] { typeof(bool*) }, new object[] { typeof(char*) }, + new object[] { typeof(delegate* ) }, new object[] { typeof(IntPtr) }, new object[] { typeof(ConsoleKey) }, // enum }; @@ -156,4 +157,4 @@ unsafe partial class Test }} "; } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs index 9aa19952ea31c..16fc451c9de89 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs @@ -10,12 +10,11 @@ public static void InvokeCallbackAfterGCCollect(delegate* unmanaged fptr) { // We are at the mercy of the GC to verify our delegate has been retain // across the native function call. This is a best effort validation. - GC.Collect(); - GC.Collect(); - GC.Collect(); - GC.Collect(); - GC.Collect(); - GC.WaitForPendingFinalizers(); + for (int i = 0; i < 5; ++i) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + } // If the corresponding Delegate was collected, the runtime will rudely abort. fptr(); From a4e42796c1acde40e5681d069be8213098c85413 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Tue, 4 May 2021 00:34:07 +0600 Subject: [PATCH 077/161] Fix link (dotnet/runtimelab#1065) Commit migrated from https://github.com/dotnet/runtimelab/commit/2fdea5e3a52219e6a5d200a96589a196067b7eb5 --- docs/design/libraries/DllImportGenerator/Pipeline.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/libraries/DllImportGenerator/Pipeline.md b/docs/design/libraries/DllImportGenerator/Pipeline.md index d9e4acb0b758a..c32f0fdee8819 100644 --- a/docs/design/libraries/DllImportGenerator/Pipeline.md +++ b/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -5,7 +5,7 @@ The P/Invoke source generator is responsible for finding all methods marked with 1. [Process the symbols and metadata](#symbols-and-metadata-processing) for the method, its parameters, and its return type. 1. [Determine the marshalling generators](#marshalling-generators) that will be responsible for generating the stub code for each parameter and return 1. [Generate the stub code](#stub-code-generation) -1. [Generate the corresponding P/Invoke](#p/invoke) +1. [Generate the corresponding P/Invoke](#pinvoke) 1. Add the generated source to the compilation. The pipeline uses the Roslyn [Syntax APIs](https://docs.microsoft.com/dotnet/api/microsoft.codeanalysis.csharp.syntax) to create the generated code. This imposes some structure for the marshalling generators and allows for easier inspection or modification (if desired) of the generated code. From 1e3f71c9487373da9b83e248c82c7e4dbc6c77b1 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 3 May 2021 20:23:37 -0700 Subject: [PATCH 078/161] Add support for null arrays in the blittable array marshaller's pinning optimization. (dotnet/runtimelab#1063) * Add support for null arrays in the blittable array marshaller's pinning optimization. * Add comment block about the behavior. * Use pointer casting instead of Unsafe.NullRef since we are already using pointers. Commit migrated from https://github.com/dotnet/runtimelab/commit/c436fda400ce8b6bc374a69f53d02091d8e968f3 --- .../Marshalling/BlittableArrayMarshaller.cs | 53 ++++++++++++++++--- .../gen/DllImportGenerator/TypeNames.cs | 2 +- .../DllImportGenerator.Tests/ArrayTests.cs | 8 ++- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs index 8e7291f9158b3..cd42a96d83245 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs @@ -56,21 +56,58 @@ public override IEnumerable Generate(TypePositionInfo info, Stu var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); if (!info.IsByRef && !info.IsManagedReturnPosition && context.PinningSupported) { + string byRefIdentifier = $"__byref_{managedIdentifer}"; + if (context.CurrentStage == StubCodeContext.Stage.Marshal) + { + // [COMPAT] We use explicit byref calculations here instead of just using a fixed statement + // since a fixed statement converts a zero-length array to a null pointer. + // Many native APIs, such as GDI+, ICU, etc. validate that an array parameter is non-null + // even when the passed in array length is zero. To avoid breaking customers that want to move + // to source-generated interop in subtle ways, we explicitly pass a reference to the 0-th element + // of an array as long as it is non-null, matching the behavior of the built-in interop system + // for single-dimensional zero-based arrays. + + // ref = == null ? ref *(); + var nullRef = + PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, + CastExpression( + PointerType(GetElementTypeSyntax(info)), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))); + + var getArrayDataReference = + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), + IdentifierName("GetArrayDataReference")), + ArgumentList(SingletonSeparatedList( + Argument(IdentifierName(managedIdentifer))))); + + yield return LocalDeclarationStatement( + VariableDeclaration( + RefType(GetElementTypeSyntax(info))) + .WithVariables(SingletonSeparatedList( + VariableDeclarator(Identifier(byRefIdentifier)) + .WithInitializer(EqualsValueClause( + RefExpression(ParenthesizedExpression( + ConditionalExpression( + BinaryExpression( + SyntaxKind.EqualsExpression, + IdentifierName(managedIdentifer), + LiteralExpression( + SyntaxKind.NullLiteralExpression)), + RefExpression(nullRef), + RefExpression(getArrayDataReference))))))))); + } if (context.CurrentStage == StubCodeContext.Stage.Pin) { - // fixed ( = &MemoryMarshal.GetArrayDataReference()) + // fixed ( = &) yield return FixedStatement( VariableDeclaration(AsNativeType(info), SingletonSeparatedList( VariableDeclarator(nativeIdentifier) .WithInitializer(EqualsValueClause( PrefixUnaryExpression(SyntaxKind.AddressOfExpression, - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), - IdentifierName("GetArrayDataReference")), - ArgumentList( - SingletonSeparatedList(Argument(IdentifierName(managedIdentifer))) - ))))))), + IdentifierName(byRefIdentifier)))))), EmptyStatement()); } yield break; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 457a4db0386a5..509969a052306 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -44,7 +44,7 @@ public static string MarshalEx(AnalyzerConfigOptions options) public const string System_Runtime_InteropServices_OutAttribute = "System.Runtime.InteropServices.OutAttribute"; public const string System_Runtime_InteropServices_InAttribute = "System.Runtime.InteropServices.InAttribute"; - + public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; } } 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 d535c13d7691c..0a5b67328152c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -67,10 +67,16 @@ public class ArrayTests [Fact] public void IntArrayMarshalledToNativeAsExpected() { - var array = new [] { 1, 5, 79, 165, 32, 3 }; + var array = new[] { 1, 5, 79, 165, 32, 3 }; Assert.Equal(array.Sum(), NativeExportsNE.Arrays.Sum(array, array.Length)); } + [Fact] + public void NullIntArrayMarshalledToNativeAsExpected() + { + Assert.Equal(-1, NativeExportsNE.Arrays.Sum(null, 0)); + } + [Fact] public void ZeroLengthArrayMarshalledAsNonNull() { From bdd2d21aa62810573c8bb206756af4330336b5f2 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 4 May 2021 19:41:05 -0700 Subject: [PATCH 079/161] Add support for abstract SafeHandle types for by-value marshalling. (dotnet/runtimelab#1066) * Add support for abstract SafeHandle types for by-value marshalling. * Add test for byref abstract SafeHandle. * Add abstract by-ref test. Add details for failure case. Commit migrated from https://github.com/dotnet/runtimelab/commit/a406e64e53db09de69f6125b2c7d4e2311b7120d --- .../Marshalling/MarshallingGenerator.cs | 7 +++++++ .../gen/DllImportGenerator/Resources.Designer.cs | 9 +++++++++ .../gen/DllImportGenerator/Resources.resx | 3 +++ .../gen/DllImportGenerator/TypePositionInfo.cs | 5 ++--- .../tests/DllImportGenerator.UnitTests/CodeSnippets.cs | 9 +++++++++ .../tests/DllImportGenerator.UnitTests/CompileFails.cs | 3 +++ .../tests/DllImportGenerator.UnitTests/Compiles.cs | 1 + 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index e9d81561b75a3..c8f13da707c3f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -237,6 +237,13 @@ private static IMarshallingGenerator CreateCore( { throw new MarshallingNotSupportedException(info, context); } + if (info.IsByRef && info.ManagedType.IsAbstract) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.SafeHandleByRefMustBeConcrete + }; + } return new SafeHandleMarshaller(options); // Marshalling in new model. 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 e86940b256c65..87fac1a3e0ffa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -483,6 +483,15 @@ internal static string RefValuePropertyUnsupportedMessage { } } + /// + /// Looks up a localized string similar to An abstract type derived from 'SafeHandle' cannot be marshalled by reference. The provided type must be concrete.. + /// + internal static string SafeHandleByRefMustBeConcrete { + get { + return ResourceManager.GetString("SafeHandleByRefMustBeConcrete", resourceCulture); + } + } + /// /// Looks up a localized string similar to When constructor taking a Span<byte> is specified on the native type, the type must also have a public integer constant named StackBufferSize to provide the size of the stack-allocated buffer.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index c6a5491493395..f66d2945ad7a8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -259,6 +259,9 @@ The 'Value' property on the native type '{0}' must not be a 'ref' or 'readonly ref' property. + + An abstract type derived from 'SafeHandle' cannot be marshalled by reference. The provided type must be concrete. + When constructor taking a Span<byte> is specified on the native type, the type must also have a public integer constant named StackBufferSize to provide the size of the stack-allocated buffer. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 9cb216590cc03..0a5d4c921b22d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -312,11 +312,10 @@ static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshalli var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); if (conversion.Exists && conversion.IsImplicit - && conversion.IsReference - && !type.IsAbstract) + && (conversion.IsReference || conversion.IsIdentity)) { bool hasAccessibleDefaultConstructor = false; - if (type is INamedTypeSymbol named && named.InstanceConstructors.Length > 0) + if (type is INamedTypeSymbol named && !named.IsAbstract && named.InstanceConstructors.Length > 0) { foreach (var ctor in named.InstanceConstructors) { 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 8d630f9c2b62f..eb4cc83858fee 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -843,6 +843,15 @@ public static partial void Method( {byRefKind} {typeName} p); }}"; + public static string BasicParameterByValue(string typeName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + {typeName} p); +}}"; + public static string BasicReturnType(string typeName) => @$" using System.Runtime.InteropServices; partial class Test 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 61f98f45fff8d..89622d1cdf233 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -92,6 +92,9 @@ public static IEnumerable CodeSnippetsToCompile() // Custom type marshalling in arrays (complex case with Value property) yield return new object[] { CodeSnippets.ArrayMarshallingWithCustomStructElementWithValueProperty, 5, 0 }; + + // Abstract SafeHandle type by reference + yield return new object[] { CodeSnippets.BasicParameterWithByRefModifier("ref", "System.Runtime.InteropServices.SafeHandle"), 1, 0 }; } [Theory] 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 60d61de1d0b58..c9da24ff41a48 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -135,6 +135,7 @@ public static IEnumerable CodeSnippetsToCompile() // SafeHandle yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + yield return new[] { CodeSnippets.BasicParameterByValue("System.Runtime.InteropServices.SafeHandle") }; yield return new[] { CodeSnippets.SafeHandleWithCustomDefaultConstructorAccessibility(privateCtor: false) }; yield return new[] { CodeSnippets.SafeHandleWithCustomDefaultConstructorAccessibility(privateCtor: true) }; From 83a0fe2157104740ffd8795a3249f6018e088005 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 6 May 2021 11:27:09 -0700 Subject: [PATCH 080/161] Disable the test for the Marshal switch now that it currently is a no-op. I've disabled the test so that we can re-enable it if we end up adding more APIs to the MarshalEx surface. (dotnet/runtimelab#1082) Commit migrated from https://github.com/dotnet/runtimelab/commit/b7688d5d93b35256521b2460c5b6fcdc256bd3bb --- .../tests/DllImportGenerator.UnitTests/Compiles.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 c9da24ff41a48..e5c3ccf8f1876 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -253,14 +253,10 @@ public async Task ValidateSnippetsWithForwarder(string source) public static IEnumerable CodeSnippetsToCompileWithMarshalType() { - // SetLastError - yield return new[] { CodeSnippets.AllSupportedDllImportNamedArguments }; - - // SafeHandle - yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; + yield break; } - [Theory] + [Theory(Skip = "No current scenarios to test.")] [MemberData(nameof(CodeSnippetsToCompileWithMarshalType))] public async Task ValidateSnippetsWithMarshalType(string source) { From 4dc5101efdeba0d701b6e22f582fc2b6a4f9e229 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 May 2021 10:10:02 -0700 Subject: [PATCH 081/161] Keep target DllImport info in structured data before converting to syntax. (dotnet/runtimelab#1075) Commit migrated from https://github.com/dotnet/runtimelab/commit/2f89e87e872378f5fafe907a6e288d9f1784e55a --- .../DllImportGenerator/DllImportGenerator.cs | 213 +++++++++++------- .../gen/DllImportGenerator/DllImportStub.cs | 1 + 2 files changed, 129 insertions(+), 85 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 0a342621345f1..678570f1d6449 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -93,16 +93,16 @@ public void Execute(GeneratorExecutionContext context) continue; // Process the GeneratedDllImport attribute - DllImportStub.GeneratedDllImportData dllImportData; - AttributeSyntax dllImportAttr = this.ProcessGeneratedDllImportAttribute(methodSymbolInfo, generatedDllImportAttr, context.AnalyzerConfigOptions.GlobalOptions.GenerateForwarders(), out dllImportData); - Debug.Assert((dllImportAttr is not null) && (dllImportData is not null)); + DllImportStub.GeneratedDllImportData stubDllImportData = this.ProcessGeneratedDllImportAttribute(generatedDllImportAttr); + Debug.Assert(stubDllImportData is not null); + AttributeSyntax dllImportAttr = this.CreateDllImportAttributeForTarget(stubDllImportData!, env.Options.GenerateForwarders(), methodSymbolInfo.Name); - if (dllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) + if (stubDllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) { generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.BestFitMapping)); } - if (dllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) + if (stubDllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) { generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar)); } @@ -114,7 +114,7 @@ public void Execute(GeneratorExecutionContext context) } // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, dllImportData!, env, generatorDiagnostics, context.CancellationToken); + var dllImportStub = DllImportStub.Create(methodSymbolInfo, stubDllImportData!, env, generatorDiagnostics, context.CancellationToken); PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub, dllImportAttr!); } @@ -229,13 +229,9 @@ private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMayb || attrName.EndsWith(PrefixedGeneratedDllImportAttribute); } - private AttributeSyntax ProcessGeneratedDllImportAttribute( - IMethodSymbol method, - AttributeData attrData, - bool generateForwarders, - out DllImportStub.GeneratedDllImportData dllImportData) + private DllImportStub.GeneratedDllImportData ProcessGeneratedDllImportAttribute(AttributeData attrData) { - dllImportData = new DllImportStub.GeneratedDllImportData(); + var stubDllImportData = new DllImportStub.GeneratedDllImportData(); // Found the GeneratedDllImport, but it has an error so report the error. // This is most likely an issue with targeting an incorrect TFM. @@ -245,101 +241,122 @@ private AttributeSyntax ProcessGeneratedDllImportAttribute( throw new InvalidProgramException(); } - var newAttributeArgs = new List(); - // Populate the DllImport data from the GeneratedDllImportAttribute attribute. - dllImportData.ModuleName = attrData.ConstructorArguments[0].Value!.ToString(); - - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(SyntaxFactory.LiteralExpression( - SyntaxKind.StringLiteralExpression, - SyntaxFactory.Literal(dllImportData.ModuleName)))); + stubDllImportData.ModuleName = attrData.ConstructorArguments[0].Value!.ToString(); // All other data on attribute is defined as NamedArguments. foreach (var namedArg in attrData.NamedArguments) { - ExpressionSyntax? expSyntaxMaybe = null; switch (namedArg.Key) { default: Debug.Fail($"An unknown member was found on {GeneratedDllImport}"); continue; case nameof(DllImportStub.GeneratedDllImportData.BestFitMapping): - dllImportData.BestFitMapping = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.BestFitMapping); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.BestFitMapping; + stubDllImportData.BestFitMapping = (bool)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.BestFitMapping; break; case nameof(DllImportStub.GeneratedDllImportData.CallingConvention): - dllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value!; - expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CallingConvention); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CallingConvention; + stubDllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.CallingConvention; break; case nameof(DllImportStub.GeneratedDllImportData.CharSet): - dllImportData.CharSet = (CharSet)namedArg.Value.Value!; - expSyntaxMaybe = CreateEnumExpressionSyntax(dllImportData.CharSet); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.CharSet; + stubDllImportData.CharSet = (CharSet)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.CharSet; break; case nameof(DllImportStub.GeneratedDllImportData.EntryPoint): - dllImportData.EntryPoint = (string)namedArg.Value.Value!; - expSyntaxMaybe = CreateStringExpressionSyntax(dllImportData.EntryPoint!); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.EntryPoint; + stubDllImportData.EntryPoint = (string)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.EntryPoint; break; case nameof(DllImportStub.GeneratedDllImportData.ExactSpelling): - dllImportData.ExactSpelling = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ExactSpelling); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ExactSpelling; + stubDllImportData.ExactSpelling = (bool)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.ExactSpelling; break; case nameof(DllImportStub.GeneratedDllImportData.PreserveSig): - dllImportData.PreserveSig = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.PreserveSig); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.PreserveSig; + stubDllImportData.PreserveSig = (bool)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.PreserveSig; break; case nameof(DllImportStub.GeneratedDllImportData.SetLastError): - dllImportData.SetLastError = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.SetLastError); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.SetLastError; + stubDllImportData.SetLastError = (bool)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.SetLastError; break; case nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar): - dllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value!; - expSyntaxMaybe = CreateBoolExpressionSyntax(dllImportData.ThrowOnUnmappableChar); - dllImportData.IsUserDefined |= DllImportStub.DllImportMember.ThrowOnUnmappableChar; + stubDllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value!; + stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.ThrowOnUnmappableChar; break; } + } - Debug.Assert(expSyntaxMaybe is not null); + return stubDllImportData; + } - // If we're generating a forwarder stub, then all parameters on the GenerateDllImport attribute - // must also be added to the generated DllImport attribute. - if (generateForwarders || PassThroughToDllImportAttribute(namedArg.Key)) - { - // Defer the name equals syntax till we know the value means something. If we created - // an expression we know the key value was valid. - NameEqualsSyntax nameSyntax = SyntaxFactory.NameEquals(namedArg.Key); - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(nameSyntax, null, expSyntaxMaybe!)); - } - } + private AttributeSyntax CreateDllImportAttributeForTarget(DllImportStub.GeneratedDllImportData stubDllImportData, bool generateForwarders, string originalMethodName) + { + DllImportStub.GeneratedDllImportData targetDllImportData = + GetTargetDllImportDataFromStubData(stubDllImportData, generateForwarders, originalMethodName); - // If the EntryPoint property is not set, we will compute and - // add it based on existing semantics (i.e. method name). - // - // N.B. The export discovery logic is identical regardless of where - // the name is defined (i.e. method name vs EntryPoint property). - if (!dllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) + var newAttributeArgs = new List { - var entryPointName = SyntaxFactory.NameEquals(nameof(DllImportAttribute.EntryPoint)); + AttributeArgument(LiteralExpression( + SyntaxKind.StringLiteralExpression, + Literal(targetDllImportData.ModuleName))), + AttributeArgument( + NameEquals(nameof(DllImportAttribute.EntryPoint)), + null, + CreateStringExpressionSyntax(targetDllImportData.EntryPoint)) + }; - // The name of the method is the entry point name to use. - var entryPointValue = CreateStringExpressionSyntax(method.Name); - newAttributeArgs.Add(SyntaxFactory.AttributeArgument(entryPointName, null, entryPointValue)); + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) + { + var name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); + var value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CallingConvention)) + { + var name = NameEquals(nameof(DllImportAttribute.CallingConvention)); + var value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CharSet)) + { + var name = NameEquals(nameof(DllImportAttribute.CharSet)); + var value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ExactSpelling)) + { + var name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); + var value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.PreserveSig)) + { + var name = NameEquals(nameof(DllImportAttribute.PreserveSig)); + var value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.SetLastError)) + { + var name = NameEquals(nameof(DllImportAttribute.SetLastError)); + var value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) + { + var name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); + var value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); + newAttributeArgs.Add(AttributeArgument(name, null, value)); } // Create new attribute - return SyntaxFactory.Attribute( - SyntaxFactory.ParseName(typeof(DllImportAttribute).FullName), - SyntaxFactory.AttributeArgumentList(SyntaxFactory.SeparatedList(newAttributeArgs))); + return Attribute( + ParseName(typeof(DllImportAttribute).FullName), + AttributeArgumentList(SeparatedList(newAttributeArgs))); static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) { - return SyntaxFactory.LiteralExpression( + return LiteralExpression( trueOrFalse ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression); @@ -347,36 +364,62 @@ static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) static ExpressionSyntax CreateStringExpressionSyntax(string str) { - return SyntaxFactory.LiteralExpression( + return LiteralExpression( SyntaxKind.StringLiteralExpression, - SyntaxFactory.Literal(str)); + Literal(str)); } static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum { - return SyntaxFactory.MemberAccessExpression( + return MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - SyntaxFactory.IdentifierName(typeof(T).FullName), - SyntaxFactory.IdentifierName(value.ToString())); + IdentifierName(typeof(T).FullName), + IdentifierName(value.ToString())); } - static bool PassThroughToDllImportAttribute(string argName) + static DllImportStub.GeneratedDllImportData GetTargetDllImportDataFromStubData(DllImportStub.GeneratedDllImportData stubDllImportData, bool generateForwarders, string originalMethodName) { - // Certain fields on DllImport will prevent inlining. Their functionality should be handled by the - // generated source, so the generated DllImport declaration should not include these fields. - return argName switch + DllImportStub.DllImportMember membersToForward = DllImportStub.DllImportMember.All + // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig + // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. + & ~DllImportStub.DllImportMember.PreserveSig + // 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. + & ~DllImportStub.DllImportMember.SetLastError; + if (generateForwarders) { - // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig - // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. - nameof(DllImportStub.GeneratedDllImportData.PreserveSig) => false, - // 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. - nameof(DllImportStub.GeneratedDllImportData.SetLastError) => false, - _ => true + membersToForward = DllImportStub.DllImportMember.All; + } + + var targetDllImportData = new DllImportStub.GeneratedDllImportData + { + CharSet = stubDllImportData.CharSet, + BestFitMapping = stubDllImportData.BestFitMapping, + CallingConvention = stubDllImportData.CallingConvention, + EntryPoint = stubDllImportData.EntryPoint, + ModuleName = stubDllImportData.ModuleName, + ExactSpelling = stubDllImportData.ExactSpelling, + SetLastError = stubDllImportData.SetLastError, + PreserveSig = stubDllImportData.PreserveSig, + ThrowOnUnmappableChar = stubDllImportData.ThrowOnUnmappableChar, + IsUserDefined = stubDllImportData.IsUserDefined & membersToForward }; + + // If the EntryPoint property is not set, we will compute and + // add it based on existing semantics (i.e. method name). + // + // N.B. The export discovery logic is identical regardless of where + // the name is defined (i.e. method name vs EntryPoint property). + if (!targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) + { + targetDllImportData.EntryPoint = originalMethodName; + } + + return targetDllImportData; } } + private class SyntaxReceiver : ISyntaxReceiver { public ICollection Methods { get; } = new List(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 85ac9bef9b577..264b3aaf5090f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -75,6 +75,7 @@ public enum DllImportMember PreserveSig = 1 << 5, SetLastError = 1 << 6, ThrowOnUnmappableChar = 1 << 7, + All = ~None } /// From 7cd59c478f497b01a79a1a78408fa02c6fb7f110 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Sat, 8 May 2021 09:31:07 -0700 Subject: [PATCH 082/161] Make DllImport target function local. (dotnet/runtimelab#1090) Commit migrated from https://github.com/dotnet/runtimelab/commit/b8c7d30a556400cc6f5d6f3616863e16086a33a4 --- .../DllImportGenerator/DllImportGenerator.cs | 142 +----------------- .../gen/DllImportGenerator/DllImportStub.cs | 5 +- .../DllImportGenerator/StubCodeGenerator.cs | 140 ++++++++++++++++- .../DllImportGenerator.Tests/ArrayTests.cs | 10 ++ .../DllImportGenerator.UnitTests/Compiles.cs | 21 +++ .../DllImportGenerator.UnitTests/TestUtils.cs | 18 +++ 6 files changed, 187 insertions(+), 149 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 678570f1d6449..c1f94784456d9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -95,7 +95,6 @@ public void Execute(GeneratorExecutionContext context) // Process the GeneratedDllImport attribute DllImportStub.GeneratedDllImportData stubDllImportData = this.ProcessGeneratedDllImportAttribute(generatedDllImportAttr); Debug.Assert(stubDllImportData is not null); - AttributeSyntax dllImportAttr = this.CreateDllImportAttributeForTarget(stubDllImportData!, env.Options.GenerateForwarders(), methodSymbolInfo.Name); if (stubDllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) { @@ -116,7 +115,7 @@ public void Execute(GeneratorExecutionContext context) // Create the stub. var dllImportStub = DllImportStub.Create(methodSymbolInfo, stubDllImportData!, env, generatorDiagnostics, context.CancellationToken); - PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub, dllImportAttr!); + PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub); } Debug.WriteLine(generatedDllImports.ToString()); // [TODO] Find some way to emit this for debugging - logs? @@ -150,8 +149,7 @@ private TypeDeclarationSyntax CreateTypeDeclarationWithoutTrivia(TypeDeclaration private void PrintGeneratedSource( StringBuilder builder, MethodDeclarationSyntax userDeclaredMethod, - DllImportStub stub, - AttributeSyntax dllImportAttr) + DllImportStub stub) { // Create stub function var stubMethod = MethodDeclaration(stub.StubReturnType, userDeclaredMethod.Identifier) @@ -160,17 +158,12 @@ private void PrintGeneratedSource( .WithParameterList(ParameterList(SeparatedList(stub.StubParameters))) .WithBody(stub.StubCode); - // Create the DllImport declaration. - var dllImport = stub.DllImportDeclaration.AddAttributeLists( - AttributeList( - SingletonSeparatedList(dllImportAttr))); - // Stub should have at least one containing type Debug.Assert(stub.StubContainingTypes.Any()); // Add stub function and DllImport declaration to the first (innermost) containing MemberDeclarationSyntax containingType = CreateTypeDeclarationWithoutTrivia(stub.StubContainingTypes.First()) - .AddMembers(stubMethod, dllImport); + .AddMembers(stubMethod); // Add type to the remaining containing types (skipping the first which was handled above) foreach (var typeDecl in stub.StubContainingTypes.Skip(1)) @@ -290,135 +283,6 @@ private DllImportStub.GeneratedDllImportData ProcessGeneratedDllImportAttribute( return stubDllImportData; } - private AttributeSyntax CreateDllImportAttributeForTarget(DllImportStub.GeneratedDllImportData stubDllImportData, bool generateForwarders, string originalMethodName) - { - DllImportStub.GeneratedDllImportData targetDllImportData = - GetTargetDllImportDataFromStubData(stubDllImportData, generateForwarders, originalMethodName); - - var newAttributeArgs = new List - { - AttributeArgument(LiteralExpression( - SyntaxKind.StringLiteralExpression, - Literal(targetDllImportData.ModuleName))), - AttributeArgument( - NameEquals(nameof(DllImportAttribute.EntryPoint)), - null, - CreateStringExpressionSyntax(targetDllImportData.EntryPoint)) - }; - - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) - { - var name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); - var value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CallingConvention)) - { - var name = NameEquals(nameof(DllImportAttribute.CallingConvention)); - var value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CharSet)) - { - var name = NameEquals(nameof(DllImportAttribute.CharSet)); - var value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ExactSpelling)) - { - var name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); - var value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.PreserveSig)) - { - var name = NameEquals(nameof(DllImportAttribute.PreserveSig)); - var value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.SetLastError)) - { - var name = NameEquals(nameof(DllImportAttribute.SetLastError)); - var value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) - { - var name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); - var value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - - // Create new attribute - return Attribute( - ParseName(typeof(DllImportAttribute).FullName), - AttributeArgumentList(SeparatedList(newAttributeArgs))); - - static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) - { - return LiteralExpression( - trueOrFalse - ? SyntaxKind.TrueLiteralExpression - : SyntaxKind.FalseLiteralExpression); - } - - static ExpressionSyntax CreateStringExpressionSyntax(string str) - { - return LiteralExpression( - SyntaxKind.StringLiteralExpression, - Literal(str)); - } - - static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum - { - return MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(typeof(T).FullName), - IdentifierName(value.ToString())); - } - - static DllImportStub.GeneratedDllImportData GetTargetDllImportDataFromStubData(DllImportStub.GeneratedDllImportData stubDllImportData, bool generateForwarders, string originalMethodName) - { - DllImportStub.DllImportMember membersToForward = DllImportStub.DllImportMember.All - // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig - // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. - & ~DllImportStub.DllImportMember.PreserveSig - // 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. - & ~DllImportStub.DllImportMember.SetLastError; - if (generateForwarders) - { - membersToForward = DllImportStub.DllImportMember.All; - } - - var targetDllImportData = new DllImportStub.GeneratedDllImportData - { - CharSet = stubDllImportData.CharSet, - BestFitMapping = stubDllImportData.BestFitMapping, - CallingConvention = stubDllImportData.CallingConvention, - EntryPoint = stubDllImportData.EntryPoint, - ModuleName = stubDllImportData.ModuleName, - ExactSpelling = stubDllImportData.ExactSpelling, - SetLastError = stubDllImportData.SetLastError, - PreserveSig = stubDllImportData.PreserveSig, - ThrowOnUnmappableChar = stubDllImportData.ThrowOnUnmappableChar, - IsUserDefined = stubDllImportData.IsUserDefined & membersToForward - }; - - // If the EntryPoint property is not set, we will compute and - // add it based on existing semantics (i.e. method name). - // - // N.B. The export discovery logic is identical regardless of where - // the name is defined (i.e. method name vs EntryPoint property). - if (!targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) - { - targetDllImportData.EntryPoint = originalMethodName; - } - - return targetDllImportData; - } - } - private class SyntaxReceiver : ISyntaxReceiver { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index 264b3aaf5090f..cff9d7f41d83f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -56,8 +56,6 @@ public IEnumerable StubParameters public BlockSyntax StubCode { get; init; } - public MethodDeclarationSyntax DllImportDeclaration { get; init; } - public AttributeListSyntax[] AdditionalAttributes { get; init; } /// @@ -210,7 +208,7 @@ public static DllImportStub Create( // Generate stub code var stubGenerator = new StubCodeGenerator(method, dllImportData, paramsTypeInfo, retTypeInfo, diagnostics, env.Options); - var (code, dllImport) = stubGenerator.GenerateSyntax(); + var code = stubGenerator.GenerateSyntax(); var additionalAttrs = new List(); @@ -235,7 +233,6 @@ public static DllImportStub Create( StubTypeNamespace = stubTypeNamespace, StubContainingTypes = containingTypes, StubCode = code, - DllImportDeclaration = dllImport, AdditionalAttributes = additionalAttrs.ToArray(), }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 696cac760ffa2..ea5995414f89b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; - +using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -115,7 +115,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } } - public (BlockSyntax Code, MethodDeclarationSyntax DllImport) GenerateSyntax() + public BlockSyntax GenerateSyntax() { string dllImportName = stubMethod.Name + "__PInvoke__"; var setupStatements = new List(); @@ -340,20 +340,22 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo var codeBlock = Block(UnsafeStatement(Block(allStatements))); // Define P/Invoke declaration - var dllImport = MethodDeclaration(retMarshaller.Generator.AsNativeType(retMarshaller.TypeInfo), dllImportName) + var dllImport = LocalFunctionStatement(retMarshaller.Generator.AsNativeType(retMarshaller.TypeInfo), dllImportName) .AddModifiers( Token(SyntaxKind.ExternKeyword), - Token(SyntaxKind.PrivateKeyword), Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.UnsafeKeyword)) - .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); + .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) + .WithAttributeLists( + SingletonList(AttributeList( + SingletonSeparatedList(CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData()))))); foreach (var marshaller in paramMarshallers) { ParameterSyntax paramSyntax = marshaller.Generator.AsParameter(marshaller.TypeInfo); dllImport = dllImport.AddParameterListParameters(paramSyntax); } - return (codeBlock, dllImport); + return codeBlock.AddStatements(dllImport); List GetStatements(Stage stage) { @@ -399,5 +401,131 @@ private void AppendVariableDeclations(List statementsToUpdate, native)); } } + + private static AttributeSyntax CreateDllImportAttributeForTarget(DllImportStub.GeneratedDllImportData targetDllImportData) + { + var newAttributeArgs = new List + { + AttributeArgument(LiteralExpression( + SyntaxKind.StringLiteralExpression, + Literal(targetDllImportData.ModuleName))), + AttributeArgument( + NameEquals(nameof(DllImportAttribute.EntryPoint)), + null, + CreateStringExpressionSyntax(targetDllImportData.EntryPoint)) + }; + + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) + { + var name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); + var value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CallingConvention)) + { + var name = NameEquals(nameof(DllImportAttribute.CallingConvention)); + var value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CharSet)) + { + var name = NameEquals(nameof(DllImportAttribute.CharSet)); + var value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ExactSpelling)) + { + var name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); + var value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.PreserveSig)) + { + var name = NameEquals(nameof(DllImportAttribute.PreserveSig)); + var value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.SetLastError)) + { + var name = NameEquals(nameof(DllImportAttribute.SetLastError)); + var value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) + { + var name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); + var value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + + // Create new attribute + return Attribute( + ParseName(typeof(DllImportAttribute).FullName), + AttributeArgumentList(SeparatedList(newAttributeArgs))); + + static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) + { + return LiteralExpression( + trueOrFalse + ? SyntaxKind.TrueLiteralExpression + : SyntaxKind.FalseLiteralExpression); + } + + static ExpressionSyntax CreateStringExpressionSyntax(string str) + { + return LiteralExpression( + SyntaxKind.StringLiteralExpression, + Literal(str)); + } + + static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum + { + return MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(typeof(T).FullName), + IdentifierName(value.ToString())); + } + } + + DllImportStub.GeneratedDllImportData GetTargetDllImportDataFromStubData() + { + DllImportStub.DllImportMember membersToForward = DllImportStub.DllImportMember.All + // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig + // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. + & ~DllImportStub.DllImportMember.PreserveSig + // 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. + & ~DllImportStub.DllImportMember.SetLastError; + if (options.GenerateForwarders()) + { + membersToForward = DllImportStub.DllImportMember.All; + } + + var targetDllImportData = new DllImportStub.GeneratedDllImportData + { + CharSet = dllImportData.CharSet, + BestFitMapping = dllImportData.BestFitMapping, + CallingConvention = dllImportData.CallingConvention, + EntryPoint = dllImportData.EntryPoint, + ModuleName = dllImportData.ModuleName, + ExactSpelling = dllImportData.ExactSpelling, + SetLastError = dllImportData.SetLastError, + PreserveSig = dllImportData.PreserveSig, + ThrowOnUnmappableChar = dllImportData.ThrowOnUnmappableChar, + IsUserDefined = dllImportData.IsUserDefined & membersToForward + }; + + // If the EntryPoint property is not set, we will compute and + // add it based on existing semantics (i.e. method name). + // + // N.B. The export discovery logic is identical regardless of where + // the name is defined (i.e. method name vs EntryPoint property). + if (!targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) + { + targetDllImportData.EntryPoint = stubMethod.Name; + } + + return targetDllImportData; + } } } 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 0a5b67328152c..77be3b4f324d8 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -16,6 +16,9 @@ public partial class Arrays [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum(int[] values, int numValues); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + public static partial int Sum(ref int values, int numValues); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] public static partial int SumInArray(in int[] values, int numValues); @@ -71,6 +74,13 @@ public void IntArrayMarshalledToNativeAsExpected() Assert.Equal(array.Sum(), NativeExportsNE.Arrays.Sum(array, array.Length)); } + [Fact] + public void IntArrayRefToFirstElementMarshalledToNativeAsExpected() + { + var array = new[] { 1, 5, 79, 165, 32, 3 }; + Assert.Equal(array.Sum(), NativeExportsNE.Arrays.Sum(ref array[0], array.Length)); + } + [Fact] public void NullIntArrayMarshalledToNativeAsExpected() { 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 e5c3ccf8f1876..d92f268c9bb1f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -279,5 +279,26 @@ public async Task ValidateSnippetsWithMarshalType(string source) Assert.StartsWith("'Marshal' does not contain a definition for ", diag.GetMessage()); }); } + + 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.BasicParameterByValue("int[]"), CodeSnippets.BasicParameterWithByRefModifier("ref", "int") } }; + } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompileMultipleSources))] + public async Task ValidateSnippetsWithMultipleSources(string[] sources) + { + Compilation comp = await TestUtils.CreateCompilation(sources); + TestUtils.AssertPreSourceGeneratorCompilation(comp); + + var newComp = TestUtils.RunGenerators(comp, out var generatorDiags, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(generatorDiags); + + var newCompDiags = newComp.GetDiagnostics(); + Assert.Empty(newCompDiags); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index 3be5e32aadcf0..4664b48d903b9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -54,6 +54,24 @@ public static async Task CreateCompilation(string source, OutputKin new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); } + /// + /// Create a compilation given sources + /// + /// Sources to compile + /// Output type + /// Whether or not use of the unsafe keyword should be allowed + /// The resulting compilation + public static async Task CreateCompilation(string[] sources, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true, IEnumerable? preprocessorSymbols = null) + { + var (mdRefs, ancillary) = GetReferenceAssemblies(); + + return CSharpCompilation.Create("compilation", + sources.Select(source => + CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview, preprocessorSymbols: preprocessorSymbols))).ToArray(), + (await mdRefs.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)).Add(ancillary), + new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); + } + /// /// Create a compilation given source and reference assemblies /// From 757002794ee60402bd8a8ceab8dfbf2ede58aa5f Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 10 May 2021 12:48:18 -0700 Subject: [PATCH 083/161] Basic infrastructure to enable DllImportGenerator (#52486) --- Directory.Build.targets | 3 +- NuGet.config | 2 + eng/Versions.props | 2 + eng/generators.targets | 35 ++++++++++++++++ .../GeneratedDllImportAttribute.cs | 34 +++++++++++++++ .../GeneratedMarshallingAttribute.cs | 41 +++++++++++++++++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 eng/generators.targets create mode 100644 src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs create mode 100644 src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs diff --git a/Directory.Build.targets b/Directory.Build.targets index e6457e6111cfb..c46b686c543d4 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -9,6 +9,7 @@ + @@ -24,7 +25,7 @@ $(ProductVersion) $(ProductVersion)-$(VersionSuffix) - + + + diff --git a/eng/Versions.props b/eng/Versions.props index 9d3af13f3369f..48e36672340d5 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -168,6 +168,8 @@ 9.0.1-alpha.1.21253.1 9.0.1-alpha.1.21253.1 9.0.1-alpha.1.21253.1 + + 1.0.0-alpha.21258.2 diff --git a/eng/generators.targets b/eng/generators.targets new file mode 100644 index 0000000000000..77d07da6fb1e0 --- /dev/null +++ b/eng/generators.targets @@ -0,0 +1,35 @@ + + + + + + + + true + + + + + + + + + + + + + + true + + + true + true + + + + diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs new file mode 100644 index 0000000000000..b04c9d9482bc7 --- /dev/null +++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable enable + +// +// Types in this file are used for generated p/invokes (docs/design/features/source-generator-pinvokes.md). +// See the DllImportGenerator experiment in https://github.com/dotnet/runtimelab. +// +namespace System.Runtime.InteropServices +{ + /// + /// Indicates that method will be generated at compile time and invoke into an unmanaged library entry point + /// + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + internal sealed class GeneratedDllImportAttribute : Attribute + { + public bool BestFitMapping { get; set; } + public CallingConvention CallingConvention { get; set; } + public CharSet CharSet { get; set; } + public string? EntryPoint { get; set; } + public bool ExactSpelling { get; set; } + public bool PreserveSig { get; set; } + public bool SetLastError { get; set; } + public bool ThrowOnUnmappableChar { get; set; } + + public GeneratedDllImportAttribute(string dllName) + { + this.Value = dllName; + } + + public string Value { get; private set; } + } +} diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs new file mode 100644 index 0000000000000..c66605e02ed19 --- /dev/null +++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs @@ -0,0 +1,41 @@ +// 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 (docs/design/features/source-generator-pinvokes.md). +// See the DllImportGenerator experiment in https://github.com/dotnet/runtimelab. +// +namespace System.Runtime.InteropServices +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + internal class GeneratedMarshallingAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Struct)] + internal class BlittableTypeAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] + internal class NativeMarshallingAttribute : Attribute + { + public NativeMarshallingAttribute(Type nativeType) + { + NativeType = nativeType; + } + + public Type NativeType { get; } + } + + [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field)] + internal class MarshalUsingAttribute : Attribute + { + public MarshalUsingAttribute(Type nativeType) + { + NativeType = nativeType; + } + + public Type NativeType { get; } + } +} From 1cba6dc43ccaba022f3b68682bff31d85c026804 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 10 May 2021 16:50:17 -0700 Subject: [PATCH 084/161] Prepend identifiers with @ symbol since the Roslyn Symbol API strips the @ from the name. (dotnet/runtimelab#1105) Fixes https://github.com/dotnet/runtimelab/issues/1096 Commit migrated from https://github.com/dotnet/runtimelab/commit/3c162b8e3a01a3753db5411cd2d67719606868ce --- .../gen/DllImportGenerator/TypePositionInfo.cs | 4 ++-- .../DllImportGenerator.UnitTests/CodeSnippets.cs | 12 ++++++++++++ .../tests/DllImportGenerator.UnitTests/Compiles.cs | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 0a5d4c921b22d..06d6040ea3c07 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { @@ -88,7 +88,7 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, var typeInfo = new TypePositionInfo() { ManagedType = paramSymbol.Type, - InstanceIdentifier = paramSymbol.Name, + InstanceIdentifier = ParseToken(paramSymbol.Name).IsReservedKeyword() ? $"@{paramSymbol.Name}" : paramSymbol.Name, RefKind = paramSymbol.RefKind, RefKindSyntax = RefKindToSyntax(paramSymbol.RefKind), MarshallingAttributeInfo = marshallingInfo, 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 eb4cc83858fee..8d74efa7ea8e6 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -396,6 +396,18 @@ public static partial void Method( public static string ByValueParameterWithModifier(string attributeName) => ByValueParameterWithModifier(typeof(T).ToString(), attributeName); + /// + /// Declaration with by-value parameter with custom name. + /// + public static string ByValueParameterWithName(string methodName, string paramName) => @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void {methodName}( + int {paramName}); +}}"; + /// /// Declaration with parameters with MarshalAs. /// 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 d92f268c9bb1f..f3efff8e40bbd 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -179,6 +179,11 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.CustomStructMarshallingNativeTypePinnable }; yield return new[] { CodeSnippets.CustomStructMarshallingMarshalUsingParametersAndModifiers }; yield return new[] { CodeSnippets.ArrayMarshallingWithCustomStructElement }; + + // Escaped C# keyword identifiers + yield return new[] { CodeSnippets.ByValueParameterWithName("Method", "@event") }; + yield return new[] { CodeSnippets.ByValueParameterWithName("Method", "@var") }; + yield return new[] { CodeSnippets.ByValueParameterWithName("@params", "i") }; } [Theory] From d205672ec8a7c3edcaf6305fc28f9763acca521d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 18 May 2021 13:59:58 -0700 Subject: [PATCH 085/161] Use SemanticModel to discover GeneratedDllImportAttribute. (dotnet/runtimelab#1116) Commit migrated from https://github.com/dotnet/runtimelab/commit/4dc8111108263a9f17d9c18d9a55ffbaf767b21f --- .../DllImportGenerator/DllImportGenerator.cs | 50 ++++++------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index c1f94784456d9..f0a33362b3eb5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -24,17 +24,12 @@ public class DllImportGenerator : ISourceGenerator public void Execute(GeneratorExecutionContext context) { - var synRec = context.SyntaxReceiver as SyntaxReceiver; - if (synRec is null || !synRec.Methods.Any()) + if (context.SyntaxContextReceiver is not SyntaxContextReceiver synRec + || !synRec.Methods.Any()) { return; } - // Get the symbol for GeneratedDllImportAttribute. If it doesn't exist in the compilation, the generator has nothing to do. - INamedTypeSymbol? generatedDllImportAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.GeneratedDllImportAttribute); - if (generatedDllImportAttrType == null) - return; - INamedTypeSymbol? lcidConversionAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.LCIDConversionAttribute); // Fire the start/stop pair for source generation @@ -48,8 +43,7 @@ public void Execute(GeneratorExecutionContext context) var generatorDiagnostics = new GeneratorDiagnostics(context); - Version targetFrameworkVersion; - bool isSupported = IsSupportedTargetFramework(context.Compilation, out targetFrameworkVersion); + bool isSupported = IsSupportedTargetFramework(context.Compilation, out Version targetFrameworkVersion); if (!isSupported) { // We don't return early here, letting the source generation continue. @@ -79,7 +73,8 @@ public void Execute(GeneratorExecutionContext context) AttributeData? lcidConversionAttr = null; foreach (var attr in methodSymbolInfo.GetAttributes()) { - if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, generatedDllImportAttrType)) + if (attr.AttributeClass is not null + && attr.AttributeClass.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) { generatedDllImportAttr = attr; } @@ -124,7 +119,7 @@ public void Execute(GeneratorExecutionContext context) public void Initialize(GeneratorInitializationContext context) { - context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); + context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); } private SyntaxTokenList StripTriviaFromModifiers(SyntaxTokenList tokenList) @@ -175,7 +170,7 @@ private void PrintGeneratedSource( MemberDeclarationSyntax toPrint = containingType; // Add type to the containing namespace - if (!(stub.StubTypeNamespace is null)) + if (stub.StubTypeNamespace is not null) { toPrint = NamespaceDeclaration(IdentifierName(stub.StubTypeNamespace)) .AddMembers(toPrint); @@ -201,27 +196,6 @@ private static bool IsSupportedTargetFramework(Compilation compilation, out Vers }; } - private static bool IsGeneratedDllImportAttribute(AttributeSyntax attrSyntaxMaybe) - { - var attrName = attrSyntaxMaybe.Name.ToString(); - - if (attrName.Length == GeneratedDllImport.Length) - { - return attrName.Equals(GeneratedDllImport); - } - else if (attrName.Length == GeneratedDllImportAttribute.Length) - { - return attrName.Equals(GeneratedDllImportAttribute); - } - - // Handle the case where the user defines an attribute with - // the same name but adds a prefix. - const string PrefixedGeneratedDllImport = "." + GeneratedDllImport; - const string PrefixedGeneratedDllImportAttribute = "." + GeneratedDllImportAttribute; - return attrName.EndsWith(PrefixedGeneratedDllImport) - || attrName.EndsWith(PrefixedGeneratedDllImportAttribute); - } - private DllImportStub.GeneratedDllImportData ProcessGeneratedDllImportAttribute(AttributeData attrData) { var stubDllImportData = new DllImportStub.GeneratedDllImportData(); @@ -284,12 +258,14 @@ private DllImportStub.GeneratedDllImportData ProcessGeneratedDllImportAttribute( } - private class SyntaxReceiver : ISyntaxReceiver + private class SyntaxContextReceiver : ISyntaxContextReceiver { public ICollection Methods { get; } = new List(); - public void OnVisitSyntaxNode(SyntaxNode syntaxNode) + public void OnVisitSyntaxNode(GeneratorSyntaxContext context) { + SyntaxNode syntaxNode = context.Node; + // We only support C# method declarations. if (syntaxNode.Language != LanguageNames.CSharp || !syntaxNode.IsKind(SyntaxKind.MethodDeclaration)) @@ -314,7 +290,9 @@ public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { foreach (AttributeSyntax attrSyntax in listSyntax.Attributes) { - if (IsGeneratedDllImportAttribute(attrSyntax)) + SymbolInfo info = context.SemanticModel.GetSymbolInfo(attrSyntax); + if (info.Symbol is IMethodSymbol attrConstructor + && attrConstructor.ContainingType.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) { this.Methods.Add(syntaxNode.GetReference()); return; From 7d9a4d9154bcaa8928df2db480213e264cc30cba Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 18 May 2021 14:00:04 -0700 Subject: [PATCH 086/161] Support implicit blittability for structs declared in and not exposed outside of the current compilation. (dotnet/runtimelab#1126) Commit migrated from https://github.com/dotnet/runtimelab/commit/51d9ad880e106c88188630fd9318360b1ac21854 --- .../DllImportGenerator/TypePositionInfo.cs | 17 +++- .../TypeSymbolExtensions.cs | 92 ++++++++++++------- .../CodeSnippets.cs | 59 ++++++++++-- .../CompileFails.cs | 32 +++++++ .../DllImportGenerator.UnitTests/Compiles.cs | 21 ++++- 5 files changed, 180 insertions(+), 41 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 06d6040ea3c07..8d23b274ee3a0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -153,7 +153,12 @@ private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable< if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute), attributeClass)) { - return new BlittableTypeAttributeInfo(); + // If type is generic, then we need to re-evaluate that it is blittable at usage time. + if (type is INamedTypeSymbol { IsGenericType: false } || type.HasOnlyBlittableFields()) + { + return new BlittableTypeAttributeInfo(); + } + break; } else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute), attributeClass)) { @@ -335,6 +340,16 @@ static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshalli marshallingInfo = new ArrayMarshallingInfo(GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics, scopeSymbol)); return true; } + + if (type is INamedTypeSymbol { IsValueType: true } valueType + && !valueType.IsExposedOutsideOfCurrentCompilation() + && valueType.IsConsideredBlittable()) + { + // Allow implicit [BlittableType] on internal value types. + marshallingInfo = new BlittableTypeAttributeInfo(); + return true; + } + marshallingInfo = NoMarshallingInfo.Instance; return false; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 745f861f61019..4495704b3dccc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -13,34 +13,44 @@ namespace Microsoft.Interop { static class TypeSymbolExtensions { - public static bool HasOnlyBlittableFields(this ITypeSymbol type) + public static bool HasOnlyBlittableFields(this ITypeSymbol type) => HasOnlyBlittableFields(type, new HashSet(SymbolEqualityComparer.Default)); + + private static bool HasOnlyBlittableFields(this ITypeSymbol type, HashSet seenTypes) { + if (seenTypes.Contains(type)) + { + // A recursive struct type isn't blittable. + // It's also illegal in C#, but I believe that source generators run + // before that is detected, so we check here to avoid a stack overflow. + return false; + } + seenTypes.Add(type); foreach (var field in type.GetMembers().OfType()) { - bool? fieldBlittable = field switch + if (!field.IsStatic) { - { IsStatic : true } => null, - { Type : { IsReferenceType : true }} => false, - { Type : IPointerTypeSymbol ptr } => IsConsideredBlittable(ptr.PointedAtType), - { Type : IFunctionPointerTypeSymbol } => true, - not { Type : { SpecialType : SpecialType.None }} => IsSpecialTypeBlittable(field.Type.SpecialType), - // Assume that type parameters that can be blittable are blittable. - // We'll re-evaluate blittability for generic fields of generic types at instantation time. - { Type : ITypeParameterSymbol } => true, - { Type : { IsValueType : false }} => false, - // A recursive struct type isn't blittable. - // It's also illegal in C#, but I believe that source generators run - // before that is detected, so we check here to avoid a stack overflow. - // [TODO]: Handle mutual recursion. - _ => !SymbolEqualityComparer.Default.Equals(field.Type, type) && IsConsideredBlittable(field.Type) - }; - - if (fieldBlittable is false) - { - return false; + bool fieldBlittable = field switch + { + { Type: { IsReferenceType: true } } => false, + { Type: IPointerTypeSymbol ptr } => IsConsideredBlittable(ptr.PointedAtType), + { Type: IFunctionPointerTypeSymbol } => true, + not { Type: { SpecialType: SpecialType.None } } => IsSpecialTypeBlittable(field.Type.SpecialType), + // Assume that type parameters that can be blittable are blittable. + // We'll re-evaluate blittability for generic fields of generic types at instantation time. + { Type: ITypeParameterSymbol } => true, + { Type: { IsValueType: false } } => false, + _ => IsConsideredBlittable(field.Type, seenTypes) + }; + + if (!fieldBlittable) + { + seenTypes.Remove(type); + return false; + } } } + seenTypes.Remove(type); return true; } @@ -62,14 +72,16 @@ or SpecialType.System_IntPtr _ => false }; - public static bool IsConsideredBlittable(this ITypeSymbol type) + public static bool IsConsideredBlittable(this ITypeSymbol type) => IsConsideredBlittable(type, new HashSet(SymbolEqualityComparer.Default)); + + private static bool IsConsideredBlittable(this ITypeSymbol type, HashSet seenTypes) { if (type.SpecialType != SpecialType.None) { return IsSpecialTypeBlittable(type.SpecialType); } - if (type.TypeKind == TypeKind.FunctionPointer) + if (type.TypeKind is TypeKind.FunctionPointer or TypeKind.Pointer) { return true; } @@ -79,14 +91,9 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) return false; } - if (type is IPointerTypeSymbol { PointedAtType: ITypeSymbol pointedAtType }) - { - return pointedAtType.IsConsideredBlittable(); - } - if (type is INamedTypeSymbol { TypeKind: TypeKind.Enum, EnumUnderlyingType: ITypeSymbol underlyingType }) { - return underlyingType!.IsConsideredBlittable(); + return underlyingType.IsConsideredBlittable(seenTypes); } bool hasNativeMarshallingAttribute = false; @@ -107,7 +114,7 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) // since we are guaranteed that if a type has generic fields, // they will be present in the contract assembly to ensure // that recursive structs can be identified at build time. - return generic.HasOnlyBlittableFields(); + return generic.HasOnlyBlittableFields(seenTypes); } return true; } @@ -126,7 +133,16 @@ public static bool IsConsideredBlittable(this ITypeSymbol type) // The struct type has generated marshalling via a source generator. // We can't guarantee that we can see the results of the struct source generator, // so we re-calculate if the type is blittable here. - return type.HasOnlyBlittableFields(); + return type.HasOnlyBlittableFields(seenTypes); + } + + if (type is INamedTypeSymbol namedType + && namedType.DeclaringSyntaxReferences.Length != 0 + && !namedType.IsExposedOutsideOfCurrentCompilation()) + { + // If a type is declared in the current compilation and not exposed outside of it, + // we will allow it to be considered blittable if its fields are considered blittable. + return type.HasOnlyBlittableFields(seenTypes); } return false; } @@ -165,5 +181,19 @@ or SpecialType.System_IntPtr _ => false }; } + + public static bool IsExposedOutsideOfCurrentCompilation(this INamedTypeSymbol type) + { + for (; type is not null; type = type.ContainingType) + { + Accessibility accessibility = type.DeclaredAccessibility; + + if (accessibility is Accessibility.Internal or Accessibility.ProtectedAndInternal or Accessibility.Private or Accessibility.Friend or Accessibility.ProtectedAndFriend) + { + return false; + } + } + return true; + } } } 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 8d74efa7ea8e6..b89acc1f63dbc 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -511,14 +511,6 @@ struct MyStruct private int i; private short s; }"; - public static string GenericBlittableStructParametersAndModifiers = BasicParametersAndModifiers("MyStruct") + @" -#pragma warning disable CS0169 -[BlittableType] -struct MyStruct -{ - private T t; - private short s; -}"; public static string ArrayParametersAndModifiers(string elementType) => $@" using System.Runtime.InteropServices; @@ -1040,5 +1032,56 @@ public static partial int Method2( #endif public static int Foo() => throw null; }}"; + + public static string MaybeBlittableGenericTypeParametersAndModifiers(string typeArgument) => BasicParametersAndModifiers($"Generic<{typeArgument}>") + @" +[BlittableType] +struct Generic +{ +#pragma warning disable CS0649 + public T field; +} +"; + + public static string MaybeBlittableGenericTypeParametersAndModifiers() => + MaybeBlittableGenericTypeParametersAndModifiers(typeof(T).ToString()); + + public static string ImplicitlyBlittableStructParametersAndModifiers(string visibility = "") => BasicParametersAndModifiers("ImplicitBlittable") + $@" +#pragma warning disable CS0649 +#pragma warning disable CS0169 +{visibility} struct ImplicitBlittable +{{ + int i; +}}"; + + public static string ImplicitlyBlittableGenericTypeParametersAndModifiers(string typeArgument, string visibility = "") => BasicParametersAndModifiers($"Generic<{typeArgument}>") + $@" +{visibility} struct Generic +{{ +#pragma warning disable CS0649 +#pragma warning disable CS0169 + public T field; +}} +"; + + public static string ImplicitlyBlittableGenericTypeParametersAndModifiers(string visibility = "") => + ImplicitlyBlittableGenericTypeParametersAndModifiers(typeof(T).ToString(), visibility); + + public static string RecursiveImplicitlyBlittableStruct => BasicParametersAndModifiers("RecursiveStruct") + @" +struct RecursiveStruct +{ + RecursiveStruct s; + int i; +}"; + public static string MutuallyRecursiveImplicitlyBlittableStruct => BasicParametersAndModifiers("RecursiveStruct1") + @" +struct RecursiveStruct1 +{ + RecursiveStruct2 s; + int i; +} + +struct RecursiveStruct2 +{ + RecursiveStruct1 s; + int i; +}"; } } 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 89622d1cdf233..19736372a2535 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -95,6 +95,15 @@ public static IEnumerable CodeSnippetsToCompile() // Abstract SafeHandle type by reference yield return new object[] { CodeSnippets.BasicParameterWithByRefModifier("ref", "System.Runtime.InteropServices.SafeHandle"), 1, 0 }; + + // Non-blittable instantiation of generic type + yield return new object[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers(), 5, 0 }; + + // No marshalling annotations + + yield return new object[] { CodeSnippets.ImplicitlyBlittableStructParametersAndModifiers("public"), 5, 0 }; + yield return new object[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers(), 5, 0 }; + yield return new object[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers("public"), 5, 0 }; } [Theory] @@ -113,5 +122,28 @@ public async Task ValidateSnippets(string source, int expectedGeneratorErrors, i int compilerErrors = newComp.GetDiagnostics().Count(d => d.Severity == DiagnosticSeverity.Error); Assert.Equal(expectedCompilerErrors, compilerErrors); } + + public static IEnumerable CodeSnippetsToCompile_InvalidCode() + { + yield return new object[] { CodeSnippets.RecursiveImplicitlyBlittableStruct, 5, 1 }; + yield return new object[] { CodeSnippets.MutuallyRecursiveImplicitlyBlittableStruct, 5, 2 }; + } + + [Theory] + [MemberData(nameof(CodeSnippetsToCompile_InvalidCode))] + public async Task ValidateSnippets_InvalidCodeGracefulFailure(string source, int expectedGeneratorErrors, int expectedCompilerErrors) + { + // Do not validate that the compilation has no errors that the generator will not fix. + Compilation comp = await TestUtils.CreateCompilation(source); + + 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); + } } } 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 f3efff8e40bbd..a785ed75ac654 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -131,7 +131,6 @@ public static IEnumerable CodeSnippetsToCompile() // Structs yield return new[] { CodeSnippets.BlittableStructParametersAndModifiers }; - yield return new[] { CodeSnippets.GenericBlittableStructParametersAndModifiers }; // SafeHandle yield return new[] { CodeSnippets.BasicParametersAndModifiers("Microsoft.Win32.SafeHandles.SafeFileHandle") }; @@ -184,6 +183,26 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.ByValueParameterWithName("Method", "@event") }; yield return new[] { CodeSnippets.ByValueParameterWithName("Method", "@var") }; yield return new[] { CodeSnippets.ByValueParameterWithName("@params", "i") }; + + // Generics + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.MaybeBlittableGenericTypeParametersAndModifiers() }; + + // Implicit blittable types + yield return new[] { CodeSnippets.ImplicitlyBlittableStructParametersAndModifiers() }; + yield return new[] { CodeSnippets.ImplicitlyBlittableStructParametersAndModifiers("internal") }; + yield return new[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers() }; + yield return new[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers("internal") }; } [Theory] From cd046502f20bb9a156fe930155203d30470b1b6f Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 19 May 2021 10:56:21 -0700 Subject: [PATCH 087/161] Move to DllImportGenerator 1.0.0-alpha.21268.4 (#52981) --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 48e36672340d5..ecb27f126a115 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -169,7 +169,7 @@ 9.0.1-alpha.1.21253.1 9.0.1-alpha.1.21253.1 - 1.0.0-alpha.21258.2 + 1.0.0-alpha.21268.4 From 5513d6190f1cfce10acb6b40e6be52d2c686c831 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 20 May 2021 16:28:28 -0700 Subject: [PATCH 088/161] Use GeneratedDllImport in System.Diagnostics.FileVersionInfo and System.Runtime.InteropServices.RuntimeInformation (#52739) * Convert System.Diagnostics.FileVersionInfo * Convert System.Runtime.InteropServices.RuntimeInformation * Use SYSTEM_INFO* instead of GeneratedDllImport for GetSystemInfo/GetNativeSystemInfo --- .../Unix/System.Native/Interop.GetUnixVersion.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.Stat.cs | 12 ++++++------ .../Kernel32/Interop.GetNativeSystemInfo.cs | 2 +- .../Windows/Kernel32/Interop.GetSystemInfo.cs | 2 +- .../Version/Interop.GetFileVersionInfoEx.cs | 4 ++-- .../Version/Interop.GetFileVersionInfoSizeEx.cs | 4 ++-- .../Windows/Version/Interop.VerQueryValue.cs | 4 ++-- .../MemoryMappedFiles/MemoryMappedView.Windows.cs | 5 ++++- .../src/System/Environment.Windows.cs | 7 ++++++- .../src/System/Runtime/MemoryFailPoint.Windows.cs | 7 ++++++- ...ntime.InteropServices.RuntimeInformation.csproj | 1 + .../RuntimeInformation.Windows.cs | 14 ++++++++++++-- 12 files changed, 45 insertions(+), 21 deletions(-) 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 75854552fa3d5..3c130da95f54d 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,8 +10,8 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixVersion", CharSet = CharSet.Ansi, SetLastError = true)] - private static extern int GetUnixVersion(byte[] version, ref int capacity); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixVersion", CharSet = CharSet.Ansi, 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.Stat.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.cs index c143ab1828b83..4f8193e859599 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 @@ -53,13 +53,13 @@ internal enum FileStatusFlags HasBirthTime = 1, } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat", SetLastError = true)] - internal static extern int FStat(SafeHandle fd, out FileStatus output); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat", SetLastError = true)] + internal static partial int FStat(SafeHandle fd, out FileStatus output); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", SetLastError = true)] - internal static extern int Stat(string path, out FileStatus output); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int Stat(string path, out FileStatus output); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", SetLastError = true)] - internal static extern int LStat(string path, out FileStatus output); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int LStat(string path, out FileStatus output); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs index 60bbcca66c548..2322bdd4d7b14 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class Kernel32 { [DllImport(Libraries.Kernel32)] - internal static extern void GetNativeSystemInfo(out SYSTEM_INFO lpSystemInfo); + internal static unsafe extern void GetNativeSystemInfo(SYSTEM_INFO* lpSystemInfo); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs index 48e4b23dfcc3d..f3872f106180e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs @@ -8,6 +8,6 @@ internal static partial class Interop internal static partial class Kernel32 { [DllImport(Libraries.Kernel32)] - internal static extern void GetSystemInfo(out SYSTEM_INFO lpSystemInfo); + internal static unsafe extern void GetSystemInfo(SYSTEM_INFO* lpSystemInfo); } } 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 5392b85d67360..330b4626b867d 100644 --- a/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Version/Interop.GetFileVersionInfoEx.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Version { - [DllImport(Libraries.Version, CharSet = CharSet.Unicode, EntryPoint = "GetFileVersionInfoExW")] - internal static extern bool GetFileVersionInfoEx( + [GeneratedDllImport(Libraries.Version, CharSet = CharSet.Unicode, EntryPoint = "GetFileVersionInfoExW")] + internal static partial bool GetFileVersionInfoEx( uint dwFlags, string lpwstrFilename, uint dwHandle, 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 e6a703695db18..6eddc000b3463 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 { - [DllImport(Libraries.Version, CharSet = CharSet.Unicode, EntryPoint = "GetFileVersionInfoSizeExW")] - internal static extern uint GetFileVersionInfoSizeEx(uint dwFlags, string lpwstrFilename, out uint lpdwHandle); + [GeneratedDllImport(Libraries.Version, CharSet = CharSet.Unicode, EntryPoint = "GetFileVersionInfoSizeExW")] + 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 60c122d07b42e..8dffcdb22a018 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 { - [DllImport(Libraries.Version, CharSet = CharSet.Unicode, EntryPoint = "VerQueryValueW")] - internal static extern bool VerQueryValue(IntPtr pBlock, string lpSubBlock, out IntPtr lplpBuffer, out uint puLen); + [GeneratedDllImport(Libraries.Version, CharSet = CharSet.Unicode, EntryPoint = "VerQueryValueW")] + internal static partial bool VerQueryValue(IntPtr pBlock, string lpSubBlock, out IntPtr lplpBuffer, out uint puLen); } } diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.cs b/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.cs index cc3300c12c9fe..4db049a392f98 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.cs @@ -148,7 +148,10 @@ public unsafe void Flush(UIntPtr capacity) private static int GetSystemPageAllocationGranularity() { Interop.Kernel32.SYSTEM_INFO info; - Interop.Kernel32.GetSystemInfo(out info); + unsafe + { + Interop.Kernel32.GetSystemInfo(&info); + } return (int)info.dwAllocationGranularity; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs index ca9dfc0aa9711..4e1fead4ea678 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs @@ -57,7 +57,12 @@ public static int SystemPageSize { get { - Interop.Kernel32.GetSystemInfo(out Interop.Kernel32.SYSTEM_INFO info); + Interop.Kernel32.SYSTEM_INFO info; + unsafe + { + Interop.Kernel32.GetSystemInfo(&info); + } + return info.dwPageSize; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs index 7c4a2da7babb1..052c26bec44e3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs @@ -9,7 +9,12 @@ public sealed partial class MemoryFailPoint { private static ulong GetTopOfMemory() { - Interop.Kernel32.GetSystemInfo(out Interop.Kernel32.SYSTEM_INFO info); + Interop.Kernel32.SYSTEM_INFO info; + unsafe + { + Interop.Kernel32.GetSystemInfo(&info); + } + return (ulong)info.lpMaximumApplicationAddress; } diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj index 2ee0caf2d562f..e143498080333 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj @@ -38,6 +38,7 @@ Link="Common\Interop\Windows\Kernel32\Interop.GetSystemInfo.cs" /> + diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs index 0177eec2317cc..02dcac2cf68b3 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs @@ -41,7 +41,12 @@ public static Architecture OSArchitecture if (osArch == -1) { - Interop.Kernel32.GetNativeSystemInfo(out Interop.Kernel32.SYSTEM_INFO sysInfo); + Interop.Kernel32.SYSTEM_INFO sysInfo; + unsafe + { + Interop.Kernel32.GetNativeSystemInfo(&sysInfo); + } + osArch = s_osArch = (int)Map((Interop.Kernel32.ProcessorArchitecture)sysInfo.wProcessorArchitecture); } @@ -59,7 +64,12 @@ public static Architecture ProcessArchitecture if (processArch == -1) { - Interop.Kernel32.GetSystemInfo(out Interop.Kernel32.SYSTEM_INFO sysInfo); + Interop.Kernel32.SYSTEM_INFO sysInfo; + unsafe + { + Interop.Kernel32.GetSystemInfo(&sysInfo); + } + processArch = s_processArch = (int)Map((Interop.Kernel32.ProcessorArchitecture)sysInfo.wProcessorArchitecture); } From 9f32647332cd85af0bf791d5267f77ebb5130a5d Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 20 May 2021 16:29:03 -0700 Subject: [PATCH 089/161] Use GeneratedDllImport in System.Console (#52740) --- .../src/Interop/Unix/System.Native/Interop.Close.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.Dup.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.FLock.cs | 8 ++++---- .../System.Native/Interop.GetControlCharacters.cs | 4 ++-- .../Interop/Unix/System.Native/Interop.GetPwUid.cs | 8 ++++---- .../Unix/System.Native/Interop.GetWindowWidth.cs | 4 ++-- .../Interop.InitializeTerminalAndSignalHandling.cs | 8 ++++---- .../src/Interop/Unix/System.Native/Interop.IsATty.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.LSeek.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.Open.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.Read.cs | 4 ++-- .../System.Native/Interop.ReadStdinUnbuffered.cs | 4 ++-- .../Interop/Unix/System.Native/Interop.SNPrintF.cs | 8 ++++---- .../Interop/Unix/System.Native/Interop.StdinReady.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.Write.cs | 8 ++++---- .../src/Interop/Windows/Kernel32/Interop.Beep.cs | 4 ++-- .../Windows/Kernel32/Interop.ConsoleCursorInfo.cs | 10 +++++----- .../Kernel32/Interop.FillConsoleOutputAttribute.cs | 4 ++-- .../Kernel32/Interop.FillConsoleOutputCharacter.cs | 4 ++-- .../Windows/Kernel32/Interop.FormatMessage.cs | 12 ++++++++++++ .../Windows/Kernel32/Interop.GetConsoleMode.cs | 10 ++++++++++ .../Kernel32/Interop.GetConsoleScreenBufferInfo.cs | 4 ++-- .../Windows/Kernel32/Interop.GetConsoleTitle.cs | 4 ++-- .../Windows/Kernel32/Interop.GetFileType_IntPtr.cs | 4 ++-- .../Kernel32/Interop.GetLargestConsoleWindowSize.cs | 4 ++-- .../Windows/Kernel32/Interop.PeekConsoleInput.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.ReadConsole.cs | 4 ++-- .../Windows/Kernel32/Interop.ReadConsoleInput.cs | 6 +++--- .../Windows/Kernel32/Interop.ReadConsoleOutput.cs | 4 ++-- .../Windows/Kernel32/Interop.ReadFile_IntPtr.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.SetConsoleCP.cs | 4 ++-- .../Kernel32/Interop.SetConsoleCtrlHandler.cs | 5 +++++ .../Kernel32/Interop.SetConsoleCursorPosition.cs | 4 ++-- .../Windows/Kernel32/Interop.SetConsoleOutputCP.cs | 4 ++-- .../Kernel32/Interop.SetConsoleScreenBufferSize.cs | 4 ++-- .../Kernel32/Interop.SetConsoleTextAttribute.cs | 4 ++-- .../Windows/Kernel32/Interop.SetConsoleTitle.cs | 4 ++-- .../Windows/Kernel32/Interop.SetConsoleWindowInfo.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.WriteConsole.cs | 4 ++-- .../Windows/Kernel32/Interop.WriteConsoleOutput.cs | 4 ++-- .../Windows/Kernel32/Interop.WriteFile_IntPtr.cs | 4 ++-- .../System.Console/src/System/ConsolePal.Windows.cs | 4 ++-- 42 files changed, 119 insertions(+), 92 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Close.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Close.cs index 6dfec617396a9..dcf65c410fc33 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Close.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Close.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Close", SetLastError = true)] - internal static extern int Close(IntPtr fd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Close", SetLastError = true)] + internal static partial int Close(IntPtr fd); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Dup.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Dup.cs index 37df5702161dd..d61ab47050fee 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Dup.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Dup.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Dup", SetLastError = true)] - internal static extern SafeFileHandle Dup(SafeFileHandle oldfd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Dup", SetLastError = true)] + internal static partial SafeFileHandle Dup(SafeFileHandle oldfd); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FLock.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FLock.cs index 4e6e36b8f94d7..a2a89fef02681 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FLock.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FLock.cs @@ -17,14 +17,14 @@ internal enum LockOperations : int LOCK_UN = 8, /* unlock */ } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FLock", SetLastError = true)] - internal static extern int FLock(SafeFileHandle fd, LockOperations operation); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FLock", SetLastError = true)] + internal static partial int FLock(SafeFileHandle fd, LockOperations operation); /// /// Exposing this for SafeFileHandle.ReleaseHandle() to call. /// Normal callers should use FLock(SafeFileHandle fd). /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FLock", SetLastError = true)] - internal static extern int FLock(IntPtr fd, LockOperations operation); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FLock", SetLastError = true)] + internal static partial int FLock(IntPtr fd, LockOperations operation); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetControlCharacters.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetControlCharacters.cs index 7f8bb04babe3d..be1316a2b17a6 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetControlCharacters.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetControlCharacters.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetControlCharacters")] - internal static extern void GetControlCharacters( + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetControlCharacters")] + internal static partial void GetControlCharacters( ControlCharacterNames[] controlCharacterNames, byte[] controlCharacterValues, int controlCharacterLength, out byte posixDisableValue); 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 08cb7a4085983..086a7b686535c 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 @@ -20,10 +20,10 @@ internal unsafe struct Passwd internal byte* Shell; } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwUidR", SetLastError = false)] - internal static extern unsafe int GetPwUidR(uint uid, out Passwd pwd, byte* buf, int bufLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwUidR", SetLastError = false)] + internal static unsafe partial int GetPwUidR(uint uid, out Passwd pwd, byte* buf, int bufLen); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwNamR", SetLastError = false)] - internal static extern unsafe int GetPwNamR(string name, out Passwd pwd, byte* buf, int bufLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwNamR", SetLastError = false, CharSet = CharSet.Ansi)] + 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.GetWindowWidth.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetWindowWidth.cs index 151b6a65ed524..83410484f60a7 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetWindowWidth.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetWindowWidth.cs @@ -17,7 +17,7 @@ internal struct WinSize internal ushort YPixel; }; - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetWindowSize", SetLastError = true)] - internal static extern int GetWindowSize(out WinSize winSize); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetWindowSize", SetLastError = true)] + internal static partial int GetWindowSize(out WinSize winSize); } } 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 66e18a03def05..a9d4b29d23517 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 @@ -7,10 +7,10 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeTerminalAndSignalHandling", SetLastError = true)] - internal static extern bool InitializeTerminalAndSignalHandling(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeTerminalAndSignalHandling", SetLastError = true)] + internal static partial bool InitializeTerminalAndSignalHandling(); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetKeypadXmit")] - internal static extern void SetKeypadXmit(string terminfoString); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetKeypadXmit", CharSet = CharSet.Ansi)] + internal static partial void SetKeypadXmit(string terminfoString); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IsATty.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IsATty.cs index a7e144519d002..94fccc8c6052d 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IsATty.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IsATty.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_IsATty", SetLastError = true)] - internal static extern bool IsATty(SafeFileHandle fd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_IsATty", SetLastError = true)] + internal static partial bool IsATty(SafeFileHandle fd); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LSeek.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LSeek.cs index 95574358639f4..c76231bb193b0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LSeek.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LSeek.cs @@ -15,7 +15,7 @@ internal enum SeekWhence SEEK_END = 2 } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LSeek", SetLastError = true)] - internal static extern long LSeek(SafeFileHandle fd, long offset, SeekWhence whence); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LSeek", SetLastError = true)] + internal static partial long LSeek(SafeFileHandle fd, long offset, SeekWhence whence); } } 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 a4ec5f57b1207..d80adcce03cfb 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 { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Open", SetLastError = true)] - internal static extern SafeFileHandle Open(string filename, OpenFlags flags, int mode); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Open", SetLastError = true, CharSet = CharSet.Ansi)] + internal static partial SafeFileHandle Open(string filename, OpenFlags flags, int mode); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs index 51038fc099d97..7d9988d057eeb 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs @@ -17,7 +17,7 @@ internal static partial class Sys /// Returns the number of bytes read on success; otherwise, -1 is returned /// Note - on fail. the position of the stream may change depending on the platform; consult man 2 read for more info /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Read", SetLastError = true)] - internal static extern unsafe int Read(SafeHandle fd, byte* buffer, int count); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Read", SetLastError = true)] + internal static unsafe partial int Read(SafeHandle fd, byte* buffer, int count); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs index 2ac19f1d9d1bb..03565b1dd1747 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadStdin", SetLastError = true)] - internal static extern unsafe int ReadStdin(byte* buffer, int bufferSize); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadStdin", SetLastError = true)] + internal static unsafe partial int ReadStdin(byte* buffer, int bufferSize); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeConsoleBeforeRead")] internal static extern void InitializeConsoleBeforeRead(byte minChars = 1, byte decisecondsTimeout = 0); 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 8755c7e0a6987..ec3b5472066e8 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,8 +26,8 @@ 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. /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", SetLastError = true)] - internal static extern unsafe int SNPrintF(byte* str, int size, string format, string arg1); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", SetLastError = true, CharSet = CharSet.Ansi)] + internal static unsafe partial int SNPrintF(byte* str, int size, string format, string arg1); /// /// Takes a string and applies a formatting to it to transform @@ -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. /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", SetLastError = true)] - internal static extern unsafe int SNPrintF(byte* str, int size, string format, int arg1); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", SetLastError = true, CharSet = CharSet.Ansi)] + 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.StdinReady.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.StdinReady.cs index 8ba426acc962d..52f97e37747e1 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.StdinReady.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.StdinReady.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StdinReady")] - internal static extern bool StdinReady(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StdinReady")] + internal static partial bool StdinReady(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs index 6b322ee72a882..278346759d3eb 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs @@ -17,10 +17,10 @@ internal static partial class Sys /// /// Returns the number of bytes written on success; otherwise, returns -1 and sets errno /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] - internal static extern unsafe int Write(SafeHandle fd, byte* buffer, int bufferSize); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] + internal static unsafe partial int Write(SafeHandle fd, byte* buffer, int bufferSize); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] - internal static extern unsafe int Write(IntPtr fd, byte* buffer, int bufferSize); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] + internal static unsafe partial int Write(IntPtr fd, byte* buffer, int bufferSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Beep.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Beep.cs index 7c7c79e76899b..ed50f3346fce1 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Beep.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Beep.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool Beep(int frequency, int duration); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool Beep(int frequency, int duration); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConsoleCursorInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConsoleCursorInfo.cs index 5b34e2210b965..38c4419699a3e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConsoleCursorInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConsoleCursorInfo.cs @@ -12,13 +12,13 @@ internal static partial class Kernel32 internal struct CONSOLE_CURSOR_INFO { internal int dwSize; - internal bool bVisible; + internal BOOL bVisible; } - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool GetConsoleCursorInfo(IntPtr hConsoleOutput, out CONSOLE_CURSOR_INFO cci); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool GetConsoleCursorInfo(IntPtr hConsoleOutput, out CONSOLE_CURSOR_INFO cci); - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetConsoleCursorInfo(IntPtr hConsoleOutput, ref CONSOLE_CURSOR_INFO cci); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleCursorInfo(IntPtr hConsoleOutput, ref CONSOLE_CURSOR_INFO cci); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs index 4a1657f02119a..5cad2a13ba0b0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode)] - internal static extern bool FillConsoleOutputAttribute(IntPtr hConsoleOutput, short wColorAttribute, int numCells, COORD startCoord, out int pNumBytesWritten); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial bool FillConsoleOutputAttribute(IntPtr hConsoleOutput, short wColorAttribute, int numCells, COORD startCoord, out int pNumBytesWritten); } } 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 5b5f6ac477246..3bb435cad7468 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 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FillConsoleOutputCharacterW")] - internal static extern bool FillConsoleOutputCharacter(IntPtr hConsoleOutput, char character, int nLength, COORD dwWriteCoord, out int pNumCharsWritten); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FillConsoleOutputCharacterW")] + 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.FormatMessage.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs index 53b0ad25573dd..6b90203adf5b7 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs @@ -15,6 +15,17 @@ internal static partial class Kernel32 private const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; private const int ERROR_INSUFFICIENT_BUFFER = 0x7A; +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, ExactSpelling = true)] + private static unsafe partial int FormatMessage( + int dwFlags, + IntPtr lpSource, + uint dwMessageId, + int dwLanguageId, + void* lpBuffer, + int nSize, + IntPtr arguments); +#else [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, BestFitMapping = true, ExactSpelling = true)] private static extern unsafe int FormatMessage( int dwFlags, @@ -24,6 +35,7 @@ private static extern unsafe int FormatMessage( void* lpBuffer, int nSize, IntPtr arguments); +#endif /// /// Returns a string message for the specified Win32 error code. diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleMode.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleMode.cs index 99e725c885bfb..b03d88f475094 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleMode.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleMode.cs @@ -8,8 +8,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool GetConsoleMode(IntPtr handle, out int mode); +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool GetConsoleMode(IntPtr handle, out int mode); +#endif internal static bool IsGetConsoleModeCallSuccessful(IntPtr handle) { @@ -17,8 +22,13 @@ internal static bool IsGetConsoleModeCallSuccessful(IntPtr handle) return GetConsoleMode(handle, out mode); } +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleMode(IntPtr handle, int mode); +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool SetConsoleMode(IntPtr handle, int mode); +#endif internal const int ENABLE_PROCESSED_INPUT = 0x0001; internal const uint ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004; diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleScreenBufferInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleScreenBufferInfo.cs index b782fb94d391b..3ff5965ac77d3 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleScreenBufferInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleScreenBufferInfo.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool GetConsoleScreenBufferInfo(IntPtr hConsoleOutput, out CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool GetConsoleScreenBufferInfo(IntPtr hConsoleOutput, out CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo); } } 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 39f7ef1e4678e..bfeac321ec592 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 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] - internal static extern unsafe uint GetConsoleTitleW(char* title, uint nSize); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] + internal static unsafe partial uint GetConsoleTitleW(char* title, uint nSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_IntPtr.cs index 313ca31e97dd5..1a2e5432e3a6a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_IntPtr.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern uint GetFileType(IntPtr hFile); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial uint GetFileType(IntPtr hFile); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLargestConsoleWindowSize.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLargestConsoleWindowSize.cs index d26a2d924f5c1..ca7bf2b5ef48a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLargestConsoleWindowSize.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLargestConsoleWindowSize.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern Interop.Kernel32.COORD GetLargestConsoleWindowSize(IntPtr hConsoleOutput); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial Interop.Kernel32.COORD GetLargestConsoleWindowSize(IntPtr hConsoleOutput); } } 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 98ef5c59c7898..ed972c79dcc72 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 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PeekConsoleInputW")] - internal static extern bool PeekConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PeekConsoleInputW")] + 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 1ef39b4465df2..adfd028aade3b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsole.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsole.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "ReadConsoleW")] - internal static extern unsafe bool ReadConsole( + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "ReadConsoleW")] + internal static unsafe partial bool ReadConsole( IntPtr hConsoleInput, byte* lpBuffer, int nNumberOfCharsToRead, 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 413ad3d88042f..a2fb18ecc76df 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs @@ -16,7 +16,7 @@ internal struct KeyEventRecord internal short repeatCount; internal short virtualKeyCode; internal short virtualScanCode; - internal char uChar; // Union between WCHAR and ASCII char + internal ushort uChar; // Union between WCHAR and ASCII char internal int controlKeyState; } @@ -33,8 +33,8 @@ internal struct InputRecord internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "ReadConsoleInputW")] - internal static extern bool ReadConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "ReadConsoleInputW")] + 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 5a40457dc5f26..c755198df6914 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; } - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "ReadConsoleOutputW")] - internal static extern unsafe bool ReadConsoleOutput(IntPtr hConsoleOutput, CHAR_INFO* pBuffer, COORD bufferSize, COORD bufferCoord, ref SMALL_RECT readRegion); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "ReadConsoleOutputW")] + 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.ReadFile_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_IntPtr.cs index 2ccefd764674a..6e8aa47a7f9ad 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_IntPtr.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe int ReadFile( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int ReadFile( IntPtr handle, byte* bytes, int numBytesToRead, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCP.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCP.cs index e7c2140d16beb..adf85070a1e3c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCP.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCP.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetConsoleCP(int codePage); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleCP(int codePage); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs index c6ee59a77a2b9..ff1e0f19ae69a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs @@ -14,7 +14,12 @@ internal static partial class Kernel32 internal delegate bool ConsoleCtrlHandlerRoutine(int controlType); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleCtrlHandler(ConsoleCtrlHandlerRoutine handler, bool addOrRemove); +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool SetConsoleCtrlHandler(ConsoleCtrlHandlerRoutine handler, bool addOrRemove); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCursorPosition.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCursorPosition.cs index 39a951b4399bb..78f6440e75ac2 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCursorPosition.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCursorPosition.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetConsoleCursorPosition(IntPtr hConsoleOutput, COORD cursorPosition); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleCursorPosition(IntPtr hConsoleOutput, COORD cursorPosition); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleOutputCP.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleOutputCP.cs index 81441a4a66012..3a705e51c8f67 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleOutputCP.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleOutputCP.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetConsoleOutputCP(int codePage); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleOutputCP(int codePage); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleScreenBufferSize.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleScreenBufferSize.cs index 7c55bf6b3c614..049a9821b988e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleScreenBufferSize.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleScreenBufferSize.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetConsoleScreenBufferSize(IntPtr hConsoleOutput, Interop.Kernel32.COORD size); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleScreenBufferSize(IntPtr hConsoleOutput, Interop.Kernel32.COORD size); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTextAttribute.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTextAttribute.cs index a4cfcd65b49a9..23bd38e24bf2c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTextAttribute.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleTextAttribute.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern int SetConsoleTextAttribute(IntPtr hConsoleOutput, short wAttributes); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial int SetConsoleTextAttribute(IntPtr hConsoleOutput, short wAttributes); } } 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 34fb5bf40e436..f25b7ba251130 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 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "SetConsoleTitleW")] - internal static extern bool SetConsoleTitle(string title); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "SetConsoleTitleW")] + internal static partial bool SetConsoleTitle(string title); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleWindowInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleWindowInfo.cs index ae87d60ffe9b2..af33386ca831c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleWindowInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleWindowInfo.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe bool SetConsoleWindowInfo(IntPtr hConsoleOutput, bool absolute, SMALL_RECT* consoleWindow); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial bool SetConsoleWindowInfo(IntPtr hConsoleOutput, bool absolute, SMALL_RECT* consoleWindow); } } 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 ed5cfee214666..bb56c3e165cdb 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsole.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteConsole.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "WriteConsoleW")] - internal static extern unsafe bool WriteConsole( + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "WriteConsoleW")] + internal static unsafe partial bool WriteConsole( IntPtr hConsoleOutput, byte* lpBuffer, int nNumberOfCharsToWrite, 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 47e03d8057633..9cb88c72fb14a 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 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "WriteConsoleOutputW")] - internal static extern unsafe bool WriteConsoleOutput(IntPtr hConsoleOutput, CHAR_INFO* buffer, COORD bufferSize, COORD bufferCoord, ref SMALL_RECT writeRegion); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "WriteConsoleOutputW")] + 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/Kernel32/Interop.WriteFile_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_IntPtr.cs index 7ebff795dcfb4..2c4e963dbc59d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_IntPtr.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe int WriteFile( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int WriteFile( IntPtr handle, byte* bytes, int numBytesToWrite, diff --git a/src/libraries/System.Console/src/System/ConsolePal.Windows.cs b/src/libraries/System.Console/src/System/ConsolePal.Windows.cs index dd74a7d826e97..238220d5d0b64 100644 --- a/src/libraries/System.Console/src/System/ConsolePal.Windows.cs +++ b/src/libraries/System.Console/src/System/ConsolePal.Windows.cs @@ -562,7 +562,7 @@ public static bool CursorVisible if (!Interop.Kernel32.GetConsoleCursorInfo(OutputHandle, out cci)) throw Win32Marshal.GetExceptionForWin32Error(Marshal.GetLastWin32Error()); - return cci.bVisible; + return cci.bVisible != Interop.BOOL.FALSE; } set { @@ -570,7 +570,7 @@ public static bool CursorVisible if (!Interop.Kernel32.GetConsoleCursorInfo(OutputHandle, out cci)) throw Win32Marshal.GetExceptionForWin32Error(Marshal.GetLastWin32Error()); - cci.bVisible = value; + cci.bVisible = value ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; if (!Interop.Kernel32.SetConsoleCursorInfo(OutputHandle, ref cci)) throw Win32Marshal.GetExceptionForWin32Error(Marshal.GetLastWin32Error()); } From 0fd1fa12f2d20b446b307ddcb2045f256042f0b5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 21 May 2021 11:36:55 -0700 Subject: [PATCH 090/161] Require that methods marked with GeneratedDllImport are in types that are marked partial and any parents of their containing types are also marked partial. (dotnet/runtimelab#1091) Commit migrated from https://github.com/dotnet/runtimelab/commit/53af4b5dfa7e4d77b34151523e82665974da329c --- .../AnalyzerReleases.Unshipped.md | 1 + .../Analyzers/AnalyzerDiagnostics.cs | 1 + .../Analyzers/GeneratedDllImportAnalyzer.cs | 32 +++++++++--- .../DllImportGenerator/DllImportGenerator.cs | 9 ++++ .../DllImportGenerator/Resources.Designer.cs | 27 ++++++++++ .../gen/DllImportGenerator/Resources.resx | 9 ++++ .../GeneratedDllImportAnalyzerTests.cs | 50 +++++++++++++++++++ 7 files changed, 123 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md index 2e88786cee8fa..87ac29a463b2f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/AnalyzerReleases.Unshipped.md @@ -21,3 +21,4 @@ DLLIMPORTGENANALYZER013 | Usage | Warning | GeneratedDllImportMissin DLLIMPORTGENANALYZER014 | Usage | Error | RefValuePropertyUnsupported DLLIMPORTGENANALYZER015 | Interoperability | Disabled | ConvertToGeneratedDllImportAnalyzer DLLIMPORTGENANALYZER016 | Usage | Error | GenericTypeMustBeClosed +DLLIMPORTGENANALYZER017 | Usage | Warning | GeneratedDllImportContainingTypeMissingModifiers diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs index 17a03e0447524..88a5f269f322d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs @@ -29,6 +29,7 @@ public static class Ids // GeneratedDllImport public const string GeneratedDllImportMissingRequiredModifiers = Prefix + "013"; + public const string GeneratedDllImportContaiingTypeMissingRequiredModifiers = Prefix + "017"; // Migration from DllImport to GeneratedDllImport public const string ConvertToGeneratedDllImport = Prefix + "015"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs index 3bedc018cf583..a0a0ceb3c67fd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs @@ -25,7 +25,17 @@ public class GeneratedDllImportAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.GeneratedDllImportMissingModifiersDescription))); - public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(GeneratedDllImportMissingModifiers); + public readonly static DiagnosticDescriptor GeneratedDllImportContainingTypeMissingModifiers = + new DiagnosticDescriptor( + Ids.GeneratedDllImportContaiingTypeMissingRequiredModifiers, + GetResourceString(nameof(Resources.GeneratedDllImportContainingTypeMissingModifiersTitle)), + GetResourceString(nameof(Resources.GeneratedDllImportContainingTypeMissingModifiersMessage)), + Category, + DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.GeneratedDllImportContainingTypeMissingModifiersDescription))); + + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(GeneratedDllImportMissingModifiers, GeneratedDllImportContainingTypeMissingModifiers); public override void Initialize(AnalysisContext context) { @@ -64,17 +74,27 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbo foreach (var reference in methodSymbol.DeclaringSyntaxReferences) { var syntax = reference.GetSyntax(context.CancellationToken); - var methodSyntax = syntax as MethodDeclarationSyntax; - if (methodSyntax == null) - continue; - - if (!methodSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) + if (syntax is MethodDeclarationSyntax methodSyntax && !methodSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) { // Must be marked partial context.ReportDiagnostic(methodSymbol.CreateDiagnostic(GeneratedDllImportMissingModifiers, methodSymbol.Name)); break; } } + + for (INamedTypeSymbol? typeSymbol = methodSymbol.ContainingType; typeSymbol is not null; typeSymbol = typeSymbol.ContainingType) + { + foreach (var reference in typeSymbol.DeclaringSyntaxReferences) + { + var syntax = reference.GetSyntax(context.CancellationToken); + if (syntax is TypeDeclarationSyntax typeSyntax && !typeSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) + { + // Must be marked partial + context.ReportDiagnostic(typeSymbol.CreateDiagnostic(GeneratedDllImportContainingTypeMissingModifiers, typeSymbol.Name)); + break; + } + } + } } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index f0a33362b3eb5..de2038f7a0979 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -285,6 +285,15 @@ public void OnVisitSyntaxNode(GeneratorSyntaxContext context) return; } + // Verify that the types the method is declared in are marked partial. + for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent) + { + if (!typeDecl.Modifiers.Any(SyntaxKind.PartialKeyword)) + { + return; + } + } + // Check if the method is marked with the GeneratedDllImport attribute. foreach (AttributeListSyntax listSyntax in methodSyntax.AttributeLists) { 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 87fac1a3e0ffa..2acea21707cac 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -249,6 +249,33 @@ internal static string CustomTypeMarshallingNativeToManagedUnsupported { } } + /// + /// Looks up a localized string similar to Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types.. + /// + internal static string GeneratedDllImportContainingTypeMissingModifiersDescription { + get { + return ResourceManager.GetString("GeneratedDllImportContainingTypeMissingModifiersDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type '{0}' contains methods marked with 'GeneratedDllImportAttribute' and should be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types.. + /// + internal static string GeneratedDllImportContainingTypeMissingModifiersMessage { + get { + return ResourceManager.GetString("GeneratedDllImportContainingTypeMissingModifiersMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'.. + /// + internal static string GeneratedDllImportContainingTypeMissingModifiersTitle { + get { + return ResourceManager.GetString("GeneratedDllImportContainingTypeMissingModifiersTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index f66d2945ad7a8..698f32820bf24 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -181,6 +181,15 @@ The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it. + + Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types. + + + Type '{0}' contains methods marked with 'GeneratedDllImportAttribute' and should be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types. + + + Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'. + Methods marked with 'GeneratedDllImportAttribute' should be 'static' and 'partial'. P/Invoke source generation will ignore methods that are not 'static' and 'partial'. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs index e05b24cf64fa9..63c5497902e20 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs @@ -139,5 +139,55 @@ partial class Test "; await VerifyCS.VerifyAnalyzerAsync(source); } + + [Theory] + [InlineData("class")] + [InlineData("struct")] + [InlineData("record")] + + public async Task NonPartialParentType_Diagnostic(string typeKind) + { + string source = $@" +using System.Runtime.InteropServices; +{typeKind} {{|#0:Test|}} +{{ + [GeneratedDllImport(""DoesNotExist"")] + static partial void {{|CS0751:Method2|}}(); +}} +"; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(GeneratedDllImportContainingTypeMissingModifiers) + .WithLocation(0) + .WithArguments("Test")); + } + + [Theory] + [InlineData("class")] + [InlineData("struct")] + [InlineData("record")] + + public async Task NonPartialGrandparentType_Diagnostic(string typeKind) + { + + string source = $@" +using System.Runtime.InteropServices; +{typeKind} {{|#0:Test|}} +{{ + partial class TestInner + {{ + [GeneratedDllImport(""DoesNotExist"")] + static partial void Method2(); + }} +}} +"; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(GeneratedDllImportContainingTypeMissingModifiers) + .WithLocation(0) + .WithArguments("Test")); + } } } \ No newline at end of file From 36955b1a89016cedc71523ce1b97c3d4fb97071e Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 25 May 2021 15:35:55 -0700 Subject: [PATCH 091/161] Use GeneratedDllImport in System.Security.Cryptography.Encoding (#53111) --- .../Interop.ASN1.cs | 20 +++++------ .../Interop.BIO.cs | 35 +++++++++---------- .../Interop.ERR.cs | 32 +++++++++-------- .../Interop.LookupFriendlyNameByOid.cs | 4 +-- .../Interop.X509Ext.cs | 16 ++++----- .../Common/src/Interop/Windows/BCrypt/Cng.cs | 14 ++++---- .../Crypt32/Interop.CryptFormatObject.cs | 22 ++++++------ .../Win32/SafeHandles/SafeBioHandle.Unix.cs | 2 +- 8 files changed, 74 insertions(+), 71 deletions(-) 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 a4bfc8d962154..1f5c911383873 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,14 +12,14 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Obj", CharSet = CharSet.Ansi)] - internal static extern SafeAsn1ObjectHandle ObjTxt2Obj(string s); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Obj", CharSet = CharSet.Ansi)] + internal static partial SafeAsn1ObjectHandle ObjTxt2Obj(string s); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjObj2Txt")] private static extern unsafe int ObjObj2Txt(byte* buf, int buf_len, IntPtr a); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetObjectDefinitionByName", CharSet = CharSet.Ansi)] - private static extern IntPtr CryptoNative_GetObjectDefinitionByName(string friendlyName); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetObjectDefinitionByName", CharSet = CharSet.Ansi)] + private static partial IntPtr CryptoNative_GetObjectDefinitionByName(string friendlyName); internal static IntPtr GetObjectDefinitionByName(string friendlyName) { IntPtr ret = CryptoNative_GetObjectDefinitionByName(friendlyName); @@ -38,18 +38,18 @@ internal static IntPtr GetObjectDefinitionByName(string friendlyName) [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Asn1ObjectFree")] internal static extern void Asn1ObjectFree(IntPtr o); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeAsn1BitString")] - internal static extern SafeAsn1BitStringHandle DecodeAsn1BitString(byte[] buf, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeAsn1BitString")] + internal static partial SafeAsn1BitStringHandle DecodeAsn1BitString(byte[] buf, int len); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Asn1BitStringFree")] internal static extern void Asn1BitStringFree(IntPtr o); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Asn1OctetStringNew")] - internal static extern SafeAsn1OctetStringHandle Asn1OctetStringNew(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Asn1OctetStringNew")] + internal static partial SafeAsn1OctetStringHandle Asn1OctetStringNew(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Asn1OctetStringSet")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Asn1OctetStringSet")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool Asn1OctetStringSet(SafeAsn1OctetStringHandle o, byte[] d, int len); + internal static partial bool Asn1OctetStringSet(SafeAsn1OctetStringHandle o, byte[] d, int len); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Asn1OctetStringFree")] internal static extern void Asn1OctetStringFree(IntPtr o); 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 bc5349745a845..c972c12d4f08d 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 @@ -9,35 +9,34 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CreateMemoryBio")] - internal static extern SafeBioHandle CreateMemoryBio(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CreateMemoryBio")] + internal static partial SafeBioHandle CreateMemoryBio(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioNewFile")] - internal static extern SafeBioHandle BioNewFile(string filename, string mode); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioNewFile", CharSet = CharSet.Ansi)] + internal static partial SafeBioHandle BioNewFile(string filename, string mode); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioDestroy")] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool BioDestroy(IntPtr a); + internal static extern int BioDestroy(IntPtr a); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioGets")] - internal static extern int BioGets(SafeBioHandle b, byte[] buf, int size); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioGets")] + internal static partial int BioGets(SafeBioHandle b, byte[] buf, int size); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioRead")] - internal static extern int BioRead(SafeBioHandle b, byte[] data, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioRead")] + internal static partial int BioRead(SafeBioHandle b, byte[] data, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] - internal static extern int BioWrite(SafeBioHandle b, byte[] data, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] + internal static partial int BioWrite(SafeBioHandle b, byte[] data, int len); internal static int BioWrite(SafeBioHandle b, ReadOnlySpan data) => BioWrite(b, ref MemoryMarshal.GetReference(data), data.Length); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] - private static extern int BioWrite(SafeBioHandle b, ref byte data, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] + private static partial int BioWrite(SafeBioHandle b, ref byte data, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetMemoryBioSize")] - internal static extern int GetMemoryBioSize(SafeBioHandle bio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetMemoryBioSize")] + internal static partial int GetMemoryBioSize(SafeBioHandle bio); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioCtrlPending")] - internal static extern int BioCtrlPending(SafeBioHandle bio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioCtrlPending")] + internal static partial int BioCtrlPending(SafeBioHandle bio); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs index 771a5ed4f88aa..3f77618d3d5c9 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs @@ -14,7 +14,7 @@ internal static partial class Crypto internal static extern ulong ErrClearError(); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrGetErrorAlloc")] - private static extern ulong ErrGetErrorAlloc([MarshalAs(UnmanagedType.Bool)] out bool isAllocFailure); + private static extern unsafe ulong ErrGetErrorAlloc(int* isAllocFailure); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrPeekError")] internal static extern ulong ErrPeekError(); @@ -53,19 +53,23 @@ internal static Exception CreateOpenSslCryptographicException() // Windows code and the OpenSSL-calling code, drain the queue // whenever an Exception is desired, and report the exception // related to the last value in the queue. - bool isAllocFailure; - ulong error = ErrGetErrorAlloc(out isAllocFailure); - ulong lastRead = error; - bool lastIsAllocFailure = isAllocFailure; - - // 0 (there's no named constant) is only returned when the calls - // to ERR_get_error exceed the calls to ERR_set_error. - while (lastRead != 0) + int isAllocFailure = 0; + ulong error = 0; + unsafe { - error = lastRead; - isAllocFailure = lastIsAllocFailure; - - lastRead = ErrGetErrorAlloc(out lastIsAllocFailure); + int lastIsAllocFailure = isAllocFailure; + while (true) + { + ulong lastRead = ErrGetErrorAlloc(&lastIsAllocFailure); + + // 0 (there's no named constant) is only returned when the calls + // to ERR_get_error exceed the calls to ERR_set_error. + if (lastRead == 0) + break; + + error = lastRead; + isAllocFailure = lastIsAllocFailure; + } } // If we're in an error flow which results in an Exception, but @@ -76,7 +80,7 @@ internal static Exception CreateOpenSslCryptographicException() return new CryptographicException(); } - if (isAllocFailure) + if (isAllocFailure != 0) { return new OutOfMemoryException(); } 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 f4cdbae5401f9..db1b67c63bcdb 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 { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_LookupFriendlyNameByOid")] - internal static extern int LookupFriendlyNameByOid(string oidValue, ref IntPtr friendlyNamePtr); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_LookupFriendlyNameByOid", CharSet = CharSet.Ansi)] + internal static partial int LookupFriendlyNameByOid(string oidValue, ref IntPtr friendlyNamePtr); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Ext.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Ext.cs index b3374cdf934c8..f3d47ec4c293a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Ext.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Ext.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionCreateByObj")] - internal static extern SafeX509ExtensionHandle X509ExtensionCreateByObj( + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionCreateByObj")] + internal static partial SafeX509ExtensionHandle X509ExtensionCreateByObj( SafeAsn1ObjectHandle oid, [MarshalAs(UnmanagedType.Bool)] bool isCritical, SafeAsn1OctetStringHandle data); @@ -18,21 +18,21 @@ internal static extern SafeX509ExtensionHandle X509ExtensionCreateByObj( [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionDestroy")] internal static extern int X509ExtensionDestroy(IntPtr x); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509V3ExtPrint")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509V3ExtPrint")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool X509V3ExtPrint(SafeBioHandle buf, SafeX509ExtensionHandle ext); + internal static partial bool X509V3ExtPrint(SafeBioHandle buf, SafeX509ExtensionHandle ext); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeX509BasicConstraints2Extension")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeX509BasicConstraints2Extension")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DecodeX509BasicConstraints2Extension( + internal static partial bool DecodeX509BasicConstraints2Extension( byte[] encoded, int encodedLength, [MarshalAs(UnmanagedType.Bool)] out bool certificateAuthority, [MarshalAs(UnmanagedType.Bool)] out bool hasPathLengthConstraint, out int pathLengthConstraint); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeExtendedKeyUsage")] - internal static extern SafeEkuExtensionHandle DecodeExtendedKeyUsage(byte[] buf, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeExtendedKeyUsage")] + internal static partial SafeEkuExtensionHandle DecodeExtendedKeyUsage(byte[] buf, int len); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ExtendedKeyUsageDestory")] internal static extern void ExtendedKeyUsageDestory(IntPtr a); diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs index 273a0a89863aa..5be6c3754f64d 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs @@ -119,16 +119,16 @@ private static Exception CreateCryptographicException(NTSTATUS ntStatus) internal static partial class Cng { - internal static class Interop + internal static partial class Interop { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - public static extern NTSTATUS BCryptOpenAlgorithmProvider(out SafeAlgorithmHandle phAlgorithm, string pszAlgId, string? pszImplementation, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + public static partial NTSTATUS BCryptOpenAlgorithmProvider(out SafeAlgorithmHandle phAlgorithm, string pszAlgId, string? pszImplementation, int dwFlags); - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - public static extern NTSTATUS BCryptSetProperty(SafeAlgorithmHandle hObject, string pszProperty, string pbInput, int cbInput, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + public static partial NTSTATUS BCryptSetProperty(SafeAlgorithmHandle hObject, string pszProperty, string pbInput, int cbInput, int dwFlags); - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode, EntryPoint = "BCryptSetProperty")] - private static extern NTSTATUS BCryptSetIntPropertyPrivate(SafeBCryptHandle hObject, string pszProperty, ref int pdwInput, int cbInput, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode, EntryPoint = "BCryptSetProperty")] + 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/Crypt32/Interop.CryptFormatObject.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptFormatObject.cs index b9c3418823084..4f75276fcb2eb 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptFormatObject.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptFormatObject.cs @@ -12,16 +12,16 @@ internal static partial class Crypt32 internal const int CRYPT_FORMAT_STR_MULTI_LINE = 0x00000001; internal const int CRYPT_FORMAT_STR_NO_HEX = 0x00000010; - [DllImport(Libraries.Crypt32, SetLastError = true, BestFitMapping = false)] - internal static extern unsafe bool CryptFormatObject( - [In] int dwCertEncodingType, // only valid value is X509_ASN_ENCODING - [In] int dwFormatType, // unused - pass 0. - [In] int dwFormatStrType, // select multiline - [In] IntPtr pFormatStruct, // unused - pass IntPtr.Zero - [In] byte* lpszStructType, // OID value - [In] byte[] pbEncoded, // Data to be formatted - [In] int cbEncoded, // Length of data to be formatted - [Out] void* pbFormat, // Receives formatted string. - [In, Out] ref int pcbFormat); // Sends/receives length of formatted string in bytes + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static unsafe partial bool CryptFormatObject( + int dwCertEncodingType, // only valid value is X509_ASN_ENCODING + int dwFormatType, // unused - pass 0. + int dwFormatStrType, // select multiline + IntPtr pFormatStruct, // unused - pass IntPtr.Zero + byte* lpszStructType, // OID value + byte[] pbEncoded, // Data to be formatted + int cbEncoded, // Length of data to be formatted + void* pbFormat, // Receives formatted string. + ref int pcbFormat); // Sends/receives length of formatted string in bytes } } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs index 8bfdb74716d78..a7961c34a67d1 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs @@ -31,7 +31,7 @@ protected override bool ReleaseHandle() } else { - return Interop.Crypto.BioDestroy(h); + return Interop.Crypto.BioDestroy(h) != 0; } } From efaa1fe2009b557de763d5951a974a7cf1e569ee Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 25 May 2021 15:36:11 -0700 Subject: [PATCH 092/161] Use GeneratedDllImport in System.Security.Cryptography.Algorithms (#53245) --- .../Interop.Evp.cs | 2 +- .../OSX/Interop.CoreFoundation.CFArray.cs | 8 +-- .../OSX/Interop.CoreFoundation.CFData.cs | 8 +-- .../OSX/Interop.CoreFoundation.CFError.cs | 8 +-- .../OSX/Interop.CoreFoundation.CFString.cs | 8 +-- .../src/Interop/OSX/Interop.CoreFoundation.cs | 16 ++--- .../Interop.Digest.cs | 22 +++---- .../Interop.Ecc.cs | 8 +-- .../Interop.Hmac.cs | 20 +++--- .../Interop.KeyAgree.cs | 4 +- .../Interop.Pbkdf2.cs | 5 +- .../Interop.RSA.cs | 32 +++++----- .../Interop.Random.cs | 4 +- .../Interop.SecErrMessage.cs | 4 +- .../Interop.SecKeyRef.cs | 16 ++--- .../Interop.SecKeyRef.macOS.cs | 8 +-- .../Interop.SignVerify.cs | 8 +-- .../Interop.Symmetric.cs | 16 ++--- .../Interop.ASN1.Nid.cs | 8 +-- .../Interop.Bignum.cs | 8 +-- .../Interop.Dsa.cs | 35 +++++----- .../Interop.EVP.Cipher.cs | 64 +++++++++---------- .../Interop.EVP.cs | 22 +++---- .../Interop.EcDsa.ImportExport.cs | 16 ++--- .../Interop.EcDsa.cs | 12 ++-- .../Interop.EcKey.cs | 19 +++--- .../Interop.EvpPkey.EcKey.cs | 8 +-- .../Interop.EvpPkey.Ecdh.cs | 8 +-- .../Interop.EvpPkey.Rsa.cs | 32 +++++----- .../Interop.EvpPkey.cs | 12 ++-- .../Interop.Hmac.cs | 20 +++--- .../Interop.RAND.cs | 5 +- .../Interop.Rsa.cs | 23 ++++--- .../BCrypt/Interop.BCryptCreateHash.cs | 4 +- .../BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs | 4 +- .../BCrypt/Interop.BCryptDuplicateHash.cs | 4 +- .../BCrypt/Interop.BCryptEncryptDecrypt.cs | 8 +-- .../BCrypt/Interop.BCryptFinishHash.cs | 4 +- .../Interop.BCryptGenerateSymmetricKey.cs | 8 +-- .../BCrypt/Interop.BCryptGetProperty.cs | 4 +- .../Windows/BCrypt/Interop.BCryptHashData.cs | 4 +- .../Windows/BCrypt/Interop.BCryptImportKey.cs | 4 +- .../BCrypt/Interop.BCryptKeyDerivation.cs | 4 +- .../Interop.BCryptOpenAlgorithmProvider.cs | 4 +- .../Windows/Crypt32/Interop.HashIdAlg.cs | 14 ++-- .../Windows/NCrypt/Interop.EncryptDecrypt.cs | 8 +-- .../Interop/Windows/NCrypt/Interop.Keys.cs | 36 +++++------ .../NCrypt/Interop.NCryptDeriveKeyMaterial.cs | 10 +-- .../Interop.NCryptDeriveSecretAgreement.cs | 6 +- .../Interop.NCryptOpenStorageProvider.cs | 4 +- .../Windows/NCrypt/Interop.Properties.cs | 10 +++ .../Windows/NCrypt/Interop.SignVerify.cs | 8 +-- .../Win32/SafeHandles/SafeDsaHandle.Unix.cs | 2 +- .../Win32/SafeHandles/SafeEcKeyHandle.Unix.cs | 2 +- .../Win32/SafeHandles/SafeRsaHandle.Unix.cs | 2 +- .../Cryptography/HashProviderDispenser.OSX.cs | 3 +- .../HashProviderDispenser.Unix.cs | 2 +- 57 files changed, 330 insertions(+), 318 deletions(-) diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs index 66eaaa6f7ef0f..393f1bd7ba59d 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs @@ -32,7 +32,7 @@ internal static int EvpDigestUpdate(SafeEvpMdCtxHandle ctx, ReadOnlySpan d internal static extern int EvpDigestCurrent(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestOneShot")] - internal static unsafe extern int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, ref uint mdSize); + internal static unsafe extern int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, uint* mdSize); [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdSize")] internal static extern int EvpMdSize(IntPtr md); diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFArray.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFArray.cs index 3c57e9f894291..aeba90d5bc546 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFArray.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFArray.cs @@ -13,13 +13,13 @@ internal static partial class Interop { internal static partial class CoreFoundation { - [DllImport(Libraries.CoreFoundationLibrary, EntryPoint = "CFArrayGetCount")] - private static extern CFIndex _CFArrayGetCount(SafeCFArrayHandle cfArray); + [GeneratedDllImport(Libraries.CoreFoundationLibrary, EntryPoint = "CFArrayGetCount")] + private static partial CFIndex _CFArrayGetCount(SafeCFArrayHandle cfArray); // Follows the "Get" version of the "Create" rule, so needs to return an IntPtr to // prevent CFRelease from being called on the SafeHandle close. - [DllImport(Libraries.CoreFoundationLibrary, EntryPoint = "CFArrayGetValueAtIndex")] - private static extern IntPtr CFArrayGetValueAtIndex(SafeCFArrayHandle cfArray, CFIndex index); + [GeneratedDllImport(Libraries.CoreFoundationLibrary, EntryPoint = "CFArrayGetValueAtIndex")] + private static partial IntPtr CFArrayGetValueAtIndex(SafeCFArrayHandle cfArray, CFIndex index); internal static long CFArrayGetCount(SafeCFArrayHandle cfArray) { diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFData.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFData.cs index 68e8164a539f5..f0775d72cadf9 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFData.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFData.cs @@ -13,11 +13,11 @@ internal static partial class Interop { internal static partial class CoreFoundation { - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern unsafe byte* CFDataGetBytePtr(SafeCFDataHandle cfData); + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static unsafe partial byte* CFDataGetBytePtr(SafeCFDataHandle cfData); - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern CFIndex CFDataGetLength(SafeCFDataHandle cfData); + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static partial CFIndex CFDataGetLength(SafeCFDataHandle cfData); internal static unsafe Span CFDataDangerousGetSpan(SafeCFDataHandle cfData) { diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFError.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFError.cs index 52c6507fb5438..056628a81e6ee 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFError.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFError.cs @@ -14,11 +14,11 @@ internal static partial class Interop { internal static partial class CoreFoundation { - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern CFIndex CFErrorGetCode(SafeCFErrorHandle cfError); + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static partial CFIndex CFErrorGetCode(SafeCFErrorHandle cfError); - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern SafeCFStringHandle CFErrorCopyDescription(SafeCFErrorHandle cfError); + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static partial SafeCFStringHandle CFErrorCopyDescription(SafeCFErrorHandle cfError); internal static int GetErrorCode(SafeCFErrorHandle cfError) { diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFString.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFString.cs index 8c19957f55b7a..152741605e086 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFString.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFString.cs @@ -15,13 +15,13 @@ internal static partial class CoreFoundation /// Returns the interior pointer of the cfString if it has the specified encoding. /// If it has the wrong encoding, or if the interior pointer isn't being shared for some reason, returns NULL /// - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern IntPtr CFStringGetCStringPtr( + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static partial IntPtr CFStringGetCStringPtr( SafeCFStringHandle cfString, CFStringBuiltInEncodings encoding); - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern SafeCFDataHandle CFStringCreateExternalRepresentation( + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static partial SafeCFDataHandle CFStringCreateExternalRepresentation( IntPtr alloc, SafeCFStringHandle theString, CFStringBuiltInEncodings encoding, diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs index 20fdcfd697313..11fe4891c4c99 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.cs @@ -47,8 +47,8 @@ private enum CFStringBuiltInEncodings : uint /// The encoding type. /// Whether or not a BOM is present. /// A CFStringRef on success, otherwise a SafeCreateHandle(IntPtr.Zero). - [DllImport(Interop.Libraries.CoreFoundationLibrary)] - private static extern SafeCreateHandle CFStringCreateWithBytes( + [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary)] + private static partial SafeCreateHandle CFStringCreateWithBytes( IntPtr alloc, IntPtr bytes, CFIndex numBytes, @@ -63,8 +63,8 @@ private static extern 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 - [DllImport(Interop.Libraries.CoreFoundationLibrary, CharSet = CharSet.Ansi)] - private static extern SafeCreateHandle CFStringCreateWithCString( + [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary, CharSet = CharSet.Ansi)] + private static partial SafeCreateHandle CFStringCreateWithCString( IntPtr allocator, string str, CFStringBuiltInEncodings encoding); @@ -77,8 +77,8 @@ private static extern 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 - [DllImport(Interop.Libraries.CoreFoundationLibrary, CharSet = CharSet.Ansi)] - private static extern SafeCreateHandle CFStringCreateWithCString( + [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary, CharSet = CharSet.Ansi)] + private static partial SafeCreateHandle CFStringCreateWithCString( IntPtr allocator, IntPtr str, CFStringBuiltInEncodings encoding); @@ -130,8 +130,8 @@ internal static unsafe SafeCreateHandle CFStringCreateFromSpan(ReadOnlySpanThe number of values in the array /// Should be IntPtr.Zero /// Returns a pointer to a CFArray on success; otherwise, returns IntPtr.Zero - [DllImport(Interop.Libraries.CoreFoundationLibrary)] - private static extern SafeCreateHandle CFArrayCreate( + [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary)] + private static partial SafeCreateHandle CFArrayCreate( IntPtr allocator, [MarshalAs(UnmanagedType.LPArray)] IntPtr[] values, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs index 144b66d2a1149..5a6939e0fb4b5 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs @@ -12,32 +12,32 @@ internal static partial class AppleCrypto [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestFree")] internal static extern void DigestFree(IntPtr handle); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestCreate")] - internal static extern SafeDigestCtxHandle DigestCreate(PAL_HashAlgorithm algorithm, out int cbDigest); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestCreate")] + internal static partial SafeDigestCtxHandle DigestCreate(PAL_HashAlgorithm algorithm, out int cbDigest); internal static int DigestUpdate(SafeDigestCtxHandle ctx, ReadOnlySpan data) => DigestUpdate(ctx, ref MemoryMarshal.GetReference(data), data.Length); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestUpdate")] - private static extern int DigestUpdate(SafeDigestCtxHandle ctx, ref byte pbData, int cbData); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestUpdate")] + private static partial int DigestUpdate(SafeDigestCtxHandle ctx, ref byte pbData, int cbData); internal static int DigestFinal(SafeDigestCtxHandle ctx, Span output) => DigestFinal(ctx, ref MemoryMarshal.GetReference(output), output.Length); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestFinal")] - private static extern int DigestFinal(SafeDigestCtxHandle ctx, ref byte pbOutput, int cbOutput); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestFinal")] + private static partial int DigestFinal(SafeDigestCtxHandle ctx, ref byte pbOutput, int cbOutput); internal static int DigestCurrent(SafeDigestCtxHandle ctx, Span output) => DigestCurrent(ctx, ref MemoryMarshal.GetReference(output), output.Length); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestCurrent")] - private static extern int DigestCurrent(SafeDigestCtxHandle ctx, ref byte pbOutput, int cbOutput); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestCurrent")] + private static partial int DigestCurrent(SafeDigestCtxHandle ctx, ref byte pbOutput, int cbOutput); [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestOneShot")] - internal static unsafe extern int DigestOneShot(PAL_HashAlgorithm algorithm, byte* pbData, int cbData, byte* pbOutput, int cbOutput, out int cbDigest); + internal static unsafe extern int DigestOneShot(PAL_HashAlgorithm algorithm, byte* pbData, int cbData, byte* pbOutput, int cbOutput, int* cbDigest); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestReset")] - internal static extern int DigestReset(SafeDigestCtxHandle ctx); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestReset")] + internal static partial int DigestReset(SafeDigestCtxHandle ctx); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ecc.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ecc.cs index 18e6f62cc04e1..d1a27c769eb32 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ecc.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ecc.cs @@ -11,15 +11,15 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_EccGenerateKey( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_EccGenerateKey( int keySizeInBits, out SafeSecKeyRefHandle pPublicKey, out SafeSecKeyRefHandle pPrivateKey, out SafeCFErrorHandle pErrorOut); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_EccGetKeySizeInBits")] - internal static extern long EccGetKeySizeInBits(SafeSecKeyRefHandle publicKey); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_EccGetKeySizeInBits")] + internal static partial long EccGetKeySizeInBits(SafeSecKeyRefHandle publicKey); internal static void EccGenerateKey( int keySizeInBits, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs index 9898f5821289c..7c75a84ab8414 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs @@ -12,29 +12,29 @@ internal static partial class AppleCrypto [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacFree")] internal static extern void HmacFree(IntPtr handle); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCreate")] - internal static extern SafeHmacHandle HmacCreate(PAL_HashAlgorithm algorithm, ref int cbDigest); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCreate")] + internal static partial SafeHmacHandle HmacCreate(PAL_HashAlgorithm algorithm, ref int cbDigest); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacInit")] - internal static extern int HmacInit(SafeHmacHandle ctx, [In] byte[] pbKey, int cbKey); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacInit")] + internal static partial int HmacInit(SafeHmacHandle ctx, byte[] pbKey, int cbKey); internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan data) => HmacUpdate(ctx, ref MemoryMarshal.GetReference(data), data.Length); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacUpdate")] - private static extern int HmacUpdate(SafeHmacHandle ctx, ref byte pbData, int cbData); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacUpdate")] + private static partial int HmacUpdate(SafeHmacHandle ctx, ref byte pbData, int cbData); internal static int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan output) => HmacFinal(ctx, ref MemoryMarshal.GetReference(output), output.Length); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacFinal")] - private static extern int HmacFinal(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacFinal")] + private static partial int HmacFinal(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput); internal static int HmacCurrent(SafeHmacHandle ctx, ReadOnlySpan output) => HmacCurrent(ctx, ref MemoryMarshal.GetReference(output), output.Length); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCurrent")] - private static extern int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCurrent")] + private static partial int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.KeyAgree.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.KeyAgree.cs index 379db2ee51264..703f72b7fafc2 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.KeyAgree.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.KeyAgree.cs @@ -12,8 +12,8 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_EcdhKeyAgree( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_EcdhKeyAgree( SafeSecKeyRefHandle privateKey, SafeSecKeyRefHandle publicKey, out SafeCFDataHandle cfDataOut, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs index 4eb5bfd57edfa..04fc12ac935e3 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs @@ -21,6 +21,7 @@ internal static unsafe void Pbkdf2( fixed (byte* pSalt = salt) fixed (byte* pDestination = destination) { + int ccStatus; int ret = AppleCryptoNative_Pbkdf2( prfAlgorithm, pPassword, @@ -30,7 +31,7 @@ internal static unsafe void Pbkdf2( iterations, pDestination, destination.Length, - out int ccStatus); + &ccStatus); if (ret == 0) { @@ -57,6 +58,6 @@ private static extern unsafe int AppleCryptoNative_Pbkdf2( int iterations, byte* derivedKey, int derivedKeyLen, - out int errorCode); + int* errorCode); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.RSA.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.RSA.cs index f0ebcf94d95e5..e3c68bed82480 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.RSA.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.RSA.cs @@ -12,31 +12,31 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_RsaGenerateKey( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_RsaGenerateKey( int keySizeInBits, out SafeSecKeyRefHandle pPublicKey, out SafeSecKeyRefHandle pPrivateKey, out SafeCFErrorHandle pErrorOut); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_RsaSignaturePrimitive( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_RsaSignaturePrimitive( SafeSecKeyRefHandle privateKey, ref byte pbData, int cbData, out SafeCFDataHandle pDataOut, out SafeCFErrorHandle pErrorOut); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_RsaVerificationPrimitive( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_RsaVerificationPrimitive( SafeSecKeyRefHandle publicKey, ref byte pbData, int cbData, out SafeCFDataHandle pDataOut, out SafeCFErrorHandle pErrorOut); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_RsaEncryptionPrimitive( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_RsaEncryptionPrimitive( SafeSecKeyRefHandle publicKey, ref byte pbData, int cbData, @@ -52,8 +52,8 @@ private static int RsaEncryptOaep( out SafeCFErrorHandle pErrorOut) => RsaEncryptOaep(publicKey, ref MemoryMarshal.GetReference(pbData), cbData, mgfAlgorithm, out pEncryptedOut, out pErrorOut); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaEncryptOaep")] - private static extern int RsaEncryptOaep( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaEncryptOaep")] + private static partial int RsaEncryptOaep( SafeSecKeyRefHandle publicKey, ref byte pbData, int cbData, @@ -69,8 +69,8 @@ private static int RsaEncryptPkcs( out SafeCFErrorHandle pErrorOut) => RsaEncryptPkcs(publicKey, ref MemoryMarshal.GetReference(pbData), cbData, out pEncryptedOut, out pErrorOut); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaEncryptPkcs")] - private static extern int RsaEncryptPkcs( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaEncryptPkcs")] + private static partial int RsaEncryptPkcs( SafeSecKeyRefHandle publicKey, ref byte pbData, int cbData, @@ -86,8 +86,8 @@ private static int RsaDecryptOaep( out SafeCFErrorHandle pErrorOut) => RsaDecryptOaep(publicKey, ref MemoryMarshal.GetReference(pbData), cbData, mgfAlgorithm, out pEncryptedOut, out pErrorOut); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaDecryptOaep")] - private static extern int RsaDecryptOaep( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaDecryptOaep")] + private static partial int RsaDecryptOaep( SafeSecKeyRefHandle publicKey, ref byte pbData, int cbData, @@ -103,8 +103,8 @@ private static int RsaDecryptPkcs( out SafeCFErrorHandle pErrorOut) => RsaDecryptPkcs(publicKey, ref MemoryMarshal.GetReference(pbData), cbData, out pEncryptedOut, out pErrorOut); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaDecryptPkcs")] - private static extern int RsaDecryptPkcs( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_RsaDecryptPkcs")] + private static partial int RsaDecryptPkcs( SafeSecKeyRefHandle publicKey, ref byte pbData, int cbData, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs index adde4ad378243..aceadb978eae5 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs @@ -14,7 +14,7 @@ internal static unsafe void GetRandomBytes(byte* pbBuffer, int count) Debug.Assert(count >= 0); int errorCode; - int ret = AppleCryptoNative_GetRandomBytes(pbBuffer, count, out errorCode); + int ret = AppleCryptoNative_GetRandomBytes(pbBuffer, count, &errorCode); if (ret == 0) { @@ -28,6 +28,6 @@ internal static unsafe void GetRandomBytes(byte* pbBuffer, int count) } [DllImport(Libraries.AppleCryptoNative)] - private static extern unsafe int AppleCryptoNative_GetRandomBytes(byte* buf, int num, out int errorCode); + private static extern unsafe int AppleCryptoNative_GetRandomBytes(byte* buf, int num, int* errorCode); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecErrMessage.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecErrMessage.cs index cb94d972a361b..f353c503f8d34 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecErrMessage.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecErrMessage.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative)] - private static extern SafeCFStringHandle AppleCryptoNative_SecCopyErrorMessageString(int osStatus); + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial SafeCFStringHandle AppleCryptoNative_SecCopyErrorMessageString(int osStatus); internal static string? GetSecErrorString(int osStatus) { diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.cs index a479faf2be559..a37ecbf9634b2 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.cs @@ -23,8 +23,8 @@ internal enum PAL_KeyAlgorithm : uint RSA = 2, } - [DllImport(Libraries.AppleCryptoNative)] - private static extern ulong AppleCryptoNative_SecKeyGetSimpleKeySizeInBytes(SafeSecKeyRefHandle publicKey); + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial ulong AppleCryptoNative_SecKeyGetSimpleKeySizeInBytes(SafeSecKeyRefHandle publicKey); private delegate int SecKeyTransform(ReadOnlySpan source, out SafeCFDataHandle outputHandle, out SafeCFErrorHandle errorHandle); @@ -154,8 +154,8 @@ internal static bool TrySecKeyCopyExternalRepresentation( } } - [DllImport(Libraries.AppleCryptoNative)] - private static unsafe extern int AppleCryptoNative_SecKeyCreateWithData( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static unsafe partial int AppleCryptoNative_SecKeyCreateWithData( byte* pKey, int cbKey, PAL_KeyAlgorithm keyAlgorithm, @@ -163,14 +163,14 @@ private static unsafe extern int AppleCryptoNative_SecKeyCreateWithData( out SafeSecKeyRefHandle pDataKey, out SafeCFErrorHandle pErrorOut); - [DllImport(Libraries.AppleCryptoNative)] - private static unsafe extern int AppleCryptoNative_SecKeyCopyExternalRepresentation( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static unsafe partial int AppleCryptoNative_SecKeyCopyExternalRepresentation( SafeSecKeyRefHandle key, out SafeCFDataHandle pDataOut, out SafeCFErrorHandle pErrorOut); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SecKeyCopyPublicKey")] - internal static unsafe extern SafeSecKeyRefHandle CopyPublicKey(SafeSecKeyRefHandle privateKey); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SecKeyCopyPublicKey")] + internal static unsafe partial SafeSecKeyRefHandle CopyPublicKey(SafeSecKeyRefHandle privateKey); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.macOS.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.macOS.cs index cb78aabd624e3..789415a0d5680 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.macOS.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SecKeyRef.macOS.cs @@ -26,8 +26,8 @@ ref MemoryMarshal.GetReference(pbKeyBlob), out ppKeyOut, out pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeyImportEphemeral( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeyImportEphemeral( ref byte pbKeyBlob, int cbKeyBlob, int isPrivateKey, @@ -61,8 +61,8 @@ internal static SafeSecKeyRefHandle ImportEphemeralKey(ReadOnlySpan keyBlo throw new CryptographicException(); } - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeyExport( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeyExport( SafeSecKeyRefHandle? key, int exportPrivate, SafeCreateHandle cfExportPassphrase, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SignVerify.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SignVerify.cs index 71ba802f4dae6..a612ce0f16c04 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SignVerify.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SignVerify.cs @@ -47,8 +47,8 @@ private static unsafe int AppleCryptoNative_SecKeyVerifySignature( } } - [DllImport(Libraries.AppleCryptoNative)] - private static unsafe extern int AppleCryptoNative_SecKeyVerifySignature( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static unsafe partial int AppleCryptoNative_SecKeyVerifySignature( SafeSecKeyRefHandle publicKey, byte* pbDataHash, int cbDataHash, @@ -79,8 +79,8 @@ private static unsafe int AppleCryptoNative_SecKeyCreateSignature( } } - [DllImport(Libraries.AppleCryptoNative)] - private static unsafe extern int AppleCryptoNative_SecKeyCreateSignature( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static unsafe partial int AppleCryptoNative_SecKeyCreateSignature( SafeSecKeyRefHandle privateKey, byte* pbDataHash, int cbDataHash, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs index 22f6e512109ed..bdd2a97f35abc 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs @@ -45,8 +45,8 @@ internal enum PAL_SymmetricOptions [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorFree")] internal static extern void CryptorFree(IntPtr handle); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorCreate")] - internal static extern unsafe int CryptorCreate( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorCreate")] + internal static unsafe partial int CryptorCreate( PAL_SymmetricOperation operation, PAL_SymmetricAlgorithm algorithm, PAL_ChainingMode chainingMode, @@ -58,8 +58,8 @@ internal static extern unsafe int CryptorCreate( out SafeAppleCryptorHandle cryptor, out int ccStatus); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorUpdate")] - internal static extern unsafe int CryptorUpdate( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorUpdate")] + internal static unsafe partial int CryptorUpdate( SafeAppleCryptorHandle cryptor, byte* pbData, int cbData, @@ -68,16 +68,16 @@ internal static extern unsafe int CryptorUpdate( out int cbWritten, out int ccStatus); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorFinal")] - internal static extern unsafe int CryptorFinal( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorFinal")] + internal static unsafe partial int CryptorFinal( SafeAppleCryptorHandle cryptor, byte* pbOutput, int cbOutput, out int cbWritten, out int ccStatus); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorReset")] - internal static extern unsafe int CryptorReset(SafeAppleCryptorHandle cryptor, byte* pbIv, out int ccStatus); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorReset")] + internal static unsafe partial int CryptorReset(SafeAppleCryptorHandle cryptor, byte* pbIv, out int ccStatus); } } 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 a0f7ef27de21d..3d5167912dcc6 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,11 +15,11 @@ internal static partial class Crypto internal const int NID_undef = 0; - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjSn2Nid", CharSet = CharSet.Ansi)] - internal static extern int ObjSn2Nid(string sn); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjSn2Nid", CharSet = CharSet.Ansi)] + internal static partial int ObjSn2Nid(string sn); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Nid", CharSet = CharSet.Ansi)] - private static extern int ObjTxt2Nid(string oid); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ObjTxt2Nid", CharSet = CharSet.Ansi)] + 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.Bignum.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs index 6d09f2d9810b8..b6eb67c99f023 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs @@ -16,11 +16,11 @@ internal static partial class Crypto [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumFromBinary")] private static extern unsafe IntPtr BigNumFromBinary(byte* s, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumToBinary")] - private static extern unsafe int BigNumToBinary(SafeBignumHandle a, byte* to); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumToBinary")] + private static unsafe partial int BigNumToBinary(SafeBignumHandle a, byte* to); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetBigNumBytes")] - private static extern int GetBigNumBytes(SafeBignumHandle a); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetBigNumBytes")] + private static partial int GetBigNumBytes(SafeBignumHandle a); private static unsafe IntPtr CreateBignumPtr(ReadOnlySpan bigEndianValue) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs index ff9140632d3fb..559fb650e0a3f 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs @@ -12,18 +12,17 @@ internal static partial class Interop internal static partial class Crypto { [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaUpRef")] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DsaUpRef(IntPtr dsa); + internal static extern int DsaUpRef(IntPtr dsa); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaDestroy")] internal static extern void DsaDestroy(IntPtr dsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaGenerateKey")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaGenerateKey")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DsaGenerateKey(out SafeDsaHandle dsa, int bits); + internal static partial bool DsaGenerateKey(out SafeDsaHandle dsa, int bits); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSizeSignature")] - private static extern int DsaSizeSignature(SafeDsaHandle dsa); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSizeSignature")] + private static partial int DsaSizeSignature(SafeDsaHandle dsa); /// /// Return the maximum size of the DER-encoded key in bytes. @@ -34,8 +33,8 @@ internal static int DsaEncodedSignatureSize(SafeDsaHandle dsa) return size; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSizeQ")] - private static extern int DsaSizeQ(SafeDsaHandle dsa); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSizeQ")] + private static partial int DsaSizeQ(SafeDsaHandle dsa); /// /// Return the size of the 'r' or 's' signature fields in bytes. @@ -47,8 +46,8 @@ internal static int DsaSignatureFieldSize(SafeDsaHandle dsa) return size; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSizeP")] - private static extern int DsaSizeP(SafeDsaHandle dsa); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSizeP")] + private static partial int DsaSizeP(SafeDsaHandle dsa); /// /// Return the size of the key in bytes. @@ -65,9 +64,9 @@ internal static int DsaKeySize(SafeDsaHandle dsa) internal static bool DsaSign(SafeDsaHandle dsa, ReadOnlySpan hash, Span refSignature, out int outSignatureLength) => DsaSign(dsa, ref MemoryMarshal.GetReference(hash), hash.Length, ref MemoryMarshal.GetReference(refSignature), out outSignatureLength); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSign")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSign")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool DsaSign(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte refSignature, out int outSignatureLength); + private static partial bool DsaSign(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte refSignature, out int outSignatureLength); internal static bool DsaVerify(SafeDsaHandle dsa, ReadOnlySpan hash, ReadOnlySpan signature) { @@ -83,9 +82,9 @@ ref MemoryMarshal.GetReference(signature), return ret; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaVerify")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaVerify")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool DsaVerify(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte signature, int signatureLength); + private static partial bool DsaVerify(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte signature, int signatureLength); internal static DSAParameters ExportDsaParameters(SafeDsaHandle key, bool includePrivateParameters) { @@ -144,9 +143,9 @@ internal static DSAParameters ExportDsaParameters(SafeDsaHandle key, bool includ } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetDsaParameters")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetDsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool GetDsaParameters( + private static partial bool GetDsaParameters( SafeDsaHandle key, out IntPtr p, out int p_cb, out IntPtr q, out int q_cb, @@ -154,9 +153,9 @@ private static extern bool GetDsaParameters( out IntPtr y, out int y_cb, out IntPtr x, out int x_cb); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaKeyCreateByExplicitParameters")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaKeyCreateByExplicitParameters")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DsaKeyCreateByExplicitParameters( + internal static partial bool DsaKeyCreateByExplicitParameters( out SafeDsaHandle dsa, byte[] p, int pLength, diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs index e7d0461346a20..f960ed7e881c5 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherCreate2")] - internal static extern SafeEvpCipherCtxHandle EvpCipherCreate( + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherCreate2")] + internal static partial SafeEvpCipherCtxHandle EvpCipherCreate( IntPtr cipher, ref byte key, int keyLength, @@ -18,13 +18,13 @@ internal static extern SafeEvpCipherCtxHandle EvpCipherCreate( ref byte iv, int enc); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherCreatePartial")] - internal static extern SafeEvpCipherCtxHandle EvpCipherCreatePartial( + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherCreatePartial")] + internal static partial SafeEvpCipherCtxHandle EvpCipherCreatePartial( IntPtr cipher); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetKeyAndIV")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetKeyAndIV")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherSetKeyAndIV( + private static partial bool EvpCipherSetKeyAndIV( SafeEvpCipherCtxHandle ctx, ref byte key, ref byte iv, @@ -46,9 +46,9 @@ ref MemoryMarshal.GetReference(iv), } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetGcmNonceLength")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetGcmNonceLength")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CryptoNative_EvpCipherSetGcmNonceLength( + private static partial bool CryptoNative_EvpCipherSetGcmNonceLength( SafeEvpCipherCtxHandle ctx, int nonceLength); internal static void EvpCipherSetGcmNonceLength(SafeEvpCipherCtxHandle ctx, int nonceLength) @@ -59,9 +59,9 @@ internal static void EvpCipherSetGcmNonceLength(SafeEvpCipherCtxHandle ctx, int } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetCcmNonceLength")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetCcmNonceLength")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CryptoNative_EvpCipherSetCcmNonceLength( + private static partial bool CryptoNative_EvpCipherSetCcmNonceLength( SafeEvpCipherCtxHandle ctx, int nonceLength); internal static void EvpCipherSetCcmNonceLength(SafeEvpCipherCtxHandle ctx, int nonceLength) @@ -75,21 +75,21 @@ internal static void EvpCipherSetCcmNonceLength(SafeEvpCipherCtxHandle ctx, int [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherDestroy")] internal static extern void EvpCipherDestroy(IntPtr ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherReset")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherReset")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpCipherReset(SafeEvpCipherCtxHandle ctx); + internal static partial bool EvpCipherReset(SafeEvpCipherCtxHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherCtxSetPadding")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherCtxSetPadding")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpCipherCtxSetPadding(SafeEvpCipherCtxHandle x, int padding); + internal static partial bool EvpCipherCtxSetPadding(SafeEvpCipherCtxHandle x, int padding); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherUpdate")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherUpdate")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherUpdate( + private static partial bool EvpCipherUpdate( SafeEvpCipherCtxHandle ctx, - ref byte @out, + ref byte output, out int outl, - ref byte @in, + ref byte input, int inl); internal static bool EvpCipherUpdate( @@ -115,9 +115,9 @@ internal static void EvpCipherSetInputLength(SafeEvpCipherCtxHandle ctx, int inp } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherFinalEx")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherFinalEx")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherFinalEx( + private static partial bool EvpCipherFinalEx( SafeEvpCipherCtxHandle ctx, ref byte outm, out int outl); @@ -130,9 +130,9 @@ internal static bool EvpCipherFinalEx( return EvpCipherFinalEx(ctx, ref MemoryMarshal.GetReference(output), out bytesWritten); } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherGetGcmTag")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherGetGcmTag")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherGetGcmTag( + private static partial bool EvpCipherGetGcmTag( SafeEvpCipherCtxHandle ctx, ref byte tag, int tagLength); @@ -145,9 +145,9 @@ internal static void EvpCipherGetGcmTag(SafeEvpCipherCtxHandle ctx, Span t } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherGetAeadTag")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherGetAeadTag")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherGetAeadTag( + private static partial bool EvpCipherGetAeadTag( SafeEvpCipherCtxHandle ctx, ref byte tag, int tagLength); @@ -160,9 +160,9 @@ internal static void EvpCipherGetAeadTag(SafeEvpCipherCtxHandle ctx, Span } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetGcmTag")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetGcmTag")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherSetGcmTag( + private static partial bool EvpCipherSetGcmTag( SafeEvpCipherCtxHandle ctx, ref byte tag, int tagLength); @@ -175,9 +175,9 @@ internal static void EvpCipherSetGcmTag(SafeEvpCipherCtxHandle ctx, ReadOnlySpan } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetAeadTag")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetAeadTag")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherSetAeadTag( + private static partial bool EvpCipherSetAeadTag( SafeEvpCipherCtxHandle ctx, ref byte tag, int tagLength); @@ -190,9 +190,9 @@ internal static void EvpCipherSetAeadTag(SafeEvpCipherCtxHandle ctx, ReadOnlySpa } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherGetCcmTag")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherGetCcmTag")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherGetCcmTag( + private static partial bool EvpCipherGetCcmTag( SafeEvpCipherCtxHandle ctx, ref byte tag, int tagLength); @@ -205,9 +205,9 @@ internal static void EvpCipherGetCcmTag(SafeEvpCipherCtxHandle ctx, Span t } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetCcmTag")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherSetCcmTag")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherSetCcmTag( + private static partial bool EvpCipherSetCcmTag( SafeEvpCipherCtxHandle ctx, ref byte tag, int tagLength); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs index bd6cf8bfb5b61..1c853dfb47cc2 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs @@ -10,29 +10,29 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdCtxCreate")] - internal static extern SafeEvpMdCtxHandle EvpMdCtxCreate(IntPtr type); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdCtxCreate")] + internal static partial SafeEvpMdCtxHandle EvpMdCtxCreate(IntPtr type); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdCtxDestroy")] internal static extern void EvpMdCtxDestroy(IntPtr ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestReset")] - internal static extern int EvpDigestReset(SafeEvpMdCtxHandle ctx, IntPtr type); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestReset")] + internal static partial int EvpDigestReset(SafeEvpMdCtxHandle ctx, IntPtr type); internal static int EvpDigestUpdate(SafeEvpMdCtxHandle ctx, ReadOnlySpan d, int cnt) => EvpDigestUpdate(ctx, ref MemoryMarshal.GetReference(d), cnt); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestUpdate")] - private static extern int EvpDigestUpdate(SafeEvpMdCtxHandle ctx, ref byte d, int cnt); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestUpdate")] + private static partial int EvpDigestUpdate(SafeEvpMdCtxHandle ctx, ref byte d, int cnt); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestFinalEx")] - internal static extern int EvpDigestFinalEx(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestFinalEx")] + internal static partial int EvpDigestFinalEx(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestCurrent")] - internal static extern int EvpDigestCurrent(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestCurrent")] + internal static partial int EvpDigestCurrent(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestOneShot")] - internal static unsafe extern int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, ref uint mdSize); + internal static unsafe extern int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, uint* mdSize); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdSize")] internal static extern int EvpMdSize(IntPtr md); 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 9687abdafdc01..0b23fc788b997 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,8 +11,8 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)] - private static extern int EcKeyCreateByKeyParameters( + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)] + private static partial int EcKeyCreateByKeyParameters( out SafeEcKeyHandle key, string oid, byte[]? qx, int qxLength, @@ -37,8 +37,8 @@ internal static SafeEcKeyHandle EcKeyCreateByKeyParameters( return key; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByExplicitParameters")] - internal static extern SafeEcKeyHandle EcKeyCreateByExplicitParameters( + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByExplicitParameters")] + internal static partial SafeEcKeyHandle EcKeyCreateByExplicitParameters( ECCurve.ECCurveType curveType, byte[]? qx, int qxLength, byte[]? qy, int qyLength, @@ -97,8 +97,8 @@ internal static SafeEcKeyHandle EcKeyCreateByExplicitCurve(ECCurve curve) } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_GetECKeyParameters( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_GetECKeyParameters( SafeEcKeyHandle key, bool includePrivate, out SafeBignumHandle qx_bn, out int x_cb, @@ -166,8 +166,8 @@ internal static ECParameters GetECKeyParameters( return parameters; } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_GetECCurveParameters( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_GetECCurveParameters( SafeEcKeyHandle key, bool includePrivate, out ECCurve.ECCurveType curveType, diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs index 9fa5f14055a38..77d7f78048927 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs @@ -12,9 +12,9 @@ internal static partial class Crypto internal static bool EcDsaSign(ReadOnlySpan dgst, Span sig, out int siglen, SafeEcKeyHandle ecKey) => EcDsaSign(ref MemoryMarshal.GetReference(dgst), dgst.Length, ref MemoryMarshal.GetReference(sig), out siglen, ecKey); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaSign")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaSign")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EcDsaSign(ref byte dgst, int dlen, ref byte sig, out int siglen, SafeEcKeyHandle ecKey); + private static partial bool EcDsaSign(ref byte dgst, int dlen, ref byte sig, out int siglen, SafeEcKeyHandle ecKey); internal static int EcDsaVerify(ReadOnlySpan dgst, ReadOnlySpan sigbuf, SafeEcKeyHandle ecKey) { @@ -39,12 +39,12 @@ ref MemoryMarshal.GetReference(sigbuf), * 0: incorrect signature * -1: error */ - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaVerify")] - private static extern int EcDsaVerify(ref byte dgst, int dgst_len, ref byte sigbuf, int sig_len, SafeEcKeyHandle ecKey); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaVerify")] + private static partial int EcDsaVerify(ref byte dgst, int dgst_len, ref byte sigbuf, int sig_len, SafeEcKeyHandle ecKey); // returns the maximum length of a DER encoded ECDSA signature created with this key. - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaSize")] - private static extern int CryptoNative_EcDsaSize(SafeEcKeyHandle ecKey); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaSize")] + private static partial int CryptoNative_EcDsaSize(SafeEcKeyHandle ecKey); internal static int EcDsaSize(SafeEcKeyHandle ecKey) { 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 ae841331f1e46..fa8b4f04a0d38 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,8 +10,8 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid")] - private static extern SafeEcKeyHandle CryptoNative_EcKeyCreateByOid(string oid); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid", CharSet = CharSet.Ansi)] + private static partial SafeEcKeyHandle CryptoNative_EcKeyCreateByOid(string oid); internal static SafeEcKeyHandle? EcKeyCreateByOid(string oid) { SafeEcKeyHandle handle = CryptoNative_EcKeyCreateByOid(oid); @@ -26,16 +26,15 @@ internal static partial class Crypto [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyDestroy")] internal static extern void EcKeyDestroy(IntPtr a); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyGenerateKey")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyGenerateKey")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EcKeyGenerateKey(SafeEcKeyHandle eckey); + internal static partial bool EcKeyGenerateKey(SafeEcKeyHandle eckey); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyUpRef")] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EcKeyUpRef(IntPtr r); + internal static extern int EcKeyUpRef(IntPtr r); - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_EcKeyGetSize(SafeEcKeyHandle ecKey, out int keySize); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_EcKeyGetSize(SafeEcKeyHandle ecKey, out int keySize); internal static int EcKeyGetSize(SafeEcKeyHandle key) { int keySize; @@ -47,8 +46,8 @@ internal static int EcKeyGetSize(SafeEcKeyHandle key) throw Interop.Crypto.CreateOpenSslCryptographicException(); } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyGetCurveName2")] - private static extern int CryptoNative_EcKeyGetCurveName(SafeEcKeyHandle ecKey, out int nid); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyGetCurveName2")] + private static partial int CryptoNative_EcKeyGetCurveName(SafeEcKeyHandle ecKey, out int nid); internal static string EcKeyGetCurveName(SafeEcKeyHandle key) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.EcKey.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.EcKey.cs index 54790cbf1728d..2d61d8b1cad4c 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.EcKey.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.EcKey.cs @@ -9,11 +9,11 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyGetEcKey")] - internal static extern SafeEcKeyHandle EvpPkeyGetEcKey(SafeEvpPKeyHandle pkey); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyGetEcKey")] + internal static partial SafeEcKeyHandle EvpPkeyGetEcKey(SafeEvpPKeyHandle pkey); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetEcKey")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetEcKey")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpPkeySetEcKey(SafeEvpPKeyHandle pkey, SafeEcKeyHandle key); + internal static partial bool EvpPkeySetEcKey(SafeEvpPKeyHandle pkey, SafeEcKeyHandle key); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs index 6e87f4e27e78e..a097a5bf31ad5 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs @@ -11,11 +11,11 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeyCtxCreate")] - internal static extern SafeEvpPKeyCtxHandle EvpPKeyCtxCreate(SafeEvpPKeyHandle pkey, SafeEvpPKeyHandle peerkey, out uint secretLength); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeyCtxCreate")] + internal static partial SafeEvpPKeyCtxHandle EvpPKeyCtxCreate(SafeEvpPKeyHandle pkey, SafeEvpPKeyHandle peerkey, out uint secretLength); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeyDeriveSecretAgreement")] - private static extern int EvpPKeyDeriveSecretAgreement( + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeyDeriveSecretAgreement")] + private static partial int EvpPKeyDeriveSecretAgreement( ref byte secret, uint secretLength, SafeEvpPKeyCtxHandle ctx); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs index c8849d343d9ce..486cade91628d 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative)] - private static extern SafeEvpPKeyHandle CryptoNative_RsaGenerateKey(int keySize); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial SafeEvpPKeyHandle CryptoNative_RsaGenerateKey(int keySize); internal static SafeEvpPKeyHandle RsaGenerateKey(int keySize) { @@ -27,8 +27,8 @@ internal static SafeEvpPKeyHandle RsaGenerateKey(int keySize) return pkey; } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_RsaDecrypt( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_RsaDecrypt( SafeEvpPKeyHandle pkey, ref byte source, int sourceLength, @@ -62,8 +62,8 @@ ref MemoryMarshal.GetReference(destination), return written; } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_RsaEncrypt( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_RsaEncrypt( SafeEvpPKeyHandle pkey, ref byte source, int sourceLength, @@ -97,8 +97,8 @@ ref MemoryMarshal.GetReference(destination), return written; } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_RsaSignHash( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_RsaSignHash( SafeEvpPKeyHandle pkey, RSASignaturePaddingMode paddingMode, IntPtr digestAlgorithm, @@ -132,8 +132,8 @@ ref MemoryMarshal.GetReference(destination), return written; } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_RsaVerifyHash( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_RsaVerifyHash( SafeEvpPKeyHandle pkey, RSASignaturePaddingMode paddingMode, IntPtr digestAlgorithm, @@ -172,15 +172,15 @@ ref MemoryMarshal.GetReference(signature), throw CreateOpenSslCryptographicException(); } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyGetRsa")] - internal static extern SafeRsaHandle EvpPkeyGetRsa(SafeEvpPKeyHandle pkey); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyGetRsa")] + internal static partial SafeRsaHandle EvpPkeyGetRsa(SafeEvpPKeyHandle pkey); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetRsa")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetRsa")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpPkeySetRsa(SafeEvpPKeyHandle pkey, SafeRsaHandle rsa); + internal static partial bool EvpPkeySetRsa(SafeEvpPKeyHandle pkey, SafeRsaHandle rsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetRsa")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetRsa")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpPkeySetRsa(SafeEvpPKeyHandle pkey, IntPtr rsa); + internal static partial bool EvpPkeySetRsa(SafeEvpPKeyHandle pkey, IntPtr rsa); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs index 8a3fc840b1610..d322e03e7a9e0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs @@ -9,16 +9,16 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyCreate")] - internal static extern SafeEvpPKeyHandle EvpPkeyCreate(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyCreate")] + internal static partial SafeEvpPKeyHandle EvpPkeyCreate(); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyDestroy")] internal static extern void EvpPkeyDestroy(IntPtr pkey); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeySize")] - internal static extern int EvpPKeySize(SafeEvpPKeyHandle pkey); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeySize")] + internal static partial int EvpPKeySize(SafeEvpPKeyHandle pkey); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_UpRefEvpPkey")] - internal static extern int UpRefEvpPkey(SafeEvpPKeyHandle handle); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_UpRefEvpPkey")] + internal static partial int UpRefEvpPkey(SafeEvpPKeyHandle handle); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs index 5638d20ae9d65..1aeef24ab7fe0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs @@ -9,25 +9,25 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacCreate")] - internal static extern SafeHmacCtxHandle HmacCreate(ref byte key, int keyLen, IntPtr md); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacCreate")] + internal static partial SafeHmacCtxHandle HmacCreate(ref byte key, int keyLen, IntPtr md); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacDestroy")] internal static extern void HmacDestroy(IntPtr ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacReset")] - internal static extern int HmacReset(SafeHmacCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacReset")] + internal static partial int HmacReset(SafeHmacCtxHandle ctx); internal static int HmacUpdate(SafeHmacCtxHandle ctx, ReadOnlySpan data, int len) => HmacUpdate(ctx, ref MemoryMarshal.GetReference(data), len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacUpdate")] - private static extern int HmacUpdate(SafeHmacCtxHandle ctx, ref byte data, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacUpdate")] + private static partial int HmacUpdate(SafeHmacCtxHandle ctx, ref byte data, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacFinal")] - internal static extern int HmacFinal(SafeHmacCtxHandle ctx, ref byte data, ref int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacFinal")] + internal static partial int HmacFinal(SafeHmacCtxHandle ctx, ref byte data, ref int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacCurrent")] - internal static extern int HmacCurrent(SafeHmacCtxHandle ctx, ref byte data, ref int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacCurrent")] + internal static partial int HmacCurrent(SafeHmacCtxHandle ctx, ref byte data, ref int len); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs index fc7f8956c4e4d..f01afda233ca6 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs @@ -12,11 +12,10 @@ internal static unsafe bool GetRandomBytes(byte* pbBuffer, int count) { Debug.Assert(count >= 0); - return CryptoNative_GetRandomBytes(pbBuffer, count); + return CryptoNative_GetRandomBytes(pbBuffer, count) != 0; } [DllImport(Libraries.CryptoNative)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern unsafe bool CryptoNative_GetRandomBytes(byte* buf, int num); + private static extern unsafe int CryptoNative_GetRandomBytes(byte* buf, int num); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Rsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Rsa.cs index 105258194845c..abaaf67fac757 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Rsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Rsa.cs @@ -11,12 +11,11 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_RsaCreate")] - internal static extern SafeRsaHandle RsaCreate(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_RsaCreate")] + internal static partial SafeRsaHandle RsaCreate(); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_RsaUpRef")] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool RsaUpRef(IntPtr rsa); + internal static extern int RsaUpRef(IntPtr rsa); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_RsaDestroy")] internal static extern void RsaDestroy(IntPtr rsa); @@ -24,11 +23,11 @@ internal static partial class Crypto internal static SafeRsaHandle DecodeRsaPublicKey(ReadOnlySpan buf) => DecodeRsaPublicKey(ref MemoryMarshal.GetReference(buf), buf.Length); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeRsaPublicKey")] - private static extern SafeRsaHandle DecodeRsaPublicKey(ref byte buf, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeRsaPublicKey")] + private static partial SafeRsaHandle DecodeRsaPublicKey(ref byte buf, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_RsaSize")] - internal static extern int RsaSize(SafeRsaHandle rsa); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_RsaSize")] + internal static partial int RsaSize(SafeRsaHandle rsa); internal static RSAParameters ExportRsaParameters(SafeEvpPKeyHandle key, bool includePrivateParameters) { @@ -92,9 +91,9 @@ internal static RSAParameters ExportRsaParameters(SafeRsaHandle key, bool includ } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetRsaParameters")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetRsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool GetRsaParameters( + private static partial bool GetRsaParameters( SafeRsaHandle key, out IntPtr n, out IntPtr e, @@ -105,9 +104,9 @@ private static extern bool GetRsaParameters( out IntPtr dmq1, out IntPtr iqmp); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetRsaParameters")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetRsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetRsaParameters( + internal static partial bool SetRsaParameters( SafeRsaHandle key, byte[]? n, int nLength, 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 bd3578a6a7b0d..619b9848fa13c 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCreateHash.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCreateHash.cs @@ -16,8 +16,8 @@ internal static NTSTATUS BCryptCreateHash(SafeBCryptAlgorithmHandle hAlgorithm, return BCryptCreateHash(hAlgorithm, out phHash, pbHashObject, cbHashObject, ref MemoryMarshal.GetReference(secret), cbSecret, dwFlags); } - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - private static extern NTSTATUS BCryptCreateHash(SafeBCryptAlgorithmHandle hAlgorithm, out SafeBCryptHashHandle phHash, IntPtr pbHashObject, int cbHashObject, ref byte pbSecret, int cbSecret, BCryptCreateHashFlags dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + private static partial NTSTATUS BCryptCreateHash(SafeBCryptAlgorithmHandle hAlgorithm, out SafeBCryptHashHandle phHash, IntPtr pbHashObject, int cbHashObject, ref byte pbSecret, int cbSecret, BCryptCreateHashFlags dwFlags); [Flags] internal enum BCryptCreateHashFlags : int 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 88ff68b7ae1c2..6a1eaaaed7c98 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static extern unsafe NTSTATUS BCryptDeriveKeyPBKDF2( + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + internal static unsafe partial NTSTATUS BCryptDeriveKeyPBKDF2( SafeBCryptAlgorithmHandle hPrf, byte* pbPassword, int cbPassword, diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDuplicateHash.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDuplicateHash.cs index 5635873ad17e5..fe03585bf9b41 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDuplicateHash.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDuplicateHash.cs @@ -23,8 +23,8 @@ internal static SafeBCryptHashHandle BCryptDuplicateHash(SafeBCryptHashHandle hH return newHash; } - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - private static extern NTSTATUS BCryptDuplicateHash( + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + private static partial NTSTATUS BCryptDuplicateHash( SafeBCryptHashHandle hHash, out SafeBCryptHashHandle phNewHash, IntPtr pbHashObject, diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptEncryptDecrypt.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptEncryptDecrypt.cs index 4cb1a123bc4e6..5ebad79983143 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptEncryptDecrypt.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptEncryptDecrypt.cs @@ -53,10 +53,10 @@ internal static int BCryptDecrypt(SafeKeyHandle hKey, ReadOnlySpan input, } } - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - public static extern unsafe NTSTATUS BCryptEncrypt(SafeKeyHandle hKey, byte* pbInput, int cbInput, IntPtr paddingInfo, [In, Out] byte[]? pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + public static unsafe partial NTSTATUS BCryptEncrypt(SafeKeyHandle hKey, byte* pbInput, int cbInput, IntPtr paddingInfo, byte[]? pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags); - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - public static extern unsafe NTSTATUS BCryptDecrypt(SafeKeyHandle hKey, byte* pbInput, int cbInput, IntPtr paddingInfo, [In, Out] byte[]? pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + public static unsafe partial NTSTATUS BCryptDecrypt(SafeKeyHandle hKey, byte* pbInput, int cbInput, IntPtr paddingInfo, byte[]? pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptFinishHash.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptFinishHash.cs index bf1b5a6571290..c91997b7af244 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptFinishHash.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptFinishHash.cs @@ -12,7 +12,7 @@ internal static partial class BCrypt internal static NTSTATUS BCryptFinishHash(SafeBCryptHashHandle hHash, Span pbOutput, int cbOutput, int dwFlags) => BCryptFinishHash(hHash, ref MemoryMarshal.GetReference(pbOutput), cbOutput, dwFlags); - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - private static extern NTSTATUS BCryptFinishHash(SafeBCryptHashHandle hHash, ref byte pbOutput, int cbOutput, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + private static partial NTSTATUS BCryptFinishHash(SafeBCryptHashHandle hHash, ref byte pbOutput, int cbOutput, int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenerateSymmetricKey.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenerateSymmetricKey.cs index 2d3d2364b87ad..35cb2e8ea8b50 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenerateSymmetricKey.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenerateSymmetricKey.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static unsafe extern NTSTATUS BCryptGenerateSymmetricKey( + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + internal static unsafe partial NTSTATUS BCryptGenerateSymmetricKey( SafeBCryptAlgorithmHandle hAlgorithm, out SafeBCryptKeyHandle phKey, IntPtr pbKeyObject, @@ -19,8 +19,8 @@ internal static unsafe extern NTSTATUS BCryptGenerateSymmetricKey( int cbSecret, uint dwFlags); - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static unsafe extern NTSTATUS BCryptGenerateSymmetricKey( + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + internal static unsafe partial NTSTATUS BCryptGenerateSymmetricKey( nuint hAlgorithm, out SafeBCryptKeyHandle phKey, IntPtr pbKeyObject, 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 b052cfead2db4..f5429ac535a12 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 { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static extern unsafe NTSTATUS BCryptGetProperty(SafeBCryptHandle hObject, string pszProperty, void* pbOutput, int cbOutput, out int pcbResult, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + 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.BCryptHashData.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHashData.cs index 445a67b8f0f12..db9a126b48a99 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); - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - private static extern NTSTATUS BCryptHashData(SafeBCryptHashHandle hHash, ref byte pbInput, int cbInput, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + 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 5ee600d5283a9..13d709643a184 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptImportKey.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptImportKey.cs @@ -47,7 +47,7 @@ private struct BCRYPT_KEY_DATA_BLOB_HEADER public const uint BCRYPT_KEY_DATA_BLOB_VERSION1 = 0x1; } - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - private static extern NTSTATUS BCryptImportKey(SafeAlgorithmHandle hAlgorithm, IntPtr hImportKey, string pszBlobType, out SafeKeyHandle hKey, IntPtr pbKeyObject, int cbKeyObject, byte[] pbInput, int cbInput, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + private static 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.BCryptKeyDerivation.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptKeyDerivation.cs index e9c93a367908d..9a0e6604f3bcb 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptKeyDerivation.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptKeyDerivation.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static unsafe extern NTSTATUS BCryptKeyDerivation( + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + internal static unsafe partial NTSTATUS BCryptKeyDerivation( SafeBCryptKeyHandle hKey, BCryptBufferDesc* pParameterList, byte* pbDerivedKey, 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 65b457f046ed0..a0bb0c9e35ee9 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptOpenAlgorithmProvider.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptOpenAlgorithmProvider.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static extern NTSTATUS BCryptOpenAlgorithmProvider(out SafeBCryptAlgorithmHandle phAlgorithm, string pszAlgId, string? pszImplementation, BCryptOpenAlgorithmProviderFlags dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + internal static partial NTSTATUS BCryptOpenAlgorithmProvider(out SafeBCryptAlgorithmHandle phAlgorithm, string pszAlgId, string? pszImplementation, BCryptOpenAlgorithmProviderFlags dwFlags); [Flags] internal enum BCryptOpenAlgorithmProviderFlags : int diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs index d9aac15e5d311..926d8f463024e 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs @@ -13,15 +13,19 @@ internal static partial class Crypt32 /// Version used for a buffer containing a scalar integer (not an IntPtr) /// [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode)] - private static extern IntPtr CryptFindOIDInfo(CryptOidInfoKeyType dwKeyType, ref int pvKey, OidGroup group); + private static unsafe extern IntPtr CryptFindOIDInfo(CryptOidInfoKeyType dwKeyType, int* pvKey, OidGroup group); public static CRYPT_OID_INFO FindAlgIdOidInfo(Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM algId) { int intAlgId = (int)algId; - IntPtr fullOidInfo = CryptFindOIDInfo( - CryptOidInfoKeyType.CRYPT_OID_INFO_ALGID_KEY, - ref intAlgId, - OidGroup.HashAlgorithm); + IntPtr fullOidInfo; + unsafe + { + fullOidInfo = CryptFindOIDInfo( + CryptOidInfoKeyType.CRYPT_OID_INFO_ALGID_KEY, + &intAlgId, + OidGroup.HashAlgorithm); + } if (fullOidInfo != IntPtr.Zero) { diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.EncryptDecrypt.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.EncryptDecrypt.cs index 5382193fcd0c9..7013035c7e2fb 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.EncryptDecrypt.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.EncryptDecrypt.cs @@ -12,13 +12,13 @@ internal static partial class NCrypt internal static unsafe ErrorCode NCryptEncrypt(SafeNCryptKeyHandle hKey, ReadOnlySpan pbInput, int cbInput, void* pPaddingInfo, Span pbOutput, int cbOutput, out int pcbResult, AsymmetricPaddingMode dwFlags) => NCryptEncrypt(hKey, ref MemoryMarshal.GetReference(pbInput), cbInput, pPaddingInfo, ref MemoryMarshal.GetReference(pbOutput), cbOutput, out pcbResult, dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - private static extern unsafe ErrorCode NCryptEncrypt(SafeNCryptKeyHandle hKey, ref byte pbInput, int cbInput, void* pPaddingInfo, ref byte pbOutput, int cbOutput, out int pcbResult, AsymmetricPaddingMode dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + private static unsafe partial ErrorCode NCryptEncrypt(SafeNCryptKeyHandle hKey, ref byte pbInput, int cbInput, void* pPaddingInfo, ref byte pbOutput, int cbOutput, out int pcbResult, AsymmetricPaddingMode dwFlags); internal static unsafe ErrorCode NCryptDecrypt(SafeNCryptKeyHandle hKey, ReadOnlySpan pbInput, int cbInput, void* pPaddingInfo, Span pbOutput, int cbOutput, out int pcbResult, AsymmetricPaddingMode dwFlags) => NCryptDecrypt(hKey, ref MemoryMarshal.GetReference(pbInput), cbInput, pPaddingInfo, ref MemoryMarshal.GetReference(pbOutput), cbOutput, out pcbResult, dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - private static extern unsafe ErrorCode NCryptDecrypt(SafeNCryptKeyHandle hKey, ref byte pbInput, int cbInput, void* pPaddingInfo, ref byte pbOutput, int cbOutput, out int pcbResult, AsymmetricPaddingMode dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + private static unsafe partial ErrorCode NCryptDecrypt(SafeNCryptKeyHandle hKey, ref byte pbInput, int cbInput, void* pPaddingInfo, ref byte pbOutput, int cbOutput, out int pcbResult, AsymmetricPaddingMode dwFlags); } } 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 08ff909431756..406e0177f8ecf 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Keys.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Keys.cs @@ -13,32 +13,32 @@ internal static partial class NCrypt { internal const string NCRYPT_PKCS8_PRIVATE_KEY_BLOB = "PKCS8_PRIVATEKEY"; - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptOpenKey(SafeNCryptProviderHandle hProvider, out SafeNCryptKeyHandle phKey, string pszKeyName, int dwLegacyKeySpec, CngKeyOpenOptions dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptOpenKey(SafeNCryptProviderHandle hProvider, out SafeNCryptKeyHandle phKey, string pszKeyName, int dwLegacyKeySpec, CngKeyOpenOptions dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptImportKey(SafeNCryptProviderHandle hProvider, IntPtr hImportKey, string pszBlobType, IntPtr pParameterList, [Out] out SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptImportKey(SafeNCryptProviderHandle hProvider, IntPtr hImportKey, string pszBlobType, IntPtr pParameterList, out SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptImportKey(SafeNCryptProviderHandle hProvider, IntPtr hImportKey, string pszBlobType, ref NCryptBufferDesc pParameterList, [Out] out SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptImportKey(SafeNCryptProviderHandle hProvider, IntPtr hImportKey, string pszBlobType, ref NCryptBufferDesc pParameterList, out SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, IntPtr pParameterList, [Out] byte[]? pbOutput, int cbOutput, [Out] out int pcbResult, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, IntPtr pParameterList, byte[]? pbOutput, int cbOutput, out int pcbResult, int dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, IntPtr pParameterList, ref byte pbOutput, int cbOutput, [Out] out int pcbResult, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, IntPtr pParameterList, ref byte pbOutput, int cbOutput, out int pcbResult, int dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, ref NCryptBufferDesc pParameterList, ref byte pbOutput, int cbOutput, [Out] out int pcbResult, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptExportKey(SafeNCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, ref NCryptBufferDesc pParameterList, ref byte pbOutput, int cbOutput, out int pcbResult, int dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptDeleteKey(SafeNCryptKeyHandle hKey, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptDeleteKey(SafeNCryptKeyHandle hKey, int dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptCreatePersistedKey(SafeNCryptProviderHandle hProvider, out SafeNCryptKeyHandle phKey, string pszAlgId, string? pszKeyName, int dwLegacyKeySpec, CngKeyCreationOptions dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptCreatePersistedKey(SafeNCryptProviderHandle hProvider, out SafeNCryptKeyHandle phKey, string pszAlgId, string? pszKeyName, int dwLegacyKeySpec, CngKeyCreationOptions dwFlags); - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptFinalizeKey(SafeNCryptKeyHandle hKey, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static partial ErrorCode NCryptFinalizeKey(SafeNCryptKeyHandle hKey, int dwFlags); [StructLayout(LayoutKind.Sequential)] internal struct CRYPT_PKCS12_PBE_PARAMS 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 2c7bfbd434d9a..f0fa8ff23249a 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs @@ -15,14 +15,14 @@ internal static partial class NCrypt /// /// Generate a key from a secret agreement /// - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - private static extern ErrorCode NCryptDeriveKey( + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + private static partial ErrorCode NCryptDeriveKey( SafeNCryptSecretHandle hSharedSecret, string pwszKDF, - [In] ref NCryptBufferDesc pParameterList, - [Out, MarshalAs(UnmanagedType.LPArray)] byte[]? pbDerivedKey, + ref NCryptBufferDesc pParameterList, + [MarshalAs(UnmanagedType.LPArray)] byte[]? pbDerivedKey, int cbDerivedKey, - [Out] out int pcbResult, + out int pcbResult, SecretAgreementFlags dwFlags); /// diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveSecretAgreement.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveSecretAgreement.cs index 422f9537ff36f..6c5b2a70cf2a4 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveSecretAgreement.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveSecretAgreement.cs @@ -20,11 +20,11 @@ internal enum SecretAgreementFlags /// /// Generate a secret agreement for generating shared key material /// - [DllImport(Interop.Libraries.NCrypt)] - private static extern ErrorCode NCryptSecretAgreement( + [GeneratedDllImport(Interop.Libraries.NCrypt)] + private static partial ErrorCode NCryptSecretAgreement( SafeNCryptKeyHandle hPrivKey, SafeNCryptKeyHandle hPubKey, - [Out] out SafeNCryptSecretHandle phSecret, + out SafeNCryptSecretHandle phSecret, int dwFlags); 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 90e4a2e933380..97368d0550922 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 { - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptOpenStorageProvider(out SafeNCryptProviderHandle phProvider, string pszProviderName, int dwFlags); + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + 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 9c6ce0359c00a..6e68098bd535a 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs @@ -13,11 +13,21 @@ internal static partial class Interop { internal static partial class NCrypt { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static unsafe partial ErrorCode NCryptGetProperty(SafeNCryptHandle hObject, string pszProperty, void* pbOutput, int cbOutput, out int pcbResult, CngPropertyOptions dwFlags); +#else [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] internal static extern unsafe ErrorCode NCryptGetProperty(SafeNCryptHandle hObject, string pszProperty, [Out] void* pbOutput, int cbOutput, out int pcbResult, CngPropertyOptions dwFlags); +#endif +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] + internal static unsafe partial ErrorCode NCryptSetProperty(SafeNCryptHandle hObject, string pszProperty, void* pbInput, int cbInput, CngPropertyOptions dwFlags); +#else [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] internal static extern unsafe ErrorCode NCryptSetProperty(SafeNCryptHandle hObject, string pszProperty, [In] void* pbInput, int cbInput, CngPropertyOptions dwFlags); +#endif [SupportedOSPlatform("windows")] internal static unsafe ErrorCode NCryptGetByteProperty(SafeNCryptHandle hObject, string pszProperty, ref byte result, CngPropertyOptions options = CngPropertyOptions.None) 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 e6a23b5bac4d0..8e651c7277df8 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); - [DllImport(Libraries.NCrypt, CharSet = CharSet.Unicode)] - private static extern unsafe ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ref byte pbHashValue, int cbHashValue, ref byte pbSignature, int cbSignature, out int pcbResult, AsymmetricPaddingMode dwFlags); + [GeneratedDllImport(Libraries.NCrypt, CharSet = CharSet.Unicode)] + 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); - [DllImport(Libraries.NCrypt, CharSet = CharSet.Unicode)] - private static extern unsafe ErrorCode NCryptVerifySignature(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ref byte pbHashValue, int cbHashValue, ref byte pbSignature, int cbSignature, AsymmetricPaddingMode dwFlags); + [GeneratedDllImport(Libraries.NCrypt, CharSet = CharSet.Unicode)] + 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/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs index 0899f2f1938b9..4af8065ab7d81 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs @@ -35,7 +35,7 @@ internal static SafeDsaHandle DuplicateHandle(IntPtr handle) // that we don't lose a tracked reference in low-memory situations. SafeDsaHandle safeHandle = new SafeDsaHandle(); - if (!Interop.Crypto.DsaUpRef(handle)) + if (Interop.Crypto.DsaUpRef(handle) == 0) { throw Interop.Crypto.CreateOpenSslCryptographicException(); } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs index 1a72392bd08aa..b307f9cfc139b 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs @@ -35,7 +35,7 @@ internal static SafeEcKeyHandle DuplicateHandle(IntPtr handle) // that we don't lose a tracked reference in low-memory situations. SafeEcKeyHandle safeHandle = new SafeEcKeyHandle(); - if (!Interop.Crypto.EcKeyUpRef(handle)) + if (Interop.Crypto.EcKeyUpRef(handle) == 0) { throw Interop.Crypto.CreateOpenSslCryptographicException(); } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeRsaHandle.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeRsaHandle.Unix.cs index aef516adb3a30..3e6d67f793bdf 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeRsaHandle.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeRsaHandle.Unix.cs @@ -35,7 +35,7 @@ internal static SafeRsaHandle DuplicateHandle(IntPtr handle) // that we don't lose a tracked reference in low-memory situations. SafeRsaHandle safeHandle = new SafeRsaHandle(); - if (!Interop.Crypto.RsaUpRef(handle)) + if (Interop.Crypto.RsaUpRef(handle) == 0) { throw Interop.Crypto.CreateOpenSslCryptographicException(); } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs index 3a9901337f9c6..f21223555f0f7 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs @@ -40,13 +40,14 @@ public static unsafe int HashData(string hashAlgorithmId, ReadOnlySpan sou fixed (byte* pSource = source) fixed (byte* pDestination = destination) { + int digestSize; int ret = Interop.AppleCrypto.DigestOneShot( algorithm, pSource, source.Length, pDestination, destination.Length, - out int digestSize); + &digestSize); if (ret != 1) { diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.Unix.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.Unix.cs index af984e5344557..d25981e7c1e35 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.Unix.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.Unix.cs @@ -39,7 +39,7 @@ public static unsafe int HashData(string hashAlgorithmId, ReadOnlySpan sou fixed (byte* pDestination = destination) { uint length = (uint)destination.Length; - Check(Interop.Crypto.EvpDigestOneShot(evpType, pSource, source.Length, pDestination, ref length)); + Check(Interop.Crypto.EvpDigestOneShot(evpType, pSource, source.Length, pDestination, &length)); Debug.Assert(length == hashSize); } From 4f834bc880d6bf454f3c53e268a06133d3000b6e Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 26 May 2021 18:02:23 -0700 Subject: [PATCH 093/161] Use GeneratedDllImport in System.Security.Cryptography.X509Certificates (#53259) --- .../OSX/Interop.CoreFoundation.CFDate.cs | 4 +- .../Interop.Keychain.macOS.cs | 44 ++--- .../Interop.Trust.cs | 16 +- .../Interop.X509.cs | 32 ++-- .../Interop.X509.macOS.cs | 20 +- .../Interop.X509Chain.cs | 36 ++-- .../Unix/System.Native/Interop.FChMod.cs | 4 +- .../Unix/System.Native/Interop.ReadLink.cs | 4 +- .../Interop.ASN1.GetIntegerBytes.cs | 8 +- .../Interop.Crypto.cs | 68 +++---- .../Interop.EvpPkey.Dsa.cs | 8 +- .../Interop.OCSP.cs | 24 +-- .../Interop.Pkcs7.cs | 28 +-- .../Interop.X509.cs | 155 ++++++++------- .../Interop.X509Name.cs | 12 +- .../Interop.X509Stack.cs | 28 +-- .../Interop.X509StoreCtx.cs | 28 +-- .../Windows/BCrypt/Interop.BCryptExportKey.cs | 4 +- .../Windows/Crypt32/Interop.CertCloseStore.cs | 5 + .../Interop.CertFreeCertificateContext.cs | 5 + .../Windows/Crypt32/Interop.CertNameToStr.cs | 5 + .../Windows/Crypt32/Interop.CryptMsgClose.cs | 5 + .../Windows/Kernel32/Interop.FormatMessage.cs | 9 +- .../Windows/NCrypt/Interop.Properties.cs | 19 +- .../Pal.Unix/OpenSslX509CertificateReader.cs | 2 +- .../Pal.Windows/Native/Interop.crypt32.cs | 180 +++++++++--------- .../Pal.Windows/Native/Interop.cryptoapi.cs | 4 +- ...Cryptography.X509Certificates.Tests.csproj | 3 +- 28 files changed, 396 insertions(+), 364 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDate.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDate.cs index 4393796ef6add..e43e20d83f679 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDate.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDate.cs @@ -17,8 +17,8 @@ internal static partial class CoreFoundation // https://developer.apple.com/reference/corefoundation/cfabsolutetime private static readonly DateTime s_cfDateEpoch = new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc); - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern SafeCFDateHandle CFDateCreate(IntPtr zero, CFAbsoluteTime at); + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static partial SafeCFDateHandle CFDateCreate(IntPtr zero, CFAbsoluteTime at); internal static SafeCFDateHandle CFDateCreate(DateTime date) { 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 862760aa2c8de..2b2c6ce7e93ee 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 @@ -15,20 +15,20 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainItemCopyKeychain( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeychainItemCopyKeychain( IntPtr item, out SafeKeychainHandle keychain); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SecKeychainCreate")] - private static extern unsafe int AppleCryptoNative_SecKeychainCreateTemporary( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SecKeychainCreate", CharSet = CharSet.Ansi)] + private static unsafe partial int AppleCryptoNative_SecKeychainCreateTemporary( string path, int utf8PassphraseLength, byte* utf8Passphrase, out SafeTemporaryKeychainHandle keychain); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainCreate( + [GeneratedDllImport(Libraries.AppleCryptoNative, CharSet = CharSet.Ansi)] + private static partial int AppleCryptoNative_SecKeychainCreate( string path, int utf8PassphraseLength, byte[] utf8Passphrase, @@ -37,43 +37,43 @@ private static extern int AppleCryptoNative_SecKeychainCreate( [DllImport(Libraries.AppleCryptoNative)] private static extern int AppleCryptoNative_SecKeychainDelete(IntPtr keychain); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainCopyDefault(out SafeKeychainHandle keychain); + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeychainCopyDefault(out SafeKeychainHandle keychain); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainOpen( + [GeneratedDllImport(Libraries.AppleCryptoNative, CharSet = CharSet.Ansi)] + private static partial int AppleCryptoNative_SecKeychainOpen( string keychainPath, out SafeKeychainHandle keychain); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainUnlock( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeychainUnlock( SafeKeychainHandle keychain, int utf8PassphraseLength, byte[] utf8Passphrase); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SetKeychainNeverLock(SafeKeychainHandle keychain); + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SetKeychainNeverLock(SafeKeychainHandle keychain); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainEnumerateCerts( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeychainEnumerateCerts( SafeKeychainHandle keychain, out SafeCFArrayHandle matches, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainEnumerateIdentities( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeychainEnumerateIdentities( SafeKeychainHandle keychain, out SafeCFArrayHandle matches, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509StoreAddCertificate( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509StoreAddCertificate( SafeKeychainItemHandle cert, SafeKeychainHandle keychain, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509StoreRemoveCertificate( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509StoreRemoveCertificate( SafeKeychainItemHandle cert, SafeKeychainHandle keychain, bool isReadOnlyMode, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Trust.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Trust.cs index 1121a62553b0c..9a59dd089529b 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Trust.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Trust.cs @@ -11,23 +11,23 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_StoreEnumerateUserRoot( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_StoreEnumerateUserRoot( out SafeCFArrayHandle pCertsOut, out int pOSStatusOut); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_StoreEnumerateMachineRoot( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_StoreEnumerateMachineRoot( out SafeCFArrayHandle pCertsOut, out int pOSStatusOut); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_StoreEnumerateUserDisallowed( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_StoreEnumerateUserDisallowed( out SafeCFArrayHandle pCertsOut, out int pOSStatusOut); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_StoreEnumerateMachineDisallowed( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_StoreEnumerateMachineDisallowed( out SafeCFArrayHandle pCertsOut, out int pOSStatusOut); diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs index d50ca014c4e3a..04e1b1a01ed58 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs @@ -14,33 +14,41 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509GetRawData( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509GetRawData( SafeSecCertificateHandle cert, out SafeCFDataHandle cfDataOut, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509GetPublicKey(SafeSecCertificateHandle cert, out SafeSecKeyRefHandle publicKey, out int pOSStatus); + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509GetPublicKey(SafeSecCertificateHandle cert, out SafeSecKeyRefHandle publicKey, out int pOSStatus); internal static X509ContentType X509GetContentType(ReadOnlySpan data) - => X509GetContentType(ref MemoryMarshal.GetReference(data), data.Length); + { + unsafe + { + fixed (byte* dataPtr = &MemoryMarshal.GetReference(data)) + { + return X509GetContentType(dataPtr, data.Length); + } + } + } [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509GetContentType")] - private static extern X509ContentType X509GetContentType(ref byte pbData, int cbData); + private static unsafe extern X509ContentType X509GetContentType(byte* pbData, int cbData); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509CopyCertFromIdentity( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509CopyCertFromIdentity( SafeSecIdentityHandle identity, out SafeSecCertificateHandle cert); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509CopyPrivateKeyFromIdentity( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509CopyPrivateKeyFromIdentity( SafeSecIdentityHandle identity, out SafeSecKeyRefHandle key); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509DemuxAndRetainHandle( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509DemuxAndRetainHandle( IntPtr handle, out SafeSecCertificateHandle certHandle, out SafeSecIdentityHandle identityHandle); diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.macOS.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.macOS.cs index 3caca43d8ece6..785f9e6ad54ae 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.macOS.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.macOS.cs @@ -39,8 +39,8 @@ ref MemoryMarshal.GetReference(keyBlob), out pOSStatus); } - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509ImportCertificate( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509ImportCertificate( ref byte pbKeyBlob, int cbKeyBlob, X509ContentType contentType, @@ -51,8 +51,8 @@ private static extern int AppleCryptoNative_X509ImportCertificate( out SafeSecIdentityHandle pPrivateKeyOut, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509ImportCollection( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509ImportCollection( ref byte pbKeyBlob, int cbKeyBlob, X509ContentType contentType, @@ -62,24 +62,24 @@ private static extern int AppleCryptoNative_X509ImportCollection( out SafeCFArrayHandle pCollectionOut, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509ExportData( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509ExportData( SafeCreateHandle data, X509ContentType type, SafeCreateHandle cfExportPassphrase, out SafeCFDataHandle pExportOut, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509CopyWithPrivateKey( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509CopyWithPrivateKey( SafeSecCertificateHandle certHandle, SafeSecKeyRefHandle privateKeyHandle, SafeKeychainHandle targetKeychain, out SafeSecIdentityHandle pIdentityHandleOut, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509MoveToKeychain( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_X509MoveToKeychain( SafeSecCertificateHandle certHandle, SafeKeychainHandle targetKeychain, SafeSecKeyRefHandle privateKeyHandle, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509Chain.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509Chain.cs index 5e456410616c0..16525bfd370c8 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509Chain.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509Chain.cs @@ -11,42 +11,42 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainCreateDefaultPolicy")] - internal static extern SafeCreateHandle X509ChainCreateDefaultPolicy(); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainCreateDefaultPolicy")] + internal static partial SafeCreateHandle X509ChainCreateDefaultPolicy(); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainCreateRevocationPolicy")] - internal static extern SafeCreateHandle X509ChainCreateRevocationPolicy(); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainCreateRevocationPolicy")] + internal static partial SafeCreateHandle X509ChainCreateRevocationPolicy(); - [DllImport(Libraries.AppleCryptoNative)] - internal static extern int AppleCryptoNative_X509ChainCreate( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + internal static partial int AppleCryptoNative_X509ChainCreate( SafeCreateHandle certs, SafeCreateHandle policies, out SafeX509ChainHandle pTrustOut, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative)] - internal static extern int AppleCryptoNative_X509ChainEvaluate( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + internal static partial int AppleCryptoNative_X509ChainEvaluate( SafeX509ChainHandle chain, SafeCFDateHandle cfEvaluationTime, bool allowNetwork, out int pOSStatus); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetChainSize")] - internal static extern long X509ChainGetChainSize(SafeX509ChainHandle chain); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetChainSize")] + internal static partial long X509ChainGetChainSize(SafeX509ChainHandle chain); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetCertificateAtIndex")] - internal static extern IntPtr X509ChainGetCertificateAtIndex(SafeX509ChainHandle chain, long index); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetCertificateAtIndex")] + internal static partial IntPtr X509ChainGetCertificateAtIndex(SafeX509ChainHandle chain, long index); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetTrustResults")] - internal static extern SafeCreateHandle X509ChainGetTrustResults(SafeX509ChainHandle chain); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetTrustResults")] + internal static partial SafeCreateHandle X509ChainGetTrustResults(SafeX509ChainHandle chain); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetStatusAtIndex")] - internal static extern int X509ChainGetStatusAtIndex(SafeCreateHandle trustResults, long index, out int pdwStatus); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetStatusAtIndex")] + internal static partial int X509ChainGetStatusAtIndex(SafeCreateHandle trustResults, long index, out int pdwStatus); [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_GetOSStatusForChainStatus")] internal static extern int GetOSStatusForChainStatus(X509ChainStatusFlags flag); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainSetTrustAnchorCertificates")] - internal static extern int X509ChainSetTrustAnchorCertificates(SafeX509ChainHandle chain, SafeCreateHandle anchorCertificates); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainSetTrustAnchorCertificates")] + internal static partial int X509ChainSetTrustAnchorCertificates(SafeX509ChainHandle chain, SafeCreateHandle anchorCertificates); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FChMod.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FChMod.cs index 765ba23c3e6a5..57a278cd47a4d 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FChMod.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FChMod.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FChMod", SetLastError = true)] - internal static extern int FChMod(SafeFileHandle fd, int mode); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FChMod", SetLastError = true)] + internal static partial int FChMod(SafeFileHandle fd, int mode); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs index 8f0f6a15fed95..96f1f6d330da4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs @@ -19,8 +19,8 @@ internal static partial class Sys /// /// Returns the number of bytes placed into the buffer on success; bufferSize if the buffer is too small; and -1 on error. /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadLink", SetLastError = true)] - private static extern int ReadLink(string path, byte[] buffer, int bufferSize); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadLink", SetLastError = true, CharSet = CharSet.Ansi)] + private static partial int ReadLink(string path, byte[] buffer, int bufferSize); /// /// Takes a path to a symbolic link and returns the link target path. diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.GetIntegerBytes.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.GetIntegerBytes.cs index c5b94de3d20a9..e9a78844fd28a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.GetIntegerBytes.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.GetIntegerBytes.cs @@ -11,11 +11,11 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetAsn1IntegerDerSize")] - private static extern int GetAsn1IntegerDerSize(SafeSharedAsn1IntegerHandle i); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetAsn1IntegerDerSize")] + private static partial int GetAsn1IntegerDerSize(SafeSharedAsn1IntegerHandle i); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeAsn1Integer")] - private static extern int EncodeAsn1Integer(SafeSharedAsn1IntegerHandle i, byte[] buf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeAsn1Integer")] + private static partial int EncodeAsn1Integer(SafeSharedAsn1IntegerHandle i, byte[] buf); internal static byte[] GetAsn1IntegerBytes(SafeSharedAsn1IntegerHandle asn1Integer) { 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 3572c427a7e17..9af05f6b67ef5 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 @@ -13,8 +13,8 @@ internal static partial class Crypto { internal delegate int NegativeSizeReadMethod(THandle handle, byte[]? buf, int cBuf); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioTell")] - internal static extern int CryptoNative_BioTell(SafeBioHandle bio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioTell")] + internal static partial int CryptoNative_BioTell(SafeBioHandle bio); internal static int BioTell(SafeBioHandle bio) { @@ -27,46 +27,46 @@ internal static int BioTell(SafeBioHandle bio) return ret; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioSeek")] - internal static extern int BioSeek(SafeBioHandle bio, int pos); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioSeek")] + internal static partial int BioSeek(SafeBioHandle bio, int pos); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509Thumbprint")] - private static extern int GetX509Thumbprint(SafeX509Handle x509, byte[]? buf, int cBuf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509Thumbprint")] + private static partial int GetX509Thumbprint(SafeX509Handle x509, byte[]? buf, int cBuf); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameRawBytes")] - private static extern int GetX509NameRawBytes(IntPtr x509Name, byte[]? buf, int cBuf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameRawBytes")] + private static partial int GetX509NameRawBytes(IntPtr x509Name, byte[]? buf, int cBuf); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ReadX509AsDerFromBio")] - internal static extern SafeX509Handle ReadX509AsDerFromBio(SafeBioHandle bio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ReadX509AsDerFromBio")] + internal static partial SafeX509Handle ReadX509AsDerFromBio(SafeBioHandle bio); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509CrlNextUpdate")] - internal static extern IntPtr GetX509CrlNextUpdate(SafeX509CrlHandle crl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509CrlNextUpdate")] + internal static partial IntPtr GetX509CrlNextUpdate(SafeX509CrlHandle crl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509Version")] - internal static extern int GetX509Version(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509Version")] + internal static partial int GetX509Version(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509PublicKeyParameterBytes")] - private static extern int GetX509PublicKeyParameterBytes(SafeX509Handle x509, byte[]? buf, int cBuf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509PublicKeyParameterBytes")] + private static partial int GetX509PublicKeyParameterBytes(SafeX509Handle x509, byte[]? buf, int cBuf); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509EkuFieldCount")] - internal static extern int GetX509EkuFieldCount(SafeEkuExtensionHandle eku); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509EkuFieldCount")] + internal static partial int GetX509EkuFieldCount(SafeEkuExtensionHandle eku); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509EkuField")] - internal static extern IntPtr GetX509EkuField(SafeEkuExtensionHandle eku, int loc); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509EkuField")] + internal static partial IntPtr GetX509EkuField(SafeEkuExtensionHandle eku, int loc); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameInfo")] - internal static extern SafeBioHandle GetX509NameInfo(SafeX509Handle x509, int nameType, [MarshalAs(UnmanagedType.Bool)] bool forIssuer); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameInfo")] + internal static partial SafeBioHandle GetX509NameInfo(SafeX509Handle x509, int nameType, [MarshalAs(UnmanagedType.Bool)] bool forIssuer); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetAsn1StringBytes")] - private static extern int GetAsn1StringBytes(IntPtr asn1, byte[]? buf, int cBuf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetAsn1StringBytes")] + private static partial int GetAsn1StringBytes(IntPtr asn1, byte[]? buf, int cBuf); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PushX509StackField")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PushX509StackField")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool PushX509StackField(SafeX509StackHandle stack, SafeX509Handle x509); + internal static partial bool PushX509StackField(SafeX509StackHandle stack, SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PushX509StackField")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PushX509StackField")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool PushX509StackField(SafeSharedX509StackHandle stack, SafeX509Handle x509); + internal static partial bool PushX509StackField(SafeSharedX509StackHandle stack, SafeX509Handle x509); internal static string? GetX509RootStorePath() { @@ -84,8 +84,8 @@ internal static int BioTell(SafeBioHandle bio) [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509RootStoreFile")] private static extern IntPtr GetX509RootStoreFile_private(); - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509StoreSetVerifyTime( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_X509StoreSetVerifyTime( SafeX509StoreHandle ctx, int year, int month, @@ -95,11 +95,11 @@ private static extern int CryptoNative_X509StoreSetVerifyTime( int second, [MarshalAs(UnmanagedType.Bool)] bool isDst); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509IpAddress")] - internal static extern int CheckX509IpAddress(SafeX509Handle x509, [In]byte[] addressBytes, int addressLen, string hostname, int cchHostname); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509IpAddress", CharSet = CharSet.Ansi)] + internal static partial int CheckX509IpAddress(SafeX509Handle x509, byte[] addressBytes, int addressLen, string hostname, int cchHostname); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname")] - internal static extern int CheckX509Hostname(SafeX509Handle x509, string hostname, int cchHostname); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname", CharSet = CharSet.Ansi)] + 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.EvpPkey.Dsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Dsa.cs index 820f300b0641e..cd25db971e2d4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Dsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Dsa.cs @@ -9,11 +9,11 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyGetDsa")] - internal static extern SafeDsaHandle EvpPkeyGetDsa(SafeEvpPKeyHandle pkey); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyGetDsa")] + internal static partial SafeDsaHandle EvpPkeyGetDsa(SafeEvpPKeyHandle pkey); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetDsa")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeySetDsa")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpPkeySetDsa(SafeEvpPKeyHandle pkey, SafeDsaHandle key); + internal static partial bool EvpPkeySetDsa(SafeEvpPKeyHandle pkey, SafeDsaHandle key); } } 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 edb731fc905d5..c052f5a4c5fe5 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 @@ -15,14 +15,14 @@ internal static partial class Crypto [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspRequestDestroy")] internal static extern void OcspRequestDestroy(IntPtr ocspReq); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOcspRequestDerSize")] - internal static extern int GetOcspRequestDerSize(SafeOcspRequestHandle req); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOcspRequestDerSize")] + internal static partial int GetOcspRequestDerSize(SafeOcspRequestHandle req); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeOcspRequest")] - internal static extern int EncodeOcspRequest(SafeOcspRequestHandle req, byte[] buf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeOcspRequest")] + internal static partial int EncodeOcspRequest(SafeOcspRequestHandle req, byte[] buf); - [DllImport(Libraries.CryptoNative)] - private static extern SafeOcspResponseHandle CryptoNative_DecodeOcspResponse(ref byte buf, int len); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial SafeOcspResponseHandle CryptoNative_DecodeOcspResponse(ref byte buf, int len); internal static SafeOcspResponseHandle DecodeOcspResponse(ReadOnlySpan buf) { @@ -34,8 +34,8 @@ ref MemoryMarshal.GetReference(buf), [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspResponseDestroy")] internal static extern void OcspResponseDestroy(IntPtr ocspReq); - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509ChainGetCachedOcspStatus( + [GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)] + private static partial int CryptoNative_X509ChainGetCachedOcspStatus( SafeX509StoreCtxHandle ctx, string cachePath, int chainDepth); @@ -53,8 +53,8 @@ internal static X509VerifyStatusCode X509ChainGetCachedOcspStatus(SafeX509StoreC return response; } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509ChainVerifyOcsp( + [GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)] + private static partial int CryptoNative_X509ChainVerifyOcsp( SafeX509StoreCtxHandle ctx, SafeOcspRequestHandle req, SafeOcspResponseHandle resp, @@ -79,8 +79,8 @@ internal static X509VerifyStatusCode X509ChainVerifyOcsp( return response; } - [DllImport(Libraries.CryptoNative)] - private static extern SafeOcspRequestHandle CryptoNative_X509ChainBuildOcspRequest( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial SafeOcspRequestHandle CryptoNative_X509ChainBuildOcspRequest( SafeX509StoreCtxHandle storeCtx, int chainDepth); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs index 3f9dbf1f8e1fc..657e7cbcda4b9 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs @@ -9,32 +9,32 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadBioPkcs7")] - internal static extern SafePkcs7Handle PemReadBioPkcs7(SafeBioHandle bp); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadBioPkcs7")] + internal static partial SafePkcs7Handle PemReadBioPkcs7(SafeBioHandle bp); internal static SafePkcs7Handle DecodePkcs7(ReadOnlySpan buf) => DecodePkcs7(ref MemoryMarshal.GetReference(buf), buf.Length); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodePkcs7")] - private static extern SafePkcs7Handle DecodePkcs7(ref byte buf, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodePkcs7")] + private static partial SafePkcs7Handle DecodePkcs7(ref byte buf, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_D2IPkcs7Bio")] - internal static extern SafePkcs7Handle D2IPkcs7Bio(SafeBioHandle bp); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_D2IPkcs7Bio")] + internal static partial SafePkcs7Handle D2IPkcs7Bio(SafeBioHandle bp); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7CreateCertificateCollection")] - internal static extern SafePkcs7Handle Pkcs7CreateCertificateCollection(SafeX509StackHandle certs); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7CreateCertificateCollection")] + internal static partial SafePkcs7Handle Pkcs7CreateCertificateCollection(SafeX509StackHandle certs); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7Destroy")] internal static extern void Pkcs7Destroy(IntPtr p7); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetPkcs7Certificates")] - private static extern int GetPkcs7Certificates(SafePkcs7Handle p7, out SafeSharedX509StackHandle certs); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetPkcs7Certificates")] + private static partial int GetPkcs7Certificates(SafePkcs7Handle p7, out SafeSharedX509StackHandle certs); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetPkcs7DerSize")] - internal static extern int GetPkcs7DerSize(SafePkcs7Handle p7); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetPkcs7DerSize")] + internal static partial int GetPkcs7DerSize(SafePkcs7Handle p7); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodePkcs7")] - internal static extern int EncodePkcs7(SafePkcs7Handle p7, byte[] buf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodePkcs7")] + internal static partial int EncodePkcs7(SafePkcs7Handle p7, byte[] buf); internal static SafeSharedX509StackHandle GetPkcs7Certificates(SafePkcs7Handle p7) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs index 0e5806d109135..ef98e885075db 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs @@ -13,35 +13,35 @@ internal static partial class Crypto { internal delegate int X509StoreVerifyCallback(int ok, IntPtr ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NotBefore")] - internal static extern IntPtr GetX509NotBefore(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NotBefore")] + internal static partial IntPtr GetX509NotBefore(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NotAfter")] - internal static extern IntPtr GetX509NotAfter(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NotAfter")] + internal static partial IntPtr GetX509NotAfter(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509SignatureAlgorithm")] - internal static extern IntPtr GetX509SignatureAlgorithm(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509SignatureAlgorithm")] + internal static partial IntPtr GetX509SignatureAlgorithm(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509PublicKeyAlgorithm")] - internal static extern IntPtr GetX509PublicKeyAlgorithm(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509PublicKeyAlgorithm")] + internal static partial IntPtr GetX509PublicKeyAlgorithm(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509PublicKeyBytes")] - internal static extern IntPtr GetX509PublicKeyBytes(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509PublicKeyBytes")] + internal static partial IntPtr GetX509PublicKeyBytes(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509EvpPublicKey")] - internal static extern SafeEvpPKeyHandle GetX509EvpPublicKey(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509EvpPublicKey")] + internal static partial SafeEvpPKeyHandle GetX509EvpPublicKey(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeX509Crl")] - internal static extern SafeX509CrlHandle DecodeX509Crl(byte[] buf, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeX509Crl")] + internal static partial SafeX509CrlHandle DecodeX509Crl(byte[] buf, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeX509")] - internal static extern SafeX509Handle DecodeX509(ref byte buf, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DecodeX509")] + internal static partial SafeX509Handle DecodeX509(ref byte buf, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509DerSize")] - internal static extern int GetX509DerSize(SafeX509Handle x); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509DerSize")] + internal static partial int GetX509DerSize(SafeX509Handle x); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeX509")] - internal static extern int EncodeX509(SafeX509Handle x, byte[] buf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeX509")] + internal static partial int EncodeX509(SafeX509Handle x, byte[] buf); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509Destroy")] internal static extern void X509Destroy(IntPtr a); @@ -49,37 +49,37 @@ internal static partial class Crypto /// /// Clone the input certificate into a new object. /// - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509Duplicate")] - internal static extern SafeX509Handle X509Duplicate(IntPtr handle); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509Duplicate")] + internal static partial SafeX509Handle X509Duplicate(IntPtr handle); /// /// Clone the input certificate into a new object. /// - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509Duplicate")] - internal static extern SafeX509Handle X509Duplicate(SafeX509Handle handle); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509Duplicate")] + internal static partial SafeX509Handle X509Duplicate(SafeX509Handle handle); /// /// Increment the native reference count of the certificate to protect against /// a free from another pointer-holder. /// - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509UpRef")] - internal static extern SafeX509Handle X509UpRef(IntPtr handle); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509UpRef")] + internal static partial SafeX509Handle X509UpRef(IntPtr handle); /// /// Increment the native reference count of the certificate to protect against /// a free from another pointer-holder. /// - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509UpRef")] - internal static extern SafeX509Handle X509UpRef(SafeX509Handle handle); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509UpRef")] + internal static partial SafeX509Handle X509UpRef(SafeX509Handle handle); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadX509FromBio")] - internal static extern SafeX509Handle PemReadX509FromBio(SafeBioHandle bio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadX509FromBio")] + internal static partial SafeX509Handle PemReadX509FromBio(SafeBioHandle bio); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadX509FromBioAux")] - internal static extern SafeX509Handle PemReadX509FromBioAux(SafeBioHandle bio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadX509FromBioAux")] + internal static partial SafeX509Handle PemReadX509FromBioAux(SafeBioHandle bio); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetSerialNumber")] - private static extern SafeSharedAsn1IntegerHandle X509GetSerialNumber_private(SafeX509Handle x); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetSerialNumber")] + private static partial SafeSharedAsn1IntegerHandle X509GetSerialNumber_private(SafeX509Handle x); internal static SafeSharedAsn1IntegerHandle X509GetSerialNumber(SafeX509Handle x) { @@ -90,21 +90,21 @@ internal static SafeSharedAsn1IntegerHandle X509GetSerialNumber(SafeX509Handle x x); } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetIssuerName")] - internal static extern IntPtr X509GetIssuerName(SafeX509Handle x); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetIssuerName")] + internal static partial IntPtr X509GetIssuerName(SafeX509Handle x); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetSubjectName")] - internal static extern IntPtr X509GetSubjectName(SafeX509Handle x); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetSubjectName")] + internal static partial IntPtr X509GetSubjectName(SafeX509Handle x); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509CheckPurpose")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509CheckPurpose")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool X509CheckPurpose(SafeX509Handle x, int id, int ca); + internal static partial bool X509CheckPurpose(SafeX509Handle x, int id, int ca); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509IssuerNameHash")] - internal static extern ulong X509IssuerNameHash(SafeX509Handle x); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509IssuerNameHash")] + internal static partial ulong X509IssuerNameHash(SafeX509Handle x); - [DllImport(Libraries.CryptoNative)] - private static extern SafeSharedAsn1OctetStringHandle CryptoNative_X509FindExtensionData( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial SafeSharedAsn1OctetStringHandle CryptoNative_X509FindExtensionData( SafeX509Handle x, int extensionNid); @@ -118,13 +118,13 @@ internal static SafeSharedAsn1OctetStringHandle X509FindExtensionData(SafeX509Ha extensionNid); } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetExtCount")] - internal static extern int X509GetExtCount(SafeX509Handle x); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetExtCount")] + internal static partial int X509GetExtCount(SafeX509Handle x); // Returns a pointer already being tracked by the SafeX509Handle, shouldn't be SafeHandle tracked/freed. // Bounds checking is in place for "loc", IntPtr.Zero is returned on violations. - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetExt")] - internal static extern IntPtr X509GetExt(SafeX509Handle x, int loc); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509GetExt")] + internal static partial IntPtr X509GetExt(SafeX509Handle x, int loc); // Returns a pointer already being tracked by a SafeX509Handle, shouldn't be SafeHandle tracked/freed. [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionGetOid")] @@ -135,11 +135,10 @@ internal static SafeSharedAsn1OctetStringHandle X509FindExtensionData(SafeX509Ha internal static extern IntPtr X509ExtensionGetData(IntPtr ex); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionGetCritical")] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool X509ExtensionGetCritical(IntPtr ex); + internal static extern int X509ExtensionGetCritical(IntPtr ex); - [DllImport(Libraries.CryptoNative)] - private static extern SafeX509StoreHandle CryptoNative_X509ChainNew(SafeX509StackHandle systemTrust, SafeX509StackHandle userTrust); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial SafeX509StoreHandle CryptoNative_X509ChainNew(SafeX509StackHandle systemTrust, SafeX509StackHandle userTrust); internal static SafeX509StoreHandle X509ChainNew(SafeX509StackHandle systemTrust, SafeX509StackHandle userTrust) { @@ -156,13 +155,13 @@ internal static SafeX509StoreHandle X509ChainNew(SafeX509StackHandle systemTrust [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreDestory")] internal static extern void X509StoreDestory(IntPtr v); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreAddCrl")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreAddCrl")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool X509StoreAddCrl(SafeX509StoreHandle ctx, SafeX509CrlHandle x); + internal static partial bool X509StoreAddCrl(SafeX509StoreHandle ctx, SafeX509CrlHandle x); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreSetRevocationFlag")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreSetRevocationFlag")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CryptoNative_X509StoreSetRevocationFlag(SafeX509StoreHandle ctx, X509RevocationFlag revocationFlag); + private static partial bool CryptoNative_X509StoreSetRevocationFlag(SafeX509StoreHandle ctx, X509RevocationFlag revocationFlag); internal static void X509StoreSetRevocationFlag(SafeX509StoreHandle ctx, X509RevocationFlag revocationFlag) { @@ -172,16 +171,16 @@ internal static void X509StoreSetRevocationFlag(SafeX509StoreHandle ctx, X509Rev } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxInit")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxInit")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool X509StoreCtxInit( + internal static partial bool X509StoreCtxInit( SafeX509StoreCtxHandle ctx, SafeX509StoreHandle store, SafeX509Handle x509, SafeX509StackHandle extraCerts); - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509VerifyCert(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_X509VerifyCert(SafeX509StoreCtxHandle ctx); internal static bool X509VerifyCert(SafeX509StoreCtxHandle ctx) { @@ -195,16 +194,16 @@ internal static bool X509VerifyCert(SafeX509StoreCtxHandle ctx) return result != 0; } - [DllImport(Libraries.CryptoNative)] - internal static extern int CryptoNative_X509StoreCtxGetError(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative)] + internal static partial int CryptoNative_X509StoreCtxGetError(SafeX509StoreCtxHandle ctx); internal static X509VerifyStatusCode X509StoreCtxGetError(SafeX509StoreCtxHandle ctx) { return (X509VerifyStatusCode)CryptoNative_X509StoreCtxGetError(ctx); } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509StoreCtxReset(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_X509StoreCtxReset(SafeX509StoreCtxHandle ctx); internal static void X509StoreCtxReset(SafeX509StoreCtxHandle ctx) { @@ -214,8 +213,8 @@ internal static void X509StoreCtxReset(SafeX509StoreCtxHandle ctx) } } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509StoreCtxRebuildChain(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_X509StoreCtxRebuildChain(SafeX509StoreCtxHandle ctx); internal static bool X509StoreCtxRebuildChain(SafeX509StoreCtxHandle ctx) { @@ -229,11 +228,11 @@ internal static bool X509StoreCtxRebuildChain(SafeX509StoreCtxHandle ctx) return result != 0; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetErrorDepth")] - internal static extern int X509StoreCtxGetErrorDepth(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetErrorDepth")] + internal static partial int X509StoreCtxGetErrorDepth(SafeX509StoreCtxHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxSetVerifyCallback")] - internal static extern void X509StoreCtxSetVerifyCallback(SafeX509StoreCtxHandle ctx, X509StoreVerifyCallback callback); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxSetVerifyCallback")] + internal static partial void X509StoreCtxSetVerifyCallback(SafeX509StoreCtxHandle ctx, X509StoreVerifyCallback callback); internal static string GetX509VerifyCertErrorString(int n) { @@ -246,17 +245,17 @@ internal static string GetX509VerifyCertErrorString(int n) [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509CrlDestroy")] internal static extern void X509CrlDestroy(IntPtr a); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemWriteBioX509Crl")] - internal static extern int PemWriteBioX509Crl(SafeBioHandle bio, SafeX509CrlHandle crl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemWriteBioX509Crl")] + internal static partial int PemWriteBioX509Crl(SafeBioHandle bio, SafeX509CrlHandle crl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadBioX509Crl")] - internal static extern SafeX509CrlHandle PemReadBioX509Crl(SafeBioHandle bio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_PemReadBioX509Crl")] + internal static partial SafeX509CrlHandle PemReadBioX509Crl(SafeBioHandle bio); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509SubjectPublicKeyInfoDerSize")] - internal static extern int GetX509SubjectPublicKeyInfoDerSize(SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509SubjectPublicKeyInfoDerSize")] + internal static partial int GetX509SubjectPublicKeyInfoDerSize(SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeX509SubjectPublicKeyInfo")] - internal static extern int EncodeX509SubjectPublicKeyInfo(SafeX509Handle x509, byte[] buf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EncodeX509SubjectPublicKeyInfo")] + internal static partial int EncodeX509SubjectPublicKeyInfo(SafeX509Handle x509, byte[] buf); internal enum X509VerifyStatusCodeUniversal { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Name.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Name.cs index ad2b0fefc2404..17aeb1559a1a4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Name.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Name.cs @@ -10,15 +10,15 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameStackFieldCount")] - internal static extern int GetX509NameStackFieldCount(SafeSharedX509NameStackHandle sk); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameStackFieldCount")] + internal static partial int GetX509NameStackFieldCount(SafeSharedX509NameStackHandle sk); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameStackField")] - private static extern SafeSharedX509NameHandle GetX509NameStackField_private(SafeSharedX509NameStackHandle sk, + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameStackField")] + private static partial SafeSharedX509NameHandle GetX509NameStackField_private(SafeSharedX509NameStackHandle sk, int loc); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameRawBytes")] - private static extern int GetX509NameRawBytes(SafeSharedX509NameHandle x509Name, byte[]? buf, int cBuf); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509NameRawBytes")] + private static partial int GetX509NameRawBytes(SafeSharedX509NameHandle x509Name, byte[]? buf, int cBuf); internal static X500DistinguishedName LoadX500Name(SafeSharedX509NameHandle namePtr) { 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 c3468042c0c69..2bf09b7eb9f50 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 @@ -9,34 +9,34 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_NewX509Stack")] - internal static extern SafeX509StackHandle NewX509Stack(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_NewX509Stack")] + internal static partial SafeX509StackHandle NewX509Stack(); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_RecursiveFreeX509Stack")] internal static extern void RecursiveFreeX509Stack(IntPtr stack); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackFieldCount")] - internal static extern int GetX509StackFieldCount(SafeX509StackHandle stack); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackFieldCount")] + internal static partial int GetX509StackFieldCount(SafeX509StackHandle stack); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackFieldCount")] - internal static extern int GetX509StackFieldCount(SafeSharedX509StackHandle stack); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackFieldCount")] + internal static partial int GetX509StackFieldCount(SafeSharedX509StackHandle stack); /// /// Gets a pointer to a certificate within a STACK_OF(X509). This pointer will later /// be freed, so it should be cloned via new X509Certificate2(IntPtr) /// - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackField")] - internal static extern IntPtr GetX509StackField(SafeX509StackHandle stack, int loc); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackField")] + internal static partial IntPtr GetX509StackField(SafeX509StackHandle stack, int loc); /// /// Gets a pointer to a certificate within a STACK_OF(X509). This pointer will later /// be freed, so it should be cloned via new X509Certificate2(IntPtr) /// - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackField")] - internal static extern IntPtr GetX509StackField(SafeSharedX509StackHandle stack, int loc); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetX509StackField")] + internal static partial IntPtr GetX509StackField(SafeSharedX509StackHandle stack, int loc); - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509StackAddDirectoryStore(SafeX509StackHandle stack, string storePath); + [GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)] + private static partial int CryptoNative_X509StackAddDirectoryStore(SafeX509StackHandle stack, string storePath); internal static void X509StackAddDirectoryStore(SafeX509StackHandle stack, string storePath) { @@ -46,8 +46,8 @@ internal static void X509StackAddDirectoryStore(SafeX509StackHandle stack, strin } } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509StackAddMultiple(SafeX509StackHandle dest, SafeX509StackHandle src); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_X509StackAddMultiple(SafeX509StackHandle dest, SafeX509StackHandle src); internal static void X509StackAddMultiple(SafeX509StackHandle dest, SafeX509StackHandle src) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509StoreCtx.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509StoreCtx.cs index 0b652965784e8..8325165c5cfa8 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509StoreCtx.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509StoreCtx.cs @@ -9,20 +9,20 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxCreate")] - internal static extern SafeX509StoreCtxHandle X509StoreCtxCreate(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxCreate")] + internal static partial SafeX509StoreCtxHandle X509StoreCtxCreate(); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxDestroy")] internal static extern void X509StoreCtxDestroy(IntPtr v); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetChain")] - internal static extern SafeX509StackHandle X509StoreCtxGetChain(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetChain")] + internal static partial SafeX509StackHandle X509StoreCtxGetChain(SafeX509StoreCtxHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetCurrentCert")] - internal static extern SafeX509Handle X509StoreCtxGetCurrentCert(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetCurrentCert")] + internal static partial SafeX509Handle X509StoreCtxGetCurrentCert(SafeX509StoreCtxHandle ctx); - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509StoreCtxCommitToChain(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_X509StoreCtxCommitToChain(SafeX509StoreCtxHandle ctx); internal static void X509StoreCtxCommitToChain(SafeX509StoreCtxHandle ctx) { @@ -32,8 +32,8 @@ internal static void X509StoreCtxCommitToChain(SafeX509StoreCtxHandle ctx) } } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_X509StoreCtxResetForSignatureError( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_X509StoreCtxResetForSignatureError( SafeX509StoreCtxHandle ctx, out SafeX509StoreHandle newStore); @@ -55,11 +55,11 @@ internal static void X509StoreCtxResetForSignatureError( } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetSharedUntrusted")] - private static extern SafeSharedX509StackHandle X509StoreCtxGetSharedUntrusted_private(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetSharedUntrusted")] + private static partial SafeSharedX509StackHandle X509StoreCtxGetSharedUntrusted_private(SafeX509StoreCtxHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetTargetCert")] - internal static extern IntPtr X509StoreCtxGetTargetCert(SafeX509StoreCtxHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509StoreCtxGetTargetCert")] + internal static partial IntPtr X509StoreCtxGetTargetCert(SafeX509StoreCtxHandle ctx); internal static SafeSharedX509StackHandle X509StoreCtxGetSharedUntrusted(SafeX509StoreCtxHandle ctx) { 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 8f5936af4ce06..b9f585e3a245d 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 { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static extern NTSTATUS BCryptExportKey(SafeBCryptKeyHandle hKey, IntPtr hExportKey, string pszBlobType, [Out] byte[]? pbOutput, int cbOutput, out int pcbResult, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + 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/Crypt32/Interop.CertCloseStore.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertCloseStore.cs index 8248d470d76c1..f26df2d4d8e5c 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertCloseStore.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertCloseStore.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Crypt32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool CertCloseStore(IntPtr hCertStore, uint dwFlags); +#else [DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool CertCloseStore(IntPtr hCertStore, uint dwFlags); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertFreeCertificateContext.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertFreeCertificateContext.cs index 577283c94dca9..9158b597dbbb7 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertFreeCertificateContext.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertFreeCertificateContext.cs @@ -9,7 +9,12 @@ internal static partial class Interop internal static partial class Crypt32 { // Note: This api always return TRUE, regardless of success. +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool CertFreeCertificateContext(IntPtr pCertContext); +#else [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool CertFreeCertificateContext(IntPtr pCertContext); +#endif } } 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 30d5379eb6823..ebb45e1a86829 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs @@ -7,8 +7,13 @@ internal static partial class Interop { internal static partial class Crypt32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertNameToStrW")] + internal static unsafe partial int CertNameToStr( +#else [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertNameToStrW")] internal static extern unsafe int CertNameToStr( +#endif int dwCertEncodingType, void* pName, int dwStrType, diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgClose.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgClose.cs index 08dd13648b85b..f4235e3d178bb 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgClose.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgClose.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Crypt32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool CryptMsgClose(IntPtr hCryptMsg); +#else [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool CryptMsgClose(IntPtr hCryptMsg); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs index 6b90203adf5b7..e327cb2851f45 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs @@ -18,16 +18,10 @@ internal static partial class Kernel32 #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, ExactSpelling = true)] private static unsafe partial int FormatMessage( - int dwFlags, - IntPtr lpSource, - uint dwMessageId, - int dwLanguageId, - void* lpBuffer, - int nSize, - IntPtr arguments); #else [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, BestFitMapping = true, ExactSpelling = true)] private static extern unsafe int FormatMessage( +#endif int dwFlags, IntPtr lpSource, uint dwMessageId, @@ -35,7 +29,6 @@ private static extern unsafe int FormatMessage( void* lpBuffer, int nSize, IntPtr arguments); -#endif /// /// Returns a string message for the specified Win32 error code. 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 6e68098bd535a..4304ccf9bbf4c 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.Properties.cs @@ -15,19 +15,30 @@ internal static partial class NCrypt { #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static unsafe partial ErrorCode NCryptGetProperty(SafeNCryptHandle hObject, string pszProperty, void* pbOutput, int cbOutput, out int pcbResult, CngPropertyOptions dwFlags); + internal static unsafe partial ErrorCode NCryptGetProperty( #else [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern unsafe ErrorCode NCryptGetProperty(SafeNCryptHandle hObject, string pszProperty, [Out] void* pbOutput, int cbOutput, out int pcbResult, CngPropertyOptions dwFlags); + internal static extern unsafe ErrorCode NCryptGetProperty( #endif + SafeNCryptHandle hObject, + string pszProperty, + void* pbOutput, + int cbOutput, + out int pcbResult, + CngPropertyOptions dwFlags); #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static unsafe partial ErrorCode NCryptSetProperty(SafeNCryptHandle hObject, string pszProperty, void* pbInput, int cbInput, CngPropertyOptions dwFlags); + internal static unsafe partial ErrorCode NCryptSetProperty( #else [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern unsafe ErrorCode NCryptSetProperty(SafeNCryptHandle hObject, string pszProperty, [In] void* pbInput, int cbInput, CngPropertyOptions dwFlags); + internal static extern unsafe ErrorCode NCryptSetProperty( #endif + SafeNCryptHandle hObject, + string pszProperty, + void* pbInput, + int cbInput, + CngPropertyOptions dwFlags); [SupportedOSPlatform("windows")] internal static unsafe ErrorCode NCryptGetByteProperty(SafeNCryptHandle hObject, string pszProperty, ref byte result, CngPropertyOptions options = CngPropertyOptions.None) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs index e5561d9279c68..b02d075786365 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs @@ -509,7 +509,7 @@ public IEnumerable Extensions Interop.Crypto.CheckValidOpenSslHandle(dataPtr); byte[] extData = Interop.Crypto.GetAsn1StringBytes(dataPtr); - bool critical = Interop.Crypto.X509ExtensionGetCritical(ext); + bool critical = Interop.Crypto.X509ExtensionGetCritical(ext) != 0; extensions[i] = new X509Extension(oid, extData, critical); } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs index 2b59f383266d2..8c6f33c1991ab 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs @@ -22,8 +22,8 @@ internal static partial class Interop { public static partial class crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CryptQueryObject( + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CryptQueryObject( CertQueryObjectType dwObjectType, void* pvObject, ExpectedContentTypeFlags dwExpectedContentTypeFlags, @@ -37,8 +37,8 @@ public static extern unsafe bool CryptQueryObject( out SafeCertContextHandle ppvContext ); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CryptQueryObject( + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CryptQueryObject( CertQueryObjectType dwObjectType, void* pvObject, ExpectedContentTypeFlags dwExpectedContentTypeFlags, @@ -52,8 +52,8 @@ public static extern unsafe bool CryptQueryObject( IntPtr ppvContext ); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CryptQueryObject( + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CryptQueryObject( CertQueryObjectType dwObjectType, void* pvObject, ExpectedContentTypeFlags dwExpectedContentTypeFlags, @@ -68,26 +68,26 @@ IntPtr ppvContext ); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertGetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, [Out] byte[]? pvData, [In, Out] ref int pcbData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertGetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, byte[]? pvData, ref int pcbData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertGetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, [Out] out CRYPTOAPI_BLOB pvData, [In, Out] ref int pcbData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertGetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, out CRYPTOAPI_BLOB pvData, ref int pcbData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertGetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, [Out] out IntPtr pvData, [In, Out] ref int pcbData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertGetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, out IntPtr pvData, ref int pcbData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertGetCertificateContextProperty")] - public static extern unsafe bool CertGetCertificateContextPropertyString(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, byte* pvData, ref int pcbData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertGetCertificateContextProperty")] + public static unsafe partial bool CertGetCertificateContextPropertyString(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, byte* pvData, ref int pcbData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CertSetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, CertSetPropertyFlags dwFlags, [In] CRYPTOAPI_BLOB* pvData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CertSetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, CertSetPropertyFlags dwFlags, CRYPTOAPI_BLOB* pvData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CertSetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, CertSetPropertyFlags dwFlags, [In] CRYPT_KEY_PROV_INFO* pvData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CertSetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, CertSetPropertyFlags dwFlags, CRYPT_KEY_PROV_INFO* pvData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CertSetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, CertSetPropertyFlags dwFlags, [In] SafeNCryptKeyHandle keyHandle); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CertSetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, CertSetPropertyFlags dwFlags, SafeNCryptKeyHandle keyHandle); public static unsafe string CertGetNameString( SafeCertContextHandle certContext, @@ -114,34 +114,34 @@ public static unsafe string CertGetNameString( } } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertGetNameStringW")] - private static extern unsafe int CertGetNameString(SafeCertContextHandle pCertContext, CertNameType dwType, CertNameFlags dwFlags, in CertNameStringType pvTypePara, char* pszNameString, int cchNameString); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertGetNameStringW")] + private static unsafe partial int CertGetNameString(SafeCertContextHandle pCertContext, CertNameType dwType, CertNameFlags dwFlags, in CertNameStringType pvTypePara, char* pszNameString, int cchNameString); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern SafeCertContextHandle CertDuplicateCertificateContext(IntPtr pCertContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial SafeCertContextHandle CertDuplicateCertificateContext(IntPtr pCertContext); - [DllImport(Libraries.Crypt32, SetLastError = true)] - public static extern SafeX509ChainHandle CertDuplicateCertificateChain(IntPtr pChainContext); + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + public static partial SafeX509ChainHandle CertDuplicateCertificateChain(IntPtr pChainContext); - [DllImport(Libraries.Crypt32, SetLastError = true)] - internal static extern SafeCertStoreHandle CertDuplicateStore(IntPtr hCertStore); + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static partial SafeCertStoreHandle CertDuplicateStore(IntPtr hCertStore); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertDuplicateCertificateContext")] - public static extern SafeCertContextHandleWithKeyContainerDeletion CertDuplicateCertificateContextWithKeyContainerDeletion(IntPtr pCertContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertDuplicateCertificateContext")] + public static partial SafeCertContextHandleWithKeyContainerDeletion CertDuplicateCertificateContextWithKeyContainerDeletion(IntPtr pCertContext); public static SafeCertStoreHandle CertOpenStore(CertStoreProvider lpszStoreProvider, CertEncodingType dwMsgAndCertEncodingType, IntPtr hCryptProv, CertStoreFlags dwFlags, string? pvPara) { return CertOpenStore((IntPtr)lpszStoreProvider, dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara); } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern SafeCertStoreHandle CertOpenStore(IntPtr lpszStoreProvider, CertEncodingType dwMsgAndCertEncodingType, IntPtr hCryptProv, CertStoreFlags dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string? pvPara); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + private static partial SafeCertStoreHandle CertOpenStore(IntPtr lpszStoreProvider, CertEncodingType dwMsgAndCertEncodingType, IntPtr hCryptProv, CertStoreFlags dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string? pvPara); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertAddCertificateContextToStore(SafeCertStoreHandle hCertStore, SafeCertContextHandle pCertContext, CertStoreAddDisposition dwAddDisposition, IntPtr ppStoreContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertAddCertificateContextToStore(SafeCertStoreHandle hCertStore, SafeCertContextHandle pCertContext, CertStoreAddDisposition dwAddDisposition, IntPtr ppStoreContext); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertAddCertificateLinkToStore(SafeCertStoreHandle hCertStore, SafeCertContextHandle pCertContext, CertStoreAddDisposition dwAddDisposition, IntPtr ppStoreContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertAddCertificateLinkToStore(SafeCertStoreHandle hCertStore, SafeCertContextHandle pCertContext, CertStoreAddDisposition dwAddDisposition, IntPtr ppStoreContext); /// /// A less error-prone wrapper for CertEnumCertificatesInStore(). @@ -174,56 +174,56 @@ public static unsafe bool CertEnumCertificatesInStore(SafeCertStoreHandle hCertS return false; } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern unsafe CERT_CONTEXT* CertEnumCertificatesInStore(SafeCertStoreHandle hCertStore, CERT_CONTEXT* pPrevCertContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + private static unsafe partial CERT_CONTEXT* CertEnumCertificatesInStore(SafeCertStoreHandle hCertStore, CERT_CONTEXT* pPrevCertContext); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern SafeCertStoreHandle PFXImportCertStore([In] ref CRYPTOAPI_BLOB pPFX, SafePasswordHandle password, PfxCertStoreFlags dwFlags); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial SafeCertStoreHandle PFXImportCertStore(ref CRYPTOAPI_BLOB pPFX, SafePasswordHandle password, PfxCertStoreFlags dwFlags); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CryptMsgGetParam(SafeCryptMsgHandle hCryptMsg, CryptMessageParameterType dwParamType, int dwIndex, byte* pvData, [In, Out] ref int pcbData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CryptMsgGetParam(SafeCryptMsgHandle hCryptMsg, CryptMessageParameterType dwParamType, int dwIndex, byte* pvData, ref int pcbData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptMsgGetParam(SafeCryptMsgHandle hCryptMsg, CryptMessageParameterType dwParamType, int dwIndex, out int pvData, [In, Out] ref int pcbData); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptMsgGetParam(SafeCryptMsgHandle hCryptMsg, CryptMessageParameterType dwParamType, int dwIndex, out int pvData, ref int pcbData); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertSerializeCertificateStoreElement(SafeCertContextHandle pCertContext, int dwFlags, [Out] byte[]? pbElement, [In, Out] ref int pcbElement); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertSerializeCertificateStoreElement(SafeCertContextHandle pCertContext, int dwFlags, byte[]? pbElement, ref int pcbElement); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool PFXExportCertStore(SafeCertStoreHandle hStore, [In, Out] ref CRYPTOAPI_BLOB pPFX, SafePasswordHandle szPassword, PFXExportFlags dwFlags); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool PFXExportCertStore(SafeCertStoreHandle hStore, ref CRYPTOAPI_BLOB pPFX, SafePasswordHandle szPassword, PFXExportFlags dwFlags); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertStrToNameW")] - public static extern bool CertStrToName(CertEncodingType dwCertEncodingType, string pszX500, CertNameStrTypeAndFlags dwStrType, IntPtr pvReserved, [Out] byte[]? pbEncoded, [In, Out] ref int pcbEncoded, IntPtr ppszError); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertStrToNameW")] + public static partial bool CertStrToName(CertEncodingType dwCertEncodingType, string pszX500, CertNameStrTypeAndFlags dwStrType, IntPtr pvReserved, byte[]? pbEncoded, ref int pcbEncoded, IntPtr ppszError); public static bool CryptDecodeObject(CertEncodingType dwCertEncodingType, CryptDecodeObjectStructType lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, byte[]? pvStructInfo, ref int pcbStructInfo) { return CryptDecodeObject(dwCertEncodingType, (IntPtr)lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo, ref pcbStructInfo); } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern bool CryptDecodeObject(CertEncodingType dwCertEncodingType, IntPtr lpszStructType, [In] byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, [Out] byte[]? pvStructInfo, [In, Out] ref int pcbStructInfo); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + private static partial bool CryptDecodeObject(CertEncodingType dwCertEncodingType, IntPtr lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, byte[]? pvStructInfo, ref int pcbStructInfo); public static unsafe bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodingType, CryptDecodeObjectStructType lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo) { return CryptDecodeObjectPointer(dwCertEncodingType, (IntPtr)lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo, ref pcbStructInfo); } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptDecodeObject")] - private static extern unsafe bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodingType, IntPtr lpszStructType, [In] byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, [Out] void* pvStructInfo, [In, Out] ref int pcbStructInfo); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptDecodeObject")] + private static unsafe partial bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodingType, IntPtr lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptDecodeObject")] - public static extern unsafe bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodingType, [MarshalAs(UnmanagedType.LPStr)] string lpszStructType, [In] byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, [Out] void* pvStructInfo, [In, Out] ref int pcbStructInfo); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptDecodeObject")] + public static unsafe partial bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodingType, [MarshalAs(UnmanagedType.LPStr)] string lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo); public static unsafe bool CryptEncodeObject(CertEncodingType dwCertEncodingType, CryptDecodeObjectStructType lpszStructType, void* pvStructInfo, byte[]? pbEncoded, ref int pcbEncoded) { return CryptEncodeObject(dwCertEncodingType, (IntPtr)lpszStructType, pvStructInfo, pbEncoded, ref pcbEncoded); } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern unsafe bool CryptEncodeObject(CertEncodingType dwCertEncodingType, IntPtr lpszStructType, void* pvStructInfo, [Out] byte[]? pbEncoded, [In, Out] ref int pcbEncoded); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + private static unsafe partial bool CryptEncodeObject(CertEncodingType dwCertEncodingType, IntPtr lpszStructType, void* pvStructInfo, byte[]? pbEncoded, ref int pcbEncoded); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CryptEncodeObject(CertEncodingType dwCertEncodingType, [MarshalAs(UnmanagedType.LPStr)] string lpszStructType, void* pvStructInfo, [Out] byte[]? pbEncoded, [In, Out] ref int pcbEncoded); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CryptEncodeObject(CertEncodingType dwCertEncodingType, [MarshalAs(UnmanagedType.LPStr)] string lpszStructType, void* pvStructInfo, byte[]? pbEncoded, ref int pcbEncoded); public static unsafe byte[] EncodeObject(CryptDecodeObjectStructType lpszStructType, void* decoded) { @@ -262,20 +262,20 @@ internal static SafeChainEngineHandle CertCreateCertificateChainEngine(ref CERT_ return chainEngineHandle; } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern bool CertCreateCertificateChainEngine(ref CERT_CHAIN_ENGINE_CONFIG pConfig, out SafeChainEngineHandle hChainEngineHandle); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + private static partial bool CertCreateCertificateChainEngine(ref CERT_CHAIN_ENGINE_CONFIG pConfig, out SafeChainEngineHandle hChainEngineHandle); [DllImport(Libraries.Crypt32)] public static extern void CertFreeCertificateChainEngine(IntPtr hChainEngine); - [DllImport(Libraries.Crypt32, SetLastError = true)] - public static extern unsafe bool CertGetCertificateChain(IntPtr hChainEngine, SafeCertContextHandle pCertContext, FILETIME* pTime, SafeCertStoreHandle hStore, [In] ref CERT_CHAIN_PARA pChainPara, CertChainFlags dwFlags, IntPtr pvReserved, out SafeX509ChainHandle ppChainContext); + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + public static unsafe partial bool CertGetCertificateChain(IntPtr hChainEngine, SafeCertContextHandle pCertContext, FILETIME* pTime, SafeCertStoreHandle hStore, ref CERT_CHAIN_PARA pChainPara, CertChainFlags dwFlags, IntPtr pvReserved, out SafeX509ChainHandle ppChainContext); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptHashPublicKeyInfo(IntPtr hCryptProv, int algId, int dwFlags, CertEncodingType dwCertEncodingType, [In] ref CERT_PUBLIC_KEY_INFO pInfo, [Out] byte[] pbComputedHash, [In, Out] ref int pcbComputedHash); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptHashPublicKeyInfo(IntPtr hCryptProv, int algId, int dwFlags, CertEncodingType dwCertEncodingType, ref CERT_PUBLIC_KEY_INFO pInfo, byte[] pbComputedHash, ref int pcbComputedHash); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertSaveStore(SafeCertStoreHandle hCertStore, CertEncodingType dwMsgAndCertEncodingType, CertStoreSaveAs dwSaveAs, CertStoreSaveTo dwSaveTo, ref CRYPTOAPI_BLOB pvSaveToPara, int dwFlags); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertSaveStore(SafeCertStoreHandle hCertStore, CertEncodingType dwMsgAndCertEncodingType, CertStoreSaveAs dwSaveAs, CertStoreSaveTo dwSaveTo, ref CRYPTOAPI_BLOB pvSaveToPara, int dwFlags); /// /// A less error-prone wrapper for CertEnumCertificatesInStore(). @@ -291,45 +291,45 @@ public static unsafe bool CertFindCertificateInStore(SafeCertStoreHandle hCertSt return !pCertContext.IsInvalid; } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern unsafe SafeCertContextHandle CertFindCertificateInStore(SafeCertStoreHandle hCertStore, CertEncodingType dwCertEncodingType, CertFindFlags dwFindFlags, CertFindType dwFindType, void* pvFindPara, CERT_CONTEXT* pPrevCertContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + private static unsafe partial SafeCertContextHandle CertFindCertificateInStore(SafeCertStoreHandle hCertStore, CertEncodingType dwCertEncodingType, CertFindFlags dwFindFlags, CertFindType dwFindType, void* pvFindPara, CERT_CONTEXT* pPrevCertContext); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe int CertVerifyTimeValidity([In] ref FILETIME pTimeToVerify, [In] CERT_INFO* pCertInfo); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial int CertVerifyTimeValidity(ref FILETIME pTimeToVerify, CERT_INFO* pCertInfo); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe CERT_EXTENSION* CertFindExtension([MarshalAs(UnmanagedType.LPStr)] string pszObjId, int cExtensions, CERT_EXTENSION* rgExtensions); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial CERT_EXTENSION* CertFindExtension([MarshalAs(UnmanagedType.LPStr)] string pszObjId, int cExtensions, CERT_EXTENSION* rgExtensions); // Note: It's somewhat unusual to use an API enum as a parameter type to a P/Invoke but in this case, X509KeyUsageFlags was intentionally designed as bit-wise // identical to the wincrypt CERT_*_USAGE values. - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CertGetIntendedKeyUsage(CertEncodingType dwCertEncodingType, CERT_INFO* pCertInfo, out X509KeyUsageFlags pbKeyUsage, int cbKeyUsage); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CertGetIntendedKeyUsage(CertEncodingType dwCertEncodingType, CERT_INFO* pCertInfo, out X509KeyUsageFlags pbKeyUsage, int cbKeyUsage); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CertGetValidUsages(int cCerts, [In] ref SafeCertContextHandle rghCerts, out int cNumOIDs, [Out] void* rghOIDs, [In, Out] ref int pcbOIDs); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CertGetValidUsages(int cCerts, ref SafeCertContextHandle rghCerts, out int cNumOIDs, void* rghOIDs, ref int pcbOIDs); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CertControlStore(SafeCertStoreHandle hCertStore, CertControlStoreFlags dwFlags, CertControlStoreType dwControlType, IntPtr pvCtrlPara); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CertControlStore(SafeCertStoreHandle hCertStore, CertControlStoreFlags dwFlags, CertControlStoreType dwControlType, IntPtr pvCtrlPara); // Note: CertDeleteCertificateFromStore always calls CertFreeCertificateContext on pCertContext, even if an error is encountered. - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CertDeleteCertificateFromStore(CERT_CONTEXT* pCertContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CertDeleteCertificateFromStore(CERT_CONTEXT* pCertContext); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern void CertFreeCertificateChain(IntPtr pChainContext); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial void CertFreeCertificateChain(IntPtr pChainContext); public static bool CertVerifyCertificateChainPolicy(ChainPolicy pszPolicyOID, SafeX509ChainHandle pChainContext, ref CERT_CHAIN_POLICY_PARA pPolicyPara, ref CERT_CHAIN_POLICY_STATUS pPolicyStatus) { return CertVerifyCertificateChainPolicy((IntPtr)pszPolicyOID, pChainContext, ref pPolicyPara, ref pPolicyStatus); } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern bool CertVerifyCertificateChainPolicy(IntPtr pszPolicyOID, SafeX509ChainHandle pChainContext, [In] ref CERT_CHAIN_POLICY_PARA pPolicyPara, [In, Out] ref CERT_CHAIN_POLICY_STATUS pPolicyStatus); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + private static partial bool CertVerifyCertificateChainPolicy(IntPtr pszPolicyOID, SafeX509ChainHandle pChainContext, ref CERT_CHAIN_POLICY_PARA pPolicyPara, ref CERT_CHAIN_POLICY_STATUS pPolicyStatus); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool CryptImportPublicKeyInfoEx2(CertEncodingType dwCertEncodingType, CERT_PUBLIC_KEY_INFO* pInfo, CryptImportPublicKeyInfoFlags dwFlags, void* pvAuxInfo, out SafeBCryptKeyHandle phKey); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial bool CryptImportPublicKeyInfoEx2(CertEncodingType dwCertEncodingType, CERT_PUBLIC_KEY_INFO* pInfo, CryptImportPublicKeyInfoFlags dwFlags, void* pvAuxInfo, out SafeBCryptKeyHandle phKey); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptAcquireCertificatePrivateKey(SafeCertContextHandle pCert, CryptAcquireFlags dwFlags, IntPtr pvParameters, out SafeNCryptKeyHandle phCryptProvOrNCryptKey, out int pdwKeySpec, out bool pfCallerFreeProvOrNCryptKey); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptAcquireCertificatePrivateKey(SafeCertContextHandle pCert, CryptAcquireFlags dwFlags, IntPtr pvParameters, out SafeNCryptKeyHandle phCryptProvOrNCryptKey, out int pdwKeySpec, out bool pfCallerFreeProvOrNCryptKey); } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs index 0e0c6b64ae554..8037dac0ec0af 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs @@ -14,8 +14,8 @@ internal static partial class Interop { public static partial class cryptoapi { - [DllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CryptAcquireContextW")] + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CryptAcquireContextW")] [return: MarshalAs(UnmanagedType.Bool)] - public static extern unsafe bool CryptAcquireContext(out IntPtr psafeProvHandle, char* pszContainer, char* pszProvider, int dwProvType, CryptAcquireContextFlags dwFlags); + public static unsafe partial bool CryptAcquireContext(out IntPtr psafeProvHandle, char* pszContainer, char* pszProvider, int dwProvType, CryptAcquireContextFlags dwFlags); } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj b/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj index a3ecd6dbeaaf8..7a83d19bf4a85 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj @@ -1,10 +1,11 @@ - + true $(DefineConstants);HAVE_THUMBPRINT_OVERLOADS $(DefineConstants);Unix true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS + true true From a7c64c14f9cfc9853db4de98059c5c9e8bbe5d0d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 26 May 2021 20:55:32 -0700 Subject: [PATCH 094/161] Introduce design doc for Span/ReadOnlySpan marshalling (dotnet/runtimelab#1103) * First draft of the heart of the span marshalling design. Finish the in-code collection marshalling support design doc. * Apply suggestions from code review Co-authored-by: Aaron Robinson * Feedback. * Empty spans will be marshalled as null. * Make the primary design in Design 2 be contiguous collection support. * pr feedback and add example stub. * Fix typo Co-authored-by: Aaron Robinson Commit migrated from https://github.com/dotnet/runtimelab/commit/1bc504d822114b70c8a3df5709b39484bc99a911 --- .../DllImportGenerator/SpanMarshallers.md | 315 ++++++++++++++++++ 1 file changed, 315 insertions(+) create mode 100644 docs/design/libraries/DllImportGenerator/SpanMarshallers.md diff --git a/docs/design/libraries/DllImportGenerator/SpanMarshallers.md b/docs/design/libraries/DllImportGenerator/SpanMarshallers.md new file mode 100644 index 0000000000000..4fa80be494fec --- /dev/null +++ b/docs/design/libraries/DllImportGenerator/SpanMarshallers.md @@ -0,0 +1,315 @@ +# Support for Marshalling `(ReadOnly)Span` + +As part of the exit criteria for the DllImportGenerator experiment, we have decided to introduce support for marshalling `System.Span` and `System.ReadOnlySpan` into the DllImportGenerator-generated stubs. This document describes design decisions made during the implementation of these marshallers. + +## Design 1: "Intrinsic" support for `(ReadOnly)Span` + +In this design, the default support for `(ReadOnly)Span` is emitted into the marshalling stub directly and builds on the pattern we enabled for arrays. + +### Default behavior + +This section describes the behavior of the default emitted-in-stub marshallers. + +By default, we will marshal `Span` and `ReadOnlySpan` similarly to array types. When possible, we will pin the `(ReadOnly)Span`'s data and pass that down. When it is not possible to do so, we will try stack allocating scratch space for efficiency or allocate native memory with `Marshal.AllocCoTaskMem` for compatibility with arrays. + +To support marshalling from native to managed, we will support the same `MarshalAsAttribute` properties that arrays support today. + +When a `(ReadOnly)Span` is marshalled from native to managed, we will allocate a managed array and copy the data from the native memory into the array. + +### Empty spans + +We have decided to match the managed semantics of `(ReadOnly)Span` to provide the smoothest default experience for span users in interop. To assist developers who wish to transition from array parameters to span parameters, we will also provide an in-source marshaller that enables marshalling a span that wraps an empty array as a non-null pointer as an opt-in experience. + +### Additional proposed in-source marshallers + +As part of this design, we would also want to include some in-box marshallers that follow the design laid out in the [Struct Marshalling design doc](./StructMarshalling.md) to support some additional scenarios: + +- A marshaler that marshals an empty span as a non-null pointer. + - This marshaller would only support empty spans as it cannot correctly represent non-empty spans of non-blittable types. +- A marshaler that marshals out a pointer to the native memory as a Span instead of copying the data into a managed array. + - This marshaller would only support blittable spans by design. + - This marshaler will require the user to manually release the memory. Since this will be an opt-in marshaler, this scenario is already advanced and that additional requirement should be understandable to users who use this marshaler. + - Since there is no mechansim to provide a collection length, the question of how to provide the span's length in this case is still unresolved. One option would be to always provide a length 1 span and require the user to create a new span with the correct size, but that feels like a bad design. + +### Pros/Cons of Design 1 + +Pros: + +- This design builds on the array support that already exists, providing implementation experience and a slightly easier implementation. +- As we use the same MarshalAs attributes that already support arrays, developers can easily migrate their usage of array parameters in source-generated P/Invokes to use the span types with minimal hassle. + +Cons: + +- Defining custom marshalers for non-empty spans of non-blittable types generically is impossible since the marshalling rules of the element's type cannot be known. +- Custom non-default marshalling of the span element types is impossible for non-built-in types. +- Inlining the span marshalling fully into the stub increases on-disk IL size. +- This design does not enable developers to easily define custom marshalling support for their own collection types, which may be desireable. +- The MarshalAs attributes will continue to fail to work on spans used in non-source-generated DllImports, so this would be the first instance of enabling the "old" MarshalAs model on a new type in the generated DllImports, which may or may not be undesirable. + - The existing "native type marshalling" support cannot support marshalling collections of an unknown (at marshaller authoring time) non-blittable element type and cannot specify an element count for collections during unmarshalling. + +## Design 2: "Out-line" default support with extensions to Native Type Marshalling for Contiguous Collections + +An alternative option to fully inlining the stub would be to extend the model described in the [Struct Marshalling design doc](./StructMarshalling.md) to have custom support for collection-like types. By extending the model to be built with generic collection types in mind, many of the cons of the first approach would be resolved. + +Span marshalling would still be implemented with similar semantics as mentioned above in the Empty Spans section. Additional marshallers would still be provided as mentioned in the Additional proposed in-source marshallers section, but the non-`null` span marshaller and the no-alloc span marshaller would be able to be used in all cases, not just for empty spans. + +### Proposed extension to the custom type marshalling design + +Introduce a new attribute named `GenericContiguousCollectionMarshallerAttribute`. This attribute would have the following shape: + +```csharp +namespace System.Runtime.InteropServices +{ + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] + public sealed class GenericContiguousCollectionMarshallerAttribute : Attribute + { + public GenericContiguousCollectionMarshallerAttribute(); + } +} +``` + +The attribute would be used with a collection type like `Span` as follows: + +```csharp +[NativeTypeMarshalling(typeof(DefaultSpanMarshaler<>))] +public ref struct Span +{ + ... +} + +[GenericContiguousCollectionMarshaller] +public ref struct DefaultSpanMarshaler +{ + ... +} +``` + +The `GenericContiguousCollectionMarshallerAttribute` attribute is applied to a generic marshaler type with the "collection marshaller" shape described below. Since generic parameters cannot be used in attributes, open generic types will be permitted in the `NativeTypeMarshallingAttribute` constructor as long as they have the same arity as the type the attribute is applied to and generic parameters provided to the applied-to type can also be used to construct the type passed as a parameter. + +#### Generic collection marshaller shape + +A generic collection marshaller would be required to have the following shape, in addition to the requirements for marshaler types used with the `NativeTypeMarshallingAttribute`, excluding the constructors. + +```csharp +[GenericContiguousCollectionMarshaller] +public struct GenericContiguousCollectionMarshallerImpl +{ + // these constructors are required if marshalling from managed to native is supported. + public GenericContiguousCollectionMarshallerImpl(GenericCollection collection, int nativeSizeOfElement); + public GenericContiguousCollectionMarshallerImpl(GenericCollection collection, Span stackSpace, int nativeSizeOfElement); // optional + + public const int StackBufferSize = /* */; // required if the span-based constructor is supplied. + + /// + /// A span that points to the memory where the managed values of the collection are stored (in the marshalling case) or should be stored (in the unmarshalling case). + /// + public Span ManagedValues { get; } + + /// + /// Set the expected length of the managed collection based on the parameter/return value/field marshalling information. + /// Required only when unmarshalling is supported. + /// + public void SetUnmarshalledCollectionLength(int length); + + public IntPtr Value { get; set; } + + /// + /// A span that points to the memory where the native values of the collection should be stored. + /// + public unsafe Span NativeValueStorage { get; } + + // The requirements on the Value property are the same as when used with `NativeTypeMarshallingAttribute`. + // The property is required with the generic collection marshalling. + public TNative Value { get; set; } +} +``` + +The constructors now require an additional `int` parameter specifying the native size of a collection element. The collection element type is represented as `TCollectionElement` above, and can be any type the marshaller defines. As the elements may be marshalled to types with different native sizes than managed, this enables the author of the generic collection marshaller to not need to know how to marshal the elements of the collection, just the collection structure itself. + +When the elements of the collection are blittable, the marshaller will emit a block copy of the span `ManagedValues` to the destination `NativeValueStorage`. When the elements are not blittable, the marshaller will emit a loop that will marshal the elements of the managed span one at a time and store them in the `NativeValueStorage` span. + +This would enable similar performance metrics as the current support for arrays as well as Design 1's support for the span types when the element type is blittable. + +#### Providing additional data for collection marshalling + +As part of collection marshalling, there needs to be a mechanism for the user to tell the stub code generator how many elements are in the native collection when unmarshalling. For parity with the previous system, there also needs to be a mechanism to describe how to marshal the elements of the collection. This proposal adds the following members to the `MarshalUsingAttribute` attribute to enable this and other features: + +```diff + +- [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field)] ++ [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field, AllowMultiple=true)] +public class MarshalUsingAttribute : Attribute +{ ++ public MarshalUsingAttribute() {} + public MarshalUsingAttribute(Type nativeType) {} ++ public string CountElementName { get; set; } ++ public int ConstantElementCount { get; set; } ++ public int ElementIndirectionLevel { get; set; } ++ public const string ReturnsCountValue = "return-value"; +} +``` + +The `MarshalUsingAttribute` will now provide a `CountElementName` property that will point to a parameter (or a field in a struct-marshalling context) whose value will hold the number of native collection elements, or to the return value if the value of `CountElementName` is `ReturnsCountValue`. The `ConstantElementCount` property allows users to provide a constant collection length. + +> Open Question: +> Should combining `CountElementName` and `ConstantElementCount` in the same attribute be allowed? +> With the `MarshalAs` marshalling, `SizeParamIndex` and `SizeConst` can be combined and the resulting size will be `paramValue(SizeParamIndex) + SizeConst`. + +To support supplying information about collection element counts, a parameterless constructor is added to the `MarshalUsingAttribute` type. The default constructor specifies that the code generator should use the information in the attribute but use the default marshalling rules for the type. + +The `ElementIndirectionLevel` property is added to support supplying marshalling info for element types in a collection. For example, if the user is passing a `List>` from managed to native code, they could provide the following attributes to specify marshalling rules for the outer and inner lists and `Foo` separately: + +```csharp +private static partial void Bar([MarshalUsing(typeof(ListAsArrayMarshaller>), CountElementName = nameof(count)), MarshalUsing(ConstantElementCount = 10, ElementIndirectionLevel = 1), MarshalUsing(typeof(FooMarshaler), ElementIndirectionLevel = 2)] List> foos, int count); +``` + +Multiple `MarshalUsing` attributes can only be supplied on the same parameter or return value if the `ElementIndirectionLevel` property is set to distinct values. One `MarshalUsing` attribute per parameter or return value can leave the `ElementIndirectionLevel` property unset. This attribute controls the marshalling of the collection object passed in as the parameter. The sequence of managed types for `ElementIndirectionLevel` is based on the elements of the `ManagedValues` span on the collection marshaller of the previous indirection level. For example, for the marshalling info for `ElementIndirectionLevel = 1` above, the managed type is the type of the following C# expression: `ListAsArrayMarshaller>.ManagedValues[0]`. + +Alternatively, the `MarshalUsingAttribute` could provide a `Type ElementNativeType { get; set; }` property instead of an `ElementIndirectionLevel` property and support specifying the native type of the element of the collection this way. However, this design would block support for marshalling collections of collections. + +#### Example: Using generic collection marshalling for spans + +This design could be used to provide a default marshaller for spans and arrays. Below is an example simple marshaller for `Span`. This design does not include all possible optimizations, such as stack allocation, for simpilicity of the example. + +```csharp +[GenericContiguousCollectionMarshaller] +public ref struct SpanMarshaler +{ + private Span managedCollection; + + private int nativeElementSize; + + public SpanMarshaler(Span collection, int nativeSizeOfElement) + { + managedCollection = collection; + Value = Marshal.AllocCoTaskMem(collection.Length * nativeSizeOfElement); + nativeElementSize = nativeSizeOfElement; + nativeElementSize = nativeSizeOfElement; + } + + public Span ManagedValues => managedCollection; + + public void SetUnmarshalledCollectionLength(int length) + { + managedCollection = new T[value]; + } + + public IntPtr Value { get; set; } + + public unsafe Span NativeValueStorage => MemoryMarshal.CreateSpan(ref *(byte*)(Value), Length); + + public Span ToManaged() => managedCollection; + + public void FreeNative() + { + if (Value != IntPtr.Zero) + { + Marshal.FreeCoTaskMem(Value); + } + } +} +``` + +The following example would show the expected stub for the provided signature (assuming that `Span` has a `[NativeMarshalling(typeof(SpanMarshaller<>))]` attribute): + +```csharp +struct WrappedInt +{ + private int value; + + public WrappedInt(int w) + { + value = w.i; + } + + public int ToManaged() => value; +} + +[GeneratedDllImport("Native")] +[return:MarshalUsing(CountElementName = nameof(length))] +public static partial Span DuplicateValues([MarshalUsing(typeof(WrappedInt), ElementIndirectionLevel = 1)] Span values, int length); + +// Generated stub: +public static partial unsafe Span DuplicateValues(Span values, int length) +{ + SpanMarshaller __values_marshaller = new SpanMarshaller(values, sizeof(WrappedInt)); + for (int i = 0; i < __values_marshaller.ManagedValues.Length; ++i) + { + WrappedInt native = new WrappedInt(__values_marshaller.ManagedValues[i]); + MemoryMarshal.Write(__values_marshaller.NativeValueStorage.Slice(sizeof(WrappedInt) * i), ref native); + } + + IntPtr __retVal_native = __PInvoke__(__values_marshaller.Value, length); + SpanMarshaller __retVal_marshaller = new + { + Value = __retVal_native + }; + __retVal_marshaller.SetUnmarshalledCollectionLength(length); + MemoryMarshal.Cast(__retVal_marshaller.NativeValueStorage).CopyTo(__retVal_marshaller.ManagedValues); + return __retVal_marshaller.ToManaged(); + + [DllImport("Native", EntryPoint="DuplicateValues")] + static extern IntPtr __PInvoke__(IntPtr values, int length); +} +``` + +This design could also be applied to support the built-in array marshalling if it is desired to move that marshalling out of the stub and into shared code. + +#### Future extension to the above model: Non-contiguous collection support + +If a managed or native representation of a collection has a non-contiguous element layout, then developers currently will need to convert to or from array/span types at the interop boundary. This section proposes an API that would enable developers to convert directly between a managed and native non-contiguous collection layout as part of marshalling. + +A new attribute named `GenericCollectionMarshaller` attribute could be added that would specify that the collection is noncontiguous in either managed or native representations. Then additional methods should be added to the generic collection model, and some methods would be removed: + +```diff +- [GenericContiguousCollectionMarshaller] ++ [GenericCollectionMarshaller] +public struct GenericContiguousCollectionMarshallerImpl +{ + // these constructors are required if marshalling from managed to native is supported. + public GenericContiguousCollectionMarshallerImpl(GenericCollection collection, int nativeSizeOfElements); + public GenericContiguousCollectionMarshallerImpl(GenericCollection collection, Span stackSpace, int nativeSizeOfElements); // optional + + public const int StackBufferSize = /* */; // required if the span-based constructor is supplied. + +- public Span ManagedValues { get; } + +- public void SetUnmarshalledCollectionLength(int length); + + public IntPtr Value { get; set; } + +- public unsafe Span NativeValueStorage { get; } + + // The requirements on the Value property are the same as when used with `NativeTypeMarshallingAttribute`. + // The property is required with the generic collection marshalling. + public TNative Value { get; set; } + ++ public ref byte GetOffsetForNativeValueAtIndex(int index); ++ public TCollectionElement GetManagedValueAtIndex(int index); ++ public TCollectionElement SetManagedValueAtIndex(int index); ++ public int Count { get; set; } +} +``` + +The `GetManagedValueAtIndex` method and `Count` getter are used in the process of marshalling from managed to native. The generated code will iterate through `Count` elements (retrieved through `GetManagedValueAtIndex`) and assign their marshalled result to the address represented by `GetOffsetForNativeValueAtIndex` called with the same index. Then either the `Value` property getter will be called or the marshaller's `GetPinnableReference` method will be called, depending on if pinning is supported in the current scenario. + +The `SetManagedValueAtIndex` method and the `Count` setter are used in the process of marshalling from native to managed. The `Count` property will be set to the number of elements that the native collection contains, and the `Value` property will be assigned the result value from native code. Then the stub will iterate through the native collection `Count` times, calling `GetOffsetForNativeValueAtIndex` to get the offset of the native value and calling `SetManagedValueAtIndex` to set the unmarshalled managed value at that index. + +### Pros/Cons of Design 2 + +Pros: + +- Collection type owners do not need to know how to marshal the elements of the collection. +- Custom non-default marshalling of collections of non-blittable types supported with the same code as blittable types. +- Sharing code for marshalling a given collection type reduces IL size on disk. +- Developers can easily enable marshalling their own collection types without needing to modify the source generator. +- Makes no assumptions about native collection layout, so collections like linked lists can be easily supported. + +Cons: + +- Introduces more attribute types into the BCL. +- Introduces more complexity in the marshalling type model. + - It may be worth describing the required members (other than constructors) in interfaces just to simplify the mental load of which members are required for which scenarios. + - A set of interfaces (one for managed-to-native members, one for native-to-managed members, and one for the sequential-specific members) could replace the `GenericContiguousCollectionMarshaller` attribute. +- The base proposal only supports contiguous collections. + - The feeling at time of writing is that we are okay asking developers to convert to/from arrays or spans at the interop boundary. From 51aaa63d6d6f79e81929a394b6a988dba821a7e5 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Tue, 1 Jun 2021 16:05:52 -0700 Subject: [PATCH 095/161] Handle case where void* is a field. (dotnet/runtimelab#1195) * Handle case where void* is a field. Commit migrated from https://github.com/dotnet/runtimelab/commit/41bf5d17bc65e44fc8f8bba118ddb5c51b77ed1e --- .../ConvertToGeneratedDllImportAnalyzer.cs | 15 ++------- .../DllImportGenerator/TypePositionInfo.cs | 1 + .../TypeSymbolExtensions.cs | 3 +- .../CodeSnippets.cs | 33 +++++++++++-------- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs index 2df44242463ee..398a26fa4a98f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs @@ -73,7 +73,7 @@ private static bool RequiresMarshalling(IMethodSymbol method, DllImportData dllI return true; // Check if return value requires marshalling - if (!method.ReturnsVoid && RequiresMarshalling(method.ReturnType)) + if (!method.ReturnsVoid && !method.ReturnType.IsConsideredBlittable()) return true; // Check if parameters require marshalling @@ -82,7 +82,7 @@ private static bool RequiresMarshalling(IMethodSymbol method, DllImportData dllI if (paramType.RefKind != RefKind.None) return true; - if (RequiresMarshalling(paramType.Type)) + if (!paramType.Type.IsConsideredBlittable()) return true; } @@ -110,16 +110,5 @@ private static bool RequiresMarshalling(IMethodSymbol method, DllImportData dllI return false; } - - private static bool RequiresMarshalling(ITypeSymbol typeSymbol) - { - if (typeSymbol.TypeKind == TypeKind.Enum) - return false; - - if (typeSymbol.TypeKind == TypeKind.Pointer) - return false; - - return !typeSymbol.IsConsideredBlittable(); - } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 8d23b274ee3a0..0fc8788e1c919 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -314,6 +314,7 @@ static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol ty static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol, out MarshallingInfo marshallingInfo) { + // Check for an implicit SafeHandle conversion. var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); if (conversion.Exists && conversion.IsImplicit diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 4495704b3dccc..616d87c521c2b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -57,7 +57,8 @@ private static bool HasOnlyBlittableFields(this ITypeSymbol type, HashSet specialType switch { - SpecialType.System_SByte + SpecialType.System_Void + or SpecialType.System_SByte or SpecialType.System_Byte or SpecialType.System_Int16 or SpecialType.System_UInt16 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 b89acc1f63dbc..d19caf2e5f579 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -503,14 +503,24 @@ partial class Test public static string DelegateMarshalAsParametersAndModifiers = MarshalAsParametersAndModifiers("MyDelegate", UnmanagedType.FunctionPtr) + @" delegate int MyDelegate(int a);"; - public static string BlittableStructParametersAndModifiers = BasicParametersAndModifiers("MyStruct") + @" -#pragma warning disable CS0169 -[BlittableType] -struct MyStruct -{ + private static string BlittableMyStruct(string modifier = "") => $@"#pragma warning disable CS0169 +{modifier} unsafe struct MyStruct +{{ private int i; private short s; -}"; + private long l; + private double d; + private int* iptr; + private short* sptr; + private long* lptr; + private double* dptr; + private void* vptr; +}}"; + + public static string BlittableStructParametersAndModifiers = BasicParametersAndModifiers("MyStruct") + $@" +[BlittableType] +{BlittableMyStruct()} +"; public static string ArrayParametersAndModifiers(string elementType) => $@" using System.Runtime.InteropServices; @@ -1045,13 +1055,10 @@ struct Generic public static string MaybeBlittableGenericTypeParametersAndModifiers() => MaybeBlittableGenericTypeParametersAndModifiers(typeof(T).ToString()); - public static string ImplicitlyBlittableStructParametersAndModifiers(string visibility = "") => BasicParametersAndModifiers("ImplicitBlittable") + $@" -#pragma warning disable CS0649 -#pragma warning disable CS0169 -{visibility} struct ImplicitBlittable -{{ - int i; -}}"; + public static string ImplicitlyBlittableStructParametersAndModifiers(string visibility = "") => BasicParametersAndModifiers("MyStruct") + $@" +// Implicitly blittable +{BlittableMyStruct(visibility)} +"; public static string ImplicitlyBlittableGenericTypeParametersAndModifiers(string typeArgument, string visibility = "") => BasicParametersAndModifiers($"Generic<{typeArgument}>") + $@" {visibility} struct Generic From 2ee7b3e27b11d060f8f44d1692f2b7b8414a994d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 2 Jun 2021 19:16:08 -0700 Subject: [PATCH 096/161] Fix memory leaks for return values and some out params. (dotnet/runtimelab#1200) Fix some memory leaks we had where we didn't generate code to free native resources for out parameters that use custom native type marshalling or all return values. Also set a flag in the csproj that enables a nice debugging innerloop option for roslyn components in the csproj settings (in our case running the generator on the integration tests) Commit migrated from https://github.com/dotnet/runtimelab/commit/b11a26add0e6a599d3f87d73015988034c665583 --- .../gen/DllImportGenerator/DllImportGenerator.csproj | 1 + .../Marshalling/CustomNativeTypeMarshaller.cs | 2 +- .../gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs | 2 +- .../gen/DllImportGenerator/StubCodeGenerator.cs | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index dbc6bd335afea..cda46f7058dca 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -10,6 +10,7 @@ Preview enable Microsoft.Interop + true diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs index c2f70b702b8f0..f1bda542f03d0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs @@ -231,7 +231,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } break; case StubCodeContext.Stage.Cleanup: - if (info.RefKind != RefKind.Out && _hasFreeNative) + if (_hasFreeNative) { // .FreeNative(); yield return ExpressionStatement( diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index 7fa6513186c18..652894e056901 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -228,7 +228,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } break; case StubCodeContext.Stage.Cleanup: - if (!info.IsByRef || info.RefKind == RefKind.In) + if (!info.IsManagedReturnPosition && (!info.IsByRef || info.RefKind == RefKind.In)) { yield return IfStatement( IdentifierName(addRefdIdentifier), diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index ea5995414f89b..dce737b7d5a71 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -197,7 +197,7 @@ public BlockSyntax GenerateSyntax() int initialCount = statements.Count; this.CurrentStage = stage; - if (!invokeReturnsVoid && (stage == Stage.Setup || stage == Stage.Unmarshal || stage == Stage.GuaranteedUnmarshal)) + if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Unmarshal or Stage.GuaranteedUnmarshal or Stage.Cleanup)) { // Handle setup and unmarshalling for return var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, this); From 3b2fbeefd26c61399783395b485bcf7f78a3cbef Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 4 Jun 2021 14:27:39 -0700 Subject: [PATCH 097/161] Use GeneratedDllImport in System.Diagnostics.Process (#53702) --- .../BSD/System.Native/Interop.Sysctl.cs | 5 ++-- .../OSX/Interop.libproc.GetProcessInfoById.cs | 4 ++-- .../Common/src/Interop/OSX/Interop.libproc.cs | 24 +++++++++---------- .../Unix/System.Native/Interop.Access.cs | 4 ++-- ...nterop.ConfigureTerminalForChildProcess.cs | 2 +- .../Interop.ForkAndExecProcess.cs | 4 ++-- .../System.Native/Interop.GetGroupList.cs | 4 ++-- .../Unix/System.Native/Interop.GetHostName.cs | 4 ++-- .../System.Native/Interop.GetSetPriority.cs | 8 +++---- .../Unix/System.Native/Interop.Kill.cs | 4 ++-- .../Unix/System.Native/Interop.PathConf.cs | 4 ++-- .../System.Native/Interop.ResourceLimits.cs | 8 +++---- .../Interop.SchedGetSetAffinity.cs | 8 +++---- .../Unix/System.Native/Interop.SysConf.cs | 4 ++-- .../Unix/System.Native/Interop.WaitId.cs | 4 ++-- .../Unix/System.Native/Interop.WaitPid.cs | 4 ++-- .../Advapi32/Interop.AdjustTokenPrivileges.cs | 5 ++++ .../Interop.CreateProcessWithLogon.cs | 4 ++-- .../Advapi32/Interop.LookupPrivilegeValue.cs | 8 ++++++- .../Advapi32/Interop.OpenProcessToken.cs | 4 ++-- .../Windows/Kernel32/Interop.CloseHandle.cs | 5 ++++ .../Interop.CreatePipe_SafeFileHandle.cs | 4 ++-- .../Windows/Kernel32/Interop.CreateProcess.cs | 4 ++-- .../Interop.DuplicateHandle_SafeFileHandle.cs | 4 ++-- .../Interop.DuplicateHandle_SafeWaitHandle.cs | 5 ++++ .../Kernel32/Interop.EnumProcessModules.cs | 4 ++-- .../Windows/Kernel32/Interop.EnumProcesses.cs | 4 ++-- .../Kernel32/Interop.GetComputerName.cs | 15 ++++++++---- .../Kernel32/Interop.GetExitCodeProcess.cs | 4 ++-- .../Kernel32/Interop.GetModuleBaseName.cs | 4 ++-- .../Kernel32/Interop.GetModuleFileNameEx.cs | 4 ++-- .../Kernel32/Interop.GetModuleInformation.cs | 4 ++-- .../Kernel32/Interop.GetPriorityClass.cs | 4 ++-- .../Interop.GetProcessAffinityMask.cs | 4 ++-- .../Windows/Kernel32/Interop.GetProcessId.cs | 4 ++-- .../Interop.GetProcessPriorityBoost.cs | 4 ++-- .../Kernel32/Interop.GetProcessTimes.cs | 8 ++++++- .../Interop.GetProcessWorkingSetSizeEx.cs | 4 ++-- .../Kernel32/Interop.GetThreadPriority.cs | 4 ++-- .../Interop.GetThreadPriorityBoost.cs | 4 ++-- .../Kernel32/Interop.GetThreadTimes.cs | 4 ++-- .../Kernel32/Interop.IsWow64Process_IntPtr.cs | 4 ++-- ...nterop.IsWow64Process_SafeProcessHandle.cs | 4 ++-- .../Windows/Kernel32/Interop.OpenProcess.cs | 8 ++++++- .../Windows/Kernel32/Interop.OpenThread.cs | 4 ++-- .../Kernel32/Interop.SetPriorityClass.cs | 4 ++-- .../Interop.SetProcessAffinityMask.cs | 4 ++-- .../Interop.SetProcessPriorityBoost.cs | 4 ++-- .../Interop.SetProcessWorkingSetSizeEx.cs | 4 ++-- .../Kernel32/Interop.SetThreadAffinityMask.cs | 4 ++-- .../Interop.SetThreadIdealProcessor.cs | 4 ++-- .../Kernel32/Interop.SetThreadPriority.cs | 4 ++-- .../Interop.SetThreadPriorityBoost.cs | 4 ++-- .../Kernel32/Interop.TerminateProcess.cs | 4 ++-- .../Interop.NtQueryInformationProcess.cs | 4 ++-- .../Shell32/Interop.ShellExecuteExW.cs | 4 ++-- .../Windows/User32/Interop.EnumWindows.cs | 2 +- .../User32/Interop.GetWindowTextLengthW.cs | 4 ++-- .../Windows/User32/Interop.GetWindowTextW.cs | 4 ++-- .../Interop.GetWindowThreadProcessId.cs | 2 +- .../Windows/User32/Interop.IsWindowVisible.cs | 2 +- .../User32/Interop.SendMessageTimeout.cs | 2 +- .../User32/Interop.WaitForInputIdle.cs | 4 ++-- .../src/System/Diagnostics/Process.Unix.cs | 4 ++-- .../src/System/Diagnostics/Process.Win32.cs | 5 +++- .../Diagnostics/ProcessManager.Win32.cs | 4 ++-- .../tests/System.IO.FileSystem.Tests.csproj | 1 + ...System.Net.NameResolution.Pal.Tests.csproj | 1 + .../System.Net.Ping.Functional.Tests.csproj | 1 + .../src/System/Environment.Win32.cs | 3 ++- 70 files changed, 182 insertions(+), 138 deletions(-) diff --git a/src/libraries/Common/src/Interop/BSD/System.Native/Interop.Sysctl.cs b/src/libraries/Common/src/Interop/BSD/System.Native/Interop.Sysctl.cs index f524faae9c38e..dd511f97d586d 100644 --- a/src/libraries/Common/src/Interop/BSD/System.Native/Interop.Sysctl.cs +++ b/src/libraries/Common/src/Interop/BSD/System.Native/Interop.Sysctl.cs @@ -16,9 +16,8 @@ internal static partial class Interop { internal static partial class Sys { - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sysctl", SetLastError = true)] - private static extern unsafe int Sysctl(int* name, int namelen, void* value, size_t* len); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sysctl", SetLastError = true)] + private static unsafe partial int Sysctl(int* name, int namelen, void* value, size_t* len); // This is 'raw' sysctl call, only wrapped to allocate memory if needed // caller always needs to free returned buffer using Marshal.FreeHGlobal() diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libproc.GetProcessInfoById.cs b/src/libraries/Common/src/Interop/OSX/Interop.libproc.GetProcessInfoById.cs index 7ac40a21e67f4..f667641d27c99 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libproc.GetProcessInfoById.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libproc.GetProcessInfoById.cs @@ -89,8 +89,8 @@ internal struct proc_taskallinfo /// the data is valid. If the sizes do not match then the data is invalid, most likely due /// to not having enough permissions to query for the data of that specific process /// - [DllImport(Interop.Libraries.libproc, SetLastError = true)] - private static extern unsafe int proc_pidinfo( + [GeneratedDllImport(Interop.Libraries.libproc, SetLastError = true)] + private static unsafe partial int proc_pidinfo( int pid, int flavor, ulong arg, diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs index fd4b968c132ea..fefac9aac1fa8 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs @@ -107,8 +107,8 @@ internal struct proc_fdinfo /// A pointer to the memory block where the PID array will start /// The length of the block of memory allocated for the PID array /// Returns the number of elements (PIDs) in the buffer - [DllImport(Interop.Libraries.libproc, SetLastError = true)] - private static extern unsafe int proc_listallpids( + [GeneratedDllImport(Interop.Libraries.libproc, SetLastError = true)] + private static unsafe partial int proc_listallpids( int* pBuffer, int buffersize); @@ -166,8 +166,8 @@ internal static unsafe int[] proc_listallpids() /// the data is valid. If the sizes do not match then the data is invalid, most likely due /// to not having enough permissions to query for the data of that specific process /// - [DllImport(Interop.Libraries.libproc, SetLastError = true)] - private static extern unsafe int proc_pidinfo( + [GeneratedDllImport(Interop.Libraries.libproc, SetLastError = true)] + private static unsafe partial int proc_pidinfo( int pid, int flavor, ulong arg, @@ -187,8 +187,8 @@ private static extern unsafe int proc_pidinfo( /// the data is valid. If the sizes do not match then the data is invalid, most likely due /// to not having enough permissions to query for the data of that specific process /// - [DllImport(Interop.Libraries.libproc, SetLastError = true)] - private static extern unsafe int proc_pidinfo( + [GeneratedDllImport(Interop.Libraries.libproc, SetLastError = true)] + private static unsafe partial int proc_pidinfo( int pid, int flavor, ulong arg, @@ -208,8 +208,8 @@ private static extern unsafe int proc_pidinfo( /// the data is valid. If the sizes do not match then the data is invalid, most likely due /// to not having enough permissions to query for the data of that specific process /// - [DllImport(Interop.Libraries.libproc, SetLastError = true)] - private static extern unsafe int proc_pidinfo( + [GeneratedDllImport(Interop.Libraries.libproc, SetLastError = true)] + private static unsafe partial int proc_pidinfo( int pid, int flavor, ulong arg, @@ -307,8 +307,8 @@ private static extern unsafe int proc_pidinfo( /// A pointer to an allocated block of memory that will be filled with the process path /// The size of the buffer, should be PROC_PIDPATHINFO_MAXSIZE /// Returns the length of the path returned on success - [DllImport(Interop.Libraries.libproc, SetLastError = true)] - private static extern unsafe int proc_pidpath( + [GeneratedDllImport(Interop.Libraries.libproc, SetLastError = true)] + private static unsafe partial int proc_pidpath( int pid, byte* buffer, uint bufferSize); @@ -346,8 +346,8 @@ internal static unsafe string proc_pidpath(int pid) /// Specifies the type of struct that is passed in to buffer. Should be RUSAGE_INFO_V3 to specify a rusage_info_v3 struct. /// A buffer to be filled with rusage_info data /// Returns 0 on success; on fail, -1 and errno is set with the error code - [DllImport(Interop.Libraries.libproc, SetLastError = true)] - private static extern unsafe int proc_pid_rusage( + [GeneratedDllImport(Interop.Libraries.libproc, SetLastError = true)] + private static unsafe partial int proc_pid_rusage( int pid, int flavor, rusage_info_v3* buffer); 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 bfeb1cf9e8a15..fa33ed0947169 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 */ } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Access", SetLastError = true)] - internal static extern int Access(string path, AccessMode mode); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Access", SetLastError = true, CharSet = CharSet.Ansi)] + internal static partial int Access(string path, AccessMode mode); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs index 0801ed3b84e05..da8e47395d885 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class Sys { [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConfigureTerminalForChildProcess")] - internal static extern void ConfigureTerminalForChildProcess(bool childUsesTerminal); + internal static extern void ConfigureTerminalForChildProcess(int childUsesTerminal); } } 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 585437706a1c4..6f50e53615553 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,8 +40,8 @@ internal static unsafe int ForkAndExecProcess( } } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ForkAndExecProcess", SetLastError = true)] - private static extern unsafe int ForkAndExecProcess( + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ForkAndExecProcess", SetLastError = true, CharSet = CharSet.Ansi)] + private static unsafe partial int ForkAndExecProcess( string filename, byte** argv, byte** envp, string? cwd, int redirectStdin, int redirectStdout, int redirectStderr, int setUser, uint userId, uint groupId, uint* groups, int groupsLength, 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 55960b5dbf06c..ec6228c91d77a 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); } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroupList", SetLastError = true)] - private static extern unsafe int GetGroupList(string name, uint group, uint* groups, int* ngroups); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroupList", SetLastError = true, CharSet = CharSet.Ansi)] + 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.GetHostName.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetHostName.cs index 985edb4cadc22..72710dcf7e1f8 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetHostName.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetHostName.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostName", SetLastError = true)] - private static extern unsafe int GetHostName(byte* name, int nameLength); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostName", SetLastError = true)] + private static unsafe partial int GetHostName(byte* name, int nameLength); internal static unsafe string GetHostName() { diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSetPriority.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSetPriority.cs index 87eb5d0ac7a2d..4677fd8f63266 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSetPriority.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSetPriority.cs @@ -16,11 +16,11 @@ internal enum PriorityWhich : int PRIO_USER = 2, } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPriority", SetLastError = true)] - private static extern int GetPriority(PriorityWhich which, int who); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPriority", SetLastError = true)] + private static partial int GetPriority(PriorityWhich which, int who); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetPriority", SetLastError = true)] - internal static extern int SetPriority(PriorityWhich which, int who, int nice); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetPriority", SetLastError = true)] + internal static partial int SetPriority(PriorityWhich which, int who, int nice); /// /// Wrapper around getpriority since getpriority can return from -20 to 20; therefore, diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Kill.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Kill.cs index 80cfb59e173d8..1fb42efc27ec2 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Kill.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Kill.cs @@ -15,7 +15,7 @@ internal enum Signals : int SIGSTOP = 19 } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Kill", SetLastError = true)] - internal static extern int Kill(int pid, Signals signal); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Kill", SetLastError = true)] + internal static partial int Kill(int pid, Signals signal); } } 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 5a9f27b7db06c..dc0501f171648 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, } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PathConf", SetLastError = true)] - private static extern int PathConf(string path, PathConfName name); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PathConf", SetLastError = true, CharSet = CharSet.Ansi)] + private static partial int PathConf(string path, PathConfName name); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ResourceLimits.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ResourceLimits.cs index e3a10b7d13681..1d25b5c82ade9 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ResourceLimits.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ResourceLimits.cs @@ -30,10 +30,10 @@ internal struct RLimit internal ulong MaximumLimit; } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetRLimit", SetLastError = true)] - internal static extern int GetRLimit(RlimitResources resourceType, out RLimit limits); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetRLimit", SetLastError = true)] + internal static partial int GetRLimit(RlimitResources resourceType, out RLimit limits); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetRLimit", SetLastError = true)] - internal static extern int SetRLimit(RlimitResources resourceType, ref RLimit limits); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetRLimit", SetLastError = true)] + internal static partial int SetRLimit(RlimitResources resourceType, ref RLimit limits); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SchedGetSetAffinity.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SchedGetSetAffinity.cs index 0a39741df9e55..e304cc29d2dc0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SchedGetSetAffinity.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SchedGetSetAffinity.cs @@ -8,10 +8,10 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SchedSetAffinity", SetLastError = true)] - internal static extern int SchedSetAffinity(int pid, ref IntPtr mask); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SchedSetAffinity", SetLastError = true)] + internal static partial int SchedSetAffinity(int pid, ref IntPtr mask); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SchedGetAffinity", SetLastError = true)] - internal static extern int SchedGetAffinity(int pid, out IntPtr mask); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SchedGetAffinity", SetLastError = true)] + internal static partial int SchedGetAffinity(int pid, out IntPtr mask); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysConf.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysConf.cs index 022584ab95f4c..5790ad50046de 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysConf.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysConf.cs @@ -13,7 +13,7 @@ internal enum SysConfName _SC_PAGESIZE = 2 } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysConf", SetLastError = true)] - internal static extern long SysConf(SysConfName name); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysConf", SetLastError = true)] + internal static partial long SysConf(SysConfName name); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitId.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitId.cs index ec9c19ad6776e..4701e4729c37e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitId.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitId.cs @@ -16,7 +16,7 @@ internal static partial class Sys /// 2) if no children are terminated, 0 is returned /// 3) on error, -1 is returned /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_WaitIdAnyExitedNoHangNoWait", SetLastError = true)] - internal static extern int WaitIdAnyExitedNoHangNoWait(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_WaitIdAnyExitedNoHangNoWait", SetLastError = true)] + internal static partial int WaitIdAnyExitedNoHangNoWait(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitPid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitPid.cs index 766d47faeb79b..129ea867cb620 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitPid.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.WaitPid.cs @@ -17,7 +17,7 @@ internal static partial class Sys /// 3) if the child has not yet terminated, 0 is returned /// 4) on error, -1 is returned. /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_WaitPidExitedNoHang", SetLastError = true)] - internal static extern int WaitPidExitedNoHang(int pid, out int exitCode); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_WaitPidExitedNoHang", SetLastError = true)] + internal static partial int WaitPidExitedNoHang(int pid, out int exitCode); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AdjustTokenPrivileges.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AdjustTokenPrivileges.cs index b93d0660e61ab..5a3faa36313b3 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AdjustTokenPrivileges.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AdjustTokenPrivileges.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + internal static unsafe partial bool AdjustTokenPrivileges( +#else [DllImport(Libraries.Advapi32, SetLastError = true)] internal static extern unsafe bool AdjustTokenPrivileges( +#endif SafeTokenHandle TokenHandle, bool DisableAllPrivileges, TOKEN_PRIVILEGE* NewState, 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 60f2745df3d6c..53e713e1931d3 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, BestFitMapping = false, EntryPoint = "CreateProcessWithLogonW")] - internal static extern unsafe bool CreateProcessWithLogonW( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, EntryPoint = "CreateProcessWithLogonW")] + internal static unsafe partial bool CreateProcessWithLogonW( string userName, string domain, IntPtr password, 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 af16874c9bd7b..87b7b56cd63be 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs @@ -7,8 +7,14 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "LookupPrivilegeValueW")] + internal static partial bool LookupPrivilegeValue( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "LookupPrivilegeValueW")] - internal static extern bool LookupPrivilegeValue([MarshalAs(UnmanagedType.LPTStr)] string? lpSystemName, [MarshalAs(UnmanagedType.LPTStr)] string lpName, out LUID lpLuid); + internal static extern bool LookupPrivilegeValue( +#endif + [MarshalAs(UnmanagedType.LPTStr)] string? lpSystemName, [MarshalAs(UnmanagedType.LPTStr)] string lpName, out LUID lpLuid); internal const string SeDebugPrivilege = "SeDebugPrivilege"; } 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 3e992403871ce..d01c7725ea9d5 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 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, out SafeTokenHandle TokenHandle); + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, out SafeTokenHandle TokenHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CloseHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CloseHandle.cs index bf767ece3d2d1..9c12510d83f26 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CloseHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CloseHandle.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool CloseHandle(IntPtr handle); +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool CloseHandle(IntPtr handle); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafeFileHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafeFileHandle.cs index ae4e43a73a386..46c64430603ec 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafeFileHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafeFileHandle.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool CreatePipe(out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, ref SECURITY_ATTRIBUTES lpPipeAttributes, int nSize); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool CreatePipe(out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, ref SECURITY_ATTRIBUTES lpPipeAttributes, int nSize); } } 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 ede776e82438f..f794ecd3453eb 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs @@ -10,8 +10,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "CreateProcessW")] - internal static extern unsafe bool CreateProcess( + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CreateProcessW")] + internal static unsafe partial bool CreateProcess( string? lpApplicationName, char* lpCommandLine, ref SECURITY_ATTRIBUTES procSecAttrs, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeFileHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeFileHandle.cs index fb542316a2438..843b39780ac7a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeFileHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeFileHandle.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool DuplicateHandle( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool DuplicateHandle( IntPtr hSourceProcessHandle, SafeHandle hSourceHandle, IntPtr hTargetProcess, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs index 5749d82479f87..f68f28bc1eadc 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool DuplicateHandle( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool DuplicateHandle( +#endif IntPtr hSourceProcessHandle, SafeHandle hSourceHandle, IntPtr hTargetProcess, 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 5a5ae4ddca197..019e4e9a7db0e 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 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32EnumProcessModules")] - internal static extern bool EnumProcessModules(SafeProcessHandle handle, IntPtr[]? modules, int size, out int needed); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32EnumProcessModules")] + 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 f5298dc2cc879..60cc47d3e6113 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 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32EnumProcesses")] - internal static extern bool EnumProcesses(int[] processIds, int size, out int needed); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32EnumProcesses")] + internal static partial bool EnumProcesses(int[] processIds, int size, out int needed); } } 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 4d41070638856..e186ac2be5725 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs @@ -10,7 +10,7 @@ internal static partial class Interop internal static partial class Kernel32 { [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "GetComputerNameW", ExactSpelling = true)] - private static extern int GetComputerName(ref char lpBuffer, ref uint nSize); + private static unsafe extern int GetComputerName(char* lpBuffer, uint* nSize); // maximum length of the NETBIOS name (not including NULL) private const int MAX_COMPUTERNAME_LENGTH = 15; @@ -19,10 +19,15 @@ internal static partial class Kernel32 { Span buffer = stackalloc char[MAX_COMPUTERNAME_LENGTH + 1]; uint length = (uint)buffer.Length; - - return GetComputerName(ref MemoryMarshal.GetReference(buffer), ref length) != 0 ? - buffer.Slice(0, (int)length).ToString() : - null; + unsafe + { + fixed (char* lpBuffer = &MemoryMarshal.GetReference(buffer)) + { + return GetComputerName(lpBuffer, &length) != 0 ? + buffer.Slice(0, (int)length).ToString() : + null; + } + } } } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetExitCodeProcess.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetExitCodeProcess.cs index 6184ad87a5bc5..05260a7d4882d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetExitCodeProcess.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetExitCodeProcess.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool GetExitCodeProcess(SafeProcessHandle processHandle, out int exitCode); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool GetExitCodeProcess(SafeProcessHandle processHandle, out int exitCode); } } 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 9cfb175b0a16c..9903c0c0c573d 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 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "K32GetModuleBaseNameW")] - internal static extern int GetModuleBaseName(SafeProcessHandle processHandle, IntPtr moduleHandle, [Out] char[] baseName, int size); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32GetModuleBaseNameW")] + 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.GetModuleFileNameEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileNameEx.cs index fc99fca9a0942..9e84b60d47519 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 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "K32GetModuleFileNameExW")] - internal static extern int GetModuleFileNameEx(SafeProcessHandle processHandle, IntPtr moduleHandle, [Out] char[] baseName, int size); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32GetModuleFileNameExW")] + 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.GetModuleInformation.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs index 6ec386711ca4c..a63d7592a54c6 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32GetModuleInformation")] - private static extern bool GetModuleInformation(SafeProcessHandle processHandle, IntPtr moduleHandle, out NtModuleInfo ntModuleInfo, int size); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32GetModuleInformation")] + 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) => GetModuleInformation(processHandle, moduleHandle, out ntModuleInfo, sizeof(NtModuleInfo)); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetPriorityClass.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetPriorityClass.cs index 385b534acb3f8..9ce76e68252ae 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetPriorityClass.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetPriorityClass.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern int GetPriorityClass(SafeProcessHandle handle); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial int GetPriorityClass(SafeProcessHandle handle); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessAffinityMask.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessAffinityMask.cs index 0cd7484e25289..ced602109c306 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessAffinityMask.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessAffinityMask.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool GetProcessAffinityMask(SafeProcessHandle handle, out IntPtr processMask, out IntPtr systemMask); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool GetProcessAffinityMask(SafeProcessHandle handle, out IntPtr processMask, out IntPtr systemMask); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessId.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessId.cs index 9d9167df4a13c..5261c0d5a065d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessId.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessId.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] - public static extern int GetProcessId(SafeProcessHandle nativeHandle); + [GeneratedDllImport(Libraries.Kernel32)] + public static partial int GetProcessId(SafeProcessHandle nativeHandle); } } 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 93619bebe7f97..d5efb5e07cabd 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 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool GetProcessPriorityBoost(SafeProcessHandle handle, out bool disabled); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + 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 1c585d6e74a80..e76f80712ba4a 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,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool GetProcessTimes( +#else [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool GetProcessTimes(SafeProcessHandle handle, out long creation, out long exit, out long kernel, out long user); + internal static extern bool GetProcessTimes( +#endif + 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.GetProcessWorkingSetSizeEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessWorkingSetSizeEx.cs index 64284d546f7fa..74ce0e8a6a3a5 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessWorkingSetSizeEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessWorkingSetSizeEx.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool GetProcessWorkingSetSizeEx(SafeProcessHandle handle, out IntPtr min, out IntPtr max, out int flags); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool GetProcessWorkingSetSizeEx(SafeProcessHandle handle, out IntPtr min, out IntPtr max, out int flags); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriority.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriority.cs index b55390030f24b..5e30e6b5d085d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriority.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriority.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern int GetThreadPriority(SafeThreadHandle handle); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial int GetThreadPriority(SafeThreadHandle handle); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriorityBoost.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriorityBoost.cs index e9a9bc9924174..18cb3cb262384 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriorityBoost.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadPriorityBoost.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool GetThreadPriorityBoost(SafeThreadHandle handle, out bool disabled); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool GetThreadPriorityBoost(SafeThreadHandle handle, out bool disabled); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadTimes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadTimes.cs index 54e2e43458ccb..0d4d5b03988e0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadTimes.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetThreadTimes.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool GetThreadTimes(SafeThreadHandle handle, out long creation, out long exit, out long kernel, out long user); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool GetThreadTimes(SafeThreadHandle handle, out long creation, out long exit, out long kernel, out long user); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_IntPtr.cs index 60ddd4225b2a0..cfd93cc036b7f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_IntPtr.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool IsWow64Process(IntPtr hProcess, out bool Wow64Process); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool IsWow64Process(IntPtr hProcess, out bool Wow64Process); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_SafeProcessHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_SafeProcessHandle.cs index eb365d7e18a54..764456f73e116 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_SafeProcessHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.IsWow64Process_SafeProcessHandle.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool IsWow64Process(SafeProcessHandle hProcess, out bool Wow64Process); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool IsWow64Process(SafeProcessHandle hProcess, out bool Wow64Process); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs index 970193fe756ef..2eaa7a9e5f597 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs @@ -8,7 +8,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SafeProcessHandle OpenProcess( +#else [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern SafeProcessHandle OpenProcess(int access, bool inherit, int processId); + internal static extern SafeProcessHandle OpenProcess( +#endif + int access, bool inherit, int processId); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenThread.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenThread.cs index 0eebf8b61d96d..dab1c7c79d964 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenThread.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenThread.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern SafeThreadHandle OpenThread(int access, bool inherit, int threadId); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SafeThreadHandle OpenThread(int access, bool inherit, int threadId); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetPriorityClass.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetPriorityClass.cs index eaa743fd26c36..4793622b546a4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetPriorityClass.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetPriorityClass.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool SetPriorityClass(SafeProcessHandle handle, int priorityClass); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool SetPriorityClass(SafeProcessHandle handle, int priorityClass); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessAffinityMask.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessAffinityMask.cs index f4bf52550ae8b..d95af73e97151 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessAffinityMask.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessAffinityMask.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool SetProcessAffinityMask(SafeProcessHandle handle, IntPtr mask); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool SetProcessAffinityMask(SafeProcessHandle handle, IntPtr mask); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessPriorityBoost.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessPriorityBoost.cs index 73263e99458fc..069c1a6227871 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessPriorityBoost.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessPriorityBoost.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool SetProcessPriorityBoost(SafeProcessHandle handle, bool disabled); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool SetProcessPriorityBoost(SafeProcessHandle handle, bool disabled); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessWorkingSetSizeEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessWorkingSetSizeEx.cs index 06b06a704675a..069e3099e4221 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessWorkingSetSizeEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetProcessWorkingSetSizeEx.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool SetProcessWorkingSetSizeEx(SafeProcessHandle handle, IntPtr min, IntPtr max, int flags); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool SetProcessWorkingSetSizeEx(SafeProcessHandle handle, IntPtr min, IntPtr max, int flags); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadAffinityMask.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadAffinityMask.cs index 54120f20d8bcd..32270d39ec9c8 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadAffinityMask.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadAffinityMask.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr SetThreadAffinityMask(SafeThreadHandle handle, IntPtr mask); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial IntPtr SetThreadAffinityMask(SafeThreadHandle handle, IntPtr mask); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadIdealProcessor.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadIdealProcessor.cs index 3d4f3e9d0b22f..3614ac2a34e5b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadIdealProcessor.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadIdealProcessor.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern int SetThreadIdealProcessor(SafeThreadHandle handle, int processor); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial int SetThreadIdealProcessor(SafeThreadHandle handle, int processor); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriority.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriority.cs index 4024214bc64dc..b7910e8283053 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriority.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriority.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool SetThreadPriority(SafeThreadHandle handle, int priority); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool SetThreadPriority(SafeThreadHandle handle, int priority); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriorityBoost.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriorityBoost.cs index b285164670226..479acffcdfe75 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriorityBoost.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadPriorityBoost.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool SetThreadPriorityBoost(SafeThreadHandle handle, bool disabled); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool SetThreadPriorityBoost(SafeThreadHandle handle, bool disabled); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TerminateProcess.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TerminateProcess.cs index 37dfec5d196f3..e835fce96eea5 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TerminateProcess.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TerminateProcess.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool TerminateProcess(SafeProcessHandle processHandle, int exitCode); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool TerminateProcess(SafeProcessHandle processHandle, int exitCode); } } diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs index 24db7e74756d0..b591db05d1c0d 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class NtDll { - [DllImport(Libraries.NtDll, ExactSpelling = true)] - internal static extern unsafe uint NtQueryInformationProcess(SafeProcessHandle ProcessHandle, int ProcessInformationClass, void* ProcessInformation, uint ProcessInformationLength, out uint ReturnLength); + [GeneratedDllImport(Libraries.NtDll, ExactSpelling = true)] + internal static unsafe partial uint NtQueryInformationProcess(SafeProcessHandle ProcessHandle, int ProcessInformationClass, void* ProcessInformation, uint ProcessInformationLength, out uint ReturnLength); } } 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 2d2213ae70b0b..eab55a0f92914 100644 --- a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs +++ b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs @@ -50,8 +50,8 @@ internal unsafe struct SHELLEXECUTEINFO internal const uint SEE_MASK_NOCLOSEPROCESS = 0x00000040; internal const uint SEE_MASK_FLAG_NO_UI = 0x00000400; - [DllImport(Libraries.Shell32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe bool ShellExecuteExW( + [GeneratedDllImport(Libraries.Shell32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial bool ShellExecuteExW( SHELLEXECUTEINFO* pExecInfo); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs index 853738f9a61f3..a7a0fa0bec1cd 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class User32 { [DllImport(Libraries.User32)] - public static extern unsafe bool EnumWindows(delegate* unmanaged callback, IntPtr extraData); + public static extern unsafe int EnumWindows(delegate* unmanaged callback, IntPtr extraData); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs index 3acbfa271c7b7..24d2cdde6438a 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, SetLastError = true, ExactSpelling = true)] - public static extern int GetWindowTextLengthW(IntPtr hWnd); + [GeneratedDllImport(Libraries.User32, SetLastError = true, ExactSpelling = true)] + public static partial int GetWindowTextLengthW(IntPtr hWnd); } } 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 2590f25f465ec..2e11079cd1096 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 { - [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] - public static extern unsafe int GetWindowTextW(IntPtr hWnd, char* lpString, int nMaxCount); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] + public static unsafe partial int GetWindowTextW(IntPtr hWnd, char* lpString, int nMaxCount); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs index 33863ed425912..3b145fea4cc29 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs @@ -9,7 +9,7 @@ internal static partial class Interop internal static partial class User32 { [DllImport(Libraries.User32, ExactSpelling = true)] - public static extern int GetWindowThreadProcessId(IntPtr handle, out int processId); + public static unsafe extern int GetWindowThreadProcessId(IntPtr handle, int* processId); [DllImport(Libraries.User32, ExactSpelling = true)] public static extern int GetWindowThreadProcessId(HandleRef handle, out int processId); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs index 5e819d26db630..d2f41577961a6 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class User32 { [DllImport(Libraries.User32)] - public static extern bool IsWindowVisible(IntPtr hWnd); + public static extern int IsWindowVisible(IntPtr hWnd); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs index 7472803ade678..c84dfdab7378c 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class User32 { [DllImport(Libraries.User32, EntryPoint = "SendMessageTimeoutW")] - public static extern IntPtr SendMessageTimeout(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, int flags, int timeout, out IntPtr pdwResult); + public static unsafe extern IntPtr SendMessageTimeout(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, int flags, int timeout, IntPtr* pdwResult); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.WaitForInputIdle.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.WaitForInputIdle.cs index f6d3667775628..e4f98acb30c55 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.WaitForInputIdle.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.WaitForInputIdle.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32)] - public static extern int WaitForInputIdle(SafeProcessHandle handle, int milliseconds); + [GeneratedDllImport(Libraries.User32)] + public static partial int WaitForInputIdle(SafeProcessHandle handle, int milliseconds); } } diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs index 0894dd9e6f7a0..691036752fadb 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs @@ -1059,7 +1059,7 @@ internal static void ConfigureTerminalForChildProcesses(int increment) Debug.Assert(s_processStartLock.IsReadLockHeld); // At least one child is using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: true); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 1); } else { @@ -1068,7 +1068,7 @@ internal static void ConfigureTerminalForChildProcesses(int increment) if (childrenUsingTerminalRemaining == 0) { // No more children are using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: false); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 0); } } } diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Win32.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Win32.cs index 18aff1fb17238..7a0d228d287d6 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Win32.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Win32.cs @@ -288,7 +288,10 @@ private bool IsRespondingCore() } IntPtr result; - return Interop.User32.SendMessageTimeout(mainWindow, WM_NULL, IntPtr.Zero, IntPtr.Zero, SMTO_ABORTIFHUNG, 5000, out result) != (IntPtr)0; + unsafe + { + return Interop.User32.SendMessageTimeout(mainWindow, WM_NULL, IntPtr.Zero, IntPtr.Zero, SMTO_ABORTIFHUNG, 5000, &result) != (IntPtr)0; + } } public bool Responding diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs index 53c9c743de856..ab0dec62ecf9a 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs @@ -42,7 +42,7 @@ public static unsafe IntPtr FindMainWindow(int processId) private static bool IsMainWindow(IntPtr handle) { - return (Interop.User32.GetWindow(handle, GW_OWNER) == IntPtr.Zero) && Interop.User32.IsWindowVisible(handle); + return (Interop.User32.GetWindow(handle, GW_OWNER) == IntPtr.Zero) && (Interop.User32.IsWindowVisible(handle) != 0); } [UnmanagedCallersOnly] @@ -51,7 +51,7 @@ private static unsafe Interop.BOOL EnumWindowsCallback(IntPtr handle, IntPtr ext MainWindowFinder* instance = (MainWindowFinder*)extraParameter; int processId = 0; // Avoid uninitialized variable if the window got closed in the meantime - Interop.User32.GetWindowThreadProcessId(handle, out processId); + Interop.User32.GetWindowThreadProcessId(handle, &processId); if ((processId == instance->_processId) && IsMainWindow(handle)) { diff --git a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj index dba6172218ca0..fac982e534a2b 100644 --- a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj +++ b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj @@ -5,6 +5,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser --working-dir=/test-dir + true diff --git a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj index 7b2b9ee2c9fd6..fe19804a3d825 100644 --- a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj +++ b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj @@ -5,6 +5,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser annotations true + true diff --git a/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj b/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj index 86a7dacccaefd..e83bfdd22273f 100644 --- a/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj +++ b/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj @@ -4,6 +4,7 @@ true true true + true diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs index a499d8984371e..adf2e680d326e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs @@ -55,7 +55,8 @@ private static void SetEnvironmentVariableFromRegistry(string variable, string? // send a WM_SETTINGCHANGE message to all windows fixed (char* lParam = "Environment") { - IntPtr r = Interop.User32.SendMessageTimeout(new IntPtr(Interop.User32.HWND_BROADCAST), Interop.User32.WM_SETTINGCHANGE, IntPtr.Zero, (IntPtr)lParam, 0, 1000, out IntPtr _); + IntPtr unused; + IntPtr r = Interop.User32.SendMessageTimeout(new IntPtr(Interop.User32.HWND_BROADCAST), Interop.User32.WM_SETTINGCHANGE, IntPtr.Zero, (IntPtr)lParam, 0, 1000, &unused); Debug.Assert(r != IntPtr.Zero, "SetEnvironmentVariable failed: " + Marshal.GetLastPInvokeError()); } } From 42e903c2d869a177c949d297dfcaeaa77dcf2c51 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 7 Jun 2021 15:32:45 -0700 Subject: [PATCH 098/161] Use GeneratedDllImport in System.IO.FileSystem (#53830) * Convert System.IO.FileSystem to DllImport source generator --- eng/Versions.props | 2 +- .../Interop/Unix/System.Native/Interop.ChMod.cs | 4 ++-- .../Unix/System.Native/Interop.CopyFile.cs | 4 ++-- .../Unix/System.Native/Interop.LChflags.cs | 4 ++-- .../Interop/Unix/System.Native/Interop.Link.cs | 4 ++-- .../Interop/Unix/System.Native/Interop.MkDir.cs | 4 ++-- .../Unix/System.Native/Interop.MountPoints.cs | 4 ++-- .../Unix/System.Native/Interop.ReadDir.cs | 12 ++++++------ .../Interop/Unix/System.Native/Interop.Rename.cs | 4 ++-- .../Interop/Unix/System.Native/Interop.RmDir.cs | 4 ++-- .../Unix/System.Native/Interop.Stat.Span.cs | 8 ++++---- .../Unix/System.Native/Interop.UTimensat.cs | 4 ++-- .../Interop/Unix/System.Native/Interop.Unlink.cs | 4 ++-- .../Windows/Advapi32/Interop.EncryptDecrypt.cs | 8 ++++---- .../Windows/Kernel32/Interop.CopyFileEx.cs | 4 ++-- .../Windows/Kernel32/Interop.CreateDirectory.cs | 4 ++-- .../Windows/Kernel32/Interop.CreateFile.cs | 4 ++-- .../Kernel32/Interop.CreateFile_IntPtr.cs | 4 ++-- .../Windows/Kernel32/Interop.DeleteFile.cs | 4 ++-- .../Kernel32/Interop.DeleteVolumeMountPoint.cs | 4 ++-- .../Windows/Kernel32/Interop.FindClose.cs | 4 ++-- .../Kernel32/Interop.GetFileAttributesEx.cs | 4 ++-- .../Windows/Kernel32/Interop.GetLogicalDrives.cs | 4 ++-- .../Kernel32/Interop.GetVolumeInformation.cs | 4 ++-- .../Windows/Kernel32/Interop.MoveFileEx.cs | 4 ++-- .../Windows/Kernel32/Interop.RemoveDirectory.cs | 4 ++-- .../Windows/Kernel32/Interop.ReplaceFile.cs | 4 ++-- .../Kernel32/Interop.SetFileAttributes.cs | 4 ++-- .../Interop.SetFileInformationByHandle.cs | 4 ++-- .../Kernel32/Interop.SetThreadErrorMode.cs | 4 ++-- .../Windows/NtDll/Interop.NtCreateFile.cs | 16 +++++++++------- .../NtDll/Interop.NtQueryDirectoryFile.cs | 4 ++-- .../IO/Enumeration/FileSystemEnumerator.Unix.cs | 7 ++++++- .../IO/Enumeration/FileSystemEnumerator.Win32.cs | 3 ++- .../src/System/TimeZoneInfo.Unix.cs | 2 +- 35 files changed, 87 insertions(+), 79 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 62bb9fca29dee..f26cbe79f7252 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -175,7 +175,7 @@ 9.0.1-alpha.1.21267.1 9.0.1-alpha.1.21267.1 - 1.0.0-alpha.21268.4 + 1.0.0-alpha.21301.2 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 c3a09ec513e2a..044f8cd414ac6 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 { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChMod", SetLastError = true)] - internal static extern int ChMod(string path, int mode); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChMod", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int ChMod(string path, int mode); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.CopyFile.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.CopyFile.cs index 8967e3fb2545f..89217982ea51b 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.CopyFile.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.CopyFile.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CopyFile", SetLastError = true)] - internal static extern int CopyFile(SafeFileHandle source, SafeFileHandle destination); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CopyFile", SetLastError = true)] + internal static partial int CopyFile(SafeFileHandle source, SafeFileHandle destination); } } 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 03afef646f086..17ba8e3233223 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,8 +14,8 @@ internal enum UserFlags : uint UF_HIDDEN = 0x8000 } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflags", SetLastError = true)] - internal static extern int LChflags(string path, uint flags); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflags", CharSet = CharSet.Ansi, 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 64d1a32d27ba5..6fca0a14d003f 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 { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Link", SetLastError = true)] - internal static extern int Link(string source, string link); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Link", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int Link(string source, string link); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MkDir.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MkDir.cs index 8779967fd5d62..499b1e74597e9 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MkDir.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MkDir.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MkDir", SetLastError = true)] - internal static extern int MkDir(string path, int mode); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MkDir", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int MkDir(string path, int mode); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs index 716725a3b1944..1f547971e010f 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs @@ -11,8 +11,8 @@ internal static partial class Sys [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private unsafe delegate void MountPointFound(byte* name); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetAllMountPoints", SetLastError = true)] - private static extern int GetAllMountPoints(MountPointFound mpf); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetAllMountPoints", SetLastError = true)] + private static partial int GetAllMountPoints(MountPointFound mpf); internal static string[] GetAllMountPoints() { 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 67a8a6bfc9bd3..4801498489d61 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,17 +53,17 @@ internal ReadOnlySpan GetName(Span buffer) } } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", SetLastError = true)] - internal static extern IntPtr OpenDir(string path); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial IntPtr OpenDir(string path); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetReadDirRBufferSize", SetLastError = false)] [SuppressGCTransition] internal static extern int GetReadDirRBufferSize(); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadDirR", SetLastError = false)] - internal static extern unsafe int ReadDirR(IntPtr dir, byte* buffer, int bufferSize, out DirectoryEntry outputEntry); + [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadDirR")] + internal static unsafe extern int ReadDirR(IntPtr dir, byte* buffer, int bufferSize, DirectoryEntry* outputEntry); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CloseDir", SetLastError = true)] - internal static extern int CloseDir(IntPtr dir); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CloseDir", SetLastError = true)] + internal static partial int CloseDir(IntPtr dir); } } 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 be81942392d6d..8670f15a7ba40 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 @@ -16,7 +16,7 @@ internal static partial class Sys /// /// Returns 0 on success; otherwise, returns -1 /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Rename", SetLastError = true)] - internal static extern int Rename(string oldPath, string newPath); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Rename", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int Rename(string oldPath, string newPath); } } 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 5f178a33f7e4c..24b04035262c2 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 /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RmDir", SetLastError = true)] - internal static extern int RmDir(string path); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RmDir", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int RmDir(string path); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs index 3c638cb60aa52..0d6137f8de3e3 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs @@ -13,8 +13,8 @@ internal static partial class Sys // without putting too much pressure on the stack. private const int StackBufferSize = 256; - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", SetLastError = true)] - internal static extern int Stat(ref byte path, out FileStatus output); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", SetLastError = true)] + internal static partial int Stat(ref byte path, out FileStatus output); internal static int Stat(ReadOnlySpan path, out FileStatus output) { @@ -24,8 +24,8 @@ internal static int Stat(ReadOnlySpan path, out FileStatus output) return result; } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", SetLastError = true)] - internal static extern int LStat(ref byte path, out FileStatus output); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", SetLastError = true)] + internal static partial int LStat(ref byte path, out FileStatus output); internal static int LStat(ReadOnlySpan path, out FileStatus output) { 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 3477c6ae6fc91..dd9ab9014508c 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 /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UTimensat", SetLastError = true)] - internal static extern unsafe int UTimensat(string path, TimeSpec* times); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UTimensat", CharSet = CharSet.Ansi, 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 c71ffe645edd3..fed2f15688ab7 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 { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Unlink", SetLastError = true)] - internal static extern int Unlink(string pathname); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Unlink", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial int Unlink(string pathname); } } 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 14cf346be531f..8d627e5b5b312 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs @@ -11,8 +11,8 @@ internal static partial class Advapi32 /// /// WARNING: This method does not implicitly handle long paths. Use EncryptFile. /// - [DllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] - private static extern bool EncryptFilePrivate(string lpFileName); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + private static partial bool EncryptFilePrivate(string lpFileName); internal static bool EncryptFile(string path) { @@ -23,8 +23,8 @@ internal static bool EncryptFile(string path) /// /// WARNING: This method does not implicitly handle long paths. Use DecryptFile. /// - [DllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] - private static extern bool DecryptFileFilePrivate(string lpFileName, int dwReserved); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + private static partial bool DecryptFileFilePrivate(string lpFileName, int dwReserved); internal static bool DecryptFile(string path) { 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 f0766d2477b26..176c0104f4432 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs @@ -12,8 +12,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CopyFileEx. /// - [DllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - private static extern bool CopyFileExPrivate( + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + private static partial bool CopyFileExPrivate( string src, string dst, IntPtr progressRoutine, 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 5c4e754f86019..5954e242aea24 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs @@ -12,8 +12,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateDirectory. /// - [DllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - private static extern bool CreateDirectoryPrivate(string path, ref SECURITY_ATTRIBUTES lpSecurityAttributes); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + private static partial bool CreateDirectoryPrivate(string path, ref SECURITY_ATTRIBUTES lpSecurityAttributes); internal static bool CreateDirectory(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 ce5bfd9fd5321..67a1240a359e7 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs @@ -13,8 +13,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// - [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)] - private static extern unsafe SafeFileHandle CreateFilePrivate( + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + private static unsafe partial SafeFileHandle CreateFilePrivate( string lpFileName, int dwDesiredAccess, FileShare dwShareMode, 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 de8ec49722c54..fe47b09542184 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,8 +12,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// - [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)] - private static extern unsafe IntPtr CreateFilePrivate_IntPtr( + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + private static unsafe partial IntPtr CreateFilePrivate_IntPtr( string lpFileName, int dwDesiredAccess, FileShare dwShareMode, 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 112538259e925..decf6d7734483 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs @@ -12,8 +12,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use DeleteFile. /// - [DllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - private static extern bool DeleteFilePrivate(string path); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode)] + 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 66b39032eb90e..7910be508418c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs @@ -12,8 +12,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use DeleteVolumeMountPoint. /// - [DllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - internal static extern bool DeleteVolumeMountPointPrivate(string mountPoint); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial bool DeleteVolumeMountPointPrivate(string mountPoint); internal static bool DeleteVolumeMountPoint(string mountPoint) diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs index 9999d8b94186e..7c04238ea3111 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool FindClose(IntPtr hFindFile); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool FindClose(IntPtr hFindFile); } } 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 0df1c75cd4c65..04fa6b02c415c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs @@ -11,8 +11,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use GetFileAttributesEx. /// - [DllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] - private static extern bool GetFileAttributesExPrivate(string? name, GET_FILEEX_INFO_LEVELS fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + private static partial bool GetFileAttributesExPrivate(string? name, GET_FILEEX_INFO_LEVELS fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation); internal static bool GetFileAttributesEx(string? name, GET_FILEEX_INFO_LEVELS fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation) { diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs index 557c019e6a647..f084be9926b40 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern int GetLogicalDrives(); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial int GetLogicalDrives(); } } 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 48775f06c5a9d..67b8dee9144bd 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] - internal static extern unsafe bool GetVolumeInformation(string drive, char* volumeName, int volumeNameBufLen, int* volSerialNumber, int* maxFileNameLen, out int fileSystemFlags, char* fileSystemName, int fileSystemNameBufLen); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial bool GetVolumeInformation(string drive, char* volumeName, int volumeNameBufLen, int* volSerialNumber, int* maxFileNameLen, out int fileSystemFlags, char* fileSystemName, int fileSystemNameBufLen); internal const uint FILE_SUPPORTS_ENCRYPTION = 0x00020000; } 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 507d325517443..389e7b91de62b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs @@ -15,8 +15,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use MoveFile. /// - [DllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - private static extern bool MoveFileExPrivate(string src, string dst, uint flags); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + private static partial bool MoveFileExPrivate(string src, string dst, uint flags); /// /// Moves a file or directory, optionally overwriting existing destination file. NOTE: overwrite must be false for directories. 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 2d9d01ea06445..058894972e5b6 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs @@ -12,8 +12,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use RemoveDirectory. /// - [DllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - private static extern bool RemoveDirectoryPrivate(string path); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + 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 e3a6eb5c2d805..b29552d677edf 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - private static extern bool ReplaceFilePrivate( + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode)] + 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.SetFileAttributes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs index 33ecdabc76f1a..77a8bf70ae45c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs @@ -11,8 +11,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use SetFileAttributes. /// - [DllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - private static extern bool SetFileAttributesPrivate(string name, int attr); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode)] + private static partial bool SetFileAttributesPrivate(string name, int attr); internal static bool SetFileAttributes(string name, int attr) { diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs index 193fa9b988710..18b658039d5ea 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] - internal static extern unsafe bool SetFileInformationByHandle(SafeFileHandle hFile, int FileInformationClass, void* lpFileInformation, uint dwBufferSize); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + internal static unsafe partial bool SetFileInformationByHandle(SafeFileHandle hFile, int FileInformationClass, void* lpFileInformation, uint dwBufferSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs index ebf30875b1c6d..5a3acb3fcccc4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs @@ -7,9 +7,9 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] [SuppressGCTransition] - internal static extern bool SetThreadErrorMode(uint dwNewMode, out uint lpOldMode); + internal static partial bool SetThreadErrorMode(uint dwNewMode, out uint lpOldMode); internal const uint SEM_FAILCRITICALERRORS = 1; } 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 9ce82c7f4ad45..e075a79427e7a 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs @@ -17,11 +17,11 @@ 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 [DllImport(Libraries.NtDll, CharSet = CharSet.Unicode, ExactSpelling = true)] - private static extern unsafe uint NtCreateFile( - out IntPtr FileHandle, + private static unsafe extern uint NtCreateFile( + IntPtr* FileHandle, DesiredAccess DesiredAccess, - ref OBJECT_ATTRIBUTES ObjectAttributes, - out IO_STATUS_BLOCK IoStatusBlock, + OBJECT_ATTRIBUTES* ObjectAttributes, + IO_STATUS_BLOCK* IoStatusBlock, long* AllocationSize, FileAttributes FileAttributes, FileShare ShareAccess, @@ -59,11 +59,13 @@ internal static unsafe (uint status, IntPtr handle) CreateFile( rootDirectory, securityQualityOfService); + IntPtr handle; + IO_STATUS_BLOCK statusBlock; uint status = NtCreateFile( - out IntPtr handle, + &handle, desiredAccess, - ref attributes, - out IO_STATUS_BLOCK statusBlock, + &attributes, + &statusBlock, AllocationSize: preallocationSize, fileAttributes, shareAccess, 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 517fd4195f360..25d5f5f925bc4 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs @@ -11,12 +11,12 @@ 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 [DllImport(Libraries.NtDll, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern unsafe int NtQueryDirectoryFile( + public static unsafe extern int NtQueryDirectoryFile( IntPtr FileHandle, IntPtr Event, IntPtr ApcRoutine, IntPtr ApcContext, - out IO_STATUS_BLOCK IoStatusBlock, + IO_STATUS_BLOCK* IoStatusBlock, IntPtr FileInformation, uint Length, FILE_INFORMATION_CLASS FileInformationClass, diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs index 04f8282736a44..090e4cd2b89cb 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs @@ -175,7 +175,12 @@ private unsafe void FindNextEntry() private unsafe void FindNextEntry(byte* entryBufferPtr, int bufferLength) { - int result = Interop.Sys.ReadDirR(_directoryHandle, entryBufferPtr, bufferLength, out _entry); + int result; + fixed (Interop.Sys.DirectoryEntry* e = &_entry) + { + result = Interop.Sys.ReadDirR(_directoryHandle, entryBufferPtr, bufferLength, e); + } + switch (result) { case -1: diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Win32.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Win32.cs index 22e990194f5d8..3b90d71120eda 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Win32.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Win32.cs @@ -20,12 +20,13 @@ private unsafe bool GetData() { Debug.Assert(_directoryHandle != (IntPtr)(-1) && _directoryHandle != IntPtr.Zero && !_lastEntryFound); + Interop.NtDll.IO_STATUS_BLOCK statusBlock; int status = Interop.NtDll.NtQueryDirectoryFile( FileHandle: _directoryHandle, Event: IntPtr.Zero, ApcRoutine: IntPtr.Zero, ApcContext: IntPtr.Zero, - IoStatusBlock: out Interop.NtDll.IO_STATUS_BLOCK statusBlock, + IoStatusBlock: &statusBlock, FileInformation: _buffer, Length: (uint)_bufferLength, FileInformationClass: Interop.NtDll.FILE_INFORMATION_CLASS.FileFullDirectoryInformation, diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs index c67b3a261e0eb..a61b9e7cc7adf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs @@ -498,7 +498,7 @@ private static unsafe void EnumerateFilesRecursively(string path, Predicate Date: Mon, 7 Jun 2021 16:44:39 -0700 Subject: [PATCH 099/161] Use GeneratedDllImport in System.Net.Security (#53839) --- .../Interop.Ssl.cs | 84 +++--- ...terop.NetSecurityNative.IsNtlmInstalled.cs | 2 +- .../Interop.NetSecurityNative.cs | 74 ++--- .../Interop.Ssl.cs | 109 ++++--- .../Interop.SslCtx.cs | 12 +- .../Interop.SslCtxOptions.cs | 28 +- .../Interop.CertEnumCertificatesInStore.cs | 9 +- .../Windows/Crypt32/Interop.certificates.cs | 16 +- .../Crypt32/Interop.certificates_types.cs | 2 +- .../Interop/Windows/SspiCli/Interop.SSPI.cs | 285 +++++++++--------- .../Win32/SafeHandles/GssSafeHandles.cs | 35 ++- .../Common/tests/Common.Tests.csproj | 1 + .../System/Net/Capability.Security.Unix.cs | 2 +- .../System.IO.FileSystem.Watcher.Tests.csproj | 2 + .../Net/Http/WinHttpCertificateHelper.cs | 2 +- .../Unit/System.Net.Mail.Unit.Tests.csproj | 1 + .../System.Net.Primitives.Pal.Tests.csproj | 5 +- .../Net/CertificateValidationPal.Windows.cs | 2 +- 18 files changed, 345 insertions(+), 326 deletions(-) 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 26bf0a3fd111e..5b3b9d6d7cdc8 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 @@ -57,97 +57,97 @@ internal enum PAL_TlsIo Renegotiate, } - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslCreateContext")] - internal static extern System.Net.SafeSslHandle SslCreateContext(int isServer); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslCreateContext")] + internal static partial System.Net.SafeSslHandle SslCreateContext(int isServer); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslSetMinProtocolVersion( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslSetMinProtocolVersion( SafeSslHandle sslHandle, SslProtocols minProtocolId); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslSetMaxProtocolVersion( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslSetMaxProtocolVersion( SafeSslHandle sslHandle, SslProtocols maxProtocolId); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslCopyCertChain( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslCopyCertChain( SafeSslHandle sslHandle, out SafeX509ChainHandle pTrustOut, out int pOSStatus); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslCopyCADistinguishedNames( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslCopyCADistinguishedNames( SafeSslHandle sslHandle, out SafeCFArrayHandle pArrayOut, out int pOSStatus); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslSetBreakOnServerAuth( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslSetBreakOnServerAuth( SafeSslHandle sslHandle, int setBreak, out int pOSStatus); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslSetBreakOnClientAuth( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslSetBreakOnClientAuth( SafeSslHandle sslHandle, int setBreak, out int pOSStatus); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslSetCertificate( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslSetCertificate( SafeSslHandle sslHandle, SafeCreateHandle cfCertRefs); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslSetTargetName( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, CharSet = CharSet.Ansi)] + private static partial int AppleCryptoNative_SslSetTargetName( SafeSslHandle sslHandle, string targetName, int cbTargetName, out int osStatus); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SSLSetALPNProtocols")] - internal static extern int SSLSetALPNProtocols(SafeSslHandle ctx, SafeCreateHandle cfProtocolsRefs, out int osStatus); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SSLSetALPNProtocols")] + internal static partial int SSLSetALPNProtocols(SafeSslHandle ctx, SafeCreateHandle cfProtocolsRefs, out int osStatus); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetAlpnSelected")] - internal static extern int SslGetAlpnSelected(SafeSslHandle ssl, out SafeCFDataHandle protocol); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetAlpnSelected")] + internal static partial int SslGetAlpnSelected(SafeSslHandle ssl, out SafeCFDataHandle protocol); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslHandshake")] - internal static extern PAL_TlsHandshakeState SslHandshake(SafeSslHandle sslHandle); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslHandshake")] + internal static partial PAL_TlsHandshakeState SslHandshake(SafeSslHandle sslHandle); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslSetAcceptClientCert(SafeSslHandle sslHandle); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslSetAcceptClientCert(SafeSslHandle sslHandle); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetIoCallbacks")] - internal static extern int SslSetIoCallbacks( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetIoCallbacks")] + internal static partial int SslSetIoCallbacks( SafeSslHandle sslHandle, SSLReadFunc readCallback, SSLWriteFunc writeCallback); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslWrite")] - internal static extern unsafe PAL_TlsIo SslWrite(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslWrite")] + internal static unsafe partial PAL_TlsIo SslWrite(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslRead")] - internal static extern unsafe PAL_TlsIo SslRead(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslRead")] + internal static unsafe partial PAL_TlsIo SslRead(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten); - [DllImport(Interop.Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SslIsHostnameMatch( + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SslIsHostnameMatch( SafeSslHandle handle, SafeCreateHandle cfHostname, SafeCFDateHandle cfValidTime, out int pOSStatus); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslShutdown")] - internal static extern int SslShutdown(SafeSslHandle sslHandle); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslShutdown")] + internal static partial int SslShutdown(SafeSslHandle sslHandle); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetCipherSuite")] - internal static extern int SslGetCipherSuite(SafeSslHandle sslHandle, out TlsCipherSuite cipherSuite); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetCipherSuite")] + internal static partial int SslGetCipherSuite(SafeSslHandle sslHandle, out TlsCipherSuite cipherSuite); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetProtocolVersion")] - internal static extern int SslGetProtocolVersion(SafeSslHandle sslHandle, out SslProtocols protocol); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetProtocolVersion")] + internal static partial int SslGetProtocolVersion(SafeSslHandle sslHandle, out SslProtocols protocol); - [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetEnabledCipherSuites")] - internal static extern unsafe int SslSetEnabledCipherSuites(SafeSslHandle sslHandle, uint* cipherSuites, int numCipherSuites); + [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetEnabledCipherSuites")] + internal static unsafe partial int SslSetEnabledCipherSuites(SafeSslHandle sslHandle, uint* cipherSuites, int numCipherSuites); internal static void SslSetAcceptClientCert(SafeSslHandle sslHandle) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs index 79edbf6adad46..09e0b6bb75b46 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class NetSecurityNative { [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_IsNtlmInstalled")] - internal static extern bool IsNtlmInstalled(); + internal static extern int IsNtlmInstalled(); } } 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 083b6ce18b77d..fc950025174c0 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 @@ -16,50 +16,50 @@ internal static extern void ReleaseGssBuffer( IntPtr bufferPtr, ulong length); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DisplayMinorStatus")] - internal static extern Status DisplayMinorStatus( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DisplayMinorStatus")] + internal static partial Status DisplayMinorStatus( out Status minorStatus, Status statusValue, ref GssBuffer buffer); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DisplayMajorStatus")] - internal static extern Status DisplayMajorStatus( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DisplayMajorStatus")] + internal static partial Status DisplayMajorStatus( out Status minorStatus, Status statusValue, ref GssBuffer buffer); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ImportUserName")] - internal static extern Status ImportUserName( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ImportUserName")] + internal static partial Status ImportUserName( out Status minorStatus, - string inputName, + [MarshalAs(UnmanagedType.LPUTF8Str)] string inputName, int inputNameByteCount, out SafeGssNameHandle outputName); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ImportPrincipalName")] - internal static extern Status ImportPrincipalName( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ImportPrincipalName")] + internal static partial Status ImportPrincipalName( out Status minorStatus, - string inputName, + [MarshalAs(UnmanagedType.LPUTF8Str)] string inputName, int inputNameByteCount, out SafeGssNameHandle outputName); [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseName")] - internal static extern Status ReleaseName( - out Status minorStatus, - ref IntPtr inputName); + internal static unsafe extern Status ReleaseName( + Status* minorStatus, + IntPtr* inputName); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_AcquireAcceptorCred")] - internal static extern Status AcquireAcceptorCred( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_AcquireAcceptorCred")] + internal static partial Status AcquireAcceptorCred( out Status minorStatus, out SafeGssCredHandle outputCredHandle); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitiateCredSpNego")] - internal static extern Status InitiateCredSpNego( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitiateCredSpNego")] + internal static partial Status InitiateCredSpNego( out Status minorStatus, SafeGssNameHandle desiredName, out SafeGssCredHandle outputCredHandle); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitiateCredWithPassword")] - internal static extern Status InitiateCredWithPassword( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitiateCredWithPassword", CharSet = CharSet.Ansi)] + internal static partial Status InitiateCredWithPassword( out Status minorStatus, bool isNtlm, SafeGssNameHandle desiredName, @@ -68,12 +68,12 @@ internal static extern Status InitiateCredWithPassword( out SafeGssCredHandle outputCredHandle); [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseCred")] - internal static extern Status ReleaseCred( - out Status minorStatus, - ref IntPtr credHandle); + internal static unsafe extern Status ReleaseCred( + Status* minorStatus, + IntPtr* credHandle); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitSecContext")] - internal static extern Status InitSecContext( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitSecContext")] + internal static partial Status InitSecContext( out Status minorStatus, SafeGssCredHandle initiatorCredHandle, ref SafeGssContextHandle contextHandle, @@ -86,8 +86,8 @@ internal static extern Status InitSecContext( out uint retFlags, out bool isNtlmUsed); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitSecContextEx")] - internal static extern Status InitSecContext( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitSecContextEx")] + internal static partial Status InitSecContext( out Status minorStatus, SafeGssCredHandle initiatorCredHandle, ref SafeGssContextHandle contextHandle, @@ -102,8 +102,8 @@ internal static extern Status InitSecContext( out uint retFlags, out bool isNtlmUsed); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_AcceptSecContext")] - internal static extern Status AcceptSecContext( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_AcceptSecContext")] + internal static partial Status AcceptSecContext( out Status minorStatus, SafeGssCredHandle acceptorCredHandle, ref SafeGssContextHandle acceptContextHandle, @@ -114,18 +114,18 @@ internal static extern Status AcceptSecContext( out bool isNtlmUsed); [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DeleteSecContext")] - internal static extern Status DeleteSecContext( - out Status minorStatus, - ref IntPtr contextHandle); + internal static unsafe extern Status DeleteSecContext( + Status* minorStatus, + IntPtr* contextHandle); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_GetUser")] - internal static extern Status GetUser( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_GetUser")] + internal static partial Status GetUser( out Status minorStatus, SafeGssContextHandle? acceptContextHandle, ref GssBuffer token); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_Wrap")] - private static extern unsafe Status Wrap( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_Wrap")] + private static unsafe partial Status Wrap( out Status minorStatus, SafeGssContextHandle? contextHandle, bool isEncrypt, @@ -133,8 +133,8 @@ private static extern unsafe Status Wrap( int count, ref GssBuffer outBuffer); - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_Unwrap")] - private static extern Status Unwrap( + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_Unwrap")] + private static partial Status Unwrap( out Status minorStatus, SafeGssContextHandle? contextHandle, byte[] inputBytes, 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 057e4dc8279a4..8ce0c8e735275 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 @@ -23,36 +23,36 @@ internal static partial class Ssl [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslV2_3Method")] internal static extern IntPtr SslV2_3Method(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCreate")] - internal static extern SafeSslHandle SslCreate(SafeSslContextHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCreate")] + internal static partial SafeSslHandle SslCreate(SafeSslContextHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetError")] - internal static extern SslErrorCode SslGetError(SafeSslHandle ssl, int ret); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetError")] + internal static partial SslErrorCode SslGetError(SafeSslHandle ssl, int ret); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetError")] internal static extern SslErrorCode SslGetError(IntPtr ssl, int ret); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetQuietShutdown")] - internal static extern void SslSetQuietShutdown(SafeSslHandle ssl, int mode); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetQuietShutdown")] + internal static partial void SslSetQuietShutdown(SafeSslHandle ssl, int mode); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslDestroy")] internal static extern void SslDestroy(IntPtr ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetConnectState")] - internal static extern void SslSetConnectState(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetConnectState")] + internal static partial void SslSetConnectState(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetAcceptState")] - internal static extern void SslSetAcceptState(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetAcceptState")] + internal static partial void SslSetAcceptState(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetVersion")] - internal static extern IntPtr SslGetVersion(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetVersion")] + internal static partial IntPtr SslGetVersion(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetTlsExtHostName")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetTlsExtHostName", CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SslSetTlsExtHostName(SafeSslHandle ssl, string host); + internal static partial bool SslSetTlsExtHostName(SafeSslHandle ssl, string host); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGet0AlpnSelected")] - internal static extern void SslGetAlpnSelected(SafeSslHandle ssl, out IntPtr protocol, out int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGet0AlpnSelected")] + internal static partial void SslGetAlpnSelected(SafeSslHandle ssl, out IntPtr protocol, out int len); internal static byte[]? SslGetAlpnSelected(SafeSslHandle ssl) { @@ -68,67 +68,67 @@ internal static partial class Ssl return result; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslWrite", SetLastError = true)] - internal static extern int SslWrite(SafeSslHandle ssl, ref byte buf, int num); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslWrite", SetLastError = true)] + internal static partial int SslWrite(SafeSslHandle ssl, ref byte buf, int num); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslRead", SetLastError = true)] - internal static extern unsafe int SslRead(SafeSslHandle ssl, byte* buf, int num); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslRead", SetLastError = true)] + internal static unsafe partial int SslRead(SafeSslHandle ssl, byte* buf, int num); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_IsSslRenegotiatePending")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_IsSslRenegotiatePending")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool IsSslRenegotiatePending(SafeSslHandle ssl); + internal static partial bool IsSslRenegotiatePending(SafeSslHandle ssl); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslShutdown")] internal static extern int SslShutdown(IntPtr ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslShutdown")] - internal static extern int SslShutdown(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslShutdown")] + internal static partial int SslShutdown(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetBio")] - internal static extern void SslSetBio(SafeSslHandle ssl, SafeBioHandle rbio, SafeBioHandle wbio); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetBio")] + internal static partial void SslSetBio(SafeSslHandle ssl, SafeBioHandle rbio, SafeBioHandle wbio); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslDoHandshake", SetLastError = true)] - internal static extern int SslDoHandshake(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslDoHandshake", SetLastError = true)] + internal static partial int SslDoHandshake(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_IsSslStateOK")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_IsSslStateOK")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool IsSslStateOK(SafeSslHandle ssl); + internal static partial bool IsSslStateOK(SafeSslHandle ssl); // NOTE: this is just an (unsafe) overload to the BioWrite method from Interop.Bio.cs. - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] - internal static extern unsafe int BioWrite(SafeBioHandle b, byte* data, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] + internal static unsafe partial int BioWrite(SafeBioHandle b, byte* data, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] - internal static extern int BioWrite(SafeBioHandle b, ref byte data, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")] + internal static partial int BioWrite(SafeBioHandle b, ref byte data, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertificate")] - internal static extern SafeX509Handle SslGetPeerCertificate(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertificate")] + internal static partial SafeX509Handle SslGetPeerCertificate(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertChain")] - internal static extern SafeSharedX509StackHandle SslGetPeerCertChain(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertChain")] + internal static partial SafeSharedX509StackHandle SslGetPeerCertChain(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerFinished")] - internal static extern int SslGetPeerFinished(SafeSslHandle ssl, IntPtr buf, int count); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerFinished")] + internal static partial int SslGetPeerFinished(SafeSslHandle ssl, IntPtr buf, int count); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetFinished")] - internal static extern int SslGetFinished(SafeSslHandle ssl, IntPtr buf, int count); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetFinished")] + internal static partial int SslGetFinished(SafeSslHandle ssl, IntPtr buf, int count); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSessionReused")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSessionReused")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SslSessionReused(SafeSslHandle ssl); + internal static partial bool SslSessionReused(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslAddExtraChainCert")] - internal static extern bool SslAddExtraChainCert(SafeSslHandle ssl, SafeX509Handle x509); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslAddExtraChainCert")] + internal static partial bool SslAddExtraChainCert(SafeSslHandle ssl, SafeX509Handle x509); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetClientCAList")] - private static extern SafeSharedX509NameStackHandle SslGetClientCAList_private(SafeSslHandle ssl); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetClientCAList")] + private static partial SafeSharedX509NameStackHandle SslGetClientCAList_private(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetCurrentCipherId")] + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetCurrentCipherId")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SslGetCurrentCipherId(SafeSslHandle ssl, out int cipherId); + internal static partial bool SslGetCurrentCipherId(SafeSslHandle ssl, out int cipherId); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOpenSslCipherSuiteName")] - private static extern IntPtr GetOpenSslCipherSuiteName(SafeSslHandle ssl, int cipherSuite, out int isTls12OrLower); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOpenSslCipherSuiteName")] + private static partial IntPtr GetOpenSslCipherSuiteName(SafeSslHandle ssl, int cipherSuite, out int isTls12OrLower); internal static string? GetOpenSslCipherSuiteName(SafeSslHandle ssl, TlsCipherSuite cipherSuite, out bool isTls12OrLower) { @@ -138,9 +138,8 @@ internal static partial class Ssl } [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Tls13Supported")] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool Tls13SupportedImpl(); - internal static readonly bool Tls13Supported = Tls13SupportedImpl(); + private static extern int Tls13SupportedImpl(); + internal static readonly bool Tls13Supported = Tls13SupportedImpl() != 0; internal static SafeSharedX509NameStackHandle SslGetClientCAList(SafeSslHandle ssl) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs index d39b6595d39b1..217f41952da99 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs @@ -12,17 +12,17 @@ internal static partial class Interop { internal static partial class Ssl { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxCreate")] - internal static extern SafeSslContextHandle SslCtxCreate(IntPtr method); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxCreate")] + internal static partial SafeSslContextHandle SslCtxCreate(IntPtr method); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxDestroy")] internal static extern void SslCtxDestroy(IntPtr ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnProtos")] - internal static extern int SslCtxSetAlpnProtos(SafeSslContextHandle ctx, IntPtr protos, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnProtos")] + internal static partial int SslCtxSetAlpnProtos(SafeSslContextHandle ctx, IntPtr protos, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnSelectCb")] - internal static extern unsafe void SslCtxSetAlpnSelectCb(SafeSslContextHandle ctx, delegate* unmanaged callback, IntPtr arg); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnSelectCb")] + internal static unsafe partial void SslCtxSetAlpnSelectCb(SafeSslContextHandle ctx, delegate* unmanaged callback, IntPtr arg); internal static unsafe int SslCtxSetAlpnProtos(SafeSslContextHandle ctx, List protocols) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs index 978f846939c2f..66b776b9a24cf 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs @@ -11,25 +11,25 @@ internal static partial class Interop { internal static partial class Ssl { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUseCertificate")] - internal static extern int SslCtxUseCertificate(SafeSslContextHandle ctx, SafeX509Handle certPtr); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUseCertificate")] + internal static partial int SslCtxUseCertificate(SafeSslContextHandle ctx, SafeX509Handle certPtr); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUsePrivateKey")] - internal static extern int SslCtxUsePrivateKey(SafeSslContextHandle ctx, SafeEvpPKeyHandle keyPtr); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUsePrivateKey")] + internal static partial int SslCtxUsePrivateKey(SafeSslContextHandle ctx, SafeEvpPKeyHandle keyPtr); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxCheckPrivateKey")] - internal static extern int SslCtxCheckPrivateKey(SafeSslContextHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxCheckPrivateKey")] + internal static partial int SslCtxCheckPrivateKey(SafeSslContextHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetQuietShutdown")] - internal static extern void SslCtxSetQuietShutdown(SafeSslContextHandle ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetQuietShutdown")] + internal static partial void SslCtxSetQuietShutdown(SafeSslContextHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetVerify")] - internal static extern unsafe void SslCtxSetVerify(SafeSslContextHandle ctx, delegate* unmanaged callback); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetVerify")] + internal static unsafe partial void SslCtxSetVerify(SafeSslContextHandle ctx, delegate* unmanaged callback); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetCiphers")] - internal static extern unsafe bool SetCiphers(SafeSslContextHandle ctx, byte* cipherList, byte* cipherSuites); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetCiphers")] + internal static unsafe partial bool SetCiphers(SafeSslContextHandle ctx, byte* cipherList, byte* cipherSuites); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetEncryptionPolicy")] - internal static extern bool SetEncryptionPolicy(SafeSslContextHandle ctx, EncryptionPolicy policy); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetEncryptionPolicy")] + internal static partial bool SetEncryptionPolicy(SafeSslContextHandle ctx, EncryptionPolicy policy); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertEnumCertificatesInStore.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertEnumCertificatesInStore.cs index b6d12f6ca92ac..50cb6c5997be0 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertEnumCertificatesInStore.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertEnumCertificatesInStore.cs @@ -8,7 +8,14 @@ internal static partial class Interop { internal static partial class Crypt32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + public static unsafe partial CERT_CONTEXT* CertEnumCertificatesInStore( +#else [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe CERT_CONTEXT* CertEnumCertificatesInStore(IntPtr hCertStore, CERT_CONTEXT* pPrevCertContext); + public static unsafe extern CERT_CONTEXT* CertEnumCertificatesInStore( +#endif + IntPtr hCertStore, + CERT_CONTEXT* pPrevCertContext); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates.cs index c177c76cfb2bb..e61361bfa8ae7 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates.cs @@ -10,16 +10,28 @@ internal static partial class Interop { internal static partial class Crypt32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool CertFreeCertificateContext(IntPtr pCertContext); +#else [DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CertFreeCertificateContext(IntPtr pCertContext); +#endif +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool CertVerifyCertificateChainPolicy( +#else [DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CertVerifyCertificateChainPolicy( +#endif IntPtr pszPolicyOID, SafeX509ChainHandle pChainContext, - [In] ref CERT_CHAIN_POLICY_PARA pPolicyPara, - [In, Out] ref CERT_CHAIN_POLICY_STATUS pPolicyStatus); + ref CERT_CHAIN_POLICY_PARA pPolicyPara, + ref CERT_CHAIN_POLICY_STATUS pPolicyStatus); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates_types.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates_types.cs index 2fa029d9d8f30..d51195c5b613d 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates_types.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.certificates_types.cs @@ -92,7 +92,7 @@ internal unsafe struct SSL_EXTRA_CERT_CHAIN_POLICY_PARA internal uint cbSize; internal uint dwAuthType; internal uint fdwChecks; - internal char* pwszServerName; + internal ushort* pwszServerName; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 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 b675f7f022473..c296f31197626 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs @@ -315,162 +315,149 @@ public SecBufferDesc(int count) } } - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern int EncryptMessage( - ref CredHandle contextHandle, - [In] uint qualityOfProtection, - [In, Out] ref SecBufferDesc inputOutput, - [In] uint sequenceNumber - ); + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static partial int EncryptMessage( + ref CredHandle contextHandle, + uint qualityOfProtection, + ref SecBufferDesc inputOutput, + uint sequenceNumber); - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern unsafe int DecryptMessage( - [In] ref CredHandle contextHandle, - [In, Out] ref SecBufferDesc inputOutput, - [In] uint sequenceNumber, - uint* qualityOfProtection - ); + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial int DecryptMessage( + ref CredHandle contextHandle, + ref SecBufferDesc inputOutput, + uint sequenceNumber, + uint* qualityOfProtection); [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] internal static extern int QuerySecurityContextToken( ref CredHandle phContext, - [Out] out SecurityContextTokenHandle handle); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern int FreeContextBuffer( - [In] IntPtr contextBuffer); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern int FreeCredentialsHandle( - ref CredHandle handlePtr - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern int DeleteSecurityContext( - ref CredHandle handlePtr - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern unsafe int AcceptSecurityContext( - ref CredHandle credentialHandle, - [In] void* inContextPtr, - [In] SecBufferDesc* inputBuffer, - [In] ContextFlags inFlags, - [In] Endianness endianness, - ref CredHandle outContextPtr, - [In, Out] ref SecBufferDesc outputBuffer, - [In, Out] ref ContextFlags attributes, - out long timeStamp - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern unsafe int QueryContextAttributesW( + out SecurityContextTokenHandle handle); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static partial int FreeContextBuffer( + IntPtr contextBuffer); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static partial int FreeCredentialsHandle( + ref CredHandle handlePtr); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static partial int DeleteSecurityContext( + ref CredHandle handlePtr); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial int AcceptSecurityContext( + ref CredHandle credentialHandle, + void* inContextPtr, + SecBufferDesc* inputBuffer, + ContextFlags inFlags, + Endianness endianness, + ref CredHandle outContextPtr, + ref SecBufferDesc outputBuffer, + ref ContextFlags attributes, + out long timeStamp); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial int QueryContextAttributesW( ref CredHandle contextHandle, - [In] ContextAttribute attribute, - [In] void* buffer); + ContextAttribute attribute, + void* buffer); - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern int SetContextAttributesW( + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static partial int SetContextAttributesW( ref CredHandle contextHandle, - [In] ContextAttribute attribute, - [In] byte[] buffer, - [In] int bufferSize); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern int EnumerateSecurityPackagesW( - [Out] out int pkgnum, - [Out] out SafeFreeContextBuffer_SECURITY handle); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe int AcquireCredentialsHandleW( - [In] string? principal, - [In] string moduleName, - [In] int usage, - [In] void* logonID, - [In] IntPtr zero, - [In] void* keyCallback, - [In] void* keyArgument, - ref CredHandle handlePtr, - [Out] out long timeStamp - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe int AcquireCredentialsHandleW( - [In] string? principal, - [In] string moduleName, - [In] int usage, - [In] void* logonID, - [In] SafeSspiAuthDataHandle authdata, - [In] void* keyCallback, - [In] void* keyArgument, - ref CredHandle handlePtr, - [Out] out long timeStamp - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe int AcquireCredentialsHandleW( - [In] string? principal, - [In] string moduleName, - [In] int usage, - [In] void* logonID, - [In] SCHANNEL_CRED* authData, - [In] void* keyCallback, - [In] void* keyArgument, - ref CredHandle handlePtr, - [Out] out long timeStamp - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe int AcquireCredentialsHandleW( - [In] string? principal, - [In] string moduleName, - [In] int usage, - [In] void* logonID, - [In] SCH_CREDENTIALS* authData, - [In] void* keyCallback, - [In] void* keyArgument, - ref CredHandle handlePtr, - [Out] out long timeStamp - ); - - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern unsafe int InitializeSecurityContextW( - ref CredHandle credentialHandle, - [In] void* inContextPtr, - [In] byte* targetName, - [In] ContextFlags inFlags, - [In] int reservedI, - [In] Endianness endianness, - [In] SecBufferDesc* inputBuffer, - [In] int reservedII, - ref CredHandle outContextPtr, - [In, Out] ref SecBufferDesc outputBuffer, - [In, Out] ref ContextFlags attributes, - out long timeStamp - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern unsafe int CompleteAuthToken( - [In] void* inContextPtr, - [In, Out] ref SecBufferDesc inputBuffers - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern unsafe int ApplyControlToken( - [In] void* inContextPtr, - [In, Out] ref SecBufferDesc inputBuffers - ); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] - internal static extern SECURITY_STATUS SspiFreeAuthIdentity( - [In] IntPtr authData); - - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern SECURITY_STATUS SspiEncodeStringsAsAuthIdentity( - [In] string userName, - [In] string domainName, - [In] string password, - [Out] out SafeSspiAuthDataHandle authData); + ContextAttribute attribute, + byte[] buffer, + int bufferSize); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static partial int EnumerateSecurityPackagesW( + out int pkgnum, + out SafeFreeContextBuffer_SECURITY handle); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial int AcquireCredentialsHandleW( + string? principal, + string moduleName, + int usage, + void* logonID, + IntPtr zero, + void* keyCallback, + void* keyArgument, + ref CredHandle handlePtr, + out long timeStamp); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial int AcquireCredentialsHandleW( + string? principal, + string moduleName, + int usage, + void* logonID, + SafeSspiAuthDataHandle authdata, + void* keyCallback, + void* keyArgument, + ref CredHandle handlePtr, + out long timeStamp); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial int AcquireCredentialsHandleW( + string? principal, + string moduleName, + int usage, + void* logonID, + SCHANNEL_CRED* authData, + void* keyCallback, + void* keyArgument, + ref CredHandle handlePtr, + out long timeStamp); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial int AcquireCredentialsHandleW( + string? principal, + string moduleName, + int usage, + void* logonID, + SCH_CREDENTIALS* authData, + void* keyCallback, + void* keyArgument, + ref CredHandle handlePtr, + out long timeStamp); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial int InitializeSecurityContextW( + ref CredHandle credentialHandle, + void* inContextPtr, + byte* targetName, + ContextFlags inFlags, + int reservedI, + Endianness endianness, + SecBufferDesc* inputBuffer, + int reservedII, + ref CredHandle outContextPtr, + ref SecBufferDesc outputBuffer, + ref ContextFlags attributes, + out long timeStamp); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial int CompleteAuthToken( + void* inContextPtr, + ref SecBufferDesc inputBuffers); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial int ApplyControlToken( + void* inContextPtr, + ref SecBufferDesc inputBuffers); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, SetLastError = true)] + internal static partial SECURITY_STATUS SspiFreeAuthIdentity( + IntPtr authData); + + [GeneratedDllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SECURITY_STATUS SspiEncodeStringsAsAuthIdentity( + string userName, + string domainName, + string password, + out SafeSspiAuthDataHandle authData); } } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs index e99fbed3c332c..99b8629bb9b88 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs @@ -52,12 +52,15 @@ public override bool IsInvalid get { return handle == IntPtr.Zero; } } - protected override bool ReleaseHandle() + protected override unsafe bool ReleaseHandle() { Interop.NetSecurityNative.Status minorStatus; - Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseName(out minorStatus, ref handle); - SetHandle(IntPtr.Zero); - return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE; + fixed (IntPtr* handleRef = &handle) + { + Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseName(&minorStatus, handleRef); + SetHandle(IntPtr.Zero); + return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE; + } } public SafeGssNameHandle() @@ -141,17 +144,20 @@ public override bool IsInvalid get { return handle == IntPtr.Zero; } } - protected override bool ReleaseHandle() + protected override unsafe bool ReleaseHandle() { Interop.NetSecurityNative.Status minorStatus; - Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseCred(out minorStatus, ref handle); - SetHandle(IntPtr.Zero); - return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE; + fixed (IntPtr* handlePtr = &handle) + { + Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseCred(&minorStatus, handlePtr); + SetHandle(IntPtr.Zero); + return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE; + } } private static bool InitIsNtlmInstalled() { - return Interop.NetSecurityNative.IsNtlmInstalled(); + return Interop.NetSecurityNative.IsNtlmInstalled() != 0; } } @@ -167,12 +173,15 @@ public override bool IsInvalid get { return handle == IntPtr.Zero; } } - protected override bool ReleaseHandle() + protected override unsafe bool ReleaseHandle() { Interop.NetSecurityNative.Status minorStatus; - Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.DeleteSecContext(out minorStatus, ref handle); - SetHandle(IntPtr.Zero); - return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE; + fixed (IntPtr* handlePtr = &handle) + { + Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.DeleteSecContext(&minorStatus, handlePtr); + SetHandle(IntPtr.Zero); + return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE; + } } } } diff --git a/src/libraries/Common/tests/Common.Tests.csproj b/src/libraries/Common/tests/Common.Tests.csproj index ba76497cfc556..4097a3c79efd7 100644 --- a/src/libraries/Common/tests/Common.Tests.csproj +++ b/src/libraries/Common/tests/Common.Tests.csproj @@ -4,6 +4,7 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX annotations + true + true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-FreeBSD true + true diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpCertificateHelper.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpCertificateHelper.cs index da4baadb35903..74ff18a42daf6 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpCertificateHelper.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpCertificateHelper.cs @@ -64,7 +64,7 @@ public static void BuildChain( fixed (char* namePtr = hostName) { - eppStruct.pwszServerName = namePtr; + eppStruct.pwszServerName = (ushort*)namePtr; // The native field is WCHAR*, so we can just cast to ushort in this case cppStruct.dwFlags = Interop.Crypt32.CertChainPolicyIgnoreFlags.CERT_CHAIN_POLICY_IGNORE_ALL & ~Interop.Crypt32.CertChainPolicyIgnoreFlags.CERT_CHAIN_POLICY_IGNORE_INVALID_NAME_FLAG; diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index d63a2501e8a46..9a01f192010c8 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -4,6 +4,7 @@ ../../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser annotations + true diff --git a/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj b/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj index 4652679d91bf6..fc4e4d4e55f4e 100644 --- a/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj +++ b/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj @@ -3,9 +3,10 @@ true ../../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser + true - $(DefineConstants);SYSTEM_NET_PRIMITIVES_DLL @@ -118,4 +119,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs b/src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs index ca9494b3b023b..8c50b124dd491 100644 --- a/src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs +++ b/src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs @@ -54,7 +54,7 @@ internal static SslPolicyErrors VerifyCertificateProperties( fixed (char* namePtr = hostName) { - eppStruct.pwszServerName = namePtr; + eppStruct.pwszServerName = (ushort*)namePtr; // The native field is WCHAR*, so we can just cast to ushort in this case cppStruct.dwFlags |= (Interop.Crypt32.CertChainPolicyIgnoreFlags.CERT_CHAIN_POLICY_IGNORE_ALL & ~Interop.Crypt32.CertChainPolicyIgnoreFlags.CERT_CHAIN_POLICY_IGNORE_INVALID_NAME_FLAG); From 95552f4b62373528b5bba7c8821990db76beddea Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 7 Jun 2021 18:30:50 -0700 Subject: [PATCH 100/161] Comment in source that source file is auto-generated. (dotnet/runtimelab#1209) * Comment in source that source file is auto-generated. Co-authored-by: Sam Harwell Commit migrated from https://github.com/dotnet/runtimelab/commit/fd4042ce8f0f90d82e34f70cec03056db14717cb --- .../gen/DllImportGenerator/DllImportGenerator.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index de2038f7a0979..cf3013a22daa2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -53,7 +53,12 @@ public void Execute(GeneratorExecutionContext context) } var env = new StubEnvironment(context.Compilation, isSupported, targetFrameworkVersion, context.AnalyzerConfigOptions.GlobalOptions); + var generatedDllImports = new StringBuilder(); + + // Mark in source that the file is auto-generated. + generatedDllImports.AppendLine("// "); + foreach (SyntaxReference synRef in synRec.Methods) { var methodSyntax = (MethodDeclarationSyntax)synRef.GetSyntax(context.CancellationToken); From f85171f11a1e070da9454dfd041ecda0dc460f99 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 7 Jun 2021 19:13:20 -0700 Subject: [PATCH 101/161] Use GeneratedDllImport in System.IO.FileSystem.AccessControl (#53845) --- .../Windows/Kernel32/Interop.CreateDirectory.cs | 9 ++++++++- .../Interop/Windows/Kernel32/Interop.CreateFile.cs | 5 +++++ .../src/Interop/Windows/Kernel32/Interop.FindClose.cs | 5 +++++ .../Windows/Kernel32/Interop.GetFileAttributesEx.cs | 10 +++++++++- .../Windows/Kernel32/Interop.GetFullPathNameW.cs | 11 ++++++++++- .../Windows/Kernel32/Interop.GetLongPathNameW.cs | 10 +++++++++- .../Windows/Kernel32/Interop.SetThreadErrorMode.cs | 11 +++++++++-- 7 files changed, 55 insertions(+), 6 deletions(-) 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 5954e242aea24..e642ed22fff60 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs @@ -12,8 +12,15 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateDirectory. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] - private static partial bool CreateDirectoryPrivate(string path, ref SECURITY_ATTRIBUTES lpSecurityAttributes); + private static partial bool CreateDirectoryPrivate( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool CreateDirectoryPrivate( +#endif + string path, + ref SECURITY_ATTRIBUTES lpSecurityAttributes); internal static bool CreateDirectory(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 67a1240a359e7..0702187ea4f92 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs @@ -13,8 +13,13 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] private static unsafe partial SafeFileHandle CreateFilePrivate( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + private static unsafe extern SafeFileHandle CreateFilePrivate( +#endif string lpFileName, int dwDesiredAccess, FileShare dwShareMode, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs index 7c04238ea3111..c32ccf24f480b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindClose.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] internal static partial bool FindClose(IntPtr hFindFile); +#else + [DllImport(Libraries.Kernel32, SetLastError = true)] + internal static extern bool FindClose(IntPtr hFindFile); +#endif } } 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 04fa6b02c415c..d7c4f3ec51c02 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs @@ -11,8 +11,16 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use GetFileAttributesEx. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] - private static partial bool GetFileAttributesExPrivate(string? name, GET_FILEEX_INFO_LEVELS fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation); + private static partial bool GetFileAttributesExPrivate( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + private static extern bool GetFileAttributesExPrivate( +#endif + string? name, + GET_FILEEX_INFO_LEVELS fileInfoLevel, + ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation); internal static bool GetFileAttributesEx(string? name, GET_FILEEX_INFO_LEVELS fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation) { 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 0c69a28cc79ea..f824fd79d76fe 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,16 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use GetFullPathName or PathHelper. /// +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + internal static partial uint GetFullPathNameW( +#else [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)] - internal static extern uint GetFullPathNameW(ref char lpFileName, uint nBufferLength, ref char lpBuffer, IntPtr lpFilePart); + internal static extern uint GetFullPathNameW( +#endif + ref char lpFileName, + uint nBufferLength, + ref char lpBuffer, + IntPtr lpFilePart); } } 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 616edc72c61b7..b3be36d9007f5 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,15 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use GetFullPath/PathHelper. /// +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + internal static partial uint GetLongPathNameW( +#else [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)] - internal static extern uint GetLongPathNameW(ref char lpszShortPath, ref char lpszLongPath, uint cchBuffer); + internal static extern uint GetLongPathNameW( +#endif + ref char lpszShortPath, + ref char lpszLongPath, + uint cchBuffer); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs index 5a3acb3fcccc4..ff10cfef54791 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs @@ -7,9 +7,16 @@ internal static partial class Interop { internal static partial class Kernel32 { - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] [SuppressGCTransition] - internal static partial bool SetThreadErrorMode(uint dwNewMode, out uint lpOldMode); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + internal static partial bool SetThreadErrorMode( +#else + [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + internal static extern bool SetThreadErrorMode( +#endif + uint dwNewMode, + out uint lpOldMode); internal const uint SEM_FAILCRITICALERRORS = 1; } From 614ba846bbbd22836a24dcd8558a4077c1086a0c Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 7 Jun 2021 19:22:16 -0700 Subject: [PATCH 102/161] Use GeneratedDllImport in System.Net.Sockets (#53844) --- .../Unix/System.Native/Interop.Accept.cs | 4 +- .../Unix/System.Native/Interop.Bind.cs | 4 +- .../Unix/System.Native/Interop.Connect.cs | 4 +- .../Unix/System.Native/Interop.Fcntl.cs | 24 +++--- .../Interop.GetBytesAvailable.cs | 8 +- .../Interop.GetDomainSocketSizes.cs | 2 +- .../Unix/System.Native/Interop.GetPeerName.cs | 4 +- .../Unix/System.Native/Interop.GetSockName.cs | 4 +- .../Unix/System.Native/Interop.GetSockOpt.cs | 8 +- .../Interop.GetSocketErrorOption.cs | 4 +- .../System.Native/Interop.GetSocketType.cs | 4 +- .../Interop.IPPacketInformation.cs | 2 +- .../System.Native/Interop.LingerOption.cs | 8 +- .../Unix/System.Native/Interop.Listen.cs | 4 +- .../System.Native/Interop.MulticastOption.cs | 16 ++-- .../Unix/System.Native/Interop.Pipe.cs | 4 +- .../Unix/System.Native/Interop.Receive.cs | 4 +- .../System.Native/Interop.ReceiveMessage.cs | 4 +- .../Unix/System.Native/Interop.Send.cs | 4 +- .../Unix/System.Native/Interop.SendFile.cs | 4 +- .../Unix/System.Native/Interop.SendMessage.cs | 4 +- .../Interop.SetReceiveTimeout.cs | 4 +- .../System.Native/Interop.SetSendTimeout.cs | 4 +- .../Unix/System.Native/Interop.SetSockOpt.cs | 8 +- .../Unix/System.Native/Interop.Shutdown.cs | 4 +- .../Unix/System.Native/Interop.SocketEvent.cs | 8 +- .../Windows/Kernel32/Interop.CancelIoEx.cs | 8 +- .../Kernel32/Interop.HandleInformation.cs | 4 +- ...erop.SetFileCompletionNotificationModes.cs | 4 +- .../Windows/WinSock/Interop.TransmitFile.cs | 4 +- .../Windows/WinSock/Interop.WSAConnect.cs | 16 ++-- .../WinSock/Interop.WSADuplicateSocket.cs | 10 +-- .../WinSock/Interop.WSAGetOverlappedResult.cs | 14 ++-- .../Windows/WinSock/Interop.WSAIoctl.cs | 20 ++--- .../Windows/WinSock/Interop.WSARecv.cs | 4 +- .../Windows/WinSock/Interop.WSARecvFrom.cs | 4 +- .../Windows/WinSock/Interop.WSASend.cs | 4 +- .../Windows/WinSock/Interop.WSASendTo.cs | 4 +- .../Interop.WSASocketW.SafeCloseSocket.cs | 16 ++-- .../Windows/WinSock/Interop.WSASocketW.cs | 16 ++-- .../Interop/Windows/WinSock/Interop.accept.cs | 8 +- .../Interop/Windows/WinSock/Interop.bind.cs | 10 +-- .../Windows/WinSock/Interop.closesocket.cs | 4 +- .../Windows/WinSock/Interop.getpeername.cs | 10 +-- .../Windows/WinSock/Interop.getsockname.cs | 4 +- .../Windows/WinSock/Interop.getsockopt.cs | 42 +++++----- .../Windows/WinSock/Interop.ioctlsocket.cs | 20 ++--- .../Interop/Windows/WinSock/Interop.listen.cs | 8 +- .../Interop/Windows/WinSock/Interop.recv.cs | 10 +-- .../Windows/WinSock/Interop.recvfrom.cs | 14 ++-- .../Interop/Windows/WinSock/Interop.select.cs | 28 +++---- .../Interop/Windows/WinSock/Interop.send.cs | 10 +-- .../Interop/Windows/WinSock/Interop.sendto.cs | 14 ++-- .../Windows/WinSock/Interop.setsockopt.cs | 84 +++++++++---------- .../Windows/WinSock/Interop.shutdown.cs | 8 +- .../tests/System.Console.Tests.csproj | 1 + .../Net/Sockets/SocketAsyncEngine.Unix.cs | 20 +++-- .../src/System/Net/Sockets/SocketPal.Unix.cs | 2 +- .../Sockets/UnixDomainSocketEndPoint.Unix.cs | 10 ++- 59 files changed, 302 insertions(+), 285 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Accept.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Accept.cs index a36936b5db036..2385cf98bdbf2 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Accept.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Accept.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Accept")] - internal static extern unsafe Error Accept(SafeHandle socket, byte* socketAddress, int* socketAddressLen, IntPtr* acceptedFd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Accept")] + internal static unsafe partial Error Accept(SafeHandle socket, byte* socketAddress, int* socketAddressLen, IntPtr* acceptedFd); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Bind.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Bind.cs index b7e56d09d9d46..41dac6ff61cde 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Bind.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Bind.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Bind")] - internal static extern unsafe Error Bind(SafeHandle socket, ProtocolType socketProtocolType, byte* socketAddress, int socketAddressLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Bind")] + internal static unsafe partial Error Bind(SafeHandle socket, ProtocolType socketProtocolType, byte* socketAddress, int socketAddressLen); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Connect.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Connect.cs index 8e1fb3cc791d2..5149052c4ecd5 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Connect.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Connect.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Connect")] - internal static extern unsafe Error Connect(SafeHandle socket, byte* socketAddress, int socketAddressLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Connect")] + internal static unsafe partial Error Connect(SafeHandle socket, byte* socketAddress, int socketAddressLen); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.cs index 231621f2fa307..e5fb22e44af2c 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.cs @@ -10,23 +10,23 @@ internal static partial class Sys { internal static partial class Fcntl { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetIsNonBlocking", SetLastError = true)] - internal static extern int DangerousSetIsNonBlocking(IntPtr fd, int isNonBlocking); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetIsNonBlocking", SetLastError = true)] + internal static partial int DangerousSetIsNonBlocking(IntPtr fd, int isNonBlocking); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetIsNonBlocking", SetLastError=true)] - internal static extern int SetIsNonBlocking(SafeHandle fd, int isNonBlocking); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetIsNonBlocking", SetLastError=true)] + internal static partial int SetIsNonBlocking(SafeHandle fd, int isNonBlocking); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetIsNonBlocking", SetLastError = true)] - internal static extern int GetIsNonBlocking(SafeHandle fd, out bool isNonBlocking); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetIsNonBlocking", SetLastError = true)] + internal static partial int GetIsNonBlocking(SafeHandle fd, out bool isNonBlocking); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetFD", SetLastError=true)] - internal static extern int SetFD(SafeHandle fd, int flags); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetFD", SetLastError=true)] + internal static partial int SetFD(SafeHandle fd, int flags); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetFD", SetLastError=true)] - internal static extern int GetFD(SafeHandle fd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetFD", SetLastError=true)] + internal static partial int GetFD(SafeHandle fd); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetFD", SetLastError=true)] - internal static extern int GetFD(IntPtr fd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetFD", SetLastError=true)] + internal static partial int GetFD(IntPtr fd); } } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetBytesAvailable.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetBytesAvailable.cs index 741e132631eac..96b5791d13166 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetBytesAvailable.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetBytesAvailable.cs @@ -8,10 +8,10 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetBytesAvailable")] - internal static extern unsafe Error GetBytesAvailable(SafeHandle socket, int* available); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetBytesAvailable")] + internal static unsafe partial Error GetBytesAvailable(SafeHandle socket, int* available); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetAtOutOfBandMark")] - internal static extern unsafe Error GetAtOutOfBandMark(SafeHandle socket, int* atMark); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetAtOutOfBandMark")] + internal static unsafe partial Error GetAtOutOfBandMark(SafeHandle socket, int* atMark); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainSocketSizes.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainSocketSizes.cs index 3748ebfe148f0..7daf1ba2aef34 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainSocketSizes.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainSocketSizes.cs @@ -10,6 +10,6 @@ internal static partial class Sys { [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetDomainSocketSizes")] [SuppressGCTransition] - internal static extern void GetDomainSocketSizes(out int pathOffset, out int pathSize, out int addressSize); + internal static unsafe extern void GetDomainSocketSizes(int* pathOffset, int* pathSize, int* addressSize); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerName.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerName.cs index e400ae9a6f927..a66bcfe353609 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerName.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerName.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerName")] - internal static extern unsafe Error GetPeerName(SafeHandle socket, byte* socketAddress, int* socketAddressLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerName")] + internal static unsafe partial Error GetPeerName(SafeHandle socket, byte* socketAddress, int* socketAddressLen); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockName.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockName.cs index fb1aa6b735bb2..a0a44f2a1792e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockName.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockName.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSockName")] - internal static extern unsafe Error GetSockName(SafeHandle socket, byte* socketAddress, int* socketAddressLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSockName")] + internal static unsafe partial Error GetSockName(SafeHandle socket, byte* socketAddress, int* socketAddressLen); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockOpt.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockOpt.cs index 71f69d69ab76b..0a0dbae00073f 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockOpt.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSockOpt.cs @@ -9,13 +9,13 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSockOpt")] - internal static extern unsafe Error GetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int* optionLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSockOpt")] + internal static unsafe partial Error GetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int* optionLen); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSockOpt")] internal static extern unsafe Error GetSockOpt(IntPtr socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int* optionLen); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetRawSockOpt")] - internal static extern unsafe Error GetRawSockOpt(SafeHandle socket, int optionLevel, int optionName, byte* optionValue, int* optionLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetRawSockOpt")] + internal static unsafe partial Error GetRawSockOpt(SafeHandle socket, int optionLevel, int optionName, byte* optionValue, int* optionLen); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketErrorOption.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketErrorOption.cs index 1fb0dcecc207c..a77fb31b77a3a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketErrorOption.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketErrorOption.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSocketErrorOption")] - internal static extern unsafe Error GetSocketErrorOption(SafeHandle socket, Error* socketError); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSocketErrorOption")] + internal static unsafe partial Error GetSocketErrorOption(SafeHandle socket, Error* socketError); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketType.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketType.cs index a97336d2cc8fc..387b02646f114 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketType.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSocketType.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSocketType")] - internal static extern Error GetSocketType(SafeSocketHandle socket, out AddressFamily addressFamily, out SocketType socketType, out ProtocolType protocolType, out bool isListening); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSocketType")] + internal static partial Error GetSocketType(SafeSocketHandle socket, out AddressFamily addressFamily, out SocketType socketType, out ProtocolType protocolType, out bool isListening); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs index 76c992748b626..fe25a9eb5eeb6 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs @@ -21,6 +21,6 @@ internal struct IPPacketInformation internal static extern int GetControlMessageBufferSize(int isIPv4, int isIPv6); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_TryGetIPPacketInformation")] - internal static extern unsafe bool TryGetIPPacketInformation(MessageHeader* messageHeader, bool isIPv4, IPPacketInformation* packetInfo); + internal static unsafe extern int TryGetIPPacketInformation(MessageHeader* messageHeader, int isIPv4, IPPacketInformation* packetInfo); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LingerOption.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LingerOption.cs index 312222f042d5e..5092a15151dbb 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LingerOption.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LingerOption.cs @@ -15,11 +15,11 @@ internal struct LingerOption public int Seconds; // Number of seconds to linger for } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetLingerOption")] - internal static extern unsafe Error GetLingerOption(SafeHandle socket, LingerOption* option); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetLingerOption")] + internal static unsafe partial Error GetLingerOption(SafeHandle socket, LingerOption* option); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetLingerOption")] - internal static extern unsafe Error SetLingerOption(SafeHandle socket, LingerOption* option); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetLingerOption")] + internal static unsafe partial Error SetLingerOption(SafeHandle socket, LingerOption* option); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetLingerOption")] internal static extern unsafe Error SetLingerOption(IntPtr socket, LingerOption* option); diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Listen.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Listen.cs index b6196a3de5646..f630563bd1283 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Listen.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Listen.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Listen")] - internal static extern Error Listen(SafeHandle socket, int backlog); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Listen")] + internal static partial Error Listen(SafeHandle socket, int backlog); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MulticastOption.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MulticastOption.cs index aa4445573a4b2..f874683371108 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MulticastOption.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MulticastOption.cs @@ -31,16 +31,16 @@ internal struct IPv6MulticastOption private int _padding; } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetIPv4MulticastOption")] - internal static extern unsafe Error GetIPv4MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv4MulticastOption* option); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetIPv4MulticastOption")] + internal static unsafe partial Error GetIPv4MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv4MulticastOption* option); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetIPv4MulticastOption")] - internal static extern unsafe Error SetIPv4MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv4MulticastOption* option); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetIPv4MulticastOption")] + internal static unsafe partial Error SetIPv4MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv4MulticastOption* option); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetIPv6MulticastOption")] - internal static extern unsafe Error GetIPv6MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv6MulticastOption* option); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetIPv6MulticastOption")] + internal static unsafe partial Error GetIPv6MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv6MulticastOption* option); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetIPv6MulticastOption")] - internal static extern unsafe Error SetIPv6MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv6MulticastOption* option); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetIPv6MulticastOption")] + internal static unsafe partial Error SetIPv6MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv6MulticastOption* option); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Pipe.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Pipe.cs index ca4fc28b2c612..92587f258f6af 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Pipe.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Pipe.cs @@ -24,7 +24,7 @@ internal enum PipeFlags /// internal const int WriteEndOfPipe = 1; - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Pipe", SetLastError = true)] - internal static extern unsafe int Pipe(int* pipefd, PipeFlags flags = 0); // pipefd is an array of two ints + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Pipe", SetLastError = true)] + internal static unsafe partial int Pipe(int* pipefd, PipeFlags flags = 0); // pipefd is an array of two ints } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Receive.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Receive.cs index a30f4c5e43a4f..a23bdad54aec7 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Receive.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Receive.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Receive")] - internal static extern unsafe Error Receive(SafeHandle socket, byte* buffer, int bufferLen, SocketFlags flags, int* received); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Receive")] + internal static unsafe partial Error Receive(SafeHandle socket, byte* buffer, int bufferLen, SocketFlags flags, int* received); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReceiveMessage.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReceiveMessage.cs index 643e2acc39dce..5757d46f6cc52 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReceiveMessage.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReceiveMessage.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReceiveMessage")] - internal static extern unsafe Error ReceiveMessage(SafeHandle socket, MessageHeader* messageHeader, SocketFlags flags, long* received); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReceiveMessage")] + internal static unsafe partial Error ReceiveMessage(SafeHandle socket, MessageHeader* messageHeader, SocketFlags flags, long* received); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Send.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Send.cs index b22723d266c1b..c65b45291709e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Send.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Send.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Send")] - internal static extern unsafe Error Send(SafeHandle socket, byte* buffer, int bufferLen, SocketFlags flags, int* sent); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Send")] + internal static unsafe partial Error Send(SafeHandle socket, byte* buffer, int bufferLen, SocketFlags flags, int* sent); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendFile.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendFile.cs index 3eb343895fafb..b7310100384f7 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendFile.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendFile.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SendFile", SetLastError = true)] - internal static extern Error SendFile(SafeHandle out_fd, SafeHandle in_fd, long offset, long count, out long sent); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SendFile", SetLastError = true)] + internal static partial Error SendFile(SafeHandle out_fd, SafeHandle in_fd, long offset, long count, out long sent); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendMessage.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendMessage.cs index 7d1474896f634..d091c9d29dd82 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendMessage.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SendMessage.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SendMessage")] - internal static extern unsafe Error SendMessage(SafeHandle socket, MessageHeader* messageHeader, SocketFlags flags, long* sent); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SendMessage")] + internal static unsafe partial Error SendMessage(SafeHandle socket, MessageHeader* messageHeader, SocketFlags flags, long* sent); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetReceiveTimeout.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetReceiveTimeout.cs index daba80bbed250..5eae239583689 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetReceiveTimeout.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetReceiveTimeout.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetReceiveTimeout")] - internal static extern Error SetReceiveTimeout(SafeHandle socket, int millisecondsTimeout); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetReceiveTimeout")] + internal static partial Error SetReceiveTimeout(SafeHandle socket, int millisecondsTimeout); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSendTimeout.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSendTimeout.cs index ac7171fa48352..7e2fe7c131d20 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSendTimeout.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSendTimeout.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSendTimeout")] - internal static extern Error SetSendTimeout(SafeHandle socket, int millisecondsTimeout); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSendTimeout")] + internal static partial Error SetSendTimeout(SafeHandle socket, int millisecondsTimeout); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSockOpt.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSockOpt.cs index 6172c266a61e4..10760287e439e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSockOpt.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSockOpt.cs @@ -9,13 +9,13 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSockOpt")] - internal static extern unsafe Error SetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSockOpt")] + internal static unsafe partial Error SetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSockOpt")] internal static extern unsafe Error SetSockOpt(IntPtr socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetRawSockOpt")] - internal static extern unsafe Error SetRawSockOpt(SafeHandle socket, int optionLevel, int optionName, byte* optionValue, int optionLen); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetRawSockOpt")] + internal static unsafe partial Error SetRawSockOpt(SafeHandle socket, int optionLevel, int optionName, byte* optionValue, int optionLen); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Shutdown.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Shutdown.cs index 6bbb8d70da67a..ee516a59c2e86 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Shutdown.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Shutdown.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Shutdown")] - internal static extern Error Shutdown(SafeHandle socket, SocketShutdown how); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Shutdown")] + internal static partial Error Shutdown(SafeHandle socket, SocketShutdown how); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Shutdown")] internal static extern Error Shutdown(IntPtr socket, SocketShutdown how); diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SocketEvent.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SocketEvent.cs index 2a8246a7b9ab0..c3e6769ac6cdd 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SocketEvent.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SocketEvent.cs @@ -28,19 +28,19 @@ internal struct SocketEvent } [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CreateSocketEventPort")] - internal static extern Error CreateSocketEventPort(out IntPtr port); + internal static unsafe extern Error CreateSocketEventPort(IntPtr* port); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CloseSocketEventPort")] internal static extern Error CloseSocketEventPort(IntPtr port); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CreateSocketEventBuffer")] - internal static extern unsafe Error CreateSocketEventBuffer(int count, out SocketEvent* buffer); + internal static unsafe extern Error CreateSocketEventBuffer(int count, SocketEvent** buffer); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FreeSocketEventBuffer")] internal static extern unsafe Error FreeSocketEventBuffer(SocketEvent* buffer); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_TryChangeSocketEventRegistration")] - internal static extern Error TryChangeSocketEventRegistration(IntPtr port, SafeHandle socket, SocketEvents currentEvents, SocketEvents newEvents, IntPtr data); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_TryChangeSocketEventRegistration")] + internal static partial Error TryChangeSocketEventRegistration(IntPtr port, SafeHandle socket, SocketEvents currentEvents, SocketEvents newEvents, IntPtr data); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_TryChangeSocketEventRegistration")] internal static extern Error TryChangeSocketEventRegistration(IntPtr port, IntPtr socket, SocketEvents currentEvents, SocketEvents newEvents, IntPtr data); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CancelIoEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CancelIoEx.cs index 124578deb49b6..45d5dcfcac14c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CancelIoEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CancelIoEx.cs @@ -9,10 +9,10 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe bool CancelIoEx(SafeHandle handle, NativeOverlapped* lpOverlapped); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial bool CancelIoEx(SafeHandle handle, NativeOverlapped* lpOverlapped); - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe bool CancelIoEx(IntPtr handle, NativeOverlapped* lpOverlapped); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial bool CancelIoEx(IntPtr handle, NativeOverlapped* lpOverlapped); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.HandleInformation.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.HandleInformation.cs index fdc12144d35ae..85c07d6c34a99 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.HandleInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.HandleInformation.cs @@ -17,7 +17,7 @@ internal enum HandleFlags : uint HANDLE_FLAG_PROTECT_FROM_CLOSE = 2 } - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetHandleInformation(SafeHandle hObject, HandleFlags dwMask, HandleFlags dwFlags); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetHandleInformation(SafeHandle hObject, HandleFlags dwMask, HandleFlags dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileCompletionNotificationModes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileCompletionNotificationModes.cs index 684fabc0cafd0..9a1bcadfbd953 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileCompletionNotificationModes.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileCompletionNotificationModes.cs @@ -16,7 +16,7 @@ internal enum FileCompletionNotificationModes : byte SkipSetEventOnHandle = 2 } - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetFileCompletionNotificationModes(SafeHandle handle, FileCompletionNotificationModes flags); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetFileCompletionNotificationModes(SafeHandle handle, FileCompletionNotificationModes flags); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs index c26ce52c41c91..56de7a94d9f7f 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs @@ -10,8 +10,8 @@ internal static partial class Interop { internal static partial class Mswsock { - [DllImport(Interop.Libraries.Mswsock, SetLastError = true)] - internal static extern unsafe bool TransmitFile( + [GeneratedDllImport(Interop.Libraries.Mswsock, SetLastError = true)] + internal static unsafe partial bool TransmitFile( SafeHandle socket, IntPtr fileHandle, int numberOfBytesToWrite, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAConnect.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAConnect.cs index a15a0d67f0468..6d827d94e2332 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAConnect.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAConnect.cs @@ -9,14 +9,14 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError WSAConnect( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError WSAConnect( SafeSocketHandle socketHandle, - [In] byte[] socketAddress, - [In] int socketAddressSize, - [In] IntPtr inBuffer, - [In] IntPtr outBuffer, - [In] IntPtr sQOS, - [In] IntPtr gQOS); + byte[] socketAddress, + int socketAddressSize, + IntPtr inBuffer, + IntPtr outBuffer, + IntPtr sQOS, + IntPtr gQOS); } } 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 a394ebb519fea..25c50d0522e3a 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSADuplicateSocket.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSADuplicateSocket.cs @@ -8,11 +8,11 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe int WSADuplicateSocket( - [In] SafeSocketHandle s, - [In] uint dwProcessId, - [In] WSAPROTOCOL_INFOW* lpProtocolInfo + [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial int WSADuplicateSocket( + SafeSocketHandle s, + uint dwProcessId, + WSAPROTOCOL_INFOW* lpProtocolInfo ); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAGetOverlappedResult.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAGetOverlappedResult.cs index 51517a2e3c621..4ba107cf46299 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAGetOverlappedResult.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAGetOverlappedResult.cs @@ -9,12 +9,12 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe bool WSAGetOverlappedResult( - [In] SafeSocketHandle socketHandle, - [In] NativeOverlapped* overlapped, - [Out] out uint bytesTransferred, - [In] bool wait, - [Out] out SocketFlags socketFlags); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial bool WSAGetOverlappedResult( + SafeSocketHandle socketHandle, + NativeOverlapped* overlapped, + out uint bytesTransferred, + bool wait, + out SocketFlags socketFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs index d067e351f755c..53f7738ab9ac9 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs @@ -22,16 +22,16 @@ internal static extern SocketError WSAIoctl( [In] IntPtr shouldBeNull, [In] IntPtr shouldBeNull2); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true, EntryPoint = "WSAIoctl")] - internal static extern SocketError WSAIoctl_Blocking( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true, EntryPoint = "WSAIoctl")] + internal static partial SocketError WSAIoctl_Blocking( SafeSocketHandle socketHandle, - [In] int ioControlCode, - [In] byte[]? inBuffer, - [In] int inBufferSize, - [Out] byte[]? outBuffer, - [In] int outBufferSize, - [Out] out int bytesTransferred, - [In] IntPtr overlapped, - [In] IntPtr completionRoutine); + int ioControlCode, + byte[]? inBuffer, + int inBufferSize, + byte[]? outBuffer, + int outBufferSize, + out int bytesTransferred, + IntPtr overlapped, + IntPtr completionRoutine); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecv.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecv.cs index e775ebcd775b0..1a9f090bd83c3 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecv.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecv.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe SocketError WSARecv( + [GeneratedDllImport(Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial SocketError WSARecv( SafeHandle socketHandle, WSABuffer* buffer, int bufferCount, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecvFrom.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecvFrom.cs index da2667e0bbe66..dc200e6c8fd30 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecvFrom.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSARecvFrom.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - private static extern unsafe SocketError WSARecvFrom( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + private static unsafe partial SocketError WSARecvFrom( SafeHandle socketHandle, WSABuffer* buffers, int bufferCount, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASend.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASend.cs index 30c2786b664e2..583674f8f4aa8 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASend.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASend.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe SocketError WSASend( + [GeneratedDllImport(Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial SocketError WSASend( SafeHandle socketHandle, WSABuffer* buffers, int bufferCount, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASendTo.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASendTo.cs index b98509b1ca27d..4896eb8557ad5 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASendTo.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASendTo.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - private static extern unsafe SocketError WSASendTo( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + private static unsafe partial SocketError WSASendTo( SafeHandle socketHandle, WSABuffer* buffers, int bufferCount, 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 2fca0e1aa269b..fcf408c262a03 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,13 +9,13 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr WSASocketW( - [In] AddressFamily addressFamily, - [In] SocketType socketType, - [In] ProtocolType protocolType, - [In] IntPtr protocolInfo, - [In] uint group, - [In] SocketConstructorFlags flags); + [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial IntPtr WSASocketW( + AddressFamily addressFamily, + SocketType socketType, + ProtocolType protocolType, + IntPtr protocolInfo, + uint group, + SocketConstructorFlags flags); } } 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 db6e3bda33e66..9f0060b4afdd1 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSASocketW.cs @@ -12,13 +12,13 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr WSASocketW( - [In] AddressFamily addressFamily, - [In] SocketType socketType, - [In] int protocolType, - [In] IntPtr protocolInfo, - [In] int group, - [In] int flags); + [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial IntPtr WSASocketW( + AddressFamily addressFamily, + SocketType socketType, + int protocolType, + IntPtr protocolInfo, + int group, + int flags); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.accept.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.accept.cs index 0e0ae44df5f07..4e34ee8b1fe13 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.accept.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.accept.cs @@ -9,10 +9,10 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] - internal static extern IntPtr accept( + [GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] + internal static partial IntPtr accept( SafeSocketHandle socketHandle, - [Out] byte[] socketAddress, - [In, Out] ref int socketAddressSize); + byte[] socketAddress, + ref int socketAddressSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.bind.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.bind.cs index e407f134dadb9..a5f8d3b664557 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.bind.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.bind.cs @@ -8,10 +8,10 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError bind( - [In] SafeSocketHandle socketHandle, - [In] byte[] socketAddress, - [In] int socketAddressSize); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError bind( + SafeSocketHandle socketHandle, + byte[] socketAddress, + int socketAddressSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.closesocket.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.closesocket.cs index 1a1f6406e2901..d80768bccba4b 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.closesocket.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.closesocket.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] - internal static extern SocketError closesocket([In] IntPtr socketHandle); + [GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] + internal static partial SocketError closesocket(IntPtr socketHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getpeername.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getpeername.cs index a2ce5be9b4a1b..fa7b34683d502 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getpeername.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getpeername.cs @@ -9,10 +9,10 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe SocketError getpeername( - [In] SafeSocketHandle socketHandle, - [Out] byte* socketAddress, - [In, Out] ref int socketAddressSize); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial SocketError getpeername( + SafeSocketHandle socketHandle, + byte* socketAddress, + ref int socketAddressSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockname.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockname.cs index f457ea17c40c1..d177ac70cacae 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockname.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockname.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe SocketError getsockname( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial SocketError getsockname( SafeSocketHandle socketHandle, byte* socketAddress, int* socketAddressSize); diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockopt.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockopt.cs index 78deae877c635..bdfd0e49be9f0 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockopt.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.getsockopt.cs @@ -8,29 +8,29 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static unsafe extern SocketError getsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [Out] byte* optionValue, - [In, Out] ref int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial SocketError getsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + byte* optionValue, + ref int optionLength); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError getsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [Out] out Linger optionValue, - [In, Out] ref int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError getsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + out Linger optionValue, + ref int optionLength); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError getsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [Out] out IPMulticastRequest optionValue, - [In, Out] ref int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError getsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + out IPMulticastRequest optionValue, + ref int optionLength); [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] internal static extern SocketError getsockopt( diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.ioctlsocket.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.ioctlsocket.cs index f9ed61b46e115..92e32e6d3c561 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.ioctlsocket.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.ioctlsocket.cs @@ -9,16 +9,16 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] - internal static extern SocketError ioctlsocket( - [In] IntPtr handle, - [In] int cmd, - [In, Out] ref int argp); + [GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] + internal static partial SocketError ioctlsocket( + IntPtr handle, + int cmd, + ref int argp); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError ioctlsocket( - [In] SafeSocketHandle socketHandle, - [In] int cmd, - [In, Out] ref int argp); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError ioctlsocket( + SafeSocketHandle socketHandle, + int cmd, + ref int argp); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.listen.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.listen.cs index 3afb3b4fe28bc..a86447206247d 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.listen.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.listen.cs @@ -8,9 +8,9 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError listen( - [In] SafeSocketHandle socketHandle, - [In] int backlog); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError listen( + SafeSocketHandle socketHandle, + int backlog); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recv.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recv.cs index a4fd9b41ed2e5..20f0a6801a4ab 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recv.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recv.cs @@ -9,11 +9,11 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe int recv( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial int recv( SafeSocketHandle socketHandle, - [In] byte* pinnedBuffer, - [In] int len, - [In] SocketFlags socketFlags); + byte* pinnedBuffer, + int len, + SocketFlags socketFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recvfrom.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recvfrom.cs index 95d1dee327f7e..14daa97315975 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recvfrom.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.recvfrom.cs @@ -10,13 +10,13 @@ internal static partial class Interop internal static partial class Winsock { // This method is always blocking, so it uses an IntPtr. - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe int recvfrom( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial int recvfrom( SafeSocketHandle socketHandle, - [In] byte* pinnedBuffer, - [In] int len, - [In] SocketFlags socketFlags, - [Out] byte[] socketAddress, - [In, Out] ref int socketAddressSize); + byte* pinnedBuffer, + int len, + SocketFlags socketFlags, + byte[] socketAddress, + ref int socketAddressSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.select.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.select.cs index f6a2670643f2b..889bdeea2aa84 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.select.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.select.cs @@ -8,20 +8,20 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe int select( - [In] int ignoredParameter, - [In] IntPtr* readfds, - [In] IntPtr* writefds, - [In] IntPtr* exceptfds, - [In] ref TimeValue timeout); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial int select( + int ignoredParameter, + IntPtr* readfds, + IntPtr* writefds, + IntPtr* exceptfds, + ref TimeValue timeout); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe int select( - [In] int ignoredParameter, - [In] IntPtr* readfds, - [In] IntPtr* writefds, - [In] IntPtr* exceptfds, - [In] IntPtr nullTimeout); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial int select( + int ignoredParameter, + IntPtr* readfds, + IntPtr* writefds, + IntPtr* exceptfds, + IntPtr nullTimeout); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.send.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.send.cs index 4c1e02d5112cd..4c75af9669fcf 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.send.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.send.cs @@ -9,11 +9,11 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe int send( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial int send( SafeSocketHandle socketHandle, - [In] byte* pinnedBuffer, - [In] int len, - [In] SocketFlags socketFlags); + byte* pinnedBuffer, + int len, + SocketFlags socketFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.sendto.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.sendto.cs index 66dd58f82b5d9..c2dfd4801f743 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.sendto.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.sendto.cs @@ -9,13 +9,13 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe int sendto( + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial int sendto( SafeSocketHandle socketHandle, - [In] byte* pinnedBuffer, - [In] int len, - [In] SocketFlags socketFlags, - [In] byte[] socketAddress, - [In] int socketAddressSize); + byte* pinnedBuffer, + int len, + SocketFlags socketFlags, + byte[] socketAddress, + int socketAddressSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs index 6c5118655e1fb..98a9a3d4f3295 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs @@ -9,53 +9,53 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] - internal static extern SocketError setsockopt( - [In] IntPtr handle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [In] ref Linger linger, - [In] int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] + internal static partial SocketError setsockopt( + IntPtr handle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + ref Linger linger, + int optionLength); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError setsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [In] ref int optionValue, - [In] int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError setsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + ref int optionValue, + int optionLength); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static unsafe extern SocketError setsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [In] byte* optionValue, - [In] int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial SocketError setsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + byte* optionValue, + int optionLength); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError setsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [In] ref IntPtr pointer, - [In] int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError setsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + ref IntPtr pointer, + int optionLength); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError setsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [In] ref Linger linger, - [In] int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError setsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + ref Linger linger, + int optionLength); - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError setsockopt( - [In] SafeSocketHandle socketHandle, - [In] SocketOptionLevel optionLevel, - [In] SocketOptionName optionName, - [In] ref IPMulticastRequest mreq, - [In] int optionLength); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError setsockopt( + SafeSocketHandle socketHandle, + SocketOptionLevel optionLevel, + SocketOptionName optionName, + ref IPMulticastRequest mreq, + int optionLength); [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] internal static extern SocketError setsockopt( diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.shutdown.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.shutdown.cs index 99086e04fee27..870a9c3332833 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.shutdown.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.shutdown.cs @@ -8,9 +8,9 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError shutdown( - [In] SafeSocketHandle socketHandle, - [In] int how); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError shutdown( + SafeSocketHandle socketHandle, + int how); } } diff --git a/src/libraries/System.Console/tests/System.Console.Tests.csproj b/src/libraries/System.Console/tests/System.Console.Tests.csproj index 082f61922fe0c..f92a0cdfc4913 100644 --- a/src/libraries/System.Console/tests/System.Console.Tests.csproj +++ b/src/libraries/System.Console/tests/System.Console.Tests.csproj @@ -3,6 +3,7 @@ true true $(NetCoreAppCurrent);$(NetCoreAppCurrent)-windows + true diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs index 983ca51ed27ee..aafcf158518a9 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs @@ -140,15 +140,23 @@ private SocketAsyncEngine() // // Create the event port and buffer // - Interop.Error err = Interop.Sys.CreateSocketEventPort(out _port); - if (err != Interop.Error.SUCCESS) + Interop.Error err; + fixed (IntPtr* portPtr = &_port) { - throw new InternalException(err); + err = Interop.Sys.CreateSocketEventPort(portPtr); + if (err != Interop.Error.SUCCESS) + { + throw new InternalException(err); + } } - err = Interop.Sys.CreateSocketEventBuffer(EventBufferCount, out _buffer); - if (err != Interop.Error.SUCCESS) + + fixed (Interop.Sys.SocketEvent** bufferPtr = &_buffer) { - throw new InternalException(err); + err = Interop.Sys.CreateSocketEventBuffer(EventBufferCount, bufferPtr); + if (err != Interop.Error.SUCCESS) + { + throw new InternalException(err); + } } var thread = new Thread(static s => ((SocketAsyncEngine)s!).EventLoop()) diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs index 0e64fc1f16d88..7750e2daca951 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs @@ -45,7 +45,7 @@ private static unsafe IPPacketInformation GetIPPacketInformation(Interop.Sys.Mes } Interop.Sys.IPPacketInformation nativePacketInfo = default; - if (!Interop.Sys.TryGetIPPacketInformation(messageHeader, isIPv4, &nativePacketInfo)) + if (Interop.Sys.TryGetIPPacketInformation(messageHeader, Convert.ToInt32(isIPv4), &nativePacketInfo) == 0) { return default(IPPacketInformation); } diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.Unix.cs index d5bd57db6f8e1..bb08eca42864e 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.Unix.cs @@ -15,7 +15,15 @@ public sealed partial class UnixDomainSocketEndPoint : EndPoint static UnixDomainSocketEndPoint() { - Interop.Sys.GetDomainSocketSizes(out s_nativePathOffset, out s_nativePathLength, out s_nativeAddressSize); + unsafe + { + fixed (int* pathOffset = &s_nativePathOffset) + fixed (int* pathLength = &s_nativePathLength) + fixed (int* addressSize = &s_nativeAddressSize) + { + Interop.Sys.GetDomainSocketSizes(pathOffset, pathLength, addressSize); + } + } Debug.Assert(s_nativePathOffset >= 0, "Expected path offset to be positive"); Debug.Assert(s_nativePathOffset + s_nativePathLength <= s_nativeAddressSize, "Expected address size to include all of the path length"); From 4aad39d5f2d790371d24895a31ffde98602cf5d7 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 8 Jun 2021 15:40:10 -0700 Subject: [PATCH 103/161] Use GeneratedDllImport in System.Security.Principal.Windows (#53903) --- .../Advapi32/Interop.AllocateLocallyUniqueId.cs | 2 +- .../Advapi32/Interop.CheckTokenMembership.cs | 10 +++++++++- .../Advapi32/Interop.ConvertStringSidToSid.cs | 9 ++++++++- .../Advapi32/Interop.CreateWellKnownSid.cs | 11 ++++++++++- .../Windows/Advapi32/Interop.DuplicateTokenEx.cs | 5 +++++ .../Advapi32/Interop.GetTokenInformation.cs | 15 +++++++++++++++ .../Interop.GetWindowsAccountDomainSid.cs | 10 +++++++++- .../Advapi32/Interop.ImpersonateLoggedOnUser.cs | 5 +++++ .../Windows/Advapi32/Interop.IsEqualDomainSid.cs | 10 +++++++++- .../Windows/Advapi32/Interop.IsWellKnownSid.cs | 9 ++++++++- .../Interop/Windows/Advapi32/Interop.LsaClose.cs | 5 +++++ .../Windows/Advapi32/Interop.LsaFreeMemory.cs | 5 +++++ .../Windows/Advapi32/Interop.LsaLookupSids.cs | 5 +++++ .../Windows/Advapi32/Interop.LsaOpenPolicy.cs | 5 +++++ ...erop.OpenProcessToken_SafeAccessTokenHandle.cs | 10 +++++++++- .../Windows/Advapi32/Interop.OpenThreadToken.cs | 11 ++++++++++- .../Windows/Advapi32/Interop.RevertToSelf.cs | 5 +++++ ...terop.DuplicateHandle_SafeAccessTokenHandle.cs | 5 +++++ .../SspiCli/Interop.LsaConnectUntrusted.cs | 5 +++++ .../SspiCli/Interop.LsaFreeReturnBuffer.cs | 5 +++++ .../SspiCli/Interop.LsaGetLogonSessionData.cs | 9 ++++++++- .../Interop.LsaLookupAuthenticationPackage.cs | 7 ++++++- .../src/System.Security.Principal.Windows.csproj | 1 + .../System/Security/Principal/WindowsIdentity.cs | 8 ++++++-- 24 files changed, 159 insertions(+), 13 deletions(-) diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs index 689f8328d5207..594464a5efc03 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class Advapi32 { [DllImport(Libraries.Advapi32)] - internal static extern bool AllocateLocallyUniqueId(out LUID Luid); + internal static unsafe extern int AllocateLocallyUniqueId(LUID* Luid); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CheckTokenMembership.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CheckTokenMembership.cs index 1af4dba20107b..44cd007990090 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CheckTokenMembership.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CheckTokenMembership.cs @@ -9,7 +9,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial bool CheckTokenMembership( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] - internal static extern bool CheckTokenMembership(SafeAccessTokenHandle TokenHandle, byte[] SidToCheck, ref bool IsMember); + internal static extern bool CheckTokenMembership( +#endif + SafeAccessTokenHandle TokenHandle, + byte[] SidToCheck, + ref bool IsMember); } } 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 39a9559f4f4a0..b017d16e48157 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,14 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial int ConvertStringSidToSid( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", SetLastError = true, CharSet = CharSet.Unicode)] - internal static extern int ConvertStringSidToSid(string stringSid, out IntPtr ByteArray); + internal static extern int ConvertStringSidToSid( +#endif + string stringSid, + out IntPtr ByteArray); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs index 132f4a3e5846f..3ed45cf793ff1 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs @@ -8,7 +8,16 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial int CreateWellKnownSid( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] - internal static extern int CreateWellKnownSid(int sidType, byte[]? domainSid, byte[] resultSid, ref uint resultSidLength); + internal static extern int CreateWellKnownSid( +#endif + int sidType, + byte[]? domainSid, + byte[] resultSid, + ref uint resultSidLength); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx.cs index e0fd150bce014..9f4fd71dc6249 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial bool DuplicateTokenEx( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] internal static extern bool DuplicateTokenEx( +#endif SafeAccessTokenHandle hExistingToken, uint dwDesiredAccess, IntPtr lpTokenAttributes, // LPSECURITY_ATTRIBUTES diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs index 5423812f21ed1..d881a59ac0551 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs @@ -9,24 +9,39 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial bool GetTokenInformation( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] internal static extern bool GetTokenInformation( +#endif SafeAccessTokenHandle TokenHandle, uint TokenInformationClass, SafeLocalAllocHandle TokenInformation, uint TokenInformationLength, out uint ReturnLength); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial bool GetTokenInformation( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] internal static extern bool GetTokenInformation( +#endif IntPtr TokenHandle, uint TokenInformationClass, SafeLocalAllocHandle TokenInformation, uint TokenInformationLength, out uint ReturnLength); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool GetTokenInformation( +#else [DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool GetTokenInformation( +#endif IntPtr TokenHandle, uint TokenInformationClass, IntPtr TokenInformation, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs index 9792f1f730c5d..b34b47f44e6b0 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs @@ -8,7 +8,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial int GetWindowsAccountDomainSid( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] - internal static extern int GetWindowsAccountDomainSid(byte[] sid, byte[] resultSid, ref uint resultSidLength); + internal static extern int GetWindowsAccountDomainSid( +#endif + byte[] sid, + byte[] resultSid, + ref uint resultSidLength); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateLoggedOnUser.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateLoggedOnUser.cs index cf9ff0bfe15f1..10ab8ec20a513 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateLoggedOnUser.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateLoggedOnUser.cs @@ -9,7 +9,12 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool ImpersonateLoggedOnUser(SafeAccessTokenHandle userToken); +#else [DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool ImpersonateLoggedOnUser(SafeAccessTokenHandle userToken); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs index 501ab7a07e3da..c18d90e335b2e 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs @@ -8,7 +8,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial int IsEqualDomainSid( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] - internal static extern int IsEqualDomainSid(byte[] sid1, byte[] sid2, out bool result); + internal static extern int IsEqualDomainSid( +#endif + byte[] sid1, + byte[] sid2, + out bool result); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs index db37418003075..c12c218c31aab 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs @@ -8,7 +8,14 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial int IsWellKnownSid( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] - internal static extern int IsWellKnownSid(byte[] sid, int type); + internal static extern int IsWellKnownSid( +#endif + byte[] sid, + int type); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaClose.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaClose.cs index bc29d83ab829b..e16ad2b7249f8 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaClose.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaClose.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial int LsaClose(IntPtr handle); +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] internal static extern int LsaClose(IntPtr handle); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaFreeMemory.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaFreeMemory.cs index 5193363331ec2..9d4823cdd6f24 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaFreeMemory.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaFreeMemory.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial int LsaFreeMemory(IntPtr handle); +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] internal static extern int LsaFreeMemory(IntPtr handle); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs index 9986e358ca186..03829ca35da3e 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", SetLastError = true, CharSet = CharSet.Unicode)] + internal static partial uint LsaLookupSids( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", SetLastError = true, CharSet = CharSet.Unicode)] internal static extern uint LsaLookupSids( +#endif SafeLsaPolicyHandle handle, int count, IntPtr[] sids, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs index 910e6ff0015e1..ea6366e9c7095 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", SetLastError = true, CharSet = CharSet.Unicode)] + private static partial uint LsaOpenPolicy( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", SetLastError = true, CharSet = CharSet.Unicode)] private static extern uint LsaOpenPolicy( +#endif ref UNICODE_STRING SystemName, ref OBJECT_ATTRIBUTES ObjectAttributes, int AccessMask, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_SafeAccessTokenHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_SafeAccessTokenHandle.cs index b0560ba54dd0c..bf48ccbd086b5 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_SafeAccessTokenHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_SafeAccessTokenHandle.cs @@ -10,7 +10,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial bool OpenProcessToken( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] - internal static extern bool OpenProcessToken(IntPtr ProcessToken, TokenAccessLevels DesiredAccess, out SafeAccessTokenHandle TokenHandle); + internal static extern bool OpenProcessToken( +#endif + IntPtr ProcessToken, + TokenAccessLevels DesiredAccess, + out SafeAccessTokenHandle TokenHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken.cs index 8bce8337b2154..1deda3432150e 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken.cs @@ -10,8 +10,17 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + private static partial bool OpenThreadToken( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] - private static extern bool OpenThreadToken(IntPtr ThreadHandle, TokenAccessLevels dwDesiredAccess, bool bOpenAsSelf, out SafeAccessTokenHandle phThreadToken); + private static extern bool OpenThreadToken( +#endif + IntPtr ThreadHandle, + TokenAccessLevels dwDesiredAccess, + bool bOpenAsSelf, + out SafeAccessTokenHandle phThreadToken); internal static bool OpenThreadToken(TokenAccessLevels desiredAccess, WinSecurityContext openAs, out SafeAccessTokenHandle tokenHandle) { diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs index e18e63f04b558..d314a941100df 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + internal static partial bool RevertToSelf(); +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] internal static extern bool RevertToSelf(); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeAccessTokenHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeAccessTokenHandle.cs index fff392dedad44..ddfd30f11ff6d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeAccessTokenHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeAccessTokenHandle.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool DuplicateHandle( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool DuplicateHandle( +#endif IntPtr hSourceProcessHandle, IntPtr hSourceHandle, IntPtr hTargetProcessHandle, diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaConnectUntrusted.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaConnectUntrusted.cs index 73b9e1aa80b52..1d956fe52a09a 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaConnectUntrusted.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaConnectUntrusted.cs @@ -10,7 +10,12 @@ internal static partial class Interop { internal static partial class SspiCli { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.SspiCli)] + internal static partial int LsaConnectUntrusted(out SafeLsaHandle LsaHandle); +#else [DllImport(Interop.Libraries.SspiCli)] internal static extern int LsaConnectUntrusted(out SafeLsaHandle LsaHandle); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaFreeReturnBuffer.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaFreeReturnBuffer.cs index 1b0349ec02d80..bda15a55eba99 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaFreeReturnBuffer.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaFreeReturnBuffer.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class SspiCli { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.SspiCli, SetLastError = true)] + internal static partial int LsaFreeReturnBuffer(IntPtr handle); +#else [DllImport(Interop.Libraries.SspiCli, SetLastError = true)] internal static extern int LsaFreeReturnBuffer(IntPtr handle); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaGetLogonSessionData.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaGetLogonSessionData.cs index f002e37cdc431..91e800168197b 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaGetLogonSessionData.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaGetLogonSessionData.cs @@ -9,7 +9,14 @@ internal static partial class Interop { internal static partial class SspiCli { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.SspiCli, SetLastError = true)] + internal static partial int LsaGetLogonSessionData( +#else [DllImport(Interop.Libraries.SspiCli, SetLastError = true)] - internal static extern int LsaGetLogonSessionData(ref LUID LogonId, out SafeLsaReturnBufferHandle ppLogonSessionData); + internal static extern int LsaGetLogonSessionData( +#endif + ref LUID LogonId, + out SafeLsaReturnBufferHandle ppLogonSessionData); } } diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaLookupAuthenticationPackage.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaLookupAuthenticationPackage.cs index 059ededf0c412..dbe9a13b52d66 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaLookupAuthenticationPackage.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaLookupAuthenticationPackage.cs @@ -9,10 +9,15 @@ internal static partial class Interop { internal static partial class SspiCli { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.SspiCli)] + internal static partial int LsaLookupAuthenticationPackage( +#else [DllImport(Libraries.SspiCli)] internal static extern int LsaLookupAuthenticationPackage( +#endif SafeLsaHandle LsaHandle, - [In] ref Advapi32.LSA_STRING PackageName, + ref Advapi32.LSA_STRING PackageName, out int AuthenticationPackage ); } diff --git a/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj b/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj index 4c9b0a3aaf9a0..8269f4ce2503b 100644 --- a/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj +++ b/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj @@ -142,6 +142,7 @@ + diff --git a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs index 4bff4c48735ca..ed3970d564282 100644 --- a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs +++ b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs @@ -128,8 +128,12 @@ public WindowsIdentity(string sUserPrincipalName) byte[] sourceName = { (byte)'C', (byte)'L', (byte)'R', (byte)0 }; TOKEN_SOURCE sourceContext; - if (!Interop.Advapi32.AllocateLocallyUniqueId(out sourceContext.SourceIdentifier)) - throw new SecurityException(new Win32Exception().Message); + unsafe + { + if (Interop.Advapi32.AllocateLocallyUniqueId(&sourceContext.SourceIdentifier) == 0) + throw new SecurityException(new Win32Exception().Message); + } + sourceContext.SourceName = new byte[TOKEN_SOURCE.TOKEN_SOURCE_LENGTH]; Buffer.BlockCopy(sourceName, 0, sourceContext.SourceName, 0, sourceName.Length); From 061e414d579f75707fd9953975a81906e154779a Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 8 Jun 2021 15:40:34 -0700 Subject: [PATCH 104/161] Use GeneratedDllImport in System.Net.Http (#53885) --- .../Interop.CoreFoundation.CFDictionary.cs | 4 +- .../OSX/Interop.CoreFoundation.CFNumber.cs | 2 +- .../OSX/Interop.CoreFoundation.CFProxy.cs | 24 ++-- .../OSX/Interop.CoreFoundation.CFUrl.cs | 4 +- .../Common/src/Interop/OSX/Interop.RunLoop.cs | 2 +- .../Windows/WinHttp/Interop.winhttp.cs | 128 ++++++++++++++++++ .../Windows/WinHttp/Interop.winhttp_types.cs | 3 +- .../src/System/Net/Http/WinInetProxyHelper.cs | 2 +- .../tests/System.IO.Pipes.Tests.csproj | 1 + .../tests/UnitTests/FakeInterop.cs | 4 +- .../NetworkAddressChange.OSX.cs | 2 +- 11 files changed, 154 insertions(+), 22 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDictionary.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDictionary.cs index eeee71bd5a2a2..466bd584f46a6 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDictionary.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFDictionary.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class CoreFoundation { - [DllImport(Libraries.CoreFoundationLibrary)] - internal static extern IntPtr CFDictionaryGetValue(SafeCFDictionaryHandle handle, IntPtr key); + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + internal static partial IntPtr CFDictionaryGetValue(SafeCFDictionaryHandle handle, IntPtr key); } } diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFNumber.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFNumber.cs index 9addf8e12ca14..d01a5499a2ba0 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFNumber.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFNumber.cs @@ -17,6 +17,6 @@ internal enum CFNumberType } [DllImport(Libraries.CoreFoundationLibrary)] - private static extern int CFNumberGetValue(IntPtr handle, CFNumberType type, out int value); + private static unsafe extern int CFNumberGetValue(IntPtr handle, CFNumberType type, int* value); } } diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFProxy.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFProxy.cs index c4d4a21fa455a..f31504146348f 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFProxy.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFProxy.cs @@ -13,23 +13,23 @@ internal static partial class Interop { internal static partial class CoreFoundation { - [DllImport(Libraries.CFNetworkLibrary)] - internal static extern SafeCFDictionaryHandle CFNetworkCopySystemProxySettings(); + [GeneratedDllImport(Libraries.CFNetworkLibrary)] + internal static partial SafeCFDictionaryHandle CFNetworkCopySystemProxySettings(); - [DllImport(Libraries.CFNetworkLibrary)] - internal static extern SafeCFArrayHandle CFNetworkCopyProxiesForURL(SafeCreateHandle url, SafeCFDictionaryHandle proxySettings); + [GeneratedDllImport(Libraries.CFNetworkLibrary)] + internal static partial SafeCFArrayHandle CFNetworkCopyProxiesForURL(SafeCreateHandle url, SafeCFDictionaryHandle proxySettings); internal delegate void CFProxyAutoConfigurationResultCallback(IntPtr client, IntPtr proxyList, IntPtr error); - [DllImport(Libraries.CFNetworkLibrary)] - internal static extern CFRunLoopSourceRef CFNetworkExecuteProxyAutoConfigurationURL( + [GeneratedDllImport(Libraries.CFNetworkLibrary)] + internal static partial CFRunLoopSourceRef CFNetworkExecuteProxyAutoConfigurationURL( IntPtr proxyAutoConfigURL, SafeCreateHandle targetURL, CFProxyAutoConfigurationResultCallback cb, ref CFStreamClientContext clientContext); - [DllImport(Libraries.CFNetworkLibrary)] - internal static extern CFRunLoopSourceRef CFNetworkExecuteProxyAutoConfigurationScript( + [GeneratedDllImport(Libraries.CFNetworkLibrary)] + internal static partial CFRunLoopSourceRef CFNetworkExecuteProxyAutoConfigurationScript( IntPtr proxyAutoConfigurationScript, SafeCreateHandle targetURL, CFProxyAutoConfigurationResultCallback cb, @@ -131,9 +131,13 @@ public int PortNumber get { IntPtr dictValue = CFDictionaryGetValue(_dictionary, kCFProxyPortNumberKey); - if (dictValue != IntPtr.Zero && CFNumberGetValue(dictValue, CFNumberType.kCFNumberIntType, out int value) > 0) + unsafe { - return value; + int value; + if (dictValue != IntPtr.Zero && CFNumberGetValue(dictValue, CFNumberType.kCFNumberIntType, &value) > 0) + { + return value; + } } return -1; } diff --git a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFUrl.cs b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFUrl.cs index 28e3d2d5b807b..96632448c113a 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFUrl.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFUrl.cs @@ -11,8 +11,8 @@ internal static partial class Interop { internal static partial class CoreFoundation { - [DllImport(Libraries.CoreFoundationLibrary)] - private static extern SafeCreateHandle CFURLCreateWithString( + [GeneratedDllImport(Libraries.CoreFoundationLibrary)] + private static partial SafeCreateHandle CFURLCreateWithString( IntPtr allocator, SafeCreateHandle str, IntPtr baseUrl); diff --git a/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs b/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs index 3d3a74cf9473c..e06862f7efe3a 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs @@ -88,6 +88,6 @@ internal static partial class RunLoop /// false if rl either is not running or is currently processing /// a source, timer, or observer. [DllImport(Interop.Libraries.CoreFoundationLibrary)] - internal static extern bool CFRunLoopIsWaiting(CFRunLoopRef rl); + internal static extern int CFRunLoopIsWaiting(CFRunLoopRef rl); } } 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 7ac85b3155bbc..882a5133140fa 100644 --- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs +++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs @@ -9,27 +9,48 @@ internal static partial class Interop { internal static partial class WinHttp { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial SafeWinHttpHandle WinHttpOpen( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] public static extern SafeWinHttpHandle WinHttpOpen( +#endif IntPtr userAgent, uint accessType, string proxyName, string proxyBypass, int flags); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpCloseHandle( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpCloseHandle( +#endif IntPtr handle); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial SafeWinHttpHandle WinHttpConnect( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] public static extern SafeWinHttpHandle WinHttpConnect( +#endif SafeWinHttpHandle sessionHandle, string serverName, ushort serverPort, uint reserved); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial SafeWinHttpHandle WinHttpOpenRequest( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] public static extern SafeWinHttpHandle WinHttpOpenRequest( +#endif SafeWinHttpHandle connectHandle, string verb, string objectName, @@ -48,17 +69,29 @@ public static extern bool WinHttpAddRequestHeaders( uint headersLength, uint modifiers); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpAddRequestHeaders( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpAddRequestHeaders( +#endif SafeWinHttpHandle requestHandle, string headers, uint headersLength, uint modifiers); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpSendRequest( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpSendRequest( +#endif SafeWinHttpHandle requestHandle, IntPtr headers, uint headersLength, @@ -67,29 +100,53 @@ public static extern bool WinHttpSendRequest( uint totalLength, IntPtr context); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpReceiveResponse( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpReceiveResponse( +#endif SafeWinHttpHandle requestHandle, IntPtr reserved); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpQueryDataAvailable( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpQueryDataAvailable( +#endif SafeWinHttpHandle requestHandle, IntPtr parameterIgnoredAndShouldBeNullForAsync); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpReadData( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpReadData( +#endif SafeWinHttpHandle requestHandle, IntPtr buffer, uint bufferSize, IntPtr parameterIgnoredAndShouldBeNullForAsync); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpQueryHeaders( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpQueryHeaders( +#endif SafeWinHttpHandle requestHandle, uint infoLevel, string name, @@ -97,9 +154,15 @@ public static extern bool WinHttpQueryHeaders( ref uint bufferLength, ref uint index); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpQueryHeaders( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpQueryHeaders( +#endif SafeWinHttpHandle requestHandle, uint infoLevel, string name, @@ -107,57 +170,99 @@ public static extern bool WinHttpQueryHeaders( ref uint bufferLength, IntPtr index); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpQueryOption( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpQueryOption( +#endif SafeWinHttpHandle handle, uint option, ref IntPtr buffer, ref uint bufferSize); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpQueryOption( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpQueryOption( +#endif SafeWinHttpHandle handle, uint option, IntPtr buffer, ref uint bufferSize); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpQueryOption( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpQueryOption( +#endif SafeWinHttpHandle handle, uint option, ref uint buffer, ref uint bufferSize); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpWriteData( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpWriteData( +#endif SafeWinHttpHandle requestHandle, IntPtr buffer, uint bufferSize, IntPtr parameterIgnoredAndShouldBeNullForAsync); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpSetOption( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpSetOption( +#endif SafeWinHttpHandle handle, uint option, ref uint optionData, uint optionLength = sizeof(uint)); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpSetOption( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpSetOption( +#endif SafeWinHttpHandle handle, uint option, IntPtr optionData, uint optionLength); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpSetCredentials( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpSetCredentials( +#endif SafeWinHttpHandle requestHandle, uint authTargets, uint authScheme, @@ -165,26 +270,44 @@ public static extern bool WinHttpSetCredentials( string password, IntPtr reserved); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpQueryAuthSchemes( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpQueryAuthSchemes( +#endif SafeWinHttpHandle requestHandle, out uint supportedSchemes, out uint firstScheme, out uint authTarget); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpSetTimeouts( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpSetTimeouts( +#endif SafeWinHttpHandle handle, int resolveTimeout, int connectTimeout, int sendTimeout, int receiveTimeout); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool WinHttpGetIEProxyConfigForCurrentUser( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WinHttpGetIEProxyConfigForCurrentUser( +#endif out WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig); [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] @@ -194,8 +317,13 @@ public static extern bool WinHttpGetProxyForUrl( ref WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions, out WINHTTP_PROXY_INFO proxyInfo); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial IntPtr WinHttpSetStatusCallback( +#else [DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr WinHttpSetStatusCallback( +#endif SafeWinHttpHandle handle, WINHTTP_STATUS_CALLBACK callback, uint notificationFlags, diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs index 1b86a14907289..86f18f625e97b 100644 --- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs +++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs @@ -258,8 +258,7 @@ public struct WINHTTP_AUTOPROXY_OPTIONS [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WINHTTP_CURRENT_USER_IE_PROXY_CONFIG { - [MarshalAs(UnmanagedType.Bool)] - public bool AutoDetect; + public int AutoDetect; public IntPtr AutoConfigUrl; public IntPtr Proxy; public IntPtr ProxyBypass; diff --git a/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs b/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs index 1e623f7a7df0f..08690085deb98 100644 --- a/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs +++ b/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs @@ -28,7 +28,7 @@ public WinInetProxyHelper() if (Interop.WinHttp.WinHttpGetIEProxyConfigForCurrentUser(out proxyConfig)) { _autoConfigUrl = Marshal.PtrToStringUni(proxyConfig.AutoConfigUrl)!; - _autoDetect = proxyConfig.AutoDetect; + _autoDetect = proxyConfig.AutoDetect != 0; _proxy = Marshal.PtrToStringUni(proxyConfig.Proxy)!; _proxyBypass = Marshal.PtrToStringUni(proxyConfig.ProxyBypass)!; diff --git a/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj b/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj index b639953aff844..52ce3056b534d 100644 --- a/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj +++ b/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj @@ -4,6 +4,7 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent) true + true diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/FakeInterop.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/FakeInterop.cs index e26f1976418d6..eff52860f70ff 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/FakeInterop.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/FakeInterop.cs @@ -614,7 +614,7 @@ public static bool WinHttpGetIEProxyConfigForCurrentUser( { if (FakeRegistry.WinInetProxySettings.RegistryKeyMissing) { - proxyConfig.AutoDetect = false; + proxyConfig.AutoDetect = 0; proxyConfig.AutoConfigUrl = IntPtr.Zero; proxyConfig.Proxy = IntPtr.Zero; proxyConfig.ProxyBypass = IntPtr.Zero; @@ -623,7 +623,7 @@ public static bool WinHttpGetIEProxyConfigForCurrentUser( return false; } - proxyConfig.AutoDetect = FakeRegistry.WinInetProxySettings.AutoDetect; + proxyConfig.AutoDetect = FakeRegistry.WinInetProxySettings.AutoDetect ? 1 : 0; proxyConfig.AutoConfigUrl = Marshal.StringToHGlobalUni(FakeRegistry.WinInetProxySettings.AutoConfigUrl); proxyConfig.Proxy = Marshal.StringToHGlobalUni(FakeRegistry.WinInetProxySettings.Proxy); proxyConfig.ProxyBypass = Marshal.StringToHGlobalUni(FakeRegistry.WinInetProxySettings.ProxyBypass); diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs index b7c14cad78dae..353ff91d40c2b 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs @@ -222,7 +222,7 @@ private static void StopRunLoop() Debug.Assert(s_dynamicStoreRef != null); // Allow RunLoop to finish current processing. - SpinWait.SpinUntil(() => Interop.RunLoop.CFRunLoopIsWaiting(s_runLoop)); + SpinWait.SpinUntil(() => Interop.RunLoop.CFRunLoopIsWaiting(s_runLoop) != 0); Interop.RunLoop.CFRunLoopStop(s_runLoop); s_runLoopEndedEvent.WaitOne(); From 9c3d860916b2fdc6efa853aab9c9f613c68a6715 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 8 Jun 2021 17:56:14 -0700 Subject: [PATCH 105/161] Use GeneratedDllImport in System.Net.HttpListener (#53904) --- .../Windows/HttpApi/Interop.HttpApi.cs | 72 +++++++++---------- .../Kernel32/Interop.LoadLibraryEx_IntPtr.cs | 4 +- .../WebSocket/Interop.WebSocketAbortHandle.cs | 4 +- .../Interop.WebSocketCompleteAction.cs | 10 +-- .../Interop.WebSocketCreateClientHandle.cs | 10 +-- .../Interop.WebSocketCreateServerHandle.cs | 10 +-- .../Interop.WebSocketEndServerHandshake.cs | 4 +- .../WebSocket/Interop.WebSocketGetAction.cs | 20 +++--- .../WebSocket/Interop.WebSocketReceive.cs | 10 +-- .../WebSocket/Interop.WebSocketSend.cs | 24 +++---- 10 files changed, 84 insertions(+), 84 deletions(-) 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 e0982d907c687..3a009066544b8 100644 --- a/src/libraries/Common/src/Interop/Windows/HttpApi/Interop.HttpApi.cs +++ b/src/libraries/Common/src/Interop/Windows/HttpApi/Interop.HttpApi.cs @@ -455,54 +455,54 @@ internal struct HTTP_BINDING_INFO } - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern uint HttpInitialize(HTTPAPI_VERSION version, uint flags, IntPtr pReserved); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static partial uint HttpInitialize(HTTPAPI_VERSION version, uint flags, IntPtr pReserved); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern uint HttpSetUrlGroupProperty(ulong urlGroupId, HTTP_SERVER_PROPERTY serverProperty, IntPtr pPropertyInfo, uint propertyInfoLength); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static partial uint HttpSetUrlGroupProperty(ulong urlGroupId, HTTP_SERVER_PROPERTY serverProperty, IntPtr pPropertyInfo, uint propertyInfoLength); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpCreateServerSession(HTTPAPI_VERSION version, ulong* serverSessionId, uint reserved); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpCreateServerSession(HTTPAPI_VERSION version, ulong* serverSessionId, uint reserved); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpCreateUrlGroup(ulong serverSessionId, ulong* urlGroupId, uint reserved); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpCreateUrlGroup(ulong serverSessionId, ulong* urlGroupId, uint reserved); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern uint HttpCloseUrlGroup(ulong urlGroupId); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static partial uint HttpCloseUrlGroup(ulong urlGroupId); - [DllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe uint HttpCreateRequestQueue(HTTPAPI_VERSION version, string pName, + [GeneratedDllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial uint HttpCreateRequestQueue(HTTPAPI_VERSION version, string pName, Interop.Kernel32.SECURITY_ATTRIBUTES* pSecurityAttributes, uint flags, out HttpRequestQueueV2Handle pReqQueueHandle); - [DllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern uint HttpAddUrlToUrlGroup(ulong urlGroupId, string pFullyQualifiedUrl, ulong context, uint pReserved); + [GeneratedDllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial uint HttpAddUrlToUrlGroup(ulong urlGroupId, string pFullyQualifiedUrl, ulong context, uint pReserved); - [DllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern uint HttpRemoveUrlFromUrlGroup(ulong urlGroupId, string pFullyQualifiedUrl, uint flags); + [GeneratedDllImport(Libraries.HttpApi, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial uint HttpRemoveUrlFromUrlGroup(ulong urlGroupId, string pFullyQualifiedUrl, uint flags); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpReceiveHttpRequest(SafeHandle requestQueueHandle, ulong requestId, uint flags, HTTP_REQUEST* pRequestBuffer, uint requestBufferLength, uint* pBytesReturned, NativeOverlapped* pOverlapped); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpReceiveHttpRequest(SafeHandle requestQueueHandle, ulong requestId, uint flags, HTTP_REQUEST* pRequestBuffer, uint requestBufferLength, uint* pBytesReturned, NativeOverlapped* pOverlapped); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpSendHttpResponse(SafeHandle requestQueueHandle, ulong requestId, uint flags, HTTP_RESPONSE* pHttpResponse, void* pCachePolicy, uint* pBytesSent, SafeLocalAllocHandle pRequestBuffer, uint requestBufferLength, NativeOverlapped* pOverlapped, void* pLogData); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpSendHttpResponse(SafeHandle requestQueueHandle, ulong requestId, uint flags, HTTP_RESPONSE* pHttpResponse, void* pCachePolicy, uint* pBytesSent, SafeLocalAllocHandle pRequestBuffer, uint requestBufferLength, NativeOverlapped* pOverlapped, void* pLogData); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpWaitForDisconnect(SafeHandle requestQueueHandle, ulong connectionId, NativeOverlapped* pOverlapped); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpWaitForDisconnect(SafeHandle requestQueueHandle, ulong connectionId, NativeOverlapped* pOverlapped); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpReceiveRequestEntityBody(SafeHandle requestQueueHandle, ulong requestId, uint flags, void* pEntityBuffer, uint entityBufferLength, out uint bytesReturned, NativeOverlapped* pOverlapped); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpReceiveRequestEntityBody(SafeHandle requestQueueHandle, ulong requestId, uint flags, void* pEntityBuffer, uint entityBufferLength, out uint bytesReturned, NativeOverlapped* pOverlapped); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpSendResponseEntityBody(SafeHandle requestQueueHandle, ulong requestId, uint flags, ushort entityChunkCount, HTTP_DATA_CHUNK* pEntityChunks, uint* pBytesSent, SafeLocalAllocHandle pRequestBuffer, uint requestBufferLength, NativeOverlapped* pOverlapped, void* pLogData); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpSendResponseEntityBody(SafeHandle requestQueueHandle, ulong requestId, uint flags, ushort entityChunkCount, HTTP_DATA_CHUNK* pEntityChunks, uint* pBytesSent, SafeLocalAllocHandle pRequestBuffer, uint requestBufferLength, NativeOverlapped* pOverlapped, void* pLogData); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern uint HttpCloseRequestQueue(IntPtr pReqQueueHandle); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static partial uint HttpCloseRequestQueue(IntPtr pReqQueueHandle); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern uint HttpCancelHttpRequest(SafeHandle requestQueueHandle, ulong requestId, IntPtr pOverlapped); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static partial uint HttpCancelHttpRequest(SafeHandle requestQueueHandle, ulong requestId, IntPtr pOverlapped); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern uint HttpCloseServerSession(ulong serverSessionId); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static partial uint HttpCloseServerSession(ulong serverSessionId); internal sealed class SafeLocalFreeChannelBinding : ChannelBinding { @@ -530,11 +530,11 @@ protected override bool ReleaseHandle() } } - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpReceiveClientCertificate(SafeHandle requestQueueHandle, ulong connectionId, uint flags, HTTP_SSL_CLIENT_CERT_INFO* pSslClientCertInfo, uint sslClientCertInfoSize, uint* pBytesReceived, NativeOverlapped* pOverlapped); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpReceiveClientCertificate(SafeHandle requestQueueHandle, ulong connectionId, uint flags, HTTP_SSL_CLIENT_CERT_INFO* pSslClientCertInfo, uint sslClientCertInfoSize, uint* pBytesReceived, NativeOverlapped* pOverlapped); - [DllImport(Libraries.HttpApi, SetLastError = true)] - internal static extern unsafe uint HttpReceiveClientCertificate(SafeHandle requestQueueHandle, ulong connectionId, uint flags, byte* pSslClientCertInfo, uint sslClientCertInfoSize, uint* pBytesReceived, NativeOverlapped* pOverlapped); + [GeneratedDllImport(Libraries.HttpApi, SetLastError = true)] + internal static unsafe partial uint HttpReceiveClientCertificate(SafeHandle requestQueueHandle, ulong connectionId, uint flags, byte* pSslClientCertInfo, uint sslClientCertInfoSize, uint* pBytesReceived, NativeOverlapped* pOverlapped); internal static readonly string?[] HttpVerbs = new string?[] { 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 f5fdb6ca97fa6..92e78b85ac044 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; - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "LoadLibraryExW", SetLastError = true, ExactSpelling = true)] - internal static extern IntPtr LoadLibraryEx(string libFilename, IntPtr reserved, int flags); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "LoadLibraryExW", SetLastError = true, ExactSpelling = true)] + internal static partial IntPtr LoadLibraryEx(string libFilename, IntPtr reserved, int flags); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketAbortHandle.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketAbortHandle.cs index eadda76c81cbe..9d771af4bcac1 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketAbortHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketAbortHandle.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket)] - internal static extern void WebSocketAbortHandle([In] SafeHandle webSocketHandle); + [GeneratedDllImport(Libraries.WebSocket)] + internal static partial void WebSocketAbortHandle(SafeHandle webSocketHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCompleteAction.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCompleteAction.cs index b082e8d1a1540..c79f0292000db 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCompleteAction.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCompleteAction.cs @@ -9,10 +9,10 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket)] - internal static extern void WebSocketCompleteAction( - [In] SafeHandle webSocketHandle, - [In] IntPtr actionContext, - [In] uint bytesTransferred); + [GeneratedDllImport(Libraries.WebSocket)] + internal static partial void WebSocketCompleteAction( + SafeHandle webSocketHandle, + IntPtr actionContext, + uint bytesTransferred); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateClientHandle.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateClientHandle.cs index 6aeb2d1455228..dac7cc8202004 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateClientHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateClientHandle.cs @@ -10,10 +10,10 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket)] - internal static extern int WebSocketCreateClientHandle( - [In] Property[] properties, - [In] uint propertyCount, - [Out] out SafeWebSocketHandle webSocketHandle); + [GeneratedDllImport(Libraries.WebSocket)] + internal static partial int WebSocketCreateClientHandle( + Property[] properties, + uint propertyCount, + out SafeWebSocketHandle webSocketHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateServerHandle.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateServerHandle.cs index 672336c11fa8c..c90142692877a 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateServerHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketCreateServerHandle.cs @@ -9,10 +9,10 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket)] - internal static extern int WebSocketCreateServerHandle( - [In]Property[] properties, - [In] uint propertyCount, - [Out] out SafeWebSocketHandle webSocketHandle); + [GeneratedDllImport(Libraries.WebSocket)] + internal static partial int WebSocketCreateServerHandle( + Property[] properties, + uint propertyCount, + out SafeWebSocketHandle webSocketHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketEndServerHandshake.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketEndServerHandshake.cs index f56255fbb2322..8be9ebe0fdcaa 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketEndServerHandshake.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketEndServerHandshake.cs @@ -11,7 +11,7 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket)] - internal static extern int WebSocketEndServerHandshake([In] SafeHandle webSocketHandle); + [GeneratedDllImport(Libraries.WebSocket)] + internal static partial int WebSocketEndServerHandshake(SafeHandle webSocketHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketGetAction.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketGetAction.cs index 7cacdd4270670..567705db9f0ca 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketGetAction.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketGetAction.cs @@ -10,15 +10,15 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket)] - internal static extern int WebSocketGetAction( - [In] SafeHandle webSocketHandle, - [In] ActionQueue actionQueue, - [In, Out] Buffer[] dataBuffers, - [In, Out] ref uint dataBufferCount, - [Out] out System.Net.WebSockets.WebSocketProtocolComponent.Action action, - [Out] out BufferType bufferType, - [Out] out IntPtr applicationContext, - [Out] out IntPtr actionContext); + [GeneratedDllImport(Libraries.WebSocket)] + internal static partial int WebSocketGetAction( + SafeHandle webSocketHandle, + ActionQueue actionQueue, + Buffer[] dataBuffers, + ref uint dataBufferCount, + out System.Net.WebSockets.WebSocketProtocolComponent.Action action, + out BufferType bufferType, + out IntPtr applicationContext, + out IntPtr actionContext); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketReceive.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketReceive.cs index 41b917b76701c..3d40348d7fa7e 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketReceive.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketReceive.cs @@ -9,10 +9,10 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket)] - internal static extern int WebSocketReceive( - [In] SafeHandle webSocketHandle, - [In] IntPtr buffers, - [In] IntPtr applicationContext); + [GeneratedDllImport(Libraries.WebSocket)] + internal static partial int WebSocketReceive( + SafeHandle webSocketHandle, + IntPtr buffers, + IntPtr applicationContext); } } diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketSend.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketSend.cs index 993709ec19c8e..2a6c8fd653897 100644 --- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketSend.cs +++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.WebSocketSend.cs @@ -10,18 +10,18 @@ internal static partial class Interop { internal static partial class WebSocket { - [DllImport(Libraries.WebSocket, EntryPoint = "WebSocketSend", ExactSpelling = true)] - internal static extern int WebSocketSend_Raw( - [In] SafeHandle webSocketHandle, - [In] BufferType bufferType, - [In] ref Buffer buffer, - [In] IntPtr applicationContext); + [GeneratedDllImport(Libraries.WebSocket, EntryPoint = "WebSocketSend", ExactSpelling = true)] + internal static partial int WebSocketSend_Raw( + SafeHandle webSocketHandle, + BufferType bufferType, + ref Buffer buffer, + IntPtr applicationContext); - [DllImport(Libraries.WebSocket, EntryPoint = "WebSocketSend", ExactSpelling = true)] - internal static extern int WebSocketSendWithoutBody_Raw( - [In] SafeHandle webSocketHandle, - [In] BufferType bufferType, - [In] IntPtr buffer, - [In] IntPtr applicationContext); + [GeneratedDllImport(Libraries.WebSocket, EntryPoint = "WebSocketSend", ExactSpelling = true)] + internal static partial int WebSocketSendWithoutBody_Raw( + SafeHandle webSocketHandle, + BufferType bufferType, + IntPtr buffer, + IntPtr applicationContext); } } From a3d954faa056a68deb7620ca99a28514d400337e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 9 Jun 2021 10:41:29 -0700 Subject: [PATCH 106/161] Implement collection marshaller spec (dotnet/runtimelab#1197) Commit migrated from https://github.com/dotnet/runtimelab/commit/b3a0ead76a03a92af3b87dd5486563728fb5ecf8 --- .../DllImportGenerator/SpanMarshallers.md | 2 + .../ManualTypeMarshallingAnalyzer.cs | 4 +- ...ollectionElementMarshallingCodeContext.cs} | 40 +- .../gen/DllImportGenerator/DllImportStub.cs | 7 +- .../ManualTypeMarshallingHelper.cs | 83 +- .../Marshalling/ArrayMarshaller.cs | 141 +++ .../Marshalling/BlittableArrayMarshaller.cs | 313 ------ .../Marshalling/CustomNativeTypeMarshaller.cs | 272 ----- .../CustomNativeTypeMarshallingGenerator.cs | 88 ++ .../ICustomNativeTypeMarshallingStrategy.cs | 985 ++++++++++++++++++ .../Marshalling/MarshallerHelpers.cs | 22 +- .../Marshalling/MarshallingGenerator.cs | 191 ++-- .../NonBlittableArrayMarshaller.cs | 317 ------ .../PinnableManagedValueMarshaller.cs | 84 ++ .../Marshalling/SafeHandleMarshaller.cs | 3 +- .../Marshalling/StringMarshaller.Ansi.cs | 2 +- .../Marshalling/StringMarshaller.Utf16.cs | 2 +- .../MarshallingAttributeInfo.cs | 667 +++++++++++- .../DllImportGenerator/Resources.Designer.cs | 2 +- .../gen/DllImportGenerator/Resources.resx | 2 +- .../DllImportGenerator/StubCodeGenerator.cs | 21 +- .../gen/DllImportGenerator/TypeNames.cs | 12 +- .../DllImportGenerator/TypePositionInfo.cs | 259 +---- .../TypeSymbolExtensions.cs | 14 +- .../Ancillary.Interop/ArrayMarshaller.cs | 217 ++++ .../GeneratedMarshallingAttribute.cs | 34 +- .../CollectionTests.cs | 161 +++ .../CodeSnippets.cs | 257 ++++- .../CompileFails.cs | 28 +- .../DllImportGenerator.UnitTests/Compiles.cs | 128 ++- .../TestAssets/SharedTypes/NonBlittable.cs | 112 ++ 31 files changed, 3116 insertions(+), 1354 deletions(-) rename src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/{ArrayMarshallingCodeContext.cs => ContiguousCollectionElementMarshallingCodeContext.cs} (59%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshallingGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs diff --git a/docs/design/libraries/DllImportGenerator/SpanMarshallers.md b/docs/design/libraries/DllImportGenerator/SpanMarshallers.md index 4fa80be494fec..a1b3e74f672fe 100644 --- a/docs/design/libraries/DllImportGenerator/SpanMarshallers.md +++ b/docs/design/libraries/DllImportGenerator/SpanMarshallers.md @@ -94,6 +94,8 @@ A generic collection marshaller would be required to have the following shape, i [GenericContiguousCollectionMarshaller] public struct GenericContiguousCollectionMarshallerImpl { + // this constructor is required if marshalling from native to managed is supported. + public GenericContiguousCollectionMarshallerImpl(int nativeSizeOfElement); // these constructors are required if marshalling from managed to native is supported. public GenericContiguousCollectionMarshallerImpl(GenericCollection collection, int nativeSizeOfElement); public GenericContiguousCollectionMarshallerImpl(GenericCollection collection, Span stackSpace, int nativeSizeOfElement); // optional diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 97bc59387711f..965592e6522a7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -364,9 +364,9 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb continue; } - hasConstructor = hasConstructor || ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type); + hasConstructor = hasConstructor || ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type, ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard); - if (!hasStackallocConstructor && ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, SpanOfByte)) + if (!hasStackallocConstructor && ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, SpanOfByte, ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard)) { hasStackallocConstructor = true; IFieldSymbol stackAllocSizeField = nativeType.GetMembers("StackBufferSize").OfType().FirstOrDefault(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs similarity index 59% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs rename to src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs index 9e8d1ab5a2002..89c3b03590deb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ArrayMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs @@ -10,13 +10,11 @@ namespace Microsoft.Interop { - internal sealed class ArrayMarshallingCodeContext : StubCodeContext + internal sealed class ContiguousCollectionElementMarshallingCodeContext : StubCodeContext { - public const string LocalManagedIdentifierSuffix = "_local"; - private readonly string indexerIdentifier; + private readonly string nativeSpanIdentifier; private readonly StubCodeContext parentContext; - private readonly bool appendLocalManagedIdentifierSuffix; public override bool PinningSupported => false; @@ -27,34 +25,29 @@ internal sealed class ArrayMarshallingCodeContext : StubCodeContext /// can be added to the stub to track additional state for the marshaller in the stub. /// /// - /// Currently, array scenarios do not support declaring additional temporary variables to support + /// Currently, collection scenarios do not support declaring additional temporary variables to support /// marshalling. This can be accomplished in the future with some additional infrastructure to support - /// declaring arrays additional arrays in the stub to support the temporary state. + /// declaring additional arrays in the stub to support the temporary state. /// public override bool CanUseAdditionalTemporaryState => false; /// - /// Create a for marshalling elements of an array. + /// Create a for marshalling elements of an collection. /// /// The current marshalling stage. - /// The indexer in the loop to get the element to marshal from the array. + /// The indexer in the loop to get the element to marshal from the collection. + /// The identifier of the native value storage cast to the target element type. /// The parent context. - /// - /// For array marshalling, we sometimes cache the array in a local to avoid multithreading issues. - /// Set this to true to add the to the managed identifier when - /// marshalling the array elements to ensure that we use the local copy instead of the managed identifier - /// when marshalling elements. - /// - public ArrayMarshallingCodeContext( + public ContiguousCollectionElementMarshallingCodeContext( Stage currentStage, string indexerIdentifier, - StubCodeContext parentContext, - bool appendLocalManagedIdentifierSuffix) + string nativeSpanIdentifier, + StubCodeContext parentContext) { CurrentStage = currentStage; this.indexerIdentifier = indexerIdentifier; + this.nativeSpanIdentifier = nativeSpanIdentifier; this.parentContext = parentContext; - this.appendLocalManagedIdentifierSuffix = appendLocalManagedIdentifierSuffix; } /// @@ -64,12 +57,11 @@ public ArrayMarshallingCodeContext( /// Managed and native identifiers public override (string managed, string native) GetIdentifiers(TypePositionInfo info) { - var (managed, native) = parentContext.GetIdentifiers(info); - if (appendLocalManagedIdentifierSuffix) - { - managed += LocalManagedIdentifierSuffix; - } - return ($"{managed}[{indexerIdentifier}]", $"{native}[{indexerIdentifier}]"); + var (_, native) = parentContext.GetIdentifiers(info); + return ( + $"{native}.ManagedValues[{indexerIdentifier}]", + $"{nativeSpanIdentifier}[{indexerIdentifier}]" + ); } public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index cff9d7f41d83f..f74f9b2a3cff2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -157,12 +157,15 @@ public static DllImportStub Create( var defaultInfo = new DefaultMarshallingInfo(defaultEncoding); + var marshallingAttributeParser = new MarshallingAttributeInfoParser(env.Compilation, diagnostics, defaultInfo, method); + // Determine parameter and return types var paramsTypeInfo = new List(); for (int i = 0; i < method.Parameters.Length; i++) { var param = method.Parameters[i]; - var typeInfo = TypePositionInfo.CreateForParameter(param, defaultInfo, env.Compilation, diagnostics, method.ContainingType); + MarshallingInfo marshallingInfo = marshallingAttributeParser.ParseMarshallingInfo(param.Type, param.GetAttributes()); + var typeInfo = TypePositionInfo.CreateForParameter(param, marshallingInfo, env.Compilation); typeInfo = typeInfo with { ManagedIndex = i, @@ -171,7 +174,7 @@ public static DllImportStub Create( paramsTypeInfo.Add(typeInfo); } - TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, method.GetReturnTypeAttributes(), defaultInfo, env.Compilation, diagnostics, method.ContainingType); + TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, marshallingAttributeParser.ParseMarshallingInfo(method.ReturnType, method.GetReturnTypeAttributes())); retTypeInfo = retTypeInfo with { ManagedIndex = TypePositionInfo.ReturnIndex, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs index eb825f1c7a619..1d073064a39de 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs @@ -1,4 +1,5 @@ +using System; using System.Linq; using Microsoft.CodeAnalysis; @@ -11,6 +12,22 @@ static class ManualTypeMarshallingHelper public const string StackBufferSizeFieldName = "StackBufferSize"; public const string ToManagedMethodName = "ToManaged"; public const string FreeNativeMethodName = "FreeNative"; + public const string ManagedValuesPropertyName = "ManagedValues"; + public const string NativeValueStoragePropertyName = "NativeValueStorage"; + public const string SetUnmarshalledCollectionLengthMethodName = "SetUnmarshalledCollectionLength"; + + public static class MarshalUsingProperties + { + public const string ElementIndirectionLevel = nameof(ElementIndirectionLevel); + public const string CountElementName = nameof(CountElementName); + public const string ConstantElementCount = nameof(ConstantElementCount); + } + + public enum NativeTypeMarshallingVariant + { + Standard, + ContiguousCollection + } public static bool HasToManagedMethod(ITypeSymbol nativeType, ITypeSymbol managedType) { @@ -23,8 +40,17 @@ public static bool HasToManagedMethod(ITypeSymbol nativeType, ITypeSymbol manage && !m.IsStatic); } - public static bool IsManagedToNativeConstructor(IMethodSymbol ctor, ITypeSymbol managedType) + public static bool IsManagedToNativeConstructor( + IMethodSymbol ctor, + ITypeSymbol managedType, + NativeTypeMarshallingVariant variant) { + if (variant == NativeTypeMarshallingVariant.ContiguousCollection) + { + return ctor.Parameters.Length == 2 + && SymbolEqualityComparer.Default.Equals(managedType, ctor.Parameters[0].Type) + && ctor.Parameters[1].Type.SpecialType == SpecialType.System_Int32; + } return ctor.Parameters.Length == 1 && SymbolEqualityComparer.Default.Equals(managedType, ctor.Parameters[0].Type); } @@ -32,8 +58,16 @@ public static bool IsManagedToNativeConstructor(IMethodSymbol ctor, ITypeSymbol public static bool IsStackallocConstructor( IMethodSymbol ctor, ITypeSymbol managedType, - ITypeSymbol spanOfByte) + ITypeSymbol spanOfByte, + NativeTypeMarshallingVariant variant) { + if (variant == NativeTypeMarshallingVariant.ContiguousCollection) + { + return ctor.Parameters.Length == 3 + && SymbolEqualityComparer.Default.Equals(managedType, ctor.Parameters[0].Type) + && SymbolEqualityComparer.Default.Equals(spanOfByte, ctor.Parameters[1].Type) + && ctor.Parameters[2].Type.SpecialType == SpecialType.System_Int32; + } return ctor.Parameters.Length == 2 && SymbolEqualityComparer.Default.Equals(managedType, ctor.Parameters[0].Type) && SymbolEqualityComparer.Default.Equals(spanOfByte, ctor.Parameters[1].Type); @@ -62,8 +96,49 @@ public static bool HasFreeNativeMethod(ITypeSymbol type) { return type.GetMembers(FreeNativeMethodName) .OfType() - .Any(m => m is { Parameters: { Length: 0 } } and - ({ ReturnType: { SpecialType: SpecialType.System_Void } })); + .Any(m => m is { IsStatic: false, Parameters: { Length: 0 }, ReturnType: { SpecialType: SpecialType.System_Void } }); + } + + public static bool TryGetManagedValuesProperty(ITypeSymbol type, out IPropertySymbol managedValuesProperty) + { + managedValuesProperty = type + .GetMembers(ManagedValuesPropertyName) + .OfType() + .FirstOrDefault(p => p is { IsStatic: false, GetMethod: not null, ReturnsByRef: false, ReturnsByRefReadonly: false }); + return managedValuesProperty is not null; + } + + public static bool TryGetElementTypeFromContiguousCollectionMarshaller(ITypeSymbol type, out ITypeSymbol elementType) + { + if (!TryGetManagedValuesProperty(type, out IPropertySymbol managedValuesProperty)) + { + elementType = null!; + return false; + } + + elementType = ((INamedTypeSymbol)managedValuesProperty.Type).TypeArguments[0]; + return true; + } + + public static bool HasSetUnmarshalledCollectionLengthMethod(ITypeSymbol type) + { + return type.GetMembers(SetUnmarshalledCollectionLengthMethodName) + .OfType() + .Any(m => m is + { + IsStatic: false, + Parameters: { Length: 1 }, + ReturnType: { SpecialType: SpecialType.System_Void } + } && m.Parameters[0].Type.SpecialType == SpecialType.System_Int32); + } + + public static bool HasNativeValueStorageProperty(ITypeSymbol type, ITypeSymbol spanOfByte) + { + return type + .GetMembers(NativeValueStoragePropertyName) + .OfType() + .Any(p => p is {IsStatic: false, GetMethod: not null, ReturnsByRef: false, ReturnsByRefReadonly: false } + && SymbolEqualityComparer.Default.Equals(p.Type, spanOfByte)); } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs new file mode 100644 index 0000000000000..6d0f98c533c45 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs @@ -0,0 +1,141 @@ +using System.Collections.Generic; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal sealed class ArrayMarshaller : IMarshallingGenerator + { + private readonly IMarshallingGenerator manualMarshallingGenerator; + private readonly TypeSyntax elementType; + private readonly bool enablePinning; + + public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning) + { + this.manualMarshallingGenerator = manualMarshallingGenerator; + this.elementType = elementType; + this.enablePinning = enablePinning; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + if (IsPinningPathSupported(info, context)) + { + string identifier = context.GetIdentifiers(info).native; + return Argument(CastExpression(AsNativeType(info), IdentifierName(identifier))); + } + return manualMarshallingGenerator.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return manualMarshallingGenerator.AsNativeType(info); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + return manualMarshallingGenerator.AsParameter(info); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + if (IsPinningPathSupported(info, context)) + { + return GeneratePinningPath(info, context); + } + return manualMarshallingGenerator.Generate(info, context); + } + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) + { + if (context.PinningSupported && enablePinning) + { + return false; + } + return marshalKind.HasFlag(ByValueContentsMarshalKind.Out); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + if (IsPinningPathSupported(info, context)) + { + return false; + } + return manualMarshallingGenerator.UsesNativeIdentifier(info, context); + } + + private bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) + { + return context.PinningSupported && enablePinning && !info.IsByRef && !info.IsManagedReturnPosition; + } + + private IEnumerable GeneratePinningPath(TypePositionInfo info, StubCodeContext context) + { + var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); + string byRefIdentifier = $"__byref_{managedIdentifer}"; + TypeSyntax arrayElementType = elementType; + if (context.CurrentStage == StubCodeContext.Stage.Marshal) + { + // [COMPAT] We use explicit byref calculations here instead of just using a fixed statement + // since a fixed statement converts a zero-length array to a null pointer. + // Many native APIs, such as GDI+, ICU, etc. validate that an array parameter is non-null + // even when the passed in array length is zero. To avoid breaking customers that want to move + // to source-generated interop in subtle ways, we explicitly pass a reference to the 0-th element + // of an array as long as it is non-null, matching the behavior of the built-in interop system + // for single-dimensional zero-based arrays. + + // ref = == null ? ref *(); + var nullRef = + PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, + CastExpression( + PointerType(arrayElementType), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))); + + var getArrayDataReference = + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), + IdentifierName("GetArrayDataReference")), + ArgumentList(SingletonSeparatedList( + Argument(IdentifierName(managedIdentifer))))); + + yield return LocalDeclarationStatement( + VariableDeclaration( + RefType(arrayElementType)) + .WithVariables(SingletonSeparatedList( + VariableDeclarator(Identifier(byRefIdentifier)) + .WithInitializer(EqualsValueClause( + RefExpression(ParenthesizedExpression( + ConditionalExpression( + BinaryExpression( + SyntaxKind.EqualsExpression, + IdentifierName(managedIdentifer), + LiteralExpression( + SyntaxKind.NullLiteralExpression)), + RefExpression(nullRef), + RefExpression(getArrayDataReference))))))))); + } + if (context.CurrentStage == StubCodeContext.Stage.Pin) + { + // fixed ( = &Unsafe.As(ref )) + yield return FixedStatement( + VariableDeclaration(AsNativeType(info), SingletonSeparatedList( + VariableDeclarator(nativeIdentifier) + .WithInitializer(EqualsValueClause( + PrefixUnaryExpression(SyntaxKind.AddressOfExpression, + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_CompilerServices_Unsafe), + GenericName("As").AddTypeArgumentListArguments( + arrayElementType, + PredefinedType(Token(SyntaxKind.ByteKeyword))))) + .AddArgumentListArguments( + Argument(IdentifierName(byRefIdentifier)) + .WithRefKindKeyword(Token(SyntaxKind.RefKeyword)))))))), + EmptyStatement()); + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs deleted file mode 100644 index cd42a96d83245..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableArrayMarshaller.cs +++ /dev/null @@ -1,313 +0,0 @@ -using System.Collections.Generic; - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop -{ - internal class BlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator - { - /// - /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. - /// Number kept small to ensure that P/Invokes with a lot of small array parameters doesn't - /// blow the stack since this is a new optimization in the code-generated interop. - /// - private const int StackAllocBytesThreshold = 0x200; - private readonly ExpressionSyntax _numElementsExpr; - - public BlittableArrayMarshaller(ExpressionSyntax numElementsExpr) - { - _numElementsExpr = numElementsExpr; - } - - private TypeSyntax GetElementTypeSyntax(TypePositionInfo info) - { - return ((IArrayTypeSymbol)info.ManagedType).ElementType.AsTypeSyntax(); - } - - public override TypeSyntax AsNativeType(TypePositionInfo info) - { - return PointerType(GetElementTypeSyntax(info)); - } - - public override ParameterSyntax AsParameter(TypePositionInfo info) - { - var type = info.IsByRef - ? PointerType(AsNativeType(info)) - : AsNativeType(info); - return Parameter(Identifier(info.InstanceIdentifier)) - .WithType(type); - } - - public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) - { - return info.IsByRef - ? Argument( - PrefixUnaryExpression( - SyntaxKind.AddressOfExpression, - IdentifierName(context.GetIdentifiers(info).native))) - : Argument(IdentifierName(context.GetIdentifiers(info).native)); - } - - public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) - { - var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); - if (!info.IsByRef && !info.IsManagedReturnPosition && context.PinningSupported) - { - string byRefIdentifier = $"__byref_{managedIdentifer}"; - if (context.CurrentStage == StubCodeContext.Stage.Marshal) - { - // [COMPAT] We use explicit byref calculations here instead of just using a fixed statement - // since a fixed statement converts a zero-length array to a null pointer. - // Many native APIs, such as GDI+, ICU, etc. validate that an array parameter is non-null - // even when the passed in array length is zero. To avoid breaking customers that want to move - // to source-generated interop in subtle ways, we explicitly pass a reference to the 0-th element - // of an array as long as it is non-null, matching the behavior of the built-in interop system - // for single-dimensional zero-based arrays. - - // ref = == null ? ref *(); - var nullRef = - PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, - CastExpression( - PointerType(GetElementTypeSyntax(info)), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))); - - var getArrayDataReference = - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), - IdentifierName("GetArrayDataReference")), - ArgumentList(SingletonSeparatedList( - Argument(IdentifierName(managedIdentifer))))); - - yield return LocalDeclarationStatement( - VariableDeclaration( - RefType(GetElementTypeSyntax(info))) - .WithVariables(SingletonSeparatedList( - VariableDeclarator(Identifier(byRefIdentifier)) - .WithInitializer(EqualsValueClause( - RefExpression(ParenthesizedExpression( - ConditionalExpression( - BinaryExpression( - SyntaxKind.EqualsExpression, - IdentifierName(managedIdentifer), - LiteralExpression( - SyntaxKind.NullLiteralExpression)), - RefExpression(nullRef), - RefExpression(getArrayDataReference))))))))); - } - if (context.CurrentStage == StubCodeContext.Stage.Pin) - { - // fixed ( = &) - yield return FixedStatement( - VariableDeclaration(AsNativeType(info), SingletonSeparatedList( - VariableDeclarator(nativeIdentifier) - .WithInitializer(EqualsValueClause( - PrefixUnaryExpression(SyntaxKind.AddressOfExpression, - IdentifierName(byRefIdentifier)))))), - EmptyStatement()); - } - yield break; - } - - TypeSyntax spanElementTypeSyntax = GetElementTypeSyntax(info); - if (spanElementTypeSyntax is PointerTypeSyntax) - { - // Pointers cannot be passed to generics, so use IntPtr for this case. - spanElementTypeSyntax = ParseTypeName("System.IntPtr"); - } - - 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) - { - foreach (var statement in GenerateConditionalAllocationSyntax( - info, - context, - StackAllocBytesThreshold)) - { - yield return statement; - } - - // new Span(nativeIdentifier, managedIdentifier.Length) - var nativeSpan = ObjectCreationExpression( - GenericName(TypeNames.System_Span) - .WithTypeArgumentList( - TypeArgumentList( - SingletonSeparatedList(spanElementTypeSyntax)))) - .WithArgumentList( - ArgumentList( - SeparatedList( - new []{ - Argument( - CastExpression( - PointerType(spanElementTypeSyntax), - IdentifierName(nativeIdentifier))), - Argument( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifer), - IdentifierName("Length"))) - }))); - - // new Span(managedIdentifier).CopyTo(); - yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedIdentifer), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - ExpressionStatement( - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ObjectCreationExpression( - GenericName(Identifier(TypeNames.System_Span), - TypeArgumentList( - SingletonSeparatedList( - spanElementTypeSyntax)))) - .WithArgumentList( - ArgumentList(SingletonSeparatedList( - Argument(IdentifierName(managedIdentifer))))), - IdentifierName("CopyTo"))) - .WithArgumentList( - ArgumentList( - SingletonSeparatedList( - Argument(nativeSpan)))))); - } - break; - case StubCodeContext.Stage.Unmarshal: - if (info.IsManagedReturnPosition - || (info.IsByRef && info.RefKind != RefKind.In) - || info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) - { - // new Span(nativeIdentifier, managedIdentifier.Length).CopyTo(managedIdentifier); - var unmarshalContentsStatement = - ExpressionStatement( - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ObjectCreationExpression( - GenericName(Identifier(TypeNames.System_Span), - TypeArgumentList( - SingletonSeparatedList( - spanElementTypeSyntax)))) - .WithArgumentList( - ArgumentList( - SeparatedList( - new[]{ - Argument(CastExpression( - PointerType(spanElementTypeSyntax), - IdentifierName(nativeIdentifier))), - Argument( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifer), - IdentifierName("Length"))) - }))), - IdentifierName("CopyTo"))) - .WithArgumentList( - ArgumentList( - SingletonSeparatedList( - Argument(IdentifierName(managedIdentifer)))))); - - if (info.IsManagedReturnPosition || info.IsByRef) - { - yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block( - // = new []; - ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifer), - ArrayCreationExpression( - ArrayType(GetElementTypeSyntax(info), - SingletonList(ArrayRankSpecifier( - SingletonSeparatedList(_numElementsExpr))))))), - unmarshalContentsStatement), - ElseClause( - ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifer), - LiteralExpression(SyntaxKind.NullLiteralExpression))))); - } - else - { - yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedIdentifer), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - unmarshalContentsStatement); - } - - } - break; - case StubCodeContext.Stage.Cleanup: - yield return GenerateConditionalAllocationFreeSyntax(info, context); - break; - } - } - - public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) - { - return (info.IsByRef || info.IsManagedReturnPosition) || !context.PinningSupported; - } - - protected override ExpressionSyntax GenerateAllocationExpression(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, out bool allocationRequiresByteLength) - { - allocationRequiresByteLength = true; - // ()Marshal.AllocCoTaskMem() - return CastExpression(AsNativeType(info), - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), - IdentifierName("AllocCoTaskMem")), - ArgumentList(SingletonSeparatedList(Argument(IdentifierName(byteLengthIdentifier)))))); - } - - protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) - { - // checked(sizeof() * .Length) - return CheckedExpression(SyntaxKind.CheckedExpression, - BinaryExpression(SyntaxKind.MultiplyExpression, - SizeOfExpression(GetElementTypeSyntax(info)), - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(context.GetIdentifiers(info).managed), - IdentifierName("Length")))); - } - - protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) - { - return EmptyStatement(); - } - - protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info, StubCodeContext context) - { - // Marshal.FreeCoTaskMem((IntPtr)) - return InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), - IdentifierName("FreeCoTaskMem")), - ArgumentList(SingletonSeparatedList( - Argument( - CastExpression( - ParseTypeName("System.IntPtr"), - IdentifierName(context.GetIdentifiers(info).native)))))); - } - - public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) - { - return !context.PinningSupported && marshalKind.HasFlag(ByValueContentsMarshalKind.Out); - } - } - -} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs deleted file mode 100644 index f1bda542f03d0..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshaller.cs +++ /dev/null @@ -1,272 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop -{ - class CustomNativeTypeMarshaller : IMarshallingGenerator - { - private const string MarshalerLocalSuffix = "__marshaler"; - private readonly TypeSyntax _nativeTypeSyntax; - private readonly TypeSyntax _nativeLocalTypeSyntax; - private readonly SupportedMarshallingMethods _marshallingMethods; - private readonly bool _hasFreeNative; - private readonly bool _useValueProperty; - private readonly bool _marshalerTypePinnable; - - public CustomNativeTypeMarshaller(NativeMarshallingAttributeInfo marshallingInfo) - { - ITypeSymbol nativeType = marshallingInfo.ValuePropertyType ?? marshallingInfo.NativeMarshallingType; - _nativeTypeSyntax = ParseTypeName(nativeType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - _nativeLocalTypeSyntax = ParseTypeName(marshallingInfo.NativeMarshallingType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - _marshallingMethods = marshallingInfo.MarshallingMethods; - _hasFreeNative = ManualTypeMarshallingHelper.HasFreeNativeMethod(marshallingInfo.NativeMarshallingType); - _useValueProperty = marshallingInfo.ValuePropertyType != null; - _marshalerTypePinnable = marshallingInfo.NativeTypePinnable; - } - - public CustomNativeTypeMarshaller(GeneratedNativeMarshallingAttributeInfo marshallingInfo) - { - _nativeTypeSyntax = _nativeLocalTypeSyntax = ParseTypeName(marshallingInfo.NativeMarshallingFullyQualifiedTypeName); - _marshallingMethods = SupportedMarshallingMethods.ManagedToNative | SupportedMarshallingMethods.NativeToManaged; - _hasFreeNative = true; - _useValueProperty = false; - _marshalerTypePinnable = false; - } - - public TypeSyntax AsNativeType(TypePositionInfo info) - { - return _nativeTypeSyntax; - } - - public ParameterSyntax AsParameter(TypePositionInfo info) - { - var type = info.IsByRef - ? PointerType(AsNativeType(info)) - : AsNativeType(info); - return Parameter(Identifier(info.InstanceIdentifier)) - .WithType(type); - } - - public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) - { - string identifier = context.GetIdentifiers(info).native; - if (info.IsByRef) - { - return Argument( - PrefixUnaryExpression( - SyntaxKind.AddressOfExpression, - IdentifierName(identifier))); - } - - if (context.PinningSupported && (_marshallingMethods & SupportedMarshallingMethods.Pinning) != 0) - { - return Argument(CastExpression(AsNativeType(info), IdentifierName(identifier))); - } - - return Argument(IdentifierName(identifier)); - } - - public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) - { - (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); - string marshalerIdentifier = _useValueProperty ? nativeIdentifier + MarshalerLocalSuffix : nativeIdentifier; - if (!info.IsManagedReturnPosition - && !info.IsByRef - && context.PinningSupported - && (_marshallingMethods & SupportedMarshallingMethods.Pinning) != 0) - { - if (context.CurrentStage == StubCodeContext.Stage.Pin) - { - yield return FixedStatement( - VariableDeclaration( - PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))), - SingletonSeparatedList( - VariableDeclarator(Identifier(nativeIdentifier)) - .WithInitializer(EqualsValueClause( - IdentifierName(managedIdentifier) - )) - ) - ), - EmptyStatement() - ); - } - yield break; - } - - switch (context.CurrentStage) - { - case StubCodeContext.Stage.Setup: - if (_useValueProperty) - { - yield return LocalDeclarationStatement( - VariableDeclaration( - _nativeLocalTypeSyntax, - SingletonSeparatedList( - VariableDeclarator(marshalerIdentifier) - .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); - } - break; - case StubCodeContext.Stage.Marshal: - if (!info.IsManagedReturnPosition && info.RefKind != RefKind.Out) - { - // Stack space must be usable and the marshaler must support stackalloc to use stackalloc. - // We also require pinning to be supported to enable users to pass the stackalloc'd Span - // to native code by having the marshaler type return a byref to the Span's elements - // in its GetPinnableReference method. - bool scenarioSupportsStackalloc = context.StackSpaceUsable - && (_marshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0 - && context.PinningSupported; - - List arguments = new List - { - Argument(IdentifierName(managedIdentifier)) - }; - - if (scenarioSupportsStackalloc && (!info.IsByRef || info.RefKind == RefKind.In)) - { - string stackallocIdentifier = $"{managedIdentifier}__stackptr"; - // byte* __stackptr = stackalloc byte[<_nativeLocalType>.StackBufferSize]; - yield return LocalDeclarationStatement( - VariableDeclaration( - PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))), - SingletonSeparatedList( - VariableDeclarator(stackallocIdentifier) - .WithInitializer(EqualsValueClause( - StackAllocArrayCreationExpression( - ArrayType( - PredefinedType(Token(SyntaxKind.ByteKeyword)), - SingletonList(ArrayRankSpecifier(SingletonSeparatedList( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - _nativeLocalTypeSyntax, - IdentifierName(ManualTypeMarshallingHelper.StackBufferSizeFieldName)) - )))))))))); - - // new Span(__stackptr, <_nativeLocalType>.StackBufferSize) - arguments.Add(Argument( - ObjectCreationExpression( - GenericName(Identifier(TypeNames.System_Span), - TypeArgumentList(SingletonSeparatedList( - PredefinedType(Token(SyntaxKind.ByteKeyword)))))) - .WithArgumentList( - ArgumentList(SeparatedList(new ArgumentSyntax[] - { - Argument(IdentifierName(stackallocIdentifier)), - Argument(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - _nativeLocalTypeSyntax, - IdentifierName(ManualTypeMarshallingHelper.StackBufferSizeFieldName))) - }))))); - } - - // = new <_nativeLocalType>(); - yield return ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(marshalerIdentifier), - ObjectCreationExpression(_nativeLocalTypeSyntax) - .WithArgumentList(ArgumentList(SeparatedList(arguments))))); - - bool skipValueProperty = _marshalerTypePinnable && (!info.IsByRef || info.RefKind == RefKind.In); - - if (_useValueProperty && !skipValueProperty) - { - // = .Value; - yield return ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(marshalerIdentifier), - IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)))); - } - } - break; - case StubCodeContext.Stage.Pin: - if (_marshalerTypePinnable && (!info.IsByRef || info.RefKind == RefKind.In)) - { - // fixed (<_nativeTypeSyntax> = &) - yield return FixedStatement( - VariableDeclaration( - _nativeTypeSyntax, - SingletonSeparatedList( - VariableDeclarator(nativeIdentifier) - .WithInitializer(EqualsValueClause( - PrefixUnaryExpression(SyntaxKind.AddressOfExpression, - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(marshalerIdentifier), - IdentifierName(ManualTypeMarshallingHelper.GetPinnableReferenceName)), - ArgumentList())))))), - EmptyStatement()); - } - break; - case StubCodeContext.Stage.Unmarshal: - if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) - { - if (_useValueProperty) - { - // .Value = ; - yield return ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(marshalerIdentifier), - IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)), - IdentifierName(nativeIdentifier))); - } - - // = .ToManaged(); - yield return ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifier), - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(marshalerIdentifier), - IdentifierName(ManualTypeMarshallingHelper.ToManagedMethodName))))); - } - break; - case StubCodeContext.Stage.Cleanup: - if (_hasFreeNative) - { - // .FreeNative(); - yield return ExpressionStatement( - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(marshalerIdentifier), - IdentifierName(ManualTypeMarshallingHelper.FreeNativeMethodName)))); - } - break; - // TODO: Determine how to keep alive delegates that are in struct fields. - default: - break; - } - } - - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) - { - if (info.IsManagedReturnPosition || info.IsByRef && info.RefKind != RefKind.In) - { - return true; - } - if (context.PinningSupported) - { - if (!info.IsByRef && (_marshallingMethods & SupportedMarshallingMethods.Pinning) != 0) - { - return false; - } - else if (_marshalerTypePinnable) - { - return false; - } - } - return true; - } - - public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; - } -} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshallingGenerator.cs new file mode 100644 index 0000000000000..1f81e5040cf6e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshallingGenerator.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + /// + /// Implements generating code for an instance. + /// + internal sealed class CustomNativeTypeMarshallingGenerator : IMarshallingGenerator + { + private readonly ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller; + private readonly bool enableByValueContentsMarshalling; + + public CustomNativeTypeMarshallingGenerator(ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller, bool enableByValueContentsMarshalling) + { + this.nativeTypeMarshaller = nativeTypeMarshaller; + this.enableByValueContentsMarshalling = enableByValueContentsMarshalling; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return nativeTypeMarshaller.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return nativeTypeMarshaller.AsNativeType(info); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + var type = info.IsByRef + ? PointerType(AsNativeType(info)) + : AsNativeType(info); + return Parameter(Identifier(info.InstanceIdentifier)) + .WithType(type); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + // Although custom native type marshalling doesn't support [In] or [Out] by value marshalling, + // other marshallers that wrap this one might, so we handle the correct cases here. + switch (context.CurrentStage) + { + case StubCodeContext.Stage.Setup: + return nativeTypeMarshaller.GenerateSetupStatements(info, context); + case StubCodeContext.Stage.Marshal: + if (!info.IsManagedReturnPosition && info.RefKind != RefKind.Out) + { + return nativeTypeMarshaller.GenerateMarshalStatements(info, context, nativeTypeMarshaller.GetNativeTypeConstructorArguments(info, context)); + } + break; + case StubCodeContext.Stage.Pin: + if (!info.IsByRef || info.RefKind == RefKind.In) + { + return nativeTypeMarshaller.GeneratePinStatements(info, context); + } + break; + case StubCodeContext.Stage.Unmarshal: + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In) + || (enableByValueContentsMarshalling && !info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out))) + { + return nativeTypeMarshaller.GenerateUnmarshalStatements(info, context); + } + break; + case StubCodeContext.Stage.Cleanup: + return nativeTypeMarshaller.GenerateCleanupStatements(info, context); + default: + break; + } + + return Array.Empty(); + } + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) + { + return enableByValueContentsMarshalling; + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return nativeTypeMarshaller.UsesNativeIdentifier(info, context); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs new file mode 100644 index 0000000000000..283afaf60669d --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -0,0 +1,985 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + /// + /// The base interface for implementing various different aspects of the custom native type and collection marshalling specs. + /// + interface ICustomNativeTypeMarshallingStrategy + { + TypeSyntax AsNativeType(TypePositionInfo info); + + ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context); + + IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context); + + IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments); + + IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context); + + IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context); + + IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context); + + IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context); + + bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); + } + + /// + /// Marshalling support for a type that has a custom native type. + /// + internal sealed class SimpleCustomNativeTypeMarshalling : ICustomNativeTypeMarshallingStrategy + { + private readonly TypeSyntax nativeTypeSyntax; + + public SimpleCustomNativeTypeMarshalling(TypeSyntax nativeTypeSyntax) + { + this.nativeTypeSyntax = nativeTypeSyntax; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return nativeTypeSyntax; + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return true; + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + return Array.Empty(); + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + // = new(); + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(context.GetIdentifiers(info).native), + ImplicitObjectCreationExpression() + .WithArgumentList(ArgumentList(SeparatedList(nativeTypeConstructorArguments))))); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + // If the current element is being marshalled by-value [Out], then don't call the ToManaged method and do the assignment. + // The assignment will end up being a no-op and will not be observed. + if (!info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) + { + yield break; + } + + var (managedIdentifier, nativeIdentifier) = context.GetIdentifiers(info); + // = .ToManaged(); + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(managedIdentifier), + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(nativeIdentifier), + IdentifierName(ManualTypeMarshallingHelper.ToManagedMethodName))))); + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + yield return Argument(IdentifierName(context.GetIdentifiers(info).managed)); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + return Array.Empty(); + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + return Array.Empty(); + } + } + + /// + /// A context that redefines the 'native' identifier for a TypePositionInfo to be the marshaller identifier. + /// + internal class CustomNativeTypeWithValuePropertyStubContext : StubCodeContext + { + private readonly StubCodeContext parentContext; + + public CustomNativeTypeWithValuePropertyStubContext(StubCodeContext parentContext) + { + this.parentContext = parentContext; + CurrentStage = parentContext.CurrentStage; + } + + public override bool PinningSupported => parentContext.PinningSupported; + + public override bool StackSpaceUsable => parentContext.StackSpaceUsable; + + public override bool CanUseAdditionalTemporaryState => parentContext.CanUseAdditionalTemporaryState; + + public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) + { + return parentContext.GetTypePositionInfoForManagedIndex(index); + } + + public override (string managed, string native) GetIdentifiers(TypePositionInfo info) + { + return (parentContext.GetIdentifiers(info).managed, MarshallerHelpers.GetMarshallerIdentifier(info, parentContext)); + } + } + + /// + /// Marshaller that enables support of a Value property on a native type. + /// + internal sealed class CustomNativeTypeWithValuePropertyMarshalling : ICustomNativeTypeMarshallingStrategy + { + private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + private readonly TypeSyntax valuePropertyType; + + public CustomNativeTypeWithValuePropertyMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, TypeSyntax valuePropertyType) + { + this.innerMarshaller = innerMarshaller; + this.valuePropertyType = valuePropertyType; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + string identifier = context.GetIdentifiers(info).native; + if (info.IsByRef) + { + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(identifier))); + } + + return Argument(IdentifierName(identifier)); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return valuePropertyType; + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return true; + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + return innerMarshaller.GenerateCleanupStatements(info, subContext); + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) + { + yield return statement; + } + + // = .Value; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(context.GetIdentifiers(info).native), + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(subContext.GetIdentifiers(info).native), + IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)))); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + + // .Value = ; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(subContext.GetIdentifiers(info).native), + IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)), + IdentifierName(context.GetIdentifiers(info).native))); + + foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, subContext)) + { + yield return statement; + } + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + return innerMarshaller.GetNativeTypeConstructorArguments(info, subContext); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + yield return LocalDeclarationStatement( + VariableDeclaration( + innerMarshaller.AsNativeType(info), + SingletonSeparatedList( + VariableDeclarator(subContext.GetIdentifiers(info).native) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); + + foreach (var statement in innerMarshaller.GenerateSetupStatements(info, subContext)) + { + yield return statement; + } + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + return innerMarshaller.GeneratePinStatements(info, subContext); + } + } + + /// + /// Marshaller that enables support for a stackalloc constructor variant on a native type. + /// + internal sealed class StackallocOptimizationMarshalling : ICustomNativeTypeMarshallingStrategy + { + private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + + public StackallocOptimizationMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller) + { + this.innerMarshaller = innerMarshaller; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return innerMarshaller.AsNativeType(info); + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateCleanupStatements(info, context); + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + if (StackAllocOptimizationValid(info, context)) + { + // byte* __stackptr = stackalloc byte[<_nativeLocalType>.StackBufferSize]; + yield return LocalDeclarationStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))), + SingletonSeparatedList( + VariableDeclarator(GetStackAllocPointerIdentifier(info, context)) + .WithInitializer(EqualsValueClause( + StackAllocArrayCreationExpression( + ArrayType( + PredefinedType(Token(SyntaxKind.ByteKeyword)), + SingletonList(ArrayRankSpecifier(SingletonSeparatedList( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + AsNativeType(info), + IdentifierName(ManualTypeMarshallingHelper.StackBufferSizeFieldName)) + )))))))))); + } + + foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + { + yield return statement; + } + } + + private static bool StackAllocOptimizationValid(TypePositionInfo info, StubCodeContext context) + { + return context.StackSpaceUsable && context.PinningSupported && (!info.IsByRef || info.RefKind == RefKind.In); + } + + private static string GetStackAllocPointerIdentifier(TypePositionInfo info, StubCodeContext context) + { + return $"{context.GetIdentifiers(info).managed}__stackptr"; + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GeneratePinStatements(info, context); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateSetupStatements(info, context); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateUnmarshalStatements(info, context); + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + foreach (var arg in innerMarshaller.GetNativeTypeConstructorArguments(info, context)) + { + yield return arg; + } + if (StackAllocOptimizationValid(info, context)) + { + yield return Argument( + ObjectCreationExpression( + GenericName(Identifier(TypeNames.System_Span), + TypeArgumentList(SingletonSeparatedList( + PredefinedType(Token(SyntaxKind.ByteKeyword)))))) + .WithArgumentList( + ArgumentList(SeparatedList(new ArgumentSyntax[] + { + Argument(IdentifierName(GetStackAllocPointerIdentifier(info, context))), + Argument(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + AsNativeType(info), + IdentifierName(ManualTypeMarshallingHelper.StackBufferSizeFieldName))) + })))); + } + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.UsesNativeIdentifier(info, context); + } + } + + /// + /// Marshaller that enables support for a FreeNative method on a native type. + /// + internal sealed class FreeNativeCleanupStrategy : ICustomNativeTypeMarshallingStrategy + { + private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + + public FreeNativeCleanupStrategy(ICustomNativeTypeMarshallingStrategy innerMarshaller) + { + this.innerMarshaller = innerMarshaller; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return innerMarshaller.AsNativeType(info); + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, context)) + { + yield return statement; + } + + // .FreeNative(); + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(context.GetIdentifiers(info).native), + IdentifierName(ManualTypeMarshallingHelper.FreeNativeMethodName)))); + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + return innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments); + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GeneratePinStatements(info, context); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateSetupStatements(info, context); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateUnmarshalStatements(info, context); + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.UsesNativeIdentifier(info, context); + } + } + + /// + /// Marshaller that enables support for a GetPinnableReference method on a native type, with a Value property fallback. + /// + internal sealed class PinnableMarshallerTypeMarshalling : ICustomNativeTypeMarshallingStrategy + { + private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + private readonly TypeSyntax valuePropertyType; + + public PinnableMarshallerTypeMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, TypeSyntax valuePropertyType) + { + this.innerMarshaller = innerMarshaller; + this.valuePropertyType = valuePropertyType; + } + + private bool CanPinMarshaller(TypePositionInfo info, StubCodeContext context) + { + return context.PinningSupported && !info.IsManagedReturnPosition && !info.IsByRef || info.RefKind == RefKind.In; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return valuePropertyType; + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + return innerMarshaller.GenerateCleanupStatements(info, subContext); + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) + { + yield return statement; + } + + if (!CanPinMarshaller(info, context)) + { + // = .Value; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(context.GetIdentifiers(info).native), + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(subContext.GetIdentifiers(info).native), + IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)))); + } + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + // fixed (<_nativeTypeSyntax> = &) + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + yield return FixedStatement( + VariableDeclaration( + valuePropertyType, + SingletonSeparatedList( + VariableDeclarator(context.GetIdentifiers(info).native) + .WithInitializer(EqualsValueClause( + PrefixUnaryExpression(SyntaxKind.AddressOfExpression, + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(subContext.GetIdentifiers(info).native), + IdentifierName(ManualTypeMarshallingHelper.GetPinnableReferenceName)), + ArgumentList())))))), + EmptyStatement()); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + yield return LocalDeclarationStatement( + VariableDeclaration( + innerMarshaller.AsNativeType(info), + SingletonSeparatedList( + VariableDeclarator(subContext.GetIdentifiers(info).native) + .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); + + foreach (var statement in innerMarshaller.GenerateSetupStatements(info, subContext)) + { + yield return statement; + } + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + + if (!CanPinMarshaller(info, context)) + { + // .Value = ; + yield return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(subContext.GetIdentifiers(info).native), + IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)), + IdentifierName(context.GetIdentifiers(info).native))); + } + + foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, subContext)) + { + yield return statement; + } + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + if (CanPinMarshaller(info, context)) + { + return false; + } + return innerMarshaller.UsesNativeIdentifier(info, context); + } + } + + /// + /// Marshaller that enables support for native types with the constructor variants that take a sizeOfElement int parameter and that have a SetUnmarshalledCollectionLength method. + /// + internal sealed class NumElementsExpressionMarshalling : ICustomNativeTypeMarshallingStrategy + { + private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + private readonly ExpressionSyntax numElementsExpression; + private readonly ExpressionSyntax sizeOfElementExpression; + + public NumElementsExpressionMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, ExpressionSyntax numElementsExpression, ExpressionSyntax sizeOfElementExpression) + { + this.innerMarshaller = innerMarshaller; + this.numElementsExpression = numElementsExpression; + this.sizeOfElementExpression = sizeOfElementExpression; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return innerMarshaller.AsNativeType(info); + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateCleanupStatements(info, context); + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + return innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments); + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GeneratePinStatements(info, context); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateSetupStatements(info, context); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + string marshalerIdentifier = MarshallerHelpers.GetMarshallerIdentifier(info, context); + if (info.RefKind == RefKind.Out || info.IsManagedReturnPosition) + { + yield return ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(marshalerIdentifier), + ImplicitObjectCreationExpression().AddArgumentListArguments(Argument(sizeOfElementExpression)))); + } + + if (info.IsByRef || !info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) + { + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(marshalerIdentifier), + IdentifierName(ManualTypeMarshallingHelper.SetUnmarshalledCollectionLengthMethodName))) + .AddArgumentListArguments(Argument(numElementsExpression))); + } + + foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) + { + yield return statement; + } + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + foreach (var arg in innerMarshaller.GetNativeTypeConstructorArguments(info, context)) + { + yield return arg; + } + yield return Argument(sizeOfElementExpression); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.UsesNativeIdentifier(info, context); + } + } + + /// + /// Marshaller that enables support for marshalling blittable elements of a contiguous collection via a native type that implements the contiguous collection marshalling spec. + /// + internal sealed class ContiguousBlittableElementCollectionMarshalling : ICustomNativeTypeMarshallingStrategy + { + private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + private readonly TypeSyntax elementType; + + public ContiguousBlittableElementCollectionMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, TypeSyntax elementType) + { + this.innerMarshaller = innerMarshaller; + this.elementType = elementType; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return innerMarshaller.AsNativeType(info); + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateCleanupStatements(info, context); + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + string nativeIdentifier = context.GetIdentifiers(info).native; + foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + { + yield return statement; + } + + if (!info.IsByRef && info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.Out) + { + // If the parameter is marshalled by-value [Out], then we don't marshal the contents of the collection. + yield break; + } + + // .ManagedValues.CopyTo(MemoryMarshal.Cast>(.NativeValueStorage)); + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(nativeIdentifier), + IdentifierName(ManualTypeMarshallingHelper.ManagedValuesPropertyName)), + IdentifierName("CopyTo"))) + .AddArgumentListArguments( + Argument( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), + GenericName( + Identifier("Cast")) + .WithTypeArgumentList( + TypeArgumentList( + SeparatedList( + new[] + { + PredefinedType(Token(SyntaxKind.ByteKeyword)), + elementType + }))))) + .AddArgumentListArguments( + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(nativeIdentifier), + IdentifierName(ManualTypeMarshallingHelper.NativeValueStoragePropertyName))))))); + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GeneratePinStatements(info, context); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateSetupStatements(info, context); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + string nativeIdentifier = context.GetIdentifiers(info).native; + // MemoryMarshal.Cast>(.NativeValueStorage).CopyTo(.ManagedValues); + yield return ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), + GenericName( + Identifier("Cast")) + .WithTypeArgumentList( + TypeArgumentList( + SeparatedList( + new[] + { + PredefinedType(Token(SyntaxKind.ByteKeyword)), + elementType + }))))) + .AddArgumentListArguments( + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(nativeIdentifier), + IdentifierName(ManualTypeMarshallingHelper.NativeValueStoragePropertyName)))), + IdentifierName("CopyTo"))) + .AddArgumentListArguments( + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(nativeIdentifier), + IdentifierName(ManualTypeMarshallingHelper.ManagedValuesPropertyName))))); + + foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) + { + yield return statement; + } + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.UsesNativeIdentifier(info, context); + } + } + + /// + /// Marshaller that enables support for marshalling non-blittable elements of a contiguous collection via a native type that implements the contiguous collection marshalling spec. + /// + internal sealed class ContiguousNonBlittableElementCollectionMarshalling : ICustomNativeTypeMarshallingStrategy + { + private const string IndexerIdentifier = "__i"; + + private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + private readonly IMarshallingGenerator elementMarshaller; + private readonly TypePositionInfo elementInfo; + + public ContiguousNonBlittableElementCollectionMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, + IMarshallingGenerator elementMarshaller, + TypePositionInfo elementInfo) + { + this.innerMarshaller = innerMarshaller; + this.elementMarshaller = elementMarshaller; + this.elementInfo = elementInfo; + } + + private string GetNativeSpanIdentifier(TypePositionInfo info, StubCodeContext context) + { + return context.GetIdentifiers(info).managed + "__nativeSpan"; + } + + private LocalDeclarationStatementSyntax GenerateNativeSpanDeclaration(TypePositionInfo info, StubCodeContext context) + { + string nativeIdentifier = context.GetIdentifiers(info).native; + string nativeSpanIdentifier = GetNativeSpanIdentifier(info, context); + return LocalDeclarationStatement(VariableDeclaration( + GenericName( + Identifier(TypeNames.System_Span), + TypeArgumentList( + SingletonSeparatedList(elementMarshaller.AsNativeType(elementInfo).GetCompatibleGenericTypeParameterSyntax())) + ), + SingletonSeparatedList( + VariableDeclarator(Identifier(nativeSpanIdentifier)) + .WithInitializer(EqualsValueClause( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseTypeName(TypeNames.System_Runtime_InteropServices_MemoryMarshal), + GenericName( + Identifier("Cast")) + .WithTypeArgumentList( + TypeArgumentList( + SeparatedList( + new[] + { + PredefinedType(Token(SyntaxKind.ByteKeyword)), + elementMarshaller.AsNativeType(elementInfo).GetCompatibleGenericTypeParameterSyntax() + }))))) + .AddArgumentListArguments( + Argument(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(nativeIdentifier), + IdentifierName(ManualTypeMarshallingHelper.NativeValueStoragePropertyName))))))))); + } + + private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo info, StubCodeContext context, bool useManagedSpanForLength) + { + string nativeIdentifier = context.GetIdentifiers(info).native; + string nativeSpanIdentifier = GetNativeSpanIdentifier(info, context); + var elementSubContext = new ContiguousCollectionElementMarshallingCodeContext( + context.CurrentStage, + IndexerIdentifier, + nativeSpanIdentifier, + context); + + string collectionIdentifierForLength = useManagedSpanForLength + ? $"{nativeIdentifier}.{ManualTypeMarshallingHelper.ManagedValuesPropertyName}" + : nativeSpanIdentifier; + + TypePositionInfo localElementInfo = elementInfo with + { + InstanceIdentifier = info.InstanceIdentifier, + RefKind = info.IsByRef ? info.RefKind : info.ByValueContentsMarshalKind.GetRefKindForByValueContentsKind(), + ManagedIndex = info.ManagedIndex, + NativeIndex = info.NativeIndex + }; + + StatementSyntax marshallingStatement = Block( + List(elementMarshaller.Generate( + localElementInfo, + elementSubContext))); + + if (elementMarshaller.AsNativeType(elementInfo) is PointerTypeSyntax) + { + PointerNativeTypeAssignmentRewriter rewriter = new(elementSubContext.GetIdentifiers(localElementInfo).native); + marshallingStatement = (StatementSyntax)rewriter.Visit(marshallingStatement); + } + + // Iterate through the elements of the native collection to unmarshal them + return Block( + GenerateNativeSpanDeclaration(info, context), + MarshallerHelpers.GetForLoop(collectionIdentifierForLength, IndexerIdentifier) + .WithStatement(marshallingStatement)); + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return innerMarshaller.AsNativeType(info); + } + + public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) + { + yield return GenerateContentsMarshallingStatement(info, context, useManagedSpanForLength: false); + foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, context)) + { + yield return statement; + } + } + + public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) + { + foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + { + yield return statement; + } + + if (!info.IsByRef && info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.Out) + { + // If the parameter is marshalled by-value [Out], then we don't marshal the contents of the collection. + yield break; + } + + yield return GenerateContentsMarshallingStatement(info, context, useManagedSpanForLength: true); + } + + public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GeneratePinStatements(info, context); + } + + public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GenerateSetupStatements(info, context); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + yield return GenerateContentsMarshallingStatement(info, context, useManagedSpanForLength: false); + foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) + { + yield return statement; + } + } + + public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return innerMarshaller.UsesNativeIdentifier(info, context); + } + + /// + /// Rewrite assignment expressions to the native identifier to cast to IntPtr. + /// This handles the case where the native type of a non-blittable managed type is a pointer, + /// which are unsupported in generic type parameters. + /// + private class PointerNativeTypeAssignmentRewriter : CSharpSyntaxRewriter + { + private readonly string nativeIdentifier; + + public PointerNativeTypeAssignmentRewriter(string nativeIdentifier) + { + this.nativeIdentifier = nativeIdentifier; + } + + public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax node) + { + if (node.Left.ToString() == nativeIdentifier) + { + return node.WithRight( + CastExpression(MarshallerHelpers.SystemIntPtrType, node.Right)); + } + + return node; + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs index fd2b8c6200b30..e0529fe55b05b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs @@ -15,6 +15,8 @@ internal static class MarshallerHelpers public static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); + public static readonly TypeSyntax SystemIntPtrType = ParseTypeName("System.IntPtr"); + public static ForStatementSyntax GetForLoop(string collectionIdentifier, string indexerIdentifier) { // for(int = 0; < .Length; ++) @@ -73,6 +75,24 @@ public static RefKind GetRefKindForByValueContentsKind(this ByValueContentsMarsh }; } + public static TypeSyntax GetCompatibleGenericTypeParameterSyntax(this TypeSyntax type) + { + TypeSyntax spanElementTypeSyntax = type; + if (spanElementTypeSyntax is PointerTypeSyntax) + { + // Pointers cannot be passed to generics, so use IntPtr for this case. + spanElementTypeSyntax = SystemIntPtrType; + } + return spanElementTypeSyntax; + } + + private const string MarshalerLocalSuffix = "__marshaler"; + public static string GetMarshallerIdentifier(TypePositionInfo info, StubCodeContext context) + { + var (_, nativeIdentifier) = context.GetIdentifiers(info); + return nativeIdentifier + MarshalerLocalSuffix; + } + public static class StringMarshaller { public static ExpressionSyntax AllocationExpression(CharEncoding encoding, string managedIdentifier) @@ -111,7 +131,7 @@ public static ExpressionSyntax FreeExpression(string nativeIdentifier) ArgumentList(SingletonSeparatedList( Argument( CastExpression( - ParseTypeName("System.IntPtr"), + SystemIntPtrType, IdentifierName(nativeIdentifier)))))); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index c8f13da707c3f..f406e2c3e6d6a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -250,7 +250,7 @@ private static IMarshallingGenerator CreateCore( // Must go before the cases that do not explicitly check for marshalling info to support // the user overridding the default marshalling rules with a MarshalUsing attribute. case { MarshallingAttributeInfo: NativeMarshallingAttributeInfo marshalInfo }: - return CreateCustomNativeTypeMarshaller(info, context, marshalInfo); + return CreateCustomNativeTypeMarshaller(info, context, marshalInfo, options); case { MarshallingAttributeInfo: BlittableTypeAttributeInfo }: return Blittable; @@ -266,9 +266,6 @@ private static IMarshallingGenerator CreateCore( case { ManagedType: { SpecialType: SpecialType.System_String } }: return CreateStringMarshaller(info, context); - - case { ManagedType: IArrayTypeSymbol { IsSZArray: true, ElementType: ITypeSymbol elementType } }: - return CreateArrayMarshaller(info, context, options, elementType); case { ManagedType: { SpecialType: SpecialType.System_Void } }: return Forwarder; @@ -366,32 +363,36 @@ private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo inf throw new MarshallingNotSupportedException(info, context); } - private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, StubCodeContext context, AnalyzerConfigOptions options) + private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, CountInfo count, StubCodeContext context, AnalyzerConfigOptions options) { - ExpressionSyntax numElementsExpression; - if (info.MarshallingAttributeInfo is not ArrayMarshalAsInfo marshalAsInfo) + return count switch { - throw new MarshallingNotSupportedException(info, context) + SizeAndParamIndexInfo(int size, SizeAndParamIndexInfo.UnspecifiedData) => GetConstSizeExpression(size), + ConstSizeCountInfo(int size) => GetConstSizeExpression(size), + SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedData, int paramIndex) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(context.GetTypePositionInfoForManagedIndex(paramIndex))), + SizeAndParamIndexInfo(int size, int paramIndex) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, GetConstSizeExpression(size), GetExpressionForParam(context.GetTypePositionInfoForManagedIndex(paramIndex)))), + CountElementCountInfo(TypePositionInfo elementInfo) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(elementInfo)), + _ => throw new MarshallingNotSupportedException(info, context) { NotSupportedDetails = Resources.ArraySizeMustBeSpecified - }; + }, + }; + + static LiteralExpressionSyntax GetConstSizeExpression(int size) + { + return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(size)); } - LiteralExpressionSyntax? constSizeExpression = marshalAsInfo.ArraySizeConst != ArrayMarshalAsInfo.UnspecifiedData - ? LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(marshalAsInfo.ArraySizeConst)) - : null; - ExpressionSyntax? sizeParamIndexExpression = null; - if (marshalAsInfo.ArraySizeParamIndex != ArrayMarshalAsInfo.UnspecifiedData) + ExpressionSyntax GetExpressionForParam(TypePositionInfo? paramInfo) { - TypePositionInfo? paramIndexInfo = context.GetTypePositionInfoForManagedIndex(marshalAsInfo.ArraySizeParamIndex); - if (paramIndexInfo is null) + if (paramInfo is null) { throw new MarshallingNotSupportedException(info, context) { NotSupportedDetails = Resources.ArraySizeParamIndexOutOfRange }; } - else if (!paramIndexInfo.ManagedType.IsIntegralType()) + else if (!paramInfo.ManagedType.IsIntegralType()) { throw new MarshallingNotSupportedException(info, context) { @@ -400,53 +401,53 @@ private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(Type } else { - var (managed, native) = context.GetIdentifiers(paramIndexInfo); - string identifier = Create(paramIndexInfo, context, options).UsesNativeIdentifier(paramIndexInfo, context) ? native : managed; - sizeParamIndexExpression = CastExpression( + var (managed, native) = context.GetIdentifiers(paramInfo); + string identifier = Create(paramInfo, context, options).UsesNativeIdentifier(paramInfo, context) ? native : managed; + return CastExpression( PredefinedType(Token(SyntaxKind.IntKeyword)), IdentifierName(identifier)); } } - numElementsExpression = (constSizeExpression, sizeParamIndexExpression) switch - { - (null, null) => throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.ArraySizeMustBeSpecified - }, - (not null, null) => constSizeExpression!, - (null, not null) => CheckedExpression(SyntaxKind.CheckedExpression, sizeParamIndexExpression!), - (not null, not null) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, constSizeExpression!, sizeParamIndexExpression!)) - }; - return numElementsExpression; } - private static IMarshallingGenerator CreateArrayMarshaller(TypePositionInfo info, StubCodeContext context, AnalyzerConfigOptions options, ITypeSymbol elementType) + private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo, AnalyzerConfigOptions options) { - var elementMarshallingInfo = info.MarshallingAttributeInfo switch + ValidateCustomNativeTypeMarshallingSupported(info, context, marshalInfo); + + ICustomNativeTypeMarshallingStrategy marshallingStrategy = new SimpleCustomNativeTypeMarshalling(marshalInfo.NativeMarshallingType.AsTypeSyntax()); + + if ((marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0) { - ArrayMarshalAsInfo(UnmanagedType.LPArray, _) marshalAs => marshalAs.ElementMarshallingInfo, - ArrayMarshallingInfo marshalInfo => marshalInfo.ElementMarshallingInfo, - NoMarshallingInfo _ => NoMarshallingInfo.Instance, - _ => throw new MarshallingNotSupportedException(info, context) - }; + marshallingStrategy = new StackallocOptimizationMarshalling(marshallingStrategy); + } - var elementMarshaller = Create( - TypePositionInfo.CreateForType(elementType, elementMarshallingInfo), - new ArrayMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context, false), - options); - ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); - if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + if (ManualTypeMarshallingHelper.HasFreeNativeMethod(marshalInfo.NativeMarshallingType)) { - // In this case, we need a numElementsExpression supplied from metadata, so we'll calculate it here. - numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, context, options); + marshallingStrategy = new FreeNativeCleanupStrategy(marshallingStrategy); } - - return elementMarshaller == Blittable - ? new BlittableArrayMarshaller(numElementsExpression) - : new NonBlittableArrayMarshaller(elementMarshaller, numElementsExpression); + + // Collections have extra configuration, so handle them here. + if (marshalInfo is NativeContiguousCollectionMarshallingInfo collectionMarshallingInfo) + { + return CreateNativeCollectionMarshaller(info, context, collectionMarshallingInfo, options, marshallingStrategy); + } + + if (marshalInfo.ValuePropertyType is not null) + { + marshallingStrategy = DecorateWithValuePropertyStrategy(marshalInfo, marshallingStrategy); + } + + IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); + + if ((marshalInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) != 0) + { + return new PinnableManagedValueMarshaller(marshallingGenerator); + } + + return marshallingGenerator; } - private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) + private static void ValidateCustomNativeTypeMarshallingSupported(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) { if (marshalInfo.ValuePropertyType is not null && !context.CanUseAdditionalTemporaryState) { @@ -458,7 +459,7 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi // The marshalling method for this type doesn't support marshalling from native to managed, // but our scenario requires marshalling from native to managed. - if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) + if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.NativeToManaged) == 0) { throw new MarshallingNotSupportedException(info, context) @@ -471,9 +472,9 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi // Pinning is required for the stackalloc marshalling to enable users to safely pass the stackalloc Span's byref // to native if we ever start using a conditional stackalloc method and cannot guarantee that the Span we provide // the user with is backed by stack allocated memory. - else if (!info.IsByRef - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 - && !(context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) == 0) + else if (!info.IsByRef + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 + && !(context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) == 0) && !(context.StackSpaceUsable && context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) == 0)) { throw new MarshallingNotSupportedException(info, context) @@ -484,8 +485,8 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi // The marshalling method for this type doesn't support marshalling from managed to native by reference, // but our scenario requires marshalling from managed to native by reference. // "in" byref supports stack marshalling. - else if (info.RefKind == RefKind.In - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 + else if (info.RefKind == RefKind.In + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 && !(context.StackSpaceUsable && context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0)) { throw new MarshallingNotSupportedException(info, context) @@ -496,7 +497,7 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi // The marshalling method for this type doesn't support marshalling from managed to native by reference, // but our scenario requires marshalling from managed to native by reference. // "ref" byref marshalling doesn't support stack marshalling - else if (info.RefKind == RefKind.Ref + else if (info.RefKind == RefKind.Ref && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0) { throw new MarshallingNotSupportedException(info, context) @@ -504,8 +505,78 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) }; } - - return new CustomNativeTypeMarshaller(marshalInfo); + } + + private static ICustomNativeTypeMarshallingStrategy DecorateWithValuePropertyStrategy(NativeMarshallingAttributeInfo marshalInfo, ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller) + { + TypeSyntax valuePropertyTypeSyntax = marshalInfo.ValuePropertyType!.AsTypeSyntax(); + if (ManualTypeMarshallingHelper.FindGetPinnableReference(marshalInfo.NativeMarshallingType) is not null) + { + return new PinnableMarshallerTypeMarshalling(nativeTypeMarshaller, valuePropertyTypeSyntax); + } + + return new CustomNativeTypeWithValuePropertyMarshalling(nativeTypeMarshaller, valuePropertyTypeSyntax); + } + + private static IMarshallingGenerator CreateNativeCollectionMarshaller( + TypePositionInfo info, + StubCodeContext context, + NativeContiguousCollectionMarshallingInfo collectionInfo, + AnalyzerConfigOptions options, + ICustomNativeTypeMarshallingStrategy marshallingStrategy) + { + var elementInfo = TypePositionInfo.CreateForType(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo); + var elementMarshaller = Create( + elementInfo, + new ContiguousCollectionElementMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, string.Empty, context), + options); + var elementType = elementMarshaller.AsNativeType(elementInfo); + + bool isBlittable = elementMarshaller == Blittable; + + if (isBlittable) + { + marshallingStrategy = new ContiguousBlittableElementCollectionMarshalling(marshallingStrategy, collectionInfo.ElementType.AsTypeSyntax()); + } + else + { + marshallingStrategy = new ContiguousNonBlittableElementCollectionMarshalling(marshallingStrategy, elementMarshaller, elementInfo); + } + + // Explicitly insert the Value property handling here (before numElements handling) so that the numElements handling will be emitted before the Value property handling in unmarshalling. + if (collectionInfo.ValuePropertyType is not null) + { + marshallingStrategy = DecorateWithValuePropertyStrategy(collectionInfo, marshallingStrategy); + } + + ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + // In this case, we need a numElementsExpression supplied from metadata, so we'll calculate it here. + numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, collectionInfo.ElementCountInfo, context, options); + } + + marshallingStrategy = new NumElementsExpressionMarshalling( + marshallingStrategy, + numElementsExpression, + SizeOfExpression(elementType)); + + if (collectionInfo.UseDefaultMarshalling && info.ManagedType is IArrayTypeSymbol { IsSZArray: true }) + { + return new ArrayMarshaller( + new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: true), + elementType, + isBlittable); + } + + IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); + + if ((collectionInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) != 0) + { + return new PinnableManagedValueMarshaller(marshallingGenerator); + } + + return marshallingGenerator; } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs deleted file mode 100644 index 40d793c731018..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/NonBlittableArrayMarshaller.cs +++ /dev/null @@ -1,317 +0,0 @@ -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; - -namespace Microsoft.Interop -{ - internal class NonBlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator - { - /// - /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. - /// Number kept small to ensure that P/Invokes with a lot of small array parameters doesn't - /// blow the stack since this is a new optimization in the code-generated interop. - /// - private const int StackAllocBytesThreshold = 0x200; - - private const string IndexerIdentifier = "__i"; - - private readonly IMarshallingGenerator _elementMarshaller; - private readonly ExpressionSyntax _numElementsExpr; - - public NonBlittableArrayMarshaller(IMarshallingGenerator elementMarshaller, ExpressionSyntax numElementsExpr) - { - _elementMarshaller = elementMarshaller; - _numElementsExpr = numElementsExpr; - } - - private ITypeSymbol GetElementTypeSymbol(TypePositionInfo info) - { - return ((IArrayTypeSymbol)info.ManagedType).ElementType; - } - - private TypeSyntax GetNativeElementTypeSyntax(TypePositionInfo info) - { - return _elementMarshaller.AsNativeType(TypePositionInfo.CreateForType(GetElementTypeSymbol(info), NoMarshallingInfo.Instance)); - } - - public override TypeSyntax AsNativeType(TypePositionInfo info) - { - return PointerType(GetNativeElementTypeSyntax(info)); - } - - public override ParameterSyntax AsParameter(TypePositionInfo info) - { - var type = info.IsByRef - ? PointerType(AsNativeType(info)) - : AsNativeType(info); - return Parameter(Identifier(info.InstanceIdentifier)) - .WithType(type); - } - - public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) - { - return info.IsByRef - ? Argument( - PrefixUnaryExpression( - SyntaxKind.AddressOfExpression, - IdentifierName(context.GetIdentifiers(info).native))) - : Argument(IdentifierName(context.GetIdentifiers(info).native)); - } - - public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) - { - var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); - RefKind elementRefKind = info.IsByRef ? info.RefKind : info.ByValueContentsMarshalKind.GetRefKindForByValueContentsKind(); - bool cacheManagedValue = ShouldCacheManagedValue(info, context); - string managedLocal = !cacheManagedValue ? managedIdentifer : managedIdentifer + ArrayMarshallingCodeContext.LocalManagedIdentifierSuffix; - - switch (context.CurrentStage) - { - case StubCodeContext.Stage.Setup: - if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup)) - yield return conditionalAllocSetup; - - if (cacheManagedValue) - { - yield return LocalDeclarationStatement( - VariableDeclaration( - info.ManagedType.AsTypeSyntax(), - SingletonSeparatedList( - VariableDeclarator(managedLocal) - .WithInitializer(EqualsValueClause( - IdentifierName(managedIdentifer)))))); - } - break; - case StubCodeContext.Stage.Marshal: - if (info.RefKind != RefKind.Out) - { - foreach (var statement in GenerateConditionalAllocationSyntax( - info, - context, - StackAllocBytesThreshold)) - { - yield return statement; - } - - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); - - TypeSyntax spanElementTypeSyntax = GetNativeElementTypeSyntax(info); - if (spanElementTypeSyntax is PointerTypeSyntax) - { - // Pointers cannot be passed to generics, so use IntPtr for this case. - spanElementTypeSyntax = ParseTypeName("System.IntPtr"); - } - - if (info is { IsByRef: false, ByValueContentsMarshalKind: ByValueContentsMarshalKind.Out }) - { - // We don't marshal values from managed to native for [Out] by value arrays, - // we only allocate the buffer. - yield break; - } - - // Iterate through the elements of the array to marshal them - yield return IfStatement(BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedLocal), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block( - // new Span(, .Length).Clear(); - ExpressionStatement( - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ObjectCreationExpression( - GenericName(TypeNames.System_Span) - .WithTypeArgumentList( - TypeArgumentList( - SingletonSeparatedList(spanElementTypeSyntax)))) - .WithArgumentList( - ArgumentList( - SeparatedList( - new []{ - Argument( - CastExpression( - PointerType(spanElementTypeSyntax), - IdentifierName(nativeIdentifier))), - Argument( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifer), - IdentifierName("Length"))) - }))), - IdentifierName("Clear")), - ArgumentList())), - MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) - .WithStatement(Block( - List(_elementMarshaller.Generate( - info with { ManagedType = GetElementTypeSymbol(info), RefKind = elementRefKind }, - arraySubContext)))))); - } - break; - case StubCodeContext.Stage.Unmarshal: - if (info.IsManagedReturnPosition - || (info.IsByRef && info.RefKind != RefKind.In) - || info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) - { - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); - // Iterate through the elements of the native array to unmarshal them - StatementSyntax unmarshalContentsStatement = - MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) - .WithStatement(Block( - List(_elementMarshaller.Generate( - info with { ManagedType = GetElementTypeSymbol(info), RefKind = elementRefKind }, - arraySubContext)))); - - if (!info.IsByRef) - { - if (info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) - { - yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedLocal), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - unmarshalContentsStatement); - - if (cacheManagedValue) - { - yield return ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifer), - IdentifierName(managedLocal)) - ); - } - yield break; - } - } - - yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block( - // = new []; - ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedLocal), - ArrayCreationExpression( - ArrayType(GetElementTypeSymbol(info).AsTypeSyntax(), - SingletonList(ArrayRankSpecifier( - SingletonSeparatedList(_numElementsExpr))))))), - unmarshalContentsStatement - ), - ElseClause( - ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedLocal), - LiteralExpression(SyntaxKind.NullLiteralExpression))))); - - if (cacheManagedValue) - { - yield return ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(managedIdentifer), - IdentifierName(managedLocal)) - ); - } - } - break; - case StubCodeContext.Stage.Cleanup: - { - var arraySubContext = new ArrayMarshallingCodeContext(context.CurrentStage, IndexerIdentifier, context, appendLocalManagedIdentifierSuffix: cacheManagedValue); - var elementCleanup = List(_elementMarshaller.Generate(info with { ManagedType = GetElementTypeSymbol(info), RefKind = elementRefKind }, arraySubContext)); - if (elementCleanup.Count != 0) - { - // Iterate through the elements of the native array to clean up any unmanaged resources. - yield return IfStatement( - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(managedLocal), - LiteralExpression(SyntaxKind.NullLiteralExpression)), - MarshallerHelpers.GetForLoop(managedLocal, IndexerIdentifier) - .WithStatement(Block(elementCleanup))); - } - yield return GenerateConditionalAllocationFreeSyntax(info, context); - } - break; - } - } - - private static bool ShouldCacheManagedValue(TypePositionInfo info, StubCodeContext context) - { - return info.IsByRef && context.CanUseAdditionalTemporaryState; - } - - public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) - { - return true; - } - - - protected override ExpressionSyntax GenerateAllocationExpression(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, out bool allocationRequiresByteLength) - { - allocationRequiresByteLength = true; - // (*)Marshal.AllocCoTaskMem() - return CastExpression(AsNativeType(info), - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), - IdentifierName("AllocCoTaskMem")), - ArgumentList(SingletonSeparatedList(Argument(IdentifierName(byteLengthIdentifier)))))); - } - - protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context) - { - string managedIdentifier = context.GetIdentifiers(info).managed; - if (ShouldCacheManagedValue(info, context)) - { - managedIdentifier += ArrayMarshallingCodeContext.LocalManagedIdentifierSuffix; - } - // checked(sizeof() * .Length) - return CheckedExpression(SyntaxKind.CheckedExpression, - BinaryExpression(SyntaxKind.MultiplyExpression, - SizeOfExpression(GetNativeElementTypeSyntax(info)), - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(managedIdentifier), - IdentifierName("Length")))); - } - - protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(TypePositionInfo info, StubCodeContext context, SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) - { - return EmptyStatement(); - } - - protected override ExpressionSyntax GenerateFreeExpression(TypePositionInfo info, StubCodeContext context) - { - // Marshal.FreeCoTaskMem((IntPtr)) - return InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), - IdentifierName("FreeCoTaskMem")), - ArgumentList(SingletonSeparatedList( - Argument( - CastExpression( - ParseTypeName("System.IntPtr"), - IdentifierName(context.GetIdentifiers(info).native)))))); - } - - public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) - { - return marshalKind.HasFlag(ByValueContentsMarshalKind.Out); - } - - protected override ExpressionSyntax GenerateNullCheckExpression(TypePositionInfo info, StubCodeContext context) - { - string managedIdentifier = context.GetIdentifiers(info).managed; - if (ShouldCacheManagedValue(info, context)) - { - managedIdentifier += ArrayMarshallingCodeContext.LocalManagedIdentifierSuffix; - } - - return BinaryExpression( - SyntaxKind.NotEqualsExpression, - IdentifierName(managedIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)); - } - } -} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs new file mode 100644 index 0000000000000..eff8a6dfa055a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + internal sealed class PinnableManagedValueMarshaller : IMarshallingGenerator + { + private readonly IMarshallingGenerator manualMarshallingGenerator; + + public PinnableManagedValueMarshaller(IMarshallingGenerator manualMarshallingGenerator) + { + this.manualMarshallingGenerator = manualMarshallingGenerator; + } + + public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) + { + if (IsPinningPathSupported(info, context)) + { + string identifier = context.GetIdentifiers(info).native; + return Argument(CastExpression(AsNativeType(info), IdentifierName(identifier))); + } + return manualMarshallingGenerator.AsArgument(info, context); + } + + public TypeSyntax AsNativeType(TypePositionInfo info) + { + return manualMarshallingGenerator.AsNativeType(info); + } + + public ParameterSyntax AsParameter(TypePositionInfo info) + { + return manualMarshallingGenerator.AsParameter(info); + } + + public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + { + if (IsPinningPathSupported(info, context)) + { + return GeneratePinningPath(info, context); + } + return manualMarshallingGenerator.Generate(info, context); + } + + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) + { + return manualMarshallingGenerator.SupportsByValueMarshalKind(marshalKind, context); + } + + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + if (IsPinningPathSupported(info, context)) + { + return false; + } + return manualMarshallingGenerator.UsesNativeIdentifier(info, context); + } + private static bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) + { + return context.PinningSupported && !info.IsByRef && !info.IsManagedReturnPosition; + } + + private IEnumerable GeneratePinningPath(TypePositionInfo info, StubCodeContext context) + { + if (context.CurrentStage == StubCodeContext.Stage.Pin) + { + var (managedIdentifier, nativeIdentifier) = context.GetIdentifiers(info); + yield return FixedStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))), + SingletonSeparatedList( + VariableDeclarator(Identifier(nativeIdentifier)) + .WithInitializer(EqualsValueClause( + IdentifierName(managedIdentifier) + )) + ) + ), + EmptyStatement() + ); + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index 652894e056901..441d2ce758b7f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -10,7 +10,6 @@ namespace Microsoft.Interop { internal class SafeHandleMarshaller : IMarshallingGenerator { - private static readonly TypeSyntax NativeType = ParseTypeName("global::System.IntPtr"); private readonly AnalyzerConfigOptions options; public SafeHandleMarshaller(AnalyzerConfigOptions options) @@ -20,7 +19,7 @@ public SafeHandleMarshaller(AnalyzerConfigOptions options) public TypeSyntax AsNativeType(TypePositionInfo info) { - return NativeType; + return MarshallerHelpers.SystemIntPtrType; } public ParameterSyntax AsParameter(TypePositionInfo info) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs index b12dcfcd0231b..96b7c615dfc3d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs @@ -126,7 +126,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu BinaryExpression( SyntaxKind.EqualsExpression, IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), + LiteralExpression(SyntaxKind.DefaultLiteralExpression)), LiteralExpression(SyntaxKind.NullLiteralExpression), ObjectCreationExpression( PredefinedType(Token(SyntaxKind.StringKeyword)), diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs index ffe989fddd2e2..c5a50066f8f60 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -112,7 +112,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu BinaryExpression( SyntaxKind.EqualsExpression, IdentifierName(nativeIdentifier), - LiteralExpression(SyntaxKind.NullLiteralExpression)), + LiteralExpression(SyntaxKind.DefaultLiteralExpression)), LiteralExpression(SyntaxKind.NullLiteralExpression), ObjectCreationExpression( PredefinedType(Token(SyntaxKind.StringKeyword)), diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index a9c036948d56f..1590fc49f6962 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -1,13 +1,23 @@ using Microsoft.CodeAnalysis; using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; +using System.Linq; using System.Runtime.InteropServices; namespace Microsoft.Interop { + + /// + /// Type used to pass on default marshalling details. + /// + internal sealed record DefaultMarshallingInfo( + CharEncoding CharEncoding + ); + // The following types are modeled to fit with the current prospective spec - // for C# 10 discriminated unions. Once discriminated unions are released, + // for C# vNext discriminated unions. Once discriminated unions are released, // these should be updated to be implemented as a discriminated union. internal abstract record MarshallingInfo @@ -43,31 +53,12 @@ CharEncoding CharEncoding /// /// Simple User-application of System.Runtime.InteropServices.MarshalAsAttribute /// - internal record MarshalAsInfo( + internal sealed record MarshalAsInfo( UnmanagedType UnmanagedType, CharEncoding CharEncoding) : MarshallingInfoStringSupport(CharEncoding) { } - enum UnmanagedArrayType - { - LPArray = UnmanagedType.LPArray, - ByValArray = UnmanagedType.ByValArray - } - - /// - /// User-applied System.Runtime.InteropServices.MarshalAsAttribute with array marshalling info - /// - internal sealed record ArrayMarshalAsInfo( - UnmanagedArrayType UnmanagedArrayType, - int ArraySizeConst, - short ArraySizeParamIndex, - CharEncoding CharEncoding, - MarshallingInfo ElementMarshallingInfo) : MarshalAsInfo((UnmanagedType)UnmanagedArrayType, CharEncoding) - { - public const short UnspecifiedData = -1; - } - /// /// User-applied System.Runtime.InteropServices.BlittableTypeAttribute /// or System.Runtime.InteropServices.GeneratedMarshallingAttribute on a blittable type @@ -78,20 +69,46 @@ internal sealed record BlittableTypeAttributeInfo : MarshallingInfo; [Flags] internal enum SupportedMarshallingMethods { + None = 0, ManagedToNative = 0x1, NativeToManaged = 0x2, ManagedToNativeStackalloc = 0x4, Pinning = 0x8, + All = -1 + } + + internal abstract record CountInfo; + + internal sealed record NoCountInfo : CountInfo + { + public static readonly NoCountInfo Instance = new NoCountInfo(); + + private NoCountInfo() { } + } + + internal sealed record ConstSizeCountInfo(int Size) : CountInfo; + + internal sealed record CountElementCountInfo(TypePositionInfo ElementInfo) : CountInfo + { + public const string ReturnValueElementName = "return-value"; + } + + internal sealed record SizeAndParamIndexInfo(int ConstSize, int ParamIndex) : CountInfo + { + public const int UnspecifiedData = -1; + + public static readonly SizeAndParamIndexInfo Unspecified = new(UnspecifiedData, UnspecifiedData); } /// /// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute /// - internal sealed record NativeMarshallingAttributeInfo( + internal record NativeMarshallingAttributeInfo( ITypeSymbol NativeMarshallingType, ITypeSymbol? ValuePropertyType, SupportedMarshallingMethods MarshallingMethods, - bool NativeTypePinnable) : MarshallingInfo; + bool NativeTypePinnable, + bool UseDefaultMarshalling) : MarshallingInfo; /// /// User-applied System.Runtime.InteropServices.GeneratedMarshallingAttribute @@ -105,9 +122,605 @@ internal sealed record GeneratedNativeMarshallingAttributeInfo( /// internal sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor) : MarshallingInfo; - /// - /// Default marshalling for arrays - /// - internal sealed record ArrayMarshallingInfo(MarshallingInfo ElementMarshallingInfo) : MarshallingInfo; + /// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute + /// with a contiguous collection marshaller + internal sealed record NativeContiguousCollectionMarshallingInfo( + ITypeSymbol NativeMarshallingType, + ITypeSymbol? ValuePropertyType, + SupportedMarshallingMethods MarshallingMethods, + bool NativeTypePinnable, + bool UseDefaultMarshalling, + CountInfo ElementCountInfo, + ITypeSymbol ElementType, + MarshallingInfo ElementMarshallingInfo) : NativeMarshallingAttributeInfo( + NativeMarshallingType, + ValuePropertyType, + MarshallingMethods, + NativeTypePinnable, + UseDefaultMarshalling + ); + + internal class MarshallingAttributeInfoParser + { + private readonly Compilation compilation; + private readonly GeneratorDiagnostics diagnostics; + private readonly DefaultMarshallingInfo defaultInfo; + private readonly ISymbol contextSymbol; + private readonly ITypeSymbol marshalAsAttribute; + private readonly ITypeSymbol marshalUsingAttribute; + + public MarshallingAttributeInfoParser( + Compilation compilation, + GeneratorDiagnostics diagnostics, + DefaultMarshallingInfo defaultInfo, + ISymbol contextSymbol) + { + this.compilation = compilation; + this.diagnostics = diagnostics; + this.defaultInfo = defaultInfo; + this.contextSymbol = contextSymbol; + marshalAsAttribute = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute)!; + marshalUsingAttribute = compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute)!; + } + + public MarshallingInfo ParseMarshallingInfo( + ITypeSymbol managedType, + IEnumerable useSiteAttributes) + { + return ParseMarshallingInfo(managedType, useSiteAttributes, ImmutableHashSet.Empty); + } + + private MarshallingInfo ParseMarshallingInfo( + ITypeSymbol managedType, + IEnumerable useSiteAttributes, + ImmutableHashSet inspectedElements) + { + Dictionary marshallingAttributesByIndirectionLevel = new(); + int maxIndirectionLevelDataProvided = 0; + foreach (AttributeData attribute in useSiteAttributes) + { + if (TryGetAttributeIndirectionLevel(attribute, out int indirectionLevel)) + { + if (marshallingAttributesByIndirectionLevel.ContainsKey(indirectionLevel)) + { + diagnostics.ReportConfigurationNotSupported(attribute, "Marshalling Data for Indirection Level", indirectionLevel.ToString()); + return NoMarshallingInfo.Instance; + } + marshallingAttributesByIndirectionLevel.Add(indirectionLevel, attribute); + maxIndirectionLevelDataProvided = Math.Max(maxIndirectionLevelDataProvided, indirectionLevel); + } + } + + int maxIndirectionLevelUsed = 0; + MarshallingInfo info = GetMarshallingInfo( + managedType, + marshallingAttributesByIndirectionLevel, + indirectionLevel: 0, + inspectedElements, + ref maxIndirectionLevelUsed); + if (maxIndirectionLevelUsed < maxIndirectionLevelDataProvided) + { + diagnostics.ReportConfigurationNotSupported(marshallingAttributesByIndirectionLevel[maxIndirectionLevelDataProvided], ManualTypeMarshallingHelper.MarshalUsingProperties.ElementIndirectionLevel, maxIndirectionLevelDataProvided.ToString()); + } + return info; + } + + private MarshallingInfo GetMarshallingInfo( + ITypeSymbol type, + Dictionary useSiteAttributes, + int indirectionLevel, + ImmutableHashSet inspectedElements, + ref int maxIndirectionLevelUsed) + { + maxIndirectionLevelUsed = Math.Max(indirectionLevel, maxIndirectionLevelUsed); + CountInfo parsedCountInfo = NoCountInfo.Instance; + + if (useSiteAttributes.TryGetValue(indirectionLevel, out AttributeData useSiteAttribute)) + { + INamedTypeSymbol attributeClass = useSiteAttribute.AttributeClass!; + + if (indirectionLevel == 0 + && SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) + { + // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute + return CreateInfoFromMarshalAs(type, useSiteAttribute, ref maxIndirectionLevelUsed); + } + else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) + { + if (parsedCountInfo != NoCountInfo.Instance) + { + diagnostics.ReportConfigurationNotSupported(useSiteAttribute, "Duplicate Count Info"); + return NoMarshallingInfo.Instance; + } + parsedCountInfo = CreateCountInfo(useSiteAttribute, inspectedElements); + if (useSiteAttribute.ConstructorArguments.Length != 0) + { + return CreateNativeMarshallingInfo( + type, + useSiteAttribute, + isMarshalUsingAttribute: true, + indirectionLevel, + parsedCountInfo, + useSiteAttributes, + inspectedElements, + ref maxIndirectionLevelUsed); + } + } + } + + // If we aren't overriding the marshalling at usage time, + // then fall back to the information on the element type itself. + foreach (var typeAttribute in type.GetAttributes()) + { + INamedTypeSymbol attributeClass = typeAttribute.AttributeClass!; + + if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute), attributeClass)) + { + // If type is generic, then we need to re-evaluate that it is blittable at usage time. + if (type is INamedTypeSymbol { IsGenericType: false } || type.HasOnlyBlittableFields()) + { + return new BlittableTypeAttributeInfo(); + } + break; + } + else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute), attributeClass)) + { + return CreateNativeMarshallingInfo( + type, + typeAttribute, + isMarshalUsingAttribute: false, + indirectionLevel, + parsedCountInfo, + useSiteAttributes, + inspectedElements, + ref maxIndirectionLevelUsed); + } + else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute), attributeClass)) + { + return type.IsConsideredBlittable() ? new BlittableTypeAttributeInfo() : new GeneratedNativeMarshallingAttributeInfo(null! /* TODO: determine naming convention */); + } + } + + // If the type doesn't have custom attributes that dictate marshalling, + // then consider the type itself. + if (TryCreateTypeBasedMarshallingInfo( + type, + parsedCountInfo, + indirectionLevel, + useSiteAttributes, + inspectedElements, + ref maxIndirectionLevelUsed, + out MarshallingInfo infoMaybe)) + { + return infoMaybe; + } + + // No marshalling info was computed, but a character encoding was provided. + // If the type is a character or string then pass on these details. + if (defaultInfo.CharEncoding != CharEncoding.Undefined + && (type.SpecialType == SpecialType.System_Char + || type.SpecialType == SpecialType.System_String)) + { + return new MarshallingInfoStringSupport(defaultInfo.CharEncoding); + } + + return NoMarshallingInfo.Instance; + } + + CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet inspectedElements) + { + int? constSize = null; + string? elementName = null; + foreach (var arg in marshalUsingData.NamedArguments) + { + if (arg.Key == ManualTypeMarshallingHelper.MarshalUsingProperties.ConstantElementCount) + { + constSize = (int)arg.Value.Value!; + } + else if (arg.Key == ManualTypeMarshallingHelper.MarshalUsingProperties.CountElementName) + { + if (arg.Value.Value is null) + { + diagnostics.ReportConfigurationNotSupported(marshalUsingData, ManualTypeMarshallingHelper.MarshalUsingProperties.CountElementName, "null"); + return NoCountInfo.Instance; + } + elementName = (string)arg.Value.Value!; + } + } + + if (constSize is not null && elementName is not null) + { + diagnostics.ReportConfigurationNotSupported(marshalUsingData, $"{ManualTypeMarshallingHelper.MarshalUsingProperties.ConstantElementCount} and {ManualTypeMarshallingHelper.MarshalUsingProperties.CountElementName} combined"); + } + else if (constSize is not null) + { + return new ConstSizeCountInfo(constSize.Value); + } + else if (elementName is not null) + { + if (inspectedElements.Contains(elementName)) + { + diagnostics.ReportConfigurationNotSupported(marshalUsingData, $"Cyclical {ManualTypeMarshallingHelper.MarshalUsingProperties.CountElementName}"); + return NoCountInfo.Instance; + } + + TypePositionInfo? elementInfo = CreateForElementName(elementName, inspectedElements.Add(elementName)); + if (elementInfo is null) + { + diagnostics.ReportConfigurationNotSupported(marshalUsingData, ManualTypeMarshallingHelper.MarshalUsingProperties.CountElementName, elementName); + return NoCountInfo.Instance; + } + return new CountElementCountInfo(elementInfo); + } + + return NoCountInfo.Instance; + } + + private TypePositionInfo? CreateForElementName(string elementName, ImmutableHashSet inspectedElements) + { + if (contextSymbol is IMethodSymbol method) + { + if (elementName == CountElementCountInfo.ReturnValueElementName) + { + return TypePositionInfo.CreateForType( + method.ReturnType, + ParseMarshallingInfo(method.ReturnType, method.GetReturnTypeAttributes(), inspectedElements)) with + { + ManagedIndex = TypePositionInfo.ReturnIndex + }; + } + + foreach (var param in method.Parameters) + { + if (param.Name == elementName) + { + return TypePositionInfo.CreateForParameter(param, ParseMarshallingInfo(param.Type, param.GetAttributes(), inspectedElements), compilation); + } + } + } + else if (contextSymbol is INamedTypeSymbol _) + { + // TODO: Handle when we create a struct marshalling generator + // Do we want to support CountElementName pointing to only fields, or properties as well? + // If only fields, how do we handle properties with generated backing fields? + } + + return null; + } + + MarshallingInfo CreateInfoFromMarshalAs( + ITypeSymbol type, + AttributeData attrData, + ref int maxIndirectionLevelUsed) + { + object unmanagedTypeObj = attrData.ConstructorArguments[0].Value!; + UnmanagedType unmanagedType = unmanagedTypeObj is short + ? (UnmanagedType)(short)unmanagedTypeObj + : (UnmanagedType)unmanagedTypeObj; + if (!Enum.IsDefined(typeof(UnmanagedType), unmanagedType) + || unmanagedType == UnmanagedType.CustomMarshaler + || unmanagedType == UnmanagedType.SafeArray) + { + diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); + } + bool isArrayType = unmanagedType == UnmanagedType.LPArray || unmanagedType == UnmanagedType.ByValArray; + UnmanagedType elementUnmanagedType = (UnmanagedType)SizeAndParamIndexInfo.UnspecifiedData; + SizeAndParamIndexInfo arraySizeInfo = SizeAndParamIndexInfo.Unspecified; + + // All other data on attribute is defined as NamedArguments. + foreach (var namedArg in attrData.NamedArguments) + { + switch (namedArg.Key) + { + default: + Debug.Fail($"An unknown member was found on {nameof(MarshalAsAttribute)}"); + continue; + case nameof(MarshalAsAttribute.SafeArraySubType): + case nameof(MarshalAsAttribute.SafeArrayUserDefinedSubType): + case nameof(MarshalAsAttribute.IidParameterIndex): + case nameof(MarshalAsAttribute.MarshalTypeRef): + case nameof(MarshalAsAttribute.MarshalType): + case nameof(MarshalAsAttribute.MarshalCookie): + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + break; + case nameof(MarshalAsAttribute.ArraySubType): + if (!isArrayType) + { + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + } + elementUnmanagedType = (UnmanagedType)namedArg.Value.Value!; + break; + case nameof(MarshalAsAttribute.SizeConst): + if (!isArrayType) + { + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + } + arraySizeInfo = arraySizeInfo with { ConstSize = (int)namedArg.Value.Value! }; + break; + case nameof(MarshalAsAttribute.SizeParamIndex): + if (!isArrayType) + { + diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + } + arraySizeInfo = arraySizeInfo with { ParamIndex = (short)namedArg.Value.Value! }; + break; + } + } + + if (!isArrayType) + { + return new MarshalAsInfo(unmanagedType, defaultInfo.CharEncoding); + } + + if (type is not IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) + { + diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); + return NoMarshallingInfo.Instance; + } + + MarshallingInfo elementMarshallingInfo = NoMarshallingInfo.Instance; + if (elementUnmanagedType != (UnmanagedType)SizeAndParamIndexInfo.UnspecifiedData) + { + elementMarshallingInfo = new MarshalAsInfo(elementUnmanagedType, defaultInfo.CharEncoding); + } + else + { + maxIndirectionLevelUsed = 1; + elementMarshallingInfo = GetMarshallingInfo(elementType, new Dictionary(), 1, ImmutableHashSet.Empty, ref maxIndirectionLevelUsed); + } + + INamedTypeSymbol? arrayMarshaller; + + if (elementType is IPointerTypeSymbol { PointedAtType: ITypeSymbol pointedAt }) + { + arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata)?.Construct(pointedAt); + } + else + { + arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata)?.Construct(elementType); + } + + if (arrayMarshaller is null) + { + // If the array marshaler type is not available, then we cannot marshal arrays. + return NoMarshallingInfo.Instance; + } + + return new NativeContiguousCollectionMarshallingInfo( + NativeMarshallingType: arrayMarshaller, + ValuePropertyType: ManualTypeMarshallingHelper.FindValueProperty(arrayMarshaller)?.Type, + MarshallingMethods: ~SupportedMarshallingMethods.Pinning, + NativeTypePinnable: true, + UseDefaultMarshalling: true, + ElementCountInfo: arraySizeInfo, + ElementType: elementType, + ElementMarshallingInfo: elementMarshallingInfo); + } + + MarshallingInfo CreateNativeMarshallingInfo( + ITypeSymbol type, + AttributeData attrData, + bool isMarshalUsingAttribute, + int indirectionLevel, + CountInfo parsedCountInfo, + Dictionary useSiteAttributes, + ImmutableHashSet inspectedElements, + ref int maxIndirectionLevelUsed) + { + SupportedMarshallingMethods methods = SupportedMarshallingMethods.None; + + if (!isMarshalUsingAttribute && ManualTypeMarshallingHelper.FindGetPinnableReference(type) is not null) + { + methods |= SupportedMarshallingMethods.Pinning; + } + + ITypeSymbol spanOfByte = compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(compilation.GetSpecialType(SpecialType.System_Byte)); + + INamedTypeSymbol nativeType = (INamedTypeSymbol)attrData.ConstructorArguments[0].Value!; + + if (nativeType.IsUnboundGenericType) + { + if (isMarshalUsingAttribute) + { + diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + return NoMarshallingInfo.Instance; + } + else if (type is INamedTypeSymbol namedType) + { + if (namedType.Arity != nativeType.Arity) + { + diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + return NoMarshallingInfo.Instance; + } + else + { + nativeType = nativeType.ConstructedFrom.Construct(namedType.TypeArguments.ToArray()); + } + } + else + { + diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + return NoMarshallingInfo.Instance; + } + } + + ITypeSymbol contiguousCollectionMarshalerAttribute = compilation.GetTypeByMetadataName(TypeNames.GenericContiguousCollectionMarshallerAttribute)!; + + bool isContiguousCollectionMarshaller = nativeType.GetAttributes().Any(attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, contiguousCollectionMarshalerAttribute)); + IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); + + var marshallingVariant = isContiguousCollectionMarshaller + ? ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.ContiguousCollection + : ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard; + + bool hasInt32Constructor = false; + foreach (var ctor in nativeType.Constructors) + { + if (ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type, marshallingVariant) && (valueProperty is null or { GetMethod: not null })) + { + methods |= SupportedMarshallingMethods.ManagedToNative; + } + else if (ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, spanOfByte, marshallingVariant) + && (valueProperty is null or { GetMethod: not null })) + { + methods |= SupportedMarshallingMethods.ManagedToNativeStackalloc; + } + else if (ctor.Parameters.Length == 1 && ctor.Parameters[0].Type.SpecialType == SpecialType.System_Int32) + { + hasInt32Constructor = true; + } + } + + // The constructor that takes only the native element size is required for collection marshallers + // in the native-to-managed scenario. + if ((!isContiguousCollectionMarshaller + || (hasInt32Constructor && ManualTypeMarshallingHelper.HasSetUnmarshalledCollectionLengthMethod(nativeType))) + && ManualTypeMarshallingHelper.HasToManagedMethod(nativeType, type) + && (valueProperty is null or { SetMethod: not null })) + { + methods |= SupportedMarshallingMethods.NativeToManaged; + } + + if (methods == SupportedMarshallingMethods.None) + { + diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + return NoMarshallingInfo.Instance; + } + + if (isContiguousCollectionMarshaller) + { + if (!ManualTypeMarshallingHelper.HasNativeValueStorageProperty(nativeType, spanOfByte)) + { + diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + return NoMarshallingInfo.Instance; + } + + if (!ManualTypeMarshallingHelper.TryGetElementTypeFromContiguousCollectionMarshaller(nativeType, out ITypeSymbol elementType)) + { + diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + return NoMarshallingInfo.Instance; + } + + return new NativeContiguousCollectionMarshallingInfo( + nativeType, + valueProperty?.Type, + methods, + NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null, + UseDefaultMarshalling: !isMarshalUsingAttribute, + parsedCountInfo, + elementType, + GetMarshallingInfo(elementType, useSiteAttributes, indirectionLevel + 1, inspectedElements, ref maxIndirectionLevelUsed)); + } + + return new NativeMarshallingAttributeInfo( + nativeType, + valueProperty?.Type, + methods, + NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null, + UseDefaultMarshalling: !isMarshalUsingAttribute); + } + + bool TryCreateTypeBasedMarshallingInfo( + ITypeSymbol type, + CountInfo parsedCountInfo, + int indirectionLevel, + Dictionary useSiteAttributes, + ImmutableHashSet inspectedElements, + ref int maxIndirectionLevelUsed, + out MarshallingInfo marshallingInfo) + { + // Check for an implicit SafeHandle conversion. + var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); + if (conversion.Exists + && conversion.IsImplicit + && (conversion.IsReference || conversion.IsIdentity)) + { + bool hasAccessibleDefaultConstructor = false; + if (type is INamedTypeSymbol named && !named.IsAbstract && named.InstanceConstructors.Length > 0) + { + foreach (var ctor in named.InstanceConstructors) + { + if (ctor.Parameters.Length == 0) + { + hasAccessibleDefaultConstructor = compilation.IsSymbolAccessibleWithin(ctor, contextSymbol.ContainingType); + break; + } + } + } + marshallingInfo = new SafeHandleMarshallingInfo(hasAccessibleDefaultConstructor); + return true; + } + + if (type is IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) + { + INamedTypeSymbol? arrayMarshaller; + + if (elementType is IPointerTypeSymbol { PointedAtType: ITypeSymbol pointedAt }) + { + arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata)?.Construct(pointedAt); + } + else + { + arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata)?.Construct(elementType); + } + + if (arrayMarshaller is null) + { + // If the array marshaler type is not available, then we cannot marshal arrays. + marshallingInfo = NoMarshallingInfo.Instance; + return false; + } + + marshallingInfo = new NativeContiguousCollectionMarshallingInfo( + NativeMarshallingType: arrayMarshaller, + ValuePropertyType: ManualTypeMarshallingHelper.FindValueProperty(arrayMarshaller)?.Type, + MarshallingMethods: ~SupportedMarshallingMethods.Pinning, + NativeTypePinnable: true, + UseDefaultMarshalling: true, + ElementCountInfo: parsedCountInfo, + ElementType: elementType, + ElementMarshallingInfo: GetMarshallingInfo(elementType, useSiteAttributes, indirectionLevel + 1, inspectedElements, ref maxIndirectionLevelUsed)); + return true; + } + + if (type is INamedTypeSymbol { IsValueType: true } valueType + && !valueType.IsExposedOutsideOfCurrentCompilation() + && valueType.IsConsideredBlittable()) + { + // Allow implicit [BlittableType] on internal value types. + marshallingInfo = new BlittableTypeAttributeInfo(); + return true; + } + + marshallingInfo = NoMarshallingInfo.Instance; + return false; + } + + private bool TryGetAttributeIndirectionLevel(AttributeData attrData, out int indirectionLevel) + { + if (SymbolEqualityComparer.Default.Equals(attrData.AttributeClass, marshalAsAttribute)) + { + indirectionLevel = 0; + return true; + } + + if (!SymbolEqualityComparer.Default.Equals(attrData.AttributeClass, marshalUsingAttribute)) + { + indirectionLevel = 0; + return false; + } + + foreach (var arg in attrData.NamedArguments) + { + if (arg.Key == ManualTypeMarshallingHelper.MarshalUsingProperties.ElementIndirectionLevel) + { + indirectionLevel = (int)arg.Value.Value!; + return true; + } + } + indirectionLevel = 0; + return true; + } + } } 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 2acea21707cac..6e9b0ab11cb18 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Looks up a localized string similar to Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute'.. + /// Looks up a localized string similar to Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute' or the 'ConstantElementCount' or 'CountElementName' properties to be set on a 'MarshalUsingAttribute'.. /// internal static string ArraySizeMustBeSpecified { get { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 698f32820bf24..f9b39dd6a9233 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute'. + Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute' or the 'ConstantElementCount' or 'CountElementName' properties to be set on a 'MarshalUsingAttribute'. The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index dce737b7d5a71..15746deb0cbfd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -94,18 +94,25 @@ public StubCodeGenerator( public override (string managed, string native) GetIdentifiers(TypePositionInfo info) { - if (info.IsManagedReturnPosition && !info.IsNativeReturnPosition) + // If the info is in the managed return position, then we need to generate a name to use + // for both the managed and native values since there is no name in the signature for the return value. + if (info.IsManagedReturnPosition) { return (ReturnIdentifier, ReturnNativeIdentifier); } - else if (!info.IsManagedReturnPosition && info.IsNativeReturnPosition) - { + // If the info is in the native return position but is not in the managed return position, + // then that means that the stub is introducing an additional info for the return position. + // This means that there is no name in source for this info, so we must provide one here. + // We can't use ReturnIdentifier or ReturnNativeIdentifier since that will be used by the managed return value. + // Additionally, since all use cases today of a TypePositionInfo in the native position but not the managed + // are for infos that aren't in the managed signature at all (PreserveSig scenario), we don't have a name + // that we can use from source. As a result, we generate another name for the native return value + // and use the same name for native and managed. + else if (info.IsNativeReturnPosition) + { + Debug.Assert(info.ManagedIndex == TypePositionInfo.UnsetIndex); return (InvokeReturnIdentifier, InvokeReturnIdentifier); } - else if (info.IsManagedReturnPosition && info.IsNativeReturnPosition) - { - return (ReturnIdentifier, ReturnNativeIdentifier); - } else { // If the info isn't in either the managed or native return position, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 509969a052306..ad75ffadb8c5b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -17,6 +17,8 @@ static class TypeNames public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute"; + public const string GenericContiguousCollectionMarshallerAttribute = "System.Runtime.InteropServices.GenericContiguousCollectionMarshallerAttribute"; + public const string LCIDConversionAttribute = "System.Runtime.InteropServices.LCIDConversionAttribute"; public const string System_Span_Metadata = "System.Span`1"; @@ -36,7 +38,11 @@ public static string MarshalEx(AnalyzerConfigOptions options) { return options.UseMarshalType() ? System_Runtime_InteropServices_Marshal : System_Runtime_InteropServices_MarshalEx; } - + + public const string System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.ArrayMarshaller`1"; + + public const string System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.PtrArrayMarshaller`1"; + public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal"; public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; @@ -46,5 +52,9 @@ public static string MarshalEx(AnalyzerConfigOptions options) public const string System_Runtime_InteropServices_InAttribute = "System.Runtime.InteropServices.InAttribute"; public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; + + // TODO: Add configuration for using Internal.Runtime.CompilerServices.Unsafe to support + // running against System.Private.CoreLib + public const string System_Runtime_CompilerServices_Unsafe = "System.Runtime.CompilerServices.Unsafe"; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 0fc8788e1c919..0f011d9f0846a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -9,12 +7,6 @@ namespace Microsoft.Interop { - /// - /// Type used to pass on default marshalling details. - /// - internal sealed record DefaultMarshallingInfo ( - CharEncoding CharEncoding - ); /// /// Describes how to marshal the contents of a value in comparison to the value itself. @@ -82,9 +74,8 @@ private TypePositionInfo() public MarshallingInfo MarshallingAttributeInfo { get; init; } - public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) + public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, MarshallingInfo marshallingInfo, Compilation compilation) { - var marshallingInfo = GetMarshallingInfo(paramSymbol.Type, paramSymbol.GetAttributes(), defaultInfo, compilation, diagnostics, scopeSymbol); var typeInfo = new TypePositionInfo() { ManagedType = paramSymbol.Type, @@ -98,27 +89,12 @@ public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, return typeInfo; } - public static TypePositionInfo CreateForType(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) - { - var marshallingInfo = GetMarshallingInfo(type, attributes, defaultInfo, compilation, diagnostics, scopeSymbol); - var typeInfo = new TypePositionInfo() - { - ManagedType = type, - InstanceIdentifier = string.Empty, - RefKind = RefKind.None, - RefKindSyntax = SyntaxKind.None, - MarshallingAttributeInfo = marshallingInfo - }; - - return typeInfo; - } - - public static TypePositionInfo CreateForType(ITypeSymbol type, MarshallingInfo marshallingInfo) + public static TypePositionInfo CreateForType(ITypeSymbol type, MarshallingInfo marshallingInfo, string identifier = "") { var typeInfo = new TypePositionInfo() { ManagedType = type, - InstanceIdentifier = string.Empty, + InstanceIdentifier = identifier, RefKind = RefKind.None, RefKindSyntax = SyntaxKind.None, MarshallingAttributeInfo = marshallingInfo @@ -127,235 +103,6 @@ public static TypePositionInfo CreateForType(ITypeSymbol type, MarshallingInfo m return typeInfo; } - private static MarshallingInfo GetMarshallingInfo(ITypeSymbol type, IEnumerable attributes, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) - { - // Look at attributes passed in - usage specific. - foreach (var attrData in attributes) - { - INamedTypeSymbol attributeClass = attrData.AttributeClass!; - - if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) - { - // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute - return CreateMarshalAsInfo(type, attrData, defaultInfo, compilation, diagnostics, scopeSymbol); - } - else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) - { - return CreateNativeMarshallingInfo(type, compilation, attrData, allowGetPinnableReference: false); - } - } - - // If we aren't overriding the marshalling at usage time, - // then fall back to the information on the element type itself. - foreach (var attrData in type.GetAttributes()) - { - INamedTypeSymbol attributeClass = attrData.AttributeClass!; - - if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute), attributeClass)) - { - // If type is generic, then we need to re-evaluate that it is blittable at usage time. - if (type is INamedTypeSymbol { IsGenericType: false } || type.HasOnlyBlittableFields()) - { - return new BlittableTypeAttributeInfo(); - } - break; - } - else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute), attributeClass)) - { - return CreateNativeMarshallingInfo(type, compilation, attrData, allowGetPinnableReference: true); - } - else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute), attributeClass)) - { - return type.IsConsideredBlittable() ? new BlittableTypeAttributeInfo() : new GeneratedNativeMarshallingAttributeInfo(null! /* TODO: determine naming convention */); - } - } - - // If the type doesn't have custom attributes that dictate marshalling, - // then consider the type itself. - if (TryCreateTypeBasedMarshallingInfo(type, defaultInfo, compilation, diagnostics, scopeSymbol, out MarshallingInfo infoMaybe)) - { - return infoMaybe; - } - - // No marshalling info was computed, but a character encoding was provided. - // If the type is a character or string then pass on these details. - if (defaultInfo.CharEncoding != CharEncoding.Undefined - && (type.SpecialType == SpecialType.System_Char - || type.SpecialType == SpecialType.System_String)) - { - return new MarshallingInfoStringSupport(defaultInfo.CharEncoding); - } - - return NoMarshallingInfo.Instance; - - static MarshalAsInfo CreateMarshalAsInfo(ITypeSymbol type, AttributeData attrData, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol) - { - object unmanagedTypeObj = attrData.ConstructorArguments[0].Value!; - UnmanagedType unmanagedType = unmanagedTypeObj is short - ? (UnmanagedType)(short)unmanagedTypeObj - : (UnmanagedType)unmanagedTypeObj; - if (!Enum.IsDefined(typeof(UnmanagedType), unmanagedType) - || unmanagedType == UnmanagedType.CustomMarshaler - || unmanagedType == UnmanagedType.SafeArray) - { - diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); - } - bool isArrayType = unmanagedType == UnmanagedType.LPArray || unmanagedType == UnmanagedType.ByValArray; - UnmanagedType unmanagedArraySubType = (UnmanagedType)ArrayMarshalAsInfo.UnspecifiedData; - int arraySizeConst = ArrayMarshalAsInfo.UnspecifiedData; - short arraySizeParamIndex = ArrayMarshalAsInfo.UnspecifiedData; - - // All other data on attribute is defined as NamedArguments. - foreach (var namedArg in attrData.NamedArguments) - { - switch (namedArg.Key) - { - default: - Debug.Fail($"An unknown member was found on {nameof(MarshalAsAttribute)}"); - continue; - case nameof(MarshalAsAttribute.SafeArraySubType): - case nameof(MarshalAsAttribute.SafeArrayUserDefinedSubType): - case nameof(MarshalAsAttribute.IidParameterIndex): - case nameof(MarshalAsAttribute.MarshalTypeRef): - case nameof(MarshalAsAttribute.MarshalType): - case nameof(MarshalAsAttribute.MarshalCookie): - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); - break; - case nameof(MarshalAsAttribute.ArraySubType): - if (!isArrayType) - { - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); - } - unmanagedArraySubType = (UnmanagedType)namedArg.Value.Value!; - break; - case nameof(MarshalAsAttribute.SizeConst): - if (!isArrayType) - { - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); - } - arraySizeConst = (int)namedArg.Value.Value!; - break; - case nameof(MarshalAsAttribute.SizeParamIndex): - if (!isArrayType) - { - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); - } - arraySizeParamIndex = (short)namedArg.Value.Value!; - break; - } - } - - if (!isArrayType) - { - return new MarshalAsInfo(unmanagedType, defaultInfo.CharEncoding); - } - - MarshallingInfo elementMarshallingInfo = NoMarshallingInfo.Instance; - if (unmanagedArraySubType != (UnmanagedType)ArrayMarshalAsInfo.UnspecifiedData) - { - elementMarshallingInfo = new MarshalAsInfo(unmanagedArraySubType, defaultInfo.CharEncoding); - } - else if (type is IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) - { - elementMarshallingInfo = GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics, scopeSymbol); - } - - return new ArrayMarshalAsInfo( - UnmanagedArrayType: (UnmanagedArrayType)unmanagedType, - ArraySizeConst: arraySizeConst, - ArraySizeParamIndex: arraySizeParamIndex, - CharEncoding: defaultInfo.CharEncoding, - ElementMarshallingInfo: elementMarshallingInfo - ); - } - - static NativeMarshallingAttributeInfo CreateNativeMarshallingInfo(ITypeSymbol type, Compilation compilation, AttributeData attrData, bool allowGetPinnableReference) - { - ITypeSymbol spanOfByte = compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(compilation.GetSpecialType(SpecialType.System_Byte)); - INamedTypeSymbol nativeType = (INamedTypeSymbol)attrData.ConstructorArguments[0].Value!; - SupportedMarshallingMethods methods = 0; - IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); - foreach (var ctor in nativeType.Constructors) - { - if (ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type) - && (valueProperty is null or { GetMethod: not null })) - { - methods |= SupportedMarshallingMethods.ManagedToNative; - } - else if (ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, spanOfByte) - && (valueProperty is null or { GetMethod: not null })) - { - methods |= SupportedMarshallingMethods.ManagedToNativeStackalloc; - } - } - - if (ManualTypeMarshallingHelper.HasToManagedMethod(nativeType, type) - && (valueProperty is null or { SetMethod: not null })) - { - methods |= SupportedMarshallingMethods.NativeToManaged; - } - - if (allowGetPinnableReference && ManualTypeMarshallingHelper.FindGetPinnableReference(type) != null) - { - methods |= SupportedMarshallingMethods.Pinning; - } - - if (methods == 0) - { - // TODO: Diagnostic since no marshalling methods are supported. - } - - return new NativeMarshallingAttributeInfo( - nativeType, - valueProperty?.Type, - methods, - NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null); - } - - static bool TryCreateTypeBasedMarshallingInfo(ITypeSymbol type, DefaultMarshallingInfo defaultInfo, Compilation compilation, GeneratorDiagnostics diagnostics, INamedTypeSymbol scopeSymbol, out MarshallingInfo marshallingInfo) - { - // Check for an implicit SafeHandle conversion. - var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); - if (conversion.Exists - && conversion.IsImplicit - && (conversion.IsReference || conversion.IsIdentity)) - { - bool hasAccessibleDefaultConstructor = false; - if (type is INamedTypeSymbol named && !named.IsAbstract && named.InstanceConstructors.Length > 0) - { - foreach (var ctor in named.InstanceConstructors) - { - if (ctor.Parameters.Length == 0) - { - hasAccessibleDefaultConstructor = compilation.IsSymbolAccessibleWithin(ctor, scopeSymbol); - break; - } - } - } - marshallingInfo = new SafeHandleMarshallingInfo(hasAccessibleDefaultConstructor); - return true; - } - - if (type is IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) - { - marshallingInfo = new ArrayMarshallingInfo(GetMarshallingInfo(elementType, Array.Empty(), defaultInfo, compilation, diagnostics, scopeSymbol)); - return true; - } - - if (type is INamedTypeSymbol { IsValueType: true } valueType - && !valueType.IsExposedOutsideOfCurrentCompilation() - && valueType.IsConsideredBlittable()) - { - // Allow implicit [BlittableType] on internal value types. - marshallingInfo = new BlittableTypeAttributeInfo(); - return true; - } - - marshallingInfo = NoMarshallingInfo.Instance; - return false; - } - } - private static ByValueContentsMarshalKind GetByValueContentsMarshalKind(IEnumerable attributes, Compilation compilation) { INamedTypeSymbol outAttributeType = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_OutAttribute)!; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 616d87c521c2b..2cf28efc94349 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -13,9 +13,9 @@ namespace Microsoft.Interop { static class TypeSymbolExtensions { - public static bool HasOnlyBlittableFields(this ITypeSymbol type) => HasOnlyBlittableFields(type, new HashSet(SymbolEqualityComparer.Default)); + public static bool HasOnlyBlittableFields(this ITypeSymbol type) => HasOnlyBlittableFields(type, ImmutableHashSet.Create(SymbolEqualityComparer.Default)); - private static bool HasOnlyBlittableFields(this ITypeSymbol type, HashSet seenTypes) + private static bool HasOnlyBlittableFields(this ITypeSymbol type, ImmutableHashSet seenTypes) { if (seenTypes.Contains(type)) { @@ -24,7 +24,7 @@ private static bool HasOnlyBlittableFields(this ITypeSymbol type, HashSet()) { if (!field.IsStatic) @@ -39,18 +39,16 @@ private static bool HasOnlyBlittableFields(this ITypeSymbol type, HashSet true, { Type: { IsValueType: false } } => false, - _ => IsConsideredBlittable(field.Type, seenTypes) + _ => IsConsideredBlittable(field.Type, seenTypes.Add(type)) }; if (!fieldBlittable) { - seenTypes.Remove(type); return false; } } } - seenTypes.Remove(type); return true; } @@ -73,9 +71,9 @@ or SpecialType.System_IntPtr _ => false }; - public static bool IsConsideredBlittable(this ITypeSymbol type) => IsConsideredBlittable(type, new HashSet(SymbolEqualityComparer.Default)); + public static bool IsConsideredBlittable(this ITypeSymbol type) => IsConsideredBlittable(type, ImmutableHashSet.Create(SymbolEqualityComparer.Default)); - private static bool IsConsideredBlittable(this ITypeSymbol type, HashSet seenTypes) + private static bool IsConsideredBlittable(this ITypeSymbol type, ImmutableHashSet seenTypes) { if (type.SpecialType != SpecialType.None) { diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs new file mode 100644 index 0000000000000..370e90efb3d28 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs @@ -0,0 +1,217 @@ + +using System.Diagnostics; +using System.Runtime.CompilerServices; + +namespace System.Runtime.InteropServices.GeneratedMarshalling +{ + public unsafe ref struct ArrayMarshaller + { + private T[]? managedArray; + private readonly int sizeOfNativeElement; + private IntPtr allocatedMemory; + + public ArrayMarshaller(int sizeOfNativeElement) + :this() + { + this.sizeOfNativeElement = sizeOfNativeElement; + } + + public ArrayMarshaller(T[]? managed, int sizeOfNativeElement) + { + allocatedMemory = default; + this.sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + managedArray = null; + NativeValueStorage = default; + return; + } + managedArray = managed; + this.sizeOfNativeElement = sizeOfNativeElement; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); + allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); + } + + public ArrayMarshaller(T[]? managed, Span stackSpace, int sizeOfNativeElement) + { + allocatedMemory = default; + this.sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + managedArray = null; + NativeValueStorage = default; + return; + } + managedArray = managed; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); + if (spaceToAllocate <= stackSpace.Length) + { + NativeValueStorage = stackSpace[0..spaceToAllocate]; + } + else + { + allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); + } + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + public const int StackBufferSize = 0x200; + + public Span ManagedValues => managedArray; + + public Span NativeValueStorage { get; private set; } + + public ref byte GetPinnableReference() => ref MemoryMarshal.GetReference(NativeValueStorage); + + public void SetUnmarshalledCollectionLength(int length) + { + managedArray = new T[length]; + } + + public byte* Value + { + get + { + Debug.Assert(managedArray is null || allocatedMemory != IntPtr.Zero); + return (byte*)allocatedMemory; + } + set + { + if (value == null) + { + managedArray = null; + NativeValueStorage = default; + } + else + { + allocatedMemory = (IntPtr)value; + NativeValueStorage = new Span(value, (managedArray?.Length ?? 0) * sizeOfNativeElement); + } + } + } + + public T[]? ToManaged() => managedArray; + + public void FreeNative() + { + if (allocatedMemory != IntPtr.Zero) + { + Marshal.FreeCoTaskMem(allocatedMemory); + } + } + } + + public unsafe ref struct PtrArrayMarshaller where T : unmanaged + { + private T*[]? managedArray; + private readonly int sizeOfNativeElement; + private IntPtr allocatedMemory; + + public PtrArrayMarshaller(int sizeOfNativeElement) + : this() + { + this.sizeOfNativeElement = sizeOfNativeElement; + } + + public PtrArrayMarshaller(T*[]? managed, int sizeOfNativeElement) + { + allocatedMemory = default; + this.sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + managedArray = null; + NativeValueStorage = default; + return; + } + managedArray = managed; + this.sizeOfNativeElement = sizeOfNativeElement; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); + allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); + } + + public PtrArrayMarshaller(T*[]? managed, Span stackSpace, int sizeOfNativeElement) + { + allocatedMemory = default; + this.sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + managedArray = null; + NativeValueStorage = default; + return; + } + managedArray = managed; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); + if (spaceToAllocate <= stackSpace.Length) + { + NativeValueStorage = stackSpace[0..spaceToAllocate]; + } + else + { + allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); + } + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + public const int StackBufferSize = 0x200; + + public Span ManagedValues => Unsafe.As(managedArray); + + public Span NativeValueStorage { get; private set; } + + public ref byte GetPinnableReference() => ref MemoryMarshal.GetReference(NativeValueStorage); + + public void SetUnmarshalledCollectionLength(int length) + { + managedArray = new T*[length]; + } + + public byte* Value + { + get + { + Debug.Assert(managedArray is null || allocatedMemory != IntPtr.Zero); + return (byte*)allocatedMemory; + } + set + { + if (value == null) + { + managedArray = null; + NativeValueStorage = default; + } + else + { + allocatedMemory = (IntPtr)value; + NativeValueStorage = new Span(value, (managedArray?.Length ?? 0) * sizeOfNativeElement); + } + + } + } + + public T*[]? ToManaged() => managedArray; + + public void FreeNative() + { + if (allocatedMemory != IntPtr.Zero) + { + Marshal.FreeCoTaskMem(allocatedMemory); + } + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs index 11e1b29639fb6..dd605b9e60bbb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs @@ -2,17 +2,17 @@ namespace System.Runtime.InteropServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] - class GeneratedMarshallingAttribute : Attribute + sealed class GeneratedMarshallingAttribute : Attribute { } [AttributeUsage(AttributeTargets.Struct)] - public class BlittableTypeAttribute : Attribute + public sealed class BlittableTypeAttribute : Attribute { } [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] - public class NativeMarshallingAttribute : Attribute + public sealed class NativeMarshallingAttribute : Attribute { public NativeMarshallingAttribute(Type nativeType) { @@ -22,14 +22,36 @@ public NativeMarshallingAttribute(Type nativeType) public Type NativeType { get; } } - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field)] - public class MarshalUsingAttribute : Attribute + [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field, AllowMultiple = true)] + public sealed class MarshalUsingAttribute : Attribute { + public MarshalUsingAttribute() + { + CountElementName = string.Empty; + } + public MarshalUsingAttribute(Type nativeType) + :this() { NativeType = nativeType; } - public Type NativeType { get; } + public Type? NativeType { get; } + + public string CountElementName { get; set; } + + public int ConstantElementCount { get; set; } + + public int ElementIndirectionLevel { get; set; } + + public const string ReturnsCountValue = "return-value"; + } + + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] + public sealed class GenericContiguousCollectionMarshallerAttribute : Attribute + { + public GenericContiguousCollectionMarshallerAttribute() + { + } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs new file mode 100644 index 0000000000000..a5be7cf5d1c6a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs @@ -0,0 +1,161 @@ +using SharedTypes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public partial class Collections + { + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + public static partial int Sum([MarshalUsing(typeof(ListMarshaller))] List values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + public static partial int Sum(ref int values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] + public static partial int SumInArray([MarshalUsing(typeof(ListMarshaller))] in List values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] + public static partial void Duplicate([MarshalUsing(typeof(ListMarshaller), CountElementName = "numValues")] ref List values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] + [return:MarshalUsing(typeof(ListMarshaller), CountElementName = "numValues")] + public static partial List CreateRange(int start, int end, out int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] + public static partial void CreateRange_Out(int start, int end, out int numValues, [MarshalUsing(typeof(ListMarshaller), CountElementName = "numValues")] out List res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] + [return:MarshalUsing(typeof(ListMarshaller), ConstantElementCount = sizeof(long))] + public static partial List GetLongBytes(long l); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] + [return:MarshalAs(UnmanagedType.U1)] + public static partial bool AndAllMembers([MarshalUsing(typeof(ListMarshaller))] List pArray, int length); + } + } + + public class CollectionTests + { + [Fact] + public void BlittableElementColllectionMarshalledToNativeAsExpected() + { + var list = new List { 1, 5, 79, 165, 32, 3 }; + Assert.Equal(list.Sum(), NativeExportsNE.Collections.Sum(list, list.Count)); + } + + [Fact] + public void NullBlittableElementColllectionMarshalledToNativeAsExpected() + { + Assert.Equal(-1, NativeExportsNE.Collections.Sum(null, 0)); + } + + [Fact] + public void BlittableElementColllectionInParameter() + { + var list = new List { 1, 5, 79, 165, 32, 3 }; + Assert.Equal(list.Sum(), NativeExportsNE.Collections.SumInArray(list, list.Count)); + } + + [Fact] + public void BlittableElementCollectionRefParameter() + { + var list = new List { 1, 5, 79, 165, 32, 3 }; + var newList = list; + NativeExportsNE.Collections.Duplicate(ref newList, list.Count); + Assert.Equal((IEnumerable)list, newList); + } + + [Fact] + public void BlittableElementCollectionReturnedFromNative() + { + int start = 5; + int end = 20; + + IEnumerable expected = Enumerable.Range(start, end - start); + Assert.Equal(expected, NativeExportsNE.Collections.CreateRange(start, end, out _)); + + List res; + NativeExportsNE.Collections.CreateRange_Out(start, end, out _, out res); + Assert.Equal(expected, res); + } + + [Fact] + public void NullBlittableElementCollectionReturnedFromNative() + { + Assert.Null(NativeExportsNE.Collections.CreateRange(1, 0, out _)); + + List res; + NativeExportsNE.Collections.CreateRange_Out(1, 0, out _, out res); + Assert.Null(res); + } + + private static List GetStringList() + { + return new() + { + "ABCdef 123$%^", + "🍜 !! 🍜 !!", + "🌲 木 🔥 火 🌾 土 🛡 金 🌊 水" , + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae posuere mauris, sed ultrices leo. Suspendisse potenti. Mauris enim enim, blandit tincidunt consequat in, varius sit amet neque. Morbi eget porttitor ex. Duis mattis aliquet ante quis imperdiet. Duis sit.", + string.Empty, + null + }; + } + + [Fact] + public void ConstantSizeCollection() + { + var longVal = 0x12345678ABCDEF10L; + + Assert.Equal(longVal, MemoryMarshal.Read(CollectionsMarshal.AsSpan(NativeExportsNE.Collections.GetLongBytes(longVal)))); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void CollectionWithSimpleNonBlittableTypeMarshalling(bool result) + { + var boolValues = new List + { + new BoolStruct + { + b1 = true, + b2 = true, + b3 = true, + }, + new BoolStruct + { + b1 = true, + b2 = true, + b3 = true, + }, + new BoolStruct + { + b1 = true, + b2 = true, + b3 = result, + }, + }; + + Assert.Equal(result, NativeExportsNE.Collections.AndAllMembers(boolValues, boolValues.Count)); + } + + private static string ReverseChars(string value) + { + if (value == null) + return null; + + var chars = value.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + } +} 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 d19caf2e5f579..863eb9ae44747 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -522,7 +522,7 @@ private static string BlittableMyStruct(string modifier = "") => $@"#pragma warn {BlittableMyStruct()} "; - public static string ArrayParametersAndModifiers(string elementType) => $@" + public static string MarshalAsArrayParametersAndModifiers(string elementType) => $@" using System.Runtime.InteropServices; partial class Test {{ @@ -538,9 +538,9 @@ out int pOutSize ); }}"; - public static string ArrayParametersAndModifiers() => ArrayParametersAndModifiers(typeof(T).ToString()); + public static string MarshalAsArrayParametersAndModifiers() => MarshalAsArrayParametersAndModifiers(typeof(T).ToString()); - public static string ArrayParameterWithSizeParam(string sizeParamType, bool isByRef) => $@" + public static string MarshalAsArrayParameterWithSizeParam(string sizeParamType, bool isByRef) => $@" using System.Runtime.InteropServices; partial class Test {{ @@ -551,10 +551,10 @@ public static partial void Method( ); }}"; - public static string ArrayParameterWithSizeParam(bool isByRef) => ArrayParameterWithSizeParam(typeof(T).ToString(), isByRef); + public static string MarshalAsArrayParameterWithSizeParam(bool isByRef) => MarshalAsArrayParameterWithSizeParam(typeof(T).ToString(), isByRef); - public static string ArrayParameterWithNestedMarshalInfo(string elementType, UnmanagedType nestedMarshalInfo) => $@" + public static string MarshalAsArrayParameterWithNestedMarshalInfo(string elementType, UnmanagedType nestedMarshalInfo) => $@" using System.Runtime.InteropServices; partial class Test {{ @@ -564,7 +564,7 @@ public static partial void Method( ); }}"; - public static string ArrayParameterWithNestedMarshalInfo(UnmanagedType nestedMarshalType) => ArrayParameterWithNestedMarshalInfo(typeof(T).ToString(), nestedMarshalType); + public static string MarshalAsArrayParameterWithNestedMarshalInfo(UnmanagedType nestedMarshalType) => MarshalAsArrayParameterWithNestedMarshalInfo(typeof(T).ToString(), nestedMarshalType); public static string ArrayPreserveSigFalse(string elementType) => $@" using System.Runtime.InteropServices; @@ -925,7 +925,7 @@ struct Native } "; - public static string ArrayMarshallingWithCustomStructElementWithValueProperty => ArrayParametersAndModifiers("IntStructWrapper") + @" + public static string ArrayMarshallingWithCustomStructElementWithValueProperty => MarshalAsArrayParametersAndModifiers("IntStructWrapper") + @" [NativeMarshalling(typeof(IntStructWrapperNative))] public struct IntStructWrapper { @@ -945,7 +945,7 @@ public IntStructWrapperNative(IntStructWrapper managed) } "; - public static string ArrayMarshallingWithCustomStructElement => ArrayParametersAndModifiers("IntStructWrapper") + @" + public static string ArrayMarshallingWithCustomStructElement => MarshalAsArrayParametersAndModifiers("IntStructWrapper") + @" [NativeMarshalling(typeof(IntStructWrapperNative))] public struct IntStructWrapper { @@ -1090,5 +1090,246 @@ struct RecursiveStruct2 RecursiveStruct1 s; int i; }"; + + public static string CollectionByValue(string elementType) => BasicParameterByValue($"TestCollection<{elementType}>") + @" +[NativeMarshalling(typeof(Marshaller<>))] +class TestCollection {} + +[GenericContiguousCollectionMarshaller] +ref struct Marshaller +{ + public Marshaller(TestCollection managed, int nativeElementSize) : this() {} + public System.Span ManagedValues { get; } + public System.Span NativeValueStorage { get; } + public System.IntPtr Value { get; } +} +"; + + public static string CollectionByValue() => CollectionByValue(typeof(T).ToString()); + + public static string MarshalUsingCollectionCountInfoParametersAndModifiers(string collectionType) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + [return:MarshalUsing(ConstantElementCount=10)] + public static partial {collectionType} Method( + {collectionType} p, + in {collectionType} pIn, + int pRefSize, + [MarshalUsing(CountElementName = ""pRefSize"")] ref {collectionType} pRef, + [MarshalUsing(CountElementName = ""pOutSize"")] out {collectionType} pOut, + out int pOutSize + ); +}}"; + + public static string CustomCollectionWithMarshaller(bool enableDefaultMarshalling) + { + string nativeMarshallingAttribute = enableDefaultMarshalling ? "[NativeMarshalling(typeof(Marshaller<>))]" : string.Empty; + return nativeMarshallingAttribute + @"class TestCollection {} + +[GenericContiguousCollectionMarshaller] +ref struct Marshaller +{ + public Marshaller(int nativeElementSize) : this() {} + public Marshaller(TestCollection managed, int nativeElementSize) : this() {} + public System.Span ManagedValues { get; } + public System.Span NativeValueStorage { get; } + public System.IntPtr Value { get; set; } + public void SetUnmarshalledCollectionLength(int length) {} + public TestCollection ToManaged() => throw null; +}"; + } + + public static string MarshalUsingCollectionCountInfoParametersAndModifiers() => MarshalUsingCollectionCountInfoParametersAndModifiers(typeof(T).ToString()); + + public static string CustomCollectionDefaultMarshallerParametersAndModifiers(string elementType) => MarshalUsingCollectionCountInfoParametersAndModifiers($"TestCollection<{elementType}>") + CustomCollectionWithMarshaller(enableDefaultMarshalling: true); + + public static string CustomCollectionDefaultMarshallerParametersAndModifiers() => CustomCollectionDefaultMarshallerParametersAndModifiers(typeof(T).ToString()); + + public static string MarshalUsingCollectionParametersAndModifiers(string collectionType, string marshallerType) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + [return:MarshalUsing(typeof({marshallerType}), ConstantElementCount=10)] + public static partial {collectionType} Method( + [MarshalUsing(typeof({marshallerType}))] {collectionType} p, + [MarshalUsing(typeof({marshallerType}))] in {collectionType} pIn, + int pRefSize, + [MarshalUsing(typeof({marshallerType}), CountElementName = ""pRefSize"")] ref {collectionType} pRef, + [MarshalUsing(typeof({marshallerType}), CountElementName = ""pOutSize"")] out {collectionType} pOut, + out int pOutSize + ); +}}"; + + public static string CustomCollectionCustomMarshallerParametersAndModifiers(string elementType) => MarshalUsingCollectionParametersAndModifiers($"TestCollection<{elementType}>", $"Marshaller<{elementType}>") + CustomCollectionWithMarshaller(enableDefaultMarshalling: false); + + public static string CustomCollectionCustomMarshallerParametersAndModifiers() => CustomCollectionCustomMarshallerParametersAndModifiers(typeof(T).ToString()); + + public static string MarshalUsingCollectionReturnValueLength(string collectionType, string marshallerType) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial int Method( + [MarshalUsing(typeof({marshallerType}), CountElementName = MarshalUsingAttribute.ReturnsCountValue)] out {collectionType} pOut + ); +}}"; + + public static string CustomCollectionCustomMarshallerReturnValueLength(string elementType) => MarshalUsingCollectionReturnValueLength($"TestCollection<{elementType}>", $"Marshaller<{elementType}>") + CustomCollectionWithMarshaller(enableDefaultMarshalling: false); + + public static string CustomCollectionCustomMarshallerReturnValueLength() => CustomCollectionCustomMarshallerReturnValueLength(typeof(T).ToString()); + + public static string MarshalUsingArrayParameterWithSizeParam(string sizeParamType, bool isByRef) => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + {(isByRef ? "ref" : "")} {sizeParamType} pRefSize, + [MarshalUsing(CountElementName = ""pRefSize"")] ref int[] pRef + ); +}}"; + + public static string MarshalUsingArrayParameterWithSizeParam(bool isByRef) => MarshalUsingArrayParameterWithSizeParam(typeof(T).ToString(), isByRef); + + public static string MarshalUsingCollectionWithConstantAndElementCount => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + int pRefSize, + [MarshalUsing(ConstantElementCount = 10, CountElementName = ""pRefSize"")] ref int[] pRef + ); +}}"; + + public static string MarshalUsingCollectionWithNullElementName => $@" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + int pRefSize, + [MarshalUsing(CountElementName = null)] ref int[] pRef + ); +}}"; + + public static string GenericCollectionMarshallingArityMismatch => BasicParameterByValue("TestCollection") + @" +[NativeMarshalling(typeof(Marshaller<,>))] +class TestCollection {} + +[GenericContiguousCollectionMarshaller] +ref struct Marshaller +{ + public Marshaller(TestCollection managed, int nativeElementSize) : this() {} + public System.Span ManagedValues { get; } + public System.Span NativeValueStorage { get; } + public System.IntPtr Value { get; } + public TestCollection ToManaged() => throw null; +}"; + + public static string GenericCollectionWithCustomElementMarshalling => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + [return:MarshalUsing(ConstantElementCount=10)] + [return:MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] + public static partial TestCollection Method( + [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] TestCollection p, + [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] in TestCollection pIn, + int pRefSize, + [MarshalUsing(CountElementName = ""pRefSize""), MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] ref TestCollection pRef, + [MarshalUsing(CountElementName = ""pOutSize"")][MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] out TestCollection pOut, + out int pOutSize + ); +} + +struct IntWrapper +{ + public IntWrapper(int i){} + public int ToManaged() => throw null; +} + +" + CustomCollectionWithMarshaller(enableDefaultMarshalling: true); + + public static string GenericCollectionWithCustomElementMarshallingDuplicateElementIndirectionLevel => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] TestCollection p); +} + +struct IntWrapper +{ + public IntWrapper(int i){} + public int ToManaged() => throw null; +} + +" + CustomCollectionWithMarshaller(enableDefaultMarshalling: true); + + public static string GenericCollectionWithCustomElementMarshallingUnusedElementIndirectionLevel => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 2)] TestCollection p); +} + +struct IntWrapper +{ + public IntWrapper(int i){} + public int ToManaged() => throw null; +} + +" + CustomCollectionWithMarshaller(enableDefaultMarshalling: true); + + public static string MarshalAsAndMarshalUsingOnReturnValue => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + [return:MarshalUsing(ConstantElementCount=10)] + [return:MarshalAs(UnmanagedType.LPArray, SizeConst=10)] + public static partial int[] Method(); +} +"; + + public static string RecursiveCountElementNameOnReturnValue => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + [return:MarshalUsing(CountElementName=MarshalUsingAttribute.ReturnsCountValue)] + public static partial int[] Method(); +} +"; + + public static string RecursiveCountElementNameOnParameter => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [MarshalUsing(CountElementName=""arr"")] ref int[] arr + ); +} +"; + public static string MutuallyRecursiveCountElementNameOnParameter => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [MarshalUsing(CountElementName=""arr2"")] ref int[] arr, + [MarshalUsing(CountElementName=""arr"")] ref int[] arr2 + ); +} +"; } } 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 19736372a2535..d34b33c638132 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -78,10 +78,14 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; yield return new object[] { CodeSnippets.BasicParametersAndModifiers(), 3, 0 }; - // Array with non-integer size param - yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; - yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; - yield return new object[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + // Collection with non-integer size param + yield return new object[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + yield return new object[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + yield return new object[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + yield return new object[] { CodeSnippets.MarshalUsingArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + yield return new object[] { CodeSnippets.MarshalUsingArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + yield return new object[] { CodeSnippets.MarshalUsingArrayParameterWithSizeParam(isByRef: false), 1, 0 }; + // Custom type marshalling with invalid members yield return new object[] { CodeSnippets.CustomStructMarshallingByRefValueProperty, 3, 0 }; @@ -104,6 +108,22 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.ImplicitlyBlittableStructParametersAndModifiers("public"), 5, 0 }; yield return new object[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers(), 5, 0 }; yield return new object[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers("public"), 5, 0 }; + + // Collection with constant and element size parameter + yield return new object[] { CodeSnippets.MarshalUsingCollectionWithConstantAndElementCount, 2, 0 }; + + // Collection with null element size parameter name + yield return new object[] { CodeSnippets.MarshalUsingCollectionWithNullElementName, 2, 0 }; + + // Generic collection marshaller has different arity than collection. + yield return new object[] { CodeSnippets.GenericCollectionMarshallingArityMismatch, 2, 0 }; + + yield return new object[] { CodeSnippets.MarshalAsAndMarshalUsingOnReturnValue, 2, 0 }; + yield return new object[] { CodeSnippets.GenericCollectionWithCustomElementMarshallingDuplicateElementIndirectionLevel, 2, 0 }; + yield return new object[] { CodeSnippets.GenericCollectionWithCustomElementMarshallingUnusedElementIndirectionLevel, 1, 0 }; + yield return new object[] { CodeSnippets.RecursiveCountElementNameOnReturnValue, 2, 0 }; + yield return new object[] { CodeSnippets.RecursiveCountElementNameOnParameter, 2, 0 }; + yield return new object[] { CodeSnippets.MutuallyRecursiveCountElementNameOnParameter, 4, 0 }; } [Theory] 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 a785ed75ac654..5f5938575561e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -37,39 +37,39 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; // Arrays - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParametersAndModifiers() }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: false) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; - yield return new[] { CodeSnippets.ArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: false) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam(isByRef: true) }; // CharSet yield return new[] { CodeSnippets.BasicParametersAndModifiersWithCharSet(CharSet.Unicode) }; @@ -89,9 +89,9 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPTStr) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPUTF8Str) }; yield return new[] { CodeSnippets.MarshalAsParametersAndModifiers(UnmanagedType.LPStr) }; - yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPWStr) }; - yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPUTF8Str) }; - yield return new[] { CodeSnippets.ArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithNestedMarshalInfo(UnmanagedType.LPWStr) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithNestedMarshalInfo(UnmanagedType.LPUTF8Str) }; + yield return new[] { CodeSnippets.MarshalAsArrayParameterWithNestedMarshalInfo(UnmanagedType.LPStr) }; // [In, Out] attributes // By value non-blittable array @@ -203,6 +203,62 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.ImplicitlyBlittableStructParametersAndModifiers("internal") }; yield return new[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers() }; yield return new[] { CodeSnippets.ImplicitlyBlittableGenericTypeParametersAndModifiers("internal") }; + + // Custom collection marshalling + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.CollectionByValue() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.MarshalUsingCollectionCountInfoParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionDefaultMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; + yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerReturnValueLength() }; + yield return new[] { CodeSnippets.GenericCollectionWithCustomElementMarshalling }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs index aee951b165ea9..35275afa0916d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Runtime.InteropServices; namespace SharedTypes @@ -217,4 +219,114 @@ public IntStructWrapperNative(IntStructWrapper managed) public IntStructWrapper ToManaged() => new IntStructWrapper { Value = value }; } + + [GenericContiguousCollectionMarshaller] + public unsafe ref struct ListMarshaller + { + private List managedList; + private readonly int sizeOfNativeElement; + private IntPtr allocatedMemory; + + public ListMarshaller(int sizeOfNativeElement) + : this() + { + this.sizeOfNativeElement = sizeOfNativeElement; + } + + public ListMarshaller(List managed, int sizeOfNativeElement) + { + allocatedMemory = default; + this.sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + managedList = null; + NativeValueStorage = default; + return; + } + managedList = managed; + this.sizeOfNativeElement = sizeOfNativeElement; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Count * sizeOfNativeElement, 1); + allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); + } + + public ListMarshaller(List managed, Span stackSpace, int sizeOfNativeElement) + { + allocatedMemory = default; + this.sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + managedList = null; + NativeValueStorage = default; + return; + } + managedList = managed; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Count * sizeOfNativeElement, 1); + if (spaceToAllocate <= stackSpace.Length) + { + NativeValueStorage = stackSpace[0..spaceToAllocate]; + } + else + { + allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); + } + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + public const int StackBufferSize = 0x200; + + public Span ManagedValues => CollectionsMarshal.AsSpan(managedList); + + public Span NativeValueStorage { get; private set; } + + public ref byte GetPinnableReference() => ref NativeValueStorage.GetPinnableReference(); + + public void SetUnmarshalledCollectionLength(int length) + { + managedList = new List(length); + for (int i = 0; i < length; i++) + { + managedList.Add(default); + } + } + + public byte* Value + { + get + { + Debug.Assert(managedList is null || allocatedMemory != IntPtr.Zero); + return (byte*)allocatedMemory; + } + set + { + if (value == null) + { + managedList = null; + NativeValueStorage = default; + } + else + { + allocatedMemory = (IntPtr)value; + NativeValueStorage = new Span(value, (managedList?.Count ?? 0) * sizeOfNativeElement); + } + } + } + + public List ToManaged() => managedList; + + public void FreeNative() + { + if (allocatedMemory != IntPtr.Zero) + { + Marshal.FreeCoTaskMem(allocatedMemory); + } + } + } } From f8c34f5cca3394b60028d9f639ae286111a86fff Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 9 Jun 2021 12:05:32 -0700 Subject: [PATCH 107/161] Use GeneratedDllImport in System.IO.Pipes (#53947) --- .../Unix/System.Native/Interop.Fcntl.Pipe.cs | 8 +++---- .../Unix/System.Native/Interop.GetPeerID.cs | 4 ++-- .../System.Native/Interop.GetPeerUserName.cs | 4 ++-- .../Unix/System.Native/Interop.Read.Pipe.cs | 4 ++-- .../Unix/System.Native/Interop.Stat.Pipe.cs | 4 ++-- .../Unix/System.Native/Interop.Write.Pipe.cs | 4 ++-- .../Interop.ImpersonateNamedPipeClient.cs | 4 ++-- .../Kernel32/Interop.ConnectNamedPipe.cs | 8 +++---- .../Kernel32/Interop.CreateNamedPipe.cs | 4 ++-- .../Kernel32/Interop.CreateNamedPipeClient.cs | 4 ++-- .../Interop.CreatePipe_SafePipeHandle.cs | 4 ++-- .../Kernel32/Interop.DisconnectNamedPipe.cs | 4 ++-- .../Interop.DuplicateHandle_SafePipeHandle.cs | 4 ++-- .../Kernel32/Interop.FlushFileBuffers.cs | 6 +++++ .../Interop.GetFileType_SafeHandle.cs | 5 ++++ .../Interop.GetNamedPipeHandleState.cs | 4 ++-- .../Kernel32/Interop.GetNamedPipeInfo.cs | 4 ++-- .../Interop.ReadFile_SafeHandle_IntPtr.cs | 5 ++++ ...op.ReadFile_SafeHandle_NativeOverlapped.cs | 10 ++++++++ .../Interop.SetNamedPipeHandleState.cs | 4 ++-- .../Windows/Kernel32/Interop.WaitNamedPipe.cs | 4 ++-- .../Interop.WriteFile_SafeHandle_IntPtr.cs | 12 +++++++++- ...p.WriteFile_SafeHandle_NativeOverlapped.cs | 24 +++++++++++++++++-- 23 files changed, 97 insertions(+), 41 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs index 9e86930ec2844..6361f87fc0ee4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs @@ -13,11 +13,11 @@ internal static partial class Fcntl { internal static readonly bool CanGetSetPipeSz = (FcntlCanGetSetPipeSz() != 0); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetPipeSz", SetLastError=true)] - internal static extern int GetPipeSz(SafePipeHandle fd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlGetPipeSz", SetLastError=true)] + internal static partial int GetPipeSz(SafePipeHandle fd); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetPipeSz", SetLastError=true)] - internal static extern int SetPipeSz(SafePipeHandle fd, int size); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetPipeSz", SetLastError=true)] + internal static partial int SetPipeSz(SafePipeHandle fd, int size); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlCanGetSetPipeSz")] [SuppressGCTransition] diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerID.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerID.cs index 2e9e6f139c3bb..23a338a30a754 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerID.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPeerID.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerID", SetLastError = true)] - internal static extern int GetPeerID(SafeHandle socket, out uint euid); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerID", SetLastError = true)] + internal static partial int GetPeerID(SafeHandle socket, out uint euid); } } 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 ccc7d9c88e5a3..f45a343b60ab8 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 { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerUserName", SetLastError = true)] - internal static extern string GetPeerUserName(SafeHandle socket); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerUserName", SetLastError = true, CharSet = CharSet.Ansi)] + internal static partial string GetPeerUserName(SafeHandle socket); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.Pipe.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.Pipe.cs index 09d21bc9aa96d..c2ecd36478b58 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.Pipe.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.Pipe.cs @@ -18,7 +18,7 @@ internal static partial class Sys /// Returns the number of bytes read on success; otherwise, -1 is returned /// Note - on fail. the position of the stream may change depending on the platform; consult man 2 read for more info /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Read", SetLastError = true)] - internal static extern unsafe int Read(SafePipeHandle fd, byte* buffer, int count); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Read", SetLastError = true)] + internal static unsafe partial int Read(SafePipeHandle fd, byte* buffer, int count); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs index 1852f983470f9..ccf6a4197954b 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat", SetLastError = true)] - internal static extern int FStat(SafePipeHandle fd, out FileStatus output); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat", SetLastError = true)] + internal static partial int FStat(SafePipeHandle fd, out FileStatus output); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.Pipe.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.Pipe.cs index 2543be83046ae..b71b9c5e3f734 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.Pipe.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.Pipe.cs @@ -17,7 +17,7 @@ internal static partial class Sys /// /// Returns the number of bytes written on success; otherwise, returns -1 and sets errno /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] - internal static extern unsafe int Write(SafePipeHandle fd, byte* buffer, int bufferSize); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] + internal static unsafe partial int Write(SafePipeHandle fd, byte* buffer, int bufferSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateNamedPipeClient.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateNamedPipeClient.cs index 2b72ecd6572d5..2aef33a6589db 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateNamedPipeClient.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ImpersonateNamedPipeClient.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool ImpersonateNamedPipeClient(SafePipeHandle hNamedPipe); + internal static partial bool ImpersonateNamedPipeClient(SafePipeHandle hNamedPipe); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConnectNamedPipe.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConnectNamedPipe.cs index 2805d3d1b7684..1838d726f86bf 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConnectNamedPipe.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConnectNamedPipe.cs @@ -10,12 +10,12 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern unsafe bool ConnectNamedPipe(SafePipeHandle handle, NativeOverlapped* overlapped); + internal static unsafe partial bool ConnectNamedPipe(SafePipeHandle handle, NativeOverlapped* overlapped); - [DllImport(Libraries.Kernel32, SetLastError = true)] + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool ConnectNamedPipe(SafePipeHandle handle, IntPtr overlapped); + internal static partial bool ConnectNamedPipe(SafePipeHandle handle, IntPtr overlapped); } } 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 3d88bf3c5ba94..9afae1e1430ec 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipe.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipe.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "CreateNamedPipeW")] - internal static extern SafePipeHandle CreateNamedPipe( + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CreateNamedPipeW")] + internal static partial SafePipeHandle CreateNamedPipe( string pipeName, int openMode, int pipeMode, 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 4c8b9cbc06bc2..f5cad97b7c477 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipeClient.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateNamedPipeClient.cs @@ -10,8 +10,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] - internal static extern SafePipeHandle CreateNamedPipeClient( + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SafePipeHandle CreateNamedPipeClient( string? lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafePipeHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafePipeHandle.cs index 92a3257d33d37..0b1e88acd5126 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafePipeHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreatePipe_SafePipeHandle.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool CreatePipe(out SafePipeHandle hReadPipe, out SafePipeHandle hWritePipe, ref SECURITY_ATTRIBUTES lpPipeAttributes, int nSize); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool CreatePipe(out SafePipeHandle hReadPipe, out SafePipeHandle hWritePipe, ref SECURITY_ATTRIBUTES lpPipeAttributes, int nSize); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DisconnectNamedPipe.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DisconnectNamedPipe.cs index ccef10e08a77a..c0d137618c1e7 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DisconnectNamedPipe.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DisconnectNamedPipe.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DisconnectNamedPipe(SafePipeHandle hNamedPipe); + internal static partial bool DisconnectNamedPipe(SafePipeHandle hNamedPipe); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafePipeHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafePipeHandle.cs index 96726abc91fd4..88f2b8c4568ef 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafePipeHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafePipeHandle.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool DuplicateHandle( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool DuplicateHandle( IntPtr hSourceProcessHandle, SafeHandle hSourceHandle, IntPtr hTargetProcessHandle, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushFileBuffers.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushFileBuffers.cs index 094ef6134db79..9b0e8571854e3 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushFileBuffers.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushFileBuffers.cs @@ -7,8 +7,14 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool FlushFileBuffers(SafeHandle hHandle); +#else [DllImport(Libraries.Kernel32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool FlushFileBuffers(SafeHandle hHandle); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_SafeHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_SafeHandle.cs index 557866dbf55b8..d5d2062f05d13 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_SafeHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileType_SafeHandle.cs @@ -7,7 +7,12 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial int GetFileType(SafeHandle hFile); +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern int GetFileType(SafeHandle hFile); +#endif } } 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 f98c2c1c31b5c..74c60e6376116 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeHandleState.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeHandleState.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] - internal static extern unsafe bool GetNamedPipeHandleStateW( + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] + internal static unsafe partial bool GetNamedPipeHandleStateW( SafePipeHandle hNamedPipe, uint* lpState, uint* lpCurInstances, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeInfo.cs index 586f661857c2e..b370c8efb2b56 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNamedPipeInfo.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe bool GetNamedPipeInfo( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial bool GetNamedPipeInfo( SafePipeHandle hNamedPipe, uint* lpFlags, uint* lpOutBufferSize, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_IntPtr.cs index d2ab765d448bc..9651a10fb64bd 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_IntPtr.cs @@ -8,8 +8,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int ReadFile( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern unsafe int ReadFile( +#endif SafeHandle handle, byte* bytes, int numBytesToRead, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_NativeOverlapped.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_NativeOverlapped.cs index c6fb2c4311cf3..ba9b6a91c0eb6 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_NativeOverlapped.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_NativeOverlapped.cs @@ -9,16 +9,26 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int ReadFile( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern unsafe int ReadFile( +#endif SafeHandle handle, byte* bytes, int numBytesToRead, IntPtr numBytesRead_mustBeZero, NativeOverlapped* overlapped); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int ReadFile( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern unsafe int ReadFile( +#endif SafeHandle handle, byte* bytes, int numBytesToRead, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetNamedPipeHandleState.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetNamedPipeHandleState.cs index 70f0ab13483e7..2ee991183b760 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetNamedPipeHandleState.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetNamedPipeHandleState.cs @@ -9,9 +9,9 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern unsafe bool SetNamedPipeHandleState( + internal static unsafe partial bool SetNamedPipeHandleState( SafePipeHandle hNamedPipe, int* lpMode, IntPtr lpMaxCollectionCount, 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 cb95a8e120cd5..76abe2bca8ea4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitNamedPipe.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitNamedPipe.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "WaitNamedPipeW")] + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "WaitNamedPipeW")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool WaitNamedPipe(string? name, int timeout); + internal static partial bool WaitNamedPipe(string? name, int timeout); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_IntPtr.cs index 9101041ab4f04..6354c1a5926b4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_IntPtr.cs @@ -15,7 +15,17 @@ internal static partial class Kernel32 // struct in a callback (or an EndWrite method called by that callback), // and pass in an address for the numBytesRead parameter. +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int WriteFile( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe int WriteFile(SafeHandle handle, byte* bytes, int numBytesToWrite, out int numBytesWritten, IntPtr mustBeZero); + internal static extern unsafe int WriteFile( +#endif + SafeHandle handle, + byte* bytes, + int numBytesToWrite, + out int numBytesWritten, + IntPtr mustBeZero); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_NativeOverlapped.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_NativeOverlapped.cs index 3eaff9ca07626..0f66079a24a9e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_NativeOverlapped.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_NativeOverlapped.cs @@ -15,10 +15,30 @@ internal static partial class Kernel32 // simultaneously: overlapped IO, free the memory for the overlapped // struct in a callback (or an EndWrite method called by that callback), // and pass in an address for the numBytesRead parameter. +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int WriteFile( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe int WriteFile(SafeHandle handle, byte* bytes, int numBytesToWrite, IntPtr numBytesWritten_mustBeZero, NativeOverlapped* lpOverlapped); + internal static extern unsafe int WriteFile( +#endif + SafeHandle handle, + byte* bytes, + int numBytesToWrite, + IntPtr numBytesWritten_mustBeZero, + NativeOverlapped* lpOverlapped); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial int WriteFile( +#else [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern unsafe int WriteFile(SafeHandle handle, byte* bytes, int numBytesToWrite, out int numBytesWritten, NativeOverlapped* lpOverlapped); + internal static extern unsafe int WriteFile( +#endif + SafeHandle handle, + byte* bytes, + int numBytesToWrite, + out int numBytesWritten, + NativeOverlapped* lpOverlapped); } } From d1018392300d1c61c5ab6dc4571a430b6b1250a3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 9 Jun 2021 14:04:44 -0700 Subject: [PATCH 108/161] Add configuration option for Unsafe type name. (dotnet/runtimelab#1217) Commit migrated from https://github.com/dotnet/runtimelab/commit/5fa8059e0ba71465be018d97a37db93d72bbcb9e --- .../DllImportGenerator/Marshalling/ArrayMarshaller.cs | 7 +++++-- .../Marshalling/MarshallingGenerator.cs | 3 ++- .../Microsoft.Interop.DllImportGenerator.props | 5 +++++ .../gen/DllImportGenerator/OptionsHelper.cs | 3 +++ .../gen/DllImportGenerator/TypeNames.cs | 11 ++++++++--- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs index 6d0f98c533c45..cb6abc7447114 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -10,12 +11,14 @@ internal sealed class ArrayMarshaller : IMarshallingGenerator private readonly IMarshallingGenerator manualMarshallingGenerator; private readonly TypeSyntax elementType; private readonly bool enablePinning; + private readonly AnalyzerConfigOptions options; - public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning) + public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning, AnalyzerConfigOptions options) { this.manualMarshallingGenerator = manualMarshallingGenerator; this.elementType = elementType; this.enablePinning = enablePinning; + this.options = options; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -127,7 +130,7 @@ private IEnumerable GeneratePinningPath(TypePositionInfo info, PrefixUnaryExpression(SyntaxKind.AddressOfExpression, InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.System_Runtime_CompilerServices_Unsafe), + ParseTypeName(TypeNames.Unsafe(options)), GenericName("As").AddTypeArgumentListArguments( arrayElementType, PredefinedType(Token(SyntaxKind.ByteKeyword))))) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index f406e2c3e6d6a..f90c2731efddc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -566,7 +566,8 @@ private static IMarshallingGenerator CreateNativeCollectionMarshaller( return new ArrayMarshaller( new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: true), elementType, - isBlittable); + isBlittable, + options); } IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props index 13f7ad3690bf2..fb3d09a8a355e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props @@ -15,6 +15,11 @@ of generating a stub that handles all of the marshalling. --> + + $(DefineConstants);DLLIMPORTGENERATOR_ENABLED diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs index 39f2fdc80c1ec..13130369b41de 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs @@ -11,6 +11,7 @@ public static class OptionsHelper { public const string UseMarshalTypeOption = "build_property.DllImportGenerator_UseMarshalType"; public const string GenerateForwardersOption = "build_property.DllImportGenerator_GenerateForwarders"; + public const string UseInternalUnsafeTypeOption = "build_property.DllImportGenerator_UseInternalUnsafeType"; private static bool GetBoolOption(this AnalyzerConfigOptions options, string key) { @@ -22,5 +23,7 @@ private static bool GetBoolOption(this AnalyzerConfigOptions options, string key internal static bool UseMarshalType(this AnalyzerConfigOptions options) => options.GetBoolOption(UseMarshalTypeOption); internal static bool GenerateForwarders(this AnalyzerConfigOptions options) => options.GetBoolOption(GenerateForwardersOption); + + internal static bool UseInternalUnsafeType(this AnalyzerConfigOptions options) => options.GetBoolOption(UseInternalUnsafeTypeOption); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index ad75ffadb8c5b..6c85e26d4b110 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -53,8 +53,13 @@ public static string MarshalEx(AnalyzerConfigOptions options) public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; - // TODO: Add configuration for using Internal.Runtime.CompilerServices.Unsafe to support - // running against System.Private.CoreLib - public const string System_Runtime_CompilerServices_Unsafe = "System.Runtime.CompilerServices.Unsafe"; + private const string System_Runtime_CompilerServices_Unsafe = "System.Runtime.CompilerServices.Unsafe"; + + private const string Internal_Runtime_CompilerServices_Unsafe = "Internal.Runtime.CompilerServices.Unsafe"; + + public static string Unsafe(AnalyzerConfigOptions options) + { + return options.UseInternalUnsafeType() ? Internal_Runtime_CompilerServices_Unsafe : System_Runtime_CompilerServices_Unsafe; + } } } From 3ebfc68b559e2ce0c67a055aeb65a7ac93275e37 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 9 Jun 2021 21:41:31 -0700 Subject: [PATCH 109/161] Don't enable DllImport generator for shims (#53973) --- eng/generators.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/generators.targets b/eng/generators.targets index 77d07da6fb1e0..8764a592d3647 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -20,6 +20,7 @@ From 3004aa29e3c265142a48764121607e24494ec827 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Thu, 10 Jun 2021 12:07:38 -0700 Subject: [PATCH 110/161] Use GeneratedDllImport in System.Net.NetworkInformation (#53966) * Use GeneratedDllImport in System.Net.NetworkInformation --- .../Interop.ProtocolStatistics.cs | 14 ++++----- .../OSX/Interop.SystemConfiguration.cs | 16 +++++----- .../Interop.EnumerateInterfaceAddresses.cs | 2 +- .../System.Native/Interop.GetDomainName.cs | 2 +- .../System.Native/Interop.NetworkChange.cs | 2 +- .../IpHlpApi/Interop.GetNetworkParams.cs | 2 +- .../IpHlpApi/Interop.NetworkInformation.cs | 30 +++++++++---------- .../Windows/WinSock/Interop.WSAEventSelect.cs | 10 +++---- .../HostInformationPal.Windows.cs | 6 ++-- .../BsdIPv4GlobalStatistics.cs | 2 +- .../NetworkInformation/BsdIcmpV4Statistics.cs | 4 +-- .../NetworkInformation/BsdIcmpV6Statistics.cs | 4 +-- .../NetworkInformation/BsdTcpStatistics.cs | 4 +-- .../NetworkInformation/BsdUdpStatistics.cs | 4 +-- .../LinuxNetworkInterface.cs | 2 +- .../NetworkAddressChange.OSX.cs | 4 +-- .../NetworkAddressChange.Unix.cs | 4 +-- .../SystemIPGlobalProperties.cs | 16 +++++----- .../SystemIPGlobalStatistics.cs | 14 +++++---- .../SystemIPv4InterfaceProperties.cs | 6 ++-- .../SystemIcmpV4Statistics.cs | 6 ++-- .../SystemNetworkInterface.cs | 17 ++++++----- .../NetworkInformation/SystemTcpStatistics.cs | 12 ++++---- .../NetworkInformation/SystemUdpStatistics.cs | 12 ++++---- 24 files changed, 103 insertions(+), 92 deletions(-) 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 ab7ac0fb962c6..476b7a653edb1 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 @@ -34,7 +34,7 @@ public readonly struct TcpGlobalStatistics } [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetTcpGlobalStatistics")] - public static extern int GetTcpGlobalStatistics(out TcpGlobalStatistics statistics); + public static unsafe extern int GetTcpGlobalStatistics(TcpGlobalStatistics* statistics); [StructLayoutAttribute(LayoutKind.Sequential)] public readonly struct IPv4GlobalStatistics @@ -56,7 +56,7 @@ public readonly struct IPv4GlobalStatistics } [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetIPv4GlobalStatistics")] - public static extern int GetIPv4GlobalStatistics(out IPv4GlobalStatistics statistics); + public static unsafe extern int GetIPv4GlobalStatistics(IPv4GlobalStatistics* statistics); [StructLayoutAttribute(LayoutKind.Sequential)] public readonly struct UdpGlobalStatistics @@ -69,7 +69,7 @@ public readonly struct UdpGlobalStatistics } [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUdpGlobalStatistics")] - public static extern int GetUdpGlobalStatistics(out UdpGlobalStatistics statistics); + public static unsafe extern int GetUdpGlobalStatistics(UdpGlobalStatistics* statistics); [StructLayoutAttribute(LayoutKind.Sequential)] public readonly struct Icmpv4GlobalStatistics @@ -99,7 +99,7 @@ public readonly struct Icmpv4GlobalStatistics } [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetIcmpv4GlobalStatistics")] - public static extern int GetIcmpv4GlobalStatistics(out Icmpv4GlobalStatistics statistics); + public static unsafe extern int GetIcmpv4GlobalStatistics(Icmpv4GlobalStatistics* statistics); [StructLayoutAttribute(LayoutKind.Sequential)] public readonly struct Icmpv6GlobalStatistics @@ -135,7 +135,7 @@ public readonly struct Icmpv6GlobalStatistics } [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetIcmpv6GlobalStatistics")] - public static extern int GetIcmpv6GlobalStatistics(out Icmpv6GlobalStatistics statistics); + public static unsafe extern int GetIcmpv6GlobalStatistics(Icmpv6GlobalStatistics* statistics); public readonly struct NativeIPInterfaceStatistics { @@ -155,8 +155,8 @@ public readonly struct NativeIPInterfaceStatistics public readonly ulong Flags; } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNativeIPInterfaceStatistics")] - public static extern int GetNativeIPInterfaceStatistics(string name, out NativeIPInterfaceStatistics stats); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNativeIPInterfaceStatistics", CharSet = CharSet.Ansi)] + public static partial int GetNativeIPInterfaceStatistics(string name, out NativeIPInterfaceStatistics stats); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNumRoutes")] public static extern int GetNumRoutes(); diff --git a/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs b/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs index 5d9e896dd4024..ffe34c226aa1f 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs @@ -34,8 +34,8 @@ internal struct SCDynamicStoreContext /// Pass null if no callouts are desired. /// The context associated with the callout. /// A reference to the new dynamic store session. - [DllImport(Libraries.SystemConfigurationLibrary)] - private static extern unsafe SafeCreateHandle SCDynamicStoreCreate( + [GeneratedDllImport(Libraries.SystemConfigurationLibrary)] + private static unsafe partial SafeCreateHandle SCDynamicStoreCreate( IntPtr allocator, CFStringRef name, delegate* unmanaged callout, @@ -67,8 +67,8 @@ internal static unsafe SafeCreateHandle SCDynamicStoreCreate( /// The service ID or a regular expression pattern. /// The specific global entity, such as IPv4 or DNS. /// A string containing the formatted key. - [DllImport(Libraries.SystemConfigurationLibrary)] - private static extern SafeCreateHandle SCDynamicStoreKeyCreateNetworkServiceEntity( + [GeneratedDllImport(Libraries.SystemConfigurationLibrary)] + private static partial SafeCreateHandle SCDynamicStoreKeyCreateNetworkServiceEntity( IntPtr allocator, CFStringRef domain, CFStringRef serviceID, @@ -99,8 +99,8 @@ internal static SafeCreateHandle SCDynamicStoreKeyCreateNetworkServiceEntity( /// The order in which the sources that are ready to be processed are handled, /// on platforms that support it and for source versions that support it. /// The new run loop source object. - [DllImport(Libraries.SystemConfigurationLibrary)] - private static extern SafeCreateHandle SCDynamicStoreCreateRunLoopSource( + [GeneratedDllImport(Libraries.SystemConfigurationLibrary)] + private static partial SafeCreateHandle SCDynamicStoreCreateRunLoopSource( IntPtr allocator, SCDynamicStoreRef store, CFIndex order); @@ -125,8 +125,8 @@ internal static SafeCreateHandle SCDynamicStoreCreateRunLoopSource(SCDynamicStor /// An array of keys to be monitored or IntPtr.Zero if no specific keys are to be monitored. /// An array of POSIX regex pattern strings used to match keys to be monitored, /// or IntPtr.Zero if no key patterns are to be monitored. - /// True if the set of notification keys and patterns was successfully updated; false otherwise. + /// Non-zero if the set of notification keys and patterns was successfully updated; zero otherwise. [DllImport(Libraries.SystemConfigurationLibrary)] - internal static extern bool SCDynamicStoreSetNotificationKeys(SCDynamicStoreRef store, CFArrayRef keys, CFArrayRef patterns); + internal static extern int SCDynamicStoreSetNotificationKeys(SCDynamicStoreRef store, CFArrayRef keys, CFArrayRef patterns); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.cs index 73e988eb7a52e..2ad68069e48c0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.cs @@ -53,7 +53,7 @@ public static extern unsafe int EnumerateInterfaceAddresses( public static extern unsafe int EnumerateGatewayAddressesForInterface(void* context, uint interfaceIndex, delegate* unmanaged onGatewayFound); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNetworkInterfaces")] - public static unsafe extern int GetNetworkInterfaces(ref int count, ref NetworkInterfaceInfo* addrs, ref int addressCount, ref IpAddressInfo *aa); + public static unsafe extern int GetNetworkInterfaces(int* count, NetworkInterfaceInfo** addrs, int* addressCount, IpAddressInfo** aa); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainName.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainName.cs index 31f7c07c10c42..466afb7b0101d 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainName.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainName.cs @@ -10,7 +10,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetDomainName", SetLastError = true)] + [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetDomainName")] private static extern unsafe int GetDomainName(byte* name, int len); internal static unsafe string GetDomainName() diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.NetworkChange.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.NetworkChange.cs index 37de2ebb38807..152588f507885 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.NetworkChange.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.NetworkChange.cs @@ -17,7 +17,7 @@ public enum NetworkChangeKind } [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CreateNetworkChangeListenerSocket")] - public static extern Error CreateNetworkChangeListenerSocket(out int socket); + public static unsafe extern Error CreateNetworkChangeListenerSocket(int* socket); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CloseNetworkChangeListenerSocket")] public static extern Error CloseNetworkChangeListenerSocket(int socket); diff --git a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.GetNetworkParams.cs b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.GetNetworkParams.cs index d6760bfc17bab..f731ce50e7a38 100644 --- a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.GetNetworkParams.cs +++ b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.GetNetworkParams.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class IpHlpApi { [DllImport(Interop.Libraries.IpHlpApi, ExactSpelling = true)] - internal static extern uint GetNetworkParams(IntPtr pFixedInfo, ref uint pOutBufLen); + internal static unsafe extern uint GetNetworkParams(IntPtr pFixedInfo, uint* pOutBufLen); } } diff --git a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs index 81faff1d9a04a..5b4fe4ed49195 100644 --- a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs @@ -324,7 +324,7 @@ internal struct MibTcpStats [StructLayout(LayoutKind.Sequential)] internal struct MibIpStats { - internal bool forwardingEnabled; + internal int forwardingEnabled; internal uint defaultTtl; internal uint packetsReceived; internal uint receivedPacketsWithHeaderErrors; @@ -509,50 +509,50 @@ internal unsafe struct MibUdp6RowOwnerPid } [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetAdaptersAddresses( + internal static unsafe extern uint GetAdaptersAddresses( AddressFamily family, uint flags, IntPtr pReserved, IntPtr adapterAddresses, - ref uint outBufLen); + uint* outBufLen); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetBestInterfaceEx(byte[] ipAddress, out int index); + internal static unsafe extern uint GetBestInterfaceEx(byte* ipAddress, int* index); [DllImport(Interop.Libraries.IpHlpApi)] internal static extern uint GetIfEntry2(ref MibIfRow2 pIfRow); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetIpStatisticsEx(out MibIpStats statistics, AddressFamily family); + internal static unsafe extern uint GetIpStatisticsEx(MibIpStats* statistics, AddressFamily family); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetTcpStatisticsEx(out MibTcpStats statistics, AddressFamily family); + internal static unsafe extern uint GetTcpStatisticsEx(MibTcpStats* statistics, AddressFamily family); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetUdpStatisticsEx(out MibUdpStats statistics, AddressFamily family); + internal static unsafe extern uint GetUdpStatisticsEx(MibUdpStats* statistics, AddressFamily family); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetIcmpStatistics(out MibIcmpInfo statistics); + internal static unsafe extern uint GetIcmpStatistics(MibIcmpInfo* statistics); [DllImport(Interop.Libraries.IpHlpApi)] internal static extern uint GetIcmpStatisticsEx(out MibIcmpInfoEx statistics, AddressFamily family); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetTcpTable(IntPtr pTcpTable, ref uint dwOutBufLen, bool order); + internal static unsafe extern uint GetTcpTable(IntPtr pTcpTable, uint* dwOutBufLen, int order); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetExtendedTcpTable(IntPtr pTcpTable, ref uint dwOutBufLen, bool order, + internal static unsafe extern uint GetExtendedTcpTable(IntPtr pTcpTable, uint* dwOutBufLen, int order, uint IPVersion, TcpTableClass tableClass, uint reserved); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetUdpTable(IntPtr pUdpTable, ref uint dwOutBufLen, bool order); + internal static unsafe extern uint GetUdpTable(IntPtr pUdpTable, uint* dwOutBufLen, int order); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetExtendedUdpTable(IntPtr pUdpTable, ref uint dwOutBufLen, bool order, + internal static unsafe extern uint GetExtendedUdpTable(IntPtr pUdpTable, uint* dwOutBufLen, int order, uint IPVersion, UdpTableClass tableClass, uint reserved); [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern uint GetPerAdapterInfo(uint IfIndex, IntPtr pPerAdapterInfo, ref uint pOutBufLen); + internal static unsafe extern uint GetPerAdapterInfo(uint IfIndex, IntPtr pPerAdapterInfo, uint* pOutBufLen); [DllImport(Interop.Libraries.IpHlpApi)] internal static extern void FreeMibTable(IntPtr handle); @@ -560,8 +560,8 @@ internal static extern uint GetExtendedUdpTable(IntPtr pUdpTable, ref uint dwOut [DllImport(Interop.Libraries.IpHlpApi)] internal static extern uint CancelMibChangeNotify2(IntPtr notificationHandle); - [DllImport(Interop.Libraries.IpHlpApi)] - internal static extern unsafe uint NotifyStableUnicastIpAddressTable( + [GeneratedDllImport(Interop.Libraries.IpHlpApi)] + internal static unsafe partial uint NotifyStableUnicastIpAddressTable( AddressFamily addressFamily, out SafeFreeMibTable table, delegate* unmanaged callback, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAEventSelect.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAEventSelect.cs index 9318345ec9387..a3903f29c3dbb 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAEventSelect.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAEventSelect.cs @@ -9,11 +9,11 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern SocketError WSAEventSelect( - [In] SafeSocketHandle socketHandle, - [In] SafeHandle Event, - [In] AsyncEventBits NetworkEvents); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static partial SocketError WSAEventSelect( + SafeSocketHandle socketHandle, + SafeHandle Event, + AsyncEventBits NetworkEvents); [Flags] internal enum AsyncEventBits diff --git a/src/libraries/Common/src/System/Net/NetworkInformation/HostInformationPal.Windows.cs b/src/libraries/Common/src/System/Net/NetworkInformation/HostInformationPal.Windows.cs index 27f6ba5d1937d..bfd4127724ac7 100644 --- a/src/libraries/Common/src/System/Net/NetworkInformation/HostInformationPal.Windows.cs +++ b/src/libraries/Common/src/System/Net/NetworkInformation/HostInformationPal.Windows.cs @@ -26,20 +26,20 @@ public static string GetDomainName() return FixedInfo.domainName; } - private static Interop.IpHlpApi.FIXED_INFO GetFixedInfo() + private static unsafe Interop.IpHlpApi.FIXED_INFO GetFixedInfo() { uint size = 0; Interop.IpHlpApi.FIXED_INFO fixedInfo = default; // First we need to get the size of the buffer - uint result = Interop.IpHlpApi.GetNetworkParams(IntPtr.Zero, ref size); + uint result = Interop.IpHlpApi.GetNetworkParams(IntPtr.Zero, &size); while (result == Interop.IpHlpApi.ERROR_BUFFER_OVERFLOW) { IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetNetworkParams(buffer, ref size); + result = Interop.IpHlpApi.GetNetworkParams(buffer, &size); if (result == Interop.IpHlpApi.ERROR_SUCCESS) { fixedInfo = Marshal.PtrToStructure(buffer); diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs index 0ac0a8cbd5b1f..b997ac445f6ba 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs @@ -45,7 +45,7 @@ private static unsafe void ProcessIpv4Address(void* pContext, byte* ifaceName, I public unsafe BsdIPv4GlobalStatistics() { Interop.Sys.IPv4GlobalStatistics statistics; - if (Interop.Sys.GetIPv4GlobalStatistics(out statistics) == -1) + if (Interop.Sys.GetIPv4GlobalStatistics(&statistics) == -1) { throw new NetworkInformationException(SR.net_PInvokeError); } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV4Statistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV4Statistics.cs index d8322222a851f..37590aa3fd613 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV4Statistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV4Statistics.cs @@ -28,10 +28,10 @@ internal sealed class BsdIcmpV4Statistics : IcmpV4Statistics private readonly long _timestampRequestsReceived; private readonly long _timestampRequestsSent; - public BsdIcmpV4Statistics() + public unsafe BsdIcmpV4Statistics() { Interop.Sys.Icmpv4GlobalStatistics statistics; - if (Interop.Sys.GetIcmpv4GlobalStatistics(out statistics) != 0) + if (Interop.Sys.GetIcmpv4GlobalStatistics(&statistics) != 0) { throw new NetworkInformationException(SR.net_PInvokeError); } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV6Statistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV6Statistics.cs index fe23a313fede2..426716242643d 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV6Statistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV6Statistics.cs @@ -34,10 +34,10 @@ internal sealed class BsdIcmpV6Statistics : IcmpV6Statistics private readonly long _timeExceededMessagesReceived; private readonly long _timeExceededMessagesSent; - public BsdIcmpV6Statistics() + public unsafe BsdIcmpV6Statistics() { Interop.Sys.Icmpv6GlobalStatistics statistics; - if (Interop.Sys.GetIcmpv6GlobalStatistics(out statistics) != 0) + if (Interop.Sys.GetIcmpv6GlobalStatistics(&statistics) != 0) { throw new NetworkInformationException(SR.net_PInvokeError); } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdTcpStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdTcpStatistics.cs index ba8b649320539..4281467f07ac0 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdTcpStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdTcpStatistics.cs @@ -15,10 +15,10 @@ internal sealed class BsdTcpStatistics : TcpStatistics private readonly long _segmentsReceived; private readonly int _currentConnections; - public BsdTcpStatistics() + public unsafe BsdTcpStatistics() { Interop.Sys.TcpGlobalStatistics statistics; - if (Interop.Sys.GetTcpGlobalStatistics(out statistics) != 0) + if (Interop.Sys.GetTcpGlobalStatistics(&statistics) != 0) { throw new NetworkInformationException(SR.net_PInvokeError); } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdUdpStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdUdpStatistics.cs index c60a62173e6da..248afb771c665 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdUdpStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdUdpStatistics.cs @@ -13,10 +13,10 @@ internal sealed class BsdUdpStatistics : UdpStatistics private readonly long _incomingErrors; private readonly int _numListeners; - public BsdUdpStatistics() + public unsafe BsdUdpStatistics() { Interop.Sys.UdpGlobalStatistics statistics; - if (Interop.Sys.GetUdpGlobalStatistics(out statistics) == -1) + if (Interop.Sys.GetUdpGlobalStatistics(&statistics) == -1) { throw new NetworkInformationException(SR.net_PInvokeError); } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs index a44a3bb315d5e..d411e38bef2a6 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs @@ -79,7 +79,7 @@ public static unsafe NetworkInterface[] GetLinuxNetworkInterfaces() Interop.Sys.IpAddressInfo * ai = null; IntPtr globalMemory = (IntPtr)null; - if (Interop.Sys.GetNetworkInterfaces(ref interfaceCount, ref nii, ref addressCount, ref ai) != 0) + if (Interop.Sys.GetNetworkInterfaces(&interfaceCount, &nii, &addressCount, &ai) != 0) { string message = Interop.Sys.GetLastErrorInfo().GetErrorMessage(); throw new NetworkInformationException(message); diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs index 353ff91d40c2b..44604d57148d5 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs @@ -161,10 +161,10 @@ private static unsafe void CreateAndStartRunLoop() }, (UIntPtr)2)) { // Try to register our pattern strings with the dynamic store instance. - if (patterns.IsInvalid || !Interop.SystemConfiguration.SCDynamicStoreSetNotificationKeys( + if (patterns.IsInvalid || Interop.SystemConfiguration.SCDynamicStoreSetNotificationKeys( s_dynamicStoreRef.DangerousGetHandle(), IntPtr.Zero, - patterns.DangerousGetHandle())) + patterns.DangerousGetHandle()) == 0) { s_dynamicStoreRef.Dispose(); s_dynamicStoreRef = null; diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs index a0ad6c92bab7e..5d95e8b2b9733 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs @@ -138,11 +138,11 @@ public static event NetworkAvailabilityChangedEventHandler? NetworkAvailabilityC } } - private static void CreateSocket() + private static unsafe void CreateSocket() { Debug.Assert(s_socket == 0, "s_socket != 0, must close existing socket before opening another."); int newSocket; - Interop.Error result = Interop.Sys.CreateNetworkChangeListenerSocket(out newSocket); + Interop.Error result = Interop.Sys.CreateNetworkChangeListenerSocket(&newSocket); if (result != Interop.Error.SUCCESS) { string message = Interop.Sys.GetLastErrorInfo().GetErrorMessage(); diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs index dff0aad267f73..a15e1eff8351a 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs @@ -112,7 +112,7 @@ private unsafe List GetAllTcpConnections() if (Socket.OSSupportsIPv4) { // Get the buffer size needed. - result = Interop.IpHlpApi.GetTcpTable(IntPtr.Zero, ref size, true); + result = Interop.IpHlpApi.GetTcpTable(IntPtr.Zero, &size, order: 1); while (result == Interop.IpHlpApi.ERROR_INSUFFICIENT_BUFFER) { @@ -120,7 +120,7 @@ private unsafe List GetAllTcpConnections() IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetTcpTable(buffer, ref size, true); + result = Interop.IpHlpApi.GetTcpTable(buffer, &size, order: 1); if (result == Interop.IpHlpApi.ERROR_SUCCESS) { @@ -159,7 +159,7 @@ private unsafe List GetAllTcpConnections() { // Get the buffer size needed. size = 0; - result = Interop.IpHlpApi.GetExtendedTcpTable(IntPtr.Zero, ref size, true, + result = Interop.IpHlpApi.GetExtendedTcpTable(IntPtr.Zero, &size, order: 1, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0); @@ -169,7 +169,7 @@ private unsafe List GetAllTcpConnections() IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetExtendedTcpTable(buffer, ref size, true, + result = Interop.IpHlpApi.GetExtendedTcpTable(buffer, &size, order: 1, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0); if (result == Interop.IpHlpApi.ERROR_SUCCESS) @@ -221,7 +221,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() if (Socket.OSSupportsIPv4) { // Get the buffer size needed. - result = Interop.IpHlpApi.GetUdpTable(IntPtr.Zero, ref size, true); + result = Interop.IpHlpApi.GetUdpTable(IntPtr.Zero, &size, order: 1); while (result == Interop.IpHlpApi.ERROR_INSUFFICIENT_BUFFER) { // Allocate the buffer and get the UDP table. @@ -229,7 +229,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() try { - result = Interop.IpHlpApi.GetUdpTable(buffer, ref size, true); + result = Interop.IpHlpApi.GetUdpTable(buffer, &size, order: 1); if (result == Interop.IpHlpApi.ERROR_SUCCESS) { @@ -273,7 +273,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() { // Get the buffer size needed. size = 0; - result = Interop.IpHlpApi.GetExtendedUdpTable(IntPtr.Zero, ref size, true, + result = Interop.IpHlpApi.GetExtendedUdpTable(IntPtr.Zero, &size, order: 1, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0); while (result == Interop.IpHlpApi.ERROR_INSUFFICIENT_BUFFER) @@ -282,7 +282,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetExtendedUdpTable(buffer, ref size, true, + result = Interop.IpHlpApi.GetExtendedUdpTable(buffer, &size, order: 1, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0); diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs index e8838b31d0c24..353671e9b1897 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs @@ -12,17 +12,19 @@ internal sealed class SystemIPGlobalStatistics : IPGlobalStatistics private SystemIPGlobalStatistics() { } - internal SystemIPGlobalStatistics(AddressFamily family) + internal unsafe SystemIPGlobalStatistics(AddressFamily family) { - uint result = Interop.IpHlpApi.GetIpStatisticsEx(out _stats, family); - - if (result != Interop.IpHlpApi.ERROR_SUCCESS) + fixed (Interop.IpHlpApi.MibIpStats* pStats = &_stats) { - throw new NetworkInformationException((int)result); + uint result = Interop.IpHlpApi.GetIpStatisticsEx(pStats, family); + if (result != Interop.IpHlpApi.ERROR_SUCCESS) + { + throw new NetworkInformationException((int)result); + } } } - public override bool ForwardingEnabled { get { return _stats.forwardingEnabled; } } + public override bool ForwardingEnabled { get { return _stats.forwardingEnabled != 0; } } public override int DefaultTtl { get { return (int)_stats.defaultTtl; } } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs index 72accfe9f4514..7c455b47b455b 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs @@ -75,20 +75,20 @@ public override int Index } } - private void GetPerAdapterInfo(uint index) + private unsafe void GetPerAdapterInfo(uint index) { if (index != 0) { uint size = 0; - uint result = Interop.IpHlpApi.GetPerAdapterInfo(index, IntPtr.Zero, ref size); + uint result = Interop.IpHlpApi.GetPerAdapterInfo(index, IntPtr.Zero, &size); while (result == Interop.IpHlpApi.ERROR_BUFFER_OVERFLOW) { // Now we allocate the buffer and read the network parameters. IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetPerAdapterInfo(index, buffer, ref size); + result = Interop.IpHlpApi.GetPerAdapterInfo(index, buffer, &size); if (result == Interop.IpHlpApi.ERROR_SUCCESS) { Interop.IpHlpApi.IpPerAdapterInfo ipPerAdapterInfo = diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIcmpV4Statistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIcmpV4Statistics.cs index a2294d8ad5ef6..18f4dd555c267 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIcmpV4Statistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIcmpV4Statistics.cs @@ -8,9 +8,11 @@ internal sealed class SystemIcmpV4Statistics : IcmpV4Statistics { private readonly Interop.IpHlpApi.MibIcmpInfo _stats; - internal SystemIcmpV4Statistics() + internal unsafe SystemIcmpV4Statistics() { - uint result = Interop.IpHlpApi.GetIcmpStatistics(out _stats); + uint result; + fixed (Interop.IpHlpApi.MibIcmpInfo* pStats = &_stats) + result = Interop.IpHlpApi.GetIcmpStatistics(pStats); if (result != Interop.IpHlpApi.ERROR_SUCCESS) { diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs index f2196e3b79a4d..ed806788ae92d 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs @@ -42,14 +42,17 @@ internal static int InternalIPv6LoopbackInterfaceIndex } } - private static int GetBestInterfaceForAddress(IPAddress addr) + private static unsafe int GetBestInterfaceForAddress(IPAddress addr) { int index; Internals.SocketAddress address = new Internals.SocketAddress(addr); - int error = (int)Interop.IpHlpApi.GetBestInterfaceEx(address.Buffer, out index); - if (error != 0) + fixed (byte* buffer = address.Buffer) { - throw new NetworkInformationException(error); + int error = (int)Interop.IpHlpApi.GetBestInterfaceEx(buffer, &index); + if (error != 0) + { + throw new NetworkInformationException(error); + } } return index; @@ -77,7 +80,7 @@ internal static bool InternalGetIsNetworkAvailable() return false; } - internal static NetworkInterface[] GetNetworkInterfaces() + internal static unsafe NetworkInterface[] GetNetworkInterfaces() { AddressFamily family = AddressFamily.Unspecified; uint bufferSize = 0; @@ -91,7 +94,7 @@ internal static NetworkInterface[] GetNetworkInterfaces() // Figure out the right buffer size for the adapter information. uint result = Interop.IpHlpApi.GetAdaptersAddresses( - family, (uint)flags, IntPtr.Zero, IntPtr.Zero, ref bufferSize); + family, (uint)flags, IntPtr.Zero, IntPtr.Zero, &bufferSize); while (result == Interop.IpHlpApi.ERROR_BUFFER_OVERFLOW) { @@ -101,7 +104,7 @@ internal static NetworkInterface[] GetNetworkInterfaces() try { result = Interop.IpHlpApi.GetAdaptersAddresses( - family, (uint)flags, IntPtr.Zero, buffer, ref bufferSize); + family, (uint)flags, IntPtr.Zero, buffer, &bufferSize); // If succeeded, we're going to add each new interface. if (result == Interop.IpHlpApi.ERROR_SUCCESS) diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemTcpStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemTcpStatistics.cs index 32453ce74c6a3..9f276ed0ffcc8 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemTcpStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemTcpStatistics.cs @@ -12,13 +12,15 @@ internal sealed class SystemTcpStatistics : TcpStatistics private SystemTcpStatistics() { } - internal SystemTcpStatistics(AddressFamily family) + internal unsafe SystemTcpStatistics(AddressFamily family) { - uint result = Interop.IpHlpApi.GetTcpStatisticsEx(out _stats, family); - - if (result != Interop.IpHlpApi.ERROR_SUCCESS) + fixed (Interop.IpHlpApi.MibTcpStats* pStats = &_stats) { - throw new NetworkInformationException((int)result); + uint result = Interop.IpHlpApi.GetTcpStatisticsEx(pStats, family); + if (result != Interop.IpHlpApi.ERROR_SUCCESS) + { + throw new NetworkInformationException((int)result); + } } } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemUdpStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemUdpStatistics.cs index 20869e1f8c684..5827702b07022 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemUdpStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemUdpStatistics.cs @@ -12,13 +12,15 @@ internal sealed class SystemUdpStatistics : UdpStatistics private SystemUdpStatistics() { } - internal SystemUdpStatistics(AddressFamily family) + internal unsafe SystemUdpStatistics(AddressFamily family) { - uint result = Interop.IpHlpApi.GetUdpStatisticsEx(out _stats, family); - - if (result != Interop.IpHlpApi.ERROR_SUCCESS) + fixed (Interop.IpHlpApi.MibUdpStats* pStats = &_stats) { - throw new NetworkInformationException((int)result); + uint result = Interop.IpHlpApi.GetUdpStatisticsEx(pStats, family); + if (result != Interop.IpHlpApi.ERROR_SUCCESS) + { + throw new NetworkInformationException((int)result); + } } } From f0e38449a1b782a2f4b80fff150f52f17e5ea91f Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 10 Jun 2021 12:08:05 -0700 Subject: [PATCH 111/161] Use GeneratedDllImport in System.IO.MemoryMappedFiles (#53978) --- .../Interop/Unix/System.Native/Interop.FTruncate.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.MAdvise.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.MMap.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.MSync.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.MUnmap.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.ShmOpen.cs | 8 ++++---- .../Windows/Kernel32/Interop.CreateFileMapping.cs | 10 ++++++++++ .../Windows/Kernel32/Interop.FlushViewOfFile.cs | 4 ++-- .../Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs | 2 +- .../Interop/Windows/Kernel32/Interop.MapViewOfFile.cs | 5 +++++ .../Windows/Kernel32/Interop.OpenFileMapping.cs | 10 +++++++++- .../Windows/Kernel32/Interop.UnmapViewOfFile.cs | 5 +++++ .../Interop/Windows/Kernel32/Interop.VirtualAlloc.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.VirtualQuery.cs | 10 +++++++++- .../src/System/IO/MemoryMappedFiles/Interop.Windows.cs | 2 +- .../src/System/Runtime/MemoryFailPoint.Windows.cs | 2 +- .../System/Runtime/Caching/MemoryMonitor.Windows.cs | 2 +- .../Runtime/Caching/PhysicalMemoryMonitor.Windows.cs | 2 +- 18 files changed, 61 insertions(+), 25 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FTruncate.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FTruncate.cs index f7a726f904203..b8367261ffdc9 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FTruncate.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FTruncate.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FTruncate", SetLastError = true)] - internal static extern int FTruncate(SafeFileHandle fd, long length); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FTruncate", SetLastError = true)] + internal static partial int FTruncate(SafeFileHandle fd, long length); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MAdvise.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MAdvise.cs index 539e27a04e3c1..5ac7aa1fc4d6a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MAdvise.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MAdvise.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MAdvise", SetLastError = true)] - internal static extern int MAdvise(IntPtr addr, ulong length, MemoryAdvice advice); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MAdvise", SetLastError = true)] + internal static partial int MAdvise(IntPtr addr, ulong length, MemoryAdvice advice); internal enum MemoryAdvice { diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MMap.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MMap.cs index f75065210307a..5789ee734d45e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MMap.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MMap.cs @@ -28,8 +28,8 @@ internal enum MemoryMappedFlags } // NOTE: Shim returns null pointer on failure, not non-null MAP_FAILED sentinel. - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MMap", SetLastError = true)] - internal static extern IntPtr MMap( + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MMap", SetLastError = true)] + internal static partial IntPtr MMap( IntPtr addr, ulong len, MemoryMappedProtections prot, MemoryMappedFlags flags, SafeFileHandle fd, long offset); diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MSync.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MSync.cs index d486c36811c61..78263cbdd6af6 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MSync.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MSync.cs @@ -16,7 +16,7 @@ internal enum MemoryMappedSyncFlags MS_INVALIDATE = 0x10, } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MSync", SetLastError = true)] - internal static extern int MSync(IntPtr addr, ulong len, MemoryMappedSyncFlags flags); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MSync", SetLastError = true)] + internal static partial int MSync(IntPtr addr, ulong len, MemoryMappedSyncFlags flags); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MUnmap.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MUnmap.cs index fffd3fb941fdc..a0ed69251cc00 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MUnmap.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MUnmap.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MUnmap", SetLastError = true)] - internal static extern int MUnmap(IntPtr addr, ulong len); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MUnmap", SetLastError = true)] + internal static partial int MUnmap(IntPtr addr, ulong len); } } 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 f4749b8a5f7be..5ebd90191cf33 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 { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmOpen", SetLastError = true)] - internal static extern SafeFileHandle ShmOpen(string name, OpenFlags flags, int mode); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmOpen", SetLastError = true, CharSet = CharSet.Ansi)] + internal static partial SafeFileHandle ShmOpen(string name, OpenFlags flags, int mode); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", SetLastError = true)] - internal static extern int ShmUnlink(string name); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", SetLastError = true, CharSet = CharSet.Ansi)] + internal static partial int ShmUnlink(string name); } } 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 cc85cc91756ba..81ffec311fbc6 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs @@ -10,8 +10,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SafeMemoryMappedFileHandle CreateFileMapping( +#else [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern SafeMemoryMappedFileHandle CreateFileMapping( +#endif SafeFileHandle hFile, ref SECURITY_ATTRIBUTES lpFileMappingAttributes, int flProtect, @@ -19,8 +24,13 @@ internal static extern SafeMemoryMappedFileHandle CreateFileMapping( int dwMaximumSizeLow, string? lpName); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SafeMemoryMappedFileHandle CreateFileMapping( +#else [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern SafeMemoryMappedFileHandle CreateFileMapping( +#endif IntPtr hFile, ref SECURITY_ATTRIBUTES lpFileMappingAttributes, int flProtect, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushViewOfFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushViewOfFile.cs index ce82cfa23c33d..72a0560fa1f79 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushViewOfFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FlushViewOfFile.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool FlushViewOfFile(IntPtr lpBaseAddress, UIntPtr dwNumberOfBytesToFlush); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool FlushViewOfFile(IntPtr lpBaseAddress, UIntPtr dwNumberOfBytesToFlush); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs index a5029f5ccb6e8..5b44e735fea7e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs @@ -8,6 +8,6 @@ internal static partial class Interop internal static partial class Kernel32 { [DllImport(Libraries.Kernel32)] - internal static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer); + internal static unsafe extern int GlobalMemoryStatusEx(MEMORYSTATUSEX* lpBuffer); } } 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 73f714d64164c..764a6ad8080a9 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SafeMemoryMappedViewHandle MapViewOfFile( +#else [DllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern SafeMemoryMappedViewHandle MapViewOfFile( +#endif SafeMemoryMappedFileHandle hFileMappingObject, int dwDesiredAccess, int dwFileOffsetHigh, 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 70e3075e816c4..6ac60a8fa558f 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,15 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial SafeMemoryMappedFileHandle OpenFileMapping( +#else [DllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern SafeMemoryMappedFileHandle OpenFileMapping(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, string lpName); + internal static extern SafeMemoryMappedFileHandle OpenFileMapping( +#endif + int dwDesiredAccess, + [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, + string lpName); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs index 55d3b8eeb49b5..dd519a7f1f87f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool UnmapViewOfFile(IntPtr lpBaseAddress); +#else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool UnmapViewOfFile(IntPtr lpBaseAddress); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs index 19f93d2791dd0..02bcf91db320d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] - internal static extern IntPtr VirtualAlloc(SafeHandle lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + internal static partial IntPtr VirtualAlloc(SafeHandle lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs index 25e3fd62b0dad..856191602bda2 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs @@ -8,7 +8,15 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + internal static partial UIntPtr VirtualQuery( +#else [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] - internal static extern UIntPtr VirtualQuery(SafeHandle lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength); + internal static extern UIntPtr VirtualQuery( +#endif + SafeHandle lpAddress, + ref MEMORY_BASIC_INFORMATION lpBuffer, + UIntPtr dwLength); } } diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/Interop.Windows.cs b/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/Interop.Windows.cs index 202c3ead180f2..e232953aab103 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/Interop.Windows.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/Interop.Windows.cs @@ -13,7 +13,7 @@ public static unsafe void CheckForAvailableVirtualMemory(ulong nativeSize) { Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default; memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX); - if (Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus)) + if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) != 0) { ulong totalVirtual = memoryStatus.ullTotalVirtual; if (nativeSize >= totalVirtual) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs index 052c26bec44e3..e2f0ac6013023 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs @@ -22,7 +22,7 @@ private static unsafe bool CheckForAvailableMemory(out ulong availPageFile, out { Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default; memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX); - if (!Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus)) + if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) == 0) { availPageFile = default; totalAddressSpaceFree = default; diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.Windows.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.Windows.cs index 189a9460d32c5..8ee2de3ecf60f 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.Windows.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.Windows.cs @@ -16,7 +16,7 @@ static unsafe MemoryMonitor() { Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default; memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX); - if (Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus)) + if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) != 0) { s_totalPhysical = (long)memoryStatus.ullTotalPhys; s_totalVirtual = (long)memoryStatus.ullTotalVirtual; diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/PhysicalMemoryMonitor.Windows.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/PhysicalMemoryMonitor.Windows.cs index 078bf9ed3794e..8dacfaa5a853a 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/PhysicalMemoryMonitor.Windows.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/PhysicalMemoryMonitor.Windows.cs @@ -14,7 +14,7 @@ protected override unsafe int GetCurrentPressure() { Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default; memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX); - if (!Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus)) + if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) == 0) { return 0; } From e1cab8073ec669569502751e95fe956d6b8e7668 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 10 Jun 2021 12:36:03 -0700 Subject: [PATCH 112/161] Use DLLIMPORTGENERATOR_ENABLED ifdefs for files shared with Microsoft.IO.Redist (#53954) --- .../Windows/Advapi32/Interop.EncryptDecrypt.cs | 14 +++++++++++++- .../Windows/Kernel32/Interop.CopyFileEx.cs | 5 +++++ .../Windows/Kernel32/Interop.CreateFile_IntPtr.cs | 5 +++++ .../Windows/Kernel32/Interop.DeleteFile.cs | 5 +++++ .../Kernel32/Interop.DeleteVolumeMountPoint.cs | 6 +++++- .../Windows/Kernel32/Interop.GetLogicalDrives.cs | 5 +++++ .../Kernel32/Interop.GetVolumeInformation.cs | 15 ++++++++++++++- .../Windows/Kernel32/Interop.MoveFileEx.cs | 8 +++++++- .../Windows/Kernel32/Interop.RemoveDirectory.cs | 5 +++++ .../Windows/Kernel32/Interop.ReplaceFile.cs | 5 +++++ .../Windows/Kernel32/Interop.SetFileAttributes.cs | 9 ++++++++- .../Interop.SetFileInformationByHandle.cs | 11 ++++++++++- 12 files changed, 87 insertions(+), 6 deletions(-) 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 8d627e5b5b312..ace11221bddd8 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs @@ -11,8 +11,13 @@ internal static partial class Advapi32 /// /// WARNING: This method does not implicitly handle long paths. Use EncryptFile. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] private static partial bool EncryptFilePrivate(string lpFileName); +#else + [DllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool EncryptFilePrivate(string lpFileName); +#endif internal static bool EncryptFile(string path) { @@ -23,8 +28,15 @@ internal static bool EncryptFile(string path) /// /// WARNING: This method does not implicitly handle long paths. Use DecryptFile. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] - private static partial bool DecryptFileFilePrivate(string lpFileName, int dwReserved); + private static partial bool DecryptFileFilePrivate( +#else + [DllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool DecryptFileFilePrivate( +#endif + string lpFileName, + int dwReserved); internal static bool DecryptFile(string path) { 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 176c0104f4432..c878ec9ca1f20 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs @@ -12,8 +12,13 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CopyFileEx. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode)] private static partial bool CopyFileExPrivate( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool CopyFileExPrivate( +#endif string src, string dst, IntPtr progressRoutine, 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 fe47b09542184..cc3bee28befd7 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,8 +12,13 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] private static unsafe partial IntPtr CreateFilePrivate_IntPtr( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + private static unsafe extern IntPtr CreateFilePrivate_IntPtr( +#endif string lpFileName, int dwDesiredAccess, FileShare dwShareMode, 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 decf6d7734483..41f2e58cdf767 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs @@ -12,8 +12,13 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use DeleteFile. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode)] private static partial bool DeleteFilePrivate(string path); +#else + [DllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool DeleteFilePrivate(string path); +#endif 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 7910be508418c..9461da826576b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs @@ -12,9 +12,13 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use DeleteVolumeMountPoint. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode)] internal static partial bool DeleteVolumeMountPointPrivate(string mountPoint); - +#else + [DllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern bool DeleteVolumeMountPointPrivate(string mountPoint); +#endif internal static bool DeleteVolumeMountPoint(string mountPoint) { diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs index f084be9926b40..c756043141c59 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs @@ -7,7 +7,12 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] internal static partial int GetLogicalDrives(); +#else + [DllImport(Libraries.Kernel32, SetLastError = true)] + internal static extern int GetLogicalDrives(); +#endif } } 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 67b8dee9144bd..05a2b6357cc40 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetVolumeInformation.cs @@ -8,8 +8,21 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static unsafe partial bool GetVolumeInformation(string drive, char* volumeName, int volumeNameBufLen, int* volSerialNumber, int* maxFileNameLen, out int fileSystemFlags, char* fileSystemName, int fileSystemNameBufLen); + internal static unsafe partial bool GetVolumeInformation( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe extern bool GetVolumeInformation( +#endif + string drive, + char* volumeName, + int volumeNameBufLen, + int* volSerialNumber, + int* maxFileNameLen, + out int fileSystemFlags, + char* fileSystemName, + int fileSystemNameBufLen); internal const uint FILE_SUPPORTS_ENCRYPTION = 0x00020000; } 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 389e7b91de62b..a0b3a39b6bde0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs @@ -15,8 +15,14 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use MoveFile. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode)] - private static partial bool MoveFileExPrivate(string src, string dst, uint flags); + private static partial bool MoveFileExPrivate( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool MoveFileExPrivate( +#endif + string src, string dst, uint flags); /// /// Moves a file or directory, optionally overwriting existing destination file. NOTE: overwrite must be false for directories. 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 058894972e5b6..f1a6683cace38 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs @@ -12,8 +12,13 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use RemoveDirectory. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] private static partial bool RemoveDirectoryPrivate(string path); +#else + [DllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool RemoveDirectoryPrivate(string path); +#endif 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 b29552d677edf..051f6c6295696 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs @@ -9,8 +9,13 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode)] private static partial bool ReplaceFilePrivate( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool ReplaceFilePrivate( +#endif string replacedFileName, string replacementFileName, string? backupFileName, int dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved); 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 77a8bf70ae45c..03de746fce808 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs @@ -11,8 +11,15 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use SetFileAttributes. /// +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode)] - private static partial bool SetFileAttributesPrivate(string name, int attr); + private static partial bool SetFileAttributesPrivate( +#else + [DllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool SetFileAttributesPrivate( +#endif + string name, + int attr); internal static bool SetFileAttributes(string name, int attr) { diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs index 18b658039d5ea..9987aeccbebe4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs @@ -9,7 +9,16 @@ internal static partial class Interop { internal static partial class Kernel32 { +#if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] - internal static unsafe partial bool SetFileInformationByHandle(SafeFileHandle hFile, int FileInformationClass, void* lpFileInformation, uint dwBufferSize); + internal static unsafe partial bool SetFileInformationByHandle( +#else + [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + internal static unsafe extern bool SetFileInformationByHandle( +#endif + SafeFileHandle hFile, + int FileInformationClass, + void* lpFileInformation, + uint dwBufferSize); } } From 2f50d9529e0c696bec9f20bf0ee613b60266116d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 10 Jun 2021 13:38:57 -0700 Subject: [PATCH 113/161] Enable marshalling collections of types with marshallers that have a Value property (dotnet/runtimelab#1216) Commit migrated from https://github.com/dotnet/runtimelab/commit/c1562420e508e4939f138cc9d5145a8c43fa7afc --- .../libraries/DllImportGenerator/Pipeline.md | 20 +-- ...CollectionElementMarshallingCodeContext.cs | 20 +-- .../Marshalling/ArrayMarshaller.cs | 4 +- .../Marshalling/BlittableMarshaller.cs | 6 +- ...nditionalStackallocMarshallingGenerator.cs | 29 ++-- .../Marshalling/DelegateMarshaller.cs | 9 +- .../ICustomNativeTypeMarshallingStrategy.cs | 152 +++++++++++++----- .../Marshalling/MarshallerHelpers.cs | 5 +- .../Marshalling/MarshallingGenerator.cs | 26 +-- .../PinnableManagedValueMarshaller.cs | 2 +- .../Marshalling/StringMarshaller.Ansi.cs | 2 +- .../Marshalling/StringMarshaller.Utf16.cs | 4 +- .../DllImportGenerator/Resources.Designer.cs | 9 -- .../gen/DllImportGenerator/Resources.resx | 3 - .../gen/DllImportGenerator/StubCodeContext.cs | 31 ++-- .../DllImportGenerator/StubCodeGenerator.cs | 6 +- .../CollectionTests.cs | 71 ++++++++ .../CompileFails.cs | 3 - .../DllImportGenerator.UnitTests/Compiles.cs | 1 + 19 files changed, 260 insertions(+), 143 deletions(-) diff --git a/docs/design/libraries/DllImportGenerator/Pipeline.md b/docs/design/libraries/DllImportGenerator/Pipeline.md index c32f0fdee8819..6ae109b26cbd8 100644 --- a/docs/design/libraries/DllImportGenerator/Pipeline.md +++ b/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -120,24 +120,24 @@ Some marshalling optimizations are only available in specific scenarios. General This experiment generally is currently only focusing on two of the concepts: P/Invoke and non-blittable array marshalling (in the context of a P/Invoke). -There are three categories for specialized marshalling features that may only be available in some contexts: +There are three features for specialized marshalling features that may only be available in some contexts: - Pinning to marshal data without copying (the `fixed` statement) - Stack allocation across the native context (using the `stackalloc` keyword or https://github.com/dotnet/runtime/issues/25423) - Storing additional temporary state in extra local variables -Support for these features is indicated in code by various `bool` properties on the `StubCodeContext`-derived type. +Support for these features is indicated in code by the `abstract` `SingleFrameSpansNativeContext` and `AdditionalTemporaryStateLivesAcrossStages` properties on the `StubCodeContext` type. The `SingleFrameSpansNativeContext` property represents whether or not both pinning and stack-allocation are supported. These concepts are combined because we cannot safely support a conditional-stackalloc style API (such as https://github.com/dotnet/runtime/issues/52065) and safely get a pointer to data without also being able to pin. -These various scenarios have different levels of support for these three features: +The various scenarios mentioned above have different levels of support for these specialized features: - -| Scenarios |Pinning | Stack allocation across the native context | Storing additional temporary state in locals | +| Scenarios |Pinning and Stack allocation across the native context | Storing additional temporary state in locals | |------|-----|-----|---------| -| P/Invoke | supported | supported | supported | -| Reverse P/Invoke | unsupported | unsupported | supported | -| User-defined structures | unsupported | unsupported for individual members | unsupported | -| non-blittable array marshalling in a P/Invoke | unsupported | unsupported (supportable with https://github.com/dotnet/runtime/issues/25423) | unuspported | -| non-blittable array marshalling not in a P/Invoke | unsupported | unsupported | unuspported | +| P/Invoke | supported | supported | +| Reverse P/Invoke | unsupported | supported | +| User-defined structure content marshalling | unsupported | unsupported | +| non-blittable array marshalling | unsupported | unuspported | + +To help enable developers to use the full model described in the [Struct Marshalling design](./StructMarshalling.md), we declare that in contexts where `AdditionalTemporaryStateLivesAcrossStages` is false, developers can still assume that state declared in the `Setup` phase is valid in any phase, but any side effects in code emitted in a phase other than `Setup` will not be guaranteed to be visible in other phases. This enables developers to still use the identifiers declared in the `Setup` phase in their other phases, but they'll need to take care to design their generators to handle these rules. ### `SetLastError=true` diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs index 89c3b03590deb..06f6ef4088955 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs @@ -16,20 +16,9 @@ internal sealed class ContiguousCollectionElementMarshallingCodeContext : StubCo private readonly string nativeSpanIdentifier; private readonly StubCodeContext parentContext; - public override bool PinningSupported => false; + public override bool SingleFrameSpansNativeContext => false; - public override bool StackSpaceUsable => false; - - /// - /// Additional variables other than the {managedIdentifier} and {nativeIdentifier} variables - /// can be added to the stub to track additional state for the marshaller in the stub. - /// - /// - /// Currently, collection scenarios do not support declaring additional temporary variables to support - /// marshalling. This can be accomplished in the future with some additional infrastructure to support - /// declaring additional arrays in the stub to support the temporary state. - /// - public override bool CanUseAdditionalTemporaryState => false; + public override bool AdditionalTemporaryStateLivesAcrossStages => false; /// /// Create a for marshalling elements of an collection. @@ -64,6 +53,11 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo ); } + public override string GetAdditionalIdentifier(TypePositionInfo info, string name) + { + return $"{nativeSpanIdentifier}__{indexerIdentifier}__{name}"; + } + public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) { // We don't have parameters to look at when we're in the middle of marshalling an array. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs index cb6abc7447114..46af295b524b9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs @@ -52,7 +52,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) { - if (context.PinningSupported && enablePinning) + if (context.SingleFrameSpansNativeContext && enablePinning) { return false; } @@ -70,7 +70,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) private bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) { - return context.PinningSupported && enablePinning && !info.IsByRef && !info.IsManagedReturnPosition; + return context.SingleFrameSpansNativeContext && enablePinning && !info.IsByRef && !info.IsManagedReturnPosition; } private IEnumerable GeneratePinningPath(TypePositionInfo info, StubCodeContext context) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs index df59478466fa4..0f158706cd038 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs @@ -29,7 +29,7 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { return Argument(IdentifierName(info.InstanceIdentifier)); } - else if (context.PinningSupported && !info.IsManagedReturnPosition) + else if (context.SingleFrameSpansNativeContext && !info.IsManagedReturnPosition) { return Argument(IdentifierName(context.GetIdentifiers(info).native)); @@ -47,7 +47,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); - if (context.PinningSupported) + if (context.SingleFrameSpansNativeContext) { if (context.CurrentStage == StubCodeContext.Stage.Pin) { @@ -97,7 +97,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return info.IsByRef && !info.IsManagedReturnPosition && !context.PinningSupported; + return info.IsByRef && !info.IsManagedReturnPosition && !context.SingleFrameSpansNativeContext; } public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs index f071d153d9bbb..2994ec8df75c6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -8,18 +8,18 @@ namespace Microsoft.Interop { internal abstract class ConditionalStackallocMarshallingGenerator : IMarshallingGenerator { - protected static string GetAllocationMarkerIdentifier(string managedIdentifier) => $"{managedIdentifier}__allocated"; + protected static string GetAllocationMarkerIdentifier(TypePositionInfo info, StubCodeContext context) => context.GetAdditionalIdentifier(info, "allocated"); - private static string GetByteLengthIdentifier(string managedIdentifier) => $"{managedIdentifier}__bytelen"; + private static string GetByteLengthIdentifier(TypePositionInfo info, StubCodeContext context) => context.GetAdditionalIdentifier(info, "bytelen"); - private static string GetStackAllocIdentifier(string managedIdentifier) => $"{managedIdentifier}__stackptr"; + private static string GetStackAllocIdentifier(TypePositionInfo info, StubCodeContext context) => context.GetAdditionalIdentifier(info, "stackptr"); protected bool UsesConditionalStackAlloc(TypePositionInfo info, StubCodeContext context) { - return context.CanUseAdditionalTemporaryState - && context.StackSpaceUsable + return context.SingleFrameSpansNativeContext && (!info.IsByRef || info.RefKind == RefKind.In) - && !info.IsManagedReturnPosition; + && !info.IsManagedReturnPosition + && context.AdditionalTemporaryStateLivesAcrossStages; } protected bool TryGenerateSetupSyntax(TypePositionInfo info, StubCodeContext context, out StatementSyntax statement) @@ -29,7 +29,7 @@ protected bool TryGenerateSetupSyntax(TypePositionInfo info, StubCodeContext con if (!UsesConditionalStackAlloc(info, context)) return false; - string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(context.GetIdentifiers(info).managed); + string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(info, context); // bool = false; statement = LocalDeclarationStatement( @@ -46,11 +46,11 @@ protected IEnumerable GenerateConditionalAllocationSyntax( StubCodeContext context, int stackallocMaxSize) { - (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + (_, string nativeIdentifier) = context.GetIdentifiers(info); - string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(managedIdentifier); - string byteLenIdentifier = GetByteLengthIdentifier(managedIdentifier); - string stackAllocPtrIdentifier = GetStackAllocIdentifier(managedIdentifier); + string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(info, context); + string byteLenIdentifier = GetByteLengthIdentifier(info, context); + string stackAllocPtrIdentifier = GetStackAllocIdentifier(info, context); // = ; var allocationStatement = ExpressionStatement( AssignmentExpression( @@ -62,7 +62,7 @@ protected IEnumerable GenerateConditionalAllocationSyntax( var byteLenAssignment = LocalDeclarationStatement( VariableDeclaration( PredefinedType(Token(SyntaxKind.IntKeyword)), - SingletonSeparatedList( + SingletonSeparatedList( VariableDeclarator(byteLenIdentifier) .WithInitializer(EqualsValueClause( GenerateByteLengthCalculationExpression(info, context)))))); @@ -96,7 +96,7 @@ protected IEnumerable GenerateConditionalAllocationSyntax( StackAllocArrayCreationExpression( ArrayType( PredefinedType(Token(SyntaxKind.ByteKeyword)), - SingletonList( + SingletonList( ArrayRankSpecifier(SingletonSeparatedList( IdentifierName(byteLenIdentifier))))))))))), GenerateStackallocOnlyValueMarshalling(info, context, Identifier(byteLenIdentifier), Identifier(stackAllocPtrIdentifier)), @@ -143,8 +143,7 @@ protected StatementSyntax GenerateConditionalAllocationFreeSyntax( TypePositionInfo info, StubCodeContext context) { - (string managedIdentifier, _) = context.GetIdentifiers(info); - string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(managedIdentifier); + string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(info, context); if (!UsesConditionalStackAlloc(info, context)) { return ExpressionStatement(GenerateFreeExpression(info, context)); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs index b874ba0d1c6b5..21a5c80d4cca9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs @@ -10,7 +10,7 @@ internal class DelegateMarshaller : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { - return ParseTypeName("global::System.IntPtr"); + return MarshallerHelpers.SystemIntPtrType; } public ParameterSyntax AsParameter(TypePositionInfo info) @@ -60,7 +60,10 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont LiteralExpression(SyntaxKind.NullLiteralExpression) ), InvocationExpression( - ParseName("global::System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate"), + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_Marshal), + IdentifierName("GetFunctionPointerForDelegate")), ArgumentList(SingletonSeparatedList(Argument(IdentifierName(managedIdentifier))))), LiteralExpression(SyntaxKind.DefaultLiteralExpression)))); } @@ -81,7 +84,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseName("global::System.Runtime.InteropServices.Marshal"), + ParseName(TypeNames.System_Runtime_InteropServices_Marshal), GenericName(Identifier("GetDelegateForFunctionPointer")) .WithTypeArgumentList( TypeArgumentList( diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs index 283afaf60669d..6b5f25df7f0a1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -134,11 +135,9 @@ public CustomNativeTypeWithValuePropertyStubContext(StubCodeContext parentContex CurrentStage = parentContext.CurrentStage; } - public override bool PinningSupported => parentContext.PinningSupported; + public override bool SingleFrameSpansNativeContext => parentContext.SingleFrameSpansNativeContext; - public override bool StackSpaceUsable => parentContext.StackSpaceUsable; - - public override bool CanUseAdditionalTemporaryState => parentContext.CanUseAdditionalTemporaryState; + public override bool AdditionalTemporaryStateLivesAcrossStages => parentContext.AdditionalTemporaryStateLivesAcrossStages; public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) { @@ -192,7 +191,19 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - return innerMarshaller.GenerateCleanupStatements(info, subContext); + + // When temporary state does not live across stages, the marshaller state is uninitialized + // in any stage other than Marshal and Unmarshal. So, we need to reinitialize it here in Cleanup + // from the native value so we can safely run any cleanup functionality in the marshaller. + if (!context.AdditionalTemporaryStateLivesAcrossStages) + { + yield return GenerateValuePropertyAssignment(info, context, subContext); + } + + foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, subContext)) + { + yield return statement; + } } public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) @@ -213,18 +224,23 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)))); } - public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + private StatementSyntax GenerateValuePropertyAssignment(TypePositionInfo info, StubCodeContext context, CustomNativeTypeWithValuePropertyStubContext subContext) { - var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - // .Value = ; - yield return ExpressionStatement( + return ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName(subContext.GetIdentifiers(info).native), IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)), IdentifierName(context.GetIdentifiers(info).native))); + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + + yield return GenerateValuePropertyAssignment(info, context, subContext); foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, subContext)) { @@ -317,12 +333,12 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i private static bool StackAllocOptimizationValid(TypePositionInfo info, StubCodeContext context) { - return context.StackSpaceUsable && context.PinningSupported && (!info.IsByRef || info.RefKind == RefKind.In); + return context.SingleFrameSpansNativeContext && (!info.IsByRef || info.RefKind == RefKind.In); } private static string GetStackAllocPointerIdentifier(TypePositionInfo info, StubCodeContext context) { - return $"{context.GetIdentifiers(info).managed}__stackptr"; + return context.GetAdditionalIdentifier(info, "stackptr"); } public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) @@ -454,7 +470,7 @@ public PinnableMarshallerTypeMarshalling(ICustomNativeTypeMarshallingStrategy in private bool CanPinMarshaller(TypePositionInfo info, StubCodeContext context) { - return context.PinningSupported && !info.IsManagedReturnPosition && !info.IsByRef || info.RefKind == RefKind.In; + return context.SingleFrameSpansNativeContext && !info.IsManagedReturnPosition && !info.IsByRef || info.RefKind == RefKind.In; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -470,7 +486,17 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - return innerMarshaller.GenerateCleanupStatements(info, subContext); + + if (!CanPinMarshaller(info, context) && !context.AdditionalTemporaryStateLivesAcrossStages) + { + // .Value = ; + yield return GenerateValuePropertyAssignment(info, context, subContext); + } + + foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, subContext)) + { + yield return statement; + } } public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) @@ -529,6 +555,18 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf } } + private StatementSyntax GenerateValuePropertyAssignment(TypePositionInfo info, StubCodeContext context, CustomNativeTypeWithValuePropertyStubContext subContext) + { + // .Value = ; + return ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(subContext.GetIdentifiers(info).native), + IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)), + IdentifierName(context.GetIdentifiers(info).native))); + } + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); @@ -536,13 +574,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo if (!CanPinMarshaller(info, context)) { // .Value = ; - yield return ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(subContext.GetIdentifiers(info).native), - IdentifierName(ManualTypeMarshallingHelper.ValuePropertyName)), - IdentifierName(context.GetIdentifiers(info).native))); + yield return GenerateValuePropertyAssignment(info, context, subContext); } foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, subContext)) @@ -553,7 +585,8 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); + return innerMarshaller.GetNativeTypeConstructorArguments(info, subContext); } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) @@ -594,7 +627,21 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateCleanupStatements(info, context); + // When temporary state does not live across stages, the marshaller state is uninitialized + // in any stage other than Marshal and Unmarshal. So, we need to reinitialize it here in Cleanup + // from the native data so we can safely run any cleanup functionality in the marshaller. + if (!context.AdditionalTemporaryStateLivesAcrossStages) + { + foreach (var statement in GenerateUnmarshallerCollectionInitialization(info, context)) + { + yield return statement; + } + } + + foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, context)) + { + yield return statement; + } } public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) @@ -612,7 +659,7 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf return innerMarshaller.GenerateSetupStatements(info, context); } - public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + private IEnumerable GenerateUnmarshallerCollectionInitialization(TypePositionInfo info, StubCodeContext context) { string marshalerIdentifier = MarshallerHelpers.GetMarshallerIdentifier(info, context); if (info.RefKind == RefKind.Out || info.IsManagedReturnPosition) @@ -632,6 +679,19 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo IdentifierName(ManualTypeMarshallingHelper.SetUnmarshalledCollectionLengthMethodName))) .AddArgumentListArguments(Argument(numElementsExpression))); } + } + + public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) + { + // To fulfill the generic contiguous collection marshaller design, + // we need to emit code to initialize the collection marshaller with the size of native elements + // and set the unmanaged collection length before we marshal back the native data. + // This ensures that the marshaller object has enough state to successfully set up the ManagedValues + // and NativeValueStorage spans when the actual collection value is unmarshalled from native to the marshaller. + foreach (var statement in GenerateUnmarshallerCollectionInitialization(info, context)) + { + yield return statement; + } foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) { @@ -816,7 +876,7 @@ public ContiguousNonBlittableElementCollectionMarshalling(ICustomNativeTypeMarsh private string GetNativeSpanIdentifier(TypePositionInfo info, StubCodeContext context) { - return context.GetIdentifiers(info).managed + "__nativeSpan"; + return context.GetAdditionalIdentifier(info, "nativeSpan"); } private LocalDeclarationStatementSyntax GenerateNativeSpanDeclaration(TypePositionInfo info, StubCodeContext context) @@ -856,6 +916,11 @@ private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo in { string nativeIdentifier = context.GetIdentifiers(info).native; string nativeSpanIdentifier = GetNativeSpanIdentifier(info, context); + var elementSetupSubContext = new ContiguousCollectionElementMarshallingCodeContext( + StubCodeContext.Stage.Setup, + IndexerIdentifier, + nativeSpanIdentifier, + context); var elementSubContext = new ContiguousCollectionElementMarshallingCodeContext( context.CurrentStage, IndexerIdentifier, @@ -874,22 +939,27 @@ private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo in NativeIndex = info.NativeIndex }; - StatementSyntax marshallingStatement = Block( - List(elementMarshaller.Generate( - localElementInfo, - elementSubContext))); + List elementStatements = elementMarshaller.Generate(localElementInfo, elementSubContext).ToList(); - if (elementMarshaller.AsNativeType(elementInfo) is PointerTypeSyntax) + if (elementStatements.Any()) { - PointerNativeTypeAssignmentRewriter rewriter = new(elementSubContext.GetIdentifiers(localElementInfo).native); - marshallingStatement = (StatementSyntax)rewriter.Visit(marshallingStatement); - } + StatementSyntax marshallingStatement = Block( + List(elementMarshaller.Generate(localElementInfo, elementSetupSubContext) + .Concat(elementStatements))); + + if (elementMarshaller.AsNativeType(elementInfo) is PointerTypeSyntax elementNativeType) + { + PointerNativeTypeAssignmentRewriter rewriter = new(elementSubContext.GetIdentifiers(localElementInfo).native, elementNativeType); + marshallingStatement = (StatementSyntax)rewriter.Visit(marshallingStatement); + } - // Iterate through the elements of the native collection to unmarshal them - return Block( - GenerateNativeSpanDeclaration(info, context), - MarshallerHelpers.GetForLoop(collectionIdentifierForLength, IndexerIdentifier) - .WithStatement(marshallingStatement)); + // Iterate through the elements of the native collection to unmarshal them + return Block( + GenerateNativeSpanDeclaration(info, context), + MarshallerHelpers.GetForLoop(collectionIdentifierForLength, IndexerIdentifier) + .WithStatement(marshallingStatement)); + } + return EmptyStatement(); } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -964,10 +1034,12 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) private class PointerNativeTypeAssignmentRewriter : CSharpSyntaxRewriter { private readonly string nativeIdentifier; + private readonly PointerTypeSyntax nativeType; - public PointerNativeTypeAssignmentRewriter(string nativeIdentifier) + public PointerNativeTypeAssignmentRewriter(string nativeIdentifier, PointerTypeSyntax nativeType) { this.nativeIdentifier = nativeIdentifier; + this.nativeType = nativeType; } public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax node) @@ -977,6 +1049,10 @@ public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax return node.WithRight( CastExpression(MarshallerHelpers.SystemIntPtrType, node.Right)); } + if (node.Right.ToString() == nativeIdentifier) + { + return node.WithRight(CastExpression(nativeType, node.Right)); + } return node; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs index e0529fe55b05b..0e24ad4d63325 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs @@ -86,11 +86,10 @@ public static TypeSyntax GetCompatibleGenericTypeParameterSyntax(this TypeSyntax return spanElementTypeSyntax; } - private const string MarshalerLocalSuffix = "__marshaler"; + private const string MarshalerLocalSuffix = "marshaler"; public static string GetMarshallerIdentifier(TypePositionInfo info, StubCodeContext context) { - var (_, nativeIdentifier) = context.GetIdentifiers(info); - return nativeIdentifier + MarshalerLocalSuffix; + return context.GetAdditionalIdentifier(info, MarshalerLocalSuffix); } public static class StringMarshaller diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index f90c2731efddc..8194fc099929f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -233,7 +233,7 @@ private static IMarshallingGenerator CreateCore( return Delegate; case { MarshallingAttributeInfo: SafeHandleMarshallingInfo }: - if (!context.CanUseAdditionalTemporaryState) + if (!context.AdditionalTemporaryStateLivesAcrossStages) { throw new MarshallingNotSupportedException(info, context); } @@ -449,14 +449,6 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi private static void ValidateCustomNativeTypeMarshallingSupported(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) { - if (marshalInfo.ValuePropertyType is not null && !context.CanUseAdditionalTemporaryState) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.ValuePropertyMarshallingRequiresAdditionalState - }; - } - // The marshalling method for this type doesn't support marshalling from native to managed, // but our scenario requires marshalling from native to managed. if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) @@ -469,13 +461,9 @@ private static void ValidateCustomNativeTypeMarshallingSupported(TypePositionInf } // The marshalling method for this type doesn't support marshalling from managed to native by value, // but our scenario requires marshalling from managed to native by value. - // Pinning is required for the stackalloc marshalling to enable users to safely pass the stackalloc Span's byref - // to native if we ever start using a conditional stackalloc method and cannot guarantee that the Span we provide - // the user with is backed by stack allocated memory. - else if (!info.IsByRef - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 - && !(context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) == 0) - && !(context.StackSpaceUsable && context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) == 0)) + else if (!info.IsByRef + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 + && (context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingMethods & (SupportedMarshallingMethods.Pinning | SupportedMarshallingMethods.ManagedToNativeStackalloc)) == 0)) { throw new MarshallingNotSupportedException(info, context) { @@ -485,9 +473,9 @@ private static void ValidateCustomNativeTypeMarshallingSupported(TypePositionInf // The marshalling method for this type doesn't support marshalling from managed to native by reference, // but our scenario requires marshalling from managed to native by reference. // "in" byref supports stack marshalling. - else if (info.RefKind == RefKind.In - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 - && !(context.StackSpaceUsable && context.PinningSupported && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0)) + else if (info.RefKind == RefKind.In + && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 + && !(context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0)) { throw new MarshallingNotSupportedException(info, context) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs index eff8a6dfa055a..e14cfbf25b274 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs @@ -58,7 +58,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) } private static bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) { - return context.PinningSupported && !info.IsByRef && !info.IsManagedReturnPosition; + return context.SingleFrameSpansNativeContext && !info.IsByRef && !info.IsManagedReturnPosition; } private IEnumerable GeneratePinningPath(TypePositionInfo info, StubCodeContext context) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs index 96b7c615dfc3d..a63ecd4ab7f81 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs @@ -85,7 +85,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, - IdentifierName(GetAllocationMarkerIdentifier(managedIdentifier)), + IdentifierName(GetAllocationMarkerIdentifier(info, context)), LiteralExpression(SyntaxKind.TrueLiteralExpression)))); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs index c5a50066f8f60..9ae9bb48c454b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs @@ -30,7 +30,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext SyntaxKind.AddressOfExpression, IdentifierName(identifier))); } - else if (context.PinningSupported) + else if (context.SingleFrameSpansNativeContext) { // (ushort*) return Argument( @@ -64,7 +64,7 @@ public override ParameterSyntax AsParameter(TypePositionInfo info) public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); - if (context.PinningSupported && !info.IsByRef && !info.IsManagedReturnPosition) + if (context.SingleFrameSpansNativeContext && !info.IsByRef && !info.IsManagedReturnPosition) { if (context.CurrentStage == StubCodeContext.Stage.Pin) { 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 6e9b0ab11cb18..3fe8cbb877b54 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -636,15 +636,6 @@ internal static string TypeNotSupportedTitle { } } - /// - /// Looks up a localized string similar to Marshalling a value between managed and native with a native type with a 'Value' property requires extra state, which is not supported in this context.. - /// - internal static string ValuePropertyMarshallingRequiresAdditionalState { - get { - return ResourceManager.GetString("ValuePropertyMarshallingRequiresAdditionalState", resourceCulture); - } - } - /// /// Looks up a localized string similar to The native type's 'Value' property must have a getter to support marshalling from managed to native.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index f9b39dd6a9233..0e9a846e8b040 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -316,9 +316,6 @@ Specified type is not supported by source-generated P/Invokes - - Marshalling a value between managed and native with a native type with a 'Value' property requires extra state, which is not supported in this context. - The native type's 'Value' property must have a getter to support marshalling from managed to native. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index 3ddef8d5e331f..4d56c736efc7f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -63,26 +63,24 @@ public enum Stage public Stage CurrentStage { get; protected set; } = Stage.Invalid; /// - /// A fixed statement can be used on an individual value and the pointer - /// can be passed to native code. + /// The stub emits code that runs in a single stack frame and the frame spans over the native context. /// - public abstract bool PinningSupported { get; } - - /// - /// Memory can be allocated via the stackalloc keyword and will live through - /// the full native context of the call. - /// - public abstract bool StackSpaceUsable { get; } + /// + /// Stubs that emit code into a single frame that spans the native context can do two things: + /// + /// A fixed statement can be used on an individual value in the stage and the pointer can be passed to native code. + /// Memory can be allocated via the stackalloc keyword and will live through the full native context of the call. + /// + /// + public abstract bool SingleFrameSpansNativeContext { get; } /// - /// Additional variables other than the {managedIdentifier} and {nativeIdentifier} variables - /// can be added to the stub to track additional state for the marshaller in the stub. + /// Additional variables other than the {managedIdentifier} and {nativeIdentifier} variables can be added to the stub to track additional state for the marshaller in the stub in the Setup phase, and they will live across all phases of the stub. /// /// - /// In scenarios where the stub is defined within a single function, additional local variables - /// can be defined. + /// When this property is false, any additional variables can only be considered to have the state they had immediately after the Setup phase. /// - public abstract bool CanUseAdditionalTemporaryState { get; } + public abstract bool AdditionalTemporaryStateLivesAcrossStages { get; } protected const string GeneratedNativeIdentifierSuffix = "_gen_native"; @@ -96,6 +94,11 @@ public virtual (string managed, string native) GetIdentifiers(TypePositionInfo i return (info.InstanceIdentifier, $"__{info.InstanceIdentifier}{GeneratedNativeIdentifierSuffix}"); } + public virtual string GetAdditionalIdentifier(TypePositionInfo info, string name) + { + return $"{GetIdentifiers(info).native}__{name}"; + } + public abstract TypePositionInfo? GetTypePositionInfoForManagedIndex(int index); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 15746deb0cbfd..bd7388856616b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -13,11 +13,9 @@ namespace Microsoft.Interop { internal sealed class StubCodeGenerator : StubCodeContext { - public override bool PinningSupported => true; + public override bool SingleFrameSpansNativeContext => true; - public override bool StackSpaceUsable => true; - - public override bool CanUseAdditionalTemporaryState => true; + public override bool AdditionalTemporaryStateLivesAcrossStages => true; /// /// Identifier for managed return value diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs index a5be7cf5d1c6a..7effc5f3f9804 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs @@ -32,6 +32,22 @@ public partial class Collections [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] public static partial void CreateRange_Out(int start, int end, out int numValues, [MarshalUsing(typeof(ListMarshaller), CountElementName = "numValues")] out List res); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")] + public static partial int SumStringLengths([MarshalUsing(typeof(ListMarshaller)), MarshalUsing(typeof(Utf16StringMarshaler), ElementIndirectionLevel = 1)] List strArray); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_replace")] + public static partial void ReverseStrings_Ref([MarshalUsing(typeof(ListMarshaller), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaler), ElementIndirectionLevel = 1)] ref List strArray, out int numElements); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_return")] + [return: MarshalUsing(typeof(ListMarshaller), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaler), ElementIndirectionLevel = 1)] + public static partial List ReverseStrings_Return([MarshalUsing(typeof(ListMarshaller), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaler), ElementIndirectionLevel = 1)] List strArray, out int numElements); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_out")] + public static partial void ReverseStrings_Out( + [MarshalUsing(typeof(ListMarshaller)), MarshalUsing(typeof(Utf16StringMarshaler), ElementIndirectionLevel = 1)] List strArray, + out int numElements, + [MarshalUsing(typeof(ListMarshaller), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaler), ElementIndirectionLevel = 1)] out List res); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] [return:MarshalUsing(typeof(ListMarshaller), ConstantElementCount = sizeof(long))] public static partial List GetLongBytes(long l); @@ -110,6 +126,61 @@ private static List GetStringList() }; } + [Fact] + public void ByValueCollectionWithNonBlittableElements() + { + var strings = GetStringList(); + Assert.Equal(strings.Sum(str => str?.Length ?? 0), NativeExportsNE.Collections.SumStringLengths(strings)); + } + + [Fact] + public void ByValueNullCollectionWithNonBlittableElements() + { + Assert.Equal(0, NativeExportsNE.Collections.SumStringLengths(null)); + } + + [Fact] + public void ByRefCollectionWithNonBlittableElements() + { + var strings = GetStringList(); + var expectedStrings = strings.Select(s => ReverseChars(s)).ToList(); + NativeExportsNE.Collections.ReverseStrings_Ref(ref strings, out _); + + Assert.Equal((IEnumerable)expectedStrings, strings); + } + + [Fact] + public void ReturnCollectionWithNonBlittableElements() + { + var strings = GetStringList(); + var expectedStrings = strings.Select(s => ReverseChars(s)).ToList(); + Assert.Equal(expectedStrings, NativeExportsNE.Collections.ReverseStrings_Return(strings, out _)); + + List res; + NativeExportsNE.Collections.ReverseStrings_Out(strings, out _, out res); + Assert.Equal(expectedStrings, res); + } + + [Fact] + public void ByRefNullCollectionWithNonBlittableElements() + { + List strings = null; + NativeExportsNE.Collections.ReverseStrings_Ref(ref strings, out _); + + Assert.Null(strings); + } + + [Fact] + public void ReturnNullCollectionWithNonBlittableElements() + { + List strings = null; + Assert.Null(NativeExportsNE.Collections.ReverseStrings_Return(strings, out _)); + + List res; + NativeExportsNE.Collections.ReverseStrings_Out(strings, out _, out res); + Assert.Null(res); + } + [Fact] public void ConstantSizeCollection() { 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 d34b33c638132..f07f33e9ae0e2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -94,9 +94,6 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.CustomStructMarshallingNativeToManagedOnlyInParameter, 1, 0 }; yield return new object[] { CodeSnippets.CustomStructMarshallingStackallocOnlyRefParameter, 1, 0 }; - // Custom type marshalling in arrays (complex case with Value property) - yield return new object[] { CodeSnippets.ArrayMarshallingWithCustomStructElementWithValueProperty, 5, 0 }; - // Abstract SafeHandle type by reference yield return new object[] { CodeSnippets.BasicParameterWithByRefModifier("ref", "System.Runtime.InteropServices.SafeHandle"), 1, 0 }; 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 5f5938575561e..feaceab2b4257 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -178,6 +178,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.CustomStructMarshallingNativeTypePinnable }; yield return new[] { CodeSnippets.CustomStructMarshallingMarshalUsingParametersAndModifiers }; yield return new[] { CodeSnippets.ArrayMarshallingWithCustomStructElement }; + yield return new[] { CodeSnippets.ArrayMarshallingWithCustomStructElementWithValueProperty }; // Escaped C# keyword identifiers yield return new[] { CodeSnippets.ByValueParameterWithName("Method", "@event") }; From 247fb4d244f7a429099e0821566bca9b579fcd1b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 10 Jun 2021 14:35:44 -0700 Subject: [PATCH 114/161] Handle native identifiers for escaped managed identifiers. (dotnet/runtimelab#1167) Commit migrated from https://github.com/dotnet/runtimelab/commit/4835f732a212ebe2ffc06760d9925cbdfec10a11 --- .../gen/DllImportGenerator/StubCodeContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index 4d56c736efc7f..67299aa31315a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -91,7 +91,7 @@ public enum Stage /// Managed and native identifiers public virtual (string managed, string native) GetIdentifiers(TypePositionInfo info) { - return (info.InstanceIdentifier, $"__{info.InstanceIdentifier}{GeneratedNativeIdentifierSuffix}"); + return (info.InstanceIdentifier, $"__{info.InstanceIdentifier.TrimStart('@')}{GeneratedNativeIdentifierSuffix}"); } public virtual string GetAdditionalIdentifier(TypePositionInfo info, string name) From bb804abdfbe9ab47155ff1d66140f6fe7710d4fc Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 11 Jun 2021 10:06:04 -0700 Subject: [PATCH 115/161] Make HmacOneShot blittable --- .../System.Security.Cryptography.Native.Apple/Interop.Hmac.cs | 2 +- .../Unix/System.Security.Cryptography.Native/Interop.Hmac.cs | 4 ++-- .../src/Internal/Cryptography/HashProviderDispenser.OSX.cs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs index 2e62e64894003..5b4e18c2e71a2 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs @@ -45,7 +45,7 @@ internal static unsafe extern int HmacOneShot( int cbData, byte* pOutput, int cbOutput, - out int cbDigest); + int* cbDigest); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs index ec0b3a2f20dda..e689be5b60bcc 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs @@ -32,7 +32,7 @@ internal static int HmacUpdate(SafeHmacCtxHandle ctx, ReadOnlySpan data, i internal static partial int HmacCurrent(SafeHmacCtxHandle ctx, ref byte data, ref int len); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacOneShot")] - private static unsafe extern int HmacOneShot(IntPtr type, byte* key, int keySize, byte* source, int sourceSize, byte* md, ref int mdSize); + private static unsafe extern int HmacOneShot(IntPtr type, byte* key, int keySize, byte* source, int sourceSize, byte* md, int* mdSize); internal static unsafe int HmacOneShot(IntPtr type, ReadOnlySpan key, ReadOnlySpan source, Span destination) { @@ -43,7 +43,7 @@ internal static unsafe int HmacOneShot(IntPtr type, ReadOnlySpan key, Read fixed (byte* pSource = source) fixed (byte* pDestination = destination) { - int result = HmacOneShot(type, pKey, key.Length, pSource, source.Length, pDestination, ref size); + int result = HmacOneShot(type, pKey, key.Length, pSource, source.Length, pDestination, &size); if (result != Success) { diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs index 41cbf9e8f98d6..c562dfff5a907 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/HashProviderDispenser.OSX.cs @@ -45,6 +45,7 @@ public static unsafe int MacData( fixed (byte* pSource = source) fixed (byte* pDestination = destination) { + int digestSize; int ret = Interop.AppleCrypto.HmacOneShot( algorithm, pKey, @@ -53,7 +54,7 @@ public static unsafe int MacData( source.Length, pDestination, destination.Length, - out int digestSize); + &digestSize); if (ret != 1) { From dca91d18fa2ef633adb441d07762d9bb262ba791 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 11 Jun 2021 17:15:54 -0700 Subject: [PATCH 116/161] Implement support for collections of collections marshalling (dotnet/runtimelab#1226) * Refactor indexer naming to be nested-collection safe. * Implement initial collections-of-collections/jagged array support. Use a topological sort of the parameter+return marshallers to unmarshal "CountElementName"-referenced parameters/return before unmarshalling the elements that have a dependency on them through "CountElementName". * Fixes for edge cases around HResult/Exception handling. * Flip the edgeMap indices so we can use Array.IndexOf (which is optimized) to search for edges. * Comments and optimizations. * Add citation for algorithm, * Hoist elementIndex out of the loop. * Encapsulate the edgeMap in a private struct type and add some simple abstractions to enable more perf optimizations. * Make Topological sort more flexible for element ids * Use native index if managed index is unset to allow handling multiple native-only parameters as distinct nodes in the graph model. * Fix using the return value for passing collection size. Validate the types of the CountElementName'd elements, even in nested scenarios. * Change how we initialize the numRows array. * Fix cycle breaking in count info. * Update nested indexer creation for num elements expressions to handle non-collection sub contexts. * Add stress test for collections of collections that uses 0-11 nested arrays. * PR feedback. Commit migrated from https://github.com/dotnet/runtimelab/commit/aa2c08cb60f4e13e06e50be2d8c6e7f50b6ec5da --- .../ManualTypeMarshallingAnalyzer.cs | 6 + ...CollectionElementMarshallingCodeContext.cs | 36 +++-- .../ICustomNativeTypeMarshallingStrategy.cs | 27 +--- .../Marshalling/MarshallerHelpers.cs | 148 +++++++++++++++++- .../Marshalling/MarshallingGenerator.cs | 77 +++++++-- .../MarshallingAttributeInfo.cs | 39 ++++- .../DllImportGenerator/Resources.Designer.cs | 27 ++-- .../gen/DllImportGenerator/Resources.resx | 9 +- .../gen/DllImportGenerator/StubCodeContext.cs | 6 + .../DllImportGenerator/StubCodeGenerator.cs | 106 ++++++++++--- .../DllImportGenerator.Tests/ArrayTests.cs | 35 +++++ .../CodeSnippets.cs | 77 +++++++++ .../DllImportGenerator.UnitTests/Compiles.cs | 1 + .../tests/TestAssets/NativeExports/Arrays.cs | 16 ++ 14 files changed, 528 insertions(+), 82 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 965592e6522a7..90d12505d5ee7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -313,6 +313,12 @@ public void AnalyzeReturnType(SymbolAnalysisContext context) private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymbol type, AttributeData nativeMarshalerAttributeData, bool validateManagedGetPinnableReference, bool validateAllScenarioSupport) { + if (nativeMarshalerAttributeData.ConstructorArguments.Length == 0) + { + // This is a MarshalUsing with just count information. + return; + } + if (nativeMarshalerAttributeData.ConstructorArguments[0].IsNull) { context.ReportDiagnostic( diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs index 06f6ef4088955..5e64e126d4fe7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; - +using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -12,14 +12,14 @@ namespace Microsoft.Interop { internal sealed class ContiguousCollectionElementMarshallingCodeContext : StubCodeContext { - private readonly string indexerIdentifier; private readonly string nativeSpanIdentifier; - private readonly StubCodeContext parentContext; public override bool SingleFrameSpansNativeContext => false; public override bool AdditionalTemporaryStateLivesAcrossStages => false; + public string IndexerIdentifier { get; } + /// /// Create a for marshalling elements of an collection. /// @@ -29,14 +29,13 @@ internal sealed class ContiguousCollectionElementMarshallingCodeContext : StubCo /// The parent context. public ContiguousCollectionElementMarshallingCodeContext( Stage currentStage, - string indexerIdentifier, string nativeSpanIdentifier, StubCodeContext parentContext) { CurrentStage = currentStage; - this.indexerIdentifier = indexerIdentifier; + IndexerIdentifier = CalculateIndexerIdentifierBasedOnParentContext(parentContext); this.nativeSpanIdentifier = nativeSpanIdentifier; - this.parentContext = parentContext; + ParentContext = parentContext; } /// @@ -46,16 +45,16 @@ public ContiguousCollectionElementMarshallingCodeContext( /// Managed and native identifiers public override (string managed, string native) GetIdentifiers(TypePositionInfo info) { - var (_, native) = parentContext.GetIdentifiers(info); + var (_, native) = ParentContext!.GetIdentifiers(info); return ( - $"{native}.ManagedValues[{indexerIdentifier}]", - $"{nativeSpanIdentifier}[{indexerIdentifier}]" + $"{native}.ManagedValues[{IndexerIdentifier}]", + $"{nativeSpanIdentifier}[{IndexerIdentifier}]" ); } public override string GetAdditionalIdentifier(TypePositionInfo info, string name) { - return $"{nativeSpanIdentifier}__{indexerIdentifier}__{name}"; + return $"{nativeSpanIdentifier}__{IndexerIdentifier}__{name}"; } public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) @@ -63,5 +62,22 @@ public override string GetAdditionalIdentifier(TypePositionInfo info, string nam // We don't have parameters to look at when we're in the middle of marshalling an array. return null; } + + private static string CalculateIndexerIdentifierBasedOnParentContext(StubCodeContext? parentContext) + { + int i = 0; + while (parentContext is StubCodeContext context) + { + if (context is ContiguousCollectionElementMarshallingCodeContext) + { + i++; + } + parentContext = context.ParentContext; + } + + // Follow a progression of indexers of the following form: + // __i0, __i1, __i2, __i3, etc/ + return $"__i{i}"; + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs index 6b5f25df7f0a1..0d9c367fc46ac 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -127,26 +127,24 @@ public IEnumerable GeneratePinStatements(TypePositionInfo info, /// internal class CustomNativeTypeWithValuePropertyStubContext : StubCodeContext { - private readonly StubCodeContext parentContext; - public CustomNativeTypeWithValuePropertyStubContext(StubCodeContext parentContext) { - this.parentContext = parentContext; + ParentContext = parentContext; CurrentStage = parentContext.CurrentStage; } - public override bool SingleFrameSpansNativeContext => parentContext.SingleFrameSpansNativeContext; + public override bool SingleFrameSpansNativeContext => ParentContext!.SingleFrameSpansNativeContext; - public override bool AdditionalTemporaryStateLivesAcrossStages => parentContext.AdditionalTemporaryStateLivesAcrossStages; + public override bool AdditionalTemporaryStateLivesAcrossStages => ParentContext!.AdditionalTemporaryStateLivesAcrossStages; public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) { - return parentContext.GetTypePositionInfoForManagedIndex(index); + return ParentContext!.GetTypePositionInfoForManagedIndex(index); } public override (string managed, string native) GetIdentifiers(TypePositionInfo info) { - return (parentContext.GetIdentifiers(info).managed, MarshallerHelpers.GetMarshallerIdentifier(info, parentContext)); + return (ParentContext!.GetIdentifiers(info).managed, MarshallerHelpers.GetMarshallerIdentifier(info, ParentContext)); } } @@ -859,8 +857,6 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) /// internal sealed class ContiguousNonBlittableElementCollectionMarshalling : ICustomNativeTypeMarshallingStrategy { - private const string IndexerIdentifier = "__i"; - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; private readonly IMarshallingGenerator elementMarshaller; private readonly TypePositionInfo elementInfo; @@ -874,15 +870,10 @@ public ContiguousNonBlittableElementCollectionMarshalling(ICustomNativeTypeMarsh this.elementInfo = elementInfo; } - private string GetNativeSpanIdentifier(TypePositionInfo info, StubCodeContext context) - { - return context.GetAdditionalIdentifier(info, "nativeSpan"); - } - private LocalDeclarationStatementSyntax GenerateNativeSpanDeclaration(TypePositionInfo info, StubCodeContext context) { string nativeIdentifier = context.GetIdentifiers(info).native; - string nativeSpanIdentifier = GetNativeSpanIdentifier(info, context); + string nativeSpanIdentifier = MarshallerHelpers.GetNativeSpanIdentifier(info, context); return LocalDeclarationStatement(VariableDeclaration( GenericName( Identifier(TypeNames.System_Span), @@ -915,15 +906,13 @@ private LocalDeclarationStatementSyntax GenerateNativeSpanDeclaration(TypePositi private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo info, StubCodeContext context, bool useManagedSpanForLength) { string nativeIdentifier = context.GetIdentifiers(info).native; - string nativeSpanIdentifier = GetNativeSpanIdentifier(info, context); + string nativeSpanIdentifier = MarshallerHelpers.GetNativeSpanIdentifier(info, context); var elementSetupSubContext = new ContiguousCollectionElementMarshallingCodeContext( StubCodeContext.Stage.Setup, - IndexerIdentifier, nativeSpanIdentifier, context); var elementSubContext = new ContiguousCollectionElementMarshallingCodeContext( context.CurrentStage, - IndexerIdentifier, nativeSpanIdentifier, context); @@ -956,7 +945,7 @@ private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo in // Iterate through the elements of the native collection to unmarshal them return Block( GenerateNativeSpanDeclaration(info, context), - MarshallerHelpers.GetForLoop(collectionIdentifierForLength, IndexerIdentifier) + MarshallerHelpers.GetForLoop(collectionIdentifierForLength, elementSubContext.IndexerIdentifier) .WithStatement(marshallingStatement)); } return EmptyStatement(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs index 0e24ad4d63325..256fc939ec7b7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs @@ -1,6 +1,8 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; +using System.Collections.Generic; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -86,10 +88,152 @@ public static TypeSyntax GetCompatibleGenericTypeParameterSyntax(this TypeSyntax return spanElementTypeSyntax; } - private const string MarshalerLocalSuffix = "marshaler"; public static string GetMarshallerIdentifier(TypePositionInfo info, StubCodeContext context) { - return context.GetAdditionalIdentifier(info, MarshalerLocalSuffix); + return context.GetAdditionalIdentifier(info, "marshaller"); + } + + public static string GetNativeSpanIdentifier(TypePositionInfo info, StubCodeContext context) + { + return context.GetAdditionalIdentifier(info, "nativeSpan"); + } + + /// + /// Generate a topologically sorted collection of elements. + /// + /// The type of element. + /// The initial collection of elements. + /// A function to create a key for the element. + /// A function to resolve the dependencies of a given item in the collection as index values that would be returned by . + /// A topologically sorted collection of the elemens of the collection. + /// The graph of nodes and the edges produced by has cycles. + public static IEnumerable GetTopologicallySortedElements( + ICollection elements, + Func keyFn, + Func> getDependentIndicesFn) + { + Dictionary elementIndexToEdgeMapNodeId = new(elements.Count); + List nodeIdToElement = new(elements.Count); + EdgeMap edgeMap = new(elements.Count); + + int nextEdgeMapIndex = 0; + foreach (var element in elements) + { + elementIndexToEdgeMapNodeId.Add(keyFn(element), nextEdgeMapIndex++); + nodeIdToElement.Add(element); + } + + foreach (var element in elements) + { + U elementIndex = keyFn(element); + foreach (var dependentElementIndex in getDependentIndicesFn(element)) + { + // Add an edge from the node for dependentElementIndex-> the node for elementIndex + // This way, elements that have no dependencies have no edges pointing to them. + edgeMap[elementIndexToEdgeMapNodeId[elementIndex], elementIndexToEdgeMapNodeId[dependentElementIndex]] = true; + } + } + + // Now that we have initialized our map of edges and we have our list of nodes, + // we'll use Khan's algorithm to calculate a topological sort of the elements. + // Algorithm adapted from A. B. Kahn. 1962. Topological sorting of large networks. Commun. ACM 5, 11 (Nov. 1962), 558562. DOI:https://doi.org/10.1145/368996.369025 + + // L is the sorted list + List L = new(elements.Count); + // S is the set of elements with no incoming edges (no dependencies on it) + List S = new(elements.Count); + + // Initialize S + for (int node = 0; node < nodeIdToElement.Count; node++) + { + if (!edgeMap.AnyIncomingEdge(node)) + { + S.Add(nodeIdToElement[node]); + } + } + + while (S.Count != 0) + { + // Remove element from S + T element = S[S.Count - 1]; + S.RemoveAt(S.Count - 1); + // Add element to L + L.Add(element); + int n = elementIndexToEdgeMapNodeId[keyFn(element)]; + // For each node m that n points to + for (int m = 0; m < edgeMap.NodeCount; m++) + { + if (!edgeMap[m, n]) + { + continue; + } + // Remove the edge from n to m + edgeMap[m, n] = false; + // If m does not have any incoming edges, add to S + if (!edgeMap.AnyIncomingEdge(m)) + { + S.Add(nodeIdToElement[m]); + } + } + } + + // If we have edges left, then we have a cycle. + if (edgeMap.AnyEdges) + { + throw new InvalidOperationException(Resources.GraphHasCycles); + } + + // If we make it here, we have a topologically sorted list. + return L; + } + + private struct EdgeMap + { + private readonly bool[] edgeMap; + + public EdgeMap(int numNodes) + { + NodeCount = numNodes; + edgeMap = new bool[NodeCount * NodeCount]; + } + + /// + /// EdgeMap contains a map of boolean values denoting if an edge exists + /// If edgeMap[X][Y] is true, that means that there exists an edge Y -> X + /// + /// The node the edge points to. + /// The node the edge start at. + /// If there exists an edge that starts at and ends at + public bool this[int to, int from] + { + get => edgeMap[to * NodeCount + from]; + set => edgeMap[to * NodeCount + from] = value; + } + + public bool AnyEdges => Array.IndexOf(edgeMap, true) != -1; + + public int NodeCount { get; } + + public bool AnyIncomingEdge(int to) + { + return Array.IndexOf(edgeMap, true, to * NodeCount, NodeCount) != -1; + } + } + + public static IEnumerable GetDependentElementsOfMarshallingInfo( + MarshallingInfo elementMarshallingInfo) + { + if (elementMarshallingInfo is NativeContiguousCollectionMarshallingInfo nestedCollection) + { + if (nestedCollection.ElementCountInfo is CountElementCountInfo { ElementInfo: TypePositionInfo nestedCountElement }) + { + yield return nestedCountElement; + } + foreach (var nestedElements in GetDependentElementsOfMarshallingInfo(nestedCollection.ElementMarshallingInfo)) + { + yield return nestedElements; + } + } } public static class StringMarshaller diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 8194fc099929f..2790aefac4585 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -392,21 +392,74 @@ ExpressionSyntax GetExpressionForParam(TypePositionInfo? paramInfo) NotSupportedDetails = Resources.ArraySizeParamIndexOutOfRange }; } - else if (!paramInfo.ManagedType.IsIntegralType()) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.ArraySizeParamTypeMustBeIntegral - }; - } else { - var (managed, native) = context.GetIdentifiers(paramInfo); - string identifier = Create(paramInfo, context, options).UsesNativeIdentifier(paramInfo, context) ? native : managed; + ExpressionSyntax numElementsExpression = GetIndexedNumElementsExpression( + context, + paramInfo, + out int numIndirectionLevels); + + ITypeSymbol type = paramInfo.ManagedType; + MarshallingInfo marshallingInfo = paramInfo.MarshallingAttributeInfo; + + for (int i = 0; i < numIndirectionLevels; i++) + { + if (marshallingInfo is NativeContiguousCollectionMarshallingInfo collectionInfo) + { + type = collectionInfo.ElementType; + marshallingInfo = collectionInfo.ElementMarshallingInfo; + } + else + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral + }; + } + } + + if (!type.IsIntegralType()) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral + }; + } + return CastExpression( PredefinedType(Token(SyntaxKind.IntKeyword)), - IdentifierName(identifier)); + ParenthesizedExpression(numElementsExpression)); + } + } + + static ExpressionSyntax GetIndexedNumElementsExpression(StubCodeContext context, TypePositionInfo numElementsInfo, out int numIndirectionLevels) + { + Stack indexerStack = new(); + + StubCodeContext? currentContext = context; + StubCodeContext lastContext = null!; + + while (currentContext is not null) + { + if (currentContext is ContiguousCollectionElementMarshallingCodeContext collectionContext) + { + indexerStack.Push(collectionContext.IndexerIdentifier); + } + lastContext = currentContext; + currentContext = currentContext.ParentContext; + } + + numIndirectionLevels = indexerStack.Count; + + ExpressionSyntax indexedNumElements = IdentifierName(lastContext.GetIdentifiers(numElementsInfo).managed); + while (indexerStack.Count > 0) + { + NameSyntax indexer = IdentifierName(indexerStack.Pop()); + indexedNumElements = ElementAccessExpression(indexedNumElements) + .AddArgumentListArguments(Argument(indexer)); } + + return indexedNumElements; } } @@ -513,10 +566,10 @@ private static IMarshallingGenerator CreateNativeCollectionMarshaller( AnalyzerConfigOptions options, ICustomNativeTypeMarshallingStrategy marshallingStrategy) { - var elementInfo = TypePositionInfo.CreateForType(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo); + var elementInfo = TypePositionInfo.CreateForType(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo) with { ManagedIndex = info.ManagedIndex }; var elementMarshaller = Create( elementInfo, - new ContiguousCollectionElementMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, string.Empty, context), + new ContiguousCollectionElementMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context), options); var elementType = elementMarshaller.AsNativeType(elementInfo); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 1590fc49f6962..7e9a08b7d5541 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -341,17 +341,26 @@ CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet elementsInCycle, string startOfCycle) + { + ElementsInCycle = elementsInCycle; + StartOfCycle = startOfCycle; + } + + public ImmutableHashSet ElementsInCycle { get; } + + public string StartOfCycle { get; } + } } } 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 3fe8cbb877b54..3a93516652e5a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -78,15 +78,6 @@ internal static string ArraySizeParamIndexOutOfRange { } } - /// - /// Looks up a localized string similar to The specified array size parameter for an array must be an integer type.. - /// - internal static string ArraySizeParamTypeMustBeIntegral { - get { - return ResourceManager.GetString("ArraySizeParamTypeMustBeIntegral", resourceCulture); - } - } - /// /// Looks up a localized string similar to A type marked with 'BlittableTypeAttribute' must be blittable.. /// @@ -123,6 +114,15 @@ internal static string CannotHaveMultipleMarshallingAttributesMessage { } } + /// + /// Looks up a localized string similar to The specified collection size parameter for an collection must be an integer type. If the size information is applied to a nested collection, the size parameter must be a collection of one less level of nesting with an integral element.. + /// + internal static string CollectionSizeParamTypeMustBeIntegral { + get { + return ResourceManager.GetString("CollectionSizeParamTypeMustBeIntegral", resourceCulture); + } + } + /// /// Looks up a localized string similar to Source-generated P/Invokes will ignore any configuration that is not supported.. /// @@ -339,6 +339,15 @@ internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFal } } + /// + /// Looks up a localized string similar to The provided graph has cycles and cannot be topologically sorted.. + /// + internal static string GraphHasCycles { + get { + return ResourceManager.GetString("GraphHasCycles", resourceCulture); + } + } + /// /// Looks up a localized string similar to The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 0e9a846e8b040..56d1e2c895573 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -123,9 +123,6 @@ The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range. - - The specified array size parameter for an array must be an integer type. - A type marked with 'BlittableTypeAttribute' must be blittable. @@ -138,6 +135,9 @@ Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes. + + The specified collection size parameter for an collection must be an integer type. If the size information is applied to a nested collection, the size parameter must be a collection of one less level of nesting with an integral element. + Source-generated P/Invokes will ignore any configuration that is not supported. @@ -211,6 +211,9 @@ Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible + + The provided graph has cycles and cannot be topologically sorted. + The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index 67299aa31315a..1ea0d17553e65 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Microsoft.Interop { @@ -82,6 +83,11 @@ public enum Stage /// public abstract bool AdditionalTemporaryStateLivesAcrossStages { get; } + /// + /// If this context is a nested context, return the parent context. Otherwise, return null. + /// + public StubCodeContext? ParentContext { get; protected set; } + protected const string GeneratedNativeIdentifierSuffix = "_gen_native"; /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index bd7388856616b..dbbd4bf0c8f54 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -53,6 +53,7 @@ internal sealed class StubCodeGenerator : StubCodeContext private readonly IEnumerable paramsTypeInfo; private readonly List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> paramMarshallers; private readonly (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) retMarshaller; + private readonly List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> sortedMarshallers; public StubCodeGenerator( IMethodSymbol stubMethod, @@ -76,6 +77,38 @@ public StubCodeGenerator( // Get marshaller for return this.retMarshaller = CreateGenerator(retTypeInfo); + + List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> allMarshallers = new(this.paramMarshallers); + allMarshallers.Add(retMarshaller); + + // We are doing a topological sort of our marshallers to ensure that each parameter/return value's + // dependencies are unmarshalled before their dependents. This comes up in the case of contiguous + // collections, where the number of elements in a collection are provided via another parameter/return value. + // When using nested collections, the parameter that represents the number of elements of each element of the + // outer collection is another collection. As a result, there are two options on how to retrieve the size. + // Either we partially unmarshal the collection of counts while unmarshalling the collection of elements, + // or we unmarshal our parameters and return value in an order such that we can use the managed identifiers + // for our lengths. + // Here's an example signature where the dependency shows up: + // + // [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "transpose_matrix")] + // [return: MarshalUsing(CountElementName = "numColumns")] + // [return: MarshalUsing(CountElementName = "numRows", ElementIndirectionLevel = 1)] + // public static partial int[][] TransposeMatrix( + // int[][] matrix, + // [MarshalUsing(CountElementName="numColumns")] ref int[] numRows, + // int numColumns); + // + // In this scenario, we'd traditionally unmarshal the return value and then each parameter. However, since + // the return value has dependencies on numRows and numColumns and numRows has a dependency on numColumns, + // we want to unmarshal numColumns, then numRows, then the return value. + // A topological sort ensures we get this order correct. + this.sortedMarshallers = MarshallerHelpers.GetTopologicallySortedElements( + allMarshallers, + static m => GetInfoIndex(m.TypeInfo), + static m => GetInfoDependencies(m.TypeInfo)) + .ToList(); + (TypePositionInfo info, IMarshallingGenerator gen) CreateGenerator(TypePositionInfo p) { try @@ -88,6 +121,28 @@ public StubCodeGenerator( return (p, MarshallingGenerators.Forwarder); } } + + static IEnumerable GetInfoDependencies(TypePositionInfo info) + { + // A parameter without a managed index cannot have any dependencies. + if (info.ManagedIndex == TypePositionInfo.UnsetIndex) + { + return Array.Empty(); + } + return MarshallerHelpers.GetDependentElementsOfMarshallingInfo(info.MarshallingAttributeInfo) + .Select(static info => GetInfoIndex(info)).ToList(); + } + + static int GetInfoIndex(TypePositionInfo info) + { + if (info.ManagedIndex == TypePositionInfo.UnsetIndex) + { + // A TypePositionInfo needs to have either a managed or native index. + // We use negative values of the native index to distinguish them from the managed index. + return -info.NativeIndex; + } + return info.ManagedIndex; + } } public override (string managed, string native) GetIdentifiers(TypePositionInfo info) @@ -202,39 +257,52 @@ public BlockSyntax GenerateSyntax() int initialCount = statements.Count; this.CurrentStage = stage; - if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Unmarshal or Stage.GuaranteedUnmarshal or Stage.Cleanup)) + if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Cleanup)) { // Handle setup and unmarshalling for return var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, this); statements.AddRange(retStatements); } - // Generate code for each parameter for the current stage - foreach (var marshaller in paramMarshallers) + if (stage is Stage.Unmarshal or Stage.GuaranteedUnmarshal) { - if (stage == Stage.Invoke) + // For Unmarshal and GuaranteedUnmarshal stages, use the topologically sorted + // marshaller list to generate the marshalling statements + + foreach (var marshaller in sortedMarshallers) { - // Get arguments for invocation - ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, this); - invoke = invoke.AddArgumentListArguments(argSyntax); + statements.AddRange(marshaller.Generator.Generate(marshaller.TypeInfo, this)); } - else + } + else + { + // Generate code for each parameter for the current stage + foreach (var marshaller in paramMarshallers) { - var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); - if (stage == Stage.Pin) + if (stage == Stage.Invoke) { - // Collect all the fixed statements. These will be used in the Invoke stage. - foreach (var statement in generatedStatements) - { - if (statement is not FixedStatementSyntax fixedStatement) - continue; - - fixedStatements.Add(fixedStatement); - } + // Get arguments for invocation + ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, this); + invoke = invoke.AddArgumentListArguments(argSyntax); } else { - statements.AddRange(generatedStatements); + var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); + if (stage == Stage.Pin) + { + // Collect all the fixed statements. These will be used in the Invoke stage. + foreach (var statement in generatedStatements) + { + if (statement is not FixedStatementSyntax fixedStatement) + continue; + + fixedStatements.Add(fixedStatement); + } + } + else + { + statements.AddRange(generatedStatements); + } } } } 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 77be3b4f324d8..9e885fb417786 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -62,6 +62,11 @@ public partial class Arrays [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] [return:MarshalAs(UnmanagedType.U1)] public static partial bool AndAllMembers(BoolStruct[] pArray, int length); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "transpose_matrix")] + [return: MarshalUsing(CountElementName = "numColumns")] + [return: MarshalUsing(CountElementName = "numRows", ElementIndirectionLevel = 1)] + public static partial int[][] TransposeMatrix(int[][] matrix, int[] numRows, int numColumns); } } @@ -273,6 +278,36 @@ public void ArrayWithSimpleNonBlittableTypeMarshalling(bool result) Assert.Equal(result, NativeExportsNE.Arrays.AndAllMembers(boolValues, boolValues.Length)); } + [Fact] + public void ArraysOfArrays() + { + var random = new Random(42); + int numRows = random.Next(1, 5); + int numColumns = random.Next(1, 5); + int[][] matrix = new int[numRows][]; + for (int i = 0; i < numRows; i++) + { + matrix[i] = new int[numColumns]; + for (int j = 0; j < numColumns; j++) + { + matrix[i][j] = random.Next(); + } + } + + int[] numRowsArray = new int[numColumns]; + numRowsArray.AsSpan().Fill(numRows); + + int[][] transposed = NativeExportsNE.Arrays.TransposeMatrix(matrix, numRowsArray, numColumns); + + for (int i = 0; i < numRows; i++) + { + for (int j = 0; j < numColumns; j++) + { + Assert.Equal(matrix[i][j], transposed[j][i]); + } + } + } + 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 863eb9ae44747..24a4fe249e65f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -1330,6 +1330,83 @@ public static partial void Method( [MarshalUsing(CountElementName=""arr"")] ref int[] arr2 ); } +"; + + public static string CollectionsOfCollectionsStress => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)] + [MarshalUsing(CountElementName=""arr4"", ElementIndirectionLevel = 4)] + [MarshalUsing(CountElementName=""arr5"", ElementIndirectionLevel = 5)] + [MarshalUsing(CountElementName=""arr6"", ElementIndirectionLevel = 6)] + [MarshalUsing(CountElementName=""arr7"", ElementIndirectionLevel = 7)] + [MarshalUsing(CountElementName=""arr8"", ElementIndirectionLevel = 8)] + [MarshalUsing(CountElementName=""arr9"", ElementIndirectionLevel = 9)] + [MarshalUsing(CountElementName=""arr10"", ElementIndirectionLevel = 10)] ref int[][][][][][][][][][][] arr11, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)] + [MarshalUsing(CountElementName=""arr4"", ElementIndirectionLevel = 4)] + [MarshalUsing(CountElementName=""arr5"", ElementIndirectionLevel = 5)] + [MarshalUsing(CountElementName=""arr6"", ElementIndirectionLevel = 6)] + [MarshalUsing(CountElementName=""arr7"", ElementIndirectionLevel = 7)] + [MarshalUsing(CountElementName=""arr8"", ElementIndirectionLevel = 8)] + [MarshalUsing(CountElementName=""arr9"", ElementIndirectionLevel = 9)]ref int[][][][][][][][][][] arr10, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)] + [MarshalUsing(CountElementName=""arr4"", ElementIndirectionLevel = 4)] + [MarshalUsing(CountElementName=""arr5"", ElementIndirectionLevel = 5)] + [MarshalUsing(CountElementName=""arr6"", ElementIndirectionLevel = 6)] + [MarshalUsing(CountElementName=""arr7"", ElementIndirectionLevel = 7)] + [MarshalUsing(CountElementName=""arr8"", ElementIndirectionLevel = 8)]ref int[][][][][][][][][] arr9, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)] + [MarshalUsing(CountElementName=""arr4"", ElementIndirectionLevel = 4)] + [MarshalUsing(CountElementName=""arr5"", ElementIndirectionLevel = 5)] + [MarshalUsing(CountElementName=""arr6"", ElementIndirectionLevel = 6)] + [MarshalUsing(CountElementName=""arr7"", ElementIndirectionLevel = 7)]ref int[][][][][][][][][] arr8, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)] + [MarshalUsing(CountElementName=""arr4"", ElementIndirectionLevel = 4)] + [MarshalUsing(CountElementName=""arr5"", ElementIndirectionLevel = 5)] + [MarshalUsing(CountElementName=""arr6"", ElementIndirectionLevel = 6)]ref int[][][][][][][] arr7, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)] + [MarshalUsing(CountElementName=""arr4"", ElementIndirectionLevel = 4)] + [MarshalUsing(CountElementName=""arr5"", ElementIndirectionLevel = 5)]ref int[][][][][][] arr6, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)] + [MarshalUsing(CountElementName=""arr4"", ElementIndirectionLevel = 4)]ref int[][][][][] arr5, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)] + [MarshalUsing(CountElementName=""arr3"", ElementIndirectionLevel = 3)]ref int[][][][] arr4, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] + [MarshalUsing(CountElementName=""arr2"", ElementIndirectionLevel = 2)]ref int[][][] arr3, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] + [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)]ref int[][] arr2, + [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)]ref int[] arr1, + ref int arr0 + ); +} "; } } 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 feaceab2b4257..671b5bacd464b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -260,6 +260,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerParametersAndModifiers() }; yield return new[] { CodeSnippets.CustomCollectionCustomMarshallerReturnValueLength() }; yield return new[] { CodeSnippets.GenericCollectionWithCustomElementMarshalling }; + yield return new[] { CodeSnippets.CollectionsOfCollectionsStress }; } [Theory] diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs index b73c636423340..0357b593a2356 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs @@ -154,6 +154,22 @@ public static byte AndAllMembers([DNNE.C99Type("struct bool_struct*")] BoolStruc return (byte)(result ? 1 : 0); } + [UnmanagedCallersOnly(EntryPoint = "transpose_matrix")] + public static int** TransposeMatrix(int** matrix, int* numRows, int numColumns) + { + int** newRows = (int**)Marshal.AllocCoTaskMem(numColumns * sizeof(int*)); + for (int i = 0; i < numColumns; i++) + { + newRows[i] = (int*)Marshal.AllocCoTaskMem(numRows[i] * sizeof(int)); + for (int j = 0; j < numRows[i]; j++) + { + newRows[i][j] = matrix[j][i]; + } + } + + return newRows; + } + private static int* CreateRangeImpl(int start, int end, int* numValues) { if (start >= end) From f38351f5f3a2c15d06eb6ddbe6288493182dcd2d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 11 Jun 2021 17:16:07 -0700 Subject: [PATCH 117/161] Implement marshallers for Span and ReadOnlySpan (dotnet/runtimelab#1222) * Implement marshallers for Span/ReadOnlySpan. * Add tests for span marshalling. * Remove unused code. * PR feedback. * Use dotnet/runtime style. * Fix allocation size in ReadOnlySpanMarshaller. Commit migrated from https://github.com/dotnet/runtimelab/commit/e9876f36bda716892f6a3878b896991e1be02b81 --- .../Ancillary.Interop/SpanMarshallers.cs | 393 ++++++++++++++++++ .../DllImportGenerator.Tests/SpanTests.cs | 160 +++++++ 2 files changed, 553 insertions(+) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs new file mode 100644 index 0000000000000..dccfa6a23ad58 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs @@ -0,0 +1,393 @@ + +using System.Diagnostics; +using System.Runtime.CompilerServices; + +namespace System.Runtime.InteropServices.GeneratedMarshalling +{ + [GenericContiguousCollectionMarshaller] + public unsafe ref struct ReadOnlySpanMarshaller + { + private ReadOnlySpan _managedSpan; + private readonly int _sizeOfNativeElement; + private IntPtr _allocatedMemory; + + public ReadOnlySpanMarshaller(int sizeOfNativeElement) + : this() + { + _sizeOfNativeElement = sizeOfNativeElement; + } + + public ReadOnlySpanMarshaller(ReadOnlySpan managed, int sizeOfNativeElement) + { + _allocatedMemory = default; + _sizeOfNativeElement = sizeOfNativeElement; + if (managed.Length == 0) + { + _managedSpan = default; + NativeValueStorage = default; + return; + } + _managedSpan = managed; + _sizeOfNativeElement = sizeOfNativeElement; + int spaceToAllocate = managed.Length * sizeOfNativeElement; + _allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)_allocatedMemory, spaceToAllocate); + } + + public ReadOnlySpanMarshaller(ReadOnlySpan managed, Span stackSpace, int sizeOfNativeElement) + { + _allocatedMemory = default; + _sizeOfNativeElement = sizeOfNativeElement; + if (managed.Length == 0) + { + _managedSpan = default; + NativeValueStorage = default; + return; + } + _managedSpan = managed; + int spaceToAllocate = managed.Length * sizeOfNativeElement; + if (spaceToAllocate <= stackSpace.Length) + { + NativeValueStorage = stackSpace[0..spaceToAllocate]; + } + else + { + _allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)_allocatedMemory, spaceToAllocate); + } + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + public const int StackBufferSize = 0x200; + + public Span ManagedValues => MemoryMarshal.CreateSpan(ref MemoryMarshal.GetReference(_managedSpan), _managedSpan.Length); + + public Span NativeValueStorage { get; private set; } + + public ref byte GetPinnableReference() => ref MemoryMarshal.GetReference(NativeValueStorage); + + public void SetUnmarshalledCollectionLength(int length) + { + _managedSpan = new T[length]; + } + + public byte* Value + { + get + { + Debug.Assert(_managedSpan.IsEmpty || _allocatedMemory != IntPtr.Zero); + return (byte*)_allocatedMemory; + } + set + { + if (value == null) + { + _managedSpan = null; + NativeValueStorage = default; + } + else + { + _allocatedMemory = (IntPtr)value; + NativeValueStorage = new Span(value, _managedSpan.Length * _sizeOfNativeElement); + } + } + } + + public ReadOnlySpan ToManaged() => _managedSpan; + + public void FreeNative() + { + Marshal.FreeCoTaskMem(_allocatedMemory); + } + } + + [GenericContiguousCollectionMarshaller] + public unsafe ref struct SpanMarshaller + { + private ReadOnlySpanMarshaller _inner; + + public SpanMarshaller(int sizeOfNativeElement) + : this() + { + _inner = new ReadOnlySpanMarshaller(sizeOfNativeElement); + } + + public SpanMarshaller(Span managed, int sizeOfNativeElement) + { + _inner = new ReadOnlySpanMarshaller(managed, sizeOfNativeElement); + } + + public SpanMarshaller(Span managed, Span stackSpace, int sizeOfNativeElement) + { + _inner = new ReadOnlySpanMarshaller(managed, stackSpace, sizeOfNativeElement); + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + public const int StackBufferSize = ReadOnlySpanMarshaller.StackBufferSize; + + public Span ManagedValues => _inner.ManagedValues; + + public Span NativeValueStorage + { + get => _inner.NativeValueStorage; + } + + public ref byte GetPinnableReference() => ref _inner.GetPinnableReference(); + + public void SetUnmarshalledCollectionLength(int length) + { + _inner.SetUnmarshalledCollectionLength(length); + } + + public byte* Value + { + get => _inner.Value; + set => _inner.Value = value; + } + + public Span ToManaged() + { + ReadOnlySpan managedInner = _inner.ToManaged(); + return MemoryMarshal.CreateSpan(ref MemoryMarshal.GetReference(managedInner), managedInner.Length); + } + + public void FreeNative() + { + _inner.FreeNative(); + } + } + + [GenericContiguousCollectionMarshaller] + public unsafe ref struct NeverNullSpanMarshaller + { + private SpanMarshaller _inner; + + public NeverNullSpanMarshaller(int sizeOfNativeElement) + : this() + { + _inner = new SpanMarshaller(sizeOfNativeElement); + } + + public NeverNullSpanMarshaller(Span managed, int sizeOfNativeElement) + { + _inner = new SpanMarshaller(managed, sizeOfNativeElement); + } + + public NeverNullSpanMarshaller(Span managed, Span stackSpace, int sizeOfNativeElement) + { + _inner = new SpanMarshaller(managed, stackSpace, sizeOfNativeElement); + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small spans to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of span parameters doesn't + /// blow the stack. + /// + public const int StackBufferSize = SpanMarshaller.StackBufferSize; + + public Span ManagedValues => _inner.ManagedValues; + + public Span NativeValueStorage + { + get => _inner.NativeValueStorage; + } + + public ref byte GetPinnableReference() + { + if (_inner.ManagedValues.Length == 0) + { + return ref *(byte*)0xa5a5a5a5; + } + return ref _inner.GetPinnableReference(); + } + + public void SetUnmarshalledCollectionLength(int length) + { + _inner.SetUnmarshalledCollectionLength(length); + } + + public byte* Value + { + get + { + if (_inner.ManagedValues.Length == 0) + { + return (byte*)0x1; + } + return _inner.Value; + } + + set => _inner.Value = value; + } + + public Span ToManaged() => _inner.ToManaged(); + + public void FreeNative() + { + _inner.FreeNative(); + } + } + + [GenericContiguousCollectionMarshaller] + public unsafe ref struct NeverNullReadOnlySpanMarshaller + { + private ReadOnlySpanMarshaller _inner; + + public NeverNullReadOnlySpanMarshaller(int sizeOfNativeElement) + : this() + { + _inner = new ReadOnlySpanMarshaller(sizeOfNativeElement); + } + + public NeverNullReadOnlySpanMarshaller(ReadOnlySpan managed, int sizeOfNativeElement) + { + _inner = new ReadOnlySpanMarshaller(managed, sizeOfNativeElement); + } + + public NeverNullReadOnlySpanMarshaller(ReadOnlySpan managed, Span stackSpace, int sizeOfNativeElement) + { + _inner = new ReadOnlySpanMarshaller(managed, stackSpace, sizeOfNativeElement); + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small spans to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of span parameters doesn't + /// blow the stack. + /// + public const int StackBufferSize = SpanMarshaller.StackBufferSize; + + public Span ManagedValues => _inner.ManagedValues; + + public Span NativeValueStorage + { + get => _inner.NativeValueStorage; + } + + public ref byte GetPinnableReference() + { + if (_inner.ManagedValues.Length == 0) + { + return ref *(byte*)0xa5a5a5a5; + } + return ref _inner.GetPinnableReference(); + } + + public void SetUnmarshalledCollectionLength(int length) + { + _inner.SetUnmarshalledCollectionLength(length); + } + + public byte* Value + { + get + { + if (_inner.ManagedValues.Length == 0) + { + return (byte*)0x1; + } + return _inner.Value; + } + + set => _inner.Value = value; + } + + public ReadOnlySpan ToManaged() => _inner.ToManaged(); + + public void FreeNative() + { + _inner.FreeNative(); + } + } + + [GenericContiguousCollectionMarshaller] + public unsafe ref struct DirectSpanMarshaller + where T : unmanaged + { + private int _unmarshalledLength; + private T* _allocatedMemory; + private Span _data; + + public DirectSpanMarshaller(int sizeOfNativeElement) + :this() + { + // This check is not exhaustive, but it will catch the majority of cases. + if (typeof(T) == typeof(bool) || typeof(T) == typeof(char) || Unsafe.SizeOf() != sizeOfNativeElement) + { + throw new ArgumentException("This marshaller only supports blittable element types. The provided type parameter must be blittable", nameof(T)); + } + } + + public DirectSpanMarshaller(Span managed, int sizeOfNativeElement) + :this(sizeOfNativeElement) + { + if (managed.Length == 0) + { + return; + } + + int spaceToAllocate = managed.Length * Unsafe.SizeOf(); + _allocatedMemory = (T*)Marshal.AllocCoTaskMem(spaceToAllocate); + _data = managed; + } + + public DirectSpanMarshaller(Span managed, Span stackSpace, int sizeOfNativeElement) + :this(sizeOfNativeElement) + { + Debug.Assert(stackSpace.IsEmpty); + _data = managed; + } + + /// + /// Stack-alloc threshold set to 0 so that the generator can use the constructor that takes a stackSpace to let the marshaller know that the original data span can be used and safely pinned. + /// + public const int StackBufferSize = 0; + + public Span ManagedValues => _data; + + public Span NativeValueStorage => _allocatedMemory != null + ? new Span(_allocatedMemory, _data.Length * Unsafe.SizeOf()) + : MemoryMarshal.Cast(_data); + + public ref T GetPinnableReference() => ref _data.GetPinnableReference(); + + public void SetUnmarshalledCollectionLength(int length) + { + _unmarshalledLength = length; + } + + public T* Value + { + get + { + Debug.Assert(_data.IsEmpty || _allocatedMemory != null); + return _allocatedMemory; + } + set + { + // We don't save the pointer assigned here to be freed + // since this marshaller passes back the actual memory span from native code + // back to managed code. + _allocatedMemory = null; + _data = new Span(value, _unmarshalledLength); + } + } + + public Span ToManaged() + { + return _data; + } + + public void FreeNative() + { + Marshal.FreeCoTaskMem((IntPtr)_allocatedMemory); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs new file mode 100644 index 0000000000000..53421dbc47d19 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs @@ -0,0 +1,160 @@ +using SharedTypes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.GeneratedMarshalling; +using System.Text; + +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public partial class Span + { + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + public static partial int Sum([MarshalUsing(typeof(SpanMarshaller))] Span values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + public static partial int SumNeverNull([MarshalUsing(typeof(NeverNullSpanMarshaller))] Span values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + public static partial int SumNeverNull([MarshalUsing(typeof(NeverNullReadOnlySpanMarshaller))] ReadOnlySpan values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] + public static partial int SumInArray([MarshalUsing(typeof(SpanMarshaller))] in Span values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] + public static partial void Duplicate([MarshalUsing(typeof(SpanMarshaller), CountElementName = "numValues")] ref Span values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] + public static partial void DuplicateRaw([MarshalUsing(typeof(DirectSpanMarshaller), CountElementName = "numValues")] ref Span values, int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] + [return: MarshalUsing(typeof(SpanMarshaller), CountElementName = "numValues")] + public static partial Span CreateRange(int start, int end, out int numValues); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] + public static partial void CreateRange_Out(int start, int end, out int numValues, [MarshalUsing(typeof(SpanMarshaller), CountElementName = "numValues")] out Span res); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] + [return: MarshalUsing(typeof(SpanMarshaller), ConstantElementCount = sizeof(long))] + public static partial Span GetLongBytes(long l); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] + [return: MarshalAs(UnmanagedType.U1)] + public static partial bool AndAllMembers([MarshalUsing(typeof(SpanMarshaller))] Span pArray, int length); + } + } + + public class SpanTests + { + [Fact] + public void BlittableElementSpanMarshalledToNativeAsExpected() + { + var list = new int[] { 1, 5, 79, 165, 32, 3 }; + Assert.Equal(list.Sum(), NativeExportsNE.Span.Sum(list, list.Length)); + } + + [Fact] + public void DefaultBlittableElementSpanMarshalledToNativeAsExpected() + { + Assert.Equal(-1, NativeExportsNE.Span.Sum(default, 0)); + } + + [Fact] + public void NeverNullSpanMarshallerMarshalsDefaultAsNonNull() + { + Assert.Equal(0, NativeExportsNE.Span.SumNeverNull(Span.Empty, 0)); + } + + [Fact] + public void NeverNullReadOnlySpanMarshallerMarshalsDefaultAsNonNull() + { + Assert.Equal(0, NativeExportsNE.Span.SumNeverNull(ReadOnlySpan.Empty, 0)); + } + + [Fact] + public void BlittableElementSpanInParameter() + { + var list = new int[] { 1, 5, 79, 165, 32, 3 }; + Assert.Equal(list.Sum(), NativeExportsNE.Span.SumInArray(list, list.Length)); + } + + [Fact] + public void BlittableElementSpanRefParameter() + { + var list = new int[] { 1, 5, 79, 165, 32, 3 }; + Span newSpan = list; + NativeExportsNE.Span.Duplicate(ref newSpan, list.Length); + Assert.Equal((IEnumerable)list, newSpan.ToArray()); + } + + [Fact] + public unsafe void DirectSpanMarshaller() + { + var list = new int[] { 1, 5, 79, 165, 32, 3 }; + Span newSpan = list; + NativeExportsNE.Span.DuplicateRaw(ref newSpan, list.Length); + Assert.Equal((IEnumerable)list, newSpan.ToArray()); + Marshal.FreeCoTaskMem((IntPtr)Unsafe.AsPointer(ref newSpan.GetPinnableReference())); + } + + [Fact] + public void BlittableElementSpanReturnedFromNative() + { + int start = 5; + int end = 20; + + IEnumerable expected = Enumerable.Range(start, end - start); + Assert.Equal(expected, NativeExportsNE.Collections.CreateRange(start, end, out _)); + + Span res; + NativeExportsNE.Span.CreateRange_Out(start, end, out _, out res); + Assert.Equal(expected, res.ToArray()); + } + + [Fact] + public void NullBlittableElementSpanReturnedFromNative() + { + Assert.Null(NativeExportsNE.Collections.CreateRange(1, 0, out _)); + + Span res; + NativeExportsNE.Span.CreateRange_Out(1, 0, out _, out res); + Assert.True(res.IsEmpty); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void SpanWithSimpleNonBlittableTypeMarshalling(bool result) + { + var boolValues = new BoolStruct[] + { + new BoolStruct + { + b1 = true, + b2 = true, + b3 = true, + }, + new BoolStruct + { + b1 = true, + b2 = true, + b3 = true, + }, + new BoolStruct + { + b1 = true, + b2 = true, + b3 = result, + }, + }; + + Assert.Equal(result, NativeExportsNE.Span.AndAllMembers(boolValues, boolValues.Length)); + } + } +} From 83d8624349ce7d99c601a64f8815289cf40b741a Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 14 Jun 2021 13:41:14 -0700 Subject: [PATCH 118/161] Use GeneratedDllImport in System.IO.Compression.Brotli (#54173) --- .../Common/src/Interop/Interop.Brotli.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Brotli.cs b/src/libraries/Common/src/Interop/Interop.Brotli.cs index a817bb971e263..b84bd9939e3db 100644 --- a/src/libraries/Common/src/Interop/Interop.Brotli.cs +++ b/src/libraries/Common/src/Interop/Interop.Brotli.cs @@ -8,13 +8,13 @@ internal static partial class Interop { - internal static class Brotli + internal static partial class Brotli { - [DllImport(Libraries.CompressionNative)] - internal static extern SafeBrotliDecoderHandle BrotliDecoderCreateInstance(IntPtr allocFunc, IntPtr freeFunc, IntPtr opaque); + [GeneratedDllImport(Libraries.CompressionNative)] + internal static partial SafeBrotliDecoderHandle BrotliDecoderCreateInstance(IntPtr allocFunc, IntPtr freeFunc, IntPtr opaque); - [DllImport(Libraries.CompressionNative)] - internal static extern unsafe int BrotliDecoderDecompressStream( + [GeneratedDllImport(Libraries.CompressionNative)] + internal static unsafe partial int BrotliDecoderDecompressStream( SafeBrotliDecoderHandle state, ref nuint availableIn, byte** nextIn, ref nuint availableOut, byte** nextOut, out nuint totalOut); @@ -24,22 +24,22 @@ internal static extern unsafe int BrotliDecoderDecompressStream( [DllImport(Libraries.CompressionNative)] internal static extern void BrotliDecoderDestroyInstance(IntPtr state); - [DllImport(Libraries.CompressionNative)] - internal static extern BOOL BrotliDecoderIsFinished(SafeBrotliDecoderHandle state); + [GeneratedDllImport(Libraries.CompressionNative)] + internal static partial BOOL BrotliDecoderIsFinished(SafeBrotliDecoderHandle state); - [DllImport(Libraries.CompressionNative)] - internal static extern SafeBrotliEncoderHandle BrotliEncoderCreateInstance(IntPtr allocFunc, IntPtr freeFunc, IntPtr opaque); + [GeneratedDllImport(Libraries.CompressionNative)] + internal static partial SafeBrotliEncoderHandle BrotliEncoderCreateInstance(IntPtr allocFunc, IntPtr freeFunc, IntPtr opaque); - [DllImport(Libraries.CompressionNative)] - internal static extern BOOL BrotliEncoderSetParameter(SafeBrotliEncoderHandle state, BrotliEncoderParameter parameter, uint value); + [GeneratedDllImport(Libraries.CompressionNative)] + internal static partial BOOL BrotliEncoderSetParameter(SafeBrotliEncoderHandle state, BrotliEncoderParameter parameter, uint value); - [DllImport(Libraries.CompressionNative)] - internal static extern unsafe BOOL BrotliEncoderCompressStream( + [GeneratedDllImport(Libraries.CompressionNative)] + internal static unsafe partial BOOL BrotliEncoderCompressStream( SafeBrotliEncoderHandle state, BrotliEncoderOperation op, ref nuint availableIn, byte** nextIn, ref nuint availableOut, byte** nextOut, out nuint totalOut); - [DllImport(Libraries.CompressionNative)] - internal static extern BOOL BrotliEncoderHasMoreOutput(SafeBrotliEncoderHandle state); + [GeneratedDllImport(Libraries.CompressionNative)] + internal static partial BOOL BrotliEncoderHasMoreOutput(SafeBrotliEncoderHandle state); [DllImport(Libraries.CompressionNative)] internal static extern void BrotliEncoderDestroyInstance(IntPtr state); From 557cd3648031fff307e50d3cf09a406bc9bd52a6 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 14 Jun 2021 16:24:41 -0700 Subject: [PATCH 119/161] Use GeneratedDllImport in System.IO.FileSystem.DriveInfo (#54181) --- .../Unix/System.Native/Interop.MountPoints.FormatInfo.cs | 8 ++++---- .../Windows/Kernel32/Interop.GetDiskFreeSpaceEx.cs | 4 ++-- .../src/Interop/Windows/Kernel32/Interop.GetDriveType.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.SetVolumeLabel.cs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs index fb59b17534680..3ee8e3e065fb8 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs @@ -153,11 +153,11 @@ internal struct MountPointInformation internal ulong TotalSize; } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSpaceInfoForMountPoint", SetLastError = true)] - internal static extern int GetSpaceInfoForMountPoint([MarshalAs(UnmanagedType.LPStr)]string name, out MountPointInformation mpi); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSpaceInfoForMountPoint", SetLastError = true)] + internal static partial int GetSpaceInfoForMountPoint([MarshalAs(UnmanagedType.LPStr)]string name, out MountPointInformation mpi); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetFormatInfoForMountPoint", SetLastError = true)] - private static extern unsafe int GetFormatInfoForMountPoint( + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetFormatInfoForMountPoint", SetLastError = true)] + private static unsafe partial int GetFormatInfoForMountPoint( [MarshalAs(UnmanagedType.LPStr)]string name, byte* formatNameBuffer, int bufferLength, 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 d7dfb5d5c1d09..c9d6b8d878774 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. - [DllImport(Libraries.Kernel32, EntryPoint = "GetDiskFreeSpaceExW", CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] - internal static extern bool GetDiskFreeSpaceEx(string drive, out long freeBytesForUser, out long totalBytes, out long freeBytes); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetDiskFreeSpaceExW", CharSet = CharSet.Unicode, SetLastError = true)] + 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 4c45c528f9aa1..51321d6d6b0a0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDriveType.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetDriveType.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, EntryPoint = "GetDriveTypeW", CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] - internal static extern int GetDriveType(string drive); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetDriveTypeW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial int GetDriveType(string drive); } } 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 4b6c9344e262c..ca70a7fa2c52f 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 { - [DllImport(Libraries.Kernel32, EntryPoint = "SetVolumeLabelW", CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] - internal static extern bool SetVolumeLabel(string driveLetter, string? volumeName); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetVolumeLabelW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool SetVolumeLabel(string driveLetter, string? volumeName); } } From bfe2f7f7dfab01de9a2c405520ab2189d65de5b3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 14 Jun 2021 16:24:57 -0700 Subject: [PATCH 120/161] Use GeneratedDllImport in System.IO.FileSystem.Watcher (#54183) --- .../Linux/System.Native/Interop.INotify.cs | 12 +++++------ .../src/Interop/OSX/Interop.EventStream.cs | 20 +++++++++---------- .../Unix/System.Native/Interop.RealPath.cs | 4 ++-- .../Kernel32/Interop.ReadDirectoryChangesW.cs | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) 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 6ff843ec89903..7a900b6378d6b 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 @@ -10,14 +10,14 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyInit", SetLastError = true)] - internal static extern SafeFileHandle INotifyInit(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyInit", SetLastError = true)] + internal static partial SafeFileHandle INotifyInit(); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyAddWatch", SetLastError = true)] - internal static extern int INotifyAddWatch(SafeFileHandle fd, string pathName, uint mask); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyAddWatch", SetLastError = true, CharSet = CharSet.Ansi)] + internal static partial int INotifyAddWatch(SafeFileHandle fd, string pathName, uint mask); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyRemoveWatch", SetLastError = true)] - private static extern int INotifyRemoveWatch_private(SafeFileHandle fd, int wd); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyRemoveWatch", SetLastError = true)] + private static partial int INotifyRemoveWatch_private(SafeFileHandle fd, int wd); internal static int INotifyRemoveWatch(SafeFileHandle fd, int wd) { diff --git a/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs b/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs index 9f32269e1b8e4..b0d312ff824f4 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs @@ -99,8 +99,8 @@ 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 - [DllImport(Interop.Libraries.CoreServicesLibrary, CharSet = CharSet.Ansi)] - internal static extern unsafe SafeEventStreamHandle FSEventStreamCreate( + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary, CharSet = CharSet.Ansi)] + internal static unsafe partial SafeEventStreamHandle FSEventStreamCreate( IntPtr allocator, delegate* unmanaged callback, FSEventStreamContext* context, @@ -115,8 +115,8 @@ internal static extern unsafe SafeEventStreamHandle FSEventStreamCreate( /// The stream to attach to the RunLoop /// The RunLoop to attach the stream to /// The mode of the RunLoop; this should usually be kCFRunLoopDefaultMode. See the documentation for RunLoops for more info. - [DllImport(Interop.Libraries.CoreServicesLibrary)] - internal static extern void FSEventStreamScheduleWithRunLoop( + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)] + internal static partial void FSEventStreamScheduleWithRunLoop( SafeEventStreamHandle streamRef, CFRunLoopRef runLoop, SafeCreateHandle runLoopMode); @@ -126,15 +126,15 @@ internal static extern void FSEventStreamScheduleWithRunLoop( /// /// The stream to receive events on. /// Returns true if the stream was started; otherwise, returns false and no events will be received. - [DllImport(Interop.Libraries.CoreServicesLibrary)] - internal static extern bool FSEventStreamStart(SafeEventStreamHandle streamRef); + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)] + internal static partial bool FSEventStreamStart(SafeEventStreamHandle streamRef); /// /// Stops receiving events on the specified stream. The stream can be restarted and not miss any events. /// /// The stream to stop receiving events on. - [DllImport(Interop.Libraries.CoreServicesLibrary)] - internal static extern void FSEventStreamStop(SafeEventStreamHandle streamRef); + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)] + internal static partial void FSEventStreamStop(SafeEventStreamHandle streamRef); /// /// Stops receiving events on the specified stream. The stream can be restarted and not miss any events. @@ -157,8 +157,8 @@ internal static extern void FSEventStreamScheduleWithRunLoop( /// The stream to remove from the RunLoop /// The RunLoop to remove the stream from. /// The mode of the RunLoop; this should usually be kCFRunLoopDefaultMode. See the documentation for RunLoops for more info. - [DllImport(Interop.Libraries.CoreServicesLibrary)] - internal static extern void FSEventStreamUnscheduleFromRunLoop( + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)] + internal static partial void FSEventStreamUnscheduleFromRunLoop( SafeEventStreamHandle streamRef, CFRunLoopRef runLoop, SafeCreateHandle runLoopMode); 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 8daa79cd3e692..fc8983fd4cdff 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 - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RealPath", SetLastError = true)] - internal static extern string RealPath(string path); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RealPath", SetLastError = true, CharSet = CharSet.Ansi)] + internal static partial string RealPath(string path); } } 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 ccbffb6d14a82..aa94e95d556a5 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadDirectoryChangesW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadDirectoryChangesW.cs @@ -10,8 +10,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, EntryPoint = "ReadDirectoryChangesW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe bool ReadDirectoryChangesW( + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadDirectoryChangesW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial bool ReadDirectoryChangesW( SafeFileHandle hDirectory, byte[] lpBuffer, uint nBufferLength, From c0d6093bb7e0f20140dceaa940927e469ace7ca4 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 14 Jun 2021 17:24:03 -0700 Subject: [PATCH 121/161] Use GeneratedDllImport in System.Net.NameResolution (#54191) --- .../Unix/System.Native/Interop.HostEntry.cs | 4 ++-- .../Windows/WinSock/Interop.GetAddrInfoExW.cs | 24 +++++++++---------- .../Windows/WinSock/Interop.GetAddrInfoW.cs | 16 ++++++------- .../Windows/WinSock/Interop.GetNameInfoW.cs | 4 ++-- .../Windows/WinSock/Interop.gethostname.cs | 4 ++-- 5 files changed, 26 insertions(+), 26 deletions(-) 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 d197637043e8a..98372054ec046 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,8 +32,8 @@ internal unsafe struct HostEntry internal int IPAddressCount; // Number of IP addresses in the list } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostEntryForName")] - internal static extern unsafe int GetHostEntryForName(string address, AddressFamily family, HostEntry* entry); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostEntryForName", CharSet = CharSet.Ansi)] + internal static unsafe partial int GetHostEntryForName(string address, AddressFamily family, HostEntry* entry); [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FreeHostEntry")] internal static extern unsafe void FreeHostEntry(HostEntry* entry); 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 8129b25332f4d..8501c538ba0e0 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoExW.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoExW.cs @@ -17,18 +17,18 @@ internal static partial class Winsock internal const int NS_ALL = 0; - [DllImport(Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe int GetAddrInfoExW( - [In] string pName, - [In] string? pServiceName, - [In] int dwNamespace, - [In] IntPtr lpNspId, - [In] AddressInfoEx* pHints, - [Out] AddressInfoEx** ppResult, - [In] IntPtr timeout, - [In] NativeOverlapped* lpOverlapped, - [In] delegate* unmanaged lpCompletionRoutine, - [Out] IntPtr* lpNameHandle); + [GeneratedDllImport(Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial int GetAddrInfoExW( + string pName, + string? pServiceName, + int dwNamespace, + IntPtr lpNspId, + AddressInfoEx* pHints, + AddressInfoEx** ppResult, + IntPtr timeout, + NativeOverlapped* lpOverlapped, + delegate* unmanaged lpCompletionRoutine, + IntPtr* lpNameHandle); [DllImport(Libraries.Ws2_32, ExactSpelling = true)] internal static extern unsafe int GetAddrInfoExCancel([In] IntPtr* lpHandle); 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 01fdff217eeba..d3a28a4808e21 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoW.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetAddrInfoW.cs @@ -9,15 +9,15 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)] - internal static extern unsafe int GetAddrInfoW( - [In] string pNameName, - [In] string? pServiceName, - [In] AddressInfo* pHints, - [Out] AddressInfo** ppResult); + [GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial int GetAddrInfoW( + string pNameName, + string? pServiceName, + AddressInfo* pHints, + AddressInfo** ppResult); - [DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] - internal static extern unsafe void FreeAddrInfoW(AddressInfo* info); + [GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial void FreeAddrInfoW(AddressInfo* info); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] internal unsafe struct AddressInfo 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 13673f2adff7d..7825ed7ac5ae2 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetNameInfoW.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.GetNameInfoW.cs @@ -19,8 +19,8 @@ internal enum NameInfoFlags NI_DGRAM = 0x10, /* Service is a datagram service */ } - [DllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)] - internal static extern unsafe SocketError GetNameInfoW( + [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial SocketError GetNameInfoW( byte* pSockaddr, int SockaddrLength, char* pNodeBuffer, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.gethostname.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.gethostname.cs index 292b73230406c..54b90ef1df81f 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.gethostname.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.gethostname.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Winsock { - [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] - internal static extern unsafe SocketError gethostname(byte* name, int namelen); + [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)] + internal static unsafe partial SocketError gethostname(byte* name, int namelen); } } From 2d929b4c396cc2f8279d50b09ce280560d833d0e Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Tue, 15 Jun 2021 20:50:40 +0600 Subject: [PATCH 122/161] Fix table display (dotnet/runtimelab#1242) Commit migrated from https://github.com/dotnet/runtimelab/commit/35df9046707caf1cb84f476cc443e5828ce214f7 --- docs/design/libraries/DllImportGenerator/Pipeline.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/design/libraries/DllImportGenerator/Pipeline.md b/docs/design/libraries/DllImportGenerator/Pipeline.md index 6ae109b26cbd8..63ace4671c32e 100644 --- a/docs/design/libraries/DllImportGenerator/Pipeline.md +++ b/docs/design/libraries/DllImportGenerator/Pipeline.md @@ -130,8 +130,8 @@ Support for these features is indicated in code by the `abstract` `SingleFrameSp The various scenarios mentioned above have different levels of support for these specialized features: -| Scenarios |Pinning and Stack allocation across the native context | Storing additional temporary state in locals | -|------|-----|-----|---------| +| Scenarios | Pinning and Stack allocation across the native context | Storing additional temporary state in locals | +|------|-----|-----| | P/Invoke | supported | supported | | Reverse P/Invoke | unsupported | supported | | User-defined structure content marshalling | unsupported | unsupported | From 21d949525e5d55df5ba0c70780a01238e61484a1 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 15 Jun 2021 11:12:01 -0700 Subject: [PATCH 123/161] Use GeneratedDllImport in System.Net.Ping (#54232) --- .../Interop/Windows/IpHlpApi/Interop.ICMP.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.ICMP.cs b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.ICMP.cs index 3f7dba6e50551..71823ea3c74c3 100644 --- a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.ICMP.cs +++ b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.ICMP.cs @@ -89,21 +89,21 @@ protected override bool ReleaseHandle() } } - [DllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] - internal static extern SafeCloseIcmpHandle IcmpCreateFile(); + [GeneratedDllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] + internal static partial SafeCloseIcmpHandle IcmpCreateFile(); - [DllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] - internal static extern SafeCloseIcmpHandle Icmp6CreateFile(); + [GeneratedDllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] + internal static partial SafeCloseIcmpHandle Icmp6CreateFile(); - [DllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] - internal static extern bool IcmpCloseHandle(IntPtr handle); + [GeneratedDllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] + internal static partial bool IcmpCloseHandle(IntPtr handle); - [DllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] - internal static extern uint IcmpSendEcho2(SafeCloseIcmpHandle icmpHandle, SafeWaitHandle Event, IntPtr apcRoutine, IntPtr apcContext, - uint ipAddress, [In] SafeLocalAllocHandle data, ushort dataSize, ref IPOptions options, SafeLocalAllocHandle replyBuffer, uint replySize, uint timeout); + [GeneratedDllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] + internal static partial uint IcmpSendEcho2(SafeCloseIcmpHandle icmpHandle, SafeWaitHandle Event, IntPtr apcRoutine, IntPtr apcContext, + uint ipAddress, SafeLocalAllocHandle data, ushort dataSize, ref IPOptions options, SafeLocalAllocHandle replyBuffer, uint replySize, uint timeout); - [DllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] - internal static extern uint Icmp6SendEcho2(SafeCloseIcmpHandle icmpHandle, SafeWaitHandle Event, IntPtr apcRoutine, IntPtr apcContext, - byte[] sourceSocketAddress, byte[] destSocketAddress, [In] SafeLocalAllocHandle data, ushort dataSize, ref IPOptions options, SafeLocalAllocHandle replyBuffer, uint replySize, uint timeout); + [GeneratedDllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] + internal static partial uint Icmp6SendEcho2(SafeCloseIcmpHandle icmpHandle, SafeWaitHandle Event, IntPtr apcRoutine, IntPtr apcContext, + byte[] sourceSocketAddress, byte[] destSocketAddress, SafeLocalAllocHandle data, ushort dataSize, ref IPOptions options, SafeLocalAllocHandle replyBuffer, uint replySize, uint timeout); } } From 37b9b4eca6c7f2afc35734ca3038c0c0504b5ac9 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Tue, 15 Jun 2021 20:11:06 -0700 Subject: [PATCH 124/161] Remove fixed workarounds (dotnet/runtimelab#1247) Commit migrated from https://github.com/dotnet/runtimelab/commit/dbc21f4fd959331784f68da10c3772adf06895a6 --- .../DllImportGenerator.Tests/BlittableStructTests.cs | 8 ++++++++ .../Verifiers/CSharpVerifierHelper.cs | 9 +-------- .../tests/TestAssets/NativeExports/BlittableStructs.cs | 8 ++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs index 26a0cbd16306a..a6a32324495c5 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs @@ -8,6 +8,9 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_return_instance")] + public static partial IntFields DoubleIntFields(IntFields result); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static partial void DoubleIntFieldsByRef(ref IntFields result); @@ -45,6 +48,11 @@ public void ValidateBlittableStruct() }; var input = initial; + { + var result = NativeExportsNE.DoubleIntFields(input); + Assert.Equal(initial, input); + Assert.Equal(expected, result); + } { var result = new IntFields(); NativeExportsNE.DoubleIntFieldsRefReturn(input, ref result); diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs index c51712a3ce0b0..ab02eaae0452c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs @@ -20,14 +20,7 @@ private static ImmutableDictionary GetNullableWarnings { string[] args = { "/warnaserror:nullable" }; var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory); - var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; - - // Workaround for https://github.com/dotnet/roslyn/issues/41610 - nullableWarnings = nullableWarnings - .SetItem("CS8632", ReportDiagnostic.Error) - .SetItem("CS8669", ReportDiagnostic.Error); - - return nullableWarnings; + return commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; } } } \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs index 30c19dab6a39a..9bb1d2cc132ff 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs @@ -11,8 +11,12 @@ public static unsafe class BlittableStructs [return: DNNE.C99Type("struct int_fields")] public static IntFields DoubleIntFields([DNNE.C99Type("struct int_fields")] IntFields input) { - //return input; - throw new System.NotSupportedException( "This is currently not supported due to: https://github.com/dotnet/runtime/issues/35928"); + return new IntFields() + { + a = input.a * 2, + b = input.b * 2, + c = input.c * 2, + }; } [UnmanagedCallersOnly(EntryPoint = "blittablestructs_double_intfields_byref")] From 907dec03a5d6882d68a04ef6dc93a0f19f4c60fe Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Tue, 15 Jun 2021 20:14:28 -0700 Subject: [PATCH 125/161] Use GeneratedDllImport in Microsoft.Win32.Registry (#54236) --- .../Advapi32/Interop.ConvertSdToStringSd.cs | 6 +++++ .../Advapi32/Interop.ConvertStringSdToSd.cs | 6 +++++ ...nterop.DuplicateTokenEx_SafeTokenHandle.cs | 8 +++++- .../Interop.GetSecurityDescriptorLength.cs | 2 +- .../Interop.GetSecurityInfoByHandle.cs | 18 ++++++++++--- .../Advapi32/Interop.GetSecurityInfoByName.cs | 16 ++++++++++-- .../Interop.OpenProcessToken_IntPtr.cs | 11 +++++--- ...Interop.OpenThreadToken_SafeTokenHandle.cs | 11 +++++++- .../Advapi32/Interop.RegConnectRegistry.cs | 10 +++++++- .../Advapi32/Interop.RegCreateKeyEx.cs | 5 ++++ .../Advapi32/Interop.RegDeleteKeyEx.cs | 11 +++++++- .../Advapi32/Interop.RegDeleteValue.cs | 9 ++++++- .../Windows/Advapi32/Interop.RegFlushKey.cs | 8 +++++- .../Windows/Advapi32/Interop.RegOpenKeyEx.cs | 10 ++++++++ .../Windows/Advapi32/Interop.RegSetValueEx.cs | 25 +++++++++++++++++++ .../Interop.SetSecurityInfoByHandle.cs | 16 ++++++++++-- .../Advapi32/Interop.SetSecurityInfoByName.cs | 16 ++++++++++-- .../Advapi32/Interop.SetThreadToken.cs | 9 ++++++- .../src/System.Security.AccessControl.csproj | 3 ++- .../System/Security/AccessControl/Win32.cs | 4 +-- 20 files changed, 181 insertions(+), 23 deletions(-) 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 6240d410105e5..e975e09097069 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs @@ -8,9 +8,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertSecurityDescriptorToStringSecurityDescriptorW", + CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + internal static partial bool ConvertSdToStringSd( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertSecurityDescriptorToStringSecurityDescriptorW", CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] internal static extern bool ConvertSdToStringSd( +#endif byte[] securityDescriptor, /* DWORD */ uint requestedRevision, uint securityInformation, 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 5eb7023aad824..514b5ffa2d539 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs @@ -8,9 +8,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW", + CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + internal static partial bool ConvertStringSdToSd( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW", CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] internal static extern bool ConvertStringSdToSd( +#endif string stringSd, /* DWORD */ uint stringSdRevision, out IntPtr resultSd, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs index 7f3af0e0c08a7..9e45c078e6ad6 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs @@ -10,8 +10,14 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial bool DuplicateTokenEx( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] - internal static extern bool DuplicateTokenEx(SafeTokenHandle ExistingTokenHandle, + internal static extern bool DuplicateTokenEx( +#endif + SafeTokenHandle ExistingTokenHandle, TokenAccessLevels DesiredAccess, IntPtr TokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, 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 8b89d14a13c8e..388f5d4289784 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs @@ -9,7 +9,7 @@ internal static partial class Interop internal static partial class Advapi32 { [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityDescriptorLength", CallingConvention = CallingConvention.Winapi, - SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + ExactSpelling = true, CharSet = CharSet.Unicode)] internal static extern /*DWORD*/ uint GetSecurityDescriptorLength(IntPtr byteArray); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByHandle.cs index 933d8079521ae..b331549c0cf49 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByHandle.cs @@ -8,8 +8,20 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityInfo", SetLastError = true, ExactSpelling = true)] - internal static extern /*DWORD*/ uint GetSecurityInfoByHandle(SafeHandle handle, /*DWORD*/ uint objectType, /*DWORD*/ uint securityInformation, - out IntPtr sidOwner, out IntPtr sidGroup, out IntPtr dacl, out IntPtr sacl, out IntPtr securityDescriptor); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityInfo", ExactSpelling = true)] + internal static unsafe partial uint GetSecurityInfoByHandle( +#else + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityInfo", ExactSpelling = true)] + internal static unsafe extern /*DWORD*/ uint GetSecurityInfoByHandle( +#endif + SafeHandle handle, + /*DWORD*/ uint objectType, + /*DWORD*/ uint securityInformation, + IntPtr* sidOwner, + IntPtr* sidGroup, + IntPtr* dacl, + IntPtr* sacl, + IntPtr* securityDescriptor); } } 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 5146002941d2a..a140d1f02d819 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs @@ -8,8 +8,20 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + internal static partial uint GetSecurityInfoByName( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern /*DWORD*/ uint GetSecurityInfoByName(string name, /*DWORD*/ uint objectType, /*DWORD*/ uint securityInformation, - out IntPtr sidOwner, out IntPtr sidGroup, out IntPtr dacl, out IntPtr sacl, out IntPtr securityDescriptor); + internal static extern /*DWORD*/ uint GetSecurityInfoByName( +#endif + string name, + /*DWORD*/ uint objectType, + /*DWORD*/ uint securityInformation, + out IntPtr sidOwner, + out IntPtr sidGroup, + out IntPtr dacl, + out IntPtr sacl, + out IntPtr securityDescriptor); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_IntPtr.cs index e709f3263a9d3..480bc64264da5 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenProcessToken_IntPtr.cs @@ -10,10 +10,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool OpenProcessToken( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool OpenProcessToken( - IntPtr ProcessToken, - TokenAccessLevels DesiredAccess, - out SafeTokenHandle TokenHandle); +#endif + IntPtr ProcessToken, + TokenAccessLevels DesiredAccess, + out SafeTokenHandle TokenHandle); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken_SafeTokenHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken_SafeTokenHandle.cs index 7f038c1afdea8..d86bebeddf320 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken_SafeTokenHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenThreadToken_SafeTokenHandle.cs @@ -10,7 +10,16 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)] + internal static partial bool OpenThreadToken( +#else [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] - internal static extern bool OpenThreadToken(IntPtr ThreadHandle, TokenAccessLevels dwDesiredAccess, bool bOpenAsSelf, out SafeTokenHandle phThreadToken); + internal static extern bool OpenThreadToken( +#endif + IntPtr ThreadHandle, + TokenAccessLevels dwDesiredAccess, + bool bOpenAsSelf, + out SafeTokenHandle phThreadToken); } } 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 fe0dc958c36d4..48f23e3adeef1 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,15 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegConnectRegistryW")] + internal static partial int RegConnectRegistry( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegConnectRegistryW")] - internal static extern int RegConnectRegistry(string machineName, SafeRegistryHandle key, out SafeRegistryHandle result); + internal static extern int RegConnectRegistry( +#endif + string machineName, + SafeRegistryHandle key, + out SafeRegistryHandle result); } } 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 a92f277d80bb1..13615b73722f6 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs @@ -14,8 +14,13 @@ internal static partial class Advapi32 { // Note: RegCreateKeyEx won't set the last error on failure - it returns // an error code if it fails. +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegCreateKeyExW", ExactSpelling = true)] + internal static partial int RegCreateKeyEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegCreateKeyExW", ExactSpelling = true)] internal static extern int RegCreateKeyEx( +#endif SafeRegistryHandle hKey, string lpSubKey, int Reserved, 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 64b5cc4f27e86..2f0fe680d2509 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,16 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegDeleteKeyExW", ExactSpelling = true)] + internal static partial int RegDeleteKeyEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteKeyExW", ExactSpelling = true)] - internal static extern int RegDeleteKeyEx(SafeRegistryHandle hKey, string lpSubKey, int samDesired, int Reserved); + internal static extern int RegDeleteKeyEx( +#endif + SafeRegistryHandle hKey, + string lpSubKey, + int samDesired, + int Reserved); } } 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 b8c040c021426..7fd43861c8e90 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,14 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegDeleteValueW", ExactSpelling = true)] + internal static partial int RegDeleteValue( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteValueW", ExactSpelling = true)] - internal static extern int RegDeleteValue(SafeRegistryHandle hKey, string? lpValueName); + internal static extern int RegDeleteValue( +#endif + SafeRegistryHandle hKey, + string? lpValueName); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegFlushKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegFlushKey.cs index 2f3d3ed1a7561..5bb1046bee338 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegFlushKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegFlushKey.cs @@ -12,7 +12,13 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32)] + internal static partial int RegFlushKey( +#else [DllImport(Libraries.Advapi32)] - internal static extern int RegFlushKey(SafeRegistryHandle hKey); + internal static extern int RegFlushKey( +#endif + SafeRegistryHandle hKey); } } 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 8e28c0a2be6ab..b6db23b7da19a 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs @@ -13,8 +13,13 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] + internal static partial int RegOpenKeyEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] internal static extern int RegOpenKeyEx( +#endif SafeRegistryHandle hKey, string? lpSubKey, int ulOptions, @@ -22,8 +27,13 @@ internal static extern int RegOpenKeyEx( out SafeRegistryHandle hkResult); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] + internal static partial int RegOpenKeyEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] internal static extern int RegOpenKeyEx( +#endif IntPtr hKey, string? lpSubKey, int ulOptions, 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 41df9ba67e6f7..fca1abbed5f30 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs @@ -12,8 +12,13 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + internal static partial int RegSetValueEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] internal static extern int RegSetValueEx( +#endif SafeRegistryHandle hKey, string? lpValueName, int Reserved, @@ -21,8 +26,13 @@ internal static extern int RegSetValueEx( byte[]? lpData, int cbData); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + internal static partial int RegSetValueEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] internal static extern int RegSetValueEx( +#endif SafeRegistryHandle hKey, string? lpValueName, int Reserved, @@ -30,8 +40,13 @@ internal static extern int RegSetValueEx( char[]? lpData, int cbData); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + internal static partial int RegSetValueEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] internal static extern int RegSetValueEx( +#endif SafeRegistryHandle hKey, string? lpValueName, int Reserved, @@ -39,8 +54,13 @@ internal static extern int RegSetValueEx( ref int lpData, int cbData); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + internal static partial int RegSetValueEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] internal static extern int RegSetValueEx( +#endif SafeRegistryHandle hKey, string? lpValueName, int Reserved, @@ -48,8 +68,13 @@ internal static extern int RegSetValueEx( ref long lpData, int cbData); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + internal static partial int RegSetValueEx( +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] internal static extern int RegSetValueEx( +#endif SafeRegistryHandle hKey, string? lpValueName, int Reserved, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs index d39173b121300..1fb0133cc151c 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs @@ -8,9 +8,21 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "SetSecurityInfo", CallingConvention = CallingConvention.Winapi, + SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + internal static partial uint SetSecurityInfoByHandle( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "SetSecurityInfo", CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern /*DWORD*/ uint SetSecurityInfoByHandle(SafeHandle handle, /*DWORD*/ uint objectType, /*DWORD*/ uint securityInformation, - byte[]? owner, byte[]? group, byte[]? dacl, byte[]? sacl); + internal static extern /*DWORD*/ uint SetSecurityInfoByHandle( +#endif + SafeHandle handle, + /*DWORD*/ uint objectType, + /*DWORD*/ uint securityInformation, + byte[]? owner, + byte[]? group, + byte[]? dacl, + byte[]? sacl); } } 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 1156e585cbcb4..1022b647c3bb6 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs @@ -8,9 +8,21 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "SetNamedSecurityInfoW", CallingConvention = CallingConvention.Winapi, + SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + internal static partial uint SetSecurityInfoByName( +#else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "SetNamedSecurityInfoW", CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern /*DWORD*/ uint SetSecurityInfoByName(string name, /*DWORD*/ uint objectType, /*DWORD*/ uint securityInformation, - byte[]? owner, byte[]? group, byte[]? dacl, byte[]? sacl); + internal static extern /*DWORD*/ uint SetSecurityInfoByName( +#endif + string name, + /*DWORD*/ uint objectType, + /*DWORD*/ uint securityInformation, + byte[]? owner, + byte[]? group, + byte[]? dacl, + byte[]? sacl); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetThreadToken.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetThreadToken.cs index f3c64ca98d189..a0fb653df2948 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetThreadToken.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetThreadToken.cs @@ -9,7 +9,14 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + internal static partial bool SetThreadToken( +#else [DllImport(Libraries.Advapi32, SetLastError = true)] - internal static extern bool SetThreadToken(IntPtr ThreadHandle, SafeTokenHandle? hToken); + internal static extern bool SetThreadToken( +#endif + IntPtr ThreadHandle, + SafeTokenHandle? hToken); } } diff --git a/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj b/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj index 6516f5e72a68f..fb4a4dbaa9d07 100644 --- a/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj +++ b/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj @@ -1,4 +1,4 @@ - + true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);netstandard2.0-windows;netstandard2.0;net461-windows @@ -84,6 +84,7 @@ + diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Win32.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Win32.cs index 15f3301eb7daa..fda6a851db428 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Win32.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Win32.cs @@ -66,7 +66,7 @@ internal static int ConvertSdToSddl( // Wrapper around advapi32.GetSecurityInfo // - internal static int GetSecurityInfo( + internal static unsafe int GetSecurityInfo( ResourceType resourceType, string? name, SafeHandle? handle, @@ -130,7 +130,7 @@ out RawSecurityDescriptor? resultSd } else { - errorCode = (int)Interop.Advapi32.GetSecurityInfoByHandle(handle, (uint)resourceType, (uint)SecurityInfos, out SidOwner, out SidGroup, out Dacl, out Sacl, out ByteArray); + errorCode = (int)Interop.Advapi32.GetSecurityInfoByHandle(handle, (uint)resourceType, (uint)SecurityInfos, &SidOwner, &SidGroup, &Dacl, &Sacl, &ByteArray); } } else From 78804fb752d8e164415bc391ff558e44c921e6f4 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 16 Jun 2021 15:34:18 -0700 Subject: [PATCH 126/161] Use GeneratedDllImport in System.Security.Cryptography.Csp (#54290) --- .../Advapi32/Interop.CryptAcquireContext.cs | 5 +++++ .../Windows/Advapi32/Interop.CryptCreateHash.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptDecrypt.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptDeriveKey.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptDestroyHash.cs | 5 +++++ .../Windows/Advapi32/Interop.CryptDestroyKey.cs | 5 +++++ .../Windows/Advapi32/Interop.CryptEncrypt.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptExportKey.cs | 6 +++--- .../Windows/Advapi32/Interop.CryptGenKey.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptGetHashParam.cs | 10 +++++----- .../Windows/Advapi32/Interop.CryptGetKeyParam.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptGetProvParam.cs | 15 +++++++++++++++ .../Windows/Advapi32/Interop.CryptGetUserKey.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptHashData.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptImportKey.cs | 4 ++-- .../Advapi32/Interop.CryptReleaseContext.cs | 9 ++++++++- .../Windows/Advapi32/Interop.CryptSetKeyParam.cs | 8 ++++---- .../Windows/Advapi32/Interop.CryptSignHash.cs | 12 ++++++------ 18 files changed, 74 insertions(+), 37 deletions(-) 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 903733feee10d..df73355b41257 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs @@ -20,8 +20,13 @@ internal enum CryptAcquireContextFlags : uint CRYPT_VERIFYCONTEXT = 0xF0000000 // CRYPT_VERIFYCONTEXT } +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CryptAcquireContextW")] + public static partial bool CryptAcquireContext( +#else [DllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CryptAcquireContextW")] public static extern bool CryptAcquireContext( +#endif out SafeProvHandle phProv, string? szContainer, string? szProvider, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptCreateHash.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptCreateHash.cs index 679b82aee2a5e..0a60ee7918ac3 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptCreateHash.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptCreateHash.cs @@ -15,8 +15,8 @@ internal enum CryptCreateHashFlags : int None = 0, } - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CryptCreateHash( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool CryptCreateHash( SafeProvHandle hProv, int Algid, SafeKeyHandle hKey, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDecrypt.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDecrypt.cs index 0761afdf79d77..7865c1180ff8f 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDecrypt.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDecrypt.cs @@ -14,8 +14,8 @@ internal enum CryptDecryptFlags : int CRYPT_DECRYPT_RSA_NO_PADDING_CHECK = 0x00000020 } - [DllImport(Libraries.Advapi32, SetLastError = true)] - public static extern bool CryptDecrypt( + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptDecrypt( SafeKeyHandle hKey, SafeHashHandle hHash, bool Final, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDeriveKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDeriveKey.cs index 5afc729706e37..2bc7d4ed8d8ba 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDeriveKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDeriveKey.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CryptDeriveKey( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool CryptDeriveKey( SafeProvHandle hProv, int Algid, SafeHashHandle hBaseData, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyHash.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyHash.cs index f0e94194bef77..8635ce377299c 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyHash.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyHash.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptDestroyHash(IntPtr hHash); +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] public static extern bool CryptDestroyHash(IntPtr hHash); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyKey.cs index 948165d336783..5bc36fbfd6c15 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptDestroyKey.cs @@ -8,7 +8,12 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptDestroyKey(IntPtr hKey); +#else [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] public static extern bool CryptDestroyKey(IntPtr hKey); +#endif } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptEncrypt.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptEncrypt.cs index 15f4683bf379b..fa883e5eef421 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptEncrypt.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptEncrypt.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptEncrypt( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptEncrypt( SafeKeyHandle hKey, SafeHashHandle hHash, bool Final, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptExportKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptExportKey.cs index 1e878fc9ae53d..9eb16f4019035 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptExportKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptExportKey.cs @@ -8,13 +8,13 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptExportKey( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptExportKey( SafeKeyHandle hKey, SafeKeyHandle hExpKey, int dwBlobType, int dwFlags, - [In, Out] byte[]? pbData, + byte[]? pbData, ref int dwDataLen); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGenKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGenKey.cs index 6518252da2847..d19c090d84d60 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGenKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGenKey.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CryptGenKey(SafeProvHandle hProv, int Algid, int dwFlags, out SafeKeyHandle phKey); + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool CryptGenKey(SafeProvHandle hProv, int Algid, int dwFlags, out SafeKeyHandle phKey); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetHashParam.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetHashParam.cs index 3b45b4f885f40..65ba7716ab645 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetHashParam.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetHashParam.cs @@ -18,15 +18,15 @@ internal enum CryptHashProperty : int HP_TLS1PRF_SEED = 0x0007, // seed for TLS1 PRF } - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptGetHashParam( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptGetHashParam( SafeHashHandle hHash, CryptHashProperty dwParam, out int pbData, - [In, Out] ref int pdwDataLen, + ref int pdwDataLen, int dwFlags); - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptSetHashParam(SafeHashHandle hHash, CryptHashProperty dwParam, byte[] buffer, int dwFlags); + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptSetHashParam(SafeHashHandle hHash, CryptHashProperty dwParam, byte[] buffer, int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetKeyParam.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetKeyParam.cs index 880e2aa3ac8db..9737c2b066388 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetKeyParam.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetKeyParam.cs @@ -17,8 +17,8 @@ internal enum CryptGetKeyParamFlags : int KP_KEYLEN = 9 } - [DllImport(Libraries.Advapi32, SetLastError = true)] - public static extern bool CryptGetKeyParam( + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptGetKeyParam( SafeKeyHandle hKey, CryptGetKeyParamFlags dwParam, byte[]? pbData, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetProvParam.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetProvParam.cs index 63553bcee99ab..d5a6b6dcb5f8c 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetProvParam.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetProvParam.cs @@ -22,22 +22,37 @@ internal enum CryptProvParam : int PP_UNIQUE_CONTAINER = 36 } +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptSetProvParam( +#else [DllImport(Libraries.Advapi32, SetLastError = true)] public static extern bool CryptSetProvParam( +#endif SafeHandle safeProvHandle, CryptProvParam dwParam, IntPtr pbData, int dwFlags); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptSetProvParam( +#else [DllImport(Libraries.Advapi32, SetLastError = true)] public static extern bool CryptSetProvParam( +#endif SafeProvHandle hProv, CryptProvParam dwParam, ref IntPtr pbData, int dwFlags); +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptGetProvParam( +#else [DllImport(Libraries.Advapi32, SetLastError = true)] public static extern bool CryptGetProvParam( +#endif SafeHandle safeProvHandle, CryptProvParam dwParam, IntPtr pbData, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetUserKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetUserKey.cs index d1078c88ff705..c5080a0078470 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetUserKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetUserKey.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, SetLastError = true)] - internal static extern bool CryptGetUserKey(SafeProvHandle hProv, int dwKeySpec, out SafeKeyHandle phUserKey); + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + internal static partial bool CryptGetUserKey(SafeProvHandle hProv, int dwKeySpec, out SafeKeyHandle phUserKey); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptHashData.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptHashData.cs index c655276a9b2cd..38f4a57d0dc23 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptHashData.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptHashData.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CryptHashData(SafeHashHandle hHash, byte[] pbData, int dwDataLen, int dwFlags); + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + public static partial bool CryptHashData(SafeHashHandle hHash, byte[] pbData, int dwDataLen, int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptImportKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptImportKey.cs index f1266457cbe01..f5e73879d99ca 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptImportKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptImportKey.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe bool CryptImportKey( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial bool CryptImportKey( SafeProvHandle hProv, byte* pbData, int dwDataLen, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptReleaseContext.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptReleaseContext.cs index dd5922d21f64f..f36800f515057 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptReleaseContext.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptReleaseContext.cs @@ -8,7 +8,14 @@ internal static partial class Interop { internal static partial class Advapi32 { +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptReleaseContext( +#else [DllImport(Libraries.Advapi32, SetLastError = true)] - public static extern bool CryptReleaseContext(IntPtr hProv, int dwFlags); + public static extern bool CryptReleaseContext( +#endif + IntPtr hProv, + int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSetKeyParam.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSetKeyParam.cs index 568d6bce51416..5fb1c83ff37e5 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSetKeyParam.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSetKeyParam.cs @@ -8,10 +8,10 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, SetLastError = true)] - public static extern bool CryptSetKeyParam(SafeKeyHandle hKey, int dwParam, byte[] pbData, int dwFlags); + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptSetKeyParam(SafeKeyHandle hKey, int dwParam, byte[] pbData, int dwFlags); - [DllImport(Libraries.Advapi32, SetLastError = true)] - public static extern bool CryptSetKeyParam(SafeKeyHandle safeKeyHandle, int dwParam, ref int pdw, int dwFlags); + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static partial bool CryptSetKeyParam(SafeKeyHandle safeKeyHandle, int dwParam, ref int pdw, int dwFlags); } } 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 ce8c93da4a574..a4fca2955717e 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSignHash.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptSignHash.cs @@ -24,17 +24,17 @@ internal enum CryptSignAndVerifyHashFlags : int CRYPT_X931_FORMAT = 0x00000004, // Not supported } - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptSignHashW")] - public static extern bool CryptSignHash( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptSignHashW")] + public static partial bool CryptSignHash( SafeHashHandle hHash, KeySpec dwKeySpec, string? szDescription, CryptSignAndVerifyHashFlags dwFlags, - [Out] byte[]? pbSignature, - [In, Out] ref int pdwSigLen); + byte[]? pbSignature, + ref int pdwSigLen); - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptVerifySignatureW")] - public static extern bool CryptVerifySignature( + [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptVerifySignatureW")] + public static partial bool CryptVerifySignature( SafeHashHandle hHash, byte[] pbSignature, int dwSigLen, From b021efe2936650a4cf79167618e6a4cd6c69f210 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 22 Jun 2021 15:13:02 -0700 Subject: [PATCH 127/161] Forward special P/Invoke attributes to the target DllImport method (dotnet/runtimelab#1267) Commit migrated from https://github.com/dotnet/runtimelab/commit/5715e2ee4fd7c1c81151004f6332bf66731e537f --- .../DllImportGenerator/DllImportGenerator.cs | 66 +++++- .../gen/DllImportGenerator/DllImportStub.cs | 3 +- .../DllImportGenerator/StubCodeGenerator.cs | 11 +- .../gen/DllImportGenerator/TypeNames.cs | 6 + .../CallingConventionTests.cs | 45 ++++ .../AttributeForwarding.cs | 198 ++++++++++++++++++ .../DllImportGenerator.UnitTests/TestUtils.cs | 2 +- .../NativeExports/CallingConventions.cs | 26 +++ 8 files changed, 349 insertions(+), 8 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index cf3013a22daa2..bd23299d3ae49 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -32,6 +32,10 @@ public void Execute(GeneratorExecutionContext context) INamedTypeSymbol? lcidConversionAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.LCIDConversionAttribute); + INamedTypeSymbol? suppressGCTransitionAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.SuppressGCTransitionAttribute); + + INamedTypeSymbol? unmanagedCallConvAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.UnmanagedCallConvAttribute); + // Fire the start/stop pair for source generation using var _ = Diagnostics.Events.SourceGenerationStartStop(synRec.Methods.Count); @@ -76,17 +80,31 @@ public void Execute(GeneratorExecutionContext context) // Get any attributes of interest on the method AttributeData? generatedDllImportAttr = null; AttributeData? lcidConversionAttr = null; + AttributeData? suppressGCTransitionAttribute = null; + AttributeData? unmanagedCallConvAttribute = null; + foreach (var attr in methodSymbolInfo.GetAttributes()) { - if (attr.AttributeClass is not null - && attr.AttributeClass.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) + if (attr.AttributeClass is null) + { + continue; + } + else if (attr.AttributeClass.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) { generatedDllImportAttr = attr; } - else if (lcidConversionAttrType != null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, lcidConversionAttrType)) + else if (lcidConversionAttrType is not null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, lcidConversionAttrType)) { lcidConversionAttr = attr; } + else if (suppressGCTransitionAttrType is not null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, suppressGCTransitionAttrType)) + { + suppressGCTransitionAttribute = attr; + } + else if (unmanagedCallConvAttrType is not null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, unmanagedCallConvAttrType)) + { + unmanagedCallConvAttribute = attr; + } } if (generatedDllImportAttr == null) @@ -112,8 +130,10 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(TypeNames.LCIDConversionAttribute)); } + List additionalAttributes = GenerateSyntaxForForwardedAttributes(suppressGCTransitionAttribute, unmanagedCallConvAttribute); + // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, stubDllImportData!, env, generatorDiagnostics, context.CancellationToken); + var dllImportStub = DllImportStub.Create(methodSymbolInfo, stubDllImportData!, env, generatorDiagnostics, additionalAttributes, context.CancellationToken); PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub); } @@ -127,6 +147,44 @@ public void Initialize(GeneratorInitializationContext context) context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); } + private List GenerateSyntaxForForwardedAttributes(AttributeData? suppressGCTransitionAttribute, AttributeData? unmanagedCallConvAttribute) + { + const string CallConvsField = "CallConvs"; + // Manually rehydrate the forwarded attributes with fully qualified types so we don't have to worry about any using directives. + List attributes = new(); + + if (suppressGCTransitionAttribute is not null) + { + attributes.Add(Attribute(ParseName(TypeNames.SuppressGCTransitionAttribute))); + } + if (unmanagedCallConvAttribute is not null) + { + AttributeSyntax unmanagedCallConvSyntax = Attribute(ParseName(TypeNames.UnmanagedCallConvAttribute)); + foreach (var arg in unmanagedCallConvAttribute.NamedArguments) + { + if (arg.Key == CallConvsField) + { + InitializerExpressionSyntax callConvs = InitializerExpression(SyntaxKind.ArrayInitializerExpression); + foreach (var callConv in arg.Value.Values) + { + callConvs = callConvs.AddExpressions( + TypeOfExpression(((ITypeSymbol)callConv.Value!).AsTypeSyntax())); + } + + ArrayTypeSyntax arrayOfSystemType = ArrayType(ParseTypeName(TypeNames.System_Type), SingletonList(ArrayRankSpecifier())); + + unmanagedCallConvSyntax = unmanagedCallConvSyntax.AddArgumentListArguments( + AttributeArgument( + ArrayCreationExpression(arrayOfSystemType) + .WithInitializer(callConvs)) + .WithNameEquals(NameEquals(IdentifierName(CallConvsField)))); + } + } + attributes.Add(unmanagedCallConvSyntax); + } + return attributes; + } + private SyntaxTokenList StripTriviaFromModifiers(SyntaxTokenList tokenList) { SyntaxToken[] strippedTokens = new SyntaxToken[tokenList.Count]; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index f74f9b2a3cff2..cccdc2d478556 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -110,6 +110,7 @@ public static DllImportStub Create( GeneratedDllImportData dllImportData, StubEnvironment env, GeneratorDiagnostics diagnostics, + List forwardedAttributes, CancellationToken token = default) { // Cancel early if requested @@ -211,7 +212,7 @@ public static DllImportStub Create( // Generate stub code var stubGenerator = new StubCodeGenerator(method, dllImportData, paramsTypeInfo, retTypeInfo, diagnostics, env.Options); - var code = stubGenerator.GenerateSyntax(); + var code = stubGenerator.GenerateSyntax(forwardedAttributes: forwardedAttributes.Count != 0 ? AttributeList(SeparatedList(forwardedAttributes)) : null); var additionalAttrs = new List(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index dbbd4bf0c8f54..a603a244a3124 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -175,7 +175,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } } - public BlockSyntax GenerateSyntax() + public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) { string dllImportName = stubMethod.Name + "__PInvoke__"; var setupStatements = new List(); @@ -421,7 +421,14 @@ public BlockSyntax GenerateSyntax() .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) .WithAttributeLists( SingletonList(AttributeList( - SingletonSeparatedList(CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData()))))); + SingletonSeparatedList( + CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData()))))); + + if (forwardedAttributes is not null) + { + dllImport = dllImport.AddAttributeLists(forwardedAttributes); + } + foreach (var marshaller in paramMarshallers) { ParameterSyntax paramSyntax = marshaller.Generator.AsParameter(marshaller.TypeInfo); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 6c85e26d4b110..babe52af8ef94 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -21,6 +21,10 @@ static class TypeNames public const string LCIDConversionAttribute = "System.Runtime.InteropServices.LCIDConversionAttribute"; + public const string SuppressGCTransitionAttribute = "System.Runtime.InteropServices.SuppressGCTransitionAttribute"; + + public const string UnmanagedCallConvAttribute = "System.Runtime.InteropServices.UnmanagedCallConvAttribute"; + public const string System_Span_Metadata = "System.Span`1"; public const string System_Span = "System.Span"; @@ -61,5 +65,7 @@ public static string Unsafe(AnalyzerConfigOptions options) { return options.UseInternalUnsafeType() ? Internal_Runtime_CompilerServices_Unsafe : System_Runtime_CompilerServices_Unsafe; } + + public const string System_Type = "System.Type"; } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs new file mode 100644 index 0000000000000..6e8d702b8b575 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace DllImportGenerator.IntegrationTests +{ + internal partial class NativeExportsNE + { + internal partial class CallingConventions + { + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "add_integers_cdecl")] + [UnmanagedCallConv(CallConvs = new[] { typeof(CallConvCdecl) })] + public static partial long AddLongsCdecl(long i, long j, long k, long l, long m, long n, long o, long p, long q); + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "add_integers_stdcall")] + [UnmanagedCallConv(CallConvs = new[] { typeof(CallConvStdcall) })] + public static partial long AddLongsStdcall(long i, long j, long k, long l, long m, long n, long o, long p, long q); + } + } + + public class CallingConventionTests + { + [Fact] + public void UnmanagedCallConvPropagated() + { + Random rng = new Random(1234); + long i = rng.Next(); + long j = rng.Next(); + long k = rng.Next(); + long l = rng.Next(); + long m = rng.Next(); + long n = rng.Next(); + long o = rng.Next(); + long p = rng.Next(); + long q = rng.Next(); + long expected = i + j + k + l + m + n + o + p + q; + Assert.Equal(expected, NativeExportsNE.CallingConventions.AddLongsCdecl(i, j, k, l, m, n, o, p, q)); + Assert.Equal(expected, NativeExportsNE.CallingConventions.AddLongsStdcall(i, j, k, l, m, n, o, p, q)); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs new file mode 100644 index 0000000000000..2c926a813035c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs @@ -0,0 +1,198 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace DllImportGenerator.UnitTests +{ + public class AttributeForwarding + { + [Theory] + [InlineData("SuppressGCTransition", "System.Runtime.InteropServices.SuppressGCTransitionAttribute")] + [InlineData("UnmanagedCallConv", "System.Runtime.InteropServices.UnmanagedCallConvAttribute")] + public async Task KnownParameterlessAttribute(string attributeSourceName, string attributeMetadataName) + { + string source = @$" +using System.Runtime.InteropServices; +partial class C +{{ + [{attributeSourceName}] + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); +}} +"; + Compilation origComp = await TestUtils.CreateCompilation(source); + Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(newComp.GetDiagnostics()); + + ITypeSymbol attributeType = newComp.GetTypeByMetadataName(attributeMetadataName)!; + + Assert.NotNull(attributeType); + + // The last syntax tree is the generated code + IMethodSymbol targetMethod = GetGeneratedPInvokeTargetFromCompilation(newComp); + + Assert.Contains( + targetMethod.GetAttributes(), + attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, attributeType)); + } + + [Fact] + public async Task UnmanagedCallConvAttribute_EmptyCallConvArray() + { + string source = @" +using System; +using System.Runtime.InteropServices; +partial class C +{ + [UnmanagedCallConv(CallConvs = new Type[0])] + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); +} +"; + Compilation origComp = await TestUtils.CreateCompilation(source); + Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(newComp.GetDiagnostics()); + + ITypeSymbol attributeType = newComp.GetTypeByMetadataName("System.Runtime.InteropServices.UnmanagedCallConvAttribute")!; + + Assert.NotNull(attributeType); + + // The last syntax tree is the generated code + IMethodSymbol targetMethod = GetGeneratedPInvokeTargetFromCompilation(newComp); + + Assert.Contains( + targetMethod.GetAttributes(), + attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, attributeType) + && attr.NamedArguments.Length == 1 + && attr.NamedArguments[0].Key == "CallConvs" + && attr.NamedArguments[0].Value.Values.Length == 0); + } + + [Fact] + public async Task UnmanagedCallConvAttribute_SingleCallConvType() + { + string source = @" +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +partial class C +{ + [UnmanagedCallConv(CallConvs = new[]{typeof(CallConvStdcall)})] + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); +} +"; + Compilation origComp = await TestUtils.CreateCompilation(source); + Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(newComp.GetDiagnostics()); + + ITypeSymbol attributeType = newComp.GetTypeByMetadataName("System.Runtime.InteropServices.UnmanagedCallConvAttribute")!; + ITypeSymbol callConvType = newComp.GetTypeByMetadataName("System.Runtime.CompilerServices.CallConvStdcall")!; + + Assert.NotNull(attributeType); + + // The last syntax tree is the generated code + IMethodSymbol targetMethod = GetGeneratedPInvokeTargetFromCompilation(newComp); + + Assert.Contains( + targetMethod.GetAttributes(), + attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, attributeType) + && attr.NamedArguments.Length == 1 + && attr.NamedArguments[0].Key == "CallConvs" + && attr.NamedArguments[0].Value.Values.Length == 1 + && SymbolEqualityComparer.Default.Equals( + (INamedTypeSymbol?)attr.NamedArguments[0].Value.Values[0].Value!, + callConvType)); + } + + [Fact] + public async Task UnmanagedCallConvAttribute_MultipleCallConvTypes() + { + string source = @" +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +partial class C +{ + [UnmanagedCallConv(CallConvs = new[]{typeof(CallConvStdcall), typeof(CallConvSuppressGCTransition)})] + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); +} +"; + Compilation origComp = await TestUtils.CreateCompilation(source); + Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.DllImportGenerator()); + Assert.Empty(newComp.GetDiagnostics()); + + ITypeSymbol attributeType = newComp.GetTypeByMetadataName("System.Runtime.InteropServices.UnmanagedCallConvAttribute")!; + ITypeSymbol callConvType = newComp.GetTypeByMetadataName("System.Runtime.CompilerServices.CallConvStdcall")!; + ITypeSymbol callConvType2 = newComp.GetTypeByMetadataName("System.Runtime.CompilerServices.CallConvSuppressGCTransition")!; + + Assert.NotNull(attributeType); + + // The last syntax tree is the generated code + IMethodSymbol targetMethod = GetGeneratedPInvokeTargetFromCompilation(newComp); + + Assert.Contains( + targetMethod.GetAttributes(), + attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, attributeType) + && attr.NamedArguments.Length == 1 + && attr.NamedArguments[0].Key == "CallConvs" + && attr.NamedArguments[0].Value.Values.Length == 2 + && SymbolEqualityComparer.Default.Equals( + (INamedTypeSymbol?)attr.NamedArguments[0].Value.Values[0].Value!, + callConvType) + && SymbolEqualityComparer.Default.Equals( + (INamedTypeSymbol?)attr.NamedArguments[0].Value.Values[1].Value!, + callConvType2)); + } + + [Fact] + public async Task OtherAttributeType() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +class OtherAttribute : Attribute {} + +partial class C +{ + [Other] + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method1(); +} +"; + Compilation origComp = await TestUtils.CreateCompilation(source); + Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.DllImportGenerator()); + + Assert.Empty(newComp.GetDiagnostics()); + + ITypeSymbol attributeType = newComp.GetTypeByMetadataName("OtherAttribute")!; + + Assert.NotNull(attributeType); + + // The last syntax tree is the generated code + IMethodSymbol targetMethod = GetGeneratedPInvokeTargetFromCompilation(newComp); + + Assert.DoesNotContain( + targetMethod.GetAttributes(), + attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, attributeType)); + } + + private static IMethodSymbol GetGeneratedPInvokeTargetFromCompilation(Compilation newComp) + { + SyntaxTree generatedCode = newComp.SyntaxTrees.Last(); + SemanticModel model = newComp.GetSemanticModel(generatedCode); + + var localFunctions = generatedCode.GetRoot() + .DescendantNodes().OfType() + .ToList(); + Assert.Single(localFunctions); + IMethodSymbol targetMethod = (IMethodSymbol)model.GetDeclaredSymbol(localFunctions[0])!; + return targetMethod; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index 4664b48d903b9..995c2f0450f1d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -95,7 +95,7 @@ public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() "net6.0", new PackageIdentity( "Microsoft.NETCore.App.Ref", - "6.0.0-preview.5.21226.5"), + "6.0.0-preview.6.21317.4"), Path.Combine("ref", "net6.0")); // Include the assembly containing the new attribute and all of its references. diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs new file mode 100644 index 0000000000000..525dfe991c975 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace NativeExports +{ + class CallingConventions + { + // Use 9 long arguments to ensure we spill to the stack on all platforms. + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) }, EntryPoint = "add_integers_cdecl")] + public static long AddLongsCdecl(long i, long j, long k, long l, long m, long n, long o, long p, long q) + { + return i + j + k + l + m + n + o + p + q; + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) }, EntryPoint = "add_integers_stdcall")] + public static long AddLongsStdcall(long i, long j, long k, long l, long m, long n, long o, long p, long q) + { + return i + j + k + l + m + n + o + p + q; + } + } +} From 0fc1ca2e8cd253a1e649b5e96eefc68f50c86821 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 22 Jun 2021 16:51:28 -0700 Subject: [PATCH 128/161] Fix SafeHandle benchmarks and add string benchmarks (dotnet/runtimelab#1238) Commit migrated from https://github.com/dotnet/runtimelab/commit/165fe8cfacc9c46df8062a9d8f975c35aa52cd89 --- .../Marshalling/Forwarder.cs | 92 ++++++++++++++++++- .../Marshalling/MarshallingGenerator.cs | 13 +++ .../DllImportGenerator/StubCodeGenerator.cs | 12 ++- .../gen/DllImportGenerator/TypeNames.cs | 2 + .../tests/TestAssets/NativeExports/Handles.cs | 35 +++++-- 5 files changed, 142 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs index 4921ae92ec640..385339bcfc2cd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs @@ -1,23 +1,100 @@ using System; using System.Collections.Generic; - +using System.Runtime.InteropServices; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { - internal class Forwarder : IMarshallingGenerator + internal class Forwarder : IMarshallingGenerator, IAttributedReturnTypeMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { return info.ManagedType.AsTypeSyntax(); } + private bool TryRehydrateMarshalAsAttribute(TypePositionInfo info, out AttributeSyntax marshalAsAttribute) + { + marshalAsAttribute = null!; + // If the parameter has [MarshalAs] marshalling, we resurface that + // in the forwarding target since the built-in system understands it. + // ICustomMarshaller marshalling requires additional information that we throw away earlier since it's unsupported, + // so explicitly do not resurface a [MarshalAs(UnmanagdType.CustomMarshaler)] attribute. + if (info.MarshallingAttributeInfo is MarshalAsInfo { UnmanagedType: not UnmanagedType.CustomMarshaler } marshalAs) + { + marshalAsAttribute = Attribute(ParseName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute)) + .WithArgumentList(AttributeArgumentList(SingletonSeparatedList(AttributeArgument( + CastExpression(ParseTypeName(TypeNames.System_Runtime_InteropServices_UnmanagedType), + LiteralExpression(SyntaxKind.NumericLiteralExpression, + Literal((int)marshalAs.UnmanagedType))))))); + return true; + } + + if (info.MarshallingAttributeInfo is NativeContiguousCollectionMarshallingInfo collectionMarshalling + && collectionMarshalling.UseDefaultMarshalling + && collectionMarshalling.ElementCountInfo is NoCountInfo or SizeAndParamIndexInfo + && collectionMarshalling.ElementMarshallingInfo is NoMarshallingInfo or MarshalAsInfo { UnmanagedType: not UnmanagedType.CustomMarshaler } + && info.ManagedType is IArrayTypeSymbol) + { + List marshalAsArguments = new List(); + marshalAsArguments.Add( + AttributeArgument( + CastExpression(ParseTypeName(TypeNames.System_Runtime_InteropServices_UnmanagedType), + LiteralExpression(SyntaxKind.NumericLiteralExpression, + Literal((int)UnmanagedType.LPArray)))) + ); + + if (collectionMarshalling.ElementCountInfo is SizeAndParamIndexInfo countInfo) + { + if (countInfo.ConstSize != SizeAndParamIndexInfo.UnspecifiedData) + { + marshalAsArguments.Add( + AttributeArgument(NameEquals("SizeConst"), null, + LiteralExpression(SyntaxKind.NumericLiteralExpression, + Literal(countInfo.ConstSize))) + ); + } + if (countInfo.ParamIndex != SizeAndParamIndexInfo.UnspecifiedData) + { + marshalAsArguments.Add( + AttributeArgument(NameEquals("SizeParamIndex"), null, + LiteralExpression(SyntaxKind.NumericLiteralExpression, + Literal(countInfo.ParamIndex))) + ); + } + } + + if (collectionMarshalling.ElementMarshallingInfo is MarshalAsInfo elementMarshalAs) + { + marshalAsArguments.Add( + AttributeArgument(NameEquals("ArraySubType"), null, + CastExpression(ParseTypeName(TypeNames.System_Runtime_InteropServices_UnmanagedType), + LiteralExpression(SyntaxKind.NumericLiteralExpression, + Literal((int)elementMarshalAs.UnmanagedType)))) + ); + } + marshalAsAttribute = Attribute(ParseName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute)) + .WithArgumentList(AttributeArgumentList(SeparatedList(marshalAsArguments))); + return true; + } + + return false; + } + public ParameterSyntax AsParameter(TypePositionInfo info) { - return Parameter(Identifier(info.InstanceIdentifier)) + ParameterSyntax param = Parameter(Identifier(info.InstanceIdentifier)) .WithModifiers(TokenList(Token(info.RefKindSyntax))) .WithType(info.ManagedType.AsTypeSyntax()); + + if (TryRehydrateMarshalAsAttribute(info, out AttributeSyntax marshalAsAttribute)) + { + param = param.AddAttributeLists(AttributeList(SingletonSeparatedList(marshalAsAttribute))); + } + + return param; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -34,5 +111,14 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => true; + + public AttributeListSyntax? GenerateAttributesForReturnType(TypePositionInfo info) + { + if (!TryRehydrateMarshalAsAttribute(info, out AttributeSyntax marshalAsAttribute)) + { + return null; + } + return AttributeList(SingletonSeparatedList(marshalAsAttribute)); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 2790aefac4585..40e8a7411a93e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -72,6 +72,19 @@ internal interface IMarshallingGenerator bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); } + /// + /// Interface for generating attributes for native return types. + /// + internal interface IAttributedReturnTypeMarshallingGenerator : IMarshallingGenerator + { + /// + /// Gets any attributes that should be applied to the return type for this . + /// + /// Object to marshal + /// Attributes for the return type for this , or null if no attributes should be added. + AttributeListSyntax? GenerateAttributesForReturnType(TypePositionInfo info); + } + /// /// Exception used to indicate marshalling isn't supported. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index a603a244a3124..31d13feef318d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -421,8 +421,16 @@ public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) .WithAttributeLists( SingletonList(AttributeList( - SingletonSeparatedList( - CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData()))))); + SingletonSeparatedList(CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData()))))); + + if (retMarshaller.Generator is IAttributedReturnTypeMarshallingGenerator retGenerator) + { + AttributeListSyntax? returnAttribute = retGenerator.GenerateAttributesForReturnType(retMarshaller.TypeInfo); + if (returnAttribute is not null) + { + dllImport = dllImport.AddAttributeLists(returnAttribute.WithTarget(AttributeTargetSpecifier(Identifier("return")))); + } + } if (forwardedAttributes is not null) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index babe52af8ef94..678040e4e6b78 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -34,6 +34,8 @@ static class TypeNames public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; + public const string System_Runtime_InteropServices_UnmanagedType = "System.Runtime.InteropServices.UnmanagedType"; + public const string System_Runtime_InteropServices_Marshal = "System.Runtime.InteropServices.Marshal"; private const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs index e17447659afae..4ab5b0b8445e7 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs @@ -29,13 +29,13 @@ public static void AllocateHandleOut(nint* handle) [UnmanagedCallersOnly(EntryPoint = "release_handle")] public static byte ReleaseHandle(nint handle) { - return (byte)(ActiveHandles.Remove(handle) ? 1 : 0); + return (byte)(ReleaseHandleCore(handle) ? 1 : 0); } [UnmanagedCallersOnly(EntryPoint = "is_handle_alive")] public static byte IsHandleAlive(nint handle) { - return (byte)(ActiveHandles.Contains(handle) ? 1 : 0); + return (byte)(IsHandleAliveCore(handle) ? 1 : 0); } [UnmanagedCallersOnly(EntryPoint = "modify_handle")] @@ -47,16 +47,37 @@ public static void ModifyHandle(nint* handle, byte newHandle) } } + private static object m_lock = new object(); + private static nint AllocateHandleCore() { - if (LastHandle == int.MaxValue) + lock (m_lock) { - return InvalidHandle; + if (LastHandle == int.MaxValue) + { + return InvalidHandle; + } + + nint newHandle = ++LastHandle; + ActiveHandles.Add(newHandle); + return newHandle; } + } - nint newHandle = ++LastHandle; - ActiveHandles.Add(newHandle); - return newHandle; + private static bool IsHandleAliveCore(nint handle) + { + lock (m_lock) + { + return ActiveHandles.Contains(handle); + } + } + + private static bool ReleaseHandleCore(nint handle) + { + lock (m_lock) + { + return ActiveHandles.Remove(handle); + } } } } \ No newline at end of file From 9f1e3ea2b1b254ac150b11d6e5a81e0f4c38f997 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 1 Jul 2021 12:56:30 -0700 Subject: [PATCH 129/161] Only run GuaranteedUnmarshal statements if invoke was successful. (dotnet/runtimelab#1288) Commit migrated from https://github.com/dotnet/runtimelab/commit/de39034ce26e5ab47c0967748bc839bd40e58266 --- .../DllImportGenerator/StubCodeGenerator.cs | 300 +++++++++--------- 1 file changed, 154 insertions(+), 146 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 31d13feef318d..b21f4348afa97 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -30,22 +30,11 @@ internal sealed class StubCodeGenerator : StubCodeContext private const string InvokeReturnIdentifier = "__invokeRetVal"; private const string LastErrorIdentifier = "__lastError"; + private const string InvokeSucceededIdentifier = "__invokeSucceeded"; // Error code representing success. This maps to S_OK for Windows HRESULT semantics and 0 for POSIX errno semantics. private const int SuccessErrorCode = 0; - private static readonly Stage[] Stages = new Stage[] - { - Stage.Setup, - Stage.Marshal, - Stage.Pin, - Stage.Invoke, - Stage.KeepAlive, - Stage.Unmarshal, - Stage.GuaranteedUnmarshal, - Stage.Cleanup - }; - private readonly GeneratorDiagnostics diagnostics; private readonly AnalyzerConfigOptions options; private readonly IMethodSymbol stubMethod; @@ -248,139 +237,32 @@ public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) } var tryStatements = new List(); - var finallyStatements = new List(); + var guaranteedUnmarshalStatements = new List(); + var cleanupStatements = new List(); var invoke = InvocationExpression(IdentifierName(dllImportName)); - var fixedStatements = new List(); - foreach (var stage in Stages) - { - var statements = GetStatements(stage); - int initialCount = statements.Count; - this.CurrentStage = stage; - - if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Cleanup)) - { - // Handle setup and unmarshalling for return - var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, this); - statements.AddRange(retStatements); - } - - if (stage is Stage.Unmarshal or Stage.GuaranteedUnmarshal) - { - // For Unmarshal and GuaranteedUnmarshal stages, use the topologically sorted - // marshaller list to generate the marshalling statements - foreach (var marshaller in sortedMarshallers) - { - statements.AddRange(marshaller.Generator.Generate(marshaller.TypeInfo, this)); - } - } - else - { - // Generate code for each parameter for the current stage - foreach (var marshaller in paramMarshallers) - { - if (stage == Stage.Invoke) - { - // Get arguments for invocation - ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, this); - invoke = invoke.AddArgumentListArguments(argSyntax); - } - else - { - var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); - if (stage == Stage.Pin) - { - // Collect all the fixed statements. These will be used in the Invoke stage. - foreach (var statement in generatedStatements) - { - if (statement is not FixedStatementSyntax fixedStatement) - continue; - - fixedStatements.Add(fixedStatement); - } - } - else - { - statements.AddRange(generatedStatements); - } - } - } - } - - if (stage == Stage.Invoke) - { - StatementSyntax invokeStatement; - - // Assign to return value if necessary - if (invokeReturnsVoid) - { - invokeStatement = ExpressionStatement(invoke); - } - else - { - invokeStatement = ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(this.GetIdentifiers(retMarshaller.TypeInfo).native), - invoke)); - } - - // Do not manually handle SetLastError when generating forwarders. - // We want the runtime to handle everything. - if (this.dllImportData.SetLastError && !options.GenerateForwarders()) - { - // Marshal.SetLastSystemError(0); - var clearLastError = ExpressionStatement( - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_Marshal), - IdentifierName("SetLastSystemError")), - ArgumentList(SingletonSeparatedList( - Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(SuccessErrorCode))))))); - - // = Marshal.GetLastSystemError(); - var getLastError = ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(LastErrorIdentifier), - InvocationExpression( - MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - ParseName(TypeNames.System_Runtime_InteropServices_Marshal), - IdentifierName("GetLastSystemError"))))); - - invokeStatement = Block(clearLastError, invokeStatement, getLastError); - } - - // Nest invocation in fixed statements - if (fixedStatements.Any()) - { - fixedStatements.Reverse(); - invokeStatement = fixedStatements.First().WithStatement(invokeStatement); - foreach (var fixedStatement in fixedStatements.Skip(1)) - { - invokeStatement = fixedStatement.WithStatement(Block(invokeStatement)); - } - } + // Handle GuaranteedUnmarshal first since that stage producing statements affects multiple other stages. + GenerateStatementsForStage(Stage.GuaranteedUnmarshal, guaranteedUnmarshalStatements); + if (guaranteedUnmarshalStatements.Count > 0) + { + setupStatements.Add(MarshallerHelpers.DeclareWithDefault(PredefinedType(Token(SyntaxKind.BoolKeyword)), InvokeSucceededIdentifier)); + } - statements.Add(invokeStatement); - } + GenerateStatementsForStage(Stage.Setup, setupStatements); + GenerateStatementsForStage(Stage.Marshal, tryStatements); + GenerateStatementsForInvoke(tryStatements, invoke); + GenerateStatementsForStage(Stage.KeepAlive, tryStatements); + GenerateStatementsForStage(Stage.Unmarshal, tryStatements); + GenerateStatementsForStage(Stage.Cleanup, cleanupStatements); - if (statements.Count > initialCount) - { - // Comment separating each stage - var newLeadingTrivia = TriviaList( - Comment($"//"), - Comment($"// {stage}"), - Comment($"//")); - var firstStatementInStage = statements[initialCount]; - newLeadingTrivia = newLeadingTrivia.AddRange(firstStatementInStage.GetLeadingTrivia()); - statements[initialCount] = firstStatementInStage.WithLeadingTrivia(newLeadingTrivia); - } + List allStatements = setupStatements; + List finallyStatements = new List(); + if (guaranteedUnmarshalStatements.Count > 0) + { + finallyStatements.Add(IfStatement(IdentifierName(InvokeSucceededIdentifier), Block(guaranteedUnmarshalStatements))); } - List allStatements = setupStatements; + finallyStatements.AddRange(cleanupStatements); if (finallyStatements.Count > 0) { // Add try-finally block if there are any statements in the finally block @@ -445,15 +327,141 @@ public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) return codeBlock.AddStatements(dllImport); - List GetStatements(Stage stage) + void GenerateStatementsForStage(Stage stage, List statementsToUpdate) { - return stage switch + int initialCount = statementsToUpdate.Count; + this.CurrentStage = stage; + + if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Cleanup)) { - Stage.Setup => setupStatements, - Stage.Marshal or Stage.Pin or Stage.Invoke or Stage.KeepAlive or Stage.Unmarshal => tryStatements, - Stage.GuaranteedUnmarshal or Stage.Cleanup => finallyStatements, - _ => throw new ArgumentOutOfRangeException(nameof(stage)) - }; + // Handle setup and unmarshalling for return + var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, this); + statementsToUpdate.AddRange(retStatements); + } + + if (stage is Stage.Unmarshal or Stage.GuaranteedUnmarshal) + { + // For Unmarshal and GuaranteedUnmarshal stages, use the topologically sorted + // marshaller list to generate the marshalling statements + + foreach (var marshaller in sortedMarshallers) + { + statementsToUpdate.AddRange(marshaller.Generator.Generate(marshaller.TypeInfo, this)); + } + } + else + { + // Generate code for each parameter for the current stage in declaration order. + foreach (var marshaller in paramMarshallers) + { + var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); + statementsToUpdate.AddRange(generatedStatements); + } + } + + if (statementsToUpdate.Count > initialCount) + { + // Comment separating each stage + var newLeadingTrivia = TriviaList( + Comment($"//"), + Comment($"// {stage}"), + Comment($"//")); + var firstStatementInStage = statementsToUpdate[initialCount]; + newLeadingTrivia = newLeadingTrivia.AddRange(firstStatementInStage.GetLeadingTrivia()); + statementsToUpdate[initialCount] = firstStatementInStage.WithLeadingTrivia(newLeadingTrivia); + } + } + + void GenerateStatementsForInvoke(List statementsToUpdate, InvocationExpressionSyntax invoke) + { + var fixedStatements = new List(); + this.CurrentStage = Stage.Pin; + // Generate code for each parameter for the current stage + foreach (var marshaller in paramMarshallers) + { + var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); + // Collect all the fixed statements. These will be used in the Invoke stage. + foreach (var statement in generatedStatements) + { + if (statement is not FixedStatementSyntax fixedStatement) + continue; + + fixedStatements.Add(fixedStatement); + } + } + + this.CurrentStage = Stage.Invoke; + // Generate code for each parameter for the current stage + foreach (var marshaller in paramMarshallers) + { + // Get arguments for invocation + ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, this); + invoke = invoke.AddArgumentListArguments(argSyntax); + } + + StatementSyntax invokeStatement; + + // Assign to return value if necessary + if (invokeReturnsVoid) + { + invokeStatement = ExpressionStatement(invoke); + } + else + { + invokeStatement = ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(this.GetIdentifiers(retMarshaller.TypeInfo).native), + invoke)); + } + + // Do not manually handle SetLastError when generating forwarders. + // We want the runtime to handle everything. + if (this.dllImportData.SetLastError && !options.GenerateForwarders()) + { + // Marshal.SetLastSystemError(0); + var clearLastError = ExpressionStatement( + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_Marshal), + IdentifierName("SetLastSystemError")), + ArgumentList(SingletonSeparatedList( + Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(SuccessErrorCode))))))); + + // = Marshal.GetLastSystemError(); + var getLastError = ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(LastErrorIdentifier), + InvocationExpression( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + ParseName(TypeNames.System_Runtime_InteropServices_Marshal), + IdentifierName("GetLastSystemError"))))); + + invokeStatement = Block(clearLastError, invokeStatement, getLastError); + } + + // Nest invocation in fixed statements + if (fixedStatements.Any()) + { + fixedStatements.Reverse(); + invokeStatement = fixedStatements.First().WithStatement(invokeStatement); + foreach (var fixedStatement in fixedStatements.Skip(1)) + { + invokeStatement = fixedStatement.WithStatement(Block(invokeStatement)); + } + } + + statementsToUpdate.Add(invokeStatement); + // = true; + if (guaranteedUnmarshalStatements.Count > 0) + { + statementsToUpdate.Add(ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(InvokeSucceededIdentifier), + LiteralExpression(SyntaxKind.TrueLiteralExpression)))); + } } } From 76b147a33bb4b4a9b77242cd04233f822115f64c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 1 Jul 2021 12:56:50 -0700 Subject: [PATCH 130/161] Don't emit SkipLocalsInit when it's already active (dotnet/runtimelab#1289) * Don't emit SkipLocalsInit on each stub if it's already specified on the module as a whole, the containing type, or the stub method * Precalculate module check and check that first. Commit migrated from https://github.com/dotnet/runtimelab/commit/7442710c450a3799e6d60bd57604741f88f18b73 --- .../DllImportGenerator/DllImportGenerator.cs | 12 +- .../gen/DllImportGenerator/DllImportStub.cs | 34 ++++- .../AdditionalAttributesOnStub.cs | 138 ++++++++++++++++++ 3 files changed, 179 insertions(+), 5 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index bd23299d3ae49..55292dda451b1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -56,7 +56,13 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportTargetFrameworkNotSupported(MinimumSupportedFrameworkVersion); } - var env = new StubEnvironment(context.Compilation, isSupported, targetFrameworkVersion, context.AnalyzerConfigOptions.GlobalOptions); + var env = new StubEnvironment( + context.Compilation, + isSupported, + targetFrameworkVersion, + context.AnalyzerConfigOptions.GlobalOptions, + context.Compilation.SourceModule.GetAttributes() + .Any(a => a.AttributeClass?.ToDisplayString() == TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute)); var generatedDllImports = new StringBuilder(); @@ -130,10 +136,10 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(TypeNames.LCIDConversionAttribute)); } - List additionalAttributes = GenerateSyntaxForForwardedAttributes(suppressGCTransitionAttribute, unmanagedCallConvAttribute); + List forwardedAttributes = GenerateSyntaxForForwardedAttributes(suppressGCTransitionAttribute, unmanagedCallConvAttribute); // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, stubDllImportData!, env, generatorDiagnostics, additionalAttributes, context.CancellationToken); + var dllImportStub = DllImportStub.Create(methodSymbolInfo, stubDllImportData!, env, generatorDiagnostics, forwardedAttributes, context.CancellationToken); PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs index cccdc2d478556..c82095e5b5a0e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; using System.Threading; @@ -15,7 +16,8 @@ internal record StubEnvironment( Compilation Compilation, bool SupportedTargetFramework, Version TargetFrameworkVersion, - AnalyzerConfigOptions Options); + AnalyzerConfigOptions Options, + bool ModuleSkipLocalsInit); internal class DllImportStub { @@ -217,7 +219,7 @@ public static DllImportStub Create( var additionalAttrs = new List(); // Define additional attributes for the stub definition. - if (env.TargetFrameworkVersion >= new Version(5, 0)) + if (env.TargetFrameworkVersion >= new Version(5, 0) && !MethodIsSkipLocalsInit(env, method)) { additionalAttrs.Add( AttributeList( @@ -240,5 +242,33 @@ public static DllImportStub Create( AdditionalAttributes = additionalAttrs.ToArray(), }; } + + private static bool MethodIsSkipLocalsInit(StubEnvironment env, IMethodSymbol method) + { + if (env.ModuleSkipLocalsInit) + { + return true; + } + + if (method.GetAttributes().Any(a => IsSkipLocalsInitAttribute(a))) + { + return true; + } + + for (INamedTypeSymbol type = method.ContainingType; type is not null; type = type.ContainingType) + { + if (type.GetAttributes().Any(a => IsSkipLocalsInitAttribute(a))) + { + return true; + } + } + + // We check the module case earlier, so we don't need to do it here. + + return false; + + static bool IsSkipLocalsInitAttribute(AttributeData a) + => a.AttributeClass?.ToDisplayString() == TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute; + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs new file mode 100644 index 0000000000000..0c0fe9a646b35 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs @@ -0,0 +1,138 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace DllImportGenerator.UnitTests +{ + public class AdditionalAttributesOnStub + { + [Fact] + public async Task SkipLocalsInitAdded() + { + string source = @" +using System.Runtime.InteropServices; +partial class C +{ + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method(); +}"; + Compilation comp = await TestUtils.CreateCompilation(source); + + Compilation newComp = TestUtils.RunGenerators(comp, out _, new Microsoft.Interop.DllImportGenerator()); + + ITypeSymbol c = newComp.GetTypeByMetadataName("C")!; + IMethodSymbol stubMethod = c.GetMembers().OfType().Single(m => m.Name == "Method"); + Assert.Contains(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); + } + + public static IEnumerable GetDownlevelTargetFrameworks() + { + yield return new object[] { ReferenceAssemblies.Net.Net50, true }; + yield return new object[] { ReferenceAssemblies.NetCore.NetCoreApp31, false }; + yield return new object[] { ReferenceAssemblies.NetStandard.NetStandard20, false }; + yield return new object[] { ReferenceAssemblies.NetFramework.Net48.Default, false }; + } + + [Theory] + [MemberData(nameof(GetDownlevelTargetFrameworks))] + public async Task SkipLocalsInitOnDownlevelTargetFrameworks(ReferenceAssemblies referenceAssemblies, bool expectSkipLocalsInit) + { + string source = @" +using System.Runtime.InteropServices; +namespace System.Runtime.InteropServices +{ + sealed class GeneratedDllImportAttribute : System.Attribute + { + public GeneratedDllImportAttribute(string a) { } + } +}partial class C +{ + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method(); +}"; + Compilation comp = await TestUtils.CreateCompilationWithReferenceAssemblies(source, referenceAssemblies); + + Compilation newComp = TestUtils.RunGenerators(comp, out _, new Microsoft.Interop.DllImportGenerator()); + + ITypeSymbol c = newComp.GetTypeByMetadataName("C")!; + IMethodSymbol stubMethod = c.GetMembers().OfType().Single(m => m.Name == "Method"); + if (expectSkipLocalsInit) + { + Assert.Contains(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); + } + else + { + Assert.DoesNotContain(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); + } + } + + [Fact] + public async Task SkipLocalsInitNotAddedWhenDefinedAtModuleLevel() + { + string source = @" +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +[module:SkipLocalsInit] +partial class C +{ + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method(); +}"; + Compilation comp = await TestUtils.CreateCompilation(source); + + Compilation newComp = TestUtils.RunGenerators(comp, out _, new Microsoft.Interop.DllImportGenerator()); + + ITypeSymbol c = newComp.GetTypeByMetadataName("C")!; + IMethodSymbol stubMethod = c.GetMembers().OfType().Single(m => m.Name == "Method"); + Assert.DoesNotContain(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); + } + + [Fact] + public async Task SkipLocalsInitNotAddedWhenDefinedAtClassLevel() + { + string source = @" +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +[SkipLocalsInit] +partial class C +{ + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method(); +}"; + Compilation comp = await TestUtils.CreateCompilation(source); + + Compilation newComp = TestUtils.RunGenerators(comp, out _, new Microsoft.Interop.DllImportGenerator()); + + ITypeSymbol c = newComp.GetTypeByMetadataName("C")!; + IMethodSymbol stubMethod = c.GetMembers().OfType().Single(m => m.Name == "Method"); + Assert.DoesNotContain(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); + } + + [Fact] + public async Task SkipLocalsInitNotAddedWhenDefinedOnMethodByUser() + { + string source = @" +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +partial class C +{ + [SkipLocalsInit] + [GeneratedDllImportAttribute(""DoesNotExist"")] + public static partial void Method(); +}"; + Compilation comp = await TestUtils.CreateCompilation(source); + + Compilation newComp = TestUtils.RunGenerators(comp, out _, new Microsoft.Interop.DllImportGenerator()); + + ITypeSymbol c = newComp.GetTypeByMetadataName("C")!; + IMethodSymbol stubMethod = c.GetMembers().OfType().Single(m => m.Name == "Method"); + Assert.DoesNotContain(newComp.GetDiagnostics(), d => d.Id != "CS0579"); // No duplicate attribute error + } + } +} From d7b3dc287bf79b887ca794ea7c5771a1708acfff Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 2 Jul 2021 14:40:55 -0700 Subject: [PATCH 131/161] Require using UnmanagedCallConv instead of the CallingConvention field on GeneratedDllImport (dotnet/runtimelab#1292) Co-authored-by: Aaron Robinson Commit migrated from https://github.com/dotnet/runtimelab/commit/f22931b97e89714a482307c160421eca70ad54f6 --- .../DllImportGenerator/Compatibility.md | 2 + .../ConvertToGeneratedDllImportFixer.cs | 77 +++++++++++++++- .../DllImportGenerator/DllImportGenerator.cs | 5 ++ .../CodeSnippets.cs | 3 - .../CompileFails.cs | 4 +- .../ConvertToGeneratedDllImportFixerTests.cs | 89 ++++++++++++++++++- 6 files changed, 172 insertions(+), 8 deletions(-) diff --git a/docs/design/libraries/DllImportGenerator/Compatibility.md b/docs/design/libraries/DllImportGenerator/Compatibility.md index c8f143f520c7f..112bf44b0b996 100644 --- a/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -14,6 +14,8 @@ The built-in system treats `CharSet.None` as `CharSet.Ansi`. The P/Invoke source [`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. +[`CallingConvention`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.callingconvention) will not be supported for `GeneratedDllImportAttribute`. Users will be required to use the new `UnmanagedCallConvAttribute` attribute instead. This attribute provides support for extensible calling conventions and provides parity with the `UnmanagedCallersOnlyAttribute` attribute and C# function pointer syntax. We will enable our conversion code-fix to automatically convert explicit and known calling convention usage to use the `UnmanagedCallConvAttribute`. + ### `char` marshalling Marshalling of `char` will not be supported when configured with any of the following: 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 d21b12e6e9037..509bb767da9c8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Runtime.InteropServices; @@ -101,10 +102,12 @@ private async Task ConvertToGeneratedDllImport( // Create GeneratedDllImport attribute based on the DllImport attribute var generatedDllImportSyntax = GetGeneratedDllImportAttribute( + editor, generator, dllImportSyntax, methodSymbol.GetDllImportData()!, - generatedDllImportAttrType); + generatedDllImportAttrType, + out SyntaxNode? unmanagedCallConvAttributeMaybe); // Add annotation about potential behavioural and compatibility changes generatedDllImportSyntax = generatedDllImportSyntax.WithAdditionalAnnotations( @@ -113,6 +116,11 @@ private async Task ConvertToGeneratedDllImport( // Replace DllImport with GeneratedDllImport SyntaxNode generatedDeclaration = generator.ReplaceNode(methodSyntax, dllImportSyntax, generatedDllImportSyntax); + if (unmanagedCallConvAttributeMaybe is not null) + { + generatedDeclaration = generator.AddAttributes(generatedDeclaration, unmanagedCallConvAttributeMaybe); + } + // Replace extern keyword with partial keyword generatedDeclaration = generator.WithModifiers( generatedDeclaration, @@ -165,11 +173,14 @@ private async Task ConvertToGeneratedDllImport( } private SyntaxNode GetGeneratedDllImportAttribute( + DocumentEditor editor, SyntaxGenerator generator, AttributeSyntax dllImportSyntax, DllImportData dllImportData, - INamedTypeSymbol generatedDllImportAttrType) + INamedTypeSymbol generatedDllImportAttrType, + out SyntaxNode? unmanagedCallConvAttributeMaybe) { + unmanagedCallConvAttributeMaybe = null; // Create GeneratedDllImport based on the DllImport attribute var generatedDllImportSyntax = generator.ReplaceNode(dllImportSyntax, dllImportSyntax.Name, @@ -200,11 +211,73 @@ private SyntaxNode GetGeneratedDllImportAttribute( // has the equivalent behaviour of ThrowOnUnmappableChar=false, so we can remove the argument. argumentsToRemove.Add(argument); } + else if (IsMatchingNamedArg(attrArg, nameof(DllImportAttribute.CallingConvention))) + { + if (TryCreateUnmanagedCallConvAttributeToEmit( + editor, + generator, + dllImportData.CallingConvention, + out unmanagedCallConvAttributeMaybe)) + { + argumentsToRemove.Add(argument); + } + } } return generator.RemoveNodes(generatedDllImportSyntax, argumentsToRemove); } + private bool TryCreateUnmanagedCallConvAttributeToEmit( + DocumentEditor editor, + SyntaxGenerator generator, + CallingConvention callingConvention, + out SyntaxNode? unmanagedCallConvAttribute) + { + if (editor.SemanticModel.Compilation.GetTypeByMetadataName(TypeNames.UnmanagedCallConvAttribute) is null) + { + unmanagedCallConvAttribute = null; + return false; + } + + if (callingConvention == CallingConvention.Winapi) + { + // Winapi is the default, so we return true that we've created the attribute to emit, + // but set the attribute-to-emit to null since we don't need to emit an attribute. + unmanagedCallConvAttribute = null; + return true; + } + + ITypeSymbol? callingConventionType = callingConvention switch + { + CallingConvention.Cdecl => editor.SemanticModel.Compilation.ObjectType.ContainingAssembly. + GetTypeByMetadataName($"System.Runtime.CompilerServices.CallConvCdecl"), + CallingConvention.StdCall => editor.SemanticModel.Compilation.ObjectType.ContainingAssembly. + GetTypeByMetadataName($"System.Runtime.CompilerServices.CallConvStdcall"), + CallingConvention.ThisCall => editor.SemanticModel.Compilation.ObjectType.ContainingAssembly. + GetTypeByMetadataName($"System.Runtime.CompilerServices.CallConvThiscall"), + CallingConvention.FastCall => editor.SemanticModel.Compilation.ObjectType.ContainingAssembly. + GetTypeByMetadataName($"System.Runtime.CompilerServices.CallConvFastcall"), + _ => null + }; + + // The user is using a calling convention type that doesn't have a matching CallConv type. + // There are no calling conventions like this, so we're already in a state that won't work at runtime. + // Leave the value as-is for now and let the user handle this however they see fit. + if (callingConventionType is null) + { + unmanagedCallConvAttribute = null; + return false; + } + + unmanagedCallConvAttribute = generator.Attribute(TypeNames.UnmanagedCallConvAttribute, + generator.AttributeArgument("CallConvs", + generator.ArrayCreationExpression( + generator.TypeExpression(editor.SemanticModel.Compilation.GetTypeByMetadataName(TypeNames.System_Type)), + new [] { generator.TypeOfExpression(generator.TypeExpression(callingConventionType)) }))); + + return true; + } + private static bool TryGetAttribute(IMethodSymbol method, INamedTypeSymbol attributeType, out AttributeData? attr) { attr = default; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 55292dda451b1..802858ddb1f51 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -130,6 +130,11 @@ public void Execute(GeneratorExecutionContext context) generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar)); } + if (stubDllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CallingConvention)) + { + generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.CallingConvention)); + } + if (lcidConversionAttr != null) { // Using LCIDConversion with GeneratedDllImport is not supported 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 24a4fe249e65f..c438855a69cde 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -178,7 +178,6 @@ partial class Test partial class Test { [GeneratedDllImport(""DoesNotExist"", - CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = ""UserDefinedEntryPoint"", ExactSpelling = true, @@ -202,7 +201,6 @@ partial class Test private const int Two = 2; [GeneratedDllImport(nameof(Test), - CallingConvention = (CallingConvention)1, CharSet = (CharSet)2, EntryPoint = EntryPointName, ExactSpelling = 0 != 1, @@ -211,7 +209,6 @@ partial class Test public static partial void Method1(); [GeneratedDllImport(nameof(Test), - CallingConvention = (CallingConvention)One, CharSet = (CharSet)Two, EntryPoint = EntryPointName, ExactSpelling = One != Two, 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 f07f33e9ae0e2..7a26ca49d72ca 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -56,8 +56,8 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.ByValueParameterWithModifier("In, Out"), 1, 0 }; // Unsupported named arguments - // * BestFitMapping, ThrowOnUnmappableChar - yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 2, 0 }; + // * BestFitMapping, ThrowOnUnmappableChar, CallingConvention + yield return new object[] { CodeSnippets.AllDllImportNamedArguments, 3, 0 }; // LCIDConversion yield return new object[] { CodeSnippets.LCIDConversionAttribute, 1, 0 }; 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 ebd3b3cdc6bb4..fe4a101f2ee0f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs @@ -1,3 +1,6 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Xunit; using static Microsoft.Interop.Analyzers.ConvertToGeneratedDllImportFixer; @@ -261,7 +264,7 @@ partial class Test [DllImport(""DoesNotExist"", ThrowOnUnmappableChar = false)] public static extern int Method2(out int ret); #endif -}}" : @$" +}}" : @$" using System.Runtime.InteropServices; partial class Test {{ @@ -270,6 +273,90 @@ partial class Test [GeneratedDllImport(""DoesNotExist"")] public static partial int {{|CS8795:Method2|}}(out int ret); +}}"; + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task ReplaceableExplicitPlatformDefaultCallingConvention(bool usePreprocessorDefines) + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [DllImport(""DoesNotExist"", CallingConvention = CallingConvention.Winapi, EntryPoint = ""Entry"")] + public static extern int [|Method1|](out int ret); +}}"; + // Fixed source will have CS8795 (Partial method must have an implementation) without generator run + string fixedSource = usePreprocessorDefines + ? @$" +using System.Runtime.InteropServices; +partial class Test +{{ +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + public static partial int {{|CS8795:Method1|}}(out int ret); +#else + [DllImport(""DoesNotExist"", CallingConvention = CallingConvention.Winapi, EntryPoint = ""Entry"")] + public static extern int Method1(out int ret); +#endif +}}" : @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + public static partial int {{|CS8795:Method1|}}(out int ret); +}}"; + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); + } + + [Theory] + [InlineData(CallingConvention.Cdecl, typeof(CallConvCdecl), true)] + [InlineData(CallingConvention.Cdecl, typeof(CallConvCdecl), false)] + [InlineData(CallingConvention.StdCall, typeof(CallConvStdcall), true)] + [InlineData(CallingConvention.StdCall, typeof(CallConvStdcall), false)] + [InlineData(CallingConvention.ThisCall, typeof(CallConvThiscall), true)] + [InlineData(CallingConvention.ThisCall, typeof(CallConvThiscall), false)] + [InlineData(CallingConvention.FastCall, typeof(CallConvFastcall), true)] + [InlineData(CallingConvention.FastCall, typeof(CallConvFastcall), false)] + public async Task ReplaceableCallingConvention(CallingConvention callConv, Type callConvType, bool usePreprocessorDefines) + { + string source = @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [DllImport(""DoesNotExist"", CallingConvention = CallingConvention.{callConv}, EntryPoint = ""Entry"")] + public static extern int [|Method1|](out int ret); +}}"; + // Fixed source will have CS8795 (Partial method must have an implementation) without generator run + string fixedSource = usePreprocessorDefines + ? @$" +using System.Runtime.InteropServices; +partial class Test +{{ +#if DLLIMPORTGENERATOR_ENABLED + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [UnmanagedCallConv(CallConvs = new System.Type[] {{ typeof({callConvType.FullName}) }})] + public static partial int {{|CS8795:Method1|}}(out int ret); +#else + [DllImport(""DoesNotExist"", CallingConvention = CallingConvention.{callConv}, EntryPoint = ""Entry"")] + public static extern int Method1(out int ret); +#endif +}}" : @$" +using System.Runtime.InteropServices; +partial class Test +{{ + [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [UnmanagedCallConv(CallConvs = new System.Type[] {{ typeof({callConvType.FullName}) }})] + public static partial int {{|CS8795:Method1|}}(out int ret); }}"; await VerifyCS.VerifyCodeFixAsync( source, From adf085f1cc27f95e30f870256500205a985651bc Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 7 Jul 2021 11:54:30 -0700 Subject: [PATCH 132/161] Report diagnostics for bad opt-in marshallers at MarshalUsing use-site if the marshaler is in a different compilation than the current compilation. (dotnet/runtimelab#1300) Commit migrated from https://github.com/dotnet/runtimelab/commit/d4b5fd03f51ec7f932f3e8b5856b8233903e9a39 --- .../ManualTypeMarshallingAnalyzer.cs | 30 +++++++---- .../GeneratorDiagnostics.cs | 17 ++++++ .../ManualTypeMarshallingAnalyzerTests.cs | 53 +++++++++++++++++++ 3 files changed, 91 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 90d12505d5ee7..4c8f9f3703ab6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -334,7 +334,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if (!nativeType.IsValueType) { context.ReportDiagnostic( - nativeType.CreateDiagnostic( + GetDiagnosticLocations(context, nativeType, nativeMarshalerAttributeData).CreateDiagnostic( NativeTypeMustHaveRequiredShapeRule, nativeType.ToDisplayString(), type.ToDisplayString())); @@ -379,7 +379,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if (stackAllocSizeField is null or { DeclaredAccessibility: not Accessibility.Public } or { IsConst: false } or { Type: not { SpecialType: SpecialType.System_Int32 } }) { context.ReportDiagnostic( - ctor.CreateDiagnostic( + GetDiagnosticLocations(context, ctor, nativeMarshalerAttributeData).CreateDiagnostic( StackallocConstructorMustHaveStackBufferSizeConstantRule, nativeType.ToDisplayString())); } @@ -392,7 +392,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if (!hasConstructor && !hasStackallocConstructor && !hasToManaged) { context.ReportDiagnostic( - marshalerType.CreateDiagnostic( + GetDiagnosticLocations(context, marshalerType, nativeMarshalerAttributeData).CreateDiagnostic( NativeTypeMustHaveRequiredShapeRule, marshalerType.ToDisplayString(), type.ToDisplayString())); @@ -402,7 +402,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if (validateAllScenarioSupport && hasStackallocConstructor && !hasConstructor) { context.ReportDiagnostic( - marshalerType.CreateDiagnostic( + GetDiagnosticLocations(context, marshalerType, nativeMarshalerAttributeData).CreateDiagnostic( StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, marshalerType.ToDisplayString())); } @@ -415,7 +415,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if (valuePropertyIsRefReturn) { context.ReportDiagnostic( - valueProperty.CreateDiagnostic( + GetDiagnosticLocations(context, valueProperty, nativeMarshalerAttributeData).CreateDiagnostic( RefValuePropertyUnsupportedRule, marshalerType.ToDisplayString())); } @@ -430,14 +430,14 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if ((hasConstructor || hasStackallocConstructor) && valueProperty.GetMethod is null) { context.ReportDiagnostic( - valueProperty.CreateDiagnostic( + GetDiagnosticLocations(context, valueProperty, nativeMarshalerAttributeData).CreateDiagnostic( ValuePropertyMustHaveGetterRule, marshalerType.ToDisplayString())); } if (hasToManaged && valueProperty.SetMethod is null) { context.ReportDiagnostic( - valueProperty.CreateDiagnostic( + GetDiagnosticLocations(context, valueProperty, nativeMarshalerAttributeData).CreateDiagnostic( ValuePropertyMustHaveSetterRule, marshalerType.ToDisplayString())); } @@ -446,7 +446,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if (!nativeType.IsConsideredBlittable()) { context.ReportDiagnostic( - nativeTypeDiagnosticsTargetSymbol.CreateDiagnostic( + GetDiagnosticLocations(context, nativeTypeDiagnosticsTargetSymbol, nativeMarshalerAttributeData).CreateDiagnostic( NativeTypeMustBeBlittableRule, nativeType.ToDisplayString(), type.ToDisplayString())); @@ -486,12 +486,24 @@ IPointerTypeSymbol _ or IMethodSymbol getPinnableReferenceMethodToMention = getPinnableReferenceMethods.Managed ?? getPinnableReferenceMethods.Marshaler!; context.ReportDiagnostic( - nativeTypeDiagnosticsTargetSymbol.CreateDiagnostic( + GetDiagnosticLocations(context, nativeTypeDiagnosticsTargetSymbol, nativeMarshalerAttributeData).CreateDiagnostic( NativeTypeMustBePointerSizedRule, nativeType.ToDisplayString(), getPinnableReferenceMethodToMention.ContainingType.ToDisplayString())); } } + + private ImmutableArray GetDiagnosticLocations(SymbolAnalysisContext context, ISymbol targetSymbol, AttributeData marshallingAttribute) + { + // If we're using a compilation that references another compilation, the symbol locations can be in source in the wrong compilation, + // which can cause exceptions when reporting diagnostics. Make sure the symbol is defined in the current Compilation's source module before using its locations. + // If the symbol is not defined in the current Compilation's source module, report the diagnostic at the marshalling attribute's location. + if (SymbolEqualityComparer.Default.Equals(context.Compilation.SourceModule, targetSymbol.ContainingModule)) + { + return targetSymbol.Locations; + } + return ImmutableArray.Create(marshallingAttribute.ApplicationSyntaxReference?.GetSyntax().GetLocation() ?? Location.None); + } } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 9c5d7952fa6b9..d6d50208d8298 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Linq; @@ -25,6 +26,22 @@ public static Diagnostic CreateDiagnostic( messageArgs: args); } + public static Diagnostic CreateDiagnostic( + this ImmutableArray locations, + DiagnosticDescriptor descriptor, + params object[] args) + { + IEnumerable locationsInSource = locations.Where(l => l.IsInSource); + if (!locationsInSource.Any()) + return Diagnostic.Create(descriptor, Location.None, args); + + return Diagnostic.Create( + descriptor, + location: locationsInSource.First(), + additionalLocations: locationsInSource.Skip(1), + messageArgs: args); + } + public static Diagnostic CreateDiagnostic( this AttributeData attributeData, DiagnosticDescriptor descriptor, diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index 0aae34ff49539..b46e9885b0a8e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -1,3 +1,5 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; using System.Collections.Generic; using System.Threading.Tasks; using Xunit; @@ -827,6 +829,57 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } + [Fact] + public async Task NonBlittableNativeTypeOnMarshalUsingParameter_MultipleCompilations_ReportsDiagnostic_WithLocation() + { + string source1 = @" +using System; +using System.Runtime.InteropServices; + +public struct S +{ + public string s; +} + +public struct Native +{ + private string value; + + public Native(S s) : this() + { + } + + public S ToManaged() => new S(); +} +"; + Compilation compilation1 = await TestUtils.CreateCompilation(source1); + + string source2 = @" +using System; +using System.Runtime.InteropServices; + +static class Test +{ + static void Foo([{|#0:MarshalUsing(typeof(Native))|}] S s) + {} +} +"; + var test = new Verifiers.CSharpCodeFixVerifier.Test + { + ExpectedDiagnostics = + { + VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S") + }, + SolutionTransforms = + { + (solution, projectId) => solution.AddMetadataReference(projectId, compilation1.ToMetadataReference()) + }, + TestCode = source2 + }; + + await test.RunAsync(); + } + [Fact] public async Task NonBlittableNativeTypeOnMarshalUsingReturn_ReportsDiagnostic() { From 9285a1ef044aa044109f278454f864585f24ac4a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 7 Jul 2021 14:38:44 -0700 Subject: [PATCH 133/161] Resolve SizeParamIndex to a TypePositionInfo during MarshallingInfo parsing (dotnet/runtimelab#1293) Commit migrated from https://github.com/dotnet/runtimelab/commit/eea0baeaa690b74e4d2d443d5cf951444b380e06 --- ...CollectionElementMarshallingCodeContext.cs | 6 - .../Marshalling/Forwarder.cs | 6 +- .../ICustomNativeTypeMarshallingStrategy.cs | 5 - .../Marshalling/MarshallingGenerator.cs | 68 ++++---- .../MarshallingAttributeInfo.cs | 158 +++++++++++------- .../DllImportGenerator/Resources.Designer.cs | 9 - .../gen/DllImportGenerator/Resources.resx | 3 - .../gen/DllImportGenerator/StubCodeContext.cs | 2 - .../DllImportGenerator/StubCodeGenerator.cs | 12 -- .../CodeSnippets.cs | 11 ++ .../CompileFails.cs | 1 + 11 files changed, 142 insertions(+), 139 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs index 5e64e126d4fe7..e0fac3b6427cd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs @@ -57,12 +57,6 @@ public override string GetAdditionalIdentifier(TypePositionInfo info, string nam return $"{nativeSpanIdentifier}__{IndexerIdentifier}__{name}"; } - public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) - { - // We don't have parameters to look at when we're in the middle of marshalling an array. - return null; - } - private static string CalculateIndexerIdentifierBasedOnParentContext(StubCodeContext? parentContext) { int i = 0; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs index 385339bcfc2cd..1bd26150668f6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs @@ -48,7 +48,7 @@ private bool TryRehydrateMarshalAsAttribute(TypePositionInfo info, out Attribute if (collectionMarshalling.ElementCountInfo is SizeAndParamIndexInfo countInfo) { - if (countInfo.ConstSize != SizeAndParamIndexInfo.UnspecifiedData) + if (countInfo.ConstSize != SizeAndParamIndexInfo.UnspecifiedConstSize) { marshalAsArguments.Add( AttributeArgument(NameEquals("SizeConst"), null, @@ -56,12 +56,12 @@ private bool TryRehydrateMarshalAsAttribute(TypePositionInfo info, out Attribute Literal(countInfo.ConstSize))) ); } - if (countInfo.ParamIndex != SizeAndParamIndexInfo.UnspecifiedData) + if (countInfo.ParamAtIndex is { ManagedIndex: int paramIndex }) { marshalAsArguments.Add( AttributeArgument(NameEquals("SizeParamIndex"), null, LiteralExpression(SyntaxKind.NumericLiteralExpression, - Literal(countInfo.ParamIndex))) + Literal(paramIndex))) ); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs index 0d9c367fc46ac..6a11a61b46110 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -137,11 +137,6 @@ public CustomNativeTypeWithValuePropertyStubContext(StubCodeContext parentContex public override bool AdditionalTemporaryStateLivesAcrossStages => ParentContext!.AdditionalTemporaryStateLivesAcrossStages; - public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) - { - return ParentContext!.GetTypePositionInfoForManagedIndex(index); - } - public override (string managed, string native) GetIdentifiers(TypePositionInfo info) { return (ParentContext!.GetIdentifiers(info).managed, MarshallerHelpers.GetMarshallerIdentifier(info, ParentContext)); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 40e8a7411a93e..946e96fe56220 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -376,14 +376,14 @@ private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo inf throw new MarshallingNotSupportedException(info, context); } - private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, CountInfo count, StubCodeContext context, AnalyzerConfigOptions options) + private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, CountInfo count, StubCodeContext context) { return count switch { - SizeAndParamIndexInfo(int size, SizeAndParamIndexInfo.UnspecifiedData) => GetConstSizeExpression(size), + SizeAndParamIndexInfo(int size, SizeAndParamIndexInfo.UnspecifiedParam) => GetConstSizeExpression(size), ConstSizeCountInfo(int size) => GetConstSizeExpression(size), - SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedData, int paramIndex) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(context.GetTypePositionInfoForManagedIndex(paramIndex))), - SizeAndParamIndexInfo(int size, int paramIndex) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, GetConstSizeExpression(size), GetExpressionForParam(context.GetTypePositionInfoForManagedIndex(paramIndex)))), + SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedConstSize, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(param)), + SizeAndParamIndexInfo(int size, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, GetConstSizeExpression(size), GetExpressionForParam(param))), CountElementCountInfo(TypePositionInfo elementInfo) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(elementInfo)), _ => throw new MarshallingNotSupportedException(info, context) { @@ -396,53 +396,43 @@ static LiteralExpressionSyntax GetConstSizeExpression(int size) return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(size)); } - ExpressionSyntax GetExpressionForParam(TypePositionInfo? paramInfo) + ExpressionSyntax GetExpressionForParam(TypePositionInfo paramInfo) { - if (paramInfo is null) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.ArraySizeParamIndexOutOfRange - }; - } - else - { - ExpressionSyntax numElementsExpression = GetIndexedNumElementsExpression( - context, - paramInfo, - out int numIndirectionLevels); + ExpressionSyntax numElementsExpression = GetIndexedNumElementsExpression( + context, + paramInfo, + out int numIndirectionLevels); - ITypeSymbol type = paramInfo.ManagedType; - MarshallingInfo marshallingInfo = paramInfo.MarshallingAttributeInfo; + ITypeSymbol type = paramInfo.ManagedType; + MarshallingInfo marshallingInfo = paramInfo.MarshallingAttributeInfo; - for (int i = 0; i < numIndirectionLevels; i++) + for (int i = 0; i < numIndirectionLevels; i++) + { + if (marshallingInfo is NativeContiguousCollectionMarshallingInfo collectionInfo) { - if (marshallingInfo is NativeContiguousCollectionMarshallingInfo collectionInfo) - { - type = collectionInfo.ElementType; - marshallingInfo = collectionInfo.ElementMarshallingInfo; - } - else - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral - }; - } + type = collectionInfo.ElementType; + marshallingInfo = collectionInfo.ElementMarshallingInfo; } - - if (!type.IsIntegralType()) + else { throw new MarshallingNotSupportedException(info, context) { NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral }; } + } - return CastExpression( - PredefinedType(Token(SyntaxKind.IntKeyword)), - ParenthesizedExpression(numElementsExpression)); + if (!type.IsIntegralType()) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral + }; } + + return CastExpression( + PredefinedType(Token(SyntaxKind.IntKeyword)), + ParenthesizedExpression(numElementsExpression)); } static ExpressionSyntax GetIndexedNumElementsExpression(StubCodeContext context, TypePositionInfo numElementsInfo, out int numIndirectionLevels) @@ -607,7 +597,7 @@ private static IMarshallingGenerator CreateNativeCollectionMarshaller( if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { // In this case, we need a numElementsExpression supplied from metadata, so we'll calculate it here. - numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, collectionInfo.ElementCountInfo, context, options); + numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, collectionInfo.ElementCountInfo, context); } marshallingStrategy = new NumElementsExpressionMarshalling( diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index 7e9a08b7d5541..b326834ed3da0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -93,11 +93,13 @@ internal sealed record CountElementCountInfo(TypePositionInfo ElementInfo) : Cou public const string ReturnValueElementName = "return-value"; } - internal sealed record SizeAndParamIndexInfo(int ConstSize, int ParamIndex) : CountInfo + internal sealed record SizeAndParamIndexInfo(int ConstSize, TypePositionInfo? ParamAtIndex) : CountInfo { - public const int UnspecifiedData = -1; + public const int UnspecifiedConstSize = -1; - public static readonly SizeAndParamIndexInfo Unspecified = new(UnspecifiedData, UnspecifiedData); + public const TypePositionInfo UnspecifiedParam = null; + + public static readonly SizeAndParamIndexInfo Unspecified = new(UnspecifiedConstSize, UnspecifiedParam); } /// @@ -143,12 +145,12 @@ internal sealed record NativeContiguousCollectionMarshallingInfo( internal class MarshallingAttributeInfoParser { - private readonly Compilation compilation; - private readonly GeneratorDiagnostics diagnostics; - private readonly DefaultMarshallingInfo defaultInfo; - private readonly ISymbol contextSymbol; - private readonly ITypeSymbol marshalAsAttribute; - private readonly ITypeSymbol marshalUsingAttribute; + private readonly Compilation _compilation; + private readonly GeneratorDiagnostics _diagnostics; + private readonly DefaultMarshallingInfo _defaultInfo; + private readonly ISymbol _contextSymbol; + private readonly ITypeSymbol _marshalAsAttribute; + private readonly ITypeSymbol _marshalUsingAttribute; public MarshallingAttributeInfoParser( Compilation compilation, @@ -156,12 +158,12 @@ public MarshallingAttributeInfoParser( DefaultMarshallingInfo defaultInfo, ISymbol contextSymbol) { - this.compilation = compilation; - this.diagnostics = diagnostics; - this.defaultInfo = defaultInfo; - this.contextSymbol = contextSymbol; - marshalAsAttribute = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute)!; - marshalUsingAttribute = compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute)!; + _compilation = compilation; + _diagnostics = diagnostics; + _defaultInfo = defaultInfo; + _contextSymbol = contextSymbol; + _marshalAsAttribute = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute)!; + _marshalUsingAttribute = compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute)!; } public MarshallingInfo ParseMarshallingInfo( @@ -184,7 +186,7 @@ private MarshallingInfo ParseMarshallingInfo( { if (marshallingAttributesByIndirectionLevel.ContainsKey(indirectionLevel)) { - diagnostics.ReportConfigurationNotSupported(attribute, "Marshalling Data for Indirection Level", indirectionLevel.ToString()); + _diagnostics.ReportConfigurationNotSupported(attribute, "Marshalling Data for Indirection Level", indirectionLevel.ToString()); return NoMarshallingInfo.Instance; } marshallingAttributesByIndirectionLevel.Add(indirectionLevel, attribute); @@ -201,7 +203,7 @@ private MarshallingInfo ParseMarshallingInfo( ref maxIndirectionLevelUsed); if (maxIndirectionLevelUsed < maxIndirectionLevelDataProvided) { - diagnostics.ReportConfigurationNotSupported(marshallingAttributesByIndirectionLevel[maxIndirectionLevelDataProvided], ManualTypeMarshallingHelper.MarshalUsingProperties.ElementIndirectionLevel, maxIndirectionLevelDataProvided.ToString()); + _diagnostics.ReportConfigurationNotSupported(marshallingAttributesByIndirectionLevel[maxIndirectionLevelDataProvided], ManualTypeMarshallingHelper.MarshalUsingProperties.ElementIndirectionLevel, maxIndirectionLevelDataProvided.ToString()); } return info; } @@ -221,16 +223,16 @@ private MarshallingInfo GetMarshallingInfo( INamedTypeSymbol attributeClass = useSiteAttribute.AttributeClass!; if (indirectionLevel == 0 - && SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) + && SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) { // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute - return CreateInfoFromMarshalAs(type, useSiteAttribute, ref maxIndirectionLevelUsed); + return CreateInfoFromMarshalAs(type, useSiteAttribute, inspectedElements, ref maxIndirectionLevelUsed); } - else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) + else if (SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) { if (parsedCountInfo != NoCountInfo.Instance) { - diagnostics.ReportConfigurationNotSupported(useSiteAttribute, "Duplicate Count Info"); + _diagnostics.ReportConfigurationNotSupported(useSiteAttribute, "Duplicate Count Info"); return NoMarshallingInfo.Instance; } parsedCountInfo = CreateCountInfo(useSiteAttribute, inspectedElements); @@ -255,7 +257,7 @@ private MarshallingInfo GetMarshallingInfo( { INamedTypeSymbol attributeClass = typeAttribute.AttributeClass!; - if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute), attributeClass)) + if (SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute), attributeClass)) { // If type is generic, then we need to re-evaluate that it is blittable at usage time. if (type is INamedTypeSymbol { IsGenericType: false } || type.HasOnlyBlittableFields()) @@ -264,7 +266,7 @@ private MarshallingInfo GetMarshallingInfo( } break; } - else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute), attributeClass)) + else if (SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute), attributeClass)) { return CreateNativeMarshallingInfo( type, @@ -276,7 +278,7 @@ private MarshallingInfo GetMarshallingInfo( inspectedElements, ref maxIndirectionLevelUsed); } - else if (SymbolEqualityComparer.Default.Equals(compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute), attributeClass)) + else if (SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute), attributeClass)) { return type.IsConsideredBlittable() ? new BlittableTypeAttributeInfo() : new GeneratedNativeMarshallingAttributeInfo(null! /* TODO: determine naming convention */); } @@ -298,11 +300,11 @@ private MarshallingInfo GetMarshallingInfo( // No marshalling info was computed, but a character encoding was provided. // If the type is a character or string then pass on these details. - if (defaultInfo.CharEncoding != CharEncoding.Undefined + if (_defaultInfo.CharEncoding != CharEncoding.Undefined && (type.SpecialType == SpecialType.System_Char || type.SpecialType == SpecialType.System_String)) { - return new MarshallingInfoStringSupport(defaultInfo.CharEncoding); + return new MarshallingInfoStringSupport(_defaultInfo.CharEncoding); } return NoMarshallingInfo.Instance; @@ -322,7 +324,7 @@ CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet inspectedElements) + { + if (!(_contextSymbol is IMethodSymbol method && 0 <= paramIndex && paramIndex < method.Parameters.Length)) + { + return null; + } + IParameterSymbol param = method.Parameters[paramIndex]; + + if (inspectedElements.Contains(param.Name)) + { + throw new CyclicalCountElementInfoException(inspectedElements, param.Name); + } + + try + { + return TypePositionInfo.CreateForParameter( + param, + ParseMarshallingInfo(param.Type, param.GetAttributes(), inspectedElements.Add(param.Name)), _compilation) with + { ManagedIndex = paramIndex }; + } + // Specifically catch the exception when we're trying to inspect the element that started the cycle. + // This ensures that we've unwound the whole cycle so when we return, there will be no cycles in the count info. + catch (CyclicalCountElementInfoException ex) when (ex.StartOfCycle == param.Name) + { + _diagnostics.ReportConfigurationNotSupported(attrData, $"Cyclical {ManualTypeMarshallingHelper.MarshalUsingProperties.CountElementName}"); + return SizeAndParamIndexInfo.UnspecifiedParam; + } + } + private TypePositionInfo? CreateForElementName(string elementName, ImmutableHashSet inspectedElements) { - if (contextSymbol is IMethodSymbol method) + if (_contextSymbol is IMethodSymbol method) { if (elementName == CountElementCountInfo.ReturnValueElementName) { @@ -385,11 +416,11 @@ CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet inspectedElements, ref int maxIndirectionLevelUsed) { object unmanagedTypeObj = attrData.ConstructorArguments[0].Value!; @@ -412,10 +444,10 @@ MarshallingInfo CreateInfoFromMarshalAs( || unmanagedType == UnmanagedType.CustomMarshaler || unmanagedType == UnmanagedType.SafeArray) { - diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); + _diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); } bool isArrayType = unmanagedType == UnmanagedType.LPArray || unmanagedType == UnmanagedType.ByValArray; - UnmanagedType elementUnmanagedType = (UnmanagedType)SizeAndParamIndexInfo.UnspecifiedData; + UnmanagedType elementUnmanagedType = (UnmanagedType)SizeAndParamIndexInfo.UnspecifiedConstSize; SizeAndParamIndexInfo arraySizeInfo = SizeAndParamIndexInfo.Unspecified; // All other data on attribute is defined as NamedArguments. @@ -432,47 +464,53 @@ MarshallingInfo CreateInfoFromMarshalAs( case nameof(MarshalAsAttribute.MarshalTypeRef): case nameof(MarshalAsAttribute.MarshalType): case nameof(MarshalAsAttribute.MarshalCookie): - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + _diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); break; case nameof(MarshalAsAttribute.ArraySubType): if (!isArrayType) { - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + _diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); } elementUnmanagedType = (UnmanagedType)namedArg.Value.Value!; break; case nameof(MarshalAsAttribute.SizeConst): if (!isArrayType) { - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + _diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); } arraySizeInfo = arraySizeInfo with { ConstSize = (int)namedArg.Value.Value! }; break; case nameof(MarshalAsAttribute.SizeParamIndex): if (!isArrayType) { - diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + _diagnostics.ReportConfigurationNotSupported(attrData, $"{attrData.AttributeClass!.Name}{Type.Delimiter}{namedArg.Key}"); + } + TypePositionInfo? paramIndexInfo = CreateForParamIndex(attrData, (short)namedArg.Value.Value!, inspectedElements); + + if (paramIndexInfo is null) + { + _diagnostics.ReportConfigurationNotSupported(attrData, nameof(MarshalAsAttribute.SizeParamIndex), namedArg.Value.Value.ToString()); } - arraySizeInfo = arraySizeInfo with { ParamIndex = (short)namedArg.Value.Value! }; + arraySizeInfo = arraySizeInfo with { ParamAtIndex = paramIndexInfo }; break; } } if (!isArrayType) { - return new MarshalAsInfo(unmanagedType, defaultInfo.CharEncoding); + return new MarshalAsInfo(unmanagedType, _defaultInfo.CharEncoding); } if (type is not IArrayTypeSymbol { ElementType: ITypeSymbol elementType }) { - diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); + _diagnostics.ReportConfigurationNotSupported(attrData, nameof(UnmanagedType), unmanagedType.ToString()); return NoMarshallingInfo.Instance; } MarshallingInfo elementMarshallingInfo = NoMarshallingInfo.Instance; - if (elementUnmanagedType != (UnmanagedType)SizeAndParamIndexInfo.UnspecifiedData) + if (elementUnmanagedType != (UnmanagedType)SizeAndParamIndexInfo.UnspecifiedConstSize) { - elementMarshallingInfo = new MarshalAsInfo(elementUnmanagedType, defaultInfo.CharEncoding); + elementMarshallingInfo = new MarshalAsInfo(elementUnmanagedType, _defaultInfo.CharEncoding); } else { @@ -484,11 +522,11 @@ MarshallingInfo CreateInfoFromMarshalAs( if (elementType is IPointerTypeSymbol { PointedAtType: ITypeSymbol pointedAt }) { - arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata)?.Construct(pointedAt); + arrayMarshaller = _compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata)?.Construct(pointedAt); } else { - arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata)?.Construct(elementType); + arrayMarshaller = _compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata)?.Construct(elementType); } if (arrayMarshaller is null) @@ -525,7 +563,7 @@ MarshallingInfo CreateNativeMarshallingInfo( methods |= SupportedMarshallingMethods.Pinning; } - ITypeSymbol spanOfByte = compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(compilation.GetSpecialType(SpecialType.System_Byte)); + ITypeSymbol spanOfByte = _compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(_compilation.GetSpecialType(SpecialType.System_Byte)); INamedTypeSymbol nativeType = (INamedTypeSymbol)attrData.ConstructorArguments[0].Value!; @@ -533,14 +571,14 @@ MarshallingInfo CreateNativeMarshallingInfo( { if (isMarshalUsingAttribute) { - diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + _diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); return NoMarshallingInfo.Instance; } else if (type is INamedTypeSymbol namedType) { if (namedType.Arity != nativeType.Arity) { - diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + _diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); return NoMarshallingInfo.Instance; } else @@ -550,12 +588,12 @@ MarshallingInfo CreateNativeMarshallingInfo( } else { - diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + _diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); return NoMarshallingInfo.Instance; } } - ITypeSymbol contiguousCollectionMarshalerAttribute = compilation.GetTypeByMetadataName(TypeNames.GenericContiguousCollectionMarshallerAttribute)!; + ITypeSymbol contiguousCollectionMarshalerAttribute = _compilation.GetTypeByMetadataName(TypeNames.GenericContiguousCollectionMarshallerAttribute)!; bool isContiguousCollectionMarshaller = nativeType.GetAttributes().Any(attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, contiguousCollectionMarshalerAttribute)); IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); @@ -594,7 +632,7 @@ MarshallingInfo CreateNativeMarshallingInfo( if (methods == SupportedMarshallingMethods.None) { - diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + _diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); return NoMarshallingInfo.Instance; } @@ -602,13 +640,13 @@ MarshallingInfo CreateNativeMarshallingInfo( { if (!ManualTypeMarshallingHelper.HasNativeValueStorageProperty(nativeType, spanOfByte)) { - diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + _diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); return NoMarshallingInfo.Instance; } if (!ManualTypeMarshallingHelper.TryGetElementTypeFromContiguousCollectionMarshaller(nativeType, out ITypeSymbol elementType)) { - diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); + _diagnostics.ReportConfigurationNotSupported(attrData, "Native Type", nativeType.ToDisplayString()); return NoMarshallingInfo.Instance; } @@ -641,7 +679,7 @@ bool TryCreateTypeBasedMarshallingInfo( out MarshallingInfo marshallingInfo) { // Check for an implicit SafeHandle conversion. - var conversion = compilation.ClassifyCommonConversion(type, compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); + var conversion = _compilation.ClassifyCommonConversion(type, _compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); if (conversion.Exists && conversion.IsImplicit && (conversion.IsReference || conversion.IsIdentity)) @@ -653,7 +691,7 @@ bool TryCreateTypeBasedMarshallingInfo( { if (ctor.Parameters.Length == 0) { - hasAccessibleDefaultConstructor = compilation.IsSymbolAccessibleWithin(ctor, contextSymbol.ContainingType); + hasAccessibleDefaultConstructor = _compilation.IsSymbolAccessibleWithin(ctor, _contextSymbol.ContainingType); break; } } @@ -668,11 +706,11 @@ bool TryCreateTypeBasedMarshallingInfo( if (elementType is IPointerTypeSymbol { PointedAtType: ITypeSymbol pointedAt }) { - arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata)?.Construct(pointedAt); + arrayMarshaller = _compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata)?.Construct(pointedAt); } else { - arrayMarshaller = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata)?.Construct(elementType); + arrayMarshaller = _compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata)?.Construct(elementType); } if (arrayMarshaller is null) @@ -709,13 +747,13 @@ bool TryCreateTypeBasedMarshallingInfo( private bool TryGetAttributeIndirectionLevel(AttributeData attrData, out int indirectionLevel) { - if (SymbolEqualityComparer.Default.Equals(attrData.AttributeClass, marshalAsAttribute)) + if (SymbolEqualityComparer.Default.Equals(attrData.AttributeClass, _marshalAsAttribute)) { indirectionLevel = 0; return true; } - if (!SymbolEqualityComparer.Default.Equals(attrData.AttributeClass, marshalUsingAttribute)) + if (!SymbolEqualityComparer.Default.Equals(attrData.AttributeClass, _marshalUsingAttribute)) { indirectionLevel = 0; return false; 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 3a93516652e5a..f62ff2d271997 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -69,15 +69,6 @@ internal static string ArraySizeMustBeSpecified { } } - /// - /// Looks up a localized string similar to The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range.. - /// - internal static string ArraySizeParamIndexOutOfRange { - get { - return ResourceManager.GetString("ArraySizeParamIndexOutOfRange", resourceCulture); - } - } - /// /// Looks up a localized string similar to A type marked with 'BlittableTypeAttribute' must be blittable.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 56d1e2c895573..cf5a29e48ca17 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -120,9 +120,6 @@ Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute' or the 'ConstantElementCount' or 'CountElementName' properties to be set on a 'MarshalUsingAttribute'. - - The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range. - A type marked with 'BlittableTypeAttribute' must be blittable. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index 1ea0d17553e65..fe488c608812e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -104,7 +104,5 @@ public virtual string GetAdditionalIdentifier(TypePositionInfo info, string name { return $"{GetIdentifiers(info).native}__{name}"; } - - public abstract TypePositionInfo? GetTypePositionInfoForManagedIndex(int index); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index b21f4348afa97..5679a0235094f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -465,18 +465,6 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc } } - public override TypePositionInfo? GetTypePositionInfoForManagedIndex(int index) - { - foreach (var info in paramsTypeInfo) - { - if (info.ManagedIndex == index) - { - return info; - } - } - return null; - } - private void AppendVariableDeclations(List statementsToUpdate, TypePositionInfo info, IMarshallingGenerator generator) { var (managed, native) = GetIdentifiers(info); 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 c438855a69cde..c35615cea115c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -1327,6 +1327,17 @@ public static partial void Method( [MarshalUsing(CountElementName=""arr"")] ref int[] arr2 ); } +"; + public static string MutuallyRecursiveSizeParamIndexOnParameter => @" +using System.Runtime.InteropServices; +partial class Test +{ + [GeneratedDllImport(""DoesNotExist"")] + public static partial void Method( + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] ref int[] arr, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] ref int[] arr2 + ); +} "; public static string CollectionsOfCollectionsStress => @" 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 7a26ca49d72ca..f121725e793fa 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -121,6 +121,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.RecursiveCountElementNameOnReturnValue, 2, 0 }; yield return new object[] { CodeSnippets.RecursiveCountElementNameOnParameter, 2, 0 }; yield return new object[] { CodeSnippets.MutuallyRecursiveCountElementNameOnParameter, 4, 0 }; + yield return new object[] { CodeSnippets.MutuallyRecursiveSizeParamIndexOnParameter, 4, 0 }; } [Theory] From 5bc2e291328edfa1213f07b18c6333766b37432c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 8 Jul 2021 15:12:53 -0700 Subject: [PATCH 134/161] Update analyzer to correctly handle collection marshallers (dotnet/runtimelab#1299) Commit migrated from https://github.com/dotnet/runtimelab/commit/c11f860f6f5935ac6d2db35ea64f20abb8f562c6 --- .../Analyzers/AnalyzerDiagnostics.cs | 2 +- .../ManualTypeMarshallingAnalyzer.cs | 104 ++++++-- .../DllImportGenerator/Resources.Designer.cs | 30 ++- .../gen/DllImportGenerator/Resources.resx | 14 +- .../TypeSymbolExtensions.cs | 2 +- .../ManualTypeMarshallingAnalyzerTests.cs | 249 +++++++++++++++++- 6 files changed, 360 insertions(+), 41 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs index 88a5f269f322d..dd6a675d56e69 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs @@ -25,7 +25,7 @@ public static class Ids public const string StackallocMarshallingShouldSupportAllocatingMarshallingFallback = Prefix + "011"; public const string StackallocConstructorMustHaveStackBufferSizeConstant = Prefix + "012"; public const string RefValuePropertyUnsupported = Prefix + "014"; - public const string NativeGenericTypeMustBeClosed = Prefix + "016"; + public const string NativeGenericTypeMustBeClosedOrMatchArity = Prefix + "016"; // GeneratedDllImport public const string GeneratedDllImportMissingRequiredModifiers = Prefix + "013"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 4c8f9f3703ab6..351a5e7a69019 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -84,6 +84,16 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeDescription))); + public readonly static DiagnosticDescriptor CollectionNativeTypeMustHaveRequiredShapeRule = + new DiagnosticDescriptor( + Ids.NativeTypeMustHaveRequiredShape, + "NativeTypeMustHaveRequiredShape", + GetResourceString(nameof(Resources.CollectionNativeTypeMustHaveRequiredShapeMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.CollectionNativeTypeMustHaveRequiredShapeDescription))); + public readonly static DiagnosticDescriptor ValuePropertyMustHaveSetterRule = new DiagnosticDescriptor( Ids.ValuePropertyMustHaveSetter, @@ -144,15 +154,15 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.RefValuePropertyUnsupportedDescription))); - public readonly static DiagnosticDescriptor NativeGenericTypeMustBeClosedRule = + public readonly static DiagnosticDescriptor NativeGenericTypeMustBeClosedOrMatchArityRule = new DiagnosticDescriptor( - Ids.NativeGenericTypeMustBeClosed, - "GenericTypeMustBeClosed", - GetResourceString(nameof(Resources.NativeGenericTypeMustBeClosedMessage)), + Ids.NativeGenericTypeMustBeClosedOrMatchArity, + "NativeGenericTypeMustBeClosedOrMatchArity", + GetResourceString(nameof(Resources.NativeGenericTypeMustBeClosedOrMatchArityMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(nameof(Resources.NativeGenericTypeMustBeClosedDescription))); + description: GetResourceString(nameof(Resources.NativeGenericTypeMustBeClosedOrMatchArityDescription))); public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create( @@ -163,13 +173,14 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer GetPinnableReferenceReturnTypeBlittableRule, NativeTypeMustBePointerSizedRule, NativeTypeMustHaveRequiredShapeRule, + CollectionNativeTypeMustHaveRequiredShapeRule, ValuePropertyMustHaveSetterRule, ValuePropertyMustHaveGetterRule, GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule, StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule, StackallocConstructorMustHaveStackBufferSizeConstantRule, RefValuePropertyUnsupportedRule, - NativeGenericTypeMustBeClosedRule); + NativeGenericTypeMustBeClosedOrMatchArityRule); public override void Initialize(AnalysisContext context) { @@ -185,12 +196,14 @@ private void PrepareForAnalysis(CompilationStartAnalysisContext context) var blittableTypeAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute); var nativeMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute); var marshalUsingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute); + var genericContiguousCollectionMarshallerAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.GenericContiguousCollectionMarshallerAttribute); var spanOfByte = context.Compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(context.Compilation.GetSpecialType(SpecialType.System_Byte)); if (generatedMarshallingAttribute is not null && blittableTypeAttribute is not null && nativeMarshallingAttribute is not null && marshalUsingAttribute is not null + && genericContiguousCollectionMarshallerAttribute is not null && spanOfByte is not null) { var perCompilationAnalyzer = new PerCompilationAnalyzer( @@ -198,6 +211,7 @@ private void PrepareForAnalysis(CompilationStartAnalysisContext context) blittableTypeAttribute, nativeMarshallingAttribute, marshalUsingAttribute, + genericContiguousCollectionMarshallerAttribute, spanOfByte, context.Compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_StructLayoutAttribute)!); context.RegisterSymbolAction(context => perCompilationAnalyzer.AnalyzeTypeDefinition(context), SymbolKind.NamedType); @@ -212,6 +226,7 @@ class PerCompilationAnalyzer private readonly INamedTypeSymbol BlittableTypeAttribute; private readonly INamedTypeSymbol NativeMarshallingAttribute; private readonly INamedTypeSymbol MarshalUsingAttribute; + private readonly INamedTypeSymbol GenericContiguousCollectionMarshallerAttribute; private readonly INamedTypeSymbol SpanOfByte; private readonly INamedTypeSymbol StructLayoutAttribute; @@ -219,6 +234,7 @@ public PerCompilationAnalyzer(INamedTypeSymbol generatedMarshallingAttribute, INamedTypeSymbol blittableTypeAttribute, INamedTypeSymbol nativeMarshallingAttribute, INamedTypeSymbol marshalUsingAttribute, + INamedTypeSymbol genericContiguousCollectionMarshallerAttribute, INamedTypeSymbol spanOfByte, INamedTypeSymbol structLayoutAttribute) { @@ -226,6 +242,7 @@ public PerCompilationAnalyzer(INamedTypeSymbol generatedMarshallingAttribute, BlittableTypeAttribute = blittableTypeAttribute; NativeMarshallingAttribute = nativeMarshallingAttribute; MarshalUsingAttribute = marshalUsingAttribute; + GenericContiguousCollectionMarshallerAttribute = genericContiguousCollectionMarshallerAttribute; SpanOfByte = spanOfByte; StructLayoutAttribute = structLayoutAttribute; } @@ -270,7 +287,7 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) } else if (nativeMarshallingAttributeData is not null) { - AnalyzeNativeMarshalerType(context, type, nativeMarshallingAttributeData, validateManagedGetPinnableReference: true, validateAllScenarioSupport: true); + AnalyzeNativeMarshalerType(context, type, nativeMarshallingAttributeData, isNativeMarshallingAttribute:true); } } @@ -292,11 +309,11 @@ public void AnalyzeElement(SymbolAnalysisContext context) { if (context.Symbol is IParameterSymbol param) { - AnalyzeNativeMarshalerType(context, param.Type, attrData, false, false); + AnalyzeNativeMarshalerType(context, param.Type, attrData, isNativeMarshallingAttribute: false); } else if (context.Symbol is IFieldSymbol field) { - AnalyzeNativeMarshalerType(context, field.Type, attrData, false, false); + AnalyzeNativeMarshalerType(context, field.Type, attrData, isNativeMarshallingAttribute: false); } } } @@ -307,11 +324,11 @@ public void AnalyzeReturnType(SymbolAnalysisContext context) AttributeData? attrData = method.GetReturnTypeAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(MarshalUsingAttribute, attr.AttributeClass)); if (attrData is not null) { - AnalyzeNativeMarshalerType(context, method.ReturnType, attrData, false, false); + AnalyzeNativeMarshalerType(context, method.ReturnType, attrData, isNativeMarshallingAttribute: false); } } - private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymbol type, AttributeData nativeMarshalerAttributeData, bool validateManagedGetPinnableReference, bool validateAllScenarioSupport) + private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymbol type, AttributeData nativeMarshalerAttributeData, bool isNativeMarshallingAttribute) { if (nativeMarshalerAttributeData.ConstructorArguments.Length == 0) { @@ -331,7 +348,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb ITypeSymbol nativeType = (ITypeSymbol)nativeMarshalerAttributeData.ConstructorArguments[0].Value!; ISymbol nativeTypeDiagnosticsTargetSymbol = nativeType; - if (!nativeType.IsValueType) + if (nativeType is not INamedTypeSymbol marshalerType) { context.ReportDiagnostic( GetDiagnosticLocations(context, nativeType, nativeMarshalerAttributeData).CreateDiagnostic( @@ -341,11 +358,30 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb return; } - if (nativeType is not INamedTypeSymbol marshalerType) + DiagnosticDescriptor requiredShapeRule = NativeTypeMustHaveRequiredShapeRule; + + ManualTypeMarshallingHelper.NativeTypeMarshallingVariant variant = ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard; + if (marshalerType.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(GenericContiguousCollectionMarshallerAttribute, a.AttributeClass))) + { + variant = ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.ContiguousCollection; + requiredShapeRule = CollectionNativeTypeMustHaveRequiredShapeRule; + if (!ManualTypeMarshallingHelper.TryGetManagedValuesProperty(marshalerType, out _) + || !ManualTypeMarshallingHelper.HasNativeValueStorageProperty(marshalerType, SpanOfByte)) + { + context.ReportDiagnostic( + GetDiagnosticLocations(context, marshalerType, nativeMarshalerAttributeData).CreateDiagnostic( + requiredShapeRule, + nativeType.ToDisplayString(), + type.ToDisplayString())); + return; + } + } + + if (!nativeType.IsValueType) { context.ReportDiagnostic( - nativeMarshalerAttributeData.CreateDiagnostic( - NativeTypeMustHaveRequiredShapeRule, + GetDiagnosticLocations(context, nativeType, nativeMarshalerAttributeData).CreateDiagnostic( + requiredShapeRule, nativeType.ToDisplayString(), type.ToDisplayString())); return; @@ -353,12 +389,26 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb if (marshalerType.IsUnboundGenericType) { - context.ReportDiagnostic( - nativeMarshalerAttributeData.CreateDiagnostic( - NativeGenericTypeMustBeClosedRule, - nativeType.ToDisplayString(), - type.ToDisplayString())); - return; + if (!isNativeMarshallingAttribute) + { + context.ReportDiagnostic( + nativeMarshalerAttributeData.CreateDiagnostic( + NativeGenericTypeMustBeClosedOrMatchArityRule, + nativeType.ToDisplayString(), + type.ToDisplayString())); + return; + } + if (type is not INamedTypeSymbol namedType || marshalerType.TypeArguments.Length != namedType.TypeArguments.Length) + { + context.ReportDiagnostic( + nativeMarshalerAttributeData.CreateDiagnostic( + NativeGenericTypeMustBeClosedOrMatchArityRule, + nativeType.ToDisplayString(), + type.ToDisplayString())); + return; + } + // Construct the marshaler type around the same type arguments as the managed type. + nativeType = marshalerType = marshalerType.ConstructedFrom.Construct(namedType.TypeArguments, namedType.TypeArgumentNullableAnnotations); } bool hasConstructor = false; @@ -370,9 +420,9 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb continue; } - hasConstructor = hasConstructor || ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type, ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard); + hasConstructor = hasConstructor || ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type, variant); - if (!hasStackallocConstructor && ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, SpanOfByte, ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard)) + if (!hasStackallocConstructor && ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, SpanOfByte, variant)) { hasStackallocConstructor = true; IFieldSymbol stackAllocSizeField = nativeType.GetMembers("StackBufferSize").OfType().FirstOrDefault(); @@ -393,13 +443,13 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb { context.ReportDiagnostic( GetDiagnosticLocations(context, marshalerType, nativeMarshalerAttributeData).CreateDiagnostic( - NativeTypeMustHaveRequiredShapeRule, + requiredShapeRule, marshalerType.ToDisplayString(), type.ToDisplayString())); } // Validate that this type can support marshalling when stackalloc is not usable. - if (validateAllScenarioSupport && hasStackallocConstructor && !hasConstructor) + if (isNativeMarshallingAttribute && hasStackallocConstructor && !hasConstructor) { context.ReportDiagnostic( GetDiagnosticLocations(context, marshalerType, nativeMarshalerAttributeData).CreateDiagnostic( @@ -455,7 +505,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb // Use a tuple here instead of an anonymous type so we can do the reassignment and pattern matching below. var getPinnableReferenceMethods = new { - Managed = validateManagedGetPinnableReference? ManualTypeMarshallingHelper.FindGetPinnableReference(type) : null, + Managed = isNativeMarshallingAttribute ? ManualTypeMarshallingHelper.FindGetPinnableReference(type) : null, Marshaler = ManualTypeMarshallingHelper.FindGetPinnableReference(marshalerType) }; @@ -466,7 +516,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb context.ReportDiagnostic(getPinnableReferenceMethods.Managed.CreateDiagnostic(GetPinnableReferenceReturnTypeBlittableRule)); } // Validate that our marshaler supports scenarios where GetPinnableReference cannot be used. - if (validateAllScenarioSupport && (!hasConstructor || valueProperty is { GetMethod: null })) + if (isNativeMarshallingAttribute && (!hasConstructor || valueProperty is { GetMethod: null })) { context.ReportDiagnostic( nativeMarshalerAttributeData.CreateDiagnostic( 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 f62ff2d271997..e8a16abf529c7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -105,6 +105,24 @@ internal static string CannotHaveMultipleMarshallingAttributesMessage { } } + /// + /// Looks up a localized string similar to A native type with the 'GenericContiguousCollectionMarshallerAttribute' must have at least one of the two marshalling methods as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' to enable marshalling the managed type.. + /// + internal static string CollectionNativeTypeMustHaveRequiredShapeDescription { + get { + return ResourceManager.GetString("CollectionNativeTypeMustHaveRequiredShapeDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' must be a value type and have a constructor that takes two parameters, one of type '{1}' and an 'int', or have a parameterless instance method named 'ToManaged' that returns '{1}' as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>'. + /// + internal static string CollectionNativeTypeMustHaveRequiredShapeMessage { + get { + return ResourceManager.GetString("CollectionNativeTypeMustHaveRequiredShapeMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to The specified collection size parameter for an collection must be an integer type. If the size information is applied to a nested collection, the size parameter must be a collection of one less level of nesting with an integral element.. /// @@ -385,20 +403,20 @@ internal static string MarshallingStringOrCharAsUndefinedNotSupported { } /// - /// Looks up a localized string similar to The native type '{0}' must be a closed generic so the emitted code can use a specific instantiation.. + /// Looks up a localized string similar to The native type '{0}' must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.. /// - internal static string NativeGenericTypeMustBeClosedDescription { + internal static string NativeGenericTypeMustBeClosedOrMatchArityDescription { get { - return ResourceManager.GetString("NativeGenericTypeMustBeClosedDescription", resourceCulture); + return ResourceManager.GetString("NativeGenericTypeMustBeClosedOrMatchArityDescription", resourceCulture); } } /// - /// Looks up a localized string similar to The native type '{0}' for managed type '{1}' must be a closed generic type.. + /// Looks up a localized string similar to The native type '{0}' for managed type '{1}' must be a closed generic type or have the same arity as the managed type.. /// - internal static string NativeGenericTypeMustBeClosedMessage { + internal static string NativeGenericTypeMustBeClosedOrMatchArityMessage { get { - return ResourceManager.GetString("NativeGenericTypeMustBeClosedMessage", resourceCulture); + return ResourceManager.GetString("NativeGenericTypeMustBeClosedOrMatchArityMessage", resourceCulture); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index cf5a29e48ca17..24a8b83f488a0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -226,11 +226,11 @@ Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'. - - The native type '{0}' must be a closed generic so the emitted code can use a specific instantiation. + + The native type '{0}' must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation. - - The native type '{0}' for managed type '{1}' must be a closed generic type. + + The native type '{0}' for managed type '{1}' must be a closed generic type or have the same arity as the managed type. A native type for a given type must be blittable. @@ -256,6 +256,12 @@ The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}' + + A native type with the 'GenericContiguousCollectionMarshallerAttribute' must have at least one of the two marshalling methods as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' to enable marshalling the managed type. + + + The native type '{0}' must be a value type and have a constructor that takes two parameters, one of type '{1}' and an 'int', or have a parameterless instance method named 'ToManaged' that returns '{1}' as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' + The '[Out]' attribute is only supported on array parameters. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index 2cf28efc94349..a37aa5708efad 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -85,7 +85,7 @@ private static bool IsConsideredBlittable(this ITypeSymbol type, ImmutableHashSe return true; } - if (!type.IsValueType || type.IsReferenceType) + if (type.IsReferenceType) { return false; } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index b46e9885b0a8e..d82b84c9bb11b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -615,6 +615,197 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } + [Fact] + public async Task CollectionNativeTypeWithNoMarshallingMethods_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[GenericContiguousCollectionMarshaller] +struct {|#0:Native|} +{ +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); + } + + [Fact] + public async Task CollectionNativeTypeWithWrongConstructor_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[GenericContiguousCollectionMarshaller] +ref struct {|#0:Native|} +{ + public Native(S s) : this() {} + + public Span ManagedValues { get; set; } + public Span NativeValueStorage { get; set; } + + public IntPtr Value { get; } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); + } + + [Fact] + public async Task CollectionNativeTypeWithCorrectConstructor_DoesNotReportDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[GenericContiguousCollectionMarshaller] +ref struct Native +{ + public Native(S s, int nativeElementSize) : this() {} + + public Span ManagedValues { get; set; } + public Span NativeValueStorage { get; set; } + + public IntPtr Value { get; } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task CollectionNativeTypeWithIncorrectStackallocConstructor_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[GenericContiguousCollectionMarshaller] +ref struct {|#0:Native|} +{ + public Native(S s, Span stackSpace) : this() {} + + public const int StackBufferSize = 1; + + public Span ManagedValues { get; set; } + public Span NativeValueStorage { get; set; } + + public IntPtr Value { get; } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); + } + + [Fact] + public async Task CollectionNativeTypeWithOnlyStackallocConstructor_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[GenericContiguousCollectionMarshaller] +ref struct {|#0:Native|} +{ + public Native(S s, Span stackSpace, int nativeElementSize) : this() {} + + public const int StackBufferSize = 1; + + public Span ManagedValues { get; set; } + public Span NativeValueStorage { get; set; } + + public IntPtr Value { get; } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithLocation(0).WithArguments("Native", "S")); + } + + [Fact] + public async Task CollectionNativeTypeWithMissingManagedValuesProperty_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[GenericContiguousCollectionMarshaller] +ref struct {|#0:Native|} +{ + public Native(S s, int nativeElementSize) : this() {} + + public Span NativeValueStorage { get; set; } + + public IntPtr Value { get; } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); + } + + [Fact] + public async Task CollectionNativeTypeWithMissingNativeValueStorageProperty_ReportsDiagnostic() + { + string source = @" +using System; +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native))] +class S +{ + public byte c; +} + +[GenericContiguousCollectionMarshaller] +ref struct {|#0:Native|} +{ + public Native(S s, int nativeElementSize) : this() {} + + public Span ManagedValues { get; set; } + + public IntPtr Value { get; } +}"; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); + } + [Fact] public async Task NativeTypeWithOnlyConstructor_DoesNotReportDiagnostic() { @@ -1005,7 +1196,7 @@ public Native(S s) } [Fact] - public async Task UninstantiatedGenericNativeType_ReportsDiagnostic() + public async Task UninstantiatedGenericNativeTypeOnNonGeneric_ReportsDiagnostic() { string source = @" @@ -1029,7 +1220,61 @@ public Native(S s) public T Value { get; set; } }"; - await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeGenericTypeMustBeClosedRule).WithLocation(0).WithArguments("Native<>", "S")); + await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeGenericTypeMustBeClosedOrMatchArityRule).WithLocation(0).WithArguments("Native<>", "S")); + } + + [Fact] + public async Task UninstantiatedGenericNativeTypeOnGenericWithArityMismatch_ReportsDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[{|#0:NativeMarshalling(typeof(Native<,>))|}] +struct S +{ + public string s; +} + +struct Native + where T : new() +{ + public Native(S s) + { + Value = 0; + } + + public S ToManaged() => new S(); + + public int Value { get; set; } +}"; + await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeGenericTypeMustBeClosedOrMatchArityRule).WithLocation(0).WithArguments("Native<,>", "S")); + } + + [Fact] + public async Task UninstantiatedGenericNativeTypeOnGenericWithArityMatch_DoesNotReportDiagnostic() + { + string source = @" +using System.Runtime.InteropServices; + +[NativeMarshalling(typeof(Native<>))] +struct S +{ + public T t; +} + +struct Native + where T : new() +{ + public Native(S s) + { + Value = 0; + } + + public S ToManaged() => new S(); + + public int Value { get; set; } +}"; + await VerifyCS.VerifyAnalyzerAsync(source); } [Fact] From 86f35c342c8e5ca8a8313a3513dfcdb12f2700b1 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 9 Jul 2021 10:04:22 -0700 Subject: [PATCH 135/161] Improve diagnostics messages for invalid custom native type marshalling and cyclical element info. (dotnet/runtimelab#1306) Co-authored-by: Elinor Fung Commit migrated from https://github.com/dotnet/runtimelab/commit/cd18bc47d5be7f18e80aef8c22f8848bed8cdffe --- .../GeneratorDiagnostics.cs | 21 ++++++++ .../MarshallingAttributeInfo.cs | 33 +++++++----- .../DllImportGenerator/Resources.Designer.cs | 54 +++++++++++++++++++ .../gen/DllImportGenerator/Resources.resx | 20 ++++++- 4 files changed, 115 insertions(+), 13 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index d6d50208d8298..51531f6c1a00b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -154,6 +154,16 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); + public readonly static DiagnosticDescriptor MarshallingAttributeConfigurationNotSupported = + new DiagnosticDescriptor( + Ids.ConfigurationNotSupported, + GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), + GetResourceString(nameof(Resources.ConfigurationNotSupportedMessageMarshallingInfo)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); + public readonly static DiagnosticDescriptor TargetFrameworkNotSupported = new DiagnosticDescriptor( Ids.TargetFrameworkNotSupported, @@ -280,6 +290,17 @@ internal void ReportMarshallingNotSupported( } } + internal void ReportInvalidMarshallingAttributeInfo( + AttributeData attributeData, + string reasonResourceName, + params string[] reasonArgs) + { + this.context.ReportDiagnostic( + attributeData.CreateDiagnostic( + GeneratorDiagnostics.MarshallingAttributeConfigurationNotSupported, + new LocalizableResourceString(reasonResourceName, Resources.ResourceManager, typeof(Resources), reasonArgs))); + } + /// /// Report diagnostic for targeting a framework that is not supported /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index b326834ed3da0..d69f2ea1a5855 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -186,7 +186,7 @@ private MarshallingInfo ParseMarshallingInfo( { if (marshallingAttributesByIndirectionLevel.ContainsKey(indirectionLevel)) { - _diagnostics.ReportConfigurationNotSupported(attribute, "Marshalling Data for Indirection Level", indirectionLevel.ToString()); + _diagnostics.ReportInvalidMarshallingAttributeInfo(attribute, nameof(Resources.DuplicateMarshallingInfo), indirectionLevel.ToString()); return NoMarshallingInfo.Instance; } marshallingAttributesByIndirectionLevel.Add(indirectionLevel, attribute); @@ -203,7 +203,11 @@ private MarshallingInfo ParseMarshallingInfo( ref maxIndirectionLevelUsed); if (maxIndirectionLevelUsed < maxIndirectionLevelDataProvided) { - _diagnostics.ReportConfigurationNotSupported(marshallingAttributesByIndirectionLevel[maxIndirectionLevelDataProvided], ManualTypeMarshallingHelper.MarshalUsingProperties.ElementIndirectionLevel, maxIndirectionLevelDataProvided.ToString()); + _diagnostics.ReportInvalidMarshallingAttributeInfo( + marshallingAttributesByIndirectionLevel[maxIndirectionLevelDataProvided], + nameof(Resources.ExtraneousMarshallingInfo), + maxIndirectionLevelDataProvided.ToString(), + maxIndirectionLevelUsed.ToString()); } return info; } @@ -232,7 +236,7 @@ private MarshallingInfo GetMarshallingInfo( { if (parsedCountInfo != NoCountInfo.Instance) { - _diagnostics.ReportConfigurationNotSupported(useSiteAttribute, "Duplicate Count Info"); + _diagnostics.ReportInvalidMarshallingAttributeInfo(useSiteAttribute, nameof(Resources.DuplicateCountInfo)); return NoMarshallingInfo.Instance; } parsedCountInfo = CreateCountInfo(useSiteAttribute, inspectedElements); @@ -333,7 +337,7 @@ CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet + /// Looks up a localized string similar to The specified marshalling configuration is not supported by source-generated P/Invokes. {0}. + /// + internal static string ConfigurationNotSupportedMessageMarshallingInfo { + get { + return ResourceManager.GetString("ConfigurationNotSupportedMessageMarshallingInfo", resourceCulture); + } + } + /// /// Looks up a localized string similar to The specified '{0}' configuration for parameter '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead.. /// @@ -186,6 +195,15 @@ internal static string ConfigurationNotSupportedTitle { } } + /// + /// Looks up a localized string similar to Only one of 'ConstantElementCount' or 'ElementCountInfo' may be used in a 'MarshalUsingAttribute' for a given 'ElementIndirectionLevel'. + /// + internal static string ConstantAndElementCountInfoDisallowed { + get { + return ResourceManager.GetString("ConstantAndElementCountInfoDisallowed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time. /// @@ -258,6 +276,42 @@ internal static string CustomTypeMarshallingNativeToManagedUnsupported { } } + /// + /// Looks up a localized string similar to This element cannot depend on '{0}' for collection size information without creating a dependency cycle. + /// + internal static string CyclicalCountInfo { + get { + return ResourceManager.GetString("CyclicalCountInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Count information for a given element at a given indirection level can only be specified once. + /// + internal static string DuplicateCountInfo { + get { + return ResourceManager.GetString("DuplicateCountInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Multiple marshalling attributes per element per indirection level is unsupported, but duplicate information was provided for indirection level {0}. + /// + internal static string DuplicateMarshallingInfo { + get { + return ResourceManager.GetString("DuplicateMarshallingInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Marshalling info was specified for 'ElementIndirectionLevel' {0}, but marshalling info was only needed for {1} levels of indirection. + /// + internal static string ExtraneousMarshallingInfo { + get { + return ResourceManager.GetString("ExtraneousMarshallingInfo", resourceCulture); + } + } + /// /// Looks up a localized string similar to Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index 24a8b83f488a0..d2d2adeffc2c1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -141,6 +141,9 @@ The '{0}' configuration is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead. + + The specified marshalling configuration is not supported by source-generated P/Invokes. {0}. + The specified '{0}' configuration for parameter '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular `DllImport` instead. @@ -153,6 +156,9 @@ Specified configuration is not supported by source-generated P/Invokes. + + Only one of 'ConstantElementCount' or 'ElementCountInfo' may be used in a 'MarshalUsingAttribute' for a given 'ElementIndirectionLevel' + Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time @@ -178,6 +184,18 @@ The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it. + + This element cannot depend on '{0}' for collection size information without creating a dependency cycle + + + Count information for a given element at a given indirection level can only be specified once + + + Multiple marshalling attributes per element per indirection level is unsupported, but duplicate information was provided for indirection level {0} + + + Marshalling info was specified for 'ElementIndirectionLevel' {0}, but marshalling info was only needed for {1} level(s) of indirection + Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types. @@ -334,4 +352,4 @@ The 'Value' property on the native type '{0}' must have a setter - \ No newline at end of file + From 802e7b971dbd5b87cf3d607280f9e9b90186154d Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 4 Aug 2021 16:53:52 -0700 Subject: [PATCH 136/161] Update compat doc (dotnet/runtimelab#1379) Commit migrated from https://github.com/dotnet/runtimelab/commit/1cf4425379bfb119d2eed24826bf21aa7ab70a3e --- .../DllImportGenerator/Compatibility.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/design/libraries/DllImportGenerator/Compatibility.md b/docs/design/libraries/DllImportGenerator/Compatibility.md index 112bf44b0b996..e98b6a4ec5fa2 100644 --- a/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -4,7 +4,7 @@ Documentation on compatibility guidance and the current state. The version headi ## Version 1 -The focus of version 1 is to support `NetCoreApp`. This implies that anything not needed by `NetCoreApp` is subject to change. +The focus of version 1 is to support `NetCoreApp`. This implies that anything not needed by `NetCoreApp` is subject to change. Only .NET 6+ is supported. ### Semantic changes compared to `DllImportAttribute` @@ -16,6 +16,15 @@ The built-in system treats `CharSet.None` as `CharSet.Ansi`. The P/Invoke source [`CallingConvention`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.callingconvention) will not be supported for `GeneratedDllImportAttribute`. Users will be required to use the new `UnmanagedCallConvAttribute` attribute instead. This attribute provides support for extensible calling conventions and provides parity with the `UnmanagedCallersOnlyAttribute` attribute and C# function pointer syntax. We will enable our conversion code-fix to automatically convert explicit and known calling convention usage to use the `UnmanagedCallConvAttribute`. +### Required references + +The following framework references are required: +- `System.Memory` +- `System.Runtime` +- `System.Runtime.InteropServices` + +These are all part of `NetCoreApp` and will be referenced by default unless [implicit framework references are disabled](https://docs.microsoft.com/dotnet/core/project-sdk/msbuild-props#disableimplicitframeworkreferences). + ### `char` marshalling Marshalling of `char` will not be supported when configured with any of the following: @@ -72,6 +81,13 @@ In the source generated marshalling, the `[In]` and `[Out]` attributes will only Support for struct marshalling in the source-generated marshalling is described in [StructMarshalling.md](StructMarshalling.md). +### Unsupported types + +Unlike the built-in system, the source generator does not support marshalling for the following types: +- [`CriticalHandle`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.criticalhandle) +- [`HandleRef`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.handleref) +- [`StringBuilder`](https://docs.microsoft.com/dotnet/api/system.text.stringbuilder) + ## Verison 0 This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. From 9cdc1e5ef9e04b32b0eb081b5bf5bd0491aeb274 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 6 Aug 2021 16:19:53 -0700 Subject: [PATCH 137/161] Use the repo-local NuGet.config with GetReferenceAssemblies so we can use pre-release ref packs reliably. (dotnet/runtimelab#1375) Commit migrated from https://github.com/dotnet/runtimelab/commit/397ccce0d8612c3655878ea83466941276b32c43 --- .../DllImportGenerator.UnitTests.csproj | 4 ++++ .../tests/DllImportGenerator.UnitTests/TestUtils.cs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index 7fd03c53f8c10..1ebce78dadc54 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -26,4 +26,8 @@ + + + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index 995c2f0450f1d..fd49c82ccf914 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -2,6 +2,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.IO; @@ -96,7 +97,8 @@ public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() new PackageIdentity( "Microsoft.NETCore.App.Ref", "6.0.0-preview.6.21317.4"), - Path.Combine("ref", "net6.0")); + Path.Combine("ref", "net6.0")) + .WithNuGetConfigFilePath(Path.Combine(Path.GetDirectoryName(typeof(TestUtils).Assembly.Location)!, "NuGet.config")); // Include the assembly containing the new attribute and all of its references. // [TODO] Remove once the attribute has been added to the BCL From 02fa63e1f6198f7dadcbec4202d46b6e541c19ff Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 6 Aug 2021 16:22:29 -0700 Subject: [PATCH 138/161] Plan for .NET 7 integration (dotnet/runtimelab#1378) * Plan for .NET 7 integration Commit migrated from https://github.com/dotnet/runtimelab/commit/cd76a36d7d7744bd52c65b9f5ff3d303900cb687 --- .../DllImportGenerator/RuntimeConsumption.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/design/libraries/DllImportGenerator/RuntimeConsumption.md diff --git a/docs/design/libraries/DllImportGenerator/RuntimeConsumption.md b/docs/design/libraries/DllImportGenerator/RuntimeConsumption.md new file mode 100644 index 0000000000000..fa087a8db5ebd --- /dev/null +++ b/docs/design/libraries/DllImportGenerator/RuntimeConsumption.md @@ -0,0 +1,43 @@ +# Integration into dotnet/runtime + +The prototype phase of the `DllImport` source generator is complete. The process and work done was tracked at [dotnet/runtime@43060](https://github.com/dotnet/runtime/issues/43060). The results of the prototype have provided us with some confidence that the current approach is viable and can move forward to consume the source generator in the .NET 7 timeframe. The plan for integration into the dotnet/runtime repository follows. + +Converting the prototype into a production ready product is required prior to consumption in the product. This means integration will be done in two phases, production-ready and consumption, that can be done in parallel in many cases. There is a third phase that is considered a stretch goal – productization. + +## Production-ready + +The following items must be considered to make this prototype production-ready. + +**Move source from dotnet/runtimelab** – Move the prototype source from its branch in [dotnet/runtimelab](https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator/DllImportGenerator) to [dotnet/runtime](https://github.com/dotnet/runtime). Guidance on destination can be found at [`project-guidelines.md`](https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/project-guidelines.md) – plan is under `libraries/System.Runtime.InteropServices`. Commit history should be retained during this move. + - Includes unit and scenario test integration into the `libraries/` pattern. + +**Attributes into `System.Private.CoreLib`** – Prior to productization, triggering and support attributes should be moved into a global space for consumption by `NetCoreApp`. + +**Product impact tenets** – Size impact, security, and convention reviews. Patterns have been uncovered that could be improved upon in the source generation step. Collapsing some of these patterns would help with reducing size impact and addressing potential security issues. Code generation convention changes may result in API proposals for marshal helpers – see [struct marshalling](./StructMarshalling.md). + +**UX** – Source generators can run from a command line build as well as from the IDE. Running from within the IDE will impact the UX of the IDE and therefore performance investigations are needed to ensure the generator doesn't degrade the developer inner-loop. + +**Stakeholder feedback** – An exit criteria for the prototype was to reach out to stakeholders and get feedback on the experience and generated code. Responses to all feedback prior to product consumption is expected. + +## Consumption + +The following items must be considered to make the prototype consumable in [dotnet/runtime repository](https://github.com/dotnet/runtime). + +**In-box source generation** – Guidance for [providing an in-box source generator has been documented](https://github.com/dotnet/designs/blob/main/accepted/2021/InboxSourceGenerators.md). The document should be considered a primary source for best-practices that will eventually be needed for productization. + +**Versioning/Shipping/Servicing** – Partially captured in the "In-box source generation" document, but stated item is being called out. + +**Merge in feature branch** – Integration work for updates to `NetCoreApp` have started in [`feature/use-dllimport-generator`](https://github.com/dotnet/runtime/tree/feature/use-dllimport-generator). + - Question on the impact of [source build](https://github.com/dotnet/source-build) for dotnet/runtime. + +## Productization + +The following items must be considered to make this prototype into a product. + +**Localization** – We must ensure user observed messages are properly localized and adhere to the Globalization/Localization tenets. + +**API Review** – [`GeneratedDllImportAttribute`](https://github.com/dotnet/runtime/issues/46822); Supporting [attributes](https://github.com/dotnet/runtime/issues/46838) and marshalling helper types. + +**Distribution** – The consumption of the source generator product is assumed to be in-box and/or as a standalone NuPkg. If not distributed as NuPkg there is no known additional work here. + +**Documentation/Sample** – Productization will require new documentation and at least one official example. From d8775eea98c7ea5911f2752d7746dfe9e7d14fc6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 11:10:41 -0700 Subject: [PATCH 139/161] Move to using the new Roslyn IIncrementalGenerator API for better in-VS performance (dotnet/runtimelab#1374) Commit migrated from https://github.com/dotnet/runtimelab/commit/90c617d39a9775e8eb0c5d4aba2f0cc6932bfb87 --- .../gen/DllImportGenerator/Comparers.cs | 95 ++++ .../DllImportGenerator/DllImportGenerator.cs | 504 +++++++++++------- ...lImportStub.cs => DllImportStubContext.cs} | 176 +++--- .../GeneratedDllImportData.cs | 48 ++ .../GeneratorDiagnostics.cs | 108 ++-- .../gen/DllImportGenerator/ManagedTypeInfo.cs | 74 +++ .../Marshalling/BlittableMarshaller.cs | 2 +- .../Marshalling/BoolMarshaller.cs | 2 +- .../Marshalling/CharMarshaller.cs | 2 +- .../Marshalling/DelegateMarshaller.cs | 2 +- .../Marshalling/Forwarder.cs | 4 +- .../Marshalling/HResultExceptionMarshaller.cs | 2 +- .../Marshalling/MarshallingGenerator.cs | 99 ++-- .../Marshalling/SafeHandleMarshaller.cs | 8 +- .../MarshallingAttributeInfo.cs | 94 ++-- .../gen/DllImportGenerator/StubCodeContext.cs | 4 +- .../DllImportGenerator/StubCodeGenerator.cs | 175 +++--- .../DllImportGenerator/TypePositionInfo.cs | 44 +- .../TypeSymbolExtensions.cs | 4 +- .../UnreachableException.cs | 13 + .../Ancillary.Interop.csproj | 1 - .../IncrementalGenerationTests.cs | 203 +++++++ .../DllImportGenerator.UnitTests/TestUtils.cs | 56 +- 23 files changed, 1131 insertions(+), 589 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs rename src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/{DllImportStub.cs => DllImportStubContext.cs} (62%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManagedTypeInfo.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs new file mode 100644 index 0000000000000..e1ded7b4ab184 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs @@ -0,0 +1,95 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; + +namespace Microsoft.Interop +{ + internal static class Comparers + { + /// + /// Comparer for the set of all of the generated stubs and diagnostics generated for each of them. + /// + public static readonly IEqualityComparer)>> GeneratedSourceSet = new ImmutableArraySequenceEqualComparer<(string, ImmutableArray)>(new CustomValueTupleElementComparer>(EqualityComparer.Default, new ImmutableArraySequenceEqualComparer(EqualityComparer.Default))); + + /// + /// Comparer for an individual generated stub source as a string and the generated diagnostics for the stub. + /// + public static readonly IEqualityComparer<(string, ImmutableArray)> GeneratedSource = new CustomValueTupleElementComparer>(EqualityComparer.Default, new ImmutableArraySequenceEqualComparer(EqualityComparer.Default)); + + /// + /// Comparer for an individual generated stub source as a syntax tree and the generated diagnostics for the stub. + /// + public static readonly IEqualityComparer<(MemberDeclarationSyntax Syntax, ImmutableArray Diagnostics)> GeneratedSyntax = new CustomValueTupleElementComparer>(new SyntaxEquivalentComparer(), new ImmutableArraySequenceEqualComparer(EqualityComparer.Default)); + + /// + /// Comparer for the context used to generate a stub and the original user-provided syntax that triggered stub creation. + /// + public static readonly IEqualityComparer<(MethodDeclarationSyntax Syntax, DllImportGenerator.IncrementalStubGenerationContext StubContext)> CalculatedContextWithSyntax = new CustomValueTupleElementComparer(new SyntaxEquivalentComparer(), EqualityComparer.Default); + } + + /// + /// Generic comparer to compare two instances element by element. + /// + /// The type of immutable array element. + internal class ImmutableArraySequenceEqualComparer : IEqualityComparer> + { + private readonly IEqualityComparer elementComparer; + + /// + /// Creates an with a custom comparer for the elements of the collection. + /// + /// The comparer instance for the collection elements. + public ImmutableArraySequenceEqualComparer(IEqualityComparer elementComparer) + { + this.elementComparer = elementComparer; + } + + public bool Equals(ImmutableArray x, ImmutableArray y) + { + return x.SequenceEqual(y, elementComparer); + } + + public int GetHashCode(ImmutableArray obj) + { + throw new UnreachableException(); + } + } + + internal class SyntaxEquivalentComparer : IEqualityComparer + { + public bool Equals(SyntaxNode x, SyntaxNode y) + { + return x.IsEquivalentTo(y); + } + + public int GetHashCode(SyntaxNode obj) + { + throw new UnreachableException(); + } + } + + internal class CustomValueTupleElementComparer : IEqualityComparer<(T, U)> + { + private readonly IEqualityComparer item1Comparer; + private readonly IEqualityComparer item2Comparer; + + public CustomValueTupleElementComparer(IEqualityComparer item1Comparer, IEqualityComparer item2Comparer) + { + this.item1Comparer = item1Comparer; + this.item2Comparer = item2Comparer; + } + + public bool Equals((T, U) x, (T, U) y) + { + return item1Comparer.Equals(x.Item1, y.Item1) && item2Comparer.Equals(x.Item2, y.Item2); + } + + public int GetHashCode((T, U) obj) + { + throw new UnreachableException(); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 802858ddb1f51..92668a646d46b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -1,164 +1,186 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { [Generator] - public class DllImportGenerator : ISourceGenerator + public class DllImportGenerator : IIncrementalGenerator { private const string GeneratedDllImport = nameof(GeneratedDllImport); private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute); private static readonly Version MinimumSupportedFrameworkVersion = new Version(5, 0); - public void Execute(GeneratorExecutionContext context) + internal sealed record IncrementalStubGenerationContext(DllImportStubContext StubContext, ImmutableArray ForwardedAttributes, GeneratedDllImportData DllImportData, ImmutableArray Diagnostics) { - if (context.SyntaxContextReceiver is not SyntaxContextReceiver synRec - || !synRec.Methods.Any()) + public bool Equals(IncrementalStubGenerationContext? other) { - return; + return other is not null + && StubContext.Equals(other.StubContext) + && DllImportData.Equals(other.DllImportData) + && ForwardedAttributes.SequenceEqual(other.ForwardedAttributes, (IEqualityComparer)new SyntaxEquivalentComparer()) + && Diagnostics.SequenceEqual(other.Diagnostics); } - INamedTypeSymbol? lcidConversionAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.LCIDConversionAttribute); - - INamedTypeSymbol? suppressGCTransitionAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.SuppressGCTransitionAttribute); - - INamedTypeSymbol? unmanagedCallConvAttrType = context.Compilation.GetTypeByMetadataName(TypeNames.UnmanagedCallConvAttribute); - - // Fire the start/stop pair for source generation - using var _ = Diagnostics.Events.SourceGenerationStartStop(synRec.Methods.Count); - - // Store a mapping between SyntaxTree and SemanticModel. - // SemanticModels cache results and since we could be looking at - // method declarations in the same SyntaxTree we want to benefit from - // this caching. - var syntaxToModel = new Dictionary(); - - var generatorDiagnostics = new GeneratorDiagnostics(context); + public override int GetHashCode() + { + throw new UnreachableException(); + } + } - bool isSupported = IsSupportedTargetFramework(context.Compilation, out Version targetFrameworkVersion); - if (!isSupported) + public class IncrementalityTracker + { + public enum StepName { - // We don't return early here, letting the source generation continue. - // This allows a user to copy generated source and use it as a starting point - // for manual marshalling if desired. - generatorDiagnostics.ReportTargetFrameworkNotSupported(MinimumSupportedFrameworkVersion); + CalculateStubInformation, + GenerateSingleStub, + NormalizeWhitespace, + ConcatenateStubs, + OutputSourceFile } - var env = new StubEnvironment( - context.Compilation, - isSupported, - targetFrameworkVersion, - context.AnalyzerConfigOptions.GlobalOptions, - context.Compilation.SourceModule.GetAttributes() - .Any(a => a.AttributeClass?.ToDisplayString() == TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute)); + public record ExecutedStepInfo(StepName Step, object Input); - var generatedDllImports = new StringBuilder(); + private List executedSteps = new(); + public IEnumerable ExecutedSteps => executedSteps; - // Mark in source that the file is auto-generated. - generatedDllImports.AppendLine("// "); + internal void RecordExecutedStep(ExecutedStepInfo step) => executedSteps.Add(step); + } - foreach (SyntaxReference synRef in synRec.Methods) - { - var methodSyntax = (MethodDeclarationSyntax)synRef.GetSyntax(context.CancellationToken); + /// + /// This property provides a test-only hook to enable testing the incrementality of the source generator. + /// This will be removed when https://github.com/dotnet/roslyn/issues/54832 is implemented and can be consumed. + /// + public IncrementalityTracker? IncrementalTracker { get; set; } - // Get the model for the method. - if (!syntaxToModel.TryGetValue(methodSyntax.SyntaxTree, out SemanticModel sm)) + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var methodsToGenerate = context.SyntaxProvider + .CreateSyntaxProvider( + static (node, ct) => ShouldVisitNode(node), + static (context, ct) => + new + { + Syntax = (MethodDeclarationSyntax)context.Node, + Symbol = (IMethodSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node, ct)! + }) + .Where( + static modelData => modelData.Symbol.IsStatic && modelData.Symbol.GetAttributes().Any( + static attribute => attribute.AttributeClass?.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) + ); + + var compilationAndTargetFramework = context.CompilationProvider + .Select(static (compilation, ct) => { - sm = context.Compilation.GetSemanticModel(methodSyntax.SyntaxTree, ignoreAccessibility: true); - syntaxToModel.Add(methodSyntax.SyntaxTree, sm); - } - - // Process the method syntax and get its SymbolInfo. - var methodSymbolInfo = sm.GetDeclaredSymbol(methodSyntax, context.CancellationToken)!; - - // Get any attributes of interest on the method - AttributeData? generatedDllImportAttr = null; - AttributeData? lcidConversionAttr = null; - AttributeData? suppressGCTransitionAttribute = null; - AttributeData? unmanagedCallConvAttribute = null; - - foreach (var attr in methodSymbolInfo.GetAttributes()) + bool isSupported = IsSupportedTargetFramework(compilation, out Version targetFrameworkVersion); + return (compilation, isSupported, targetFrameworkVersion); + }); + + context.RegisterSourceOutput( + compilationAndTargetFramework + .Combine(methodsToGenerate.Collect()), + static (context, data) => { - if (attr.AttributeClass is null) + if (!data.Left.isSupported && data.Right.Any()) { - continue; + // We don't block source generation when the TFM is unsupported. + // This allows a user to copy generated source and use it as a starting point + // for manual marshalling if desired. + context.ReportDiagnostic( + Diagnostic.Create( + GeneratorDiagnostics.TargetFrameworkNotSupported, + Location.None, + MinimumSupportedFrameworkVersion.ToString(2))); } - else if (attr.AttributeClass.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) + }); + + var stubEnvironment = compilationAndTargetFramework + .Combine(context.AnalyzerConfigOptionsProvider) + .Select( + static (data, ct) => + new StubEnvironment( + data.Left.compilation, + data.Left.isSupported, + data.Left.targetFrameworkVersion, + data.Right.GlobalOptions, + data.Left.compilation.SourceModule.GetAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() == TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute)) + ); + + var methodSourceAndDiagnostics = methodsToGenerate + .Combine(stubEnvironment) + .Select(static (data, ct) => new + { + data.Left.Syntax, + data.Left.Symbol, + Environment = data.Right + }) + .Select( + (data, ct) => { - generatedDllImportAttr = attr; + IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.CalculateStubInformation, data)); + return (data.Syntax, StubContext: CalculateStubInformation(data.Syntax, data.Symbol, data.Environment, ct)); } - else if (lcidConversionAttrType is not null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, lcidConversionAttrType)) + ) + .WithComparer(Comparers.CalculatedContextWithSyntax) + .Combine(context.AnalyzerConfigOptionsProvider) + .Select( + (data, ct) => { - lcidConversionAttr = attr; + IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.GenerateSingleStub, data)); + return GenerateSource(data.Left.StubContext, data.Left.Syntax, data.Right.GlobalOptions); } - else if (suppressGCTransitionAttrType is not null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, suppressGCTransitionAttrType)) + ) + .WithComparer(Comparers.GeneratedSyntax) + // Handle NormalizeWhitespace as a separate stage for incremental runs since it is an expensive operation. + .Select( + (data, ct) => { - suppressGCTransitionAttribute = attr; - } - else if (unmanagedCallConvAttrType is not null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, unmanagedCallConvAttrType)) + IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.NormalizeWhitespace, data)); + return (data.Item1.NormalizeWhitespace().ToFullString(), data.Item2); + }) + .Collect() + .WithComparer(Comparers.GeneratedSourceSet) + .Select((generatedSources, ct) => + { + IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.ConcatenateStubs, generatedSources)); + StringBuilder source = new(); + // Mark in source that the file is auto-generated. + source.AppendLine("// "); + ImmutableArray.Builder diagnostics = ImmutableArray.CreateBuilder(); + foreach (var generated in generatedSources) { - unmanagedCallConvAttribute = attr; + source.AppendLine(generated.Item1); + diagnostics.AddRange(generated.Item2); } - } - - if (generatedDllImportAttr == null) - continue; - - // Process the GeneratedDllImport attribute - DllImportStub.GeneratedDllImportData stubDllImportData = this.ProcessGeneratedDllImportAttribute(generatedDllImportAttr); - Debug.Assert(stubDllImportData is not null); - - if (stubDllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) - { - generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.BestFitMapping)); - } - - if (stubDllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) - { - generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar)); - } - - if (stubDllImportData!.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CallingConvention)) - { - generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr, nameof(DllImportStub.GeneratedDllImportData.CallingConvention)); - } + return (source: source.ToString(), diagnostics: diagnostics.ToImmutable()); + }) + .WithComparer(Comparers.GeneratedSource); - if (lcidConversionAttr != null) + context.RegisterSourceOutput(methodSourceAndDiagnostics, + (context, data) => { - // Using LCIDConversion with GeneratedDllImport is not supported - generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(TypeNames.LCIDConversionAttribute)); - } - - List forwardedAttributes = GenerateSyntaxForForwardedAttributes(suppressGCTransitionAttribute, unmanagedCallConvAttribute); - - // Create the stub. - var dllImportStub = DllImportStub.Create(methodSymbolInfo, stubDllImportData!, env, generatorDiagnostics, forwardedAttributes, context.CancellationToken); - - PrintGeneratedSource(generatedDllImports, methodSyntax, dllImportStub); - } - - Debug.WriteLine(generatedDllImports.ToString()); // [TODO] Find some way to emit this for debugging - logs? - context.AddSource("DllImportGenerator.g.cs", SourceText.From(generatedDllImports.ToString(), Encoding.UTF8)); - } + IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.OutputSourceFile, data)); + foreach (var diagnostic in data.Item2) + { + context.ReportDiagnostic(diagnostic); + } - public void Initialize(GeneratorInitializationContext context) - { - context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); + context.AddSource("GeneratedDllImports.g.cs", data.Item1); + }); } - - private List GenerateSyntaxForForwardedAttributes(AttributeData? suppressGCTransitionAttribute, AttributeData? unmanagedCallConvAttribute) + + private static List GenerateSyntaxForForwardedAttributes(AttributeData? suppressGCTransitionAttribute, AttributeData? unmanagedCallConvAttribute) { const string CallConvsField = "CallConvs"; // Manually rehydrate the forwarded attributes with fully qualified types so we don't have to worry about any using directives. @@ -196,7 +218,7 @@ private List GenerateSyntaxForForwardedAttributes(AttributeData return attributes; } - private SyntaxTokenList StripTriviaFromModifiers(SyntaxTokenList tokenList) + private static SyntaxTokenList StripTriviaFromModifiers(SyntaxTokenList tokenList) { SyntaxToken[] strippedTokens = new SyntaxToken[tokenList.Count]; for (int i = 0; i < tokenList.Count; i++) @@ -206,7 +228,7 @@ private SyntaxTokenList StripTriviaFromModifiers(SyntaxTokenList tokenList) return new SyntaxTokenList(strippedTokens); } - private TypeDeclarationSyntax CreateTypeDeclarationWithoutTrivia(TypeDeclarationSyntax typeDeclaration) + private static TypeDeclarationSyntax CreateTypeDeclarationWithoutTrivia(TypeDeclarationSyntax typeDeclaration) { return TypeDeclaration( typeDeclaration.Kind(), @@ -215,17 +237,17 @@ private TypeDeclarationSyntax CreateTypeDeclarationWithoutTrivia(TypeDeclaration .WithModifiers(typeDeclaration.Modifiers); } - private void PrintGeneratedSource( - StringBuilder builder, + private static MemberDeclarationSyntax PrintGeneratedSource( MethodDeclarationSyntax userDeclaredMethod, - DllImportStub stub) + DllImportStubContext stub, + BlockSyntax stubCode) { // Create stub function var stubMethod = MethodDeclaration(stub.StubReturnType, userDeclaredMethod.Identifier) - .AddAttributeLists(stub.AdditionalAttributes) + .AddAttributeLists(stub.AdditionalAttributes.ToArray()) .WithModifiers(StripTriviaFromModifiers(userDeclaredMethod.Modifiers)) .WithParameterList(ParameterList(SeparatedList(stub.StubParameters))) - .WithBody(stub.StubCode); + .WithBody(stubCode); // Stub should have at least one containing type Debug.Assert(stub.StubContainingTypes.Any()); @@ -250,7 +272,7 @@ private void PrintGeneratedSource( .AddMembers(toPrint); } - builder.AppendLine(toPrint.NormalizeWhitespace().ToString()); + return toPrint; } private static bool IsSupportedTargetFramework(Compilation compilation, out Version version) @@ -270,10 +292,8 @@ private static bool IsSupportedTargetFramework(Compilation compilation, out Vers }; } - private DllImportStub.GeneratedDllImportData ProcessGeneratedDllImportAttribute(AttributeData attrData) + private static GeneratedDllImportData ProcessGeneratedDllImportAttribute(AttributeData attrData) { - var stubDllImportData = new DllImportStub.GeneratedDllImportData(); - // Found the GeneratedDllImport, but it has an error so report the error. // This is most likely an issue with targeting an incorrect TFM. if (attrData.AttributeClass?.TypeKind is null or TypeKind.Error) @@ -282,8 +302,21 @@ private DllImportStub.GeneratedDllImportData ProcessGeneratedDllImportAttribute( throw new InvalidProgramException(); } - // Populate the DllImport data from the GeneratedDllImportAttribute attribute. - stubDllImportData.ModuleName = attrData.ConstructorArguments[0].Value!.ToString(); + + // Default values for these properties are based on the + // documented semanatics of DllImportAttribute: + // - https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute + DllImportMember userDefinedValues = DllImportMember.None; + bool bestFitMapping = false; + CallingConvention callingConvention = CallingConvention.Winapi; + CharSet charSet = CharSet.Ansi; + string? entryPoint = null; + bool exactSpelling = false; // VB has different and unusual default behavior here. + bool preserveSig = true; + bool setLastError = false; + bool throwOnUnmappableChar = false; + + var stubDllImportData = new GeneratedDllImportData(attrData.ConstructorArguments[0].Value!.ToString()); // All other data on attribute is defined as NamedArguments. foreach (var namedArg in attrData.NamedArguments) @@ -293,96 +326,179 @@ private DllImportStub.GeneratedDllImportData ProcessGeneratedDllImportAttribute( default: Debug.Fail($"An unknown member was found on {GeneratedDllImport}"); continue; - case nameof(DllImportStub.GeneratedDllImportData.BestFitMapping): - stubDllImportData.BestFitMapping = (bool)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.BestFitMapping; + case nameof(GeneratedDllImportData.BestFitMapping): + userDefinedValues |= DllImportMember.BestFitMapping; + bestFitMapping = (bool)namedArg.Value.Value!; break; - case nameof(DllImportStub.GeneratedDllImportData.CallingConvention): - stubDllImportData.CallingConvention = (CallingConvention)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.CallingConvention; + case nameof(GeneratedDllImportData.CallingConvention): + userDefinedValues |= DllImportMember.CallingConvention; + callingConvention = (CallingConvention)namedArg.Value.Value!; break; - case nameof(DllImportStub.GeneratedDllImportData.CharSet): - stubDllImportData.CharSet = (CharSet)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.CharSet; + case nameof(GeneratedDllImportData.CharSet): + userDefinedValues |= DllImportMember.CharSet; + charSet = (CharSet)namedArg.Value.Value!; break; - case nameof(DllImportStub.GeneratedDllImportData.EntryPoint): - stubDllImportData.EntryPoint = (string)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.EntryPoint; + case nameof(GeneratedDllImportData.EntryPoint): + userDefinedValues |= DllImportMember.EntryPoint; + entryPoint = (string)namedArg.Value.Value!; break; - case nameof(DllImportStub.GeneratedDllImportData.ExactSpelling): - stubDllImportData.ExactSpelling = (bool)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.ExactSpelling; + case nameof(GeneratedDllImportData.ExactSpelling): + userDefinedValues |= DllImportMember.ExactSpelling; + exactSpelling = (bool)namedArg.Value.Value!; break; - case nameof(DllImportStub.GeneratedDllImportData.PreserveSig): - stubDllImportData.PreserveSig = (bool)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.PreserveSig; + case nameof(GeneratedDllImportData.PreserveSig): + userDefinedValues |= DllImportMember.PreserveSig; + preserveSig = (bool)namedArg.Value.Value!; break; - case nameof(DllImportStub.GeneratedDllImportData.SetLastError): - stubDllImportData.SetLastError = (bool)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.SetLastError; + case nameof(GeneratedDllImportData.SetLastError): + userDefinedValues |= DllImportMember.SetLastError; + setLastError = (bool)namedArg.Value.Value!; break; - case nameof(DllImportStub.GeneratedDllImportData.ThrowOnUnmappableChar): - stubDllImportData.ThrowOnUnmappableChar = (bool)namedArg.Value.Value!; - stubDllImportData.IsUserDefined |= DllImportStub.DllImportMember.ThrowOnUnmappableChar; + case nameof(GeneratedDllImportData.ThrowOnUnmappableChar): + userDefinedValues |= DllImportMember.ThrowOnUnmappableChar; + throwOnUnmappableChar = (bool)namedArg.Value.Value!; break; } } - return stubDllImportData; + return new GeneratedDllImportData(attrData.ConstructorArguments[0].Value!.ToString()) + { + IsUserDefined = userDefinedValues, + BestFitMapping = bestFitMapping, + CallingConvention = callingConvention, + CharSet = charSet, + EntryPoint = entryPoint, + ExactSpelling = exactSpelling, + PreserveSig = preserveSig, + SetLastError = setLastError, + ThrowOnUnmappableChar = throwOnUnmappableChar + }; } - - private class SyntaxContextReceiver : ISyntaxContextReceiver + private static IncrementalStubGenerationContext CalculateStubInformation(MethodDeclarationSyntax syntax, IMethodSymbol symbol, StubEnvironment environment, CancellationToken ct) { - public ICollection Methods { get; } = new List(); - - public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + INamedTypeSymbol? lcidConversionAttrType = environment.Compilation.GetTypeByMetadataName(TypeNames.LCIDConversionAttribute); + INamedTypeSymbol? suppressGCTransitionAttrType = environment.Compilation.GetTypeByMetadataName(TypeNames.SuppressGCTransitionAttribute); + INamedTypeSymbol? unmanagedCallConvAttrType = environment.Compilation.GetTypeByMetadataName(TypeNames.UnmanagedCallConvAttribute); + // Get any attributes of interest on the method + AttributeData? generatedDllImportAttr = null; + AttributeData? lcidConversionAttr = null; + AttributeData? suppressGCTransitionAttribute = null; + AttributeData? unmanagedCallConvAttribute = null; + foreach (var attr in symbol.GetAttributes()) { - SyntaxNode syntaxNode = context.Node; - - // We only support C# method declarations. - if (syntaxNode.Language != LanguageNames.CSharp - || !syntaxNode.IsKind(SyntaxKind.MethodDeclaration)) + if (attr.AttributeClass is not null + && attr.AttributeClass.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) { - return; + generatedDllImportAttr = attr; } - - var methodSyntax = (MethodDeclarationSyntax)syntaxNode; - - // Verify the method has no generic types or defined implementation - // and is marked static and partial. - if (!(methodSyntax.TypeParameterList is null) - || !(methodSyntax.Body is null) - || !methodSyntax.Modifiers.Any(SyntaxKind.StaticKeyword) - || !methodSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) + else if (lcidConversionAttrType != null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, lcidConversionAttrType)) { - return; + lcidConversionAttr = attr; } - - // Verify that the types the method is declared in are marked partial. - for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent) + else if (suppressGCTransitionAttrType != null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, suppressGCTransitionAttrType)) { - if (!typeDecl.Modifiers.Any(SyntaxKind.PartialKeyword)) - { - return; - } + suppressGCTransitionAttribute = attr; } + else if (unmanagedCallConvAttrType != null && SymbolEqualityComparer.Default.Equals(attr.AttributeClass, unmanagedCallConvAttrType)) + { + unmanagedCallConvAttribute = attr; + } + } + + Debug.Assert(generatedDllImportAttr is not null); + + var generatorDiagnostics = new GeneratorDiagnostics(); + + // Process the GeneratedDllImport attribute + GeneratedDllImportData stubDllImportData = ProcessGeneratedDllImportAttribute(generatedDllImportAttr!); + + if (stubDllImportData.IsUserDefined.HasFlag(DllImportMember.BestFitMapping)) + { + generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr!, nameof(GeneratedDllImportData.BestFitMapping)); + } + + if (stubDllImportData.IsUserDefined.HasFlag(DllImportMember.ThrowOnUnmappableChar)) + { + generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr!, nameof(GeneratedDllImportData.ThrowOnUnmappableChar)); + } + + if (stubDllImportData.IsUserDefined.HasFlag(DllImportMember.CallingConvention)) + { + generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr!, nameof(GeneratedDllImportData.CallingConvention)); + } + + if (lcidConversionAttr != null) + { + // Using LCIDConversion with GeneratedDllImport is not supported + generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(TypeNames.LCIDConversionAttribute)); + } + List additionalAttributes = GenerateSyntaxForForwardedAttributes(suppressGCTransitionAttribute, unmanagedCallConvAttribute); - // Check if the method is marked with the GeneratedDllImport attribute. - foreach (AttributeListSyntax listSyntax in methodSyntax.AttributeLists) + // Create the stub. + var dllImportStub = DllImportStubContext.Create(symbol, stubDllImportData, environment, generatorDiagnostics, ct); + + return new IncrementalStubGenerationContext(dllImportStub, additionalAttributes.ToImmutableArray(), stubDllImportData, generatorDiagnostics.Diagnostics.ToImmutableArray()); + } + + private (MemberDeclarationSyntax, ImmutableArray) GenerateSource( + IncrementalStubGenerationContext dllImportStub, + MethodDeclarationSyntax originalSyntax, + AnalyzerConfigOptions options) + { + var diagnostics = new GeneratorDiagnostics(); + + // Generate stub code + var stubGenerator = new StubCodeGenerator( + dllImportStub.DllImportData, + dllImportStub.StubContext.ElementTypeInformation, + options, + (elementInfo, ex) => diagnostics.ReportMarshallingNotSupported(originalSyntax, elementInfo, ex.NotSupportedDetails)); + + ImmutableArray forwardedAttributes = dllImportStub.ForwardedAttributes; + + var code = stubGenerator.GenerateBody(originalSyntax.Identifier.Text, forwardedAttributes: forwardedAttributes.Length != 0 ? AttributeList(SeparatedList(forwardedAttributes)) : null); + + return (PrintGeneratedSource(originalSyntax, dllImportStub.StubContext, code), dllImportStub.Diagnostics.AddRange(diagnostics.Diagnostics)); + } + + private static bool ShouldVisitNode(SyntaxNode syntaxNode) + { + // We only support C# method declarations. + if (syntaxNode.Language != LanguageNames.CSharp + || !syntaxNode.IsKind(SyntaxKind.MethodDeclaration)) + { + return false; + } + + var methodSyntax = (MethodDeclarationSyntax)syntaxNode; + + // Verify the method has no generic types or defined implementation + // and is marked static and partial. + if (methodSyntax.TypeParameterList is not null + || methodSyntax.Body is not null + || !methodSyntax.Modifiers.Any(SyntaxKind.StaticKeyword) + || !methodSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) + { + return false; + } + + // Verify that the types the method is declared in are marked partial. + for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent) + { + if (!typeDecl.Modifiers.Any(SyntaxKind.PartialKeyword)) { - foreach (AttributeSyntax attrSyntax in listSyntax.Attributes) - { - SymbolInfo info = context.SemanticModel.GetSymbolInfo(attrSyntax); - if (info.Symbol is IMethodSymbol attrConstructor - && attrConstructor.ContainingType.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) - { - this.Methods.Add(syntaxNode.GetReference()); - return; - } - } + return false; } } + + // Filter out methods with no attributes early. + if (methodSyntax.AttributeLists.Count == 0) + { + return false; + } + + return true; } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs similarity index 62% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs rename to src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs index c82095e5b5a0e..e86b8fdef826a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStub.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using System.Runtime.InteropServices; using System.Threading; @@ -19,101 +20,50 @@ internal record StubEnvironment( AnalyzerConfigOptions Options, bool ModuleSkipLocalsInit); - internal class DllImportStub + internal sealed class DllImportStubContext : IEquatable { - private TypePositionInfo returnTypeInfo; - private IEnumerable paramsTypeInfo; - // We don't need the warnings around not setting the various // non-nullable fields/properties on this type in the constructor // since we always use a property initializer. #pragma warning disable 8618 - private DllImportStub() + private DllImportStubContext() { } #pragma warning restore + public ImmutableArray ElementTypeInformation { get; init; } + public string? StubTypeNamespace { get; init; } - public IEnumerable StubContainingTypes { get; init; } + public ImmutableArray StubContainingTypes { get; init; } - public TypeSyntax StubReturnType { get => this.returnTypeInfo.ManagedType.AsTypeSyntax(); } + public TypeSyntax StubReturnType { get; init; } public IEnumerable StubParameters { get { - foreach (var typeinfo in paramsTypeInfo) + foreach (var typeInfo in ElementTypeInformation) { - if (typeinfo.ManagedIndex != TypePositionInfo.UnsetIndex - && typeinfo.ManagedIndex != TypePositionInfo.ReturnIndex) + if (typeInfo.ManagedIndex != TypePositionInfo.UnsetIndex + && typeInfo.ManagedIndex != TypePositionInfo.ReturnIndex) { - yield return Parameter(Identifier(typeinfo.InstanceIdentifier)) - .WithType(typeinfo.ManagedType.AsTypeSyntax()) - .WithModifiers(TokenList(Token(typeinfo.RefKindSyntax))); + yield return Parameter(Identifier(typeInfo.InstanceIdentifier)) + .WithType(typeInfo.ManagedType.Syntax) + .WithModifiers(TokenList(Token(typeInfo.RefKindSyntax))); } } } } - public BlockSyntax StubCode { get; init; } + public ImmutableArray AdditionalAttributes { get; init; } - public AttributeListSyntax[] AdditionalAttributes { get; init; } - - /// - /// Flags used to indicate members on GeneratedDllImport attribute. - /// - [Flags] - public enum DllImportMember - { - None = 0, - BestFitMapping = 1 << 0, - CallingConvention = 1 << 1, - CharSet = 1 << 2, - EntryPoint = 1 << 3, - ExactSpelling = 1 << 4, - PreserveSig = 1 << 5, - SetLastError = 1 << 6, - ThrowOnUnmappableChar = 1 << 7, - All = ~None - } - - /// - /// GeneratedDllImportAttribute data - /// - /// - /// The names of these members map directly to those on the - /// DllImportAttribute and should not be changed. - /// - public class GeneratedDllImportData - { - public string ModuleName { get; set; } = null!; - - /// - /// Value set by the user on the original declaration. - /// - public DllImportMember IsUserDefined = DllImportMember.None; - - // Default values for the below fields are based on the - // documented semanatics of DllImportAttribute: - // - https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute - public bool BestFitMapping { get; set; } = true; - public CallingConvention CallingConvention { get; set; } = CallingConvention.Winapi; - public CharSet CharSet { get; set; } = CharSet.Ansi; - public string EntryPoint { get; set; } = null!; - public bool ExactSpelling { get; set; } = false; // VB has different and unusual default behavior here. - public bool PreserveSig { get; set; } = true; - public bool SetLastError { get; set; } = false; - public bool ThrowOnUnmappableChar { get; set; } = false; - } - - public static DllImportStub Create( + public static DllImportStubContext Create( IMethodSymbol method, GeneratedDllImportData dllImportData, StubEnvironment env, GeneratorDiagnostics diagnostics, - List forwardedAttributes, - CancellationToken token = default) + CancellationToken token) { // Cancel early if requested token.ThrowIfCancellationRequested(); @@ -127,7 +77,7 @@ public static DllImportStub Create( } // Determine containing type(s) - var containingTypes = new List(); + var containingTypes = ImmutableArray.CreateBuilder(); INamedTypeSymbol currType = method.ContainingType; while (!(currType is null)) { @@ -145,6 +95,36 @@ public static DllImportStub Create( currType = currType.ContainingType; } + var typeInfos = GenerateTypeInformation(method, dllImportData, diagnostics, env); + + var additionalAttrs = ImmutableArray.CreateBuilder(); + + // Define additional attributes for the stub definition. + if (env.TargetFrameworkVersion >= new Version(5, 0) && !MethodIsSkipLocalsInit(env, method)) + { + additionalAttrs.Add( + AttributeList( + SeparatedList(new[] + { + // Adding the skip locals init indiscriminately since the source generator is + // targeted at non-blittable method signatures which typically will contain locals + // in the generated code. + Attribute(ParseName(TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute)) + }))); + } + + return new DllImportStubContext() + { + StubReturnType = method.ReturnType.AsTypeSyntax(), + ElementTypeInformation = typeInfos, + StubTypeNamespace = stubTypeNamespace, + StubContainingTypes = containingTypes.ToImmutable(), + AdditionalAttributes = additionalAttrs.ToImmutable(), + }; + } + + private static ImmutableArray GenerateTypeInformation(IMethodSymbol method, GeneratedDllImportData dllImportData, GeneratorDiagnostics diagnostics, StubEnvironment env) + { // Compute the current default string encoding value. var defaultEncoding = CharEncoding.Undefined; if (dllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet)) @@ -163,21 +143,22 @@ public static DllImportStub Create( var marshallingAttributeParser = new MarshallingAttributeInfoParser(env.Compilation, diagnostics, defaultInfo, method); // Determine parameter and return types - var paramsTypeInfo = new List(); + var typeInfos = ImmutableArray.CreateBuilder(); for (int i = 0; i < method.Parameters.Length; i++) { var param = method.Parameters[i]; MarshallingInfo marshallingInfo = marshallingAttributeParser.ParseMarshallingInfo(param.Type, param.GetAttributes()); var typeInfo = TypePositionInfo.CreateForParameter(param, marshallingInfo, env.Compilation); - typeInfo = typeInfo with + typeInfo = typeInfo with { ManagedIndex = i, - NativeIndex = paramsTypeInfo.Count + NativeIndex = typeInfos.Count }; - paramsTypeInfo.Add(typeInfo); + typeInfos.Add(typeInfo); + } - TypePositionInfo retTypeInfo = TypePositionInfo.CreateForType(method.ReturnType, marshallingAttributeParser.ParseMarshallingInfo(method.ReturnType, method.GetReturnTypeAttributes())); + TypePositionInfo retTypeInfo = new(ManagedTypeInfo.CreateTypeInfoForTypeSymbol(method.ReturnType), marshallingAttributeParser.ParseMarshallingInfo(method.ReturnType, method.GetReturnTypeAttributes())); retTypeInfo = retTypeInfo with { ManagedIndex = TypePositionInfo.ReturnIndex, @@ -190,7 +171,7 @@ public static DllImportStub Create( if (!dllImportData.PreserveSig && !env.Options.GenerateForwarders()) { // Create type info for native HRESULT return - retTypeInfo = TypePositionInfo.CreateForType(env.Compilation.GetSpecialType(SpecialType.System_Int32), NoMarshallingInfo.Instance); + retTypeInfo = new TypePositionInfo(SpecialTypeInfo.Int32, NoMarshallingInfo.Instance); retTypeInfo = retTypeInfo with { NativeIndex = TypePositionInfo.ReturnIndex @@ -206,41 +187,34 @@ public static DllImportStub Create( RefKind = RefKind.Out, RefKindSyntax = SyntaxKind.OutKeyword, ManagedIndex = TypePositionInfo.ReturnIndex, - NativeIndex = paramsTypeInfo.Count + NativeIndex = typeInfos.Count }; - paramsTypeInfo.Add(nativeOutInfo); + typeInfos.Add(nativeOutInfo); } } + typeInfos.Add(retTypeInfo); - // Generate stub code - var stubGenerator = new StubCodeGenerator(method, dllImportData, paramsTypeInfo, retTypeInfo, diagnostics, env.Options); - var code = stubGenerator.GenerateSyntax(forwardedAttributes: forwardedAttributes.Count != 0 ? AttributeList(SeparatedList(forwardedAttributes)) : null); + return typeInfos.ToImmutable(); + } - var additionalAttrs = new List(); + public override bool Equals(object obj) + { + return obj is DllImportStubContext other && Equals(other); + } - // Define additional attributes for the stub definition. - if (env.TargetFrameworkVersion >= new Version(5, 0) && !MethodIsSkipLocalsInit(env, method)) - { - additionalAttrs.Add( - AttributeList( - SeparatedList(new [] - { - // Adding the skip locals init indiscriminately since the source generator is - // targeted at non-blittable method signatures which typically will contain locals - // in the generated code. - Attribute(ParseName(TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute)) - }))); - } + public bool Equals(DllImportStubContext other) + { + return other is not null + && StubTypeNamespace == other.StubTypeNamespace + && ElementTypeInformation.SequenceEqual(other.ElementTypeInformation) + && StubContainingTypes.SequenceEqual(other.StubContainingTypes, (IEqualityComparer)new SyntaxEquivalentComparer()) + && StubReturnType.IsEquivalentTo(other.StubReturnType) + && AdditionalAttributes.SequenceEqual(other.AdditionalAttributes, (IEqualityComparer)new SyntaxEquivalentComparer()); + } - return new DllImportStub() - { - returnTypeInfo = managedRetTypeInfo, - paramsTypeInfo = paramsTypeInfo, - StubTypeNamespace = stubTypeNamespace, - StubContainingTypes = containingTypes, - StubCode = code, - AdditionalAttributes = additionalAttrs.ToArray(), - }; + public override int GetHashCode() + { + throw new UnreachableException(); } private static bool MethodIsSkipLocalsInit(StubEnvironment env, IMethodSymbol method) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs new file mode 100644 index 0000000000000..9a4fc90a125bf --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace Microsoft.Interop +{ + /// + /// Flags used to indicate members on GeneratedDllImport attribute. + /// + [Flags] + public enum DllImportMember + { + None = 0, + BestFitMapping = 1 << 0, + CallingConvention = 1 << 1, + CharSet = 1 << 2, + EntryPoint = 1 << 3, + ExactSpelling = 1 << 4, + PreserveSig = 1 << 5, + SetLastError = 1 << 6, + ThrowOnUnmappableChar = 1 << 7, + All = ~None + } + + /// + /// GeneratedDllImportAttribute data + /// + /// + /// The names of these members map directly to those on the + /// DllImportAttribute and should not be changed. + /// + public sealed record GeneratedDllImportData(string ModuleName) + { + /// + /// Value set by the user on the original declaration. + /// + public DllImportMember IsUserDefined { get; init; } + public bool BestFitMapping { get; init; } + public CallingConvention CallingConvention { get; init; } + public CharSet CharSet { get; init; } + public string? EntryPoint { get; init; } + public bool ExactSpelling { get; init; } + public bool PreserveSig { get; init; } + public bool SetLastError { get; init; } + public bool ThrowOnUnmappableChar { 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 51531f6c1a00b..74abfb3c71497 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -5,6 +5,7 @@ using System.Linq; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.Interop { @@ -15,15 +16,20 @@ public static Diagnostic CreateDiagnostic( DiagnosticDescriptor descriptor, params object[] args) { - IEnumerable locationsInSource = symbol.Locations.Where(l => l.IsInSource); - if (!locationsInSource.Any()) - return Diagnostic.Create(descriptor, Location.None, args); + return symbol.Locations.CreateDiagnostic(descriptor, args); + } - return Diagnostic.Create( - descriptor, - location: locationsInSource.First(), - additionalLocations: locationsInSource.Skip(1), - messageArgs: args); + public static Diagnostic CreateDiagnostic( + this AttributeData attributeData, + DiagnosticDescriptor descriptor, + params object[] args) + { + SyntaxReference? syntaxReference = attributeData.ApplicationSyntaxReference; + Location location = syntaxReference is not null + ? syntaxReference.GetSyntax().GetLocation() + : Location.None; + + return location.CreateDiagnostic(descriptor, args); } public static Diagnostic CreateDiagnostic( @@ -43,15 +49,10 @@ public static Diagnostic CreateDiagnostic( } public static Diagnostic CreateDiagnostic( - this AttributeData attributeData, + this Location location, DiagnosticDescriptor descriptor, params object[] args) { - SyntaxReference? syntaxReference = attributeData.ApplicationSyntaxReference; - Location location = syntaxReference is not null - ? syntaxReference.GetSyntax().GetLocation() - : Location.None; - return Diagnostic.Create( descriptor, location: location.IsInSource ? location : Location.None, @@ -174,12 +175,9 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.TargetFrameworkNotSupportedDescription))); - private readonly GeneratorExecutionContext context; + private readonly List diagnostics = new List(); - public GeneratorDiagnostics(GeneratorExecutionContext context) - { - this.context = context; - } + public IEnumerable Diagnostics => diagnostics; /// /// Report diagnostic for configuration that is not supported by the DLL import source generator @@ -194,14 +192,14 @@ public void ReportConfigurationNotSupported( { if (unsupportedValue == null) { - this.context.ReportDiagnostic( + diagnostics.Add( attributeData.CreateDiagnostic( GeneratorDiagnostics.ConfigurationNotSupported, configurationName)); } else { - this.context.ReportDiagnostic( + diagnostics.Add( attributeData.CreateDiagnostic( GeneratorDiagnostics.ConfigurationValueNotSupported, unsupportedValue, @@ -216,30 +214,44 @@ public void ReportConfigurationNotSupported( /// Type info for the parameter/return /// [Optional] Specific reason for lack of support internal void ReportMarshallingNotSupported( - IMethodSymbol method, + MethodDeclarationSyntax method, TypePositionInfo info, string? notSupportedDetails) { + Location diagnosticLocation = Location.None; + string elementName = string.Empty; + + if (info.IsManagedReturnPosition) + { + diagnosticLocation = Location.Create(method.SyntaxTree, method.Identifier.Span); + elementName = method.Identifier.ValueText; + } + else + { + Debug.Assert(info.ManagedIndex <= method.ParameterList.Parameters.Count); + ParameterSyntax param = method.ParameterList.Parameters[info.ManagedIndex]; + diagnosticLocation = Location.Create(param.SyntaxTree, param.Identifier.Span); + elementName = param.Identifier.ValueText; + } + if (!string.IsNullOrEmpty(notSupportedDetails)) { // Report the specific not-supported reason. if (info.IsManagedReturnPosition) { - this.context.ReportDiagnostic( - method.CreateDiagnostic( + diagnostics.Add( + diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails, notSupportedDetails!, - method.Name)); + elementName)); } else { - Debug.Assert(info.ManagedIndex <= method.Parameters.Length); - IParameterSymbol paramSymbol = method.Parameters[info.ManagedIndex]; - this.context.ReportDiagnostic( - paramSymbol.CreateDiagnostic( + diagnostics.Add( + diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails, notSupportedDetails!, - paramSymbol.Name)); + elementName)); } } else if (info.MarshallingAttributeInfo is MarshalAsInfo) @@ -249,21 +261,19 @@ internal void ReportMarshallingNotSupported( // than when there is no attribute and the type itself is not supported. if (info.IsManagedReturnPosition) { - this.context.ReportDiagnostic( - method.CreateDiagnostic( + diagnostics.Add( + diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnConfigurationNotSupported, nameof(System.Runtime.InteropServices.MarshalAsAttribute), - method.Name)); + elementName)); } else { - Debug.Assert(info.ManagedIndex <= method.Parameters.Length); - IParameterSymbol paramSymbol = method.Parameters[info.ManagedIndex]; - this.context.ReportDiagnostic( - paramSymbol.CreateDiagnostic( + diagnostics.Add( + diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterConfigurationNotSupported, nameof(System.Runtime.InteropServices.MarshalAsAttribute), - paramSymbol.Name)); + elementName)); } } else @@ -271,21 +281,19 @@ internal void ReportMarshallingNotSupported( // Report that the type is not supported if (info.IsManagedReturnPosition) { - this.context.ReportDiagnostic( - method.CreateDiagnostic( + diagnostics.Add( + diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnTypeNotSupported, - method.ReturnType.ToDisplayString(), - method.Name)); + info.ManagedType.DiagnosticFormattedName, + elementName)); } else { - Debug.Assert(info.ManagedIndex <= method.Parameters.Length); - IParameterSymbol paramSymbol = method.Parameters[info.ManagedIndex]; - this.context.ReportDiagnostic( - paramSymbol.CreateDiagnostic( + diagnostics.Add( + diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterTypeNotSupported, - paramSymbol.Type.ToDisplayString(), - paramSymbol.Name)); + info.ManagedType.DiagnosticFormattedName, + elementName)); } } } @@ -295,7 +303,7 @@ internal void ReportInvalidMarshallingAttributeInfo( string reasonResourceName, params string[] reasonArgs) { - this.context.ReportDiagnostic( + diagnostics.Add( attributeData.CreateDiagnostic( GeneratorDiagnostics.MarshallingAttributeConfigurationNotSupported, new LocalizableResourceString(reasonResourceName, Resources.ResourceManager, typeof(Resources), reasonArgs))); @@ -307,7 +315,7 @@ internal void ReportInvalidMarshallingAttributeInfo( /// Minimum supported version of .NET public void ReportTargetFrameworkNotSupported(Version minimumSupportedVersion) { - this.context.ReportDiagnostic( + diagnostics.Add( Diagnostic.Create( TargetFrameworkNotSupported, Location.None, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManagedTypeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManagedTypeInfo.cs new file mode 100644 index 0000000000000..9e2bd6f70d8a4 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManagedTypeInfo.cs @@ -0,0 +1,74 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Interop +{ + /// + /// A discriminated union that contains enough info about a managed type to determine a marshalling generator and generate code. + /// + internal abstract record ManagedTypeInfo(string FullTypeName, string DiagnosticFormattedName) + { + public TypeSyntax Syntax { get; } = SyntaxFactory.ParseTypeName(FullTypeName); + + public static ManagedTypeInfo CreateTypeInfoForTypeSymbol(ITypeSymbol type) + { + string typeName = type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + string diagonsticFormattedName = type.ToDisplayString(); + if (type.SpecialType != SpecialType.None) + { + return new SpecialTypeInfo(typeName, diagonsticFormattedName, type.SpecialType); + } + if (type.TypeKind == TypeKind.Enum) + { + return new EnumTypeInfo(typeName, diagonsticFormattedName, ((INamedTypeSymbol)type).EnumUnderlyingType!.SpecialType); + } + if (type.TypeKind == TypeKind.Pointer) + { + return new PointerTypeInfo(typeName, diagonsticFormattedName, IsFunctionPointer: false); + } + if (type.TypeKind == TypeKind.FunctionPointer) + { + return new PointerTypeInfo(typeName, diagonsticFormattedName, IsFunctionPointer: true); + } + if (type.TypeKind == TypeKind.Array && type is IArrayTypeSymbol { IsSZArray: true } arraySymbol) + { + return new SzArrayType(CreateTypeInfoForTypeSymbol(arraySymbol.ElementType)); + } + if (type.TypeKind == TypeKind.Delegate) + { + return new DelegateTypeInfo(typeName, diagonsticFormattedName); + } + return new SimpleManagedTypeInfo(typeName, diagonsticFormattedName); + } + } + + internal sealed record SpecialTypeInfo(string FullTypeName, string DiagnosticFormattedName, SpecialType SpecialType) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName) + { + public static readonly SpecialTypeInfo Int32 = new("int", "int", SpecialType.System_Int32); + public static readonly SpecialTypeInfo Void = new("void", "void", SpecialType.System_Void); + + public bool Equals(SpecialTypeInfo? other) + { + return other is not null && SpecialType == other.SpecialType; + } + + public override int GetHashCode() + { + return (int)SpecialType; + } + } + + internal sealed record EnumTypeInfo(string FullTypeName, string DiagnosticFormattedName, SpecialType UnderlyingType) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); + + internal sealed record PointerTypeInfo(string FullTypeName, string DiagnosticFormattedName, bool IsFunctionPointer) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); + + internal sealed record SzArrayType(ManagedTypeInfo ElementTypeInfo) : ManagedTypeInfo($"{ElementTypeInfo.FullTypeName}[]", $"{ElementTypeInfo.DiagnosticFormattedName}[]"); + + internal sealed record DelegateTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); + + internal sealed record SimpleManagedTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs index 0f158706cd038..15fa7774a996f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs @@ -11,7 +11,7 @@ internal class BlittableMarshaller : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { - return info.ManagedType.AsTypeSyntax(); + return info.ManagedType.Syntax; } public ParameterSyntax AsParameter(TypePositionInfo info) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs index b659ccbda4b78..2b5af8d2a5cd8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs @@ -25,7 +25,7 @@ protected BoolMarshallerBase(PredefinedTypeSyntax nativeType, int trueValue, int public TypeSyntax AsNativeType(TypePositionInfo info) { - Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Boolean); + Debug.Assert(info.ManagedType is SpecialTypeInfo(_, _, SpecialType.System_Boolean)); return _nativeType; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs index b3279390da77f..d04a78c2460ae 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs @@ -33,7 +33,7 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) public TypeSyntax AsNativeType(TypePositionInfo info) { - Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Char); + Debug.Assert(info.ManagedType is SpecialTypeInfo(_, _, SpecialType.System_Char)); return NativeType; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs index 21a5c80d4cca9..b5aca0f44207f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs @@ -89,7 +89,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont .WithTypeArgumentList( TypeArgumentList( SingletonSeparatedList( - info.ManagedType.AsTypeSyntax())))), + info.ManagedType.Syntax)))), ArgumentList(SingletonSeparatedList(Argument(IdentifierName(nativeIdentifier))))), LiteralExpression(SyntaxKind.NullLiteralExpression)))); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs index 1bd26150668f6..e86c422ec4828 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs @@ -12,7 +12,7 @@ internal class Forwarder : IMarshallingGenerator, IAttributedReturnTypeMarshalli { public TypeSyntax AsNativeType(TypePositionInfo info) { - return info.ManagedType.AsTypeSyntax(); + return info.ManagedType.Syntax; } private bool TryRehydrateMarshalAsAttribute(TypePositionInfo info, out AttributeSyntax marshalAsAttribute) @@ -87,7 +87,7 @@ public ParameterSyntax AsParameter(TypePositionInfo info) { ParameterSyntax param = Parameter(Identifier(info.InstanceIdentifier)) .WithModifiers(TokenList(Token(info.RefKindSyntax))) - .WithType(info.ManagedType.AsTypeSyntax()); + .WithType(info.ManagedType.Syntax); if (TryRehydrateMarshalAsAttribute(info, out AttributeSyntax marshalAsAttribute)) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs index 4b56c8a310725..09ce81431e6a9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs @@ -15,7 +15,7 @@ internal sealed class HResultExceptionMarshaller : IMarshallingGenerator public TypeSyntax AsNativeType(TypePositionInfo info) { - Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Int32); + Debug.Assert(info.ManagedType is SpecialTypeInfo(_, _, SpecialType.System_Int32)); return NativeType; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs index 946e96fe56220..24fb56ad90bcf 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs @@ -194,31 +194,31 @@ private static IMarshallingGenerator CreateCore( if (info.IsNativeReturnPosition && !info.IsManagedReturnPosition) { // Use marshaller for native HRESULT return / exception throwing - System.Diagnostics.Debug.Assert(info.ManagedType.SpecialType == SpecialType.System_Int32); + System.Diagnostics.Debug.Assert(info.ManagedType is SpecialTypeInfo { SpecialType: SpecialType.System_Int32 }); return HResultException; } switch (info) { // Blittable primitives with no marshalling info or with a compatible [MarshalAs] attribute. - case { ManagedType: { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I1, _) } - or { ManagedType: { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U1, _) } - or { ManagedType: { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I2, _) } - or { ManagedType: { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U2, _) } - or { ManagedType: { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I4, _) } - or { ManagedType: { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U4, _) } - or { ManagedType: { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I8, _) } - or { ManagedType: { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U8, _) } - or { ManagedType: { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysInt, _) } - or { ManagedType: { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysUInt, _) } - or { ManagedType: { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } - or { ManagedType: { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I1, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U1, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I2, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U2, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I4, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U4, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I8, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U8, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysInt, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysUInt, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: return Blittable; // Enum with no marshalling info - case { ManagedType: { TypeKind: TypeKind.Enum }, MarshallingAttributeInfo: NoMarshallingInfo }: + case { ManagedType: EnumTypeInfo enumType, MarshallingAttributeInfo: NoMarshallingInfo }: // Check that the underlying type is not bool or char. C# does not allow this, but ECMA-335 does. - var underlyingSpecialType = ((INamedTypeSymbol)info.ManagedType).EnumUnderlyingType!.SpecialType; + var underlyingSpecialType = enumType.UnderlyingType; if (underlyingSpecialType == SpecialType.System_Boolean || underlyingSpecialType == SpecialType.System_Char) { throw new MarshallingNotSupportedException(info, context); @@ -226,31 +226,31 @@ private static IMarshallingGenerator CreateCore( return Blittable; // Pointer with no marshalling info - case { ManagedType: { TypeKind: TypeKind.Pointer }, MarshallingAttributeInfo: NoMarshallingInfo }: + case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer:false), MarshallingAttributeInfo: NoMarshallingInfo }: return Blittable; // Function pointer with no marshalling info - case { ManagedType: { TypeKind: TypeKind.FunctionPointer }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: + case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer: true), MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: return Blittable; - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: return ByteBool; - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool, _) }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool, _) }: return WinBool; - case { ManagedType: { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: return VariantBool; - case { ManagedType: { TypeKind: TypeKind.Delegate }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: + case { ManagedType: DelegateTypeInfo, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: return Delegate; - case { MarshallingAttributeInfo: SafeHandleMarshallingInfo }: + case { MarshallingAttributeInfo: SafeHandleMarshallingInfo(_, bool isAbstract) }: if (!context.AdditionalTemporaryStateLivesAcrossStages) { throw new MarshallingNotSupportedException(info, context); } - if (info.IsByRef && info.ManagedType.IsAbstract) + if (info.IsByRef && isAbstract) { throw new MarshallingNotSupportedException(info, context) { @@ -274,13 +274,13 @@ private static IMarshallingGenerator CreateCore( // Cases that just match on type must come after the checks that match only on marshalling attribute info. // The checks below do not account for generic marshalling overrides like [MarshalUsing], so those checks must come first. - case { ManagedType: { SpecialType: SpecialType.System_Char } }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Char } }: return CreateCharMarshaller(info, context); - case { ManagedType: { SpecialType: SpecialType.System_String } }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_String } }: return CreateStringMarshaller(info, context); - case { ManagedType: { SpecialType: SpecialType.System_Void } }: + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Void } }: return Forwarder; default: @@ -403,7 +403,7 @@ ExpressionSyntax GetExpressionForParam(TypePositionInfo paramInfo) paramInfo, out int numIndirectionLevels); - ITypeSymbol type = paramInfo.ManagedType; + ManagedTypeInfo type = paramInfo.ManagedType; MarshallingInfo marshallingInfo = paramInfo.MarshallingAttributeInfo; for (int i = 0; i < numIndirectionLevels; i++) @@ -422,7 +422,7 @@ ExpressionSyntax GetExpressionForParam(TypePositionInfo paramInfo) } } - if (!type.IsIntegralType()) + if (type is not SpecialTypeInfo specialType || !specialType.SpecialType.IsIntegralType()) { throw new MarshallingNotSupportedException(info, context) { @@ -470,14 +470,14 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi { ValidateCustomNativeTypeMarshallingSupported(info, context, marshalInfo); - ICustomNativeTypeMarshallingStrategy marshallingStrategy = new SimpleCustomNativeTypeMarshalling(marshalInfo.NativeMarshallingType.AsTypeSyntax()); + ICustomNativeTypeMarshallingStrategy marshallingStrategy = new SimpleCustomNativeTypeMarshalling(marshalInfo.NativeMarshallingType.Syntax); - if ((marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0) + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNativeStackalloc) != 0) { marshallingStrategy = new StackallocOptimizationMarshalling(marshallingStrategy); } - if (ManualTypeMarshallingHelper.HasFreeNativeMethod(marshalInfo.NativeMarshallingType)) + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.FreeNativeResources) != 0) { marshallingStrategy = new FreeNativeCleanupStrategy(marshallingStrategy); } @@ -495,7 +495,7 @@ private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositi IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); - if ((marshalInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) != 0) + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedTypePinning) != 0) { return new PinnableManagedValueMarshaller(marshallingGenerator); } @@ -508,53 +508,54 @@ private static void ValidateCustomNativeTypeMarshallingSupported(TypePositionInf // The marshalling method for this type doesn't support marshalling from native to managed, // but our scenario requires marshalling from native to managed. if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.NativeToManaged) == 0) + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.NativeToManaged) == 0) { throw new MarshallingNotSupportedException(info, context) { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingNativeToManagedUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingNativeToManagedUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) }; } // The marshalling method for this type doesn't support marshalling from managed to native by value, // but our scenario requires marshalling from managed to native by value. else if (!info.IsByRef - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 - && (context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingMethods & (SupportedMarshallingMethods.Pinning | SupportedMarshallingMethods.ManagedToNativeStackalloc)) == 0)) + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0 + && (context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingFeatures & (CustomMarshallingFeatures.ManagedTypePinning | CustomMarshallingFeatures.ManagedToNativeStackalloc)) == 0)) { throw new MarshallingNotSupportedException(info, context) { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) }; } // The marshalling method for this type doesn't support marshalling from managed to native by reference, // but our scenario requires marshalling from managed to native by reference. // "in" byref supports stack marshalling. else if (info.RefKind == RefKind.In - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0 - && !(context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNativeStackalloc) != 0)) + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0 + && !(context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNativeStackalloc) != 0)) { throw new MarshallingNotSupportedException(info, context) { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) }; } // The marshalling method for this type doesn't support marshalling from managed to native by reference, // but our scenario requires marshalling from managed to native by reference. // "ref" byref marshalling doesn't support stack marshalling else if (info.RefKind == RefKind.Ref - && (marshalInfo.MarshallingMethods & SupportedMarshallingMethods.ManagedToNative) == 0) + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0) { throw new MarshallingNotSupportedException(info, context) { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.ToDisplayString()) + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) }; } } private static ICustomNativeTypeMarshallingStrategy DecorateWithValuePropertyStrategy(NativeMarshallingAttributeInfo marshalInfo, ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller) { - TypeSyntax valuePropertyTypeSyntax = marshalInfo.ValuePropertyType!.AsTypeSyntax(); - if (ManualTypeMarshallingHelper.FindGetPinnableReference(marshalInfo.NativeMarshallingType) is not null) + TypeSyntax valuePropertyTypeSyntax = marshalInfo.ValuePropertyType!.Syntax; + + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.NativeTypePinning) != 0) { return new PinnableMarshallerTypeMarshalling(nativeTypeMarshaller, valuePropertyTypeSyntax); } @@ -569,7 +570,7 @@ private static IMarshallingGenerator CreateNativeCollectionMarshaller( AnalyzerConfigOptions options, ICustomNativeTypeMarshallingStrategy marshallingStrategy) { - var elementInfo = TypePositionInfo.CreateForType(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo) with { ManagedIndex = info.ManagedIndex }; + var elementInfo = new TypePositionInfo(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo) { ManagedIndex = info.ManagedIndex }; var elementMarshaller = Create( elementInfo, new ContiguousCollectionElementMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context), @@ -580,7 +581,7 @@ private static IMarshallingGenerator CreateNativeCollectionMarshaller( if (isBlittable) { - marshallingStrategy = new ContiguousBlittableElementCollectionMarshalling(marshallingStrategy, collectionInfo.ElementType.AsTypeSyntax()); + marshallingStrategy = new ContiguousBlittableElementCollectionMarshalling(marshallingStrategy, collectionInfo.ElementType.Syntax); } else { @@ -605,7 +606,7 @@ private static IMarshallingGenerator CreateNativeCollectionMarshaller( numElementsExpression, SizeOfExpression(elementType)); - if (collectionInfo.UseDefaultMarshalling && info.ManagedType is IArrayTypeSymbol { IsSZArray: true }) + if (collectionInfo.UseDefaultMarshalling && info.ManagedType is SzArrayType) { return new ArrayMarshaller( new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: true), @@ -616,7 +617,7 @@ private static IMarshallingGenerator CreateNativeCollectionMarshaller( IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); - if ((collectionInfo.MarshallingMethods & SupportedMarshallingMethods.Pinning) != 0) + if ((collectionInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedTypePinning) != 0) { return new PinnableManagedValueMarshaller(marshallingGenerator); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs index 441d2ce758b7f..e3b32f94a5c6c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs @@ -83,9 +83,9 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } var safeHandleCreationExpression = ((SafeHandleMarshallingInfo)info.MarshallingAttributeInfo).AccessibleDefaultConstructor - ? (ExpressionSyntax)ObjectCreationExpression(info.ManagedType.AsTypeSyntax(), ArgumentList(), initializer: null) + ? (ExpressionSyntax)ObjectCreationExpression(info.ManagedType.Syntax, ArgumentList(), initializer: null) : CastExpression( - info.ManagedType.AsTypeSyntax(), + info.ManagedType.Syntax, InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, @@ -97,7 +97,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont new []{ Argument( TypeOfExpression( - info.ManagedType.AsTypeSyntax())), + info.ManagedType.Syntax)), Argument( LiteralExpression( SyntaxKind.TrueLiteralExpression)) @@ -121,7 +121,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont // leak the handle if we failed to create the handle. yield return LocalDeclarationStatement( VariableDeclaration( - info.ManagedType.AsTypeSyntax(), + info.ManagedType.Syntax, SingletonSeparatedList( VariableDeclarator(newHandleObjectIdentifier) .WithInitializer(EqualsValueClause(safeHandleCreationExpression))))); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs index d69f2ea1a5855..96988216005cc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs @@ -67,14 +67,15 @@ internal sealed record MarshalAsInfo( internal sealed record BlittableTypeAttributeInfo : MarshallingInfo; [Flags] - internal enum SupportedMarshallingMethods + internal enum CustomMarshallingFeatures { None = 0, ManagedToNative = 0x1, NativeToManaged = 0x2, ManagedToNativeStackalloc = 0x4, - Pinning = 0x8, - All = -1 + ManagedTypePinning = 0x8, + NativeTypePinning = 0x10, + FreeNativeResources = 0x20, } internal abstract record CountInfo; @@ -106,10 +107,9 @@ internal sealed record SizeAndParamIndexInfo(int ConstSize, TypePositionInfo? Pa /// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute /// internal record NativeMarshallingAttributeInfo( - ITypeSymbol NativeMarshallingType, - ITypeSymbol? ValuePropertyType, - SupportedMarshallingMethods MarshallingMethods, - bool NativeTypePinnable, + ManagedTypeInfo NativeMarshallingType, + ManagedTypeInfo? ValuePropertyType, + CustomMarshallingFeatures MarshallingFeatures, bool UseDefaultMarshalling) : MarshallingInfo; /// @@ -122,24 +122,22 @@ internal sealed record GeneratedNativeMarshallingAttributeInfo( /// /// The type of the element is a SafeHandle-derived type with no marshalling attributes. /// - internal sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor) : MarshallingInfo; + internal sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor, bool IsAbstract) : MarshallingInfo; /// /// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute /// with a contiguous collection marshaller internal sealed record NativeContiguousCollectionMarshallingInfo( - ITypeSymbol NativeMarshallingType, - ITypeSymbol? ValuePropertyType, - SupportedMarshallingMethods MarshallingMethods, - bool NativeTypePinnable, + ManagedTypeInfo NativeMarshallingType, + ManagedTypeInfo? ValuePropertyType, + CustomMarshallingFeatures MarshallingFeatures, bool UseDefaultMarshalling, CountInfo ElementCountInfo, - ITypeSymbol ElementType, + ManagedTypeInfo ElementType, MarshallingInfo ElementMarshallingInfo) : NativeMarshallingAttributeInfo( NativeMarshallingType, ValuePropertyType, - MarshallingMethods, - NativeTypePinnable, + MarshallingFeatures, UseDefaultMarshalling ); @@ -407,8 +405,8 @@ CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet inspectedElements, ref int maxIndirectionLevelUsed) { - SupportedMarshallingMethods methods = SupportedMarshallingMethods.None; + CustomMarshallingFeatures features = CustomMarshallingFeatures.None; if (!isMarshalUsingAttribute && ManualTypeMarshallingHelper.FindGetPinnableReference(type) is not null) { - methods |= SupportedMarshallingMethods.Pinning; + features |= CustomMarshallingFeatures.ManagedTypePinning; } ITypeSymbol spanOfByte = _compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(_compilation.GetSpecialType(SpecialType.System_Byte)); @@ -611,12 +610,12 @@ MarshallingInfo CreateNativeMarshallingInfo( { if (ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type, marshallingVariant) && (valueProperty is null or { GetMethod: not null })) { - methods |= SupportedMarshallingMethods.ManagedToNative; + features |= CustomMarshallingFeatures.ManagedToNative; } else if (ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, spanOfByte, marshallingVariant) && (valueProperty is null or { GetMethod: not null })) { - methods |= SupportedMarshallingMethods.ManagedToNativeStackalloc; + features |= CustomMarshallingFeatures.ManagedToNativeStackalloc; } else if (ctor.Parameters.Length == 1 && ctor.Parameters[0].Type.SpecialType == SpecialType.System_Int32) { @@ -631,10 +630,10 @@ MarshallingInfo CreateNativeMarshallingInfo( && ManualTypeMarshallingHelper.HasToManagedMethod(nativeType, type) && (valueProperty is null or { SetMethod: not null })) { - methods |= SupportedMarshallingMethods.NativeToManaged; + features |= CustomMarshallingFeatures.NativeToManaged; } - if (methods == SupportedMarshallingMethods.None) + if (features == CustomMarshallingFeatures.None) { _diagnostics.ReportInvalidMarshallingAttributeInfo( attrData, @@ -645,6 +644,16 @@ MarshallingInfo CreateNativeMarshallingInfo( return NoMarshallingInfo.Instance; } + if (ManualTypeMarshallingHelper.HasFreeNativeMethod(nativeType)) + { + features |= CustomMarshallingFeatures.FreeNativeResources; + } + + if (ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null) + { + features |= CustomMarshallingFeatures.NativeTypePinning; + } + if (isContiguousCollectionMarshaller) { if (!ManualTypeMarshallingHelper.HasNativeValueStorageProperty(nativeType, spanOfByte)) @@ -660,21 +669,19 @@ MarshallingInfo CreateNativeMarshallingInfo( } return new NativeContiguousCollectionMarshallingInfo( - nativeType, - valueProperty?.Type, - methods, - NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null, + ManagedTypeInfo.CreateTypeInfoForTypeSymbol(nativeType), + valueProperty is not null ? ManagedTypeInfo.CreateTypeInfoForTypeSymbol(valueProperty.Type) : null, + features, UseDefaultMarshalling: !isMarshalUsingAttribute, parsedCountInfo, - elementType, + ManagedTypeInfo.CreateTypeInfoForTypeSymbol(elementType), GetMarshallingInfo(elementType, useSiteAttributes, indirectionLevel + 1, inspectedElements, ref maxIndirectionLevelUsed)); } return new NativeMarshallingAttributeInfo( - nativeType, - valueProperty?.Type, - methods, - NativeTypePinnable: ManualTypeMarshallingHelper.FindGetPinnableReference(nativeType) is not null, + ManagedTypeInfo.CreateTypeInfoForTypeSymbol(nativeType), + valueProperty is not null ? ManagedTypeInfo.CreateTypeInfoForTypeSymbol(valueProperty.Type) : null, + features, UseDefaultMarshalling: !isMarshalUsingAttribute); } @@ -705,7 +712,7 @@ bool TryCreateTypeBasedMarshallingInfo( } } } - marshallingInfo = new SafeHandleMarshallingInfo(hasAccessibleDefaultConstructor); + marshallingInfo = new SafeHandleMarshallingInfo(hasAccessibleDefaultConstructor, type.IsAbstract); return true; } @@ -729,14 +736,15 @@ bool TryCreateTypeBasedMarshallingInfo( return false; } + ITypeSymbol? valuePropertyType = ManualTypeMarshallingHelper.FindValueProperty(arrayMarshaller)?.Type; + marshallingInfo = new NativeContiguousCollectionMarshallingInfo( - NativeMarshallingType: arrayMarshaller, - ValuePropertyType: ManualTypeMarshallingHelper.FindValueProperty(arrayMarshaller)?.Type, - MarshallingMethods: ~SupportedMarshallingMethods.Pinning, - NativeTypePinnable: true, + NativeMarshallingType: ManagedTypeInfo.CreateTypeInfoForTypeSymbol(arrayMarshaller), + ValuePropertyType: valuePropertyType is not null ? ManagedTypeInfo.CreateTypeInfoForTypeSymbol(valuePropertyType) : null, + MarshallingFeatures: ~CustomMarshallingFeatures.ManagedTypePinning, UseDefaultMarshalling: true, ElementCountInfo: parsedCountInfo, - ElementType: elementType, + ElementType: ManagedTypeInfo.CreateTypeInfoForTypeSymbol(elementType), ElementMarshallingInfo: GetMarshallingInfo(elementType, useSiteAttributes, indirectionLevel + 1, inspectedElements, ref maxIndirectionLevelUsed)); return true; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs index fe488c608812e..1fcacdb07a720 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs @@ -61,7 +61,7 @@ public enum Stage GuaranteedUnmarshal } - public Stage CurrentStage { get; protected set; } = Stage.Invalid; + public Stage CurrentStage { get; set; } = Stage.Invalid; /// /// The stub emits code that runs in a single stack frame and the frame spans over the native context. @@ -88,7 +88,7 @@ public enum Stage /// public StubCodeContext? ParentContext { get; protected set; } - protected const string GeneratedNativeIdentifierSuffix = "_gen_native"; + public const string GeneratedNativeIdentifierSuffix = "_gen_native"; /// /// Get managed and native instance identifiers for the diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs index 5679a0235094f..2732414adc42b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; @@ -8,11 +9,14 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Microsoft.Interop.StubCodeContext; namespace Microsoft.Interop { internal sealed class StubCodeGenerator : StubCodeContext { + private record struct BoundGenerator(TypePositionInfo TypeInfo, IMarshallingGenerator Generator); + public override bool SingleFrameSpansNativeContext => true; public override bool AdditionalTemporaryStateLivesAcrossStages => true; @@ -26,7 +30,7 @@ internal sealed class StubCodeGenerator : StubCodeContext /// Identifier for native return value /// /// Same as the managed identifier by default - public string ReturnNativeIdentifier { get; private set; } = ReturnIdentifier; + public string ReturnNativeIdentifier { get; } = ReturnIdentifier; private const string InvokeReturnIdentifier = "__invokeRetVal"; private const string LastErrorIdentifier = "__lastError"; @@ -35,40 +39,62 @@ internal sealed class StubCodeGenerator : StubCodeContext // Error code representing success. This maps to S_OK for Windows HRESULT semantics and 0 for POSIX errno semantics. private const int SuccessErrorCode = 0; - private readonly GeneratorDiagnostics diagnostics; private readonly AnalyzerConfigOptions options; - private readonly IMethodSymbol stubMethod; - private readonly DllImportStub.GeneratedDllImportData dllImportData; - private readonly IEnumerable paramsTypeInfo; - private readonly List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> paramMarshallers; - private readonly (TypePositionInfo TypeInfo, IMarshallingGenerator Generator) retMarshaller; - private readonly List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> sortedMarshallers; + private readonly GeneratedDllImportData dllImportData; + private readonly List paramMarshallers; + private readonly BoundGenerator retMarshaller; + private readonly List sortedMarshallers; + private readonly bool stubReturnsVoid; public StubCodeGenerator( - IMethodSymbol stubMethod, - DllImportStub.GeneratedDllImportData dllImportData, - IEnumerable paramsTypeInfo, - TypePositionInfo retTypeInfo, - GeneratorDiagnostics generatorDiagnostics, - AnalyzerConfigOptions options) + GeneratedDllImportData dllImportData, + IEnumerable argTypes, + AnalyzerConfigOptions options, + Action marshallingNotSupportedCallback) { - Debug.Assert(retTypeInfo.IsNativeReturnPosition); - - this.stubMethod = stubMethod; this.dllImportData = dllImportData; - this.paramsTypeInfo = paramsTypeInfo.ToList(); - this.diagnostics = generatorDiagnostics; this.options = options; - // Get marshallers for parameters - this.paramMarshallers = paramsTypeInfo.Select(p => CreateGenerator(p)).ToList(); + List allMarshallers = new(); + List paramMarshallers = new(); + bool foundNativeRetMarshaller = false; + bool foundManagedRetMarshaller = false; + BoundGenerator nativeRetMarshaller = new(new TypePositionInfo(SpecialTypeInfo.Void, NoMarshallingInfo.Instance), new Forwarder()); + BoundGenerator managedRetMarshaller = new(new TypePositionInfo(SpecialTypeInfo.Void, NoMarshallingInfo.Instance), new Forwarder()); + + foreach (var argType in argTypes) + { + BoundGenerator generator = CreateGenerator(argType); + allMarshallers.Add(generator); + if (argType.IsManagedReturnPosition) + { + Debug.Assert(!foundManagedRetMarshaller); + managedRetMarshaller = generator; + foundManagedRetMarshaller = true; + } + if (argType.IsNativeReturnPosition) + { + Debug.Assert(!foundNativeRetMarshaller); + nativeRetMarshaller = generator; + foundNativeRetMarshaller = true; + } + if (!argType.IsManagedReturnPosition && !argType.IsNativeReturnPosition) + { + paramMarshallers.Add(generator); + } + } - // Get marshaller for return - this.retMarshaller = CreateGenerator(retTypeInfo); + this.stubReturnsVoid = managedRetMarshaller.TypeInfo.ManagedType == SpecialTypeInfo.Void; + if (!managedRetMarshaller.TypeInfo.IsNativeReturnPosition && !this.stubReturnsVoid) + { + // If the managed ret marshaller isn't the native ret marshaller, then the managed ret marshaller + // is a parameter. + paramMarshallers.Add(managedRetMarshaller); + } - List<(TypePositionInfo TypeInfo, IMarshallingGenerator Generator)> allMarshallers = new(this.paramMarshallers); - allMarshallers.Add(retMarshaller); + this.retMarshaller = nativeRetMarshaller; + this.paramMarshallers = paramMarshallers; // We are doing a topological sort of our marshallers to ensure that each parameter/return value's // dependencies are unmarshalled before their dependents. This comes up in the case of contiguous @@ -98,17 +124,10 @@ public StubCodeGenerator( static m => GetInfoDependencies(m.TypeInfo)) .ToList(); - (TypePositionInfo info, IMarshallingGenerator gen) CreateGenerator(TypePositionInfo p) + if (managedRetMarshaller.Generator.UsesNativeIdentifier(managedRetMarshaller.TypeInfo, this)) { - try - { - return (p, MarshallingGenerators.Create(p, this, options)); - } - catch (MarshallingNotSupportedException e) - { - this.diagnostics.ReportMarshallingNotSupported(this.stubMethod, p, e.NotSupportedDetails); - return (p, MarshallingGenerators.Forwarder); - } + // Update the native identifier for the return value + this.ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; } static IEnumerable GetInfoDependencies(TypePositionInfo info) @@ -132,6 +151,19 @@ static int GetInfoIndex(TypePositionInfo info) } return info.ManagedIndex; } + + BoundGenerator CreateGenerator(TypePositionInfo p) + { + try + { + return new BoundGenerator(p, MarshallingGenerators.Create(p, this, options)); + } + catch (MarshallingNotSupportedException e) + { + marshallingNotSupportedCallback(p, e); + return new BoundGenerator(p, MarshallingGenerators.Forwarder); + } + } } public override (string managed, string native) GetIdentifiers(TypePositionInfo info) @@ -164,17 +196,11 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } } - public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) + public BlockSyntax GenerateBody(string methodName, AttributeListSyntax? forwardedAttributes) { - string dllImportName = stubMethod.Name + "__PInvoke__"; + string dllImportName = methodName + "__PInvoke__"; var setupStatements = new List(); - if (retMarshaller.Generator.UsesNativeIdentifier(retMarshaller.TypeInfo, this)) - { - // Update the native identifier for the return value - ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; - } - foreach (var marshaller in paramMarshallers) { TypePositionInfo info = marshaller.TypeInfo; @@ -197,8 +223,7 @@ public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) AppendVariableDeclations(setupStatements, info, marshaller.Generator); } - bool invokeReturnsVoid = retMarshaller.TypeInfo.ManagedType.SpecialType == SpecialType.System_Void; - bool stubReturnsVoid = stubMethod.ReturnsVoid; + bool invokeReturnsVoid = retMarshaller.TypeInfo.ManagedType == SpecialTypeInfo.Void; // Stub return is not the same as invoke return if (!stubReturnsVoid && !retMarshaller.TypeInfo.IsManagedReturnPosition) @@ -210,11 +235,6 @@ public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) Debug.Assert(paramMarshallers.Any() && paramMarshallers.Last().TypeInfo.IsManagedReturnPosition, "Expected stub return to be the last parameter for the invoke"); (TypePositionInfo stubRetTypeInfo, IMarshallingGenerator stubRetGenerator) = paramMarshallers.Last(); - if (stubRetGenerator.UsesNativeIdentifier(stubRetTypeInfo, this)) - { - // Update the native identifier for the return value - ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; - } // Declare variables for stub return value AppendVariableDeclations(setupStatements, stubRetTypeInfo, stubRetGenerator); @@ -303,7 +323,7 @@ public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) .WithAttributeLists( SingletonList(AttributeList( - SingletonSeparatedList(CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData()))))); + SingletonSeparatedList(CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData(methodName)))))); if (retMarshaller.Generator is IAttributedReturnTypeMarshallingGenerator retGenerator) { @@ -313,7 +333,7 @@ public BlockSyntax GenerateSyntax(AttributeListSyntax? forwardedAttributes) dllImport = dllImport.AddAttributeLists(returnAttribute.WithTarget(AttributeTargetSpecifier(Identifier("return")))); } } - + if (forwardedAttributes is not null) { dllImport = dllImport.AddAttributeLists(forwardedAttributes); @@ -334,7 +354,6 @@ void GenerateStatementsForStage(Stage stage, List statementsToU if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Cleanup)) { - // Handle setup and unmarshalling for return var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, this); statementsToUpdate.AddRange(retStatements); } @@ -400,7 +419,6 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc } StatementSyntax invokeStatement; - // Assign to return value if necessary if (invokeReturnsVoid) { @@ -442,7 +460,6 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc invokeStatement = Block(clearLastError, invokeStatement, getLastError); } - // Nest invocation in fixed statements if (fixedStatements.Any()) { @@ -467,13 +484,13 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc private void AppendVariableDeclations(List statementsToUpdate, TypePositionInfo info, IMarshallingGenerator generator) { - var (managed, native) = GetIdentifiers(info); + var (managed, native) = this.GetIdentifiers(info); // Declare variable for return value if (info.IsManagedReturnPosition || info.IsNativeReturnPosition) { statementsToUpdate.Add(MarshallerHelpers.DeclareWithDefault( - info.ManagedType.AsTypeSyntax(), + info.ManagedType.Syntax, managed)); } @@ -486,8 +503,9 @@ private void AppendVariableDeclations(List statementsToUpdate, } } - private static AttributeSyntax CreateDllImportAttributeForTarget(DllImportStub.GeneratedDllImportData targetDllImportData) + private static AttributeSyntax CreateDllImportAttributeForTarget(GeneratedDllImportData targetDllImportData) { + Debug.Assert(targetDllImportData.EntryPoint is not null); var newAttributeArgs = new List { AttributeArgument(LiteralExpression( @@ -496,46 +514,46 @@ private static AttributeSyntax CreateDllImportAttributeForTarget(DllImportStub.G AttributeArgument( NameEquals(nameof(DllImportAttribute.EntryPoint)), null, - CreateStringExpressionSyntax(targetDllImportData.EntryPoint)) + CreateStringExpressionSyntax(targetDllImportData.EntryPoint!)) }; - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.BestFitMapping)) + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.BestFitMapping)) { var name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); var value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); newAttributeArgs.Add(AttributeArgument(name, null, value)); } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CallingConvention)) + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CallingConvention)) { var name = NameEquals(nameof(DllImportAttribute.CallingConvention)); var value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); newAttributeArgs.Add(AttributeArgument(name, null, value)); } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.CharSet)) + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet)) { var name = NameEquals(nameof(DllImportAttribute.CharSet)); var value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); newAttributeArgs.Add(AttributeArgument(name, null, value)); } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ExactSpelling)) + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ExactSpelling)) { var name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); var value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); newAttributeArgs.Add(AttributeArgument(name, null, value)); } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.PreserveSig)) + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.PreserveSig)) { var name = NameEquals(nameof(DllImportAttribute.PreserveSig)); var value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); newAttributeArgs.Add(AttributeArgument(name, null, value)); } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.SetLastError)) + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.SetLastError)) { var name = NameEquals(nameof(DllImportAttribute.SetLastError)); var value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); newAttributeArgs.Add(AttributeArgument(name, null, value)); } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.ThrowOnUnmappableChar)) + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ThrowOnUnmappableChar)) { var name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); var value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); @@ -571,31 +589,22 @@ static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum } } - DllImportStub.GeneratedDllImportData GetTargetDllImportDataFromStubData() + GeneratedDllImportData GetTargetDllImportDataFromStubData(string methodName) { - DllImportStub.DllImportMember membersToForward = DllImportStub.DllImportMember.All + DllImportMember membersToForward = DllImportMember.All // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. - & ~DllImportStub.DllImportMember.PreserveSig + & ~DllImportMember.PreserveSig // 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. - & ~DllImportStub.DllImportMember.SetLastError; + & ~DllImportMember.SetLastError; if (options.GenerateForwarders()) { - membersToForward = DllImportStub.DllImportMember.All; + membersToForward = DllImportMember.All; } - var targetDllImportData = new DllImportStub.GeneratedDllImportData + var targetDllImportData = dllImportData with { - CharSet = dllImportData.CharSet, - BestFitMapping = dllImportData.BestFitMapping, - CallingConvention = dllImportData.CallingConvention, - EntryPoint = dllImportData.EntryPoint, - ModuleName = dllImportData.ModuleName, - ExactSpelling = dllImportData.ExactSpelling, - SetLastError = dllImportData.SetLastError, - PreserveSig = dllImportData.PreserveSig, - ThrowOnUnmappableChar = dllImportData.ThrowOnUnmappableChar, IsUserDefined = dllImportData.IsUserDefined & membersToForward }; @@ -604,9 +613,9 @@ DllImportStub.GeneratedDllImportData GetTargetDllImportDataFromStubData() // // N.B. The export discovery logic is identical regardless of where // the name is defined (i.e. method name vs EntryPoint property). - if (!targetDllImportData.IsUserDefined.HasFlag(DllImportStub.DllImportMember.EntryPoint)) + if (!targetDllImportData.IsUserDefined.HasFlag(DllImportMember.EntryPoint)) { - targetDllImportData.EntryPoint = stubMethod.Name; + targetDllImportData = targetDllImportData with { EntryPoint = methodName }; } return targetDllImportData; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs index 0f011d9f0846a..2cbbcb87beccb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs @@ -40,27 +40,15 @@ internal enum ByValueContentsMarshalKind /// /// Positional type information involved in unmanaged/managed scenarios. /// - internal sealed record TypePositionInfo + internal sealed record TypePositionInfo(ManagedTypeInfo ManagedType, MarshallingInfo MarshallingAttributeInfo) { public const int UnsetIndex = int.MinValue; public const int ReturnIndex = UnsetIndex + 1; -// We don't need the warnings around not setting the various -// non-nullable fields/properties on this type in the constructor -// since we always use a property initializer. -#pragma warning disable 8618 - private TypePositionInfo() - { - this.ManagedIndex = UnsetIndex; - this.NativeIndex = UnsetIndex; - } -#pragma warning restore - - public string InstanceIdentifier { get; init; } - public ITypeSymbol ManagedType { get; init; } + public string InstanceIdentifier { get; init; } = string.Empty; - public RefKind RefKind { get; init; } - public SyntaxKind RefKindSyntax { get; init; } + public RefKind RefKind { get; init; } = RefKind.None; + public SyntaxKind RefKindSyntax { get; init; } = SyntaxKind.None; public bool IsByRef => RefKind != RefKind.None; @@ -69,40 +57,22 @@ private TypePositionInfo() public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } public bool IsNativeReturnPosition { get => this.NativeIndex == ReturnIndex; } - public int ManagedIndex { get; init; } - public int NativeIndex { get; init; } - - public MarshallingInfo MarshallingAttributeInfo { get; init; } + public int ManagedIndex { get; init; } = UnsetIndex; + public int NativeIndex { get; init; } = UnsetIndex; public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, MarshallingInfo marshallingInfo, Compilation compilation) { - var typeInfo = new TypePositionInfo() + var typeInfo = new TypePositionInfo(ManagedTypeInfo.CreateTypeInfoForTypeSymbol(paramSymbol.Type), marshallingInfo) { - ManagedType = paramSymbol.Type, InstanceIdentifier = ParseToken(paramSymbol.Name).IsReservedKeyword() ? $"@{paramSymbol.Name}" : paramSymbol.Name, RefKind = paramSymbol.RefKind, RefKindSyntax = RefKindToSyntax(paramSymbol.RefKind), - MarshallingAttributeInfo = marshallingInfo, ByValueContentsMarshalKind = GetByValueContentsMarshalKind(paramSymbol.GetAttributes(), compilation) }; return typeInfo; } - public static TypePositionInfo CreateForType(ITypeSymbol type, MarshallingInfo marshallingInfo, string identifier = "") - { - var typeInfo = new TypePositionInfo() - { - ManagedType = type, - InstanceIdentifier = identifier, - RefKind = RefKind.None, - RefKindSyntax = SyntaxKind.None, - MarshallingAttributeInfo = marshallingInfo - }; - - return typeInfo; - } - private static ByValueContentsMarshalKind GetByValueContentsMarshalKind(IEnumerable attributes, Compilation compilation) { INamedTypeSymbol outAttributeType = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_OutAttribute)!; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs index a37aa5708efad..e9b3b8261a95f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs @@ -163,9 +163,9 @@ public static TypeSyntax AsTypeSyntax(this ITypeSymbol type) return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); } - public static bool IsIntegralType(this ITypeSymbol type) + public static bool IsIntegralType(this SpecialType type) { - return type.SpecialType switch + return type switch { SpecialType.System_SByte or SpecialType.System_Byte diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs new file mode 100644 index 0000000000000..f33ae8b9564fd --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Interop +{ + /// + /// An exception that should be thrown on code-paths that are unreachable. + /// + internal class UnreachableException : Exception + { + } +} 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 7af1a40c40bcd..e19d9b4e5d9bf 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 @@ -3,7 +3,6 @@ Microsoft.Interop.Ancillary net6.0 - 8.0 System.Runtime.InteropServices enable true diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs new file mode 100644 index 0000000000000..e37e6fdd7ab43 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs @@ -0,0 +1,203 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Text; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; +using static Microsoft.Interop.DllImportGenerator; + +namespace DllImportGenerator.UnitTests +{ + public class IncrementalGenerationTests + { + public const string RequiresIncrementalSyntaxTreeModifySupport = "The GeneratorDriver treats all SyntaxTree replace operations on a Compilation as an Add/Remove operation instead of a Modify operation" + + ", so all cached results based on that input are thrown out. As a result, we cannot validate that unrelated changes within the same SyntaxTree do not cause regeneration."; + + [Fact] + public async Task AddingNewUnrelatedType_DoesNotRegenerateSource() + { + string source = CodeSnippets.BasicParametersAndModifiers(); + + Compilation comp1 = await TestUtils.CreateCompilation(source); + + Microsoft.Interop.DllImportGenerator generator = new(); + GeneratorDriver driver = TestUtils.CreateDriver(comp1, null, new IIncrementalGenerator[] { generator }); + + driver = driver.RunGenerators(comp1); + + generator.IncrementalTracker = new IncrementalityTracker(); + + Compilation comp2 = comp1.AddSyntaxTrees(CSharpSyntaxTree.ParseText("struct Foo {}", new CSharpParseOptions(LanguageVersion.Preview))); + driver.RunGenerators(comp2); + + Assert.Collection(generator.IncrementalTracker.ExecutedSteps, + step => + { + Assert.Equal(IncrementalityTracker.StepName.CalculateStubInformation, step.Step); + }); + } + + [Fact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] + public async Task AppendingUnrelatedSource_DoesNotRegenerateSource() + { + string source = $"namespace NS{{{CodeSnippets.BasicParametersAndModifiers()}}}"; + + SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)); + + Compilation comp1 = await TestUtils.CreateCompilation(new[] { syntaxTree }); + + Microsoft.Interop.DllImportGenerator generator = new(); + GeneratorDriver driver = TestUtils.CreateDriver(comp1, null, new[] { generator }); + + driver = driver.RunGenerators(comp1); + + generator.IncrementalTracker = new IncrementalityTracker(); + + SyntaxTree newTree = syntaxTree.WithRootAndOptions(syntaxTree.GetCompilationUnitRoot().AddMembers(SyntaxFactory.ParseMemberDeclaration("struct Foo {}")!), syntaxTree.Options); + + Compilation comp2 = comp1.ReplaceSyntaxTree(comp1.SyntaxTrees.First(), newTree); + driver.RunGenerators(comp2); + + Assert.Collection(generator.IncrementalTracker.ExecutedSteps, + step => + { + Assert.Equal(IncrementalityTracker.StepName.CalculateStubInformation, step.Step); + }); + } + + [Fact] + public async Task AddingFileWithNewGeneratedDllImport_DoesNotRegenerateOriginalMethod() + { + string source = CodeSnippets.BasicParametersAndModifiers(); + + Compilation comp1 = await TestUtils.CreateCompilation(source); + + Microsoft.Interop.DllImportGenerator generator = new(); + GeneratorDriver driver = TestUtils.CreateDriver(comp1, null, new[] { generator }); + + driver = driver.RunGenerators(comp1); + + generator.IncrementalTracker = new IncrementalityTracker(); + + Compilation comp2 = comp1.AddSyntaxTrees(CSharpSyntaxTree.ParseText(CodeSnippets.BasicParametersAndModifiers(), new CSharpParseOptions(LanguageVersion.Preview))); + driver.RunGenerators(comp2); + + Assert.Equal(2, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.CalculateStubInformation)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.GenerateSingleStub)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.NormalizeWhitespace)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.ConcatenateStubs)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.OutputSourceFile)); + } + + [Fact] + public async Task ReplacingFileWithNewGeneratedDllImport_DoesNotRegenerateStubsInOtherFiles() + { + string source = CodeSnippets.BasicParametersAndModifiers(); + + Compilation comp1 = await TestUtils.CreateCompilation(new string[] { CodeSnippets.BasicParametersAndModifiers(), CodeSnippets.BasicParametersAndModifiers() }); + + Microsoft.Interop.DllImportGenerator generator = new(); + GeneratorDriver driver = TestUtils.CreateDriver(comp1, null, new[] { generator }); + + driver = driver.RunGenerators(comp1); + + generator.IncrementalTracker = new IncrementalityTracker(); + + Compilation comp2 = comp1.ReplaceSyntaxTree(comp1.SyntaxTrees.First(), CSharpSyntaxTree.ParseText(CodeSnippets.BasicParametersAndModifiers(), new CSharpParseOptions(LanguageVersion.Preview))); + driver.RunGenerators(comp2); + + Assert.Equal(2, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.CalculateStubInformation)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.GenerateSingleStub)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.NormalizeWhitespace)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.ConcatenateStubs)); + Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.OutputSourceFile)); + } + + [Fact] + public async Task ChangingMarshallingStrategy_RegeneratesStub() + { + string stubSource = CodeSnippets.BasicParametersAndModifiers("CustomType"); + + string customTypeImpl1 = "struct CustomType { System.IntPtr handle; }"; + + string customTypeImpl2 = "class CustomType : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid { public CustomType():base(true){} protected override bool ReleaseHandle(){return true;} }"; + + + Compilation comp1 = await TestUtils.CreateCompilation(stubSource); + + SyntaxTree customTypeImpl1Tree = CSharpSyntaxTree.ParseText(customTypeImpl1, new CSharpParseOptions(LanguageVersion.Preview)); + comp1 = comp1.AddSyntaxTrees(customTypeImpl1Tree); + + Microsoft.Interop.DllImportGenerator generator = new(); + GeneratorDriver driver = TestUtils.CreateDriver(comp1, null, new[] { generator }); + + driver = driver.RunGenerators(comp1); + + generator.IncrementalTracker = new IncrementalityTracker(); + + Compilation comp2 = comp1.ReplaceSyntaxTree(customTypeImpl1Tree, CSharpSyntaxTree.ParseText(customTypeImpl2, new CSharpParseOptions(LanguageVersion.Preview))); + driver.RunGenerators(comp2); + + Assert.Collection(generator.IncrementalTracker.ExecutedSteps, + step => + { + Assert.Equal(IncrementalityTracker.StepName.CalculateStubInformation, step.Step); + }, + step => + { + Assert.Equal(IncrementalityTracker.StepName.GenerateSingleStub, step.Step); + }, + step => + { + Assert.Equal(IncrementalityTracker.StepName.NormalizeWhitespace, step.Step); + }, + step => + { + Assert.Equal(IncrementalityTracker.StepName.ConcatenateStubs, step.Step); + }, + step => + { + Assert.Equal(IncrementalityTracker.StepName.OutputSourceFile, step.Step); + }); + } + + [Fact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] + public async Task ChangingMarshallingAttributes_SameStrategy_DoesNotRegenerate() + { + string source = CodeSnippets.BasicParametersAndModifiers(); + + SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)); + + Compilation comp1 = await TestUtils.CreateCompilation(new[] { syntaxTree }); + + Microsoft.Interop.DllImportGenerator generator = new(); + GeneratorDriver driver = TestUtils.CreateDriver(comp1, null, new[] { generator }); + + driver = driver.RunGenerators(comp1); + + generator.IncrementalTracker = new IncrementalityTracker(); + + SyntaxTree newTree = syntaxTree.WithRootAndOptions( + syntaxTree.GetCompilationUnitRoot().AddMembers( + SyntaxFactory.ParseMemberDeclaration( + CodeSnippets.MarshalAsParametersAndModifiers(System.Runtime.InteropServices.UnmanagedType.Bool))!), + syntaxTree.Options); + + Compilation comp2 = comp1.ReplaceSyntaxTree(comp1.SyntaxTrees.First(), newTree); + driver.RunGenerators(comp2); + + Assert.Collection(generator.IncrementalTracker.ExecutedSteps, + step => + { + Assert.Equal(IncrementalityTracker.StepName.CalculateStubInformation, step.Step); + }, + step => + { + Assert.Equal(IncrementalityTracker.StepName.GenerateSingleStub, step.Step); + }); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index fd49c82ccf914..db7b0f3feccf8 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -45,14 +45,26 @@ public static void AssertPreSourceGeneratorCompilation(Compilation comp) /// Output type /// Whether or not use of the unsafe keyword should be allowed /// The resulting compilation - public static async Task CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true, IEnumerable? preprocessorSymbols = null) + public static Task CreateCompilation(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true, IEnumerable? preprocessorSymbols = null) { - var (mdRefs, ancillary) = GetReferenceAssemblies(); + return CreateCompilation(new[] { source }, outputKind, allowUnsafe, preprocessorSymbols); + } - return CSharpCompilation.Create("compilation", - new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview, preprocessorSymbols: preprocessorSymbols)) }, - (await mdRefs.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)).Add(ancillary), - new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); + /// + /// Create a compilation given sources + /// + /// Sources to compile + /// Output type + /// Whether or not use of the unsafe keyword should be allowed + /// The resulting compilation + public static Task CreateCompilation(string[] sources, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true, IEnumerable? preprocessorSymbols = null) + { + return CreateCompilation( + sources.Select(source => + CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview, preprocessorSymbols: preprocessorSymbols))).ToArray(), + outputKind, + allowUnsafe, + preprocessorSymbols); } /// @@ -62,13 +74,12 @@ public static async Task CreateCompilation(string source, OutputKin /// Output type /// Whether or not use of the unsafe keyword should be allowed /// The resulting compilation - public static async Task CreateCompilation(string[] sources, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true, IEnumerable? preprocessorSymbols = null) + public static async Task CreateCompilation(SyntaxTree[] sources, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true, IEnumerable? preprocessorSymbols = null) { var (mdRefs, ancillary) = GetReferenceAssemblies(); return CSharpCompilation.Create("compilation", - sources.Select(source => - CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview, preprocessorSymbols: preprocessorSymbols))).ToArray(), + sources, (await mdRefs.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)).Add(ancillary), new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); } @@ -81,10 +92,23 @@ public static async Task CreateCompilation(string[] sources, Output /// Output type /// Whether or not use of the unsafe keyword should be allowed /// The resulting compilation - public static async Task CreateCompilationWithReferenceAssemblies(string source, ReferenceAssemblies referenceAssemblies, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true) + public static Task CreateCompilationWithReferenceAssemblies(string source, ReferenceAssemblies referenceAssemblies, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true) + { + return CreateCompilationWithReferenceAssemblies(new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, referenceAssemblies, outputKind, allowUnsafe); + } + + /// + /// Create a compilation given source and reference assemblies + /// + /// Source to compile + /// Reference assemblies to include + /// Output type + /// Whether or not use of the unsafe keyword should be allowed + /// The resulting compilation + public static async Task CreateCompilationWithReferenceAssemblies(SyntaxTree[] sources, ReferenceAssemblies referenceAssemblies, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, bool allowUnsafe = true) { return CSharpCompilation.Create("compilation", - new[] { CSharpSyntaxTree.ParseText(source, new CSharpParseOptions(LanguageVersion.Preview)) }, + sources, (await referenceAssemblies.ResolveAsync(LanguageNames.CSharp, CancellationToken.None)), new CSharpCompilationOptions(outputKind, allowUnsafe: allowUnsafe)); } @@ -96,7 +120,7 @@ public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() "net6.0", new PackageIdentity( "Microsoft.NETCore.App.Ref", - "6.0.0-preview.6.21317.4"), + "6.0.0-preview.7.21377.19"), Path.Combine("ref", "net6.0")) .WithNuGetConfigFilePath(Path.Combine(Path.GetDirectoryName(typeof(TestUtils).Assembly.Location)!, "NuGet.config")); @@ -114,7 +138,7 @@ public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies() /// Resulting diagnostics /// Source generator instances /// The resulting compilation - public static Compilation RunGenerators(Compilation comp, out ImmutableArray diagnostics, params ISourceGenerator[] generators) + public static Compilation RunGenerators(Compilation comp, out ImmutableArray diagnostics, params IIncrementalGenerator[] generators) { CreateDriver(comp, null, generators).RunGeneratorsAndUpdateCompilation(comp, out var d, out diagnostics); return d; @@ -127,15 +151,15 @@ public static Compilation RunGenerators(Compilation comp, out ImmutableArrayResulting diagnostics /// Source generator instances /// The resulting compilation - public static Compilation RunGenerators(Compilation comp, AnalyzerConfigOptionsProvider options, out ImmutableArray diagnostics, params ISourceGenerator[] generators) + public static Compilation RunGenerators(Compilation comp, AnalyzerConfigOptionsProvider options, out ImmutableArray diagnostics, params IIncrementalGenerator[] generators) { CreateDriver(comp, options, generators).RunGeneratorsAndUpdateCompilation(comp, out var d, out diagnostics); return d; } - private static GeneratorDriver CreateDriver(Compilation c, AnalyzerConfigOptionsProvider? options, ISourceGenerator[] generators) + public static GeneratorDriver CreateDriver(Compilation c, AnalyzerConfigOptionsProvider? options, IIncrementalGenerator[] generators) => CSharpGeneratorDriver.Create( - ImmutableArray.Create(generators), + ImmutableArray.Create(generators.Select(gen => gen.AsSourceGenerator()).ToArray()), parseOptions: (CSharpParseOptions)c.SyntaxTrees.First().Options, optionsProvider: options); } From 2449c469dcb604c2a38f05dbc61575bfae2623b6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 10 Sep 2021 15:25:16 -0700 Subject: [PATCH 140/161] Refactor DllImportGenerator project for easier extensibility (dotnet/runtimelab#1119) Commit migrated from https://github.com/dotnet/runtimelab/commit/9ac16c6c9f47100ea91db6231ad47f4a8d6ca946 --- .../DllImportGenerator/DllImportGenerator.cs | 196 +++++- .../DllImportGenerator.csproj | 16 +- ...Helper.cs => DllImportGeneratorOptions.cs} | 13 +- .../DllImportStubContext.cs | 77 ++- .../ForwarderMarshallingGeneratorFactory.cs | 13 + .../GeneratorDiagnostics.cs | 65 +- .../Marshalling/MarshallingGenerator.cs | 628 ------------------ ...oPreserveSigMarshallingGeneratorFactory.cs | 30 + ...nerator.cs => PInvokeStubCodeGenerator.cs} | 213 ++---- .../DllImportGenerator/Resources.Designer.cs | 127 +--- .../gen/DllImportGenerator/Resources.resx | 55 +- .../gen/DllImportGenerator/TypeNames.cs | 20 +- ...CollectionElementMarshallingCodeContext.cs | 0 .../IGeneratorDiagnostics.cs | 99 +++ .../InteropGenerationOptions.cs | 8 + .../LanguageSupport.cs | 10 + .../ManagedTypeInfo.cs | 14 +- .../ManualTypeMarshallingHelper.cs | 2 +- .../Marshalling/ArrayMarshaller.cs | 6 +- ...ributedMarshallingModelGeneratorFactory.cs | 292 ++++++++ .../Marshalling/BlittableMarshaller.cs | 2 +- .../Marshalling/BoolMarshaller.cs | 8 +- .../ByValueContentsMarshalKindValidator.cs | 51 ++ .../Marshalling/CharMarshaller.cs | 2 +- ...nditionalStackallocMarshallingGenerator.cs | 2 +- .../CustomNativeTypeMarshallingGenerator.cs | 0 .../Marshalling/DelegateMarshaller.cs | 2 +- .../Marshalling/Forwarder.cs | 2 +- .../Marshalling/HResultExceptionMarshaller.cs | 2 +- .../ICustomNativeTypeMarshallingStrategy.cs | 0 .../Marshalling/MarshallerHelpers.cs | 2 +- .../Marshalling/MarshallingGenerator.cs | 116 ++++ .../MarshallingGeneratorFactory.cs | 221 ++++++ .../PinnableManagedValueMarshaller.cs | 2 +- .../Marshalling/SafeHandleMarshaller.cs | 9 +- .../Marshalling/StringMarshaller.Ansi.cs | 2 +- .../StringMarshaller.PlatformDefined.cs | 2 +- .../Marshalling/StringMarshaller.Utf16.cs | 2 +- .../Marshalling/StringMarshaller.Utf8.cs | 2 +- .../MarshallingAttributeInfo.cs | 47 +- .../Microsoft.Interop.SourceGeneration.csproj | 30 + .../Resources.Designer.cs | 369 ++++++++++ .../Resources.resx | 222 +++++++ .../StubCodeContext.cs | 2 +- .../TypeNames.cs | 68 ++ .../TypePositionInfo.cs | 4 +- .../TypeSymbolExtensions.cs | 2 +- .../Ancillary.Interop.csproj | 1 + .../DllImportGenerator.Tests.csproj | 1 + .../DllImportGeneratorSample.csproj | 1 + 50 files changed, 1912 insertions(+), 1148 deletions(-) rename src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/{OptionsHelper.cs => DllImportGeneratorOptions.cs} (77%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs rename src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/{StubCodeGenerator.cs => PInvokeStubCodeGenerator.cs} (71%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/ContiguousCollectionElementMarshallingCodeContext.cs (100%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/ManagedTypeInfo.cs (68%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/ManualTypeMarshallingHelper.cs (99%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/ArrayMarshaller.cs (96%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/BlittableMarshaller.cs (98%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/BoolMarshaller.cs (95%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/CharMarshaller.cs (97%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/ConditionalStackallocMarshallingGenerator.cs (99%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/CustomNativeTypeMarshallingGenerator.cs (100%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/DelegateMarshaller.cs (98%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/Forwarder.cs (98%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/HResultExceptionMarshaller.cs (96%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/ICustomNativeTypeMarshallingStrategy.cs (100%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/MarshallerHelpers.cs (99%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/PinnableManagedValueMarshaller.cs (97%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/SafeHandleMarshaller.cs (98%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/StringMarshaller.Ansi.cs (98%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/StringMarshaller.PlatformDefined.cs (98%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/StringMarshaller.Utf16.cs (99%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/Marshalling/StringMarshaller.Utf8.cs (99%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/MarshallingAttributeInfo.cs (96%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.Designer.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.resx rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/StubCodeContext.cs (98%) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/TypePositionInfo.cs (96%) rename src/libraries/System.Runtime.InteropServices/gen/{DllImportGenerator => Microsoft.Interop.SourceGeneration}/TypeSymbolExtensions.cs (99%) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 92668a646d46b..70dfbaef01203 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -105,16 +105,18 @@ public void Initialize(IncrementalGeneratorInitializationContext context) } }); + var stubOptions = context.AnalyzerConfigOptionsProvider.Select((options, ct) => new DllImportGeneratorOptions(options.GlobalOptions)); + var stubEnvironment = compilationAndTargetFramework - .Combine(context.AnalyzerConfigOptionsProvider) + .Combine(stubOptions) .Select( static (data, ct) => new StubEnvironment( data.Left.compilation, data.Left.isSupported, data.Left.targetFrameworkVersion, - data.Right.GlobalOptions, - data.Left.compilation.SourceModule.GetAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() == TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute)) + data.Left.compilation.SourceModule.GetAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() == TypeNames.System_Runtime_CompilerServices_SkipLocalsInitAttribute), + data.Right) ); var methodSourceAndDiagnostics = methodsToGenerate @@ -133,12 +135,12 @@ public void Initialize(IncrementalGeneratorInitializationContext context) } ) .WithComparer(Comparers.CalculatedContextWithSyntax) - .Combine(context.AnalyzerConfigOptionsProvider) + .Combine(stubOptions) .Select( (data, ct) => { IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.GenerateSingleStub, data)); - return GenerateSource(data.Left.StubContext, data.Left.Syntax, data.Right.GlobalOptions); + return GenerateSource(data.Left.StubContext, data.Left.Syntax, data.Right); } ) .WithComparer(Comparers.GeneratedSyntax) @@ -444,24 +446,196 @@ private static IncrementalStubGenerationContext CalculateStubInformation(MethodD private (MemberDeclarationSyntax, ImmutableArray) GenerateSource( IncrementalStubGenerationContext dllImportStub, MethodDeclarationSyntax originalSyntax, - AnalyzerConfigOptions options) + DllImportGeneratorOptions options) { var diagnostics = new GeneratorDiagnostics(); // Generate stub code - var stubGenerator = new StubCodeGenerator( - dllImportStub.DllImportData, + var stubGenerator = new PInvokeStubCodeGenerator( dllImportStub.StubContext.ElementTypeInformation, - options, - (elementInfo, ex) => diagnostics.ReportMarshallingNotSupported(originalSyntax, elementInfo, ex.NotSupportedDetails)); + dllImportStub.DllImportData.SetLastError && !options.GenerateForwarders, + (elementInfo, ex) => diagnostics.ReportMarshallingNotSupported(originalSyntax, elementInfo, ex.NotSupportedDetails), + dllImportStub.StubContext.GeneratorFactory); ImmutableArray forwardedAttributes = dllImportStub.ForwardedAttributes; - var code = stubGenerator.GenerateBody(originalSyntax.Identifier.Text, forwardedAttributes: forwardedAttributes.Length != 0 ? AttributeList(SeparatedList(forwardedAttributes)) : null); + const string innerPInvokeName = "__PInvoke__"; + + var code = stubGenerator.GeneratePInvokeBody(innerPInvokeName); + + var dllImport = CreateTargetFunctionAsLocalStatement( + stubGenerator, + dllImportStub.StubContext.Options, + dllImportStub.DllImportData, + innerPInvokeName, + originalSyntax.Identifier.Text); + + if (!forwardedAttributes.IsEmpty) + { + dllImport = dllImport.AddAttributeLists(AttributeList(SeparatedList(forwardedAttributes))); + } + + code = code.AddStatements(dllImport); return (PrintGeneratedSource(originalSyntax, dllImportStub.StubContext, code), dllImportStub.Diagnostics.AddRange(diagnostics.Diagnostics)); } + + private static LocalFunctionStatementSyntax CreateTargetFunctionAsLocalStatement( + PInvokeStubCodeGenerator stubGenerator, + DllImportGeneratorOptions options, + GeneratedDllImportData dllImportData, + string stubTargetName, + string stubMethodName) + { + var (parameterList, returnType, returnTypeAttributes) = stubGenerator.GenerateTargetMethodSignatureData(); + var localDllImport = LocalFunctionStatement(returnType, stubTargetName) + .AddModifiers( + Token(SyntaxKind.ExternKeyword), + Token(SyntaxKind.StaticKeyword), + Token(SyntaxKind.UnsafeKeyword)) + .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) + .WithAttributeLists( + SingletonList(AttributeList( + SingletonSeparatedList( + CreateDllImportAttributeForTarget( + GetTargetDllImportDataFromStubData( + dllImportData, + stubMethodName, + options.GenerateForwarders)))))) + .WithParameterList(parameterList); + if (returnTypeAttributes is not null) + { + localDllImport = localDllImport.AddAttributeLists(returnTypeAttributes.WithTarget(AttributeTargetSpecifier(Token(SyntaxKind.ReturnKeyword)))); + } + return localDllImport; + } + + private static AttributeSyntax CreateDllImportAttributeForTarget(GeneratedDllImportData targetDllImportData) + { + var newAttributeArgs = new List + { + AttributeArgument(LiteralExpression( + SyntaxKind.StringLiteralExpression, + Literal(targetDllImportData.ModuleName))), + AttributeArgument( + NameEquals(nameof(DllImportAttribute.EntryPoint)), + null, + CreateStringExpressionSyntax(targetDllImportData.EntryPoint!)) + }; + + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.BestFitMapping)) + { + var name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); + var value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CallingConvention)) + { + var name = NameEquals(nameof(DllImportAttribute.CallingConvention)); + var value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet)) + { + var name = NameEquals(nameof(DllImportAttribute.CharSet)); + var value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ExactSpelling)) + { + var name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); + var value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.PreserveSig)) + { + var name = NameEquals(nameof(DllImportAttribute.PreserveSig)); + var value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.SetLastError)) + { + var name = NameEquals(nameof(DllImportAttribute.SetLastError)); + var value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ThrowOnUnmappableChar)) + { + var name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); + var value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); + newAttributeArgs.Add(AttributeArgument(name, null, value)); + } + + // Create new attribute + return Attribute( + ParseName(typeof(DllImportAttribute).FullName), + AttributeArgumentList(SeparatedList(newAttributeArgs))); + + static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) + { + return LiteralExpression( + trueOrFalse + ? SyntaxKind.TrueLiteralExpression + : SyntaxKind.FalseLiteralExpression); + } + + static ExpressionSyntax CreateStringExpressionSyntax(string str) + { + return LiteralExpression( + SyntaxKind.StringLiteralExpression, + Literal(str)); + } + + static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum + { + return MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(typeof(T).FullName), + IdentifierName(value.ToString())); + } + } + + private static GeneratedDllImportData GetTargetDllImportDataFromStubData(GeneratedDllImportData dllImportData, string originalMethodName, bool forwardAll) + { + DllImportMember membersToForward = DllImportMember.All + // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig + // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. + & ~DllImportMember.PreserveSig + // 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; + if (forwardAll) + { + membersToForward = DllImportMember.All; + } + + var targetDllImportData = new GeneratedDllImportData(dllImportData.ModuleName) + { + CharSet = dllImportData.CharSet, + BestFitMapping = dllImportData.BestFitMapping, + CallingConvention = dllImportData.CallingConvention, + EntryPoint = dllImportData.EntryPoint, + ExactSpelling = dllImportData.ExactSpelling, + SetLastError = dllImportData.SetLastError, + PreserveSig = dllImportData.PreserveSig, + ThrowOnUnmappableChar = dllImportData.ThrowOnUnmappableChar, + IsUserDefined = dllImportData.IsUserDefined & membersToForward + }; + + // If the EntryPoint property is not set, we will compute and + // add it based on existing semantics (i.e. method name). + // + // N.B. The export discovery logic is identical regardless of where + // the name is defined (i.e. method name vs EntryPoint property). + if (!targetDllImportData.IsUserDefined.HasFlag(DllImportMember.EntryPoint)) + { + targetDllImportData = targetDllImportData with { EntryPoint = originalMethodName }; + } + + return targetDllImportData; + } + private static bool ShouldVisitNode(SyntaxNode syntaxNode) { // We only support C# method declarations. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index cda46f7058dca..ca0f1512667ef 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -35,12 +35,12 @@ - + + - - + @@ -58,4 +58,14 @@ + + + + + + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs similarity index 77% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs rename to src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs index 13130369b41de..d63f7c880b9c3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/OptionsHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs @@ -1,12 +1,15 @@ -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; namespace Microsoft.Interop { + record DllImportGeneratorOptions(bool GenerateForwarders, bool UseMarshalType, bool UseInternalUnsafeType) + { + public DllImportGeneratorOptions(AnalyzerConfigOptions options) + : this(options.GenerateForwarders(), options.UseMarshalType(), options.UseInternalUnsafeType()) + { + } + } + public static class OptionsHelper { public const string UseMarshalTypeOption = "build_property.DllImportGenerator_UseMarshalType"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs index e86b8fdef826a..c3bfef462d522 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs @@ -17,8 +17,8 @@ internal record StubEnvironment( Compilation Compilation, bool SupportedTargetFramework, Version TargetFrameworkVersion, - AnalyzerConfigOptions Options, - bool ModuleSkipLocalsInit); + bool ModuleSkipLocalsInit, + DllImportGeneratorOptions Options); internal sealed class DllImportStubContext : IEquatable { @@ -58,6 +58,10 @@ public IEnumerable StubParameters public ImmutableArray AdditionalAttributes { get; init; } + public DllImportGeneratorOptions Options { get; init; } + + public IMarshallingGeneratorFactory GeneratorFactory { get; init; } + public static DllImportStubContext Create( IMethodSymbol method, GeneratedDllImportData dllImportData, @@ -95,7 +99,7 @@ public static DllImportStubContext Create( currType = currType.ContainingType; } - var typeInfos = GenerateTypeInformation(method, dllImportData, diagnostics, env); + var (typeInfos, generatorFactory) = GenerateTypeInformation(method, dllImportData, diagnostics, env); var additionalAttrs = ImmutableArray.CreateBuilder(); @@ -120,10 +124,12 @@ public static DllImportStubContext Create( StubTypeNamespace = stubTypeNamespace, StubContainingTypes = containingTypes.ToImmutable(), AdditionalAttributes = additionalAttrs.ToImmutable(), + Options = env.Options, + GeneratorFactory = generatorFactory }; } - private static ImmutableArray GenerateTypeInformation(IMethodSymbol method, GeneratedDllImportData dllImportData, GeneratorDiagnostics diagnostics, StubEnvironment env) + private static (ImmutableArray, IMarshallingGeneratorFactory) GenerateTypeInformation(IMethodSymbol method, GeneratedDllImportData dllImportData, GeneratorDiagnostics diagnostics, StubEnvironment env) { // Compute the current default string encoding value. var defaultEncoding = CharEncoding.Undefined; @@ -165,36 +171,52 @@ private static ImmutableArray GenerateTypeInformation(IMethodS NativeIndex = TypePositionInfo.ReturnIndex }; - var managedRetTypeInfo = retTypeInfo; - // Do not manually handle PreserveSig when generating forwarders. - // We want the runtime to handle everything. - if (!dllImportData.PreserveSig && !env.Options.GenerateForwarders()) + InteropGenerationOptions options = new(env.Options.UseMarshalType, env.Options.UseInternalUnsafeType); + IMarshallingGeneratorFactory generatorFactory; + + if (env.Options.GenerateForwarders) { - // Create type info for native HRESULT return - retTypeInfo = new TypePositionInfo(SpecialTypeInfo.Int32, NoMarshallingInfo.Instance); - retTypeInfo = retTypeInfo with + generatorFactory = new ForwarderMarshallingGeneratorFactory(); + } + else + { + generatorFactory = new DefaultMarshallingGeneratorFactory(options); + AttributedMarshallingModelGeneratorFactory attributedMarshallingFactory = new(generatorFactory, options); + generatorFactory = attributedMarshallingFactory; + if (!dllImportData.PreserveSig) { - NativeIndex = TypePositionInfo.ReturnIndex - }; + // Create type info for native out param + if (!method.ReturnsVoid) + { + // Transform the managed return type info into an out parameter and add it as the last param + TypePositionInfo nativeOutInfo = retTypeInfo with + { + InstanceIdentifier = PInvokeStubCodeGenerator.ReturnIdentifier, + RefKind = RefKind.Out, + RefKindSyntax = SyntaxKind.OutKeyword, + ManagedIndex = TypePositionInfo.ReturnIndex, + NativeIndex = typeInfos.Count + }; + typeInfos.Add(nativeOutInfo); + } - // Create type info for native out param - if (!method.ReturnsVoid) - { - // Transform the managed return type info into an out parameter and add it as the last param - TypePositionInfo nativeOutInfo = managedRetTypeInfo with + // Use a marshalling generator that supports the HRESULT return->exception marshalling. + generatorFactory = new NoPreserveSigMarshallingGeneratorFactory(generatorFactory); + + // Create type info for native HRESULT return + retTypeInfo = new TypePositionInfo(SpecialTypeInfo.Int32, NoMarshallingInfo.Instance); + retTypeInfo = retTypeInfo with { - InstanceIdentifier = StubCodeGenerator.ReturnIdentifier, - RefKind = RefKind.Out, - RefKindSyntax = SyntaxKind.OutKeyword, - ManagedIndex = TypePositionInfo.ReturnIndex, - NativeIndex = typeInfos.Count + NativeIndex = TypePositionInfo.ReturnIndex }; - typeInfos.Add(nativeOutInfo); } + + generatorFactory = new ByValueContentsMarshalKindValidator(generatorFactory); + attributedMarshallingFactory.ElementMarshallingGeneratorFactory = generatorFactory; } typeInfos.Add(retTypeInfo); - return typeInfos.ToImmutable(); + return (typeInfos.ToImmutable(), generatorFactory); } public override bool Equals(object obj) @@ -204,12 +226,15 @@ public override bool Equals(object obj) public bool Equals(DllImportStubContext other) { + // We don't check if the generator factories are equal since + // the generator factory is deterministically created based on the ElementTypeInformation and Options. return other is not null && StubTypeNamespace == other.StubTypeNamespace && ElementTypeInformation.SequenceEqual(other.ElementTypeInformation) && StubContainingTypes.SequenceEqual(other.StubContainingTypes, (IEqualityComparer)new SyntaxEquivalentComparer()) && StubReturnType.IsEquivalentTo(other.StubReturnType) - && AdditionalAttributes.SequenceEqual(other.AdditionalAttributes, (IEqualityComparer)new SyntaxEquivalentComparer()); + && AdditionalAttributes.SequenceEqual(other.AdditionalAttributes, (IEqualityComparer)new SyntaxEquivalentComparer()) + && Options.Equals(other.Options); } public override int GetHashCode() diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs new file mode 100644 index 0000000000000..60c85b4baba0a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Interop +{ + class ForwarderMarshallingGeneratorFactory : IMarshallingGeneratorFactory + { + private static readonly Forwarder Forwarder = new Forwarder(); + + public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) => Forwarder; + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 74abfb3c71497..77b018f4b880a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -1,69 +1,18 @@ -using System; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; -using System.Linq; - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; +using System.Text; namespace Microsoft.Interop { - internal static class DiagnosticExtensions - { - public static Diagnostic CreateDiagnostic( - this ISymbol symbol, - DiagnosticDescriptor descriptor, - params object[] args) - { - return symbol.Locations.CreateDiagnostic(descriptor, args); - } - - public static Diagnostic CreateDiagnostic( - this AttributeData attributeData, - DiagnosticDescriptor descriptor, - params object[] args) - { - SyntaxReference? syntaxReference = attributeData.ApplicationSyntaxReference; - Location location = syntaxReference is not null - ? syntaxReference.GetSyntax().GetLocation() - : Location.None; - - return location.CreateDiagnostic(descriptor, args); - } - - public static Diagnostic CreateDiagnostic( - this ImmutableArray locations, - DiagnosticDescriptor descriptor, - params object[] args) - { - IEnumerable locationsInSource = locations.Where(l => l.IsInSource); - if (!locationsInSource.Any()) - return Diagnostic.Create(descriptor, Location.None, args); - - return Diagnostic.Create( - descriptor, - location: locationsInSource.First(), - additionalLocations: locationsInSource.Skip(1), - messageArgs: args); - } - - public static Diagnostic CreateDiagnostic( - this Location location, - DiagnosticDescriptor descriptor, - params object[] args) - { - return Diagnostic.Create( - descriptor, - location: location.IsInSource ? location : Location.None, - messageArgs: args); - } - } /// /// Class for reporting diagnostics in the DLL import generator /// - public class GeneratorDiagnostics + public class GeneratorDiagnostics : IGeneratorDiagnostics { public class Ids { @@ -213,7 +162,7 @@ public void ReportConfigurationNotSupported( /// Method with the parameter/return /// Type info for the parameter/return /// [Optional] Specific reason for lack of support - internal void ReportMarshallingNotSupported( + public void ReportMarshallingNotSupported( MethodDeclarationSyntax method, TypePositionInfo info, string? notSupportedDetails) @@ -298,7 +247,7 @@ internal void ReportMarshallingNotSupported( } } - internal void ReportInvalidMarshallingAttributeInfo( + public void ReportInvalidMarshallingAttributeInfo( AttributeData attributeData, string reasonResourceName, params string[] reasonArgs) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs deleted file mode 100644 index 24fb56ad90bcf..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallingGenerator.cs +++ /dev/null @@ -1,628 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop -{ - /// - /// Interface for generation of marshalling code for P/Invoke stubs - /// - internal interface IMarshallingGenerator - { - /// - /// Get the native type syntax for - /// - /// Object to marshal - /// Type syntax for the native type representing - TypeSyntax AsNativeType(TypePositionInfo info); - - /// - /// Get the as a parameter of the P/Invoke declaration - /// - /// Object to marshal - /// Parameter syntax for - ParameterSyntax AsParameter(TypePositionInfo info); - - /// - /// Get the as an argument to be passed to the P/Invoke - /// - /// Object to marshal - /// Code generation context - /// Argument syntax for - ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context); - - /// - /// Generate code for marshalling - /// - /// Object to marshal - /// Code generation context - /// List of statements to be added to the P/Invoke stub - /// - /// The generator should return the appropriate statements based on the - /// of . - /// For , any statements not of type - /// will be ignored. - /// - IEnumerable Generate(TypePositionInfo info, StubCodeContext context); - - /// - /// Returns whether or not this marshaller uses an identifier for the native value in addition - /// to an identifer for the managed value. - /// - /// Object to marshal - /// Code generation context - /// If the marshaller uses an identifier for the native value, true; otherwise, false. - /// - /// of may not be valid. - /// - bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); - - /// - /// Returns if the given ByValueContentsMarshalKind is supported in the current marshalling context. - /// A supported marshal kind has a different behavior than the default behavior. - /// - /// The marshal kind. - /// The marshalling context. - /// - bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); - } - - /// - /// Interface for generating attributes for native return types. - /// - internal interface IAttributedReturnTypeMarshallingGenerator : IMarshallingGenerator - { - /// - /// Gets any attributes that should be applied to the return type for this . - /// - /// Object to marshal - /// Attributes for the return type for this , or null if no attributes should be added. - AttributeListSyntax? GenerateAttributesForReturnType(TypePositionInfo info); - } - - /// - /// Exception used to indicate marshalling isn't supported. - /// - internal class MarshallingNotSupportedException : Exception - { - /// - /// Construct a new instance. - /// - /// instance - /// instance - public MarshallingNotSupportedException(TypePositionInfo info, StubCodeContext context) - { - this.TypePositionInfo = info; - this.StubCodeContext = context; - } - - /// - /// Type that is being marshalled. - /// - public TypePositionInfo TypePositionInfo { get; private init; } - - /// - /// Context in which the marshalling is taking place. - /// - public StubCodeContext StubCodeContext { get; private init; } - - /// - /// [Optional] Specific reason marshalling of the supplied type isn't supported. - /// - public string? NotSupportedDetails { get; init; } - } - - internal class MarshallingGenerators - { - public static readonly ByteBoolMarshaller ByteBool = new ByteBoolMarshaller(); - public static readonly WinBoolMarshaller WinBool = new WinBoolMarshaller(); - public static readonly VariantBoolMarshaller VariantBool = new VariantBoolMarshaller(); - - public static readonly Utf16CharMarshaller Utf16Char = new Utf16CharMarshaller(); - public static readonly Utf16StringMarshaller Utf16String = new Utf16StringMarshaller(); - public static readonly Utf8StringMarshaller Utf8String = new Utf8StringMarshaller(); - public static readonly AnsiStringMarshaller AnsiString = new AnsiStringMarshaller(Utf8String); - public static readonly PlatformDefinedStringMarshaller PlatformDefinedString = new PlatformDefinedStringMarshaller(Utf16String, Utf8String); - - public static readonly Forwarder Forwarder = new Forwarder(); - public static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); - public static readonly DelegateMarshaller Delegate = new DelegateMarshaller(); - public static readonly HResultExceptionMarshaller HResultException = new HResultExceptionMarshaller(); - - /// - /// Create an instance for marshalling the supplied type in the given position. - /// - /// Type details - /// Metadata about the stub the type is associated with - /// A instance. - public static IMarshallingGenerator Create( - TypePositionInfo info, - StubCodeContext context, - AnalyzerConfigOptions options) - { - return ValidateByValueMarshalKind(context, info, CreateCore(info, context, options)); - } - - private static IMarshallingGenerator ValidateByValueMarshalKind(StubCodeContext context, TypePositionInfo info, IMarshallingGenerator generator) - { - if (info.IsByRef && info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.InOutAttributeByRefNotSupported - }; - } - else if (info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.In) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.InAttributeNotSupportedWithoutOut - }; - } - else if (info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default - && !generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, context)) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.InOutAttributeMarshalerNotSupported - }; - } - return generator; - } - - /// - /// Create an instance to marshalling the supplied type. - /// - /// Type details - /// Metadata about the stub the type is associated with - /// A instance. - private static IMarshallingGenerator CreateCore( - TypePositionInfo info, - StubCodeContext context, - AnalyzerConfigOptions options) - { - if (options.GenerateForwarders()) - { - return MarshallingGenerators.Forwarder; - } - - if (info.IsNativeReturnPosition && !info.IsManagedReturnPosition) - { - // Use marshaller for native HRESULT return / exception throwing - System.Diagnostics.Debug.Assert(info.ManagedType is SpecialTypeInfo { SpecialType: SpecialType.System_Int32 }); - return HResultException; - } - - switch (info) - { - // Blittable primitives with no marshalling info or with a compatible [MarshalAs] attribute. - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I1, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U1, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I2, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U2, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I4, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U4, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I8, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U8, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysInt, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysUInt, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } - or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: - return Blittable; - - // Enum with no marshalling info - case { ManagedType: EnumTypeInfo enumType, MarshallingAttributeInfo: NoMarshallingInfo }: - // Check that the underlying type is not bool or char. C# does not allow this, but ECMA-335 does. - var underlyingSpecialType = enumType.UnderlyingType; - if (underlyingSpecialType == SpecialType.System_Boolean || underlyingSpecialType == SpecialType.System_Char) - { - throw new MarshallingNotSupportedException(info, context); - } - return Blittable; - - // Pointer with no marshalling info - case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer:false), MarshallingAttributeInfo: NoMarshallingInfo }: - return Blittable; - - // Function pointer with no marshalling info - case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer: true), MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: - return Blittable; - - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: - return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: - return ByteBool; - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool, _) }: - return WinBool; - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: - return VariantBool; - - case { ManagedType: DelegateTypeInfo, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: - return Delegate; - - case { MarshallingAttributeInfo: SafeHandleMarshallingInfo(_, bool isAbstract) }: - if (!context.AdditionalTemporaryStateLivesAcrossStages) - { - throw new MarshallingNotSupportedException(info, context); - } - if (info.IsByRef && isAbstract) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.SafeHandleByRefMustBeConcrete - }; - } - return new SafeHandleMarshaller(options); - - // Marshalling in new model. - // Must go before the cases that do not explicitly check for marshalling info to support - // the user overridding the default marshalling rules with a MarshalUsing attribute. - case { MarshallingAttributeInfo: NativeMarshallingAttributeInfo marshalInfo }: - return CreateCustomNativeTypeMarshaller(info, context, marshalInfo, options); - - case { MarshallingAttributeInfo: BlittableTypeAttributeInfo }: - return Blittable; - - // Simple generated marshalling with new attribute model, only have type name. - case { MarshallingAttributeInfo: GeneratedNativeMarshallingAttributeInfo(string nativeTypeName) }: - return Forwarder; - - // Cases that just match on type must come after the checks that match only on marshalling attribute info. - // The checks below do not account for generic marshalling overrides like [MarshalUsing], so those checks must come first. - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Char } }: - return CreateCharMarshaller(info, context); - - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_String } }: - return CreateStringMarshaller(info, context); - - case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Void } }: - return Forwarder; - - default: - throw new MarshallingNotSupportedException(info, context); - } - } - - private static IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeContext context) - { - MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; - if (marshalInfo is NoMarshallingInfo) - { - // [Compat] Require explicit marshalling information. - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.MarshallingStringOrCharAsUndefinedNotSupported - }; - } - - // Explicit MarshalAs takes precedence over string encoding info - if (marshalInfo is MarshalAsInfo marshalAsInfo) - { - switch (marshalAsInfo.UnmanagedType) - { - case UnmanagedType.I2: - case UnmanagedType.U2: - return Utf16Char; - } - } - else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) - { - switch (marshalStringInfo.CharEncoding) - { - case CharEncoding.Utf16: - return Utf16Char; - case CharEncoding.Ansi: - throw new MarshallingNotSupportedException(info, context) // [Compat] ANSI is not supported for char - { - 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) - }; - } - } - - throw new MarshallingNotSupportedException(info, context); - } - - private static IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, StubCodeContext context) - { - MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; - if (marshalInfo is NoMarshallingInfo) - { - // [Compat] Require explicit marshalling information. - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.MarshallingStringOrCharAsUndefinedNotSupported - }; - } - - // Explicit MarshalAs takes precedence over string encoding info - if (marshalInfo is MarshalAsInfo marshalAsInfo) - { - switch (marshalAsInfo.UnmanagedType) - { - case UnmanagedType.LPStr: - return AnsiString; - case UnmanagedType.LPTStr: - case UnmanagedType.LPWStr: - return Utf16String; - case (UnmanagedType)0x30:// UnmanagedType.LPUTF8Str - return Utf8String; - } - } - else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) - { - switch (marshalStringInfo.CharEncoding) - { - case CharEncoding.Ansi: - return AnsiString; - case CharEncoding.Utf16: - return Utf16String; - case CharEncoding.Utf8: - return Utf8String; - case CharEncoding.PlatformDefined: - return PlatformDefinedString; - } - } - - throw new MarshallingNotSupportedException(info, context); - } - - private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, CountInfo count, StubCodeContext context) - { - return count switch - { - SizeAndParamIndexInfo(int size, SizeAndParamIndexInfo.UnspecifiedParam) => GetConstSizeExpression(size), - ConstSizeCountInfo(int size) => GetConstSizeExpression(size), - SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedConstSize, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(param)), - SizeAndParamIndexInfo(int size, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, GetConstSizeExpression(size), GetExpressionForParam(param))), - CountElementCountInfo(TypePositionInfo elementInfo) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(elementInfo)), - _ => throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.ArraySizeMustBeSpecified - }, - }; - - static LiteralExpressionSyntax GetConstSizeExpression(int size) - { - return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(size)); - } - - ExpressionSyntax GetExpressionForParam(TypePositionInfo paramInfo) - { - ExpressionSyntax numElementsExpression = GetIndexedNumElementsExpression( - context, - paramInfo, - out int numIndirectionLevels); - - ManagedTypeInfo type = paramInfo.ManagedType; - MarshallingInfo marshallingInfo = paramInfo.MarshallingAttributeInfo; - - for (int i = 0; i < numIndirectionLevels; i++) - { - if (marshallingInfo is NativeContiguousCollectionMarshallingInfo collectionInfo) - { - type = collectionInfo.ElementType; - marshallingInfo = collectionInfo.ElementMarshallingInfo; - } - else - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral - }; - } - } - - if (type is not SpecialTypeInfo specialType || !specialType.SpecialType.IsIntegralType()) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral - }; - } - - return CastExpression( - PredefinedType(Token(SyntaxKind.IntKeyword)), - ParenthesizedExpression(numElementsExpression)); - } - - static ExpressionSyntax GetIndexedNumElementsExpression(StubCodeContext context, TypePositionInfo numElementsInfo, out int numIndirectionLevels) - { - Stack indexerStack = new(); - - StubCodeContext? currentContext = context; - StubCodeContext lastContext = null!; - - while (currentContext is not null) - { - if (currentContext is ContiguousCollectionElementMarshallingCodeContext collectionContext) - { - indexerStack.Push(collectionContext.IndexerIdentifier); - } - lastContext = currentContext; - currentContext = currentContext.ParentContext; - } - - numIndirectionLevels = indexerStack.Count; - - ExpressionSyntax indexedNumElements = IdentifierName(lastContext.GetIdentifiers(numElementsInfo).managed); - while (indexerStack.Count > 0) - { - NameSyntax indexer = IdentifierName(indexerStack.Pop()); - indexedNumElements = ElementAccessExpression(indexedNumElements) - .AddArgumentListArguments(Argument(indexer)); - } - - return indexedNumElements; - } - } - - private static IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo, AnalyzerConfigOptions options) - { - ValidateCustomNativeTypeMarshallingSupported(info, context, marshalInfo); - - ICustomNativeTypeMarshallingStrategy marshallingStrategy = new SimpleCustomNativeTypeMarshalling(marshalInfo.NativeMarshallingType.Syntax); - - if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNativeStackalloc) != 0) - { - marshallingStrategy = new StackallocOptimizationMarshalling(marshallingStrategy); - } - - if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.FreeNativeResources) != 0) - { - marshallingStrategy = new FreeNativeCleanupStrategy(marshallingStrategy); - } - - // Collections have extra configuration, so handle them here. - if (marshalInfo is NativeContiguousCollectionMarshallingInfo collectionMarshallingInfo) - { - return CreateNativeCollectionMarshaller(info, context, collectionMarshallingInfo, options, marshallingStrategy); - } - - if (marshalInfo.ValuePropertyType is not null) - { - marshallingStrategy = DecorateWithValuePropertyStrategy(marshalInfo, marshallingStrategy); - } - - IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); - - if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedTypePinning) != 0) - { - return new PinnableManagedValueMarshaller(marshallingGenerator); - } - - return marshallingGenerator; - } - - private static void ValidateCustomNativeTypeMarshallingSupported(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) - { - // The marshalling method for this type doesn't support marshalling from native to managed, - // but our scenario requires marshalling from native to managed. - if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) - && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.NativeToManaged) == 0) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingNativeToManagedUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) - }; - } - // The marshalling method for this type doesn't support marshalling from managed to native by value, - // but our scenario requires marshalling from managed to native by value. - else if (!info.IsByRef - && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0 - && (context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingFeatures & (CustomMarshallingFeatures.ManagedTypePinning | CustomMarshallingFeatures.ManagedToNativeStackalloc)) == 0)) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) - }; - } - // The marshalling method for this type doesn't support marshalling from managed to native by reference, - // but our scenario requires marshalling from managed to native by reference. - // "in" byref supports stack marshalling. - else if (info.RefKind == RefKind.In - && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0 - && !(context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNativeStackalloc) != 0)) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) - }; - } - // The marshalling method for this type doesn't support marshalling from managed to native by reference, - // but our scenario requires marshalling from managed to native by reference. - // "ref" byref marshalling doesn't support stack marshalling - else if (info.RefKind == RefKind.Ref - && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0) - { - throw new MarshallingNotSupportedException(info, context) - { - NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) - }; - } - } - - private static ICustomNativeTypeMarshallingStrategy DecorateWithValuePropertyStrategy(NativeMarshallingAttributeInfo marshalInfo, ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller) - { - TypeSyntax valuePropertyTypeSyntax = marshalInfo.ValuePropertyType!.Syntax; - - if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.NativeTypePinning) != 0) - { - return new PinnableMarshallerTypeMarshalling(nativeTypeMarshaller, valuePropertyTypeSyntax); - } - - return new CustomNativeTypeWithValuePropertyMarshalling(nativeTypeMarshaller, valuePropertyTypeSyntax); - } - - private static IMarshallingGenerator CreateNativeCollectionMarshaller( - TypePositionInfo info, - StubCodeContext context, - NativeContiguousCollectionMarshallingInfo collectionInfo, - AnalyzerConfigOptions options, - ICustomNativeTypeMarshallingStrategy marshallingStrategy) - { - var elementInfo = new TypePositionInfo(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo) { ManagedIndex = info.ManagedIndex }; - var elementMarshaller = Create( - elementInfo, - new ContiguousCollectionElementMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context), - options); - var elementType = elementMarshaller.AsNativeType(elementInfo); - - bool isBlittable = elementMarshaller == Blittable; - - if (isBlittable) - { - marshallingStrategy = new ContiguousBlittableElementCollectionMarshalling(marshallingStrategy, collectionInfo.ElementType.Syntax); - } - else - { - marshallingStrategy = new ContiguousNonBlittableElementCollectionMarshalling(marshallingStrategy, elementMarshaller, elementInfo); - } - - // Explicitly insert the Value property handling here (before numElements handling) so that the numElements handling will be emitted before the Value property handling in unmarshalling. - if (collectionInfo.ValuePropertyType is not null) - { - marshallingStrategy = DecorateWithValuePropertyStrategy(collectionInfo, marshallingStrategy); - } - - ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); - if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) - { - // In this case, we need a numElementsExpression supplied from metadata, so we'll calculate it here. - numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, collectionInfo.ElementCountInfo, context); - } - - marshallingStrategy = new NumElementsExpressionMarshalling( - marshallingStrategy, - numElementsExpression, - SizeOfExpression(elementType)); - - if (collectionInfo.UseDefaultMarshalling && info.ManagedType is SzArrayType) - { - return new ArrayMarshaller( - new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: true), - elementType, - isBlittable, - options); - } - - IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); - - if ((collectionInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedTypePinning) != 0) - { - return new PinnableManagedValueMarshaller(marshallingGenerator); - } - - return marshallingGenerator; - } - } -} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs new file mode 100644 index 0000000000000..1e8ae0159e454 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs @@ -0,0 +1,30 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Interop +{ + class NoPreserveSigMarshallingGeneratorFactory : IMarshallingGeneratorFactory + { + private static readonly HResultExceptionMarshaller HResultException = new HResultExceptionMarshaller(); + private readonly IMarshallingGeneratorFactory inner; + + public NoPreserveSigMarshallingGeneratorFactory(IMarshallingGeneratorFactory inner) + { + this.inner = inner; + } + + public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) + { + if (info.IsNativeReturnPosition && !info.IsManagedReturnPosition) + { + // Use marshaller for native HRESULT return / exception throwing + System.Diagnostics.Debug.Assert(info.ManagedType.Equals(SpecialTypeInfo.Int32)); + return HResultException; + } + return inner.Create(info, context); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs similarity index 71% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs rename to src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs index 2732414adc42b..a7ecd31f8e453 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs @@ -7,13 +7,26 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; using static Microsoft.Interop.StubCodeContext; namespace Microsoft.Interop { - internal sealed class StubCodeGenerator : StubCodeContext + /// + /// Base code generator for generating the body of a source-generated P/Invoke and providing customization for how to invoke/define the native method. + /// + /// + /// This type enables multiple code generators for P/Invoke-style marshalling + /// to reuse the same basic method body, but with different designs of how to emit the target native method. + /// This enables users to write code generators that work with slightly different semantics. + /// For example, the source generator for [GeneratedDllImport] emits the target P/Invoke as + /// a local function inside the generated stub body. + /// However, other managed-to-native code generators using a P/Invoke style might want to define + /// the target DllImport outside of the stub as a static non-local function or as a function pointer field. + /// This refactoring allows the code generator to have control over where the target method is declared + /// and how it is declared. + /// + internal sealed class PInvokeStubCodeGenerator : StubCodeContext { private record struct BoundGenerator(TypePositionInfo TypeInfo, IMarshallingGenerator Generator); @@ -39,21 +52,19 @@ private record struct BoundGenerator(TypePositionInfo TypeInfo, IMarshallingGene // Error code representing success. This maps to S_OK for Windows HRESULT semantics and 0 for POSIX errno semantics. private const int SuccessErrorCode = 0; - private readonly AnalyzerConfigOptions options; - private readonly GeneratedDllImportData dllImportData; + private readonly bool setLastError; private readonly List paramMarshallers; private readonly BoundGenerator retMarshaller; private readonly List sortedMarshallers; private readonly bool stubReturnsVoid; - public StubCodeGenerator( - GeneratedDllImportData dllImportData, + public PInvokeStubCodeGenerator( IEnumerable argTypes, - AnalyzerConfigOptions options, - Action marshallingNotSupportedCallback) + bool setLastError, + Action marshallingNotSupportedCallback, + IMarshallingGeneratorFactory generatorFactory) { - this.dllImportData = dllImportData; - this.options = options; + this.setLastError = setLastError; List allMarshallers = new(); List paramMarshallers = new(); @@ -156,12 +167,12 @@ BoundGenerator CreateGenerator(TypePositionInfo p) { try { - return new BoundGenerator(p, MarshallingGenerators.Create(p, this, options)); + return new BoundGenerator(p, generatorFactory.Create(p, this)); } catch (MarshallingNotSupportedException e) { marshallingNotSupportedCallback(p, e); - return new BoundGenerator(p, MarshallingGenerators.Forwarder); + return new BoundGenerator(p, new Forwarder()); } } } @@ -196,9 +207,8 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo } } - public BlockSyntax GenerateBody(string methodName, AttributeListSyntax? forwardedAttributes) + public BlockSyntax GeneratePInvokeBody(string dllImportName) { - string dllImportName = methodName + "__PInvoke__"; var setupStatements = new List(); foreach (var marshaller in paramMarshallers) @@ -228,9 +238,6 @@ public BlockSyntax GenerateBody(string methodName, AttributeListSyntax? forwarde // Stub return is not the same as invoke return if (!stubReturnsVoid && !retMarshaller.TypeInfo.IsManagedReturnPosition) { - // Should only happen when PreserveSig=false - Debug.Assert(!dllImportData.PreserveSig, "Expected PreserveSig=false when invoke return is not the stub return"); - // Stub return should be the last parameter for the invoke Debug.Assert(paramMarshallers.Any() && paramMarshallers.Last().TypeInfo.IsManagedReturnPosition, "Expected stub return to be the last parameter for the invoke"); @@ -248,7 +255,7 @@ public BlockSyntax GenerateBody(string methodName, AttributeListSyntax? forwarde // Do not manually handle SetLastError when generating forwarders. // We want the runtime to handle everything. - if (this.dllImportData.SetLastError && !options.GenerateForwarders()) + if (this.setLastError) { // Declare variable for last error setupStatements.Add(MarshallerHelpers.DeclareWithDefault( @@ -294,7 +301,7 @@ public BlockSyntax GenerateBody(string methodName, AttributeListSyntax? forwarde allStatements.AddRange(tryStatements); } - if (this.dllImportData.SetLastError && !options.GenerateForwarders()) + if (this.setLastError) { // Marshal.SetLastPInvokeError(); allStatements.Add(ExpressionStatement( @@ -312,40 +319,7 @@ public BlockSyntax GenerateBody(string methodName, AttributeListSyntax? forwarde allStatements.Add(ReturnStatement(IdentifierName(ReturnIdentifier))); // Wrap all statements in an unsafe block - var codeBlock = Block(UnsafeStatement(Block(allStatements))); - - // Define P/Invoke declaration - var dllImport = LocalFunctionStatement(retMarshaller.Generator.AsNativeType(retMarshaller.TypeInfo), dllImportName) - .AddModifiers( - Token(SyntaxKind.ExternKeyword), - Token(SyntaxKind.StaticKeyword), - Token(SyntaxKind.UnsafeKeyword)) - .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) - .WithAttributeLists( - SingletonList(AttributeList( - SingletonSeparatedList(CreateDllImportAttributeForTarget(GetTargetDllImportDataFromStubData(methodName)))))); - - if (retMarshaller.Generator is IAttributedReturnTypeMarshallingGenerator retGenerator) - { - AttributeListSyntax? returnAttribute = retGenerator.GenerateAttributesForReturnType(retMarshaller.TypeInfo); - if (returnAttribute is not null) - { - dllImport = dllImport.AddAttributeLists(returnAttribute.WithTarget(AttributeTargetSpecifier(Identifier("return")))); - } - } - - if (forwardedAttributes is not null) - { - dllImport = dllImport.AddAttributeLists(forwardedAttributes); - } - - foreach (var marshaller in paramMarshallers) - { - ParameterSyntax paramSyntax = marshaller.Generator.AsParameter(marshaller.TypeInfo); - dllImport = dllImport.AddParameterListParameters(paramSyntax); - } - - return codeBlock.AddStatements(dllImport); + return Block(UnsafeStatement(Block(allStatements))); void GenerateStatementsForStage(Stage stage, List statementsToUpdate) { @@ -435,7 +409,7 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc // Do not manually handle SetLastError when generating forwarders. // We want the runtime to handle everything. - if (this.dllImportData.SetLastError && !options.GenerateForwarders()) + if (setLastError) { // Marshal.SetLastSystemError(0); var clearLastError = ExpressionStatement( @@ -482,6 +456,19 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc } } + public (ParameterListSyntax ParameterList, TypeSyntax ReturnType, AttributeListSyntax? ReturnTypeAttributes) GenerateTargetMethodSignatureData() + { + return ( + ParameterList( + SeparatedList( + paramMarshallers.Select(marshaler => marshaler.Generator.AsParameter(marshaler.TypeInfo)))), + retMarshaller.Generator.AsNativeType(retMarshaller.TypeInfo), + retMarshaller.Generator is IAttributedReturnTypeMarshallingGenerator attributedReturn + ? attributedReturn.GenerateAttributesForReturnType(retMarshaller.TypeInfo) + : null + ); + } + private void AppendVariableDeclations(List statementsToUpdate, TypePositionInfo info, IMarshallingGenerator generator) { var (managed, native) = this.GetIdentifiers(info); @@ -502,123 +489,5 @@ private void AppendVariableDeclations(List statementsToUpdate, native)); } } - - private static AttributeSyntax CreateDllImportAttributeForTarget(GeneratedDllImportData targetDllImportData) - { - Debug.Assert(targetDllImportData.EntryPoint is not null); - var newAttributeArgs = new List - { - AttributeArgument(LiteralExpression( - SyntaxKind.StringLiteralExpression, - Literal(targetDllImportData.ModuleName))), - AttributeArgument( - NameEquals(nameof(DllImportAttribute.EntryPoint)), - null, - CreateStringExpressionSyntax(targetDllImportData.EntryPoint!)) - }; - - if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.BestFitMapping)) - { - var name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); - var value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CallingConvention)) - { - var name = NameEquals(nameof(DllImportAttribute.CallingConvention)); - var value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet)) - { - var name = NameEquals(nameof(DllImportAttribute.CharSet)); - var value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ExactSpelling)) - { - var name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); - var value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.PreserveSig)) - { - var name = NameEquals(nameof(DllImportAttribute.PreserveSig)); - var value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.SetLastError)) - { - var name = NameEquals(nameof(DllImportAttribute.SetLastError)); - var value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ThrowOnUnmappableChar)) - { - var name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); - var value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); - newAttributeArgs.Add(AttributeArgument(name, null, value)); - } - - // Create new attribute - return Attribute( - ParseName(typeof(DllImportAttribute).FullName), - AttributeArgumentList(SeparatedList(newAttributeArgs))); - - static ExpressionSyntax CreateBoolExpressionSyntax(bool trueOrFalse) - { - return LiteralExpression( - trueOrFalse - ? SyntaxKind.TrueLiteralExpression - : SyntaxKind.FalseLiteralExpression); - } - - static ExpressionSyntax CreateStringExpressionSyntax(string str) - { - return LiteralExpression( - SyntaxKind.StringLiteralExpression, - Literal(str)); - } - - static ExpressionSyntax CreateEnumExpressionSyntax(T value) where T : Enum - { - return MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(typeof(T).FullName), - IdentifierName(value.ToString())); - } - } - - GeneratedDllImportData GetTargetDllImportDataFromStubData(string methodName) - { - DllImportMember membersToForward = DllImportMember.All - // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig - // If PreserveSig=false (default is true), the P/Invoke stub checks/converts a returned HRESULT to an exception. - & ~DllImportMember.PreserveSig - // 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; - if (options.GenerateForwarders()) - { - membersToForward = DllImportMember.All; - } - - var targetDllImportData = dllImportData with - { - IsUserDefined = dllImportData.IsUserDefined & membersToForward - }; - - // If the EntryPoint property is not set, we will compute and - // add it based on existing semantics (i.e. method name). - // - // N.B. The export discovery logic is identical regardless of where - // the name is defined (i.e. method name vs EntryPoint property). - if (!targetDllImportData.IsUserDefined.HasFlag(DllImportMember.EntryPoint)) - { - targetDllImportData = targetDllImportData with { EntryPoint = methodName }; - } - - return targetDllImportData; - } } } 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 d43d6c82b3bd9..eb6bfa6e52e08 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.Interop { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -60,15 +60,6 @@ internal Resources() { } } - /// - /// Looks up a localized string similar to Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute' or the 'ConstantElementCount' or 'CountElementName' properties to be set on a 'MarshalUsingAttribute'.. - /// - internal static string ArraySizeMustBeSpecified { - get { - return ResourceManager.GetString("ArraySizeMustBeSpecified", resourceCulture); - } - } - /// /// Looks up a localized string similar to A type marked with 'BlittableTypeAttribute' must be blittable.. /// @@ -123,15 +114,6 @@ internal static string CollectionNativeTypeMustHaveRequiredShapeMessage { } } - /// - /// Looks up a localized string similar to The specified collection size parameter for an collection must be an integer type. If the size information is applied to a nested collection, the size parameter must be a collection of one less level of nesting with an integral element.. - /// - internal static string CollectionSizeParamTypeMustBeIntegral { - get { - return ResourceManager.GetString("CollectionSizeParamTypeMustBeIntegral", resourceCulture); - } - } - /// /// Looks up a localized string similar to Source-generated P/Invokes will ignore any configuration that is not supported.. /// @@ -151,7 +133,7 @@ internal static string ConfigurationNotSupportedMessage { } /// - /// Looks up a localized string similar to The specified marshalling configuration is not supported by source-generated P/Invokes. {0}. + /// Looks up a localized string similar to The specified marshalling configuration is not supported by source-generated P/Invokes. {0}.. /// internal static string ConfigurationNotSupportedMessageMarshallingInfo { get { @@ -276,42 +258,6 @@ internal static string CustomTypeMarshallingNativeToManagedUnsupported { } } - /// - /// Looks up a localized string similar to This element cannot depend on '{0}' for collection size information without creating a dependency cycle. - /// - internal static string CyclicalCountInfo { - get { - return ResourceManager.GetString("CyclicalCountInfo", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Count information for a given element at a given indirection level can only be specified once. - /// - internal static string DuplicateCountInfo { - get { - return ResourceManager.GetString("DuplicateCountInfo", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Multiple marshalling attributes per element per indirection level is unsupported, but duplicate information was provided for indirection level {0}. - /// - internal static string DuplicateMarshallingInfo { - get { - return ResourceManager.GetString("DuplicateMarshallingInfo", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Marshalling info was specified for 'ElementIndirectionLevel' {0}, but marshalling info was only needed for {1} levels of indirection. - /// - internal static string ExtraneousMarshallingInfo { - get { - return ResourceManager.GetString("ExtraneousMarshallingInfo", resourceCulture); - } - } - /// /// Looks up a localized string similar to Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types.. /// @@ -403,56 +349,11 @@ internal static string GetPinnableReferenceShouldSupportAllocatingMarshallingFal } /// - /// Looks up a localized string similar to The provided graph has cycles and cannot be topologically sorted.. - /// - internal static string GraphHasCycles { - get { - return ResourceManager.GetString("GraphHasCycles", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior.. - /// - internal static string InAttributeNotSupportedWithoutOut { - get { - return ResourceManager.GetString("InAttributeNotSupportedWithoutOut", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.. - /// - internal static string InOutAttributeByRefNotSupported { - get { - return ResourceManager.GetString("InOutAttributeByRefNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter.. + /// Looks up a localized string similar to The native type '{0}' must be a closed generic so the emitted code can use a specific instantiation.. /// - internal static string InOutAttributeMarshalerNotSupported { + internal static string NativeGenericTypeMustBeClosedDescription { get { - return ResourceManager.GetString("InOutAttributeMarshalerNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. - /// - internal static string MarshallingCharAsSpecifiedCharSetNotSupported { - get { - return ResourceManager.GetString("MarshallingCharAsSpecifiedCharSetNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'.. - /// - internal static string MarshallingStringOrCharAsUndefinedNotSupported { - get { - return ResourceManager.GetString("MarshallingStringOrCharAsUndefinedNotSupported", resourceCulture); + return ResourceManager.GetString("NativeGenericTypeMustBeClosedDescription", resourceCulture); } } @@ -546,24 +447,6 @@ internal static string NativeTypeMustHaveRequiredShapeMessage { } } - /// - /// Looks up a localized string similar to The '[Out]' attribute is only supported on array parameters.. - /// - internal static string OutByValueNotSupportedDescription { - get { - return ResourceManager.GetString("OutByValueNotSupportedDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The '[Out]' attribute is not supported on the '{0}' parameter.. - /// - internal static string OutByValueNotSupportedMessage { - get { - return ResourceManager.GetString("OutByValueNotSupportedMessage", resourceCulture); - } - } - /// /// Looks up a localized string similar to The 'Value' property must not be a 'ref' or 'readonly ref' property.. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx index d2d2adeffc2c1..3124872bc3175 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Resources.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute' or the 'ConstantElementCount' or 'CountElementName' properties to be set on a 'MarshalUsingAttribute'. - A type marked with 'BlittableTypeAttribute' must be blittable. @@ -132,8 +129,11 @@ Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes. - - The specified collection size parameter for an collection must be an integer type. If the size information is applied to a nested collection, the size parameter must be a collection of one less level of nesting with an integral element. + + A native type with the 'GenericContiguousCollectionMarshallerAttribute' must have at least one of the two marshalling methods as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' to enable marshalling the managed type. + + + The native type '{0}' must be a value type and have a constructor that takes two parameters, one of type '{1}' and an 'int', or have a parameterless instance method named 'ToManaged' that returns '{1}' as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' Source-generated P/Invokes will ignore any configuration that is not supported. @@ -184,18 +184,6 @@ The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it. - - This element cannot depend on '{0}' for collection size information without creating a dependency cycle - - - Count information for a given element at a given indirection level can only be specified once - - - Multiple marshalling attributes per element per indirection level is unsupported, but duplicate information was provided for indirection level {0} - - - Marshalling info was specified for 'ElementIndirectionLevel' {0}, but marshalling info was only needed for {1} level(s) of indirection - Types that contain methods marked with 'GeneratedDllImportAttribute' must be 'partial'. P/Invoke source generation will ignore methods contained within non-partial types. @@ -226,23 +214,8 @@ Type '{0}' has a 'GetPinnableReference' method but its native type does not support marshalling in scenarios where pinning is impossible - - The provided graph has cycles and cannot be topologically sorted. - - - The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior. - - - The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead. - - - The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter. - - - Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. - - - Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'. + + The native type '{0}' must be a closed generic so the emitted code can use a specific instantiation. The native type '{0}' must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation. @@ -274,18 +247,6 @@ The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}' - - A native type with the 'GenericContiguousCollectionMarshallerAttribute' must have at least one of the two marshalling methods as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' to enable marshalling the managed type. - - - The native type '{0}' must be a value type and have a constructor that takes two parameters, one of type '{1}' and an 'int', or have a parameterless instance method named 'ToManaged' that returns '{1}' as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' - - - The '[Out]' attribute is only supported on array parameters. - - - The '[Out]' attribute is not supported on the '{0}' parameter. - The 'Value' property must not be a 'ref' or 'readonly ref' property. @@ -352,4 +313,4 @@ The 'Value' property on the native type '{0}' must have a setter - + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs index 678040e4e6b78..32dc72b3bce32 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs @@ -2,11 +2,14 @@ using System.Collections.Generic; using System.Text; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.Interop; namespace Microsoft.Interop { static class TypeNames { + public const string DllImportAttribute = "System.Runtime.InteropServices.DllImportAttribute"; + public const string GeneratedDllImportAttribute = "System.Runtime.InteropServices.GeneratedDllImportAttribute"; public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute"; @@ -28,8 +31,6 @@ static class TypeNames public const string System_Span_Metadata = "System.Span`1"; public const string System_Span = "System.Span"; - public const string System_Activator = "System.Activator"; - public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; @@ -38,25 +39,10 @@ static class TypeNames public const string System_Runtime_InteropServices_Marshal = "System.Runtime.InteropServices.Marshal"; - private const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; - - public static string MarshalEx(AnalyzerConfigOptions options) - { - return options.UseMarshalType() ? System_Runtime_InteropServices_Marshal : System_Runtime_InteropServices_MarshalEx; - } - public const string System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.ArrayMarshaller`1"; public const string System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.PtrArrayMarshaller`1"; - public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal"; - - public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; - - public const string System_Runtime_InteropServices_OutAttribute = "System.Runtime.InteropServices.OutAttribute"; - - public const string System_Runtime_InteropServices_InAttribute = "System.Runtime.InteropServices.InAttribute"; - public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; private const string System_Runtime_CompilerServices_Unsafe = "System.Runtime.CompilerServices.Unsafe"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ContiguousCollectionElementMarshallingCodeContext.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs new file mode 100644 index 0000000000000..f02f7c28957ec --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Microsoft.Interop +{ + public static class DiagnosticExtensions + { + public static Diagnostic CreateDiagnostic( + this ISymbol symbol, + DiagnosticDescriptor descriptor, + params object[] args) + { + return symbol.Locations.CreateDiagnostic(descriptor, args); + } + + public static Diagnostic CreateDiagnostic( + this AttributeData attributeData, + DiagnosticDescriptor descriptor, + params object[] args) + { + SyntaxReference? syntaxReference = attributeData.ApplicationSyntaxReference; + Location location = syntaxReference is not null + ? syntaxReference.GetSyntax().GetLocation() + : Location.None; + + return location.CreateDiagnostic(descriptor, args); + } + + public static Diagnostic CreateDiagnostic( + this ImmutableArray locations, + DiagnosticDescriptor descriptor, + params object[] args) + { + IEnumerable locationsInSource = locations.Where(l => l.IsInSource); + if (!locationsInSource.Any()) + return Diagnostic.Create(descriptor, Location.None, args); + + return Diagnostic.Create( + descriptor, + location: locationsInSource.First(), + additionalLocations: locationsInSource.Skip(1), + messageArgs: args); + } + + public static Diagnostic CreateDiagnostic( + this Location location, + DiagnosticDescriptor descriptor, + params object[] args) + { + return Diagnostic.Create( + descriptor, + location: location.IsInSource ? location : Location.None, + messageArgs: args); + } + } + + + public interface IGeneratorDiagnostics + { + /// + /// Report diagnostic for marshalling of a parameter/return that is not supported + /// + /// Method with the parameter/return + /// Type info for the parameter/return + /// [Optional] Specific reason for lack of support + void ReportMarshallingNotSupported( + MethodDeclarationSyntax method, + TypePositionInfo info, + string? notSupportedDetails); + + /// + /// Report diagnostic for configuration that is not supported by the DLL import source generator + /// + /// Attribute specifying the unsupported configuration + /// Name of the configuration + /// [Optiona] Unsupported configuration value + void ReportConfigurationNotSupported( + AttributeData attributeData, + string configurationName, + string? unsupportedValue); + + void ReportInvalidMarshallingAttributeInfo( + AttributeData attributeData, + string reasonResourceName, + params string[] reasonArgs); + } + + public static class IGeneratorDiagnosticsExtensions + { + public static void ReportConfigurationNotSupported(this IGeneratorDiagnostics diagnostics, AttributeData attributeData, string configurationName) + => diagnostics.ReportConfigurationNotSupported(attributeData, configurationName, null); + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs new file mode 100644 index 0000000000000..fa4e46a3f3d31 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Interop +{ + public record InteropGenerationOptions(bool UseMarshalType, bool UseInternalUnsafeType); +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs new file mode 100644 index 0000000000000..ddf2c4203111c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs @@ -0,0 +1,10 @@ +// Types defined to enable language support of various features +// in the source generator. + + +namespace System.Runtime.CompilerServices +{ + // Define IsExternalInit type to support records. + internal class IsExternalInit + {} +} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManagedTypeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs similarity index 68% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManagedTypeInfo.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs index 9e2bd6f70d8a4..fe789e2e08865 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManagedTypeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs @@ -10,7 +10,7 @@ namespace Microsoft.Interop /// /// A discriminated union that contains enough info about a managed type to determine a marshalling generator and generate code. /// - internal abstract record ManagedTypeInfo(string FullTypeName, string DiagnosticFormattedName) + public abstract record ManagedTypeInfo(string FullTypeName, string DiagnosticFormattedName) { public TypeSyntax Syntax { get; } = SyntaxFactory.ParseTypeName(FullTypeName); @@ -46,7 +46,7 @@ public static ManagedTypeInfo CreateTypeInfoForTypeSymbol(ITypeSymbol type) } } - internal sealed record SpecialTypeInfo(string FullTypeName, string DiagnosticFormattedName, SpecialType SpecialType) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName) + public sealed record SpecialTypeInfo(string FullTypeName, string DiagnosticFormattedName, SpecialType SpecialType) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName) { public static readonly SpecialTypeInfo Int32 = new("int", "int", SpecialType.System_Int32); public static readonly SpecialTypeInfo Void = new("void", "void", SpecialType.System_Void); @@ -62,13 +62,13 @@ public override int GetHashCode() } } - internal sealed record EnumTypeInfo(string FullTypeName, string DiagnosticFormattedName, SpecialType UnderlyingType) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); + public sealed record EnumTypeInfo(string FullTypeName, string DiagnosticFormattedName, SpecialType UnderlyingType) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); - internal sealed record PointerTypeInfo(string FullTypeName, string DiagnosticFormattedName, bool IsFunctionPointer) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); + public sealed record PointerTypeInfo(string FullTypeName, string DiagnosticFormattedName, bool IsFunctionPointer) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); - internal sealed record SzArrayType(ManagedTypeInfo ElementTypeInfo) : ManagedTypeInfo($"{ElementTypeInfo.FullTypeName}[]", $"{ElementTypeInfo.DiagnosticFormattedName}[]"); + public sealed record SzArrayType(ManagedTypeInfo ElementTypeInfo) : ManagedTypeInfo($"{ElementTypeInfo.FullTypeName}[]", $"{ElementTypeInfo.DiagnosticFormattedName}[]"); - internal sealed record DelegateTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); + public sealed record DelegateTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); - internal sealed record SimpleManagedTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); + public sealed record SimpleManagedTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs index 1d073064a39de..137f45f1040d5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs @@ -5,7 +5,7 @@ namespace Microsoft.Interop { - static class ManualTypeMarshallingHelper + public static class ManualTypeMarshallingHelper { public const string ValuePropertyName = "Value"; public const string GetPinnableReferenceName = "GetPinnableReference"; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs similarity index 96% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs index 46af295b524b9..53fc3655af912 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs @@ -6,14 +6,14 @@ namespace Microsoft.Interop { - internal sealed class ArrayMarshaller : IMarshallingGenerator + public sealed class ArrayMarshaller : IMarshallingGenerator { private readonly IMarshallingGenerator manualMarshallingGenerator; private readonly TypeSyntax elementType; private readonly bool enablePinning; - private readonly AnalyzerConfigOptions options; + private readonly InteropGenerationOptions options; - public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning, AnalyzerConfigOptions options) + public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning, InteropGenerationOptions options) { this.manualMarshallingGenerator = manualMarshallingGenerator; this.elementType = elementType; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs new file mode 100644 index 0000000000000..1346356eee12f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs @@ -0,0 +1,292 @@ +using Microsoft.CodeAnalysis.CSharp; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Microsoft.Interop +{ + public class AttributedMarshallingModelGeneratorFactory : IMarshallingGeneratorFactory + { + private static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); + private static readonly Forwarder Forwarder = new Forwarder(); + + private readonly IMarshallingGeneratorFactory innerMarshallingGenerator; + + public AttributedMarshallingModelGeneratorFactory(IMarshallingGeneratorFactory innerMarshallingGenerator, InteropGenerationOptions options) + { + Options = options; + this.innerMarshallingGenerator = innerMarshallingGenerator; + ElementMarshallingGeneratorFactory = this; + } + + public InteropGenerationOptions Options { get; } + + /// + /// The to use for collection elements. + /// This property is settable to enable decorating factories to ensure that element marshalling also goes through the decorator support. + /// + public IMarshallingGeneratorFactory ElementMarshallingGeneratorFactory { get; set; } + + public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) + { + return info.MarshallingAttributeInfo switch + { + NativeMarshallingAttributeInfo marshalInfo => CreateCustomNativeTypeMarshaller(info, context, marshalInfo), + BlittableTypeAttributeInfo => Blittable, + GeneratedNativeMarshallingAttributeInfo => Forwarder, + _ => innerMarshallingGenerator.Create(info, context) + }; + } + + private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, CountInfo count, StubCodeContext context) + { + return count switch + { + SizeAndParamIndexInfo(int size, SizeAndParamIndexInfo.UnspecifiedParam) => GetConstSizeExpression(size), + ConstSizeCountInfo(int size) => GetConstSizeExpression(size), + SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedConstSize, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(param)), + SizeAndParamIndexInfo(int size, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, GetConstSizeExpression(size), GetExpressionForParam(param))), + CountElementCountInfo(TypePositionInfo elementInfo) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(elementInfo)), + _ => throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.ArraySizeMustBeSpecified + }, + }; + + static LiteralExpressionSyntax GetConstSizeExpression(int size) + { + return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(size)); + } + + ExpressionSyntax GetExpressionForParam(TypePositionInfo paramInfo) + { + ExpressionSyntax numElementsExpression = GetIndexedNumElementsExpression( + context, + paramInfo, + out int numIndirectionLevels); + + ManagedTypeInfo type = paramInfo.ManagedType; + MarshallingInfo marshallingInfo = paramInfo.MarshallingAttributeInfo; + + for (int i = 0; i < numIndirectionLevels; i++) + { + if (marshallingInfo is NativeContiguousCollectionMarshallingInfo collectionInfo) + { + type = collectionInfo.ElementType; + marshallingInfo = collectionInfo.ElementMarshallingInfo; + } + else + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral + }; + } + } + + if (type is not SpecialTypeInfo specialType || !specialType.SpecialType.IsIntegralType()) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.CollectionSizeParamTypeMustBeIntegral + }; + } + + return CastExpression( + PredefinedType(Token(SyntaxKind.IntKeyword)), + ParenthesizedExpression(numElementsExpression)); + } + + static ExpressionSyntax GetIndexedNumElementsExpression(StubCodeContext context, TypePositionInfo numElementsInfo, out int numIndirectionLevels) + { + Stack indexerStack = new(); + + StubCodeContext? currentContext = context; + StubCodeContext lastContext = null!; + + while (currentContext is not null) + { + if (currentContext is ContiguousCollectionElementMarshallingCodeContext collectionContext) + { + indexerStack.Push(collectionContext.IndexerIdentifier); + } + lastContext = currentContext; + currentContext = currentContext.ParentContext; + } + + numIndirectionLevels = indexerStack.Count; + + ExpressionSyntax indexedNumElements = IdentifierName(lastContext.GetIdentifiers(numElementsInfo).managed); + while (indexerStack.Count > 0) + { + NameSyntax indexer = IdentifierName(indexerStack.Pop()); + indexedNumElements = ElementAccessExpression(indexedNumElements) + .AddArgumentListArguments(Argument(indexer)); + } + + return indexedNumElements; + } + } + + private IMarshallingGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) + { + ValidateCustomNativeTypeMarshallingSupported(info, context, marshalInfo); + + ICustomNativeTypeMarshallingStrategy marshallingStrategy = new SimpleCustomNativeTypeMarshalling(marshalInfo.NativeMarshallingType.Syntax); + + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNativeStackalloc) != 0) + { + marshallingStrategy = new StackallocOptimizationMarshalling(marshallingStrategy); + } + + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.FreeNativeResources) != 0) + { + marshallingStrategy = new FreeNativeCleanupStrategy(marshallingStrategy); + } + + // Collections have extra configuration, so handle them here. + if (marshalInfo is NativeContiguousCollectionMarshallingInfo collectionMarshallingInfo) + { + return CreateNativeCollectionMarshaller(info, context, collectionMarshallingInfo, marshallingStrategy); + } + + if (marshalInfo.ValuePropertyType is not null) + { + marshallingStrategy = DecorateWithValuePropertyStrategy(marshalInfo, marshallingStrategy); + } + + IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); + + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedTypePinning) != 0) + { + return new PinnableManagedValueMarshaller(marshallingGenerator); + } + + return marshallingGenerator; + } + + private void ValidateCustomNativeTypeMarshallingSupported(TypePositionInfo info, StubCodeContext context, NativeMarshallingAttributeInfo marshalInfo) + { + // The marshalling method for this type doesn't support marshalling from native to managed, + // but our scenario requires marshalling from native to managed. + if ((info.RefKind == RefKind.Ref || info.RefKind == RefKind.Out || info.IsManagedReturnPosition) + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.NativeToManaged) == 0) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingNativeToManagedUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) + }; + } + // The marshalling method for this type doesn't support marshalling from managed to native by value, + // but our scenario requires marshalling from managed to native by value. + else if (!info.IsByRef + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0 + && (context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingFeatures & (CustomMarshallingFeatures.ManagedTypePinning | CustomMarshallingFeatures.ManagedToNativeStackalloc)) == 0)) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) + }; + } + // The marshalling method for this type doesn't support marshalling from managed to native by reference, + // but our scenario requires marshalling from managed to native by reference. + // "in" byref supports stack marshalling. + else if (info.RefKind == RefKind.In + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0 + && !(context.SingleFrameSpansNativeContext && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNativeStackalloc) != 0)) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) + }; + } + // The marshalling method for this type doesn't support marshalling from managed to native by reference, + // but our scenario requires marshalling from managed to native by reference. + // "ref" byref marshalling doesn't support stack marshalling + else if (info.RefKind == RefKind.Ref + && (marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedToNative) == 0) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = string.Format(Resources.CustomTypeMarshallingManagedToNativeUnsupported, marshalInfo.NativeMarshallingType.FullTypeName) + }; + } + } + + private ICustomNativeTypeMarshallingStrategy DecorateWithValuePropertyStrategy(NativeMarshallingAttributeInfo marshalInfo, ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller) + { + TypeSyntax valuePropertyTypeSyntax = marshalInfo.ValuePropertyType!.Syntax; + + if ((marshalInfo.MarshallingFeatures & CustomMarshallingFeatures.NativeTypePinning) != 0) + { + return new PinnableMarshallerTypeMarshalling(nativeTypeMarshaller, valuePropertyTypeSyntax); + } + + return new CustomNativeTypeWithValuePropertyMarshalling(nativeTypeMarshaller, valuePropertyTypeSyntax); + } + + private IMarshallingGenerator CreateNativeCollectionMarshaller( + TypePositionInfo info, + StubCodeContext context, + NativeContiguousCollectionMarshallingInfo collectionInfo, + ICustomNativeTypeMarshallingStrategy marshallingStrategy) + { + var elementInfo = new TypePositionInfo(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo) { ManagedIndex = info.ManagedIndex }; + var elementMarshaller = Create( + elementInfo, + new ContiguousCollectionElementMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context)); + var elementType = elementMarshaller.AsNativeType(elementInfo); + + bool isBlittable = elementMarshaller is BlittableMarshaller; + + if (isBlittable) + { + marshallingStrategy = new ContiguousBlittableElementCollectionMarshalling(marshallingStrategy, collectionInfo.ElementType.Syntax); + } + else + { + marshallingStrategy = new ContiguousNonBlittableElementCollectionMarshalling(marshallingStrategy, elementMarshaller, elementInfo); + } + + // Explicitly insert the Value property handling here (before numElements handling) so that the numElements handling will be emitted before the Value property handling in unmarshalling. + if (collectionInfo.ValuePropertyType is not null) + { + marshallingStrategy = DecorateWithValuePropertyStrategy(collectionInfo, marshallingStrategy); + } + + ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); + if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) + { + // In this case, we need a numElementsExpression supplied from metadata, so we'll calculate it here. + numElementsExpression = GetNumElementsExpressionFromMarshallingInfo(info, collectionInfo.ElementCountInfo, context); + } + + marshallingStrategy = new NumElementsExpressionMarshalling( + marshallingStrategy, + numElementsExpression, + SizeOfExpression(elementType)); + + if (collectionInfo.UseDefaultMarshalling && info.ManagedType is SzArrayType) + { + return new ArrayMarshaller( + new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: true), + elementType, + isBlittable, + Options); + } + + IMarshallingGenerator marshallingGenerator = new CustomNativeTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); + + if ((collectionInfo.MarshallingFeatures & CustomMarshallingFeatures.ManagedTypePinning) != 0) + { + return new PinnableManagedValueMarshaller(marshallingGenerator); + } + + return marshallingGenerator; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs index 15fa7774a996f..8925ffc625553 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs @@ -7,7 +7,7 @@ namespace Microsoft.Interop { - internal class BlittableMarshaller : IMarshallingGenerator + public sealed class BlittableMarshaller : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs similarity index 95% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs index 2b5af8d2a5cd8..7ceab5830c0df 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs @@ -8,7 +8,7 @@ namespace Microsoft.Interop { - internal abstract class BoolMarshallerBase : IMarshallingGenerator + public abstract class BoolMarshallerBase : IMarshallingGenerator { private readonly PredefinedTypeSyntax _nativeType; private readonly int _trueValue; @@ -114,7 +114,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont /// and C++, but those is implementation defined. /// Consult your compiler specification. /// - internal class ByteBoolMarshaller : BoolMarshallerBase + public sealed class ByteBoolMarshaller : BoolMarshallerBase { public ByteBoolMarshaller() : base(PredefinedType(Token(SyntaxKind.ByteKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false) @@ -128,7 +128,7 @@ public ByteBoolMarshaller() /// /// Corresponds to the definition of BOOL. /// - internal class WinBoolMarshaller : BoolMarshallerBase + public sealed class WinBoolMarshaller : BoolMarshallerBase { public WinBoolMarshaller() : base(PredefinedType(Token(SyntaxKind.IntKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false) @@ -139,7 +139,7 @@ public WinBoolMarshaller() /// /// Marshal a boolean value as a VARIANT_BOOL (Windows OLE/Automation type). /// - internal class VariantBoolMarshaller : BoolMarshallerBase + public sealed class VariantBoolMarshaller : BoolMarshallerBase { private const short VARIANT_TRUE = -1; private const short VARIANT_FALSE = 0; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs new file mode 100644 index 0000000000000..dc9f64fde908f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Interop +{ + /// + /// An implementation that wraps an inner instance and validates that the on the provided is valid in the current marshalling scenario. + /// + public class ByValueContentsMarshalKindValidator : IMarshallingGeneratorFactory + { + private readonly IMarshallingGeneratorFactory inner; + + public ByValueContentsMarshalKindValidator(IMarshallingGeneratorFactory inner) + { + this.inner = inner; + } + + public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) + { + return ValidateByValueMarshalKind(info, context, inner.Create(info, context)); + } + + private static IMarshallingGenerator ValidateByValueMarshalKind(TypePositionInfo info, StubCodeContext context, IMarshallingGenerator generator) + { + if (info.IsByRef && info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.InOutAttributeByRefNotSupported + }; + } + else if (info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.In) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.InAttributeNotSupportedWithoutOut + }; + } + else if (info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default + && !generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, context)) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.InOutAttributeMarshalerNotSupported + }; + } + return generator; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs similarity index 97% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index d04a78c2460ae..ce3c97230ada2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -9,7 +9,7 @@ namespace Microsoft.Interop { - internal class Utf16CharMarshaller : IMarshallingGenerator + public sealed class Utf16CharMarshaller : IMarshallingGenerator { private static readonly PredefinedTypeSyntax NativeType = PredefinedType(Token(SyntaxKind.UShortKeyword)); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs index 2994ec8df75c6..c2c0788b196fe 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -6,7 +6,7 @@ namespace Microsoft.Interop { - internal abstract class ConditionalStackallocMarshallingGenerator : IMarshallingGenerator + public abstract class ConditionalStackallocMarshallingGenerator : IMarshallingGenerator { protected static string GetAllocationMarkerIdentifier(TypePositionInfo info, StubCodeContext context) => context.GetAdditionalIdentifier(info, "allocated"); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/CustomNativeTypeMarshallingGenerator.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs index b5aca0f44207f..c8854abb54bd5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs @@ -6,7 +6,7 @@ namespace Microsoft.Interop { - internal class DelegateMarshaller : IMarshallingGenerator + public sealed class DelegateMarshaller : IMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs index e86c422ec4828..1f8f1c1756f21 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs @@ -8,7 +8,7 @@ namespace Microsoft.Interop { - internal class Forwarder : IMarshallingGenerator, IAttributedReturnTypeMarshallingGenerator + public sealed class Forwarder : IMarshallingGenerator, IAttributedReturnTypeMarshallingGenerator { public TypeSyntax AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs similarity index 96% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs index 09ce81431e6a9..349a651a9d5bc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/HResultExceptionMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs @@ -9,7 +9,7 @@ namespace Microsoft.Interop { - internal sealed class HResultExceptionMarshaller : IMarshallingGenerator + public sealed class HResultExceptionMarshaller : IMarshallingGenerator { private static readonly TypeSyntax NativeType = PredefinedType(Token(SyntaxKind.IntKeyword)); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/ICustomNativeTypeMarshallingStrategy.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index 256fc939ec7b7..f3ee0df3ea33a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -7,7 +7,7 @@ namespace Microsoft.Interop { - internal static class MarshallerHelpers + public static class MarshallerHelpers { public static readonly ExpressionSyntax IsWindows = InvocationExpression( MemberAccessExpression( diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs new file mode 100644 index 0000000000000..e97191550f183 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Microsoft.Interop +{ + /// + /// Interface for generation of marshalling code for P/Invoke stubs + /// + public interface IMarshallingGenerator + { + /// + /// Get the native type syntax for + /// + /// Object to marshal + /// Type syntax for the native type representing + TypeSyntax AsNativeType(TypePositionInfo info); + + /// + /// Get the as a parameter of the P/Invoke declaration + /// + /// Object to marshal + /// Parameter syntax for + ParameterSyntax AsParameter(TypePositionInfo info); + + /// + /// Get the as an argument to be passed to the P/Invoke + /// + /// Object to marshal + /// Code generation context + /// Argument syntax for + ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context); + + /// + /// Generate code for marshalling + /// + /// Object to marshal + /// Code generation context + /// List of statements to be added to the P/Invoke stub + /// + /// The generator should return the appropriate statements based on the + /// of . + /// For , any statements not of type + /// will be ignored. + /// + IEnumerable Generate(TypePositionInfo info, StubCodeContext context); + + /// + /// Returns whether or not this marshaller uses an identifier for the native value in addition + /// to an identifer for the managed value. + /// + /// Object to marshal + /// Code generation context + /// If the marshaller uses an identifier for the native value, true; otherwise, false. + /// + /// of may not be valid. + /// + bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context); + + /// + /// Returns if the given ByValueContentsMarshalKind is supported in the current marshalling context. + /// A supported marshal kind has a different behavior than the default behavior. + /// + /// The marshal kind. + /// The marshalling context. + /// + bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); + } + + /// + /// Interface for generating attributes for native return types. + /// + public interface IAttributedReturnTypeMarshallingGenerator : IMarshallingGenerator + { + /// + /// Gets any attributes that should be applied to the return type for this . + /// + /// Object to marshal + /// Attributes for the return type for this , or null if no attributes should be added. + AttributeListSyntax? GenerateAttributesForReturnType(TypePositionInfo info); + } + + + /// + /// Exception used to indicate marshalling isn't supported. + /// + public sealed class MarshallingNotSupportedException : Exception + { + /// + /// Construct a new instance. + /// + /// instance + /// instance + public MarshallingNotSupportedException(TypePositionInfo info, StubCodeContext context) + { + this.TypePositionInfo = info; + this.StubCodeContext = context; + } + + /// + /// Type that is being marshalled. + /// + public TypePositionInfo TypePositionInfo { get; private init; } + + /// + /// Context in which the marshalling is taking place. + /// + public StubCodeContext StubCodeContext { get; private init; } + + /// + /// [Optional] Specific reason marshalling of the supplied type isn't supported. + /// + public string? NotSupportedDetails { get; init; } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs new file mode 100644 index 0000000000000..1efa6e495e576 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs @@ -0,0 +1,221 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop +{ + public interface IMarshallingGeneratorFactory + { + /// + /// Create an instance for marshalling the supplied type in the given position. + /// + /// Type details + /// Metadata about the stub the type is associated with + /// A instance. + public IMarshallingGenerator Create( + TypePositionInfo info, + StubCodeContext context); + } + + public sealed class DefaultMarshallingGeneratorFactory : IMarshallingGeneratorFactory + { + private static readonly ByteBoolMarshaller ByteBool = new(); + private static readonly WinBoolMarshaller WinBool = new(); + private static readonly VariantBoolMarshaller VariantBool = new(); + + private static readonly Utf16CharMarshaller Utf16Char = new(); + private static readonly Utf16StringMarshaller Utf16String = new(); + private static readonly Utf8StringMarshaller Utf8String = new(); + private static readonly AnsiStringMarshaller AnsiString = new AnsiStringMarshaller(Utf8String); + private static readonly PlatformDefinedStringMarshaller PlatformDefinedString = new PlatformDefinedStringMarshaller(Utf16String, Utf8String); + + private static readonly Forwarder Forwarder = new(); + private static readonly BlittableMarshaller Blittable = new(); + private static readonly DelegateMarshaller Delegate = new(); + private static readonly SafeHandleMarshaller SafeHandle = new(); + private InteropGenerationOptions Options { get; } + + public DefaultMarshallingGeneratorFactory(InteropGenerationOptions options) + { + this.Options = options; + } + + /// + /// Create an instance for marshalling the supplied type in the given position. + /// + /// Type details + /// Metadata about the stub the type is associated with + /// A instance. + public IMarshallingGenerator Create( + TypePositionInfo info, + StubCodeContext context) + { + switch (info) + { + // Blittable primitives with no marshalling info or with a compatible [MarshalAs] attribute. + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_SByte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I1, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Byte }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U1, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I2, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt16 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U2, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I4, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt32 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U4, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Int64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.I8, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UInt64 }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.U8, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_IntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysInt, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysUInt, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } + or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: + return Blittable; + + // Enum with no marshalling info + case { ManagedType: EnumTypeInfo enumType, MarshallingAttributeInfo: NoMarshallingInfo }: + // Check that the underlying type is not bool or char. C# does not allow this, but ECMA-335 does. + var underlyingSpecialType = enumType.UnderlyingType; + if (underlyingSpecialType == SpecialType.System_Boolean || underlyingSpecialType == SpecialType.System_Char) + { + throw new MarshallingNotSupportedException(info, context); + } + return Blittable; + + // Pointer with no marshalling info + case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer: false), MarshallingAttributeInfo: NoMarshallingInfo }: + return Blittable; + + // Function pointer with no marshalling info + case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer: true), MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: + return Blittable; + + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: + return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: + return ByteBool; + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool, _) }: + return WinBool; + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: + return VariantBool; + + case { ManagedType: DelegateTypeInfo, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: + return Delegate; + + case { MarshallingAttributeInfo: SafeHandleMarshallingInfo(_, bool isAbstract) }: + if (!context.AdditionalTemporaryStateLivesAcrossStages) + { + throw new MarshallingNotSupportedException(info, context); + } + if (info.IsByRef && isAbstract) + { + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.SafeHandleByRefMustBeConcrete + }; + } + return new SafeHandleMarshaller(); + + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Char } }: + return CreateCharMarshaller(info, context); + + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_String } }: + return CreateStringMarshaller(info, context); + + case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Void } }: + return Forwarder; + + default: + throw new MarshallingNotSupportedException(info, context); + } + } + + private IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeContext context) + { + MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + if (marshalInfo is NoMarshallingInfo) + { + // [Compat] Require explicit marshalling information. + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.MarshallingStringOrCharAsUndefinedNotSupported + }; + } + + // Explicit MarshalAs takes precedence over string encoding info + if (marshalInfo is MarshalAsInfo marshalAsInfo) + { + switch (marshalAsInfo.UnmanagedType) + { + case UnmanagedType.I2: + case UnmanagedType.U2: + return Utf16Char; + } + } + else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) + { + switch (marshalStringInfo.CharEncoding) + { + case CharEncoding.Utf16: + return Utf16Char; + case CharEncoding.Ansi: + throw new MarshallingNotSupportedException(info, context) // [Compat] ANSI is not supported for char + { + 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) + }; + } + } + + throw new MarshallingNotSupportedException(info, context); + } + + private IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, StubCodeContext context) + { + MarshallingInfo marshalInfo = info.MarshallingAttributeInfo; + if (marshalInfo is NoMarshallingInfo) + { + // [Compat] Require explicit marshalling information. + throw new MarshallingNotSupportedException(info, context) + { + NotSupportedDetails = Resources.MarshallingStringOrCharAsUndefinedNotSupported + }; + } + + // Explicit MarshalAs takes precedence over string encoding info + if (marshalInfo is MarshalAsInfo marshalAsInfo) + { + switch (marshalAsInfo.UnmanagedType) + { + case UnmanagedType.LPStr: + return AnsiString; + case UnmanagedType.LPTStr: + case UnmanagedType.LPWStr: + return Utf16String; + case (UnmanagedType)0x30:// UnmanagedType.LPUTF8Str + return Utf8String; + } + } + else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) + { + switch (marshalStringInfo.CharEncoding) + { + case CharEncoding.Ansi: + return AnsiString; + case CharEncoding.Utf16: + return Utf16String; + case CharEncoding.Utf8: + return Utf8String; + case CharEncoding.PlatformDefined: + return PlatformDefinedString; + } + } + + throw new MarshallingNotSupportedException(info, context); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs similarity index 97% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs index e14cfbf25b274..d8e26f8d63348 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/PinnableManagedValueMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs @@ -5,7 +5,7 @@ namespace Microsoft.Interop { - internal sealed class PinnableManagedValueMarshaller : IMarshallingGenerator + public sealed class PinnableManagedValueMarshaller : IMarshallingGenerator { private readonly IMarshallingGenerator manualMarshallingGenerator; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs index e3b32f94a5c6c..262de1be2d9bc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs @@ -8,15 +8,8 @@ namespace Microsoft.Interop { - internal class SafeHandleMarshaller : IMarshallingGenerator + public sealed class SafeHandleMarshaller : IMarshallingGenerator { - private readonly AnalyzerConfigOptions options; - - public SafeHandleMarshaller(AnalyzerConfigOptions options) - { - this.options = options; - } - public TypeSyntax AsNativeType(TypePositionInfo info) { return MarshallerHelpers.SystemIntPtrType; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs index a63ecd4ab7f81..97dd9328c8755 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs @@ -9,7 +9,7 @@ namespace Microsoft.Interop { - internal sealed class AnsiStringMarshaller : ConditionalStackallocMarshallingGenerator + public sealed class AnsiStringMarshaller : ConditionalStackallocMarshallingGenerator { private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs index a9b665f88b094..3de4c48a724bb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.PlatformDefined.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs @@ -10,7 +10,7 @@ namespace Microsoft.Interop { - internal sealed class PlatformDefinedStringMarshaller : ConditionalStackallocMarshallingGenerator + public sealed class PlatformDefinedStringMarshaller : ConditionalStackallocMarshallingGenerator { private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs index 9ae9bb48c454b..a1ceb12d0adf3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs @@ -8,7 +8,7 @@ namespace Microsoft.Interop { - internal sealed class Utf16StringMarshaller : ConditionalStackallocMarshallingGenerator + public sealed class Utf16StringMarshaller : ConditionalStackallocMarshallingGenerator { // [Compat] Equivalent of MAX_PATH on Windows to match built-in system // The assumption is file paths are the most common case for marshalling strings, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs index a4c52bffa9a2f..2a4801e8d3c3b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs @@ -8,7 +8,7 @@ namespace Microsoft.Interop { - internal sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator + public sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator { // [Compat] Equivalent of MAX_PATH on Windows to match built-in system // The assumption is file paths are the most common case for marshalling strings, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs similarity index 96% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs index 96988216005cc..bbc2d7789145c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs @@ -12,7 +12,7 @@ namespace Microsoft.Interop /// /// Type used to pass on default marshalling details. /// - internal sealed record DefaultMarshallingInfo( + public sealed record DefaultMarshallingInfo( CharEncoding CharEncoding ); @@ -20,11 +20,15 @@ CharEncoding CharEncoding // for C# vNext discriminated unions. Once discriminated unions are released, // these should be updated to be implemented as a discriminated union. - internal abstract record MarshallingInfo + public abstract record MarshallingInfo { + // Add a constructor that can only be called by derived types in the same assembly + // to enforce that this type cannot be extended by users of this library. + private protected MarshallingInfo() + {} } - internal sealed record NoMarshallingInfo : MarshallingInfo + public sealed record NoMarshallingInfo : MarshallingInfo { public static readonly MarshallingInfo Instance = new NoMarshallingInfo(); @@ -34,7 +38,7 @@ private NoMarshallingInfo() { } /// /// Character encoding enumeration. /// - internal enum CharEncoding + public enum CharEncoding { Undefined, Utf8, @@ -46,14 +50,14 @@ internal enum CharEncoding /// /// Details that are required when scenario supports strings. /// - internal record MarshallingInfoStringSupport( + public record MarshallingInfoStringSupport( CharEncoding CharEncoding ) : MarshallingInfo; /// /// Simple User-application of System.Runtime.InteropServices.MarshalAsAttribute /// - internal sealed record MarshalAsInfo( + public sealed record MarshalAsInfo( UnmanagedType UnmanagedType, CharEncoding CharEncoding) : MarshallingInfoStringSupport(CharEncoding) { @@ -64,10 +68,10 @@ internal sealed record MarshalAsInfo( /// or System.Runtime.InteropServices.GeneratedMarshallingAttribute on a blittable type /// in source in this compilation. /// - internal sealed record BlittableTypeAttributeInfo : MarshallingInfo; + public sealed record BlittableTypeAttributeInfo : MarshallingInfo; [Flags] - internal enum CustomMarshallingFeatures + public enum CustomMarshallingFeatures { None = 0, ManagedToNative = 0x1, @@ -78,23 +82,26 @@ internal enum CustomMarshallingFeatures FreeNativeResources = 0x20, } - internal abstract record CountInfo; + public abstract record CountInfo + { + private protected CountInfo() {} + } - internal sealed record NoCountInfo : CountInfo + public sealed record NoCountInfo : CountInfo { public static readonly NoCountInfo Instance = new NoCountInfo(); private NoCountInfo() { } } - internal sealed record ConstSizeCountInfo(int Size) : CountInfo; + public sealed record ConstSizeCountInfo(int Size) : CountInfo; - internal sealed record CountElementCountInfo(TypePositionInfo ElementInfo) : CountInfo + public sealed record CountElementCountInfo(TypePositionInfo ElementInfo) : CountInfo { public const string ReturnValueElementName = "return-value"; } - internal sealed record SizeAndParamIndexInfo(int ConstSize, TypePositionInfo? ParamAtIndex) : CountInfo + public sealed record SizeAndParamIndexInfo(int ConstSize, TypePositionInfo? ParamAtIndex) : CountInfo { public const int UnspecifiedConstSize = -1; @@ -106,7 +113,7 @@ internal sealed record SizeAndParamIndexInfo(int ConstSize, TypePositionInfo? Pa /// /// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute /// - internal record NativeMarshallingAttributeInfo( + public record NativeMarshallingAttributeInfo( ManagedTypeInfo NativeMarshallingType, ManagedTypeInfo? ValuePropertyType, CustomMarshallingFeatures MarshallingFeatures, @@ -116,18 +123,18 @@ internal record NativeMarshallingAttributeInfo( /// User-applied System.Runtime.InteropServices.GeneratedMarshallingAttribute /// on a non-blittable type in source in this compilation. /// - internal sealed record GeneratedNativeMarshallingAttributeInfo( + public sealed record GeneratedNativeMarshallingAttributeInfo( string NativeMarshallingFullyQualifiedTypeName) : MarshallingInfo; /// /// The type of the element is a SafeHandle-derived type with no marshalling attributes. /// - internal sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor, bool IsAbstract) : MarshallingInfo; + public sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor, bool IsAbstract) : MarshallingInfo; /// /// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute /// with a contiguous collection marshaller - internal sealed record NativeContiguousCollectionMarshallingInfo( + public sealed record NativeContiguousCollectionMarshallingInfo( ManagedTypeInfo NativeMarshallingType, ManagedTypeInfo? ValuePropertyType, CustomMarshallingFeatures MarshallingFeatures, @@ -141,10 +148,10 @@ internal sealed record NativeContiguousCollectionMarshallingInfo( UseDefaultMarshalling ); - internal class MarshallingAttributeInfoParser + public sealed class MarshallingAttributeInfoParser { private readonly Compilation _compilation; - private readonly GeneratorDiagnostics _diagnostics; + private readonly IGeneratorDiagnostics _diagnostics; private readonly DefaultMarshallingInfo _defaultInfo; private readonly ISymbol _contextSymbol; private readonly ITypeSymbol _marshalAsAttribute; @@ -152,7 +159,7 @@ internal class MarshallingAttributeInfoParser public MarshallingAttributeInfoParser( Compilation compilation, - GeneratorDiagnostics diagnostics, + IGeneratorDiagnostics diagnostics, DefaultMarshallingInfo defaultInfo, ISymbol contextSymbol) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj new file mode 100644 index 0000000000000..8317b0a45f8ed --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj @@ -0,0 +1,30 @@ + + + + netstandard2.0 + false + enable + Microsoft.Interop + + + + + + + + + + Resources.resx + True + True + + + + + + Designer + Resources.Designer.cs + ResXFileCodeGenerator + + + diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.Designer.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.Designer.cs new file mode 100644 index 0000000000000..1d254e29a5c23 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.Designer.cs @@ -0,0 +1,369 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Interop { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Interop.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute' or the 'ConstantElementCount' or 'CountElementName' properties to be set on a 'MarshalUsingAttribute'.. + /// + internal static string ArraySizeMustBeSpecified { + get { + return ResourceManager.GetString("ArraySizeMustBeSpecified", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range.. + /// + internal static string ArraySizeParamIndexOutOfRange { + get { + return ResourceManager.GetString("ArraySizeParamIndexOutOfRange", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive.. + /// + internal static string CannotHaveMultipleMarshallingAttributesDescription { + get { + return ResourceManager.GetString("CannotHaveMultipleMarshallingAttributesDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes.. + /// + internal static string CannotHaveMultipleMarshallingAttributesMessage { + get { + return ResourceManager.GetString("CannotHaveMultipleMarshallingAttributesMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A native type with the 'GenericContiguousCollectionMarshallerAttribute' must have at least one of the two marshalling methods as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' to enable marshalling the managed type.. + /// + internal static string CollectionNativeTypeMustHaveRequiredShapeDescription { + get { + return ResourceManager.GetString("CollectionNativeTypeMustHaveRequiredShapeDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' must be a value type and have a constructor that takes two parameters, one of type '{1}' and an 'int', or have a parameterless instance method named 'ToManaged' that returns '{1}' as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>'. + /// + internal static string CollectionNativeTypeMustHaveRequiredShapeMessage { + get { + return ResourceManager.GetString("CollectionNativeTypeMustHaveRequiredShapeMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified collection size parameter for an collection must be an integer type. If the size information is applied to a nested collection, the size parameter must be a collection of one less level of nesting with an integral element.. + /// + internal static string CollectionSizeParamTypeMustBeIntegral { + get { + return ResourceManager.GetString("CollectionSizeParamTypeMustBeIntegral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Only one of 'ConstantElementCount' or 'ElementCountInfo' may be used in a 'MarshalUsingAttribute' for a given 'ElementIndirectionLevel'. + /// + internal static string ConstantAndElementCountInfoDisallowed { + get { + return ResourceManager.GetString("ConstantAndElementCountInfoDisallowed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it.. + /// + internal static string CustomTypeMarshallingManagedToNativeUnsupported { + get { + return ResourceManager.GetString("CustomTypeMarshallingManagedToNativeUnsupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it.. + /// + internal static string CustomTypeMarshallingNativeToManagedUnsupported { + get { + return ResourceManager.GetString("CustomTypeMarshallingNativeToManagedUnsupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This element cannot depend on '{0}' for collection size information without creating a dependency cycle. + /// + internal static string CyclicalCountInfo { + get { + return ResourceManager.GetString("CyclicalCountInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Count information for a given element at a given indirection level can only be specified once. + /// + internal static string DuplicateCountInfo { + get { + return ResourceManager.GetString("DuplicateCountInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Multiple marshalling attributes per element per indirection level is unsupported, but duplicate information was provided for indirection level {0}. + /// + internal static string DuplicateMarshallingInfo { + get { + return ResourceManager.GetString("DuplicateMarshallingInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Marshalling info was specified for 'ElementIndirectionLevel' {0}, but marshalling info was only needed for {1} level(s) of indirection. + /// + internal static string ExtraneousMarshallingInfo { + get { + return ResourceManager.GetString("ExtraneousMarshallingInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The provided graph has cycles and cannot be topologically sorted.. + /// + internal static string GraphHasCycles { + get { + return ResourceManager.GetString("GraphHasCycles", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior.. + /// + internal static string InAttributeNotSupportedWithoutOut { + get { + return ResourceManager.GetString("InAttributeNotSupportedWithoutOut", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.. + /// + internal static string InOutAttributeByRefNotSupported { + get { + return ResourceManager.GetString("InOutAttributeByRefNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter.. + /// + internal static string InOutAttributeMarshalerNotSupported { + get { + return ResourceManager.GetString("InOutAttributeMarshalerNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke.. + /// + internal static string MarshallingCharAsSpecifiedCharSetNotSupported { + get { + return ResourceManager.GetString("MarshallingCharAsSpecifiedCharSetNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'.. + /// + internal static string MarshallingStringOrCharAsUndefinedNotSupported { + get { + return ResourceManager.GetString("MarshallingStringOrCharAsUndefinedNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' for managed type '{1}' must be a closed generic type or have the same arity as the managed type.. + /// + internal static string NativeGenericTypeMustBeClosedOrMatchArityMessage { + get { + return ResourceManager.GetString("NativeGenericTypeMustBeClosedOrMatchArityMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type must have at least one of the two marshalling methods to enable marshalling the managed type.. + /// + internal static string NativeTypeMustHaveRequiredShapeDescription { + get { + return ResourceManager.GetString("NativeTypeMustHaveRequiredShapeDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}'. + /// + internal static string NativeTypeMustHaveRequiredShapeMessage { + get { + return ResourceManager.GetString("NativeTypeMustHaveRequiredShapeMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '[Out]' attribute is only supported on array parameters.. + /// + internal static string OutByValueNotSupportedDescription { + get { + return ResourceManager.GetString("OutByValueNotSupportedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '[Out]' attribute is not supported on the '{0}' parameter.. + /// + internal static string OutByValueNotSupportedMessage { + get { + return ResourceManager.GetString("OutByValueNotSupportedMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'Value' property must not be a 'ref' or 'readonly ref' property.. + /// + internal static string RefValuePropertyUnsupportedDescription { + get { + return ResourceManager.GetString("RefValuePropertyUnsupportedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must not be a 'ref' or 'readonly ref' property.. + /// + internal static string RefValuePropertyUnsupportedMessage { + get { + return ResourceManager.GetString("RefValuePropertyUnsupportedMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to An abstract type derived from 'SafeHandle' cannot be marshalled by reference. The provided type must be concrete.. + /// + internal static string SafeHandleByRefMustBeConcrete { + get { + return ResourceManager.GetString("SafeHandleByRefMustBeConcrete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specified type is not supported by source-generated P/Invokes. + /// + internal static string TypeNotSupportedTitle { + get { + return ResourceManager.GetString("TypeNotSupportedTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Marshalling a value between managed and native with a native type with a 'Value' property requires extra state, which is not supported in this context.. + /// + internal static string ValuePropertyMarshallingRequiresAdditionalState { + get { + return ResourceManager.GetString("ValuePropertyMarshallingRequiresAdditionalState", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type's 'Value' property must have a getter to support marshalling from managed to native.. + /// + internal static string ValuePropertyMustHaveGetterDescription { + get { + return ResourceManager.GetString("ValuePropertyMustHaveGetterDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a getter. + /// + internal static string ValuePropertyMustHaveGetterMessage { + get { + return ResourceManager.GetString("ValuePropertyMustHaveGetterMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The native type's 'Value' property must have a setter to support marshalling from native to managed.. + /// + internal static string ValuePropertyMustHaveSetterDescription { + get { + return ResourceManager.GetString("ValuePropertyMustHaveSetterDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The 'Value' property on the native type '{0}' must have a setter. + /// + internal static string ValuePropertyMustHaveSetterMessage { + get { + return ResourceManager.GetString("ValuePropertyMustHaveSetterMessage", resourceCulture); + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.resx b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.resx new file mode 100644 index 0000000000000..544a1ea46a212 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources.resx @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Marshalling an array from unmanaged to managed requires either the 'SizeParamIndex' or 'SizeConst' fields to be set on a 'MarshalAsAttribute' or the 'ConstantElementCount' or 'CountElementName' properties to be set on a 'MarshalUsingAttribute'. + + + The 'SizeParamIndex' value in the 'MarshalAsAttribute' is out of range. + + + The 'BlittableTypeAttribute' and 'NativeMarshallingAttribute' attributes are mutually exclusive. + + + Type '{0}' is marked with 'BlittableTypeAttribute' and 'NativeMarshallingAttribute'. A type can only have one of these two attributes. + + + The specified collection size parameter for an collection must be an integer type. If the size information is applied to a nested collection, the size parameter must be a collection of one less level of nesting with an integral element. + + + The specified parameter needs to be marshalled from managed to native, but the native type '{0}' does not support it. + + + The specified parameter needs to be marshalled from native to managed, but the native type '{0}' does not support it. + + + The provided graph has cycles and cannot be topologically sorted. + + + The '[In]' attribute is not supported unless the '[Out]' attribute is also used. The behavior of the '[In]' attribute without the '[Out]' attribute is the same as the default behavior. + + + The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead. + + + The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter. + + + Marshalling char with 'CharSet.{0}' is not supported. Instead, manually convert the char type to the desired byte representation and pass to the source-generated P/Invoke. + + + Marshalling string or char without explicit marshalling information is not supported. Specify either 'GeneratedDllImportAttribute.CharSet' or 'MarshalAsAttribute'. + + + The '[Out]' attribute is only supported on array parameters. + + + The '[Out]' attribute is not supported on the '{0}' parameter. + + + The 'Value' property must not be a 'ref' or 'readonly ref' property. + + + The 'Value' property on the native type '{0}' must not be a 'ref' or 'readonly ref' property. + + + An abstract type derived from 'SafeHandle' cannot be marshalled by reference. The provided type must be concrete. + + + Specified type is not supported by source-generated P/Invokes + + + Marshalling a value between managed and native with a native type with a 'Value' property requires extra state, which is not supported in this context. + + + The native type's 'Value' property must have a getter to support marshalling from managed to native. + + + The 'Value' property on the native type '{0}' must have a getter + + + The native type's 'Value' property must have a setter to support marshalling from native to managed. + + + The 'Value' property on the native type '{0}' must have a setter + + + This element cannot depend on '{0}' for collection size information without creating a dependency cycle + + + Count information for a given element at a given indirection level can only be specified once + + + Multiple marshalling attributes per element per indirection level is unsupported, but duplicate information was provided for indirection level {0} + + + Marshalling info was specified for 'ElementIndirectionLevel' {0}, but marshalling info was only needed for {1} level(s) of indirection + + + The native type '{0}' for managed type '{1}' must be a closed generic type or have the same arity as the managed type. + + + The native type must have at least one of the two marshalling methods to enable marshalling the managed type. + + + The native type '{0}' must be a value type and have a constructor that takes one parameter of type '{1}' or a parameterless instance method named 'ToManaged' that returns '{1}' + + + A native type with the 'GenericContiguousCollectionMarshallerAttribute' must have at least one of the two marshalling methods as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' to enable marshalling the managed type. + + + The native type '{0}' must be a value type and have a constructor that takes two parameters, one of type '{1}' and an 'int', or have a parameterless instance method named 'ToManaged' that returns '{1}' as well as a 'ManagedValues' property of type 'Span<T>' for some 'T' and a 'NativeValueStorage' property of type 'Span<byte>' + + + Only one of 'ConstantElementCount' or 'ElementCountInfo' may be used in a 'MarshalUsingAttribute' for a given 'ElementIndirectionLevel' + + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs index 1fcacdb07a720..ab414c504269c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs @@ -3,7 +3,7 @@ namespace Microsoft.Interop { - internal abstract class StubCodeContext + public abstract class StubCodeContext { /// /// Code generation stage 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 new file mode 100644 index 0000000000000..a0bb19753fa4f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.Interop; + +namespace Microsoft.Interop +{ + static class TypeNames + { + public const string GeneratedDllImportAttribute = "System.Runtime.InteropServices.GeneratedDllImportAttribute"; + + public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute"; + + public const string BlittableTypeAttribute = "System.Runtime.InteropServices.BlittableTypeAttribute"; + + public const string NativeMarshallingAttribute = "System.Runtime.InteropServices.NativeMarshallingAttribute"; + + public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute"; + + public const string GenericContiguousCollectionMarshallerAttribute = "System.Runtime.InteropServices.GenericContiguousCollectionMarshallerAttribute"; + + public const string LCIDConversionAttribute = "System.Runtime.InteropServices.LCIDConversionAttribute"; + + public const string System_Span_Metadata = "System.Span`1"; + public const string System_Span = "System.Span"; + + public const string System_Activator = "System.Activator"; + + public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; + + public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; + + public const string System_Runtime_InteropServices_Marshal = "System.Runtime.InteropServices.Marshal"; + + private const string System_Runtime_InteropServices_MarshalEx = "System.Runtime.InteropServices.MarshalEx"; + + public static string MarshalEx(InteropGenerationOptions options) + { + return options.UseMarshalType ? System_Runtime_InteropServices_Marshal : System_Runtime_InteropServices_MarshalEx; + } + + public const string System_Runtime_InteropServices_UnmanagedType = "System.Runtime.InteropServices.UnmanagedType"; + + public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal"; + + public const string System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.ArrayMarshaller`1"; + + public const string System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.PtrArrayMarshaller`1"; + + public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle"; + + public const string System_Runtime_InteropServices_OutAttribute = "System.Runtime.InteropServices.OutAttribute"; + + public const string System_Runtime_InteropServices_InAttribute = "System.Runtime.InteropServices.InAttribute"; + + public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; + + private const string System_Runtime_CompilerServices_Unsafe = "System.Runtime.CompilerServices.Unsafe"; + + private const string Internal_Runtime_CompilerServices_Unsafe = "Internal.Runtime.CompilerServices.Unsafe"; + + public static string Unsafe(InteropGenerationOptions options) + { + return options.UseInternalUnsafeType ? Internal_Runtime_CompilerServices_Unsafe : System_Runtime_CompilerServices_Unsafe; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs similarity index 96% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs index 2cbbcb87beccb..a7d730d08b081 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs @@ -15,7 +15,7 @@ namespace Microsoft.Interop /// contents of the managed array. /// [Flags] - internal enum ByValueContentsMarshalKind + public enum ByValueContentsMarshalKind { /// /// Marshal contents from managed to native only. @@ -40,7 +40,7 @@ internal enum ByValueContentsMarshalKind /// /// Positional type information involved in unmanaged/managed scenarios. /// - internal sealed record TypePositionInfo(ManagedTypeInfo ManagedType, MarshallingInfo MarshallingAttributeInfo) + public sealed record TypePositionInfo(ManagedTypeInfo ManagedType, MarshallingInfo MarshallingAttributeInfo) { public const int UnsetIndex = int.MinValue; public const int ReturnIndex = UnsetIndex + 1; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs similarity index 99% rename from src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs index e9b3b8261a95f..8587c0780acc1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs @@ -11,7 +11,7 @@ namespace Microsoft.Interop { - static class TypeSymbolExtensions + public static class TypeSymbolExtensions { public static bool HasOnlyBlittableFields(this ITypeSymbol type) => HasOnlyBlittableFields(type, ImmutableHashSet.Create(SymbolEqualityComparer.Default)); 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 e19d9b4e5d9bf..b04f4ba3c0894 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 @@ -6,6 +6,7 @@ System.Runtime.InteropServices enable true + APIs required for usage of the DllImportGenerator and related tools. diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 4588c962fc817..ecd9ee7adf636 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -18,6 +18,7 @@ + diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 11805179e79d0..1ffe230ada81c 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -16,6 +16,7 @@ + From 7eea82a46081c1be24a5c9e3cb8b3b3727c9d0d8 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 10 Sep 2021 17:31:31 -0700 Subject: [PATCH 141/161] Remove duplicate TypeNames.cs and create IntPtr constant. (dotnet/runtimelab#1550) Commit migrated from https://github.com/dotnet/runtimelab/commit/fb867cdfb646a4eecddb3eb91baa4709811872b5 --- .../gen/DllImportGenerator/TypeNames.cs | 59 ------------------- .../Marshalling/MarshallerHelpers.cs | 2 +- .../Marshalling/StringMarshaller.Utf16.cs | 2 +- .../Marshalling/StringMarshaller.Utf8.cs | 4 +- .../TypeNames.cs | 10 +++- 5 files changed, 13 insertions(+), 64 deletions(-) delete mode 100644 src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs deleted file mode 100644 index 32dc72b3bce32..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/TypeNames.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.Interop; - -namespace Microsoft.Interop -{ - static class TypeNames - { - public const string DllImportAttribute = "System.Runtime.InteropServices.DllImportAttribute"; - - public const string GeneratedDllImportAttribute = "System.Runtime.InteropServices.GeneratedDllImportAttribute"; - - public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute"; - - public const string BlittableTypeAttribute = "System.Runtime.InteropServices.BlittableTypeAttribute"; - - public const string NativeMarshallingAttribute = "System.Runtime.InteropServices.NativeMarshallingAttribute"; - - public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute"; - - public const string GenericContiguousCollectionMarshallerAttribute = "System.Runtime.InteropServices.GenericContiguousCollectionMarshallerAttribute"; - - public const string LCIDConversionAttribute = "System.Runtime.InteropServices.LCIDConversionAttribute"; - - public const string SuppressGCTransitionAttribute = "System.Runtime.InteropServices.SuppressGCTransitionAttribute"; - - public const string UnmanagedCallConvAttribute = "System.Runtime.InteropServices.UnmanagedCallConvAttribute"; - - public const string System_Span_Metadata = "System.Span`1"; - public const string System_Span = "System.Span"; - - public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; - - public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; - - public const string System_Runtime_InteropServices_UnmanagedType = "System.Runtime.InteropServices.UnmanagedType"; - - public const string System_Runtime_InteropServices_Marshal = "System.Runtime.InteropServices.Marshal"; - - public const string System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.ArrayMarshaller`1"; - - public const string System_Runtime_InteropServices_GeneratedMarshalling_PtrArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.PtrArrayMarshaller`1"; - - public const string System_Runtime_CompilerServices_SkipLocalsInitAttribute = "System.Runtime.CompilerServices.SkipLocalsInitAttribute"; - - private const string System_Runtime_CompilerServices_Unsafe = "System.Runtime.CompilerServices.Unsafe"; - - private const string Internal_Runtime_CompilerServices_Unsafe = "Internal.Runtime.CompilerServices.Unsafe"; - - public static string Unsafe(AnalyzerConfigOptions options) - { - return options.UseInternalUnsafeType() ? Internal_Runtime_CompilerServices_Unsafe : System_Runtime_CompilerServices_Unsafe; - } - - public const string System_Type = "System.Type"; - } -} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index f3ee0df3ea33a..b35e3c4816714 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -17,7 +17,7 @@ public static class MarshallerHelpers public static readonly TypeSyntax InteropServicesMarshalType = ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal); - public static readonly TypeSyntax SystemIntPtrType = ParseTypeName("System.IntPtr"); + public static readonly TypeSyntax SystemIntPtrType = ParseTypeName(TypeNames.System_IntPtr); public static ForStatementSyntax GetForLoop(string collectionIdentifier, string indexerIdentifier) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs index a1ceb12d0adf3..30e03da464b52 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs @@ -189,7 +189,7 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( SeparatedList(new [] { Argument( ObjectCreationExpression( - GenericName(Identifier("System.Span"), + GenericName(Identifier(TypeNames.System_Span), TypeArgumentList(SingletonSeparatedList( PredefinedType(Token(SyntaxKind.CharKeyword))))), ArgumentList( diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs index 2a4801e8d3c3b..c6ab3114565d6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs @@ -89,7 +89,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu ArgumentList(SingletonSeparatedList( Argument( CastExpression( - ParseTypeName("System.IntPtr"), + SystemIntPtrType, IdentifierName(nativeIdentifier)))))))); } break; @@ -159,7 +159,7 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( Argument(IdentifierName(context.GetIdentifiers(info).managed)), Argument( ObjectCreationExpression( - GenericName(Identifier("System.Span"), + GenericName(Identifier(TypeNames.System_Span), TypeArgumentList(SingletonSeparatedList( PredefinedType(Token(SyntaxKind.ByteKeyword))))), ArgumentList( 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 a0bb19753fa4f..8710e52abca51 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 @@ -6,8 +6,9 @@ namespace Microsoft.Interop { - static class TypeNames + public static class TypeNames { + public const string DllImportAttribute = "System.Runtime.InteropServices.DllImportAttribute"; public const string GeneratedDllImportAttribute = "System.Runtime.InteropServices.GeneratedDllImportAttribute"; public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute"; @@ -22,11 +23,18 @@ static class TypeNames public const string LCIDConversionAttribute = "System.Runtime.InteropServices.LCIDConversionAttribute"; + public const string SuppressGCTransitionAttribute = "System.Runtime.InteropServices.SuppressGCTransitionAttribute"; + + public const string UnmanagedCallConvAttribute = "System.Runtime.InteropServices.UnmanagedCallConvAttribute"; public const string System_Span_Metadata = "System.Span`1"; public const string System_Span = "System.Span"; + public const string System_IntPtr = "System.IntPtr"; + public const string System_Activator = "System.Activator"; + public const string System_Type = "System.Type"; + public const string System_Runtime_InteropServices_StructLayoutAttribute = "System.Runtime.InteropServices.StructLayoutAttribute"; public const string System_Runtime_InteropServices_MarshalAsAttribute = "System.Runtime.InteropServices.MarshalAsAttribute"; From 5b8ce63f7396c9103f5beeaa28779a7df509de84 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 14 Sep 2021 16:15:21 -0700 Subject: [PATCH 142/161] Update DllImportGenerator to the latest version (#59117) --- eng/Versions.props | 2 +- eng/generators.targets | 11 +- .../Unix/System.Native/Interop.ReadLink.cs | 2 +- .../Unix/System.Native/Interop.Stat.Span.cs | 2 +- .../Interop.EvpPkey.Rsa.cs | 6 +- .../Interop.EvpPkey.cs | 10 +- .../Interop.Ssl.cs | 2 +- .../InteropServices/ArrayMarshaller.cs | 225 ++++++++++++++++++ .../System.Console/src/System.Console.csproj | 1 + .../System.Diagnostics.FileVersionInfo.csproj | 2 + .../src/System.Diagnostics.Process.csproj | 1 + ...ConfigureTerminalForChildProcesses.Unix.cs | 6 +- .../src/System.IO.Compression.Brotli.csproj | 1 + .../src/System.IO.Compression.ZipFile.csproj | 2 + .../src/System.IO.Compression.csproj | 1 + .../src/System.IO.FileSystem.DriveInfo.csproj | 1 + .../src/System.IO.FileSystem.Watcher.csproj | 1 + .../src/System.IO.MemoryMappedFiles.csproj | 2 + .../src/System.IO.Pipes.csproj | 1 + .../src/System.Net.Http.csproj | 1 + .../src/System.Net.Mail.csproj | 1 + .../src/System.Net.NameResolution.csproj | 1 + .../src/System.Net.Ping.csproj | 1 + .../src/System.Net.Quic.csproj | 1 + .../src/System.Net.Security.csproj | 1 + .../System/TimeZoneInfo.Unix.NonAndroid.cs | 2 +- ....InteropServices.RuntimeInformation.csproj | 1 + ...stem.Security.Cryptography.Encoding.csproj | 1 + ...ystem.Security.Cryptography.OpenSsl.csproj | 1 + ...urity.Cryptography.X509Certificates.csproj | 1 + 30 files changed, 274 insertions(+), 17 deletions(-) create mode 100644 src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs diff --git a/eng/Versions.props b/eng/Versions.props index 4f2c2bb97eb50..0d289d789d9fc 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -189,6 +189,6 @@ 3.14.0-dotnet 6.0.0-preview.5.21275.7 - 1.0.0-alpha.21301.2 + 1.0.0-alpha.21464.1 diff --git a/eng/generators.targets b/eng/generators.targets index 8764a592d3647..301df026dbbfa 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -8,6 +8,11 @@ true + + true + $(DefineConstants);DLLIMPORTGENERATOR_INTERNALUNSAFE + @@ -15,6 +20,7 @@ This is mimicking the case where the source generator always generates the attributes. --> + @@ -28,7 +34,10 @@ true - true + true true diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs index 3f89554e5838d..ce3b064881371 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs @@ -21,7 +21,7 @@ internal static partial class Sys /// Returns the number of bytes placed into the buffer on success; bufferSize if the buffer is too small; and -1 on error. /// [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadLink", SetLastError = true)] - private static extern int ReadLink(ref byte path, byte[] buffer, int bufferSize); + private static partial int ReadLink(ref byte path, byte[] buffer, int bufferSize); /// /// Takes a path to a symbolic link and returns the link target path. diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs index 9e47577fcc42b..094fa66a0dfa5 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs @@ -10,7 +10,7 @@ internal static partial class Interop internal static partial class Sys { [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", SetLastError = true)] - internal static extern int Stat(ref byte path, out FileStatus output); + internal static partial int Stat(ref byte path, out FileStatus output); internal static int Stat(ReadOnlySpan path, out FileStatus output) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs index c95e239f3b5b2..523d3f33882c4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Rsa.cs @@ -12,7 +12,7 @@ internal static partial class Interop internal static partial class Crypto { [GeneratedDllImport(Libraries.CryptoNative)] - private static extern SafeEvpPKeyHandle CryptoNative_EvpPKeyCreateRsa(IntPtr rsa); + private static partial SafeEvpPKeyHandle CryptoNative_EvpPKeyCreateRsa(IntPtr rsa); internal static SafeEvpPKeyHandle EvpPKeyCreateRsa(IntPtr rsa) { @@ -29,8 +29,8 @@ internal static SafeEvpPKeyHandle EvpPKeyCreateRsa(IntPtr rsa) return pkey; } - [DllImport(Libraries.CryptoNative)] - private static extern SafeEvpPKeyHandle CryptoNative_RsaGenerateKey(int keySize); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial SafeEvpPKeyHandle CryptoNative_RsaGenerateKey(int keySize); internal static SafeEvpPKeyHandle RsaGenerateKey(int keySize) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs index 2aeb855db1a8f..0cea642fcf90b 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs @@ -44,16 +44,16 @@ internal static SafeEvpPKeyHandle EvpPKeyDuplicate( internal static partial int EvpPKeySize(SafeEvpPKeyHandle pkey); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_UpRefEvpPkey")] - internal static extern int UpRefEvpPkey(SafeEvpPKeyHandle handle); + internal static partial int UpRefEvpPkey(SafeEvpPKeyHandle handle); - [DllImport(Libraries.CryptoNative)] - private static extern unsafe SafeEvpPKeyHandle CryptoNative_DecodeSubjectPublicKeyInfo( + [GeneratedDllImport(Libraries.CryptoNative)] + private static unsafe partial SafeEvpPKeyHandle CryptoNative_DecodeSubjectPublicKeyInfo( byte* buf, int len, int algId); - [DllImport(Libraries.CryptoNative)] - private static extern unsafe SafeEvpPKeyHandle CryptoNative_DecodePkcs8PrivateKey( + [GeneratedDllImport(Libraries.CryptoNative)] + private static unsafe partial SafeEvpPKeyHandle CryptoNative_DecodePkcs8PrivateKey( byte* buf, int len, int algId); 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 b5d34ee979008..c31d402047add 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 @@ -75,7 +75,7 @@ internal static partial class Ssl internal static partial int SslRead(SafeSslHandle ssl, ref byte buf, int num); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslRenegotiate")] - internal static extern int SslRenegotiate(SafeSslHandle ssl); + internal static partial int SslRenegotiate(SafeSslHandle ssl); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_IsSslRenegotiatePending")] [return: MarshalAs(UnmanagedType.Bool)] diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs new file mode 100644 index 0000000000000..5c72173ead8e0 --- /dev/null +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs @@ -0,0 +1,225 @@ +// 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 (docs/design/features/source-generator-pinvokes.md). +// See the DllImportGenerator experiment in https://github.com/dotnet/runtimelab. +// +#if DLLIMPORTGENERATOR_INTERNALUNSAFE +using Internal.Runtime.CompilerServices; +#else +using System.Runtime.CompilerServices; +#endif +using System.Diagnostics; + +namespace System.Runtime.InteropServices.GeneratedMarshalling +{ + internal unsafe ref struct ArrayMarshaller + { + private T[]? _managedArray; + private readonly int _sizeOfNativeElement; + private IntPtr _allocatedMemory; + + public ArrayMarshaller(int sizeOfNativeElement) + :this() + { + _sizeOfNativeElement = sizeOfNativeElement; + } + + public ArrayMarshaller(T[]? managed, int sizeOfNativeElement) + { + _allocatedMemory = default; + _sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + _managedArray = null; + NativeValueStorage = default; + return; + } + _managedArray = managed; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * _sizeOfNativeElement, 1); + _allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)_allocatedMemory, spaceToAllocate); + } + + public ArrayMarshaller(T[]? managed, Span stackSpace, int sizeOfNativeElement) + { + _allocatedMemory = default; + _sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + _managedArray = null; + NativeValueStorage = default; + return; + } + _managedArray = managed; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * _sizeOfNativeElement, 1); + if (spaceToAllocate <= stackSpace.Length) + { + NativeValueStorage = stackSpace[0..spaceToAllocate]; + } + else + { + _allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)_allocatedMemory, spaceToAllocate); + } + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + public const int StackBufferSize = 0x200; + + public Span ManagedValues => _managedArray; + + public Span NativeValueStorage { get; private set; } + + public ref byte GetPinnableReference() => ref MemoryMarshal.GetReference(NativeValueStorage); + + public void SetUnmarshalledCollectionLength(int length) + { + _managedArray = new T[length]; + } + + public byte* Value + { + get + { + Debug.Assert(_managedArray is null || _allocatedMemory != IntPtr.Zero); + return (byte*)_allocatedMemory; + } + set + { + if (value == null) + { + _managedArray = null; + NativeValueStorage = default; + } + else + { + _allocatedMemory = (IntPtr)value; + NativeValueStorage = new Span(value, (_managedArray?.Length ?? 0) * _sizeOfNativeElement); + } + } + } + + public T[]? ToManaged() => _managedArray; + + public void FreeNative() + { + if (_allocatedMemory != IntPtr.Zero) + { + Marshal.FreeCoTaskMem(_allocatedMemory); + } + } + } + + internal unsafe ref struct PtrArrayMarshaller where T : unmanaged + { + private T*[]? _managedArray; + private readonly int _sizeOfNativeElement; + private IntPtr _allocatedMemory; + + public PtrArrayMarshaller(int sizeOfNativeElement) + : this() + { + _sizeOfNativeElement = sizeOfNativeElement; + } + + public PtrArrayMarshaller(T*[]? managed, int sizeOfNativeElement) + { + _allocatedMemory = default; + _sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + _managedArray = null; + NativeValueStorage = default; + return; + } + _managedArray = managed; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * _sizeOfNativeElement, 1); + _allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)_allocatedMemory, spaceToAllocate); + } + + public PtrArrayMarshaller(T*[]? managed, Span stackSpace, int sizeOfNativeElement) + { + _allocatedMemory = default; + _sizeOfNativeElement = sizeOfNativeElement; + if (managed is null) + { + _managedArray = null; + NativeValueStorage = default; + return; + } + _managedArray = managed; + // Always allocate at least one byte when the array is zero-length. + int spaceToAllocate = Math.Max(managed.Length * _sizeOfNativeElement, 1); + if (spaceToAllocate <= stackSpace.Length) + { + NativeValueStorage = stackSpace[0..spaceToAllocate]; + } + else + { + _allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); + NativeValueStorage = new Span((void*)_allocatedMemory, spaceToAllocate); + } + } + + /// + /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. + /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't + /// blow the stack since this is a new optimization in the code-generated interop. + /// + public const int StackBufferSize = 0x200; + + public Span ManagedValues => Unsafe.As(_managedArray); + + public Span NativeValueStorage { get; private set; } + + public ref byte GetPinnableReference() => ref MemoryMarshal.GetReference(NativeValueStorage); + + public void SetUnmarshalledCollectionLength(int length) + { + _managedArray = new T*[length]; + } + + public byte* Value + { + get + { + Debug.Assert(_managedArray is null || _allocatedMemory != IntPtr.Zero); + return (byte*)_allocatedMemory; + } + set + { + if (value == null) + { + _managedArray = null; + NativeValueStorage = default; + } + else + { + _allocatedMemory = (IntPtr)value; + NativeValueStorage = new Span(value, (_managedArray?.Length ?? 0) * _sizeOfNativeElement); + } + + } + } + + public T*[]? ToManaged() => _managedArray; + + public void FreeNative() + { + if (_allocatedMemory != IntPtr.Zero) + { + Marshal.FreeCoTaskMem(_allocatedMemory); + } + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index c464007dc95e9..c315a2a837d92 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -219,6 +219,7 @@ + diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/src/System.Diagnostics.FileVersionInfo.csproj b/src/libraries/System.Diagnostics.FileVersionInfo/src/System.Diagnostics.FileVersionInfo.csproj index 564f2f435945f..918384304526b 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/src/System.Diagnostics.FileVersionInfo.csproj +++ b/src/libraries/System.Diagnostics.FileVersionInfo/src/System.Diagnostics.FileVersionInfo.csproj @@ -41,7 +41,9 @@ + + diff --git a/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj b/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj index 1bf0c43270e42..30080797fddbd 100644 --- a/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj +++ b/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj @@ -364,6 +364,7 @@ + diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs index b51957fb881bf..57e1361e28b73 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs @@ -21,7 +21,7 @@ internal static void ConfigureTerminalForChildProcesses(int increment, bool conf Debug.Assert(configureConsole); // At least one child is using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: true); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 1); } else { @@ -30,7 +30,7 @@ internal static void ConfigureTerminalForChildProcesses(int increment, bool conf if (childrenUsingTerminalRemaining == 0 && configureConsole) { // No more children are using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: false); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 0); } } } @@ -50,7 +50,7 @@ private static void DelayedSigChildConsoleConfiguration() if (s_childrenUsingTerminalCount == 0) { // No more children are using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: false); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 0); } } finally diff --git a/src/libraries/System.IO.Compression.Brotli/src/System.IO.Compression.Brotli.csproj b/src/libraries/System.IO.Compression.Brotli/src/System.IO.Compression.Brotli.csproj index 9fdcecf8f5e1e..b8db87b7160be 100644 --- a/src/libraries/System.IO.Compression.Brotli/src/System.IO.Compression.Brotli.csproj +++ b/src/libraries/System.IO.Compression.Brotli/src/System.IO.Compression.Brotli.csproj @@ -42,6 +42,7 @@ + diff --git a/src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj b/src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj index 2110ae810ea63..1e825eda0cb98 100644 --- a/src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj +++ b/src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj @@ -32,7 +32,9 @@ + + diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index 0ffa0044e2a16..0d59f3971d180 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -60,6 +60,7 @@ + diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj b/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj index d07e89ec979be..9fa9a464a5f1b 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj +++ b/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj @@ -77,6 +77,7 @@ + diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj b/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj index b6b0579e63026..075c19e17667c 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj @@ -114,6 +114,7 @@ + diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj index bd15c52faebb1..b473091e6ed1b 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj @@ -115,7 +115,9 @@ + + diff --git a/src/libraries/System.IO.Pipes/src/System.IO.Pipes.csproj b/src/libraries/System.IO.Pipes/src/System.IO.Pipes.csproj index d92b0433d943f..77de961323315 100644 --- a/src/libraries/System.IO.Pipes/src/System.IO.Pipes.csproj +++ b/src/libraries/System.IO.Pipes/src/System.IO.Pipes.csproj @@ -173,6 +173,7 @@ + diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 77ed5b9c436c6..99855727c14da 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -652,6 +652,7 @@ + diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index d1d9176a5e879..0fa2b09742513 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -268,6 +268,7 @@ + diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 1642f1fff33dd..7626f207fa6fe 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -120,6 +120,7 @@ + diff --git a/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj b/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj index 571583be6c379..63e45d7e1cbd8 100644 --- a/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj +++ b/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj @@ -111,6 +111,7 @@ + diff --git a/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj b/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj index 4549842ee8e68..a8cbb4f40e607 100644 --- a/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj +++ b/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj @@ -114,6 +114,7 @@ + diff --git a/src/libraries/System.Net.Security/src/System.Net.Security.csproj b/src/libraries/System.Net.Security/src/System.Net.Security.csproj index 60c21f69a2cfd..4b46aa7b63ea0 100644 --- a/src/libraries/System.Net.Security/src/System.Net.Security.csproj +++ b/src/libraries/System.Net.Security/src/System.Net.Security.csproj @@ -422,6 +422,7 @@ + diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs index d7e54e1ebab2e..0c3e38566825c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs @@ -200,7 +200,7 @@ private static unsafe void EnumerateFilesRecursively(string path, Predicate + diff --git a/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj b/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj index ea5329594dcfb..c957f51337e5c 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj +++ b/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj @@ -124,6 +124,7 @@ + diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/src/System.Security.Cryptography.OpenSsl.csproj b/src/libraries/System.Security.Cryptography.OpenSsl/src/System.Security.Cryptography.OpenSsl.csproj index f28aa959878e3..9acc1264b43d4 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/src/System.Security.Cryptography.OpenSsl.csproj +++ b/src/libraries/System.Security.Cryptography.OpenSsl/src/System.Security.Cryptography.OpenSsl.csproj @@ -158,6 +158,7 @@ + diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj b/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj index 3b1071dd9124b..d14f8c74f6a88 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj @@ -781,6 +781,7 @@ + From 84796a6306dec1a2c71be60ed4e8bdc929a6565b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 14 Sep 2021 16:41:28 -0700 Subject: [PATCH 143/161] Fix failures in the AllConfigurations build. --- .../System.Security.Cryptography.Native.Apple/Interop.X509.cs | 4 ++-- .../src/System.Net.HttpListener.csproj | 1 + .../System.Net.Sockets/src/System.Net.Sockets.csproj | 2 +- .../src/System.Security.Cryptography.Cng.csproj | 1 + .../src/System.Security.Cryptography.Csp.csproj | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs index 9318b31a33fb3..6f167de970b25 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs @@ -21,12 +21,12 @@ private static partial int AppleCryptoNative_X509GetRawData( out int pOSStatus); [GeneratedDllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509GetSubjectSummary( + private static partial int AppleCryptoNative_X509GetSubjectSummary( SafeSecCertificateHandle cert, out SafeCFStringHandle cfSubjectSummaryOut); [GeneratedDllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_X509GetPublicKey(SafeSecCertificateHandle cert, out SafeSecKeyRefHandle publicKey, out int pOSStatus); + private static partial int AppleCryptoNative_X509GetPublicKey(SafeSecCertificateHandle cert, out SafeSecKeyRefHandle publicKey, out int pOSStatus); internal static X509ContentType X509GetContentType(ReadOnlySpan data) { diff --git a/src/libraries/System.Net.HttpListener/src/System.Net.HttpListener.csproj b/src/libraries/System.Net.HttpListener/src/System.Net.HttpListener.csproj index 0e4ac2ffad7f3..a3bf458eccd43 100644 --- a/src/libraries/System.Net.HttpListener/src/System.Net.HttpListener.csproj +++ b/src/libraries/System.Net.HttpListener/src/System.Net.HttpListener.csproj @@ -23,6 +23,7 @@ + diff --git a/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj b/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj index 496c628956f8c..0a2f6aac79ea9 100644 --- a/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj +++ b/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj @@ -287,6 +287,7 @@ + @@ -295,6 +296,5 @@ - diff --git a/src/libraries/System.Security.Cryptography.Cng/src/System.Security.Cryptography.Cng.csproj b/src/libraries/System.Security.Cryptography.Cng/src/System.Security.Cryptography.Cng.csproj index fb654f6698bfe..c61d92e98ac17 100644 --- a/src/libraries/System.Security.Cryptography.Cng/src/System.Security.Cryptography.Cng.csproj +++ b/src/libraries/System.Security.Cryptography.Cng/src/System.Security.Cryptography.Cng.csproj @@ -360,6 +360,7 @@ + diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj b/src/libraries/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj index 2e8119ae25704..1e79c0a12c9a6 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj +++ b/src/libraries/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj @@ -125,6 +125,7 @@ + From 4cfb51f0ce136985e067448e0d247fac4048f031 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 Sep 2021 10:02:59 -0700 Subject: [PATCH 144/161] Hook up DllImportGenerator to the libraries build (excluding solution file regeneration). Move System.Runtime.InteropServices unit tests to a subdirectory. --- .../DllImportGenerator/StructMarshalling.md | 4 +- eng/Versions.props | 5 +- eng/generators.targets | 86 ++++--- .../Kernel32/Interop.SetConsoleCtrlHandler.cs | 2 +- .../InteropServices/ArrayMarshaller.cs | 16 +- .../GeneratedDllImportAttribute.cs | 7 +- .../GeneratedMarshallingAttribute.cs | 59 ++++- .../gen/Directory.Build.props | 12 + .../DllImportGenerator/DllImportGenerator.cs | 2 +- .../DllImportGenerator.csproj | 4 +- ...Microsoft.Interop.DllImportGenerator.props | 2 +- .../Microsoft.Interop.SourceGeneration.csproj | 2 +- .../Ancillary.Interop.csproj | 8 +- .../Ancillary.Interop/ArrayMarshaller.cs | 217 ------------------ .../Ancillary.Interop/Directory.Build.props | 7 + .../GeneratedDllImportAttribute.cs | 31 --- .../GeneratedMarshallingAttribute.cs | 57 ----- .../Directory.Build.props | 7 + .../DllImportGenerator.Tests.csproj | 13 +- .../DllImportGenerator.UnitTests/Compiles.cs | 4 + .../Directory.Build.props | 7 + .../DllImportGenerator.UnitTests.csproj | 14 +- .../IncrementalGenerationTests.cs | 4 + ...e.InteropServices.ComDisabled.Tests.csproj | 0 .../Marshal/MarshalComDisabledTests.cs | 0 .../AssemblyInfo.cs | 0 ...ystem.Runtime.InteropServices.Tests.csproj | 0 .../System/DllNotFoundExceptionTests.cs | 0 .../IDispatchConstantAttributeTests.cs | 0 .../IUnknownConstantAttributeTests.cs | 0 .../InteropServices/ArrayWithOffsetTests.cs | 0 .../AutomationProxyAttributeTests.cs | 0 .../InteropServices/BStrWrapperTests.cs | 0 .../BestFitMappingAttributeTests.cs | 0 .../Runtime/InteropServices/CLongTests.cs | 0 .../Runtime/InteropServices/CULongTests.cs | 0 .../InteropServices/CallingConventionTests.cs | 0 .../ClassInterfaceAttributeTests.cs | 0 .../InteropServices/CoClassAttributeTests.cs | 0 .../CollectionsMarshalTests.cs | 0 .../ComAliasNameAttributeTests.cs | 0 .../ComAwareEventInfoTests.Windows.cs | 0 .../InteropServices/ComAwareEventInfoTests.cs | 0 .../ComCompatibleVersionAttributeTests.cs | 0 .../ComConversionLossAttributeTests.cs | 0 .../ComDefaultInterfaceAttributeTests.cs | 0 .../ComEventInterfaceAttributeTests.cs | 0 .../InteropServices/ComEventsHelperTests.cs | 0 .../ComRegisterFunctionAttributeTests.cs | 0 .../ComSourceInterfacesAttributeTests.cs | 0 .../ComUnregisterFunctionAttributeTests.cs | 0 .../ComVisibleAttributeTests.cs | 0 .../InteropServices/CurrencyWrapperTests.cs | 0 .../DefaultCharSetAttributeTests.cs | 0 ...faultDllImportSearchPathsAttributeTests.cs | 0 .../DefaultParameterValueAttributeTests.cs | 0 .../InteropServices/DispIdAttributeTests.cs | 0 .../InteropServices/DispatchWrapperTests.cs | 0 .../DllImportAttributeTests.cs | 0 .../InteropServices/ErrorWrapperTests.cs | 0 .../FieldOffsetAttributeTests.cs | 0 .../Runtime/InteropServices/GCHandleTests.cs | 0 .../InteropServices/GuidAttributeTests.cs | 0 .../InteropServices/HandleCollectorTests.cs | 0 .../Runtime/InteropServices/HandleRefTests.cs | 0 .../IDispatchImplAttributeTests.cs | 0 .../ImportedFromTypeLibAttributeTests.cs | 0 .../InterfaceTypeAttributeTests.cs | 0 .../LCIDConversionAttributeTests.cs | 0 ...gedToNativeComInteropStubAttributeTests.cs | 0 .../InteropServices/Marshal/AddRefTests.cs | 0 .../Marshal/AllocHGlobalTests.cs | 0 .../Marshal/BindToMonikerTests.cs | 0 ...hangeWrapperHandleStrengthTests.Windows.cs | 0 .../ChangeWrapperHandleStrengthTests.cs | 0 .../Marshal/Common/COMWrappersImpl.cs | 0 .../Marshal/Common/CommonTypes.Windows.cs | 0 .../Marshal/Common/CommonTypes.cs | 0 .../InteropServices/Marshal/Common/Variant.cs | 0 .../Marshal/Copy/ByteArrayTests.cs | 0 .../Marshal/Copy/CharArrayTests.cs | 0 .../Marshal/Copy/DoubleArrayTests.cs | 0 .../Marshal/Copy/Int16ArrayTests.cs | 0 .../Marshal/Copy/Int32ArrayTests.cs | 0 .../Marshal/Copy/Int64ArrayTests.cs | 0 .../Marshal/Copy/IntPtrArrayTests.cs | 0 .../Marshal/Copy/SingleArrayTests.cs | 0 .../Marshal/CreateAggregatedObjectTests.cs | 0 .../CreateWrapperOfTypeTests.Windows.cs | 0 .../Marshal/CreateWrapperOfTypeTests.cs | 0 .../Marshal/DestroyStructureTests.cs | 0 .../FinalReleaseComObjectTests.Windows.cs | 0 .../Marshal/FinalReleaseComObjectTests.cs | 0 .../InteropServices/Marshal/FreeBSTRTests.cs | 0 .../Marshal/FreeCoTaskMemTests.cs | 0 .../Marshal/FreeHGlobalTests.cs | 0 .../GenerateGuidForTypeTests.Windows.cs | 0 .../Marshal/GenerateGuidForTypeTests.cs | 0 .../GenerateProgIdForTypeTests.Windows.cs | 0 .../Marshal/GenerateProgIdForTypeTests.cs | 0 .../Marshal/GetComInterfaceForObjectTests.cs | 0 .../Marshal/GetComObjectDataTests.Windows.cs | 0 .../Marshal/GetComObjectDataTests.cs | 0 .../GetDelegateForFunctionPointerTests.cs | 0 .../Marshal/GetEndComSlotTests.Windows.cs | 0 .../Marshal/GetEndComSlotTests.cs | 0 .../Marshal/GetExceptionCodeTests.cs | 0 .../Marshal/GetExceptionForHRTests.cs | 0 .../Marshal/GetExceptionPointersTests.cs | 0 .../GetFunctionPointerForDelegateTests.cs | 0 .../Marshal/GetHINSTANCETests.cs | 0 .../Marshal/GetHRForExceptionTests.cs | 0 .../GetIDispatchForObjectTests.Windows.cs | 0 .../Marshal/GetIDispatchForObjectTests.cs | 0 .../Marshal/GetIUnknownForObjectTests.cs | 0 .../GetNativeVariantForObjectTests.Windows.cs | 0 .../Marshal/GetNativeVariantForObjectTests.cs | 0 .../GetObjectForIUnknownTests.Windows.cs | 0 .../Marshal/GetObjectForIUnknownTests.cs | 0 .../GetObjectForNativeVariantTests.Windows.cs | 0 .../Marshal/GetObjectForNativeVariantTests.cs | 0 .../GetObjectsForNativeVariantsTests.cs | 0 .../Marshal/GetStartComSlotTests.Windows.cs | 0 .../Marshal/GetStartComSlotTests.cs | 0 .../Marshal/GetTypeFromCLSIDTests.cs | 0 .../Marshal/GetTypeInfoNameTests.cs | 0 .../GetTypedObjectForIUnknownTests.Windows.cs | 0 .../Marshal/GetTypedObjectForIUnknownTests.cs | 0 ...GetUniqueObjectForIUnknownTests.Windows.cs | 0 .../GetUniqueObjectForIUnknownTests.cs | 0 .../Marshal/InitHandleTests.cs | 0 .../Marshal/IsComObjectTests.Windows.cs | 0 .../Marshal/IsComObjectTests.cs | 0 .../IsTypeVisibleFromComTests.Windows.cs | 0 .../Marshal/IsTypeVisibleFromComTests.cs | 0 .../InteropServices/Marshal/LastErrorTests.cs | 0 .../InteropServices/Marshal/OffsetOfTests.cs | 0 .../Marshal/PrelinkAllTests.cs | 0 .../InteropServices/Marshal/PrelinkTests.cs | 0 .../Marshal/PtrToStringAnsiTests.cs | 0 .../Marshal/PtrToStringAutoTests.cs | 0 .../Marshal/PtrToStringBSTR.cs | 0 .../Marshal/PtrToStringUTF8Tests.cs | 0 .../Marshal/PtrToStringUniTests.cs | 0 .../Marshal/PtrToStructureTests.cs | 0 .../Marshal/QueryInterfaceTests.Windows.cs | 0 .../Marshal/QueryInterfaceTests.cs | 0 .../Marshal/ReAllocCoTaskMemTests.cs | 0 .../Marshal/ReAllocHGlobalTests.cs | 0 .../Marshal/ReadWrite/ByteTests.cs | 0 .../Marshal/ReadWrite/Int16Tests.cs | 0 .../Marshal/ReadWrite/Int32Tests.cs | 0 .../Marshal/ReadWrite/Int64Tests.cs | 0 .../Marshal/ReadWrite/IntPtrTests.cs | 0 .../Marshal/ReleaseComObjectTests.Windows.cs | 0 .../Marshal/ReleaseComObjectTests.cs | 0 .../InteropServices/Marshal/ReleaseTests.cs | 0 .../Marshal/SecureStringToBSTRTests.cs | 0 .../SecureStringToCoTaskMemAnsiTests.cs | 0 .../SecureStringToCoTaskMemUnicodeTests.cs | 0 .../SecureStringToGlobalAllocAnsiTests.cs | 0 .../SecureStringToGlobalAllocUnicodeTests.cs | 0 .../Marshal/SetComObjectDataTests.Windows.cs | 0 .../Marshal/SetComObjectDataTests.cs | 0 .../InteropServices/Marshal/SizeOfTests.cs | 0 .../Marshal/StringMarshalingTests.cs | 0 .../Marshal/StringToBSTRTests.cs | 0 .../Marshal/StringToCoTaskMemAnsiTests.cs | 0 .../Marshal/StringToCoTaskMemAutoTests.cs | 0 .../Marshal/StringToCoTaskMemUTF8Tests.cs | 0 .../Marshal/StringToCoTaskMemUniTests.cs | 0 .../Marshal/StringToHGlobalAnsiTests.cs | 0 .../Marshal/StringToHGlobalAutoTests.cs | 0 .../Marshal/StringToHGlobalUniTests.cs | 0 .../Marshal/StructureToPtrTests.cs | 0 .../Marshal/ThrowExceptionForHRTests.cs | 0 .../UnsafeAddrOfPinnedArrayElementTests.cs | 0 .../Marshal/ZeroFreeCoTaskMemAnsiTests.cs | 0 .../Marshal/ZeroFreeCoTaskMemUTF8Tests.cs | 0 .../Marshal/ZeroFreeCoTaskMemUnicodeTests.cs | 0 .../Marshal/ZeroFreeGlobalAllocAnsiTests.cs | 0 .../ZeroFreeGlobalAllocUnicodeTests.cs | 0 .../MarshalAsAttributeTests.cs | 0 .../Runtime/InteropServices/NFloatTests.cs | 0 .../InteropServices/NativeMemoryTests.cs | 0 .../InteropServices/ObjectiveC/LibObjC.cs | 0 .../ObjectiveC/MessageSendTests.cs | 0 .../ObjectiveC/PendingExceptionTests.cs | 0 .../PosixSignalContextTests.cs | 0 .../PosixSignalRegistrationTests.Unix.cs | 0 .../PosixSignalRegistrationTests.Windows.cs | 0 .../PosixSignalRegistrationTests.cs | 0 .../PrimaryInteropAssemblyAttributeTests.cs | 0 .../InteropServices/ProgIdAttributeTests.cs | 0 .../RuntimeEnvironmentTests.cs | 0 .../InteropServices/SafeBufferTests.cs | 0 ...etWin32ContextInIDispatchAttributeTests.cs | 0 .../StructLayoutAttributeTests.cs | 0 .../TypeIdentifierAttributeTests.cs | 0 .../TypeLibFuncAttributeTests.cs | 0 .../TypeLibImportClassAttributeTests.cs | 0 .../TypeLibTypeAttributeTests.cs | 0 .../TypeLibVarAttributeTests.cs | 0 .../TypeLibVersionAttributeTests.cs | 0 .../InteropServices/UnknownWrapperTests.cs | 0 .../UnmanagedFunctionPointerAttributeTests.cs | 0 .../InteropServices/VariantWrapperTests.cs | 0 .../tests/TestAssets/Directory.Build.props | 5 +- .../NativeExports/NativeExports.csproj | 2 +- .../TestAssets/SharedTypes/SharedTypes.csproj | 2 +- .../DllImportGeneratorSample.csproj | 10 +- 211 files changed, 212 insertions(+), 377 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props delete mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Directory.Build.props delete mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs delete mode 100644 src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Directory.Build.props create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Directory.Build.props rename src/libraries/System.Runtime.InteropServices/tests/{ComDisabled => System.Runtime.InteropServices.ComDisabled.UnitTests}/System.Runtime.InteropServices.ComDisabled.Tests.csproj (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ComDisabled => System.Runtime.InteropServices.ComDisabled.UnitTests}/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/AssemblyInfo.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System.Runtime.InteropServices.Tests.csproj (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/DllNotFoundExceptionTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/CompilerServices/IDispatchConstantAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/CompilerServices/IUnknownConstantAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ArrayWithOffsetTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/AutomationProxyAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/BStrWrapperTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/BestFitMappingAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/CLongTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/CULongTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/CallingConventionTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ClassInterfaceAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/CoClassAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/CollectionsMarshalTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComAliasNameAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComAwareEventInfoTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComAwareEventInfoTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComCompatibleVersionAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComConversionLossAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComDefaultInterfaceAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComEventInterfaceAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComEventsHelperTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComRegisterFunctionAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComSourceInterfacesAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComUnregisterFunctionAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ComVisibleAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/CurrencyWrapperTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/DefaultCharSetAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/DefaultParameterValueAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/DispIdAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/DispatchWrapperTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/DllImportAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ErrorWrapperTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/FieldOffsetAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/GCHandleTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/GuidAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/HandleCollectorTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/HandleRefTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/IDispatchImplAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ImportedFromTypeLibAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/InterfaceTypeAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/LCIDConversionAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/AddRefTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/AllocHGlobalTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/BindToMonikerTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Common/COMWrappersImpl.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Common/CommonTypes.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Common/CommonTypes.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Common/Variant.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/ByteArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/CharArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/DoubleArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/Int16ArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/Int32ArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/Int64ArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/IntPtrArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/Copy/SingleArrayTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/CreateAggregatedObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/DestroyStructureTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/FreeBSTRTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/FreeCoTaskMemTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/FreeHGlobalTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetComInterfaceForObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetExceptionCodeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetExceptionForHRTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetExceptionPointersTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetHINSTANCETests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetHRForExceptionTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetIUnknownForObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetObjectsForNativeVariantsTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetTypeFromCLSIDTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetTypeInfoNameTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/InitHandleTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/IsComObjectTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/IsComObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/LastErrorTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PrelinkAllTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PrelinkTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PtrToStringAnsiTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PtrToStringAutoTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PtrToStringBSTR.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PtrToStringUTF8Tests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PtrToStringUniTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/PtrToStructureTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReAllocCoTaskMemTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReAllocHGlobalTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReadWrite/ByteTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReadWrite/Int32Tests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReadWrite/Int64Tests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReadWrite/IntPtrTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ReleaseTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SecureStringToBSTRTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemAnsiTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemUnicodeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocAnsiTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocUnicodeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/SizeOfTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringMarshalingTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToBSTRTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAnsiTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAutoTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUTF8Tests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUniTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToHGlobalAnsiTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToHGlobalAutoTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StringToHGlobalUniTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/StructureToPtrTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ThrowExceptionForHRTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/UnsafeAddrOfPinnedArrayElementTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemAnsiTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUTF8Tests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUnicodeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocAnsiTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocUnicodeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/MarshalAsAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/NFloatTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/NativeMemoryTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ObjectiveC/LibObjC.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ObjectiveC/MessageSendTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ObjectiveC/PendingExceptionTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/PosixSignalContextTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/PosixSignalRegistrationTests.Windows.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/PosixSignalRegistrationTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/PrimaryInteropAssemblyAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/ProgIdAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/RuntimeEnvironmentTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/SafeBufferTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/StructLayoutAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/TypeIdentifierAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/TypeLibFuncAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/TypeLibImportClassAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/TypeLibTypeAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/TypeLibVarAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/TypeLibVersionAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/UnknownWrapperTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/UnmanagedFunctionPointerAttributeTests.cs (100%) rename src/libraries/System.Runtime.InteropServices/tests/{ => System.Runtime.InteropServices.UnitTests}/System/Runtime/InteropServices/VariantWrapperTests.cs (100%) diff --git a/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/docs/design/libraries/DllImportGenerator/StructMarshalling.md index 79d5e9bd769d8..3bc6033cec4cd 100644 --- a/docs/design/libraries/DllImportGenerator/StructMarshalling.md +++ b/docs/design/libraries/DllImportGenerator/StructMarshalling.md @@ -12,7 +12,7 @@ These types pose an interesting problem for a number of reasons listed below. Wi - In the ref assemblies generated by dotnet/runtime, we save space and prevent users from relying on private implementation details of structures by emitting limited information about their fields. Structures that have at least one non-object field are given a private `int` field, and structures that have at least one field that transitively contains an object are given one private `object`-typed field. As a result, we do not have full type information at code-generation time for any structures defined in the BCL when compiling a library that uses the ref assemblies. - Private reflection - Even when we do have information about all of the fields, we can't emit code that references them if they are private, so we would have to emit unsafe code and calculate offsets manually to support marshaling them. - + ## Opt-in Interop We've been working around another problem for a while in the runtime-integrated interop design: The user can use any type that is non-auto layout and has fields that can be marshaled in interop. This has lead to various issues where types that were not intended for interop usage became usable and then we couldn't update their behavior to be special-cased since users may have been relying on the generic behavior (`Span`, `Vector` come to mind). @@ -213,7 +213,7 @@ Because the Roslyn compiler needs to be able to validate that there are not recu To enable blittable generics support in this struct marshalling model, we extend `[BlittableType]` as follows: - In a generic type definition, we consider all type parameters that can be value types as blittable for the purposes of validating that `[BlittableType]` is only applied to blittable types. -- When the source generator discovers a generic type marked with `[BlittableType]` it will look through the fields on the type and validate that they are blittable. +- When the source generator discovers a generic type marked with `[BlittableType]` it will look through the fields on the type and validate that they are blittable. Since all fields typed with non-parameterized types are validated to be blittable at type definition time, we know that they are all blittable at type usage time. So, we only need to validate that the generic fields are instantiated with blittable types. diff --git a/eng/Versions.props b/eng/Versions.props index 46544b0b903b6..7fad69eba9789 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -47,6 +47,7 @@ + 3.3.2 3.10.0 3.10.0 7.0.0-preview1.21460.1 @@ -141,6 +142,7 @@ 1.0.0-beta-build0015 1.0.4-preview6.19326.1 0.2.61701 + 1.0.23 5.0.0-preview-20201009.2 @@ -190,7 +193,5 @@ 1.1.87-gba258badda 3.14.0-dotnet 6.0.0-preview.5.21275.7 - - 1.0.0-alpha.21464.1 diff --git a/eng/generators.targets b/eng/generators.targets index 301df026dbbfa..f81418273a34e 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -1,45 +1,77 @@ - + + + + true + false + true + + + + + + + + + + + + + + + DependsOnTargets="ConfigureDllImportGenerator" + BeforeTargets="CoreCompile" /> - - + + true + true $(DefineConstants);DLLIMPORTGENERATOR_INTERNALUNSAFE - - - - - - - - + + + - + + + + - - true - - - true - true + $(DefineConstants);DLLIMPORTGENERATOR_ENABLED + diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs index 5c3c4d6206758..8a64d27c19660 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.cs @@ -15,7 +15,7 @@ internal static partial class Kernel32 #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] - internal static partial bool SetConsoleCtrlHandler(delegate* unmanaged handler, bool addOrRemove); + internal static unsafe partial bool SetConsoleCtrlHandler(delegate* unmanaged handler, bool Add); #else [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern unsafe bool SetConsoleCtrlHandler(delegate* unmanaged HandlerRoutine, bool Add); diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs index 5c72173ead8e0..4014154b4824c 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs @@ -14,7 +14,12 @@ namespace System.Runtime.InteropServices.GeneratedMarshalling { - internal unsafe ref struct ArrayMarshaller +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + unsafe ref struct ArrayMarshaller { private T[]? _managedArray; private readonly int _sizeOfNativeElement; @@ -118,7 +123,12 @@ public void FreeNative() } } - internal unsafe ref struct PtrArrayMarshaller where T : unmanaged +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + unsafe ref struct PtrArrayMarshaller where T : unmanaged { private T*[]? _managedArray; private readonly int _sizeOfNativeElement; @@ -222,4 +232,4 @@ public void FreeNative() } } } -} \ No newline at end of file +} diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs index b04c9d9482bc7..e6ae47ac8fbfc 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs @@ -13,7 +13,12 @@ namespace System.Runtime.InteropServices /// Indicates that method will be generated at compile time and invoke into an unmanaged library entry point /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - internal sealed class GeneratedDllImportAttribute : Attribute +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + sealed class GeneratedDllImportAttribute : Attribute { public bool BestFitMapping { get; set; } public CallingConvention CallingConvention { get; set; } diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs index c66605e02ed19..f9308081c2b2f 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs @@ -8,17 +8,32 @@ namespace System.Runtime.InteropServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] - internal class GeneratedMarshallingAttribute : Attribute +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + sealed class GeneratedMarshallingAttribute : Attribute { } [AttributeUsage(AttributeTargets.Struct)] - internal class BlittableTypeAttribute : Attribute +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + sealed class BlittableTypeAttribute : Attribute { } [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] - internal class NativeMarshallingAttribute : Attribute +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + sealed class NativeMarshallingAttribute : Attribute { public NativeMarshallingAttribute(Type nativeType) { @@ -28,14 +43,46 @@ public NativeMarshallingAttribute(Type nativeType) public Type NativeType { get; } } - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field)] - internal class MarshalUsingAttribute : Attribute + [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field, AllowMultiple = true)] +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + sealed class MarshalUsingAttribute : Attribute { + public MarshalUsingAttribute() + { + CountElementName = string.Empty; + } + public MarshalUsingAttribute(Type nativeType) + :this() { NativeType = nativeType; } - public Type NativeType { get; } + public Type? NativeType { get; } + + public string CountElementName { get; set; } + + public int ConstantElementCount { get; set; } + + public int ElementIndirectionLevel { get; set; } + + public const string ReturnsCountValue = "return-value"; + } + + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] +#if DLLIMPORT_GENERATOR_TEST + public +#else + internal +#endif + sealed class GenericContiguousCollectionMarshallerAttribute : Attribute + { + public GenericContiguousCollectionMarshallerAttribute() + { + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props new file mode 100644 index 0000000000000..9eff2af744867 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Directory.Build.props @@ -0,0 +1,12 @@ + + + + false + false + + false + true + false + false + + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 70dfbaef01203..de95cd752c296 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -15,7 +15,7 @@ namespace Microsoft.Interop { [Generator] - public class DllImportGenerator : IIncrementalGenerator + public sealed class DllImportGenerator : IIncrementalGenerator { private const string GeneratedDllImport = nameof(GeneratedDllImport); private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index ca0f1512667ef..8e517510aa0e4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -30,7 +30,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props index fb3d09a8a355e..550d474720ea1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props @@ -21,7 +21,7 @@ --> - + $(DefineConstants);DLLIMPORTGENERATOR_ENABLED diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj index 8317b0a45f8ed..c1768eedb4da2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj @@ -8,7 +8,7 @@ - + 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 b04f4ba3c0894..9b389dddc8dc1 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 @@ -2,11 +2,17 @@ Microsoft.Interop.Ancillary - net6.0 + $(NetCoreAppCurrent) System.Runtime.InteropServices enable true APIs required for usage of the DllImportGenerator and related tools. + $(DefineConstants);DLLIMPORT_GENERATOR_TEST + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs deleted file mode 100644 index 370e90efb3d28..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/ArrayMarshaller.cs +++ /dev/null @@ -1,217 +0,0 @@ - -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Runtime.InteropServices.GeneratedMarshalling -{ - public unsafe ref struct ArrayMarshaller - { - private T[]? managedArray; - private readonly int sizeOfNativeElement; - private IntPtr allocatedMemory; - - public ArrayMarshaller(int sizeOfNativeElement) - :this() - { - this.sizeOfNativeElement = sizeOfNativeElement; - } - - public ArrayMarshaller(T[]? managed, int sizeOfNativeElement) - { - allocatedMemory = default; - this.sizeOfNativeElement = sizeOfNativeElement; - if (managed is null) - { - managedArray = null; - NativeValueStorage = default; - return; - } - managedArray = managed; - this.sizeOfNativeElement = sizeOfNativeElement; - // Always allocate at least one byte when the array is zero-length. - int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); - allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); - NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); - } - - public ArrayMarshaller(T[]? managed, Span stackSpace, int sizeOfNativeElement) - { - allocatedMemory = default; - this.sizeOfNativeElement = sizeOfNativeElement; - if (managed is null) - { - managedArray = null; - NativeValueStorage = default; - return; - } - managedArray = managed; - // Always allocate at least one byte when the array is zero-length. - int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); - if (spaceToAllocate <= stackSpace.Length) - { - NativeValueStorage = stackSpace[0..spaceToAllocate]; - } - else - { - allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); - NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); - } - } - - /// - /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. - /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't - /// blow the stack since this is a new optimization in the code-generated interop. - /// - public const int StackBufferSize = 0x200; - - public Span ManagedValues => managedArray; - - public Span NativeValueStorage { get; private set; } - - public ref byte GetPinnableReference() => ref MemoryMarshal.GetReference(NativeValueStorage); - - public void SetUnmarshalledCollectionLength(int length) - { - managedArray = new T[length]; - } - - public byte* Value - { - get - { - Debug.Assert(managedArray is null || allocatedMemory != IntPtr.Zero); - return (byte*)allocatedMemory; - } - set - { - if (value == null) - { - managedArray = null; - NativeValueStorage = default; - } - else - { - allocatedMemory = (IntPtr)value; - NativeValueStorage = new Span(value, (managedArray?.Length ?? 0) * sizeOfNativeElement); - } - } - } - - public T[]? ToManaged() => managedArray; - - public void FreeNative() - { - if (allocatedMemory != IntPtr.Zero) - { - Marshal.FreeCoTaskMem(allocatedMemory); - } - } - } - - public unsafe ref struct PtrArrayMarshaller where T : unmanaged - { - private T*[]? managedArray; - private readonly int sizeOfNativeElement; - private IntPtr allocatedMemory; - - public PtrArrayMarshaller(int sizeOfNativeElement) - : this() - { - this.sizeOfNativeElement = sizeOfNativeElement; - } - - public PtrArrayMarshaller(T*[]? managed, int sizeOfNativeElement) - { - allocatedMemory = default; - this.sizeOfNativeElement = sizeOfNativeElement; - if (managed is null) - { - managedArray = null; - NativeValueStorage = default; - return; - } - managedArray = managed; - this.sizeOfNativeElement = sizeOfNativeElement; - // Always allocate at least one byte when the array is zero-length. - int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); - allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); - NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); - } - - public PtrArrayMarshaller(T*[]? managed, Span stackSpace, int sizeOfNativeElement) - { - allocatedMemory = default; - this.sizeOfNativeElement = sizeOfNativeElement; - if (managed is null) - { - managedArray = null; - NativeValueStorage = default; - return; - } - managedArray = managed; - // Always allocate at least one byte when the array is zero-length. - int spaceToAllocate = Math.Max(managed.Length * sizeOfNativeElement, 1); - if (spaceToAllocate <= stackSpace.Length) - { - NativeValueStorage = stackSpace[0..spaceToAllocate]; - } - else - { - allocatedMemory = Marshal.AllocCoTaskMem(spaceToAllocate); - NativeValueStorage = new Span((void*)allocatedMemory, spaceToAllocate); - } - } - - /// - /// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack. - /// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't - /// blow the stack since this is a new optimization in the code-generated interop. - /// - public const int StackBufferSize = 0x200; - - public Span ManagedValues => Unsafe.As(managedArray); - - public Span NativeValueStorage { get; private set; } - - public ref byte GetPinnableReference() => ref MemoryMarshal.GetReference(NativeValueStorage); - - public void SetUnmarshalledCollectionLength(int length) - { - managedArray = new T*[length]; - } - - public byte* Value - { - get - { - Debug.Assert(managedArray is null || allocatedMemory != IntPtr.Zero); - return (byte*)allocatedMemory; - } - set - { - if (value == null) - { - managedArray = null; - NativeValueStorage = default; - } - else - { - allocatedMemory = (IntPtr)value; - NativeValueStorage = new Span(value, (managedArray?.Length ?? 0) * sizeOfNativeElement); - } - - } - } - - public T*[]? ToManaged() => managedArray; - - public void FreeNative() - { - if (allocatedMemory != IntPtr.Zero) - { - Marshal.FreeCoTaskMem(allocatedMemory); - } - } - } -} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Directory.Build.props new file mode 100644 index 0000000000000..fa9c3a4001db5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + true + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs deleted file mode 100644 index 73f012f86a415..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedDllImportAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ - -namespace System.Runtime.InteropServices -{ - /// - /// Indicates that method will be generated at compile time and invoke into an unmanaged library entry point - /// - /// - /// IL linker/trimming currently has special handling of P/Invokes (pinvokeimpl): - /// - https://github.com/mono/linker/blob/bfab847356063d21eb15e79f2b6c03df5bd6ef3d/src/linker/Linker.Steps/MarkStep.cs#L2623 - /// We may want to make the linker aware of this attribute as well. - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public sealed class GeneratedDllImportAttribute : Attribute - { - public bool BestFitMapping; - public CallingConvention CallingConvention; - public CharSet CharSet; - public string? EntryPoint; - public bool ExactSpelling; - public bool PreserveSig; - public bool SetLastError; - public bool ThrowOnUnmappableChar; - - public GeneratedDllImportAttribute(string dllName) - { - this.Value = dllName; - } - - public string Value { get; private set; } - } -} diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs deleted file mode 100644 index dd605b9e60bbb..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/GeneratedMarshallingAttribute.cs +++ /dev/null @@ -1,57 +0,0 @@ - -namespace System.Runtime.InteropServices -{ - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] - sealed class GeneratedMarshallingAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Struct)] - public sealed class BlittableTypeAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] - public sealed class NativeMarshallingAttribute : Attribute - { - public NativeMarshallingAttribute(Type nativeType) - { - NativeType = nativeType; - } - - public Type NativeType { get; } - } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.Field, AllowMultiple = true)] - public sealed class MarshalUsingAttribute : Attribute - { - public MarshalUsingAttribute() - { - CountElementName = string.Empty; - } - - public MarshalUsingAttribute(Type nativeType) - :this() - { - NativeType = nativeType; - } - - public Type? NativeType { get; } - - public string CountElementName { get; set; } - - public int ConstantElementCount { get; set; } - - public int ElementIndirectionLevel { get; set; } - - public const string ReturnsCountValue = "return-value"; - } - - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] - public sealed class GenericContiguousCollectionMarshallerAttribute : Attribute - { - public GenericContiguousCollectionMarshallerAttribute() - { - } - } -} \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Directory.Build.props new file mode 100644 index 0000000000000..fa9c3a4001db5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + true + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index ecd9ee7adf636..887a041b0e061 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -1,15 +1,16 @@  - - - net6.0 + $(NetCoreAppCurrent) false Preview true + true + + false - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -17,8 +18,8 @@ - - + + 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 671b5bacd464b..959e4005e30b6 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -338,7 +338,11 @@ public static IEnumerable CodeSnippetsToCompileWithMarshalType() yield break; } +#pragma warning disable xUnit1004 // Test methods should not be skipped. + // If we have any new experimental APIs that we are implementing that have not been approved, + // we will add new scenarios for this test. [Theory(Skip = "No current scenarios to test.")] +#pragma warning restore [MemberData(nameof(CodeSnippetsToCompileWithMarshalType))] public async Task ValidateSnippetsWithMarshalType(string source) { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Directory.Build.props new file mode 100644 index 0000000000000..fa9c3a4001db5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + true + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index 1ebce78dadc54..89b2d192140ce 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -1,22 +1,18 @@  - net6.0 + $(NetCoreAppCurrent) false Preview enable - + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -24,10 +20,10 @@ - + - + diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs index e37e6fdd7ab43..89269066b495e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs @@ -40,7 +40,9 @@ public async Task AddingNewUnrelatedType_DoesNotRegenerateSource() }); } +#pragma warning disable xUnit1004 // Test methods should not be skipped. These tests will be updated to use the new incremental work tracking APIs and enabled then. [Fact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] +#pragma warning restore public async Task AppendingUnrelatedSource_DoesNotRegenerateSource() { string source = $"namespace NS{{{CodeSnippets.BasicParametersAndModifiers()}}}"; @@ -164,7 +166,9 @@ public async Task ChangingMarshallingStrategy_RegeneratesStub() }); } +#pragma warning disable xUnit1004 // Test methods should not be skipped. These tests will be updated to use the new incremental work tracking APIs and enabled then. [Fact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] +#pragma warning restore public async Task ChangingMarshallingAttributes_SameStrategy_DoesNotRegenerate() { string source = CodeSnippets.BasicParametersAndModifiers(); diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComDisabled/System.Runtime.InteropServices.ComDisabled.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System.Runtime.InteropServices.ComDisabled.Tests.csproj similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/ComDisabled/System.Runtime.InteropServices.ComDisabled.Tests.csproj rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System.Runtime.InteropServices.ComDisabled.Tests.csproj diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComDisabled/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/ComDisabled/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/AssemblyInfo.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/AssemblyInfo.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/AssemblyInfo.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/AssemblyInfo.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.Tests.csproj rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/DllNotFoundExceptionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/DllNotFoundExceptionTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/DllNotFoundExceptionTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/DllNotFoundExceptionTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/CompilerServices/IDispatchConstantAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/CompilerServices/IDispatchConstantAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/CompilerServices/IDispatchConstantAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/CompilerServices/IDispatchConstantAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/CompilerServices/IUnknownConstantAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/CompilerServices/IUnknownConstantAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/CompilerServices/IUnknownConstantAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/CompilerServices/IUnknownConstantAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ArrayWithOffsetTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ArrayWithOffsetTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ArrayWithOffsetTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ArrayWithOffsetTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/AutomationProxyAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/AutomationProxyAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/AutomationProxyAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/AutomationProxyAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/BStrWrapperTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/BStrWrapperTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/BStrWrapperTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/BStrWrapperTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/BestFitMappingAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/BestFitMappingAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/BestFitMappingAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/BestFitMappingAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CLongTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CLongTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CLongTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CLongTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CULongTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CULongTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CULongTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CULongTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CallingConventionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CallingConventionTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CallingConventionTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CallingConventionTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ClassInterfaceAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ClassInterfaceAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ClassInterfaceAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ClassInterfaceAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CoClassAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CoClassAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CoClassAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CoClassAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CollectionsMarshalTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CollectionsMarshalTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComAliasNameAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComAliasNameAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComAliasNameAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComAliasNameAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComAwareEventInfoTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComAwareEventInfoTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComAwareEventInfoTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComAwareEventInfoTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComAwareEventInfoTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComAwareEventInfoTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComAwareEventInfoTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComAwareEventInfoTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComCompatibleVersionAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComCompatibleVersionAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComCompatibleVersionAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComCompatibleVersionAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComConversionLossAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComConversionLossAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComConversionLossAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComConversionLossAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComDefaultInterfaceAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComDefaultInterfaceAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComDefaultInterfaceAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComDefaultInterfaceAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComEventInterfaceAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComEventInterfaceAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComEventInterfaceAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComEventInterfaceAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComEventsHelperTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComEventsHelperTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComEventsHelperTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComEventsHelperTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComRegisterFunctionAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComRegisterFunctionAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComRegisterFunctionAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComRegisterFunctionAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComSourceInterfacesAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComSourceInterfacesAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComSourceInterfacesAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComSourceInterfacesAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComUnregisterFunctionAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComUnregisterFunctionAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComUnregisterFunctionAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComUnregisterFunctionAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComVisibleAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComVisibleAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ComVisibleAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComVisibleAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CurrencyWrapperTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CurrencyWrapperTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CurrencyWrapperTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/CurrencyWrapperTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DefaultCharSetAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DefaultCharSetAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DefaultCharSetAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DefaultCharSetAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DefaultParameterValueAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DefaultParameterValueAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DefaultParameterValueAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DefaultParameterValueAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DispIdAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DispIdAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DispIdAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DispIdAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DispatchWrapperTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DispatchWrapperTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DispatchWrapperTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DispatchWrapperTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DllImportAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DllImportAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/DllImportAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/DllImportAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ErrorWrapperTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ErrorWrapperTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ErrorWrapperTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ErrorWrapperTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/FieldOffsetAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/FieldOffsetAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/FieldOffsetAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/FieldOffsetAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/GCHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/GCHandleTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/GCHandleTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/GCHandleTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/GuidAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/GuidAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/GuidAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/GuidAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/HandleCollectorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleCollectorTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/HandleCollectorTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleCollectorTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/HandleRefTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleRefTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/HandleRefTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleRefTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/IDispatchImplAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/IDispatchImplAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/IDispatchImplAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/IDispatchImplAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ImportedFromTypeLibAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ImportedFromTypeLibAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ImportedFromTypeLibAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ImportedFromTypeLibAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/InterfaceTypeAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/InterfaceTypeAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/InterfaceTypeAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/InterfaceTypeAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/LCIDConversionAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/LCIDConversionAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/LCIDConversionAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/LCIDConversionAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/AddRefTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/AddRefTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/AddRefTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/AddRefTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/AllocHGlobalTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/AllocHGlobalTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/AllocHGlobalTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/AllocHGlobalTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/BindToMonikerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/BindToMonikerTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/BindToMonikerTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/BindToMonikerTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ChangeWrapperHandleStrengthTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/COMWrappersImpl.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/COMWrappersImpl.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/COMWrappersImpl.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/COMWrappersImpl.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/CommonTypes.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/Variant.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/Variant.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Common/Variant.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Common/Variant.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/ByteArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/ByteArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/ByteArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/ByteArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/CharArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/CharArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/CharArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/CharArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/DoubleArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/DoubleArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/DoubleArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/DoubleArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/Int16ArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/Int16ArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/Int16ArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/Int16ArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/Int32ArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/Int32ArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/Int32ArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/Int32ArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/Int64ArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/Int64ArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/Int64ArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/Int64ArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/IntPtrArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/IntPtrArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/IntPtrArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/IntPtrArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/SingleArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/SingleArrayTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/Copy/SingleArrayTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/Copy/SingleArrayTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/CreateAggregatedObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/CreateAggregatedObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/CreateAggregatedObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/CreateAggregatedObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/CreateWrapperOfTypeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/DestroyStructureTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/DestroyStructureTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/DestroyStructureTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/DestroyStructureTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FinalReleaseComObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FreeBSTRTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FreeBSTRTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FreeBSTRTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FreeBSTRTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FreeCoTaskMemTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FreeCoTaskMemTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FreeCoTaskMemTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FreeCoTaskMemTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FreeHGlobalTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FreeHGlobalTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/FreeHGlobalTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/FreeHGlobalTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateGuidForTypeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GenerateProgIdForTypeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetComInterfaceForObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetComInterfaceForObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetComInterfaceForObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetComInterfaceForObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetComObjectDataTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetExceptionCodeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetExceptionCodeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetExceptionCodeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetExceptionCodeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetExceptionForHRTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetExceptionForHRTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetExceptionForHRTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetExceptionForHRTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetExceptionPointersTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetExceptionPointersTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetExceptionPointersTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetExceptionPointersTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetHINSTANCETests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetHINSTANCETests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetHINSTANCETests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetHINSTANCETests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetHRForExceptionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetHRForExceptionTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetHRForExceptionTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetHRForExceptionTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetIDispatchForObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetIUnknownForObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetIUnknownForObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetIUnknownForObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetIUnknownForObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetNativeVariantForObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForIUnknownTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectForNativeVariantTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectsForNativeVariantsTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectsForNativeVariantsTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetObjectsForNativeVariantsTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetObjectsForNativeVariantsTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetStartComSlotTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypeFromCLSIDTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypeFromCLSIDTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypeFromCLSIDTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypeFromCLSIDTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypeInfoNameTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypeInfoNameTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypeInfoNameTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypeInfoNameTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetTypedObjectForIUnknownTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetUniqueObjectForIUnknownTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/InitHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/InitHandleTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/InitHandleTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/InitHandleTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsComObjectTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsComObjectTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsComObjectTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsComObjectTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsComObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsComObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsComObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsComObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/IsTypeVisibleFromComTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/LastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/LastErrorTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/LastErrorTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/LastErrorTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PrelinkAllTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PrelinkAllTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PrelinkAllTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PrelinkAllTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PrelinkTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PrelinkTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PrelinkTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PrelinkTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringAnsiTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringAnsiTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringAnsiTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringAnsiTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringAutoTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringAutoTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringAutoTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringAutoTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringBSTR.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringBSTR.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringBSTR.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringBSTR.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringUTF8Tests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringUTF8Tests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringUTF8Tests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringUTF8Tests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringUniTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringUniTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStringUniTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStringUniTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStructureTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStructureTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/PtrToStructureTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PtrToStructureTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/QueryInterfaceTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReAllocCoTaskMemTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReAllocCoTaskMemTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReAllocCoTaskMemTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReAllocCoTaskMemTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReAllocHGlobalTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReAllocHGlobalTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReAllocHGlobalTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReAllocHGlobalTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/ByteTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/ByteTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/ByteTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/ByteTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int32Tests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int32Tests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int32Tests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int32Tests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int64Tests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int64Tests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int64Tests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int64Tests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/IntPtrTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/IntPtrTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/IntPtrTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/IntPtrTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReleaseComObjectTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReleaseTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReleaseTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReleaseTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReleaseTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToBSTRTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToBSTRTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToBSTRTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToBSTRTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemAnsiTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemAnsiTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemAnsiTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemAnsiTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemUnicodeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemUnicodeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemUnicodeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToCoTaskMemUnicodeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocAnsiTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocAnsiTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocAnsiTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocAnsiTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocUnicodeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocUnicodeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocUnicodeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SecureStringToGlobalAllocUnicodeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SetComObjectDataTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringMarshalingTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringMarshalingTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringMarshalingTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringMarshalingTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToBSTRTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToBSTRTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToBSTRTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToBSTRTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAnsiTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAnsiTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAnsiTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAnsiTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAutoTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAutoTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAutoTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemAutoTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUTF8Tests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUTF8Tests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUTF8Tests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUTF8Tests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUniTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUniTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUniTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToCoTaskMemUniTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToHGlobalAnsiTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToHGlobalAnsiTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToHGlobalAnsiTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToHGlobalAnsiTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToHGlobalAutoTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToHGlobalAutoTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToHGlobalAutoTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToHGlobalAutoTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToHGlobalUniTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToHGlobalUniTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StringToHGlobalUniTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StringToHGlobalUniTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StructureToPtrTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StructureToPtrTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/StructureToPtrTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/StructureToPtrTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ThrowExceptionForHRTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ThrowExceptionForHRTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ThrowExceptionForHRTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ThrowExceptionForHRTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/UnsafeAddrOfPinnedArrayElementTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/UnsafeAddrOfPinnedArrayElementTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/UnsafeAddrOfPinnedArrayElementTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/UnsafeAddrOfPinnedArrayElementTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemAnsiTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemAnsiTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemAnsiTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemAnsiTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUTF8Tests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUTF8Tests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUTF8Tests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUTF8Tests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUnicodeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUnicodeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUnicodeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeCoTaskMemUnicodeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocAnsiTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocAnsiTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocAnsiTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocAnsiTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocUnicodeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocUnicodeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocUnicodeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ZeroFreeGlobalAllocUnicodeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/MarshalAsAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/MarshalAsAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/MarshalAsAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/MarshalAsAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NFloatTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NFloatTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NativeMemoryTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NativeMemoryTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NativeMemoryTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NativeMemoryTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ObjectiveC/LibObjC.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ObjectiveC/LibObjC.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ObjectiveC/LibObjC.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ObjectiveC/LibObjC.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ObjectiveC/MessageSendTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ObjectiveC/MessageSendTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ObjectiveC/MessageSendTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ObjectiveC/MessageSendTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ObjectiveC/PendingExceptionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ObjectiveC/PendingExceptionTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ObjectiveC/PendingExceptionTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ObjectiveC/PendingExceptionTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalContextTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalContextTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalContextTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalContextTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Windows.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Windows.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Windows.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Windows.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalRegistrationTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PosixSignalRegistrationTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PrimaryInteropAssemblyAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PrimaryInteropAssemblyAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PrimaryInteropAssemblyAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/PrimaryInteropAssemblyAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ProgIdAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ProgIdAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ProgIdAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ProgIdAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/RuntimeEnvironmentTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/RuntimeEnvironmentTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/RuntimeEnvironmentTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/RuntimeEnvironmentTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/SafeBufferTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/SafeBufferTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/SafeBufferTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/SafeBufferTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/StructLayoutAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/StructLayoutAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/StructLayoutAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/StructLayoutAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeIdentifierAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeIdentifierAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeIdentifierAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeIdentifierAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibFuncAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibFuncAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibFuncAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibFuncAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibImportClassAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibImportClassAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibImportClassAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibImportClassAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibTypeAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibTypeAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibTypeAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibTypeAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibVarAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibVarAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibVarAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibVarAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibVersionAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibVersionAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/TypeLibVersionAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/TypeLibVersionAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/UnknownWrapperTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/UnknownWrapperTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/UnknownWrapperTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/UnknownWrapperTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/UnmanagedFunctionPointerAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/UnmanagedFunctionPointerAttributeTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/UnmanagedFunctionPointerAttributeTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/UnmanagedFunctionPointerAttributeTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/VariantWrapperTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/VariantWrapperTests.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/VariantWrapperTests.cs rename to src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/VariantWrapperTests.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props index 76d5ca907662f..90c7da2a4a1f0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/Directory.Build.props @@ -1,6 +1,7 @@ + - false + true - \ No newline at end of file + diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 84af876234cf0..00a8f53fd133b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -2,7 +2,7 @@ Microsoft.Interop.Tests.NativeExports - net6.0 + $(NetCoreAppCurrent) true true true diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj index d1c676b06d7ee..d04a12ecddd30 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/SharedTypes.csproj @@ -1,7 +1,7 @@ - net6.0 + $(NetCoreAppCurrent) true diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index 1ffe230ada81c..f42621f44c254 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + $(NetCoreAppCurrent) true preview enable @@ -10,14 +10,14 @@ true + true + false false - - - - + + From 27034bc84b3ffb7f311425fee03ebb24fee55e82 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 Sep 2021 11:11:06 -0700 Subject: [PATCH 145/161] Run slngen to regenerate the solution files. --- src/libraries/Common/Common.Tests.sln | 14 ++ .../Microsoft.Extensions.Caching.Memory.sln | 14 ++ ...icrosoft.Extensions.Configuration.Json.sln | 14 ++ ...t.Extensions.Configuration.UserSecrets.sln | 14 ++ ...Microsoft.Extensions.Configuration.Xml.sln | 56 ----- .../Microsoft.Extensions.Configuration.sln | 70 ++---- .../Microsoft.Extensions.DependencyModel.sln | 14 ++ .../Microsoft.Extensions.Hosting.Systemd.sln | 28 +++ .../NuGet.config | 12 - ...oft.Extensions.Hosting.WindowsServices.sln | 28 +++ .../Microsoft.Extensions.Hosting.sln | 28 +++ .../Microsoft.Extensions.Hosting/NuGet.config | 12 - .../Microsoft.Extensions.Http.sln | 14 ++ ...rosoft.Extensions.Logging.Abstractions.sln | 48 ++-- ...osoft.Extensions.Logging.Configuration.sln | 14 ++ .../Microsoft.Extensions.Logging.Console.sln | 28 +++ .../Microsoft.Extensions.Logging.Debug.sln | 14 ++ .../Microsoft.Extensions.Logging.EventLog.sln | 14 ++ .../NuGet.config | 12 - ...crosoft.Extensions.Logging.EventSource.sln | 28 +++ ...crosoft.Extensions.Logging.TraceSource.sln | 14 ++ .../Microsoft.Extensions.Logging.sln | 28 +++ .../Microsoft.Extensions.Logging/NuGet.config | 12 - .../Microsoft.Extensions.Options.sln | 28 +++ .../Microsoft.Extensions.Options/NuGet.config | 12 - .../Microsoft.VisualBasic.Core.sln | 7 - .../Microsoft.Win32.Primitives.sln | 42 ++++ ...Microsoft.Win32.Registry.AccessControl.sln | 7 - .../Microsoft.Win32.Registry.sln | 7 - .../Microsoft.Win32.SystemEvents/NuGet.config | 12 - .../System.AppContext/System.AppContext.sln | 42 ++++ .../System.Buffers/System.Buffers.sln | 42 ++++ .../System.Collections.Concurrent.sln | 42 ++++ .../System.Collections/System.Collections.sln | 42 ++++ .../System.Console/System.Console.sln | 14 ++ .../System.Data.Common/System.Data.Common.sln | 42 ++++ .../System.Diagnostics.Contracts.sln | 42 ++++ .../System.Diagnostics.Debug.sln | 42 ++++ .../System.Diagnostics.EventLog/NuGet.config | 12 - .../System.Diagnostics.FileVersionInfo.sln | 14 ++ .../System.Diagnostics.Process/NuGet.config | 12 - .../System.Diagnostics.Process.sln | 21 +- .../System.Diagnostics.StackTrace.sln | 42 ++++ .../System.Diagnostics.Tools.sln | 42 ++++ .../System.Diagnostics.TraceSource.sln | 42 ++++ .../System.Diagnostics.Tracing.sln | 42 ++++ .../NuGet.config | 12 - .../System.DirectoryServices/NuGet.config | 12 - .../System.Drawing.Common/NuGet.config | 12 - .../System.Drawing.Primitives/NuGet.config | 12 - .../System.Globalization.Calendars.sln | 42 ++++ .../System.Globalization.sln | 42 ++++ .../System.IO.Compression.Brotli.sln | 14 ++ .../System.IO.Compression.ZipFile.sln | 14 ++ .../System.IO.Compression.sln | 14 ++ .../NuGet.config | 12 - .../System.IO.FileSystem.DriveInfo.sln | 14 ++ .../System.IO.FileSystem.Watcher.sln | 14 ++ .../System.IO.FileSystem.sln | 14 ++ .../System.IO.IsolatedStorage/NuGet.config | 12 - .../System.IO.MemoryMappedFiles.sln | 14 ++ .../System.IO.Pipes.AccessControl.sln | 21 +- .../System.IO.Pipes/System.IO.Pipes.sln | 14 ++ .../System.IO.UnmanagedMemoryStream.sln | 42 ++++ src/libraries/System.Management/NuGet.config | 12 - .../System.Memory.Data/System.Memory.Data.sln | 14 ++ src/libraries/System.Memory/System.Memory.sln | 42 ++++ .../System.Net.Http.Json.sln | 14 ++ .../System.Net.Http.WinHttpHandler.sln | 14 ++ src/libraries/System.Net.Http/NuGet.config | 12 - .../System.Net.Http/System.Net.Http.sln | 14 ++ .../System.Net.HttpListener.sln | 14 ++ .../System.Net.Mail/System.Net.Mail.sln | 14 ++ .../System.Net.NameResolution.sln | 14 ++ .../System.Net.NetworkInformation.sln | 14 ++ .../System.Net.Ping/System.Net.Ping.sln | 14 ++ .../System.Net.Primitives.sln | 14 ++ .../System.Net.Quic/System.Net.Quic.sln | 14 ++ .../System.Net.Security.sln | 14 ++ .../System.Net.Sockets/System.Net.Sockets.sln | 14 ++ .../System.Net.WebSockets.Client.sln | 14 ++ .../System.Numerics.Vectors.sln | 42 ++++ ...ate.Runtime.InteropServices.JavaScript.sln | 14 ++ .../System.Private.Uri/System.Private.Uri.sln | 42 ++++ .../System.Private.Xml.Linq.sln | 14 ++ .../System.Private.Xml/System.Private.Xml.sln | 14 ++ .../System.Reflection.Emit.ILGeneration.sln | 42 ++++ .../System.Reflection.Emit.Lightweight.sln | 42 ++++ .../System.Reflection.Emit.sln | 42 ++++ .../System.Reflection.Primitives.sln | 42 ++++ .../System.Reflection.TypeExtensions.sln | 42 ++++ .../System.Reflection/System.Reflection.sln | 42 ++++ .../System.Resources.Extensions/NuGet.config | 12 - .../NuGet.config | 12 - .../System.Resources.ResourceManager.sln | 42 ++++ .../System.Runtime.Extensions.sln | 42 ++++ ...ime.InteropServices.RuntimeInformation.sln | 14 ++ .../System.Runtime.InteropServices.sln | 227 +++++++++++++++--- .../System.Runtime.Intrinsics.sln | 42 ++++ .../System.Runtime.Loader.sln | 42 ++++ ...ystem.Runtime.Serialization.Formatters.sln | 42 ++++ .../System.Runtime/System.Runtime.sln | 42 ++++ ...ystem.Security.Cryptography.Algorithms.sln | 14 ++ .../System.Security.Cryptography.Cng.sln | 14 ++ .../System.Security.Cryptography.Csp.sln | 14 ++ .../System.Security.Cryptography.Encoding.sln | 14 ++ .../System.Security.Cryptography.OpenSsl.sln | 14 ++ .../System.Security.Cryptography.Pkcs.sln | 14 ++ ...Security.Cryptography.X509Certificates.sln | 14 ++ .../System.Security.Cryptography.Xml.sln | 56 ----- .../System.Security.Permissions/NuGet.config | 12 - .../System.Security.Principal.sln | 42 ++++ src/libraries/System.Speech/NuGet.config | 12 - .../System.Text.Encoding.Extensions.sln | 42 ++++ .../System.Text.Encoding.sln | 42 ++++ .../System.Text.Json/System.Text.Json.sln | 62 ++--- .../System.Threading.Overlapped.sln | 42 ++++ .../System.Threading.Tasks.Extensions.sln | 42 ++++ .../System.Threading.Tasks.sln | 42 ++++ .../System.Threading.Thread.sln | 42 ++++ .../System.Threading.ThreadPool.sln | 42 ++++ .../System.Threading.Timer.sln | 42 ++++ .../System.Threading/System.Threading.sln | 42 ++++ .../System.Windows.Extensions/NuGet.config | 12 - .../System.Xml.ReaderWriter.sln | 14 ++ .../System.Xml.XDocument.sln | 14 ++ .../System.Xml.XPath.XDocument.sln | 14 ++ .../System.Xml.XPath/System.Xml.XPath.sln | 14 ++ .../System.Xml.XmlDocument.sln | 14 ++ .../System.Xml.XmlSerializer.sln | 14 ++ 130 files changed, 2874 insertions(+), 550 deletions(-) delete mode 100644 src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config delete mode 100644 src/libraries/Microsoft.Extensions.Hosting/NuGet.config delete mode 100644 src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config delete mode 100644 src/libraries/Microsoft.Extensions.Logging/NuGet.config delete mode 100644 src/libraries/Microsoft.Extensions.Options/NuGet.config delete mode 100644 src/libraries/Microsoft.Win32.SystemEvents/NuGet.config delete mode 100644 src/libraries/System.Diagnostics.EventLog/NuGet.config delete mode 100644 src/libraries/System.Diagnostics.Process/NuGet.config delete mode 100644 src/libraries/System.DirectoryServices.Protocols/NuGet.config delete mode 100644 src/libraries/System.DirectoryServices/NuGet.config delete mode 100644 src/libraries/System.Drawing.Common/NuGet.config delete mode 100644 src/libraries/System.Drawing.Primitives/NuGet.config delete mode 100644 src/libraries/System.IO.FileSystem.AccessControl/NuGet.config delete mode 100644 src/libraries/System.IO.IsolatedStorage/NuGet.config delete mode 100644 src/libraries/System.Management/NuGet.config delete mode 100644 src/libraries/System.Net.Http/NuGet.config delete mode 100644 src/libraries/System.Resources.Extensions/NuGet.config delete mode 100644 src/libraries/System.Resources.ResourceManager/NuGet.config delete mode 100644 src/libraries/System.Security.Permissions/NuGet.config delete mode 100644 src/libraries/System.Speech/NuGet.config delete mode 100644 src/libraries/System.Windows.Extensions/NuGet.config diff --git a/src/libraries/Common/Common.Tests.sln b/src/libraries/Common/Common.Tests.sln index 23a9677e3b662..0f7bc6f329113 100644 --- a/src/libraries/Common/Common.Tests.sln +++ b/src/libraries/Common/Common.Tests.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2141FEEA-0422-4319-B88D-DA15CBD77599}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{0B795514-370A-4242-8810-DDD94E92877C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B0FE807A-573F-4DFB-94BE-AAB19AD31292}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F81003B8-54C4-42B1-AD93-255B62E9DC55}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A97E6A4A-8C69-4839-B3C5-3C7A716AC70A}" @@ -41,6 +45,14 @@ Global {2141FEEA-0422-4319-B88D-DA15CBD77599}.Debug|Any CPU.Build.0 = Debug|Any CPU {2141FEEA-0422-4319-B88D-DA15CBD77599}.Release|Any CPU.ActiveCfg = Release|Any CPU {2141FEEA-0422-4319-B88D-DA15CBD77599}.Release|Any CPU.Build.0 = Release|Any CPU + {0B795514-370A-4242-8810-DDD94E92877C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B795514-370A-4242-8810-DDD94E92877C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B795514-370A-4242-8810-DDD94E92877C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B795514-370A-4242-8810-DDD94E92877C}.Release|Any CPU.Build.0 = Release|Any CPU + {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -51,6 +63,8 @@ Global {10215DC2-1255-4B60-B0AC-D8B09BCEA179} = {F81003B8-54C4-42B1-AD93-255B62E9DC55} {A0A180C4-8292-45EE-A4B9-0A359BC9C2FC} = {A97E6A4A-8C69-4839-B3C5-3C7A716AC70A} {2141FEEA-0422-4319-B88D-DA15CBD77599} = {056FFC76-3DAC-4C6C-8E96-303B403EB50B} + {0B795514-370A-4242-8810-DDD94E92877C} = {056FFC76-3DAC-4C6C-8E96-303B403EB50B} + {B0FE807A-573F-4DFB-94BE-AAB19AD31292} = {056FFC76-3DAC-4C6C-8E96-303B403EB50B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4543E82B-8616-438A-B58B-EE47079D6956} diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln b/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln index c16865355e47c..68cc71d9e374b 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln @@ -23,6 +23,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{78971B06-2519-45B7-B761-C8A30C168EBE}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{3FCCE62E-3EE0-4629-B018-2B653DF43A62}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{C76753D0-F564-45E9-AA60-A846EFE0A414}" @@ -99,6 +103,14 @@ Global {78971B06-2519-45B7-B761-C8A30C168EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {78971B06-2519-45B7-B761-C8A30C168EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {78971B06-2519-45B7-B761-C8A30C168EBE}.Release|Any CPU.Build.0 = Release|Any CPU + {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Release|Any CPU.Build.0 = Release|Any CPU + {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Release|Any CPU.Build.0 = Release|Any CPU {BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}.Debug|Any CPU.Build.0 = Debug|Any CPU {BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -152,6 +164,8 @@ Global {CD3D6F5B-0500-4035-A60A-592A2E231011} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {9A8C0B86-1CA3-4FFE-86FC-9EF0A733BEC0} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {78971B06-2519-45B7-B761-C8A30C168EBE} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} + {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} + {3FCCE62E-3EE0-4629-B018-2B653DF43A62} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {C76753D0-F564-45E9-AA60-A846EFE0A414} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {5A9310B4-82AB-46F8-83C1-72D21A6A761F} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {DA43AA92-35BA-4B84-BAA2-C3BB56C8BB3B} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} diff --git a/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln b/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln index adac4faa2384b..d8cc52a78a485 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln +++ b/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln @@ -51,6 +51,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{BD19B1E7-CAFF-4009-874A-760D5A466E28}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{6EB2865B-C9F6-4F9B-82DA-4C577587B577}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{A49023C8-173A-4B8F-84B3-2FF37FE8344A}" @@ -171,6 +175,14 @@ Global {BD19B1E7-CAFF-4009-874A-760D5A466E28}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD19B1E7-CAFF-4009-874A-760D5A466E28}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD19B1E7-CAFF-4009-874A-760D5A466E28}.Release|Any CPU.Build.0 = Release|Any CPU + {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Release|Any CPU.Build.0 = Release|Any CPU + {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Release|Any CPU.Build.0 = Release|Any CPU {6EB2865B-C9F6-4F9B-82DA-4C577587B577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EB2865B-C9F6-4F9B-82DA-4C577587B577}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EB2865B-C9F6-4F9B-82DA-4C577587B577}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -211,6 +223,8 @@ Global {B1723D4C-15E3-4A39-8976-C3E1740E5F00} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} {7517D0A0-5596-48B7-96EF-CB24DAD72675} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} {BD19B1E7-CAFF-4009-874A-760D5A466E28} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} + {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} + {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} {A49023C8-173A-4B8F-84B3-2FF37FE8344A} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln index 829b1febeb55b..e48a8b06647d9 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln @@ -51,6 +51,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{1555B38A-E9CB-4734-AAB1-59CFB833A06D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{D541ED18-720A-47E8-82F8-7B994EB408A3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{705F880D-3E27-4ACA-87CC-808BB7DDA610}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{82700778-D9AD-4B9D-8A1C-CDC1A19E4D54}" @@ -171,6 +175,14 @@ Global {1555B38A-E9CB-4734-AAB1-59CFB833A06D}.Debug|Any CPU.Build.0 = Debug|Any CPU {1555B38A-E9CB-4734-AAB1-59CFB833A06D}.Release|Any CPU.ActiveCfg = Release|Any CPU {1555B38A-E9CB-4734-AAB1-59CFB833A06D}.Release|Any CPU.Build.0 = Release|Any CPU + {D541ED18-720A-47E8-82F8-7B994EB408A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D541ED18-720A-47E8-82F8-7B994EB408A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D541ED18-720A-47E8-82F8-7B994EB408A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D541ED18-720A-47E8-82F8-7B994EB408A3}.Release|Any CPU.Build.0 = Release|Any CPU + {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Release|Any CPU.Build.0 = Release|Any CPU {705F880D-3E27-4ACA-87CC-808BB7DDA610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {705F880D-3E27-4ACA-87CC-808BB7DDA610}.Debug|Any CPU.Build.0 = Debug|Any CPU {705F880D-3E27-4ACA-87CC-808BB7DDA610}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -211,6 +223,8 @@ Global {BD85452C-1434-40FF-8A2C-36BF135A22FE} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} {1EF04395-4D84-43F1-BD99-7F6D6C3D70BB} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} {1555B38A-E9CB-4734-AAB1-59CFB833A06D} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} + {D541ED18-720A-47E8-82F8-7B994EB408A3} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} + {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} {82700778-D9AD-4B9D-8A1C-CDC1A19E4D54} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln b/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln index 16bd8851fe576..c395b07245135 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln @@ -39,14 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primit EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primitives", "..\Microsoft.Extensions.Primitives\src\Microsoft.Extensions.Primitives.csproj", "{26C61EB7-2798-4314-B750-8CD2837D4216}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{7A133F28-55F2-4143-8529-6DC7E994D852}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{1AE88632-F602-4B2F-A269-A7631A361FA7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{83270DD0-3E9F-460B-8EAA-4F33A6EB9025}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\ref\System.Formats.Asn1.csproj", "{F7D18116-335D-4CE6-980A-3330AAD05507}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\src\System.Formats.Asn1.csproj", "{84E43ED2-A2ED-49F9-B592-92270F0F2EC3}" @@ -63,14 +55,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptograph EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Xml", "..\System.Security.Cryptography.Xml\src\System.Security.Cryptography.Xml.csproj", "{8CBDDA63-8388-42AF-934E-7C60832A9B1C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{00C86D9C-1A45-49C7-91E6-24BBBF8950CB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{B25AD126-F78D-45CC-AD06-6F1E03D570DA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{00DA7CF9-86B4-4991-B760-CB3AAB31EED0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{C77305BE-823E-487F-825E-9C26E0674CC6}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AC596411-85F4-49FD-8A23-BE2983825CF1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{AB0BAC3A-1FE6-4649-83DF-DC165669C74F}" @@ -163,22 +147,6 @@ Global {26C61EB7-2798-4314-B750-8CD2837D4216}.Debug|Any CPU.Build.0 = Debug|Any CPU {26C61EB7-2798-4314-B750-8CD2837D4216}.Release|Any CPU.ActiveCfg = Release|Any CPU {26C61EB7-2798-4314-B750-8CD2837D4216}.Release|Any CPU.Build.0 = Release|Any CPU - {7A133F28-55F2-4143-8529-6DC7E994D852}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A133F28-55F2-4143-8529-6DC7E994D852}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A133F28-55F2-4143-8529-6DC7E994D852}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A133F28-55F2-4143-8529-6DC7E994D852}.Release|Any CPU.Build.0 = Release|Any CPU - {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Release|Any CPU.Build.0 = Release|Any CPU - {1AE88632-F602-4B2F-A269-A7631A361FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1AE88632-F602-4B2F-A269-A7631A361FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1AE88632-F602-4B2F-A269-A7631A361FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1AE88632-F602-4B2F-A269-A7631A361FA7}.Release|Any CPU.Build.0 = Release|Any CPU - {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Release|Any CPU.Build.0 = Release|Any CPU {F7D18116-335D-4CE6-980A-3330AAD05507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F7D18116-335D-4CE6-980A-3330AAD05507}.Debug|Any CPU.Build.0 = Debug|Any CPU {F7D18116-335D-4CE6-980A-3330AAD05507}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -211,22 +179,6 @@ Global {8CBDDA63-8388-42AF-934E-7C60832A9B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CBDDA63-8388-42AF-934E-7C60832A9B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CBDDA63-8388-42AF-934E-7C60832A9B1C}.Release|Any CPU.Build.0 = Release|Any CPU - {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Release|Any CPU.Build.0 = Release|Any CPU - {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Release|Any CPU.Build.0 = Release|Any CPU - {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Release|Any CPU.Build.0 = Release|Any CPU - {C77305BE-823E-487F-825E-9C26E0674CC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C77305BE-823E-487F-825E-9C26E0674CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C77305BE-823E-487F-825E-9C26E0674CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C77305BE-823E-487F-825E-9C26E0674CC6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -243,14 +195,10 @@ Global {600CBFCA-5F97-47EE-8AE9-B6262E1A764B} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {981358A2-F5ED-45CE-B037-446BB0F4E859} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {4039B868-612D-420F-BC25-481660475CA8} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} - {7A133F28-55F2-4143-8529-6DC7E994D852} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} - {1AE88632-F602-4B2F-A269-A7631A361FA7} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {F7D18116-335D-4CE6-980A-3330AAD05507} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {78F4F9EE-7E1D-41B5-B55A-850C1282EA99} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {91F63A74-902E-44DF-8A78-FD74D030E619} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {A3C9F01C-6D4D-413B-BADE-A8B9046F985F} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} - {00C86D9C-1A45-49C7-91E6-24BBBF8950CB} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} - {00DA7CF9-86B4-4991-B760-CB3AAB31EED0} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {9C73A2E3-B370-4B24-ACB0-0C3A9069250D} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {21E44CA2-5355-4092-9EF7-A94520EBDD40} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {EFC0C2A3-1F51-4299-BE43-78284F6AC670} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} @@ -260,14 +208,10 @@ Global {03A8EBF2-F912-480F-99E1-34A9A33DD525} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {6824AD93-4154-4710-A018-81DA1FA98C40} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {26C61EB7-2798-4314-B750-8CD2837D4216} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} - {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} - {83270DD0-3E9F-460B-8EAA-4F33A6EB9025} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {84E43ED2-A2ED-49F9-B592-92270F0F2EC3} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {5B866430-6F0B-49F1-8294-7B07F766797A} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {A00E22C3-A552-4F4C-AF2C-813B96A54582} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {8CBDDA63-8388-42AF-934E-7C60832A9B1C} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} - {B25AD126-F78D-45CC-AD06-6F1E03D570DA} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} - {C77305BE-823E-487F-825E-9C26E0674CC6} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {830494DE-07B3-4C63-9D74-4A123677D469} diff --git a/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln b/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln index e74c06668b9c6..ab806d3dffa45 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln +++ b/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln @@ -65,14 +65,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primit EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primitives", "..\Microsoft.Extensions.Primitives\src\Microsoft.Extensions.Primitives.csproj", "{165EBE5E-E512-4E7E-8C2D-1F4297483D3E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{52B5874C-5860-473C-9A7D-8F70C01A0EBF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{9DC9CC89-E2F2-41F6-8684-81AA41B469FF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{38313D23-EB52-423C-9369-42995954CFCA}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\ref\System.Formats.Asn1.csproj", "{AA6BA95D-613F-4878-BF58-409A78FC3D1B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\src\System.Formats.Asn1.csproj", "{F50B881E-8A70-48C3-80B0-2094F6868974}" @@ -89,21 +81,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptograph EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Xml", "..\System.Security.Cryptography.Xml\src\System.Security.Cryptography.Xml.csproj", "{BAA953EF-6529-4F2C-8F89-C76A05258677}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{E2181F3B-BDC4-4373-9DA8-F3B50159C65E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{6CCBE9AB-E620-4616-9B80-1F9D3E722B87}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\ref\System.Text.Encodings.Web.csproj", "{39AA6ECB-A46E-47B8-A90B-286C1C59D962}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{23F4102D-67BD-4865-BB19-195C47945733}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{D8E6322D-6862-469C-9617-F3D423E4944B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{41234DB5-1F3A-4E4A-8BD9-4A277C249666}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{C4B32219-B834-46A9-9756-F624DDF4346D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{6CDFD705-28EC-4D58-A2F9-715A3B06661B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{41234DB5-1F3A-4E4A-8BD9-4A277C249666}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CEC96DEF-9D43-4EFC-962B-B4F80EFA5C78}" EndProject @@ -249,22 +237,6 @@ Global {165EBE5E-E512-4E7E-8C2D-1F4297483D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU {165EBE5E-E512-4E7E-8C2D-1F4297483D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU {165EBE5E-E512-4E7E-8C2D-1F4297483D3E}.Release|Any CPU.Build.0 = Release|Any CPU - {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Release|Any CPU.Build.0 = Release|Any CPU - {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Release|Any CPU.Build.0 = Release|Any CPU - {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Release|Any CPU.Build.0 = Release|Any CPU - {38313D23-EB52-423C-9369-42995954CFCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {38313D23-EB52-423C-9369-42995954CFCA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {38313D23-EB52-423C-9369-42995954CFCA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {38313D23-EB52-423C-9369-42995954CFCA}.Release|Any CPU.Build.0 = Release|Any CPU {AA6BA95D-613F-4878-BF58-409A78FC3D1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA6BA95D-613F-4878-BF58-409A78FC3D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA6BA95D-613F-4878-BF58-409A78FC3D1B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -297,14 +269,6 @@ Global {BAA953EF-6529-4F2C-8F89-C76A05258677}.Debug|Any CPU.Build.0 = Debug|Any CPU {BAA953EF-6529-4F2C-8F89-C76A05258677}.Release|Any CPU.ActiveCfg = Release|Any CPU {BAA953EF-6529-4F2C-8F89-C76A05258677}.Release|Any CPU.Build.0 = Release|Any CPU - {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Release|Any CPU.Build.0 = Release|Any CPU - {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Release|Any CPU.Build.0 = Release|Any CPU {39AA6ECB-A46E-47B8-A90B-286C1C59D962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {39AA6ECB-A46E-47B8-A90B-286C1C59D962}.Debug|Any CPU.Build.0 = Debug|Any CPU {39AA6ECB-A46E-47B8-A90B-286C1C59D962}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -313,6 +277,14 @@ Global {23F4102D-67BD-4865-BB19-195C47945733}.Debug|Any CPU.Build.0 = Debug|Any CPU {23F4102D-67BD-4865-BB19-195C47945733}.Release|Any CPU.ActiveCfg = Release|Any CPU {23F4102D-67BD-4865-BB19-195C47945733}.Release|Any CPU.Build.0 = Release|Any CPU + {D8E6322D-6862-469C-9617-F3D423E4944B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8E6322D-6862-469C-9617-F3D423E4944B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8E6322D-6862-469C-9617-F3D423E4944B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8E6322D-6862-469C-9617-F3D423E4944B}.Release|Any CPU.Build.0 = Release|Any CPU + {C4B32219-B834-46A9-9756-F624DDF4346D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4B32219-B834-46A9-9756-F624DDF4346D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4B32219-B834-46A9-9756-F624DDF4346D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4B32219-B834-46A9-9756-F624DDF4346D}.Release|Any CPU.Build.0 = Release|Any CPU {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}.Debug|Any CPU.Build.0 = Debug|Any CPU {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -321,14 +293,6 @@ Global {41234DB5-1F3A-4E4A-8BD9-4A277C249666}.Debug|Any CPU.Build.0 = Debug|Any CPU {41234DB5-1F3A-4E4A-8BD9-4A277C249666}.Release|Any CPU.ActiveCfg = Release|Any CPU {41234DB5-1F3A-4E4A-8BD9-4A277C249666}.Release|Any CPU.Build.0 = Release|Any CPU - {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Release|Any CPU.Build.0 = Release|Any CPU - {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -352,16 +316,12 @@ Global {53E4909F-FC0B-4727-A73D-686C5115E8C9} = {DC224BF8-12E5-4992-B750-B12011238C26} {F4B7B95E-F732-474A-BED7-782AD2F4A1A4} = {DC224BF8-12E5-4992-B750-B12011238C26} {EC8DB110-890E-4388-97FC-0E25D98BC6F4} = {DC224BF8-12E5-4992-B750-B12011238C26} - {52B5874C-5860-473C-9A7D-8F70C01A0EBF} = {DC224BF8-12E5-4992-B750-B12011238C26} - {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74} = {DC224BF8-12E5-4992-B750-B12011238C26} {AA6BA95D-613F-4878-BF58-409A78FC3D1B} = {DC224BF8-12E5-4992-B750-B12011238C26} {5D0D6749-312A-4400-89D8-A7252D9A879B} = {DC224BF8-12E5-4992-B750-B12011238C26} {8EA7F25A-0748-4EF4-ABE8-67688B646D47} = {DC224BF8-12E5-4992-B750-B12011238C26} {F74DB3B7-243F-447D-AE39-672348F661A1} = {DC224BF8-12E5-4992-B750-B12011238C26} - {E2181F3B-BDC4-4373-9DA8-F3B50159C65E} = {DC224BF8-12E5-4992-B750-B12011238C26} {39AA6ECB-A46E-47B8-A90B-286C1C59D962} = {DC224BF8-12E5-4992-B750-B12011238C26} {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D} = {DC224BF8-12E5-4992-B750-B12011238C26} - {6CDFD705-28EC-4D58-A2F9-715A3B06661B} = {DC224BF8-12E5-4992-B750-B12011238C26} {CDC60461-56B7-4941-AD08-90228BD450CE} = {76107BEB-02C0-4A83-9631-B226340752A7} {9AF25AFA-6E25-4CA1-AD4F-FF77FD771714} = {76107BEB-02C0-4A83-9631-B226340752A7} {71F50A26-C4A8-4142-B0FD-E5D9EFEF34A1} = {76107BEB-02C0-4A83-9631-B226340752A7} @@ -377,16 +337,14 @@ Global {42C10152-F747-443F-9AC1-5738CB62EA6C} = {76107BEB-02C0-4A83-9631-B226340752A7} {8F65DFBB-9196-4E69-879A-C99C641B3E49} = {76107BEB-02C0-4A83-9631-B226340752A7} {165EBE5E-E512-4E7E-8C2D-1F4297483D3E} = {76107BEB-02C0-4A83-9631-B226340752A7} - {9DC9CC89-E2F2-41F6-8684-81AA41B469FF} = {76107BEB-02C0-4A83-9631-B226340752A7} - {38313D23-EB52-423C-9369-42995954CFCA} = {76107BEB-02C0-4A83-9631-B226340752A7} {F50B881E-8A70-48C3-80B0-2094F6868974} = {76107BEB-02C0-4A83-9631-B226340752A7} {75A03875-DC97-42AE-9EFE-78DC736B8BD6} = {76107BEB-02C0-4A83-9631-B226340752A7} {95FB3CCD-3174-4BAA-8BF6-67E0A16B8965} = {76107BEB-02C0-4A83-9631-B226340752A7} {BAA953EF-6529-4F2C-8F89-C76A05258677} = {76107BEB-02C0-4A83-9631-B226340752A7} - {6CCBE9AB-E620-4616-9B80-1F9D3E722B87} = {76107BEB-02C0-4A83-9631-B226340752A7} {23F4102D-67BD-4865-BB19-195C47945733} = {76107BEB-02C0-4A83-9631-B226340752A7} + {D8E6322D-6862-469C-9617-F3D423E4944B} = {76107BEB-02C0-4A83-9631-B226340752A7} + {C4B32219-B834-46A9-9756-F624DDF4346D} = {76107BEB-02C0-4A83-9631-B226340752A7} {41234DB5-1F3A-4E4A-8BD9-4A277C249666} = {76107BEB-02C0-4A83-9631-B226340752A7} - {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0} = {76107BEB-02C0-4A83-9631-B226340752A7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {81EEF2A5-6387-4CC4-B7CD-908EEA4E5C79} diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln b/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln index dd011a00b411a..5752a958a3479 100644 --- a/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln +++ b/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln @@ -21,6 +21,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{7902A0CA-E94D-4C96-A112-455A1E5E2390}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{613D2C4B-4D2C-4036-A673-6B7FF25E4699}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{8F58A0B7-0F39-4E2B-A6E9-3030728E4426}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{8E212A9D-391B-4EFA-943D-7D104A9D3D7E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{FA7201FE-097D-4197-BDEC-329986814D8D}" @@ -81,6 +85,14 @@ Global {7902A0CA-E94D-4C96-A112-455A1E5E2390}.Debug|Any CPU.Build.0 = Debug|Any CPU {7902A0CA-E94D-4C96-A112-455A1E5E2390}.Release|Any CPU.ActiveCfg = Release|Any CPU {7902A0CA-E94D-4C96-A112-455A1E5E2390}.Release|Any CPU.Build.0 = Release|Any CPU + {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Debug|Any CPU.Build.0 = Debug|Any CPU + {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Release|Any CPU.ActiveCfg = Release|Any CPU + {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Release|Any CPU.Build.0 = Release|Any CPU + {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Release|Any CPU.Build.0 = Release|Any CPU {8E212A9D-391B-4EFA-943D-7D104A9D3D7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E212A9D-391B-4EFA-943D-7D104A9D3D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E212A9D-391B-4EFA-943D-7D104A9D3D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -106,6 +118,8 @@ Global {5C580568-6072-4F27-B5C6-FA04556E3B98} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} {4A28B457-D950-486B-B59B-A4C977A733B1} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} {7902A0CA-E94D-4C96-A112-455A1E5E2390} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} + {613D2C4B-4D2C-4036-A673-6B7FF25E4699} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} + {8F58A0B7-0F39-4E2B-A6E9-3030728E4426} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} {FA7201FE-097D-4197-BDEC-329986814D8D} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln index 2c41ba20253e6..e1a1394f225f0 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln @@ -71,6 +71,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting", "..\Microsoft.Extensions.Hosting\src\Microsoft.Extensions.Hosting.csproj", "{AFC1BDAA-7E40-4118-BB80-F8057752A600}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{FAE962EE-A0E7-4411-8ECF-57669E39B07C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{860B845B-929F-4442-AED1-1F4186DBF497}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{A0AF82AE-ED18-4EEB-AD9A-B44017510F0C}" @@ -133,6 +137,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{E282BA2D-9D71-4DFB-B757-50731B8922D0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{7F1D776F-A653-4FE4-BBA4-ECE38192832A}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{AA2CD494-414F-42BF-9C68-7822DEB09255}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{25474DE2-4D3D-4950-BDA7-CF6FE3CCD940}" @@ -295,6 +303,14 @@ Global {AFC1BDAA-7E40-4118-BB80-F8057752A600}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFC1BDAA-7E40-4118-BB80-F8057752A600}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFC1BDAA-7E40-4118-BB80-F8057752A600}.Release|Any CPU.Build.0 = Release|Any CPU + {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Release|Any CPU.Build.0 = Release|Any CPU + {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Release|Any CPU.Build.0 = Release|Any CPU {860B845B-929F-4442-AED1-1F4186DBF497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {860B845B-929F-4442-AED1-1F4186DBF497}.Debug|Any CPU.Build.0 = Debug|Any CPU {860B845B-929F-4442-AED1-1F4186DBF497}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -419,6 +435,14 @@ Global {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}.Release|Any CPU.Build.0 = Release|Any CPU + {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Release|Any CPU.Build.0 = Release|Any CPU + {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Release|Any CPU.Build.0 = Release|Any CPU {AA2CD494-414F-42BF-9C68-7822DEB09255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA2CD494-414F-42BF-9C68-7822DEB09255}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA2CD494-414F-42BF-9C68-7822DEB09255}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -490,6 +514,8 @@ Global {4B72FC27-F786-44B4-88DF-996D478873B8} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {CFF29AA4-794A-416B-BF4C-FD2A442FB83F} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {AFC1BDAA-7E40-4118-BB80-F8057752A600} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} + {FAE962EE-A0E7-4411-8ECF-57669E39B07C} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} + {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {A0AF82AE-ED18-4EEB-AD9A-B44017510F0C} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {D61B6530-0055-4DFE-85D1-58BEDFC7AA2F} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {509B5AB4-8F9F-4856-811F-7C8E727BF2E6} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} @@ -505,6 +531,8 @@ Global {578661A4-C136-4533-819E-AF3352F79953} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {E1053E73-AB5D-4593-8E00-7E048C314A28} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} + {E282BA2D-9D71-4DFB-B757-50731B8922D0} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} + {7F1D776F-A653-4FE4-BBA4-ECE38192832A} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {25474DE2-4D3D-4950-BDA7-CF6FE3CCD940} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config b/src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln index 08a2b2bb2e83a..374c947fb7877 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln @@ -67,6 +67,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting", "..\Microsoft.Extensions.Hosting\src\Microsoft.Extensions.Hosting.csproj", "{36FAE390-EAAE-4193-98E7-34F10D3FA8E1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{498998A1-3AB9-4109-91A3-80917BF7107C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{B17D5318-2568-4898-8B86-27F63CEA025C}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{723957C4-C433-4B6D-BF0C-28AE36AEDDBD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{E5F61C36-FB9B-4DA7-96C0-056FBEADBB53}" @@ -133,6 +137,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{E45DC225-377C-4CDE-975D-15F9088562A3}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{C50BBD27-2445-4DF4-9A1D-C7919D016BBC}" @@ -285,6 +293,14 @@ Global {36FAE390-EAAE-4193-98E7-34F10D3FA8E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {36FAE390-EAAE-4193-98E7-34F10D3FA8E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {36FAE390-EAAE-4193-98E7-34F10D3FA8E1}.Release|Any CPU.Build.0 = Release|Any CPU + {498998A1-3AB9-4109-91A3-80917BF7107C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {498998A1-3AB9-4109-91A3-80917BF7107C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {498998A1-3AB9-4109-91A3-80917BF7107C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {498998A1-3AB9-4109-91A3-80917BF7107C}.Release|Any CPU.Build.0 = Release|Any CPU + {B17D5318-2568-4898-8B86-27F63CEA025C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B17D5318-2568-4898-8B86-27F63CEA025C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B17D5318-2568-4898-8B86-27F63CEA025C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B17D5318-2568-4898-8B86-27F63CEA025C}.Release|Any CPU.Build.0 = Release|Any CPU {723957C4-C433-4B6D-BF0C-28AE36AEDDBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {723957C4-C433-4B6D-BF0C-28AE36AEDDBD}.Debug|Any CPU.Build.0 = Debug|Any CPU {723957C4-C433-4B6D-BF0C-28AE36AEDDBD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -417,6 +433,14 @@ Global {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}.Release|Any CPU.Build.0 = Release|Any CPU + {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Release|Any CPU.Build.0 = Release|Any CPU + {E45DC225-377C-4CDE-975D-15F9088562A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E45DC225-377C-4CDE-975D-15F9088562A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E45DC225-377C-4CDE-975D-15F9088562A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E45DC225-377C-4CDE-975D-15F9088562A3}.Release|Any CPU.Build.0 = Release|Any CPU {35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -487,6 +511,8 @@ Global {FB7C602E-3ED6-472A-85BD-420B61BA293D} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {89A6E38E-1118-4FC6-957D-17751DAD8EAF} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {36FAE390-EAAE-4193-98E7-34F10D3FA8E1} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} + {498998A1-3AB9-4109-91A3-80917BF7107C} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} + {B17D5318-2568-4898-8B86-27F63CEA025C} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {E5F61C36-FB9B-4DA7-96C0-056FBEADBB53} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {B0D60DB8-2A4A-4B8B-83DF-A1C66BDD0982} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {C573763D-C24C-4222-AAF0-66B0C2260EB4} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} @@ -503,6 +529,8 @@ Global {78706510-4F89-4896-8E29-723C8F4B90AF} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {3636C4FF-4BBD-4BB8-B60B-E62F2C429EA4} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} + {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} + {E45DC225-377C-4CDE-975D-15F9088562A3} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {C50BBD27-2445-4DF4-9A1D-C7919D016BBC} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln b/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln index 9648a317d00cc..27f58cab19403 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln +++ b/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln @@ -71,6 +71,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting.Unit.Tests", "tests\UnitTests\Microsoft.Extensions.Hosting.Unit.Tests.csproj", "{33C3D8F0-297F-4471-92B0-F4E8717F10E3}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{185FEEC3-5178-4073-B014-F8EA85F464E1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{0B44803E-8F07-4174-9F78-630689EDE438}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{42E1BF94-6FE0-4017-9702-55913BD95EDE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{8845E6FF-94B2-4994-A8F4-DF30844A2168}" @@ -133,6 +137,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{B41AA17B-5129-41CC-8EA4-250B80BABF87}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{EFF1671F-7283-48A7-BF84-35359CE6079B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{562A8338-829C-46B8-9B72-75D44163DA36}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{0813853E-8C78-429A-B01A-3FB2EF1898F8}" @@ -295,6 +303,14 @@ Global {33C3D8F0-297F-4471-92B0-F4E8717F10E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {33C3D8F0-297F-4471-92B0-F4E8717F10E3}.Release|Any CPU.ActiveCfg = Release|Any CPU {33C3D8F0-297F-4471-92B0-F4E8717F10E3}.Release|Any CPU.Build.0 = Release|Any CPU + {185FEEC3-5178-4073-B014-F8EA85F464E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {185FEEC3-5178-4073-B014-F8EA85F464E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {185FEEC3-5178-4073-B014-F8EA85F464E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {185FEEC3-5178-4073-B014-F8EA85F464E1}.Release|Any CPU.Build.0 = Release|Any CPU + {0B44803E-8F07-4174-9F78-630689EDE438}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B44803E-8F07-4174-9F78-630689EDE438}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B44803E-8F07-4174-9F78-630689EDE438}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B44803E-8F07-4174-9F78-630689EDE438}.Release|Any CPU.Build.0 = Release|Any CPU {42E1BF94-6FE0-4017-9702-55913BD95EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {42E1BF94-6FE0-4017-9702-55913BD95EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU {42E1BF94-6FE0-4017-9702-55913BD95EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -419,6 +435,14 @@ Global {B41AA17B-5129-41CC-8EA4-250B80BABF87}.Debug|Any CPU.Build.0 = Debug|Any CPU {B41AA17B-5129-41CC-8EA4-250B80BABF87}.Release|Any CPU.ActiveCfg = Release|Any CPU {B41AA17B-5129-41CC-8EA4-250B80BABF87}.Release|Any CPU.Build.0 = Release|Any CPU + {EFF1671F-7283-48A7-BF84-35359CE6079B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EFF1671F-7283-48A7-BF84-35359CE6079B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EFF1671F-7283-48A7-BF84-35359CE6079B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EFF1671F-7283-48A7-BF84-35359CE6079B}.Release|Any CPU.Build.0 = Release|Any CPU + {562A8338-829C-46B8-9B72-75D44163DA36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {562A8338-829C-46B8-9B72-75D44163DA36}.Debug|Any CPU.Build.0 = Debug|Any CPU + {562A8338-829C-46B8-9B72-75D44163DA36}.Release|Any CPU.ActiveCfg = Release|Any CPU + {562A8338-829C-46B8-9B72-75D44163DA36}.Release|Any CPU.Build.0 = Release|Any CPU {1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}.Debug|Any CPU.Build.0 = Debug|Any CPU {1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -490,6 +514,8 @@ Global {9C06E60B-2D45-4284-B7C8-7AE6D8194CE0} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {973CE6DA-B55D-4E55-88D5-53BE69D44410} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {F5CF1FC4-8F56-49BD-BFC2-5AD42AE6302D} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} + {185FEEC3-5178-4073-B014-F8EA85F464E1} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} + {0B44803E-8F07-4174-9F78-630689EDE438} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {8845E6FF-94B2-4994-A8F4-DF30844A2168} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {99C8FB58-8718-4E76-AEFA-3C42F2F729B1} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {F3230087-28E2-4ADF-A7D1-D48C5D9CFFE9} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} @@ -505,6 +531,8 @@ Global {4ED9C0A9-C1EF-47ED-99F8-74B7411C971B} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {A9EFBE7D-6AE1-4F05-B9C5-2586835ADC4D} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {B41AA17B-5129-41CC-8EA4-250B80BABF87} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} + {EFF1671F-7283-48A7-BF84-35359CE6079B} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} + {562A8338-829C-46B8-9B72-75D44163DA36} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {0813853E-8C78-429A-B01A-3FB2EF1898F8} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting/NuGet.config b/src/libraries/Microsoft.Extensions.Hosting/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/Microsoft.Extensions.Hosting/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln b/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln index 19bcbc7a86705..ee68065148d01 100644 --- a/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln +++ b/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln @@ -19,6 +19,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Http", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Http.Tests", "tests\Microsoft.Extensions.Http.Tests\Microsoft.Extensions.Http.Tests.csproj", "{58A1E42E-5DA1-452A-B39C-A1819171970A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{A455F39F-362E-4E90-ABF5-A32AA568FAEB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{53592813-75CD-46BF-8F7F-3DFD6240183E}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{85615392-9242-4CAF-A0FE-A439FF615462}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{BAFF07C7-1F5F-4706-B7D7-9D5D309CBFE2}" @@ -95,6 +99,14 @@ Global {58A1E42E-5DA1-452A-B39C-A1819171970A}.Debug|Any CPU.Build.0 = Debug|Any CPU {58A1E42E-5DA1-452A-B39C-A1819171970A}.Release|Any CPU.ActiveCfg = Release|Any CPU {58A1E42E-5DA1-452A-B39C-A1819171970A}.Release|Any CPU.Build.0 = Release|Any CPU + {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Release|Any CPU.Build.0 = Release|Any CPU + {53592813-75CD-46BF-8F7F-3DFD6240183E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {53592813-75CD-46BF-8F7F-3DFD6240183E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {53592813-75CD-46BF-8F7F-3DFD6240183E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53592813-75CD-46BF-8F7F-3DFD6240183E}.Release|Any CPU.Build.0 = Release|Any CPU {85615392-9242-4CAF-A0FE-A439FF615462}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {85615392-9242-4CAF-A0FE-A439FF615462}.Debug|Any CPU.Build.0 = Debug|Any CPU {85615392-9242-4CAF-A0FE-A439FF615462}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -164,6 +176,8 @@ Global {A0EBE0C7-F63B-477C-BDE5-6B57AB9DB540} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {B792E72A-0513-4359-B754-D0372610DDCE} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {1236A517-6B61-4A62-9495-1C945EDA4D12} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} + {A455F39F-362E-4E90-ABF5-A32AA568FAEB} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} + {53592813-75CD-46BF-8F7F-3DFD6240183E} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {BAFF07C7-1F5F-4706-B7D7-9D5D309CBFE2} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {65079F8F-0653-4474-B105-551A9B6F102B} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {A12B92C6-071A-4C61-8934-371DBB240873} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln b/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln index 7946e4528c808..bf9829d652330 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln @@ -1,10 +1,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{79CE8C7E-A4AF-413C-A54D-86F17073559C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{1491B9C9-955D-4DB0-B1D5-70137A78EAAE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{A5439E79-96D6-4F02-8DD0-23DFF979851D}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{7F536552-0E2A-4642-B7CF-863727C2F9CD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "src\Microsoft.Extensions.Logging.Abstractions.csproj", "{75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests", "tests\Microsoft.Extensions.Logging.Generators.Tests\Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests.csproj", "{C333EC5A-F386-4A01-AE20-12D499551304}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn4.0.Tests", "tests\Microsoft.Extensions.Logging.Generators.Tests\Microsoft.Extensions.Logging.Generators.Roslyn4.0.Tests.csproj", "{1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{DAA1349E-960E-49EB-81F3-FF4F99D8A325}" @@ -17,12 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{548DF5F7-790 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{7631380A-FB73-4241-9987-0891A21E9769}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn4.0", "gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{A5439E79-96D6-4F02-8DD0-23DFF979851D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn3.11", "gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{1491B9C9-955D-4DB0-B1D5-70137A78EAAE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests", "tests\Microsoft.Extensions.Logging.Generators.Tests\Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests.csproj", "{C333EC5A-F386-4A01-AE20-12D499551304}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +33,14 @@ Global {79CE8C7E-A4AF-413C-A54D-86F17073559C}.Debug|Any CPU.Build.0 = Debug|Any CPU {79CE8C7E-A4AF-413C-A54D-86F17073559C}.Release|Any CPU.ActiveCfg = Release|Any CPU {79CE8C7E-A4AF-413C-A54D-86F17073559C}.Release|Any CPU.Build.0 = Release|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.Build.0 = Release|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.Build.0 = Release|Any CPU {7F536552-0E2A-4642-B7CF-863727C2F9CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7F536552-0E2A-4642-B7CF-863727C2F9CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F536552-0E2A-4642-B7CF-863727C2F9CD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -41,6 +49,10 @@ Global {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}.Release|Any CPU.Build.0 = Release|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.Build.0 = Release|Any CPU {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}.Debug|Any CPU.Build.0 = Debug|Any CPU {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -53,32 +65,20 @@ Global {F8CF3192-B902-4631-972A-C405FDECC48D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8CF3192-B902-4631-972A-C405FDECC48D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8CF3192-B902-4631-972A-C405FDECC48D}.Release|Any CPU.Build.0 = Release|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.Build.0 = Release|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.Build.0 = Release|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {79CE8C7E-A4AF-413C-A54D-86F17073559C} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} - {7F536552-0E2A-4642-B7CF-863727C2F9CD} = {7631380A-FB73-4241-9987-0891A21E9769} - {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {C333EC5A-F386-4A01-AE20-12D499551304} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} - {DAA1349E-960E-49EB-81F3-FF4F99D8A325} = {7631380A-FB73-4241-9987-0891A21E9769} - {F8CF3192-B902-4631-972A-C405FDECC48D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} - {A5439E79-96D6-4F02-8DD0-23DFF979851D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} {1491B9C9-955D-4DB0-B1D5-70137A78EAAE} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} - {C333EC5A-F386-4A01-AE20-12D499551304} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} + {A5439E79-96D6-4F02-8DD0-23DFF979851D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {F8CF3192-B902-4631-972A-C405FDECC48D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {7F536552-0E2A-4642-B7CF-863727C2F9CD} = {7631380A-FB73-4241-9987-0891A21E9769} + {DAA1349E-960E-49EB-81F3-FF4F99D8A325} = {7631380A-FB73-4241-9987-0891A21E9769} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {450DA749-CBDC-4BDC-950F-8A491CF59D49} diff --git a/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln b/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln index 84bddda3fbee1..0d56345c8a8b7 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln @@ -23,6 +23,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{788150B7-B822-4466-A1DC-C875449DE449}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{1EC5859E-7550-42FC-9414-7A95EB419E7A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{3E92E46A-871B-4433-86B8-5E58D21248D6}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{E7035B72-0180-437E-A696-1F0CD8921279}" @@ -113,6 +117,14 @@ Global {788150B7-B822-4466-A1DC-C875449DE449}.Debug|Any CPU.Build.0 = Debug|Any CPU {788150B7-B822-4466-A1DC-C875449DE449}.Release|Any CPU.ActiveCfg = Release|Any CPU {788150B7-B822-4466-A1DC-C875449DE449}.Release|Any CPU.Build.0 = Release|Any CPU + {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Release|Any CPU.Build.0 = Release|Any CPU + {3E92E46A-871B-4433-86B8-5E58D21248D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E92E46A-871B-4433-86B8-5E58D21248D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E92E46A-871B-4433-86B8-5E58D21248D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E92E46A-871B-4433-86B8-5E58D21248D6}.Release|Any CPU.Build.0 = Release|Any CPU {C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -202,6 +214,8 @@ Global {71755B81-EF5C-4C36-A278-60D69ECCC158} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {36176FF1-8C33-494D-A496-1D7E0DCFCD86} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {788150B7-B822-4466-A1DC-C875449DE449} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} + {1EC5859E-7550-42FC-9414-7A95EB419E7A} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} + {3E92E46A-871B-4433-86B8-5E58D21248D6} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {E7035B72-0180-437E-A696-1F0CD8921279} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {B3829B05-AA4A-4A0D-B076-D0C3031C9D33} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {BBCC241D-0980-4735-8187-229D37ADC0E5} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln b/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln index e254e84bd558d..90fe55880518d 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln @@ -25,6 +25,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{C63090AA-A232-4638-99F8-3CCB2442BBAD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{AD2EADCD-BFF7-41D0-A119-E07618302A39}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{6A02D298-6899-4DD0-BFF4-40702BC30BCD}" @@ -67,6 +71,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{EA4F2339-D7E6-4B5C-9203-6920D623D8BC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{C9F3D8F9-8646-432E-82FC-2E4E8411CFFE}" @@ -135,6 +143,14 @@ Global {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}.Release|Any CPU.Build.0 = Release|Any CPU + {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Release|Any CPU.Build.0 = Release|Any CPU + {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Release|Any CPU.Build.0 = Release|Any CPU {9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}.Debug|Any CPU.Build.0 = Debug|Any CPU {9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -219,6 +235,14 @@ Global {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}.Release|Any CPU.Build.0 = Release|Any CPU + {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Release|Any CPU.Build.0 = Release|Any CPU + {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Release|Any CPU.Build.0 = Release|Any CPU {8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -257,6 +281,8 @@ Global {EF05AB17-527F-40BC-B4D1-AAE510267F4E} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {1F272F82-E9D1-454A-8E3C-6BEAF02219D4} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} + {C63090AA-A232-4638-99F8-3CCB2442BBAD} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} + {AD2EADCD-BFF7-41D0-A119-E07618302A39} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {6A02D298-6899-4DD0-BFF4-40702BC30BCD} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {E09FB553-28C4-4C1C-8E86-CFAB3374A656} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {974792E2-0311-446A-BABF-18B3A8DDDEC5} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} @@ -267,6 +293,8 @@ Global {5DCD1587-CC45-4105-8FFE-E4A43C60DA8D} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {EB05EC17-2C21-47EC-A39D-90ABBA053318} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} + {EA4F2339-D7E6-4B5C-9203-6920D623D8BC} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} + {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {C9F3D8F9-8646-432E-82FC-2E4E8411CFFE} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln b/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln index cfece23e2113a..af8f2933ae731 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{850FBE78-DE29-480D-B4EE-6D260B0341B4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{FDEE14F9-39BF-4438-94E2-4F6233FB774B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{16E075F3-372C-4A98-BDAF-FF615B8A9855}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{3DDCFBB7-A438-46BB-9094-A1A39060DD2A}" @@ -73,6 +77,14 @@ Global {850FBE78-DE29-480D-B4EE-6D260B0341B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {850FBE78-DE29-480D-B4EE-6D260B0341B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {850FBE78-DE29-480D-B4EE-6D260B0341B4}.Release|Any CPU.Build.0 = Release|Any CPU + {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Release|Any CPU.Build.0 = Release|Any CPU + {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Release|Any CPU.Build.0 = Release|Any CPU {16E075F3-372C-4A98-BDAF-FF615B8A9855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {16E075F3-372C-4A98-BDAF-FF615B8A9855}.Debug|Any CPU.Build.0 = Debug|Any CPU {16E075F3-372C-4A98-BDAF-FF615B8A9855}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -147,6 +159,8 @@ Global {544BBE63-3650-42E0-AD83-B613907BE753} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {5B4734D0-7CF9-4F4B-B27A-FAED72A81C71} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {850FBE78-DE29-480D-B4EE-6D260B0341B4} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} + {FDEE14F9-39BF-4438-94E2-4F6233FB774B} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} + {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {3DDCFBB7-A438-46BB-9094-A1A39060DD2A} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {81AB6F03-2FF8-4F0F-AB21-B80A6C345DC1} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {7B89700F-897A-4CE8-B789-C9F915631845} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} diff --git a/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln b/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln index 7299154a81820..0070fa99dccee 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln +++ b/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{62D0B220-DABD-4C56-A0E2-640D74465328}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{E93CA456-7B60-4250-8CEA-51D478E1A9B7}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{B1BE2665-7E3F-46FB-BCE1-774D5984F76C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{6C2850C7-56F0-4DCF-BFBF-4365DE2FC439}" @@ -85,6 +89,14 @@ Global {62D0B220-DABD-4C56-A0E2-640D74465328}.Debug|Any CPU.Build.0 = Debug|Any CPU {62D0B220-DABD-4C56-A0E2-640D74465328}.Release|Any CPU.ActiveCfg = Release|Any CPU {62D0B220-DABD-4C56-A0E2-640D74465328}.Release|Any CPU.Build.0 = Release|Any CPU + {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Release|Any CPU.Build.0 = Release|Any CPU + {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Release|Any CPU.Build.0 = Release|Any CPU {B1BE2665-7E3F-46FB-BCE1-774D5984F76C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B1BE2665-7E3F-46FB-BCE1-774D5984F76C}.Debug|Any CPU.Build.0 = Debug|Any CPU {B1BE2665-7E3F-46FB-BCE1-774D5984F76C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -187,6 +199,8 @@ Global {B67E21A5-9B87-46DB-99A1-F04074CBE466} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {A21DEE4B-F49B-4A19-95AC-7589757B8962} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {62D0B220-DABD-4C56-A0E2-640D74465328} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} + {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} + {E93CA456-7B60-4250-8CEA-51D478E1A9B7} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {6C2850C7-56F0-4DCF-BFBF-4365DE2FC439} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {5EA9057E-5887-4BDB-8785-A752D96D89F9} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {515F097D-9FFB-4728-8B9E-18CFA6916AD3} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} diff --git a/src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config b/src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln b/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln index 90beb958088b7..aacc6f46afd22 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{AE3375E0-30D5-4C99-9A0F-C515B822D8AD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{13D1623E-1506-4CD0-8501-41D14711AD18}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{F5B4A3CF-03B5-40A2-BE78-DA6230270113}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{F4A703F8-3D69-4113-A86F-9AD908086092}" @@ -47,6 +51,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{9735A60C-FCAA-423D-85FF-D0C6545693F5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{3E80E645-8642-4944-9B45-0F317A8D2E58}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{5A956452-F322-4C4F-8689-D2B425764293}" @@ -91,6 +99,14 @@ Global {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}.Debug|Any CPU.Build.0 = Debug|Any CPU {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}.Release|Any CPU.ActiveCfg = Release|Any CPU {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}.Release|Any CPU.Build.0 = Release|Any CPU + {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Release|Any CPU.Build.0 = Release|Any CPU + {13D1623E-1506-4CD0-8501-41D14711AD18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13D1623E-1506-4CD0-8501-41D14711AD18}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13D1623E-1506-4CD0-8501-41D14711AD18}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13D1623E-1506-4CD0-8501-41D14711AD18}.Release|Any CPU.Build.0 = Release|Any CPU {F5B4A3CF-03B5-40A2-BE78-DA6230270113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F5B4A3CF-03B5-40A2-BE78-DA6230270113}.Debug|Any CPU.Build.0 = Debug|Any CPU {F5B4A3CF-03B5-40A2-BE78-DA6230270113}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -159,6 +175,14 @@ Global {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}.Debug|Any CPU.Build.0 = Debug|Any CPU {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}.Release|Any CPU.ActiveCfg = Release|Any CPU {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}.Release|Any CPU.Build.0 = Release|Any CPU + {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Release|Any CPU.Build.0 = Release|Any CPU + {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Release|Any CPU.Build.0 = Release|Any CPU {3E80E645-8642-4944-9B45-0F317A8D2E58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3E80E645-8642-4944-9B45-0F317A8D2E58}.Debug|Any CPU.Build.0 = Debug|Any CPU {3E80E645-8642-4944-9B45-0F317A8D2E58}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -189,6 +213,8 @@ Global {9B5DD499-7FE6-4E35-8084-EAF9D0E4CFDE} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {AD133460-B832-44BE-BF0A-A699A77FA718} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} + {AE3375E0-30D5-4C99-9A0F-C515B822D8AD} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} + {13D1623E-1506-4CD0-8501-41D14711AD18} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {F4A703F8-3D69-4113-A86F-9AD908086092} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {85D5D364-5D5F-4D9F-A6DA-1EF4C9E5503F} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {4B621745-2446-4A51-96C1-E1F9D4FCE1E3} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} @@ -197,6 +223,8 @@ Global {23F45D4C-4E33-4334-A5BF-D34E24165E0B} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {9A16DEC0-1F88-4335-95B3-D7923FEB5283} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} + {9735A60C-FCAA-423D-85FF-D0C6545693F5} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} + {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {5A956452-F322-4C4F-8689-D2B425764293} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln b/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln index 0cd8e629878e2..0908e70b541b0 100644 --- a/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln +++ b/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{A64CC82B-B781-4469-B009-49A43A0A2A96}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{8293FA5A-58DE-4238-8E3E-E153AA92766F}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{367922CE-A24E-4977-89BE-D1F2F678F8B2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{F63AB9DB-6E62-4FEC-BA06-E146615C08AC}" @@ -73,6 +77,14 @@ Global {A64CC82B-B781-4469-B009-49A43A0A2A96}.Debug|Any CPU.Build.0 = Debug|Any CPU {A64CC82B-B781-4469-B009-49A43A0A2A96}.Release|Any CPU.ActiveCfg = Release|Any CPU {A64CC82B-B781-4469-B009-49A43A0A2A96}.Release|Any CPU.Build.0 = Release|Any CPU + {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Release|Any CPU.Build.0 = Release|Any CPU + {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Release|Any CPU.Build.0 = Release|Any CPU {367922CE-A24E-4977-89BE-D1F2F678F8B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {367922CE-A24E-4977-89BE-D1F2F678F8B2}.Debug|Any CPU.Build.0 = Debug|Any CPU {367922CE-A24E-4977-89BE-D1F2F678F8B2}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -147,6 +159,8 @@ Global {1B7B708C-F860-478E-B3D4-1CB70E71A440} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {A9250A96-9B27-46C5-A043-11F67D63B128} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {A64CC82B-B781-4469-B009-49A43A0A2A96} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} + {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} + {8293FA5A-58DE-4238-8E3E-E153AA92766F} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {F63AB9DB-6E62-4FEC-BA06-E146615C08AC} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {BC92BF65-8FA0-49C0-911F-426F21090774} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {C0A5172A-162E-4CD8-B4E4-C8AE137EBC64} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} diff --git a/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln b/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln index 6070ed9135aad..0c7f5d1f1ad65 100644 --- a/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln +++ b/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln @@ -45,6 +45,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.FileSy EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.FileSystemGlobbing", "..\Microsoft.Extensions.FileSystemGlobbing\src\Microsoft.Extensions.FileSystemGlobbing.csproj", "{7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{B9E9944F-0170-478C-9BEF-136168FDBE2B}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{5CC86773-7762-4FB7-9B6E-F4002F286AD4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{4BEF5648-8DBF-4E16-B6E6-6F80694E140D}" @@ -111,6 +115,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{B5B30447-25D0-42C0-920A-092247C95664}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{C00A8442-D7CE-464F-92A1-207427755FF6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{BB1EF0C4-822E-4476-8872-8620EA665C35}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{34C22E86-B0A3-457D-B8D9-7CF47AAF2570}" @@ -221,6 +229,14 @@ Global {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}.Release|Any CPU.Build.0 = Release|Any CPU + {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Release|Any CPU.Build.0 = Release|Any CPU + {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Release|Any CPU.Build.0 = Release|Any CPU {5CC86773-7762-4FB7-9B6E-F4002F286AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5CC86773-7762-4FB7-9B6E-F4002F286AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU {5CC86773-7762-4FB7-9B6E-F4002F286AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -353,6 +369,14 @@ Global {B5B30447-25D0-42C0-920A-092247C95664}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5B30447-25D0-42C0-920A-092247C95664}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5B30447-25D0-42C0-920A-092247C95664}.Release|Any CPU.Build.0 = Release|Any CPU + {C00A8442-D7CE-464F-92A1-207427755FF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C00A8442-D7CE-464F-92A1-207427755FF6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C00A8442-D7CE-464F-92A1-207427755FF6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C00A8442-D7CE-464F-92A1-207427755FF6}.Release|Any CPU.Build.0 = Release|Any CPU + {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Release|Any CPU.Build.0 = Release|Any CPU {BB1EF0C4-822E-4476-8872-8620EA665C35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BB1EF0C4-822E-4476-8872-8620EA665C35}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB1EF0C4-822E-4476-8872-8620EA665C35}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -413,6 +437,8 @@ Global {31E317F8-F766-4EC3-8101-2D92CDB407CD} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {5F0CF40F-D54D-4101-94EA-8FE7F9C843CB} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A} = {D8928AB2-2939-4421-90C5-56B789BF93E5} + {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822} = {D8928AB2-2939-4421-90C5-56B789BF93E5} + {B9E9944F-0170-478C-9BEF-136168FDBE2B} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {4BEF5648-8DBF-4E16-B6E6-6F80694E140D} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {9D96B3BD-B371-4E44-A43F-50B8EEBEC889} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {F700E4AF-073D-4C1D-A8C2-84E744EBC374} = {D8928AB2-2939-4421-90C5-56B789BF93E5} @@ -428,6 +454,8 @@ Global {425C299F-7D53-49EC-92D0-22B77BEA12D2} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {04BA3E3C-6979-4792-B19E-C797AD607F42} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {B5B30447-25D0-42C0-920A-092247C95664} = {D8928AB2-2939-4421-90C5-56B789BF93E5} + {C00A8442-D7CE-464F-92A1-207427755FF6} = {D8928AB2-2939-4421-90C5-56B789BF93E5} + {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {34C22E86-B0A3-457D-B8D9-7CF47AAF2570} = {D8928AB2-2939-4421-90C5-56B789BF93E5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Logging/NuGet.config b/src/libraries/Microsoft.Extensions.Logging/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/Microsoft.Extensions.Logging/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln b/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln index 0fe5055533f24..5703183eec058 100644 --- a/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln +++ b/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln @@ -65,6 +65,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting", "..\Microsoft.Extensions.Hosting\src\Microsoft.Extensions.Hosting.csproj", "{6AD51705-102E-4E9D-B62E-6BF19025F3A7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{EBEF8790-8095-4FD9-8436-1354B30E1529}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{56D37CB2-68A3-42D3-AA0E-416813ABAD8B}" @@ -133,6 +137,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{59D31D62-3BF9-4F4A-9FF7-3A61F297F714}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{7B06FF78-A95C-4703-AB80-E7509D6CB3D7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{F249D915-DA90-4C96-B26B-147574801988}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{6E2398EA-A64A-4493-A79B-63D2F072A690}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{D7CEC738-5D2D-4FCB-9268-9650EB01BF31}" @@ -283,6 +291,14 @@ Global {6AD51705-102E-4E9D-B62E-6BF19025F3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU {6AD51705-102E-4E9D-B62E-6BF19025F3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU {6AD51705-102E-4E9D-B62E-6BF19025F3A7}.Release|Any CPU.Build.0 = Release|Any CPU + {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Release|Any CPU.Build.0 = Release|Any CPU + {EBEF8790-8095-4FD9-8436-1354B30E1529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EBEF8790-8095-4FD9-8436-1354B30E1529}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EBEF8790-8095-4FD9-8436-1354B30E1529}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EBEF8790-8095-4FD9-8436-1354B30E1529}.Release|Any CPU.Build.0 = Release|Any CPU {EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}.Debug|Any CPU.Build.0 = Debug|Any CPU {EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -419,6 +435,14 @@ Global {59D31D62-3BF9-4F4A-9FF7-3A61F297F714}.Debug|Any CPU.Build.0 = Debug|Any CPU {59D31D62-3BF9-4F4A-9FF7-3A61F297F714}.Release|Any CPU.ActiveCfg = Release|Any CPU {59D31D62-3BF9-4F4A-9FF7-3A61F297F714}.Release|Any CPU.Build.0 = Release|Any CPU + {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Release|Any CPU.Build.0 = Release|Any CPU + {F249D915-DA90-4C96-B26B-147574801988}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F249D915-DA90-4C96-B26B-147574801988}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F249D915-DA90-4C96-B26B-147574801988}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F249D915-DA90-4C96-B26B-147574801988}.Release|Any CPU.Build.0 = Release|Any CPU {6E2398EA-A64A-4493-A79B-63D2F072A690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6E2398EA-A64A-4493-A79B-63D2F072A690}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E2398EA-A64A-4493-A79B-63D2F072A690}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -489,6 +513,8 @@ Global {36D778AF-5EC3-433F-B03D-EB244DB3C227} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {D0932BA0-70BF-4A98-9A30-ED563AB2BFB9} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {6AD51705-102E-4E9D-B62E-6BF19025F3A7} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} + {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} + {EBEF8790-8095-4FD9-8436-1354B30E1529} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {56D37CB2-68A3-42D3-AA0E-416813ABAD8B} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {9EBA168F-239A-46C4-8614-E1D3DB25DD0E} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {47B5D904-4787-49E3-9894-31F8B7BE6755} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} @@ -505,6 +531,8 @@ Global {9175023F-6982-45CD-B360-C4FC1E145B25} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {8E7256F3-ACCF-4576-B091-CC8ADC60C33E} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {59D31D62-3BF9-4F4A-9FF7-3A61F297F714} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} + {7B06FF78-A95C-4703-AB80-E7509D6CB3D7} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} + {F249D915-DA90-4C96-B26B-147574801988} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {D7CEC738-5D2D-4FCB-9268-9650EB01BF31} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Options/NuGet.config b/src/libraries/Microsoft.Extensions.Options/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/Microsoft.Extensions.Options/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln b/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln index fe2625c0a4dda..f463dfd2be002 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln +++ b/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualBasic.Core. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry", "..\Microsoft.Win32.Registry\src\Microsoft.Win32.Registry.csproj", "{1970A570-2766-49C2-83A4-9898E295D6AF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{3B27E66C-3E44-4DC7-9434-9B66475B80E5}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{40E6CFD8-4203-49CA-A3D7-A93A2344F876}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{EE74172D-1E18-4130-B71E-C9FDF04DA0F6}" @@ -55,10 +53,6 @@ Global {1970A570-2766-49C2-83A4-9898E295D6AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {1970A570-2766-49C2-83A4-9898E295D6AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {1970A570-2766-49C2-83A4-9898E295D6AF}.Release|Any CPU.Build.0 = Release|Any CPU - {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Release|Any CPU.Build.0 = Release|Any CPU {40E6CFD8-4203-49CA-A3D7-A93A2344F876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {40E6CFD8-4203-49CA-A3D7-A93A2344F876}.Debug|Any CPU.Build.0 = Debug|Any CPU {40E6CFD8-4203-49CA-A3D7-A93A2344F876}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -91,7 +85,6 @@ Global {009D39C7-821B-44E4-ABB9-8ED94464A5CB} = {3FD0B41F-6CEA-4AE2-832F-60C8686858C4} {476C0AEB-48CB-4978-9D35-06AA49F800B9} = {3FD0B41F-6CEA-4AE2-832F-60C8686858C4} {EA1B5DA0-F263-4298-A8FC-564E9DF00771} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} - {3B27E66C-3E44-4DC7-9434-9B66475B80E5} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} {40E6CFD8-4203-49CA-A3D7-A93A2344F876} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} {744F821F-99E9-4FF5-A84A-85432CC77548} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} {E741B977-6B3F-4DA7-A22B-251A1B3E42F7} = {2FC8E7CF-2E28-42BB-BCC0-DD0EDF96A483} diff --git a/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln b/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln index dd8549340ff50..453f96fba333f 100644 --- a/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln +++ b/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{75E8E37F-C551-47B1-A62B-EE78C96BBDF0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{39EC49B3-3F54-4302-AA73-2C6CB63C054B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{71A636C5-93CD-41C5-8177-345127143843}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{44B79C97-BA70-4955-8478-87D5CB5CD3B5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CEC48784-C8F0-46DF-AA1E-07850E754180}" @@ -158,6 +162,42 @@ Global {75E8E37F-C551-47B1-A62B-EE78C96BBDF0}.Checked|x64.Build.0 = Debug|Any CPU {75E8E37F-C551-47B1-A62B-EE78C96BBDF0}.Checked|x86.ActiveCfg = Debug|Any CPU {75E8E37F-C551-47B1-A62B-EE78C96BBDF0}.Checked|x86.Build.0 = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x64.ActiveCfg = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x64.Build.0 = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x86.ActiveCfg = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x86.Build.0 = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|Any CPU.Build.0 = Release|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x64.ActiveCfg = Release|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x64.Build.0 = Release|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x86.ActiveCfg = Release|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x86.Build.0 = Release|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|Any CPU.Build.0 = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x64.ActiveCfg = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x64.Build.0 = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x86.ActiveCfg = Debug|Any CPU + {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x86.Build.0 = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Debug|x64.ActiveCfg = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Debug|x64.Build.0 = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Debug|x86.ActiveCfg = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Debug|x86.Build.0 = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Release|Any CPU.Build.0 = Release|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Release|x64.ActiveCfg = Release|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Release|x64.Build.0 = Release|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Release|x86.ActiveCfg = Release|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Release|x86.Build.0 = Release|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Checked|Any CPU.Build.0 = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Checked|x64.ActiveCfg = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Checked|x64.Build.0 = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Checked|x86.ActiveCfg = Debug|Any CPU + {71A636C5-93CD-41C5-8177-345127143843}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {7D1AFE3C-882D-4D27-A915-B87A1BC82D2D} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} {B3BBD7D9-30F3-43D3-9D6A-C9BD5E19D32E} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} {75E8E37F-C551-47B1-A62B-EE78C96BBDF0} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} + {39EC49B3-3F54-4302-AA73-2C6CB63C054B} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} + {71A636C5-93CD-41C5-8177-345127143843} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} {069C76AC-B41A-4E17-A066-12233592145D} = {CEC48784-C8F0-46DF-AA1E-07850E754180} {B43D6BB6-1760-4DB9-87CB-792D42846C62} = {CEC48784-C8F0-46DF-AA1E-07850E754180} {EA142E29-EE37-4751-868B-27516AE0A209} = {08BAF9E0-068B-4201-91E6-91B725ABE3D2} diff --git a/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln b/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln index 7e971e101f740..427a3cc8ee23b 100644 --- a/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln +++ b/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry.Ac EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry.AccessControl.Tests", "tests\Microsoft.Win32.Registry.AccessControl.Tests.csproj", "{BC8FAA75-A595-475E-B947-FA2D1E225B48}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{CF3D0A58-974A-484E-A897-634C5FF78DFB}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{9341070F-8A24-45FD-96FF-DC936EC9FE4C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DD5B2888-463A-4AB6-911F-EB0BEA47951A}" @@ -41,10 +39,6 @@ Global {BC8FAA75-A595-475E-B947-FA2D1E225B48}.Debug|Any CPU.Build.0 = Debug|Any CPU {BC8FAA75-A595-475E-B947-FA2D1E225B48}.Release|Any CPU.ActiveCfg = Release|Any CPU {BC8FAA75-A595-475E-B947-FA2D1E225B48}.Release|Any CPU.Build.0 = Release|Any CPU - {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Release|Any CPU.Build.0 = Release|Any CPU {9341070F-8A24-45FD-96FF-DC936EC9FE4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9341070F-8A24-45FD-96FF-DC936EC9FE4C}.Debug|Any CPU.Build.0 = Debug|Any CPU {9341070F-8A24-45FD-96FF-DC936EC9FE4C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -61,7 +55,6 @@ Global {F9B18052-9FB9-474A-9A6A-F322DED4F7CD} = {BF17487D-E9E3-4054-85A7-E64243B91780} {BC8FAA75-A595-475E-B947-FA2D1E225B48} = {BF17487D-E9E3-4054-85A7-E64243B91780} {97F37414-7633-4B76-AFA4-284E26894FB4} = {84D58703-7569-445A-89B8-14D024FB6091} - {CF3D0A58-974A-484E-A897-634C5FF78DFB} = {84D58703-7569-445A-89B8-14D024FB6091} {9341070F-8A24-45FD-96FF-DC936EC9FE4C} = {84D58703-7569-445A-89B8-14D024FB6091} {9A0E9CD8-33FA-4E02-8EB6-5685CD84D727} = {29A3E154-E50B-49E7-96C3-32A91CAB9BA0} {DD5B2888-463A-4AB6-911F-EB0BEA47951A} = {29A3E154-E50B-49E7-96C3-32A91CAB9BA0} diff --git a/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln b/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln index dcb2f6929969e..c6f781e6c07f5 100644 --- a/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln +++ b/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry.Tests", "tests\Microsoft.Win32.Registry.Tests.csproj", "{E9123189-58BC-41A8-83A0-C46E74ED8160}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{9923CC23-8CA1-4FE4-B561-D3487502518F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{CC7AEF63-5AE0-4A16-9DD7-0A55B539D906}" @@ -45,10 +43,6 @@ Global {E9123189-58BC-41A8-83A0-C46E74ED8160}.Debug|Any CPU.Build.0 = Debug|Any CPU {E9123189-58BC-41A8-83A0-C46E74ED8160}.Release|Any CPU.ActiveCfg = Release|Any CPU {E9123189-58BC-41A8-83A0-C46E74ED8160}.Release|Any CPU.Build.0 = Release|Any CPU - {9923CC23-8CA1-4FE4-B561-D3487502518F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9923CC23-8CA1-4FE4-B561-D3487502518F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9923CC23-8CA1-4FE4-B561-D3487502518F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9923CC23-8CA1-4FE4-B561-D3487502518F}.Release|Any CPU.Build.0 = Release|Any CPU {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -73,7 +67,6 @@ Global {F4F537EB-4436-4407-9A42-A75FE9CEECE0} = {D3839339-AF88-4867-BF81-44915AA883A2} {E9123189-58BC-41A8-83A0-C46E74ED8160} = {D3839339-AF88-4867-BF81-44915AA883A2} {FC5B0E37-024C-4A09-9080-AA78F2BCE4A0} = {DE8642D5-1264-473C-9896-35F348E89DBF} - {9923CC23-8CA1-4FE4-B561-D3487502518F} = {DE8642D5-1264-473C-9896-35F348E89DBF} {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F} = {DE8642D5-1264-473C-9896-35F348E89DBF} {3446E090-1587-4D16-AE6A-99C1788E86A6} = {66BCDB38-AFF7-4B7C-97F5-8869D5C2EDA9} {CC7AEF63-5AE0-4A16-9DD7-0A55B539D906} = {66BCDB38-AFF7-4B7C-97F5-8869D5C2EDA9} diff --git a/src/libraries/Microsoft.Win32.SystemEvents/NuGet.config b/src/libraries/Microsoft.Win32.SystemEvents/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/Microsoft.Win32.SystemEvents/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.AppContext/System.AppContext.sln b/src/libraries/System.AppContext/System.AppContext.sln index e2367001426d0..f727ce0c812fa 100644 --- a/src/libraries/System.AppContext/System.AppContext.sln +++ b/src/libraries/System.AppContext/System.AppContext.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{207F66C5-1274-445C-B69E-E2C5F0776843}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{262B61F6-470E-46B6-B392-858692D3FB23}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AE25156-94A3-4936-80FD-8343290DF4B4}" @@ -158,6 +162,42 @@ Global {207F66C5-1274-445C-B69E-E2C5F0776843}.Checked|x64.Build.0 = Debug|Any CPU {207F66C5-1274-445C-B69E-E2C5F0776843}.Checked|x86.ActiveCfg = Debug|Any CPU {207F66C5-1274-445C-B69E-E2C5F0776843}.Checked|x86.Build.0 = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x64.ActiveCfg = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x64.Build.0 = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x86.ActiveCfg = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x86.Build.0 = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|Any CPU.Build.0 = Release|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x64.ActiveCfg = Release|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x64.Build.0 = Release|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x86.ActiveCfg = Release|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x86.Build.0 = Release|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|Any CPU.Build.0 = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x64.ActiveCfg = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x64.Build.0 = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x86.ActiveCfg = Debug|Any CPU + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x86.Build.0 = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x64.ActiveCfg = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x64.Build.0 = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x86.ActiveCfg = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x86.Build.0 = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|Any CPU.Build.0 = Release|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x64.ActiveCfg = Release|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x64.Build.0 = Release|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x86.ActiveCfg = Release|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x86.Build.0 = Release|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|Any CPU.Build.0 = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x64.ActiveCfg = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x64.Build.0 = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x86.ActiveCfg = Debug|Any CPU + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {751F6E52-BD51-406F-9EB6-06D3C27BF469} = {262B61F6-470E-46B6-B392-858692D3FB23} {1648AC4C-3BEF-4B93-933B-5EC520BF11D5} = {262B61F6-470E-46B6-B392-858692D3FB23} {207F66C5-1274-445C-B69E-E2C5F0776843} = {262B61F6-470E-46B6-B392-858692D3FB23} + {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0} = {262B61F6-470E-46B6-B392-858692D3FB23} + {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E} = {262B61F6-470E-46B6-B392-858692D3FB23} {F9B2FCA3-69C0-45A6-B1FA-E989263536C4} = {0AE25156-94A3-4936-80FD-8343290DF4B4} {007AD19C-8A80-4463-834C-BE7AE1808A04} = {0AE25156-94A3-4936-80FD-8343290DF4B4} {BB689125-CDA7-4CFA-A4D6-1C932092A67F} = {4E4CBD83-24E2-49A2-B0A5-57368BB1A055} diff --git a/src/libraries/System.Buffers/System.Buffers.sln b/src/libraries/System.Buffers/System.Buffers.sln index 008b853144ce1..ffedd75f6d907 100644 --- a/src/libraries/System.Buffers/System.Buffers.sln +++ b/src/libraries/System.Buffers/System.Buffers.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{27D2947E-56F1-4046-805E-5DA3F636E15C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{97103694-085A-4CC9-9CF2-822B5472B236}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{07A3DCA1-A687-4607-81A5-3341D331D144}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A11072BB-28A6-44B6-A0A3-CAFE5E5309E5}" @@ -158,6 +162,42 @@ Global {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}.Checked|x64.Build.0 = Debug|Any CPU {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}.Checked|x86.ActiveCfg = Debug|Any CPU {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}.Checked|x86.Build.0 = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x64.ActiveCfg = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x64.Build.0 = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x86.ActiveCfg = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x86.Build.0 = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|Any CPU.Build.0 = Release|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x64.ActiveCfg = Release|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x64.Build.0 = Release|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x86.ActiveCfg = Release|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x86.Build.0 = Release|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|Any CPU.Build.0 = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x64.ActiveCfg = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x64.Build.0 = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x86.ActiveCfg = Debug|Any CPU + {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x86.Build.0 = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x64.ActiveCfg = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x64.Build.0 = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x86.ActiveCfg = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x86.Build.0 = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Release|Any CPU.Build.0 = Release|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x64.ActiveCfg = Release|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x64.Build.0 = Release|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x86.ActiveCfg = Release|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x86.Build.0 = Release|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|Any CPU.Build.0 = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x64.ActiveCfg = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x64.Build.0 = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x86.ActiveCfg = Debug|Any CPU + {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {006429DB-0860-4688-BD1D-459C9364594D} = {07A3DCA1-A687-4607-81A5-3341D331D144} {4BA09CF8-2B90-43E1-AB35-8A48FF8ECEC6} = {07A3DCA1-A687-4607-81A5-3341D331D144} {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5} = {07A3DCA1-A687-4607-81A5-3341D331D144} + {27D2947E-56F1-4046-805E-5DA3F636E15C} = {07A3DCA1-A687-4607-81A5-3341D331D144} + {97103694-085A-4CC9-9CF2-822B5472B236} = {07A3DCA1-A687-4607-81A5-3341D331D144} {350A679C-F690-49B3-AB97-340AF05E1250} = {A11072BB-28A6-44B6-A0A3-CAFE5E5309E5} {FF86CB73-2E54-4E89-9491-258324F291D0} = {A11072BB-28A6-44B6-A0A3-CAFE5E5309E5} {7F713B83-1256-4108-B40D-FDD380BB9DB6} = {914126D6-2C5E-49E9-B9BF-F94749FB2329} diff --git a/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln b/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln index 15d7747bbcf6f..e93b1d4613565 100644 --- a/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln +++ b/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln @@ -17,6 +17,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{A27E93BA-7A0C-417E-B178-F1727D50B7FF}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{4F023286-853F-4B12-B0BC-ED3E42D38A13}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0}" @@ -200,6 +204,42 @@ Global {A27E93BA-7A0C-417E-B178-F1727D50B7FF}.Checked|x64.Build.0 = Debug|Any CPU {A27E93BA-7A0C-417E-B178-F1727D50B7FF}.Checked|x86.ActiveCfg = Debug|Any CPU {A27E93BA-7A0C-417E-B178-F1727D50B7FF}.Checked|x86.Build.0 = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x64.Build.0 = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x86.Build.0 = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|Any CPU.Build.0 = Release|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x64.ActiveCfg = Release|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x64.Build.0 = Release|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x86.ActiveCfg = Release|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x86.Build.0 = Release|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|Any CPU.Build.0 = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x64.ActiveCfg = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x64.Build.0 = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x86.ActiveCfg = Debug|Any CPU + {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x86.Build.0 = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x64.ActiveCfg = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x64.Build.0 = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x86.ActiveCfg = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x86.Build.0 = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|Any CPU.Build.0 = Release|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x64.ActiveCfg = Release|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x64.Build.0 = Release|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x86.ActiveCfg = Release|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x86.Build.0 = Release|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|Any CPU.Build.0 = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x64.ActiveCfg = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x64.Build.0 = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x86.ActiveCfg = Debug|Any CPU + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x86.Build.0 = Debug|Any CPU {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}.Debug|Any CPU.Build.0 = Debug|Any CPU {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -228,6 +268,8 @@ Global {34C59132-692C-45D7-87BD-869A18F09E2C} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {93FB3527-B9E6-4ECA-8F36-56835F4F9236} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {A27E93BA-7A0C-417E-B178-F1727D50B7FF} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} + {4F023286-853F-4B12-B0BC-ED3E42D38A13} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} + {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {7C2B8279-F7BB-4AD4-BA44-B9071090AF46} = {64657647-6C2C-4D36-A5D4-7E7534F3C66F} {C391ADBE-DD23-4F4A-B3EC-011974CC6CE8} = {64657647-6C2C-4D36-A5D4-7E7534F3C66F} diff --git a/src/libraries/System.Collections/System.Collections.sln b/src/libraries/System.Collections/System.Collections.sln index 296a4cd2a17c1..c338ea9b5d647 100644 --- a/src/libraries/System.Collections/System.Collections.sln +++ b/src/libraries/System.Collections/System.Collections.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{68E94039-C5BC-47C8-87EA-DCCE549CA0B8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C848C534-DD16-4A69-81FF-894456E4B099}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6CD2C5E3-B5BA-4219-B8EF-9B5D486BF805}" @@ -158,6 +162,42 @@ Global {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}.Checked|x64.Build.0 = Debug|Any CPU {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}.Checked|x86.ActiveCfg = Debug|Any CPU {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}.Checked|x86.Build.0 = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x64.ActiveCfg = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x64.Build.0 = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x86.ActiveCfg = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x86.Build.0 = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|Any CPU.Build.0 = Release|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x64.ActiveCfg = Release|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x64.Build.0 = Release|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x86.ActiveCfg = Release|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x86.Build.0 = Release|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|Any CPU.Build.0 = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x64.ActiveCfg = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x64.Build.0 = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x86.ActiveCfg = Debug|Any CPU + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x86.Build.0 = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x64.ActiveCfg = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x64.Build.0 = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x86.ActiveCfg = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x86.Build.0 = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|Any CPU.Build.0 = Release|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x64.ActiveCfg = Release|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x64.Build.0 = Release|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x86.ActiveCfg = Release|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x86.Build.0 = Release|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|Any CPU.Build.0 = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x64.ActiveCfg = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x64.Build.0 = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x86.ActiveCfg = Debug|Any CPU + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {4385739F-14A1-4F21-96E3-12EA90580575} = {C848C534-DD16-4A69-81FF-894456E4B099} {DF501250-4105-4F79-A508-90B3A13A975A} = {C848C534-DD16-4A69-81FF-894456E4B099} {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6} = {C848C534-DD16-4A69-81FF-894456E4B099} + {68E94039-C5BC-47C8-87EA-DCCE549CA0B8} = {C848C534-DD16-4A69-81FF-894456E4B099} + {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62} = {C848C534-DD16-4A69-81FF-894456E4B099} {38D8F258-655E-459B-B2CE-0DED144AFBF7} = {6CD2C5E3-B5BA-4219-B8EF-9B5D486BF805} {BB54ED9D-FF71-4D91-B7C0-984AB0976798} = {6CD2C5E3-B5BA-4219-B8EF-9B5D486BF805} {77E9C47D-4AC4-4402-8613-40DF427174BD} = {06AE90FB-F007-4E70-BCD2-5CAD106A7C97} diff --git a/src/libraries/System.Console/System.Console.sln b/src/libraries/System.Console/System.Console.sln index f2e12502dda45..a3e38e37197c0 100644 --- a/src/libraries/System.Console/System.Console.sln +++ b/src/libraries/System.Console/System.Console.sln @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BADDD400-7CBE-436D-BF12-BB47E83D7910}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9DAEBF55-6A76-4037-B119-5E48C2121D30}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DF6461C4-C26B-4911-BA9F-E9EBE09BE018}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{87011BFC-F4A7-4BEB-A794-ED75999604BF}" @@ -59,6 +63,14 @@ Global {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}.Debug|Any CPU.Build.0 = Debug|Any CPU {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}.Release|Any CPU.Build.0 = Release|Any CPU + {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Release|Any CPU.Build.0 = Release|Any CPU + {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -72,6 +84,8 @@ Global {7EAA30FF-8911-4427-BFAC-9FC8BF8B3606} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} {BAA75C96-57D9-4EDF-8DDF-392DB08B2047} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} + {BADDD400-7CBE-436D-BF12-BB47E83D7910} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} + {9DAEBF55-6A76-4037-B119-5E48C2121D30} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E14E904-00F2-414A-BCF1-0EB09A861A21} diff --git a/src/libraries/System.Data.Common/System.Data.Common.sln b/src/libraries/System.Data.Common/System.Data.Common.sln index b3d0dd392c331..c651a9922ee8b 100644 --- a/src/libraries/System.Data.Common/System.Data.Common.sln +++ b/src/libraries/System.Data.Common/System.Data.Common.sln @@ -23,6 +23,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Extensions", "..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj", "{68D868F6-1311-47A2-9DDE-22B64B5FF85E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{69D59191-E55C-485C-987F-A7539A0D791A}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{09129981-6B0D-44C7-9F0A-AD2426106332}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5924BF80-8349-4021-A4A3-853FE714A7C7}" @@ -260,6 +264,42 @@ Global {68D868F6-1311-47A2-9DDE-22B64B5FF85E}.Checked|x64.Build.0 = Debug|Any CPU {68D868F6-1311-47A2-9DDE-22B64B5FF85E}.Checked|x86.ActiveCfg = Debug|Any CPU {68D868F6-1311-47A2-9DDE-22B64B5FF85E}.Checked|x86.Build.0 = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x64.ActiveCfg = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x64.Build.0 = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x86.ActiveCfg = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x86.Build.0 = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|Any CPU.Build.0 = Release|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x64.ActiveCfg = Release|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x64.Build.0 = Release|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x86.ActiveCfg = Release|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x86.Build.0 = Release|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|Any CPU.Build.0 = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x64.ActiveCfg = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x64.Build.0 = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x86.ActiveCfg = Debug|Any CPU + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x86.Build.0 = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x64.ActiveCfg = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x64.Build.0 = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x86.ActiveCfg = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x86.Build.0 = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Release|Any CPU.Build.0 = Release|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x64.ActiveCfg = Release|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x64.Build.0 = Release|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x86.ActiveCfg = Release|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x86.Build.0 = Release|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|Any CPU.Build.0 = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x64.ActiveCfg = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x64.Build.0 = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x86.ActiveCfg = Debug|Any CPU + {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x86.Build.0 = Debug|Any CPU {09129981-6B0D-44C7-9F0A-AD2426106332}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {09129981-6B0D-44C7-9F0A-AD2426106332}.Debug|Any CPU.Build.0 = Debug|Any CPU {09129981-6B0D-44C7-9F0A-AD2426106332}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -291,6 +331,8 @@ Global {7AB121D2-0AAC-48E0-A834-6E220ECFEC4D} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {6E353933-8CBD-467D-8FF1-00133C3F2036} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {68D868F6-1311-47A2-9DDE-22B64B5FF85E} = {5924BF80-8349-4021-A4A3-853FE714A7C7} + {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4} = {5924BF80-8349-4021-A4A3-853FE714A7C7} + {69D59191-E55C-485C-987F-A7539A0D791A} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {09129981-6B0D-44C7-9F0A-AD2426106332} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {0BD22D2A-C12C-4641-8F12-73D21AAAFBA3} = {B1861E5E-4FCA-4CA5-9BB5-5A3C3DBC7F7D} {BEBD7B5B-9544-42EB-B878-F009560CAAF4} = {B1861E5E-4FCA-4CA5-9BB5-5A3C3DBC7F7D} diff --git a/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln b/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln index f50b8dfb693fd..bf18acd8a81aa 100644 --- a/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln +++ b/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2D1EDC33-64F1-4145-B8A9-6CCC7961E195}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{A56373F2-05A6-4A91-A823-3FC2B63CA913}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ABC2D63C-77D2-49D8-AF86-2530D6672269}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{56A31E71-2D11-484D-A9D0-97E4A2AD9354}" @@ -158,6 +162,42 @@ Global {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}.Checked|x64.Build.0 = Debug|Any CPU {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}.Checked|x86.ActiveCfg = Debug|Any CPU {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}.Checked|x86.Build.0 = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x64.ActiveCfg = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x64.Build.0 = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x86.ActiveCfg = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x86.Build.0 = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|Any CPU.Build.0 = Release|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x64.ActiveCfg = Release|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x64.Build.0 = Release|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x86.ActiveCfg = Release|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x86.Build.0 = Release|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|Any CPU.Build.0 = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x64.ActiveCfg = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x64.Build.0 = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x86.ActiveCfg = Debug|Any CPU + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x86.Build.0 = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x64.ActiveCfg = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x64.Build.0 = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x86.ActiveCfg = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x86.Build.0 = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|Any CPU.Build.0 = Release|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x64.ActiveCfg = Release|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x64.Build.0 = Release|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x86.ActiveCfg = Release|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x86.Build.0 = Release|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|Any CPU.Build.0 = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x64.ActiveCfg = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x64.Build.0 = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x86.ActiveCfg = Debug|Any CPU + {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {D5A81248-C2F8-464A-8EA4-2AB2528206BC} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} {158DD2BA-5789-49B8-A801-77EF5D4FD324} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} + {2D1EDC33-64F1-4145-B8A9-6CCC7961E195} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} + {A56373F2-05A6-4A91-A823-3FC2B63CA913} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} {E4B95B10-EC2A-4874-8E71-858A90A4BDFE} = {56A31E71-2D11-484D-A9D0-97E4A2AD9354} {2F113EAD-602B-4EBD-97E4-24C97CDFEB50} = {56A31E71-2D11-484D-A9D0-97E4A2AD9354} {DD15B8D0-013A-43B3-AC3D-1B0D626B35E0} = {8B71FA04-1D67-4607-94A4-E2A85977B1FA} diff --git a/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln b/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln index 51956da5b4f41..13609c26482a0 100644 --- a/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln +++ b/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{019B8700-7F84-4DCF-B3F1-3A19D951BA3E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{C4E264C7-91E7-4100-BA47-47CB12964025}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{C61770DF-C267-4B18-8822-D9C062FE806E}" @@ -182,6 +186,42 @@ Global {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}.Checked|x64.Build.0 = Debug|Any CPU {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}.Checked|x86.ActiveCfg = Debug|Any CPU {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}.Checked|x86.Build.0 = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x64.ActiveCfg = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x64.Build.0 = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x86.ActiveCfg = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x86.Build.0 = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|Any CPU.Build.0 = Release|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x64.ActiveCfg = Release|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x64.Build.0 = Release|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x86.ActiveCfg = Release|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x86.Build.0 = Release|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|Any CPU.Build.0 = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x64.ActiveCfg = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x64.Build.0 = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x86.ActiveCfg = Debug|Any CPU + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x86.Build.0 = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x64.ActiveCfg = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x64.Build.0 = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x86.ActiveCfg = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x86.Build.0 = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|Any CPU.Build.0 = Release|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x64.ActiveCfg = Release|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x64.Build.0 = Release|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x86.ActiveCfg = Release|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x86.Build.0 = Release|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|Any CPU.Build.0 = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x64.ActiveCfg = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x64.Build.0 = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x86.ActiveCfg = Debug|Any CPU + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x86.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -227,6 +267,8 @@ Global {05AA43B5-733A-43EF-8CE5-8BF4A18BD516} = {6C5230A5-919B-465B-9C98-852B85C96947} {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04} = {6C5230A5-919B-465B-9C98-852B85C96947} {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B} = {6C5230A5-919B-465B-9C98-852B85C96947} + {019B8700-7F84-4DCF-B3F1-3A19D951BA3E} = {6C5230A5-919B-465B-9C98-852B85C96947} + {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69} = {6C5230A5-919B-465B-9C98-852B85C96947} {C4E264C7-91E7-4100-BA47-47CB12964025} = {6C5230A5-919B-465B-9C98-852B85C96947} {C61770DF-C267-4B18-8822-D9C062FE806E} = {6C5230A5-919B-465B-9C98-852B85C96947} {1C01EFBD-2332-4392-BB4A-918178861EDC} = {8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311} diff --git a/src/libraries/System.Diagnostics.EventLog/NuGet.config b/src/libraries/System.Diagnostics.EventLog/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Diagnostics.EventLog/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln b/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln index d49a50d2ab3a9..f169b9af521f9 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln +++ b/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2391C35B-E06E-4BD8-ABF0-C7EE981336D1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{98DEBCAB-4C9E-46E8-BE0C-4717218556C2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9B348261-5B6D-47C9-8042-93B19FBF6780}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8042448A-EB54-4EBB-A1E0-BAA0B5A343D8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{36141B8B-E6F5-4AAF-A053-BDD189531BAF}" @@ -53,6 +57,14 @@ Global {2391C35B-E06E-4BD8-ABF0-C7EE981336D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {2391C35B-E06E-4BD8-ABF0-C7EE981336D1}.Release|Any CPU.ActiveCfg = Release|Any CPU {2391C35B-E06E-4BD8-ABF0-C7EE981336D1}.Release|Any CPU.Build.0 = Release|Any CPU + {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Release|Any CPU.Build.0 = Release|Any CPU + {9B348261-5B6D-47C9-8042-93B19FBF6780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B348261-5B6D-47C9-8042-93B19FBF6780}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B348261-5B6D-47C9-8042-93B19FBF6780}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B348261-5B6D-47C9-8042-93B19FBF6780}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -65,6 +77,8 @@ Global {E75BB739-AE88-4CAA-82CA-72224A39D8CE} = {36141B8B-E6F5-4AAF-A053-BDD189531BAF} {922C96F5-9F92-4F0E-A83D-D1BCDDD187F2} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} {2391C35B-E06E-4BD8-ABF0-C7EE981336D1} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} + {98DEBCAB-4C9E-46E8-BE0C-4717218556C2} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} + {9B348261-5B6D-47C9-8042-93B19FBF6780} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9FDF2FF3-5DFC-45E8-9959-B59FF906E689} diff --git a/src/libraries/System.Diagnostics.Process/NuGet.config b/src/libraries/System.Diagnostics.Process/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Diagnostics.Process/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln b/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln index b3031e86d29ae..b0cd46b3d2bf8 100644 --- a/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln +++ b/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln @@ -23,12 +23,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", ".. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{65CC713C-0735-4043-A4F2-9E1A2057A21B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{AEE4DD02-E38C-43E8-9150-3F034DA5979B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{2E775DDC-C58B-4EBA-BE62-9B08D7C48059}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{68690ADA-7203-479B-B4B9-B7CE23E349A6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5862A6EC-A500-4335-9006-51699482E1B2}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{A0DE3634-6C95-4AA2-AFD5-733D352B6756}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{97763BA2-BD91-480C-8173-65EA2A72EAA8}" @@ -101,10 +103,6 @@ Global {65CC713C-0735-4043-A4F2-9E1A2057A21B}.Debug|Any CPU.Build.0 = Debug|Any CPU {65CC713C-0735-4043-A4F2-9E1A2057A21B}.Release|Any CPU.ActiveCfg = Release|Any CPU {65CC713C-0735-4043-A4F2-9E1A2057A21B}.Release|Any CPU.Build.0 = Release|Any CPU - {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Release|Any CPU.Build.0 = Release|Any CPU {2E775DDC-C58B-4EBA-BE62-9B08D7C48059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E775DDC-C58B-4EBA-BE62-9B08D7C48059}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E775DDC-C58B-4EBA-BE62-9B08D7C48059}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -113,6 +111,14 @@ Global {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}.Release|Any CPU.Build.0 = Release|Any CPU + {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Release|Any CPU.Build.0 = Release|Any CPU + {5862A6EC-A500-4335-9006-51699482E1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5862A6EC-A500-4335-9006-51699482E1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5862A6EC-A500-4335-9006-51699482E1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5862A6EC-A500-4335-9006-51699482E1B2}.Release|Any CPU.Build.0 = Release|Any CPU {A0DE3634-6C95-4AA2-AFD5-733D352B6756}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A0DE3634-6C95-4AA2-AFD5-733D352B6756}.Debug|Any CPU.Build.0 = Debug|Any CPU {A0DE3634-6C95-4AA2-AFD5-733D352B6756}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -151,6 +157,8 @@ Global {84075D59-9D5E-40F7-A914-911087419FE4} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {65CC713C-0735-4043-A4F2-9E1A2057A21B} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} + {68690ADA-7203-479B-B4B9-B7CE23E349A6} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} + {5862A6EC-A500-4335-9006-51699482E1B2} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {A0DE3634-6C95-4AA2-AFD5-733D352B6756} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {B8F3933C-7C0D-41B3-8B1F-D507EF92156B} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {6CB8C6A4-3D21-47F6-A9A3-A9D1DA3E6B9F} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} @@ -159,7 +167,6 @@ Global {4792FFA1-1AD2-4230-8DE3-D2BCF1CF804F} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {F485B36D-8DDB-44EE-A993-2FCAEC81BE3E} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {6155E80C-6CE0-4A93-8BDF-80494E489BB1} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} - {AEE4DD02-E38C-43E8-9150-3F034DA5979B} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {2E775DDC-C58B-4EBA-BE62-9B08D7C48059} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {97763BA2-BD91-480C-8173-65EA2A72EAA8} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {546D7B53-3A00-47A4-BBE0-F4BA12126D6F} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} diff --git a/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln b/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln index d803d8f5effe4..679b4b9794975 100644 --- a/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln +++ b/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln @@ -33,6 +33,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Extensions", "..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj", "{449DFAB8-C413-44E4-BEAE-C61595DBCBC2}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5C279302-4206-49C5-B0FD-57DBBE60D404}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{623D46A5-8ED4-43CF-A01B-528F0A505090}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{039BB256-1BCF-4398-B586-C05F7C5225C4}" @@ -362,6 +366,42 @@ Global {449DFAB8-C413-44E4-BEAE-C61595DBCBC2}.Checked|x64.Build.0 = Debug|Any CPU {449DFAB8-C413-44E4-BEAE-C61595DBCBC2}.Checked|x86.ActiveCfg = Debug|Any CPU {449DFAB8-C413-44E4-BEAE-C61595DBCBC2}.Checked|x86.Build.0 = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x64.ActiveCfg = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x64.Build.0 = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x86.ActiveCfg = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x86.Build.0 = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|Any CPU.Build.0 = Release|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x64.ActiveCfg = Release|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x64.Build.0 = Release|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x86.ActiveCfg = Release|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x86.Build.0 = Release|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|Any CPU.Build.0 = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x64.ActiveCfg = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x64.Build.0 = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x86.ActiveCfg = Debug|Any CPU + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x86.Build.0 = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x64.ActiveCfg = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x64.Build.0 = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x86.ActiveCfg = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x86.Build.0 = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|Any CPU.Build.0 = Release|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x64.ActiveCfg = Release|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x64.Build.0 = Release|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x86.ActiveCfg = Release|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x86.Build.0 = Release|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|Any CPU.Build.0 = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x64.ActiveCfg = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x64.Build.0 = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x86.ActiveCfg = Debug|Any CPU + {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x86.Build.0 = Debug|Any CPU {623D46A5-8ED4-43CF-A01B-528F0A505090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {623D46A5-8ED4-43CF-A01B-528F0A505090}.Debug|Any CPU.Build.0 = Debug|Any CPU {623D46A5-8ED4-43CF-A01B-528F0A505090}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -413,6 +453,8 @@ Global {E5EB0B0B-FFAC-4C1B-AD59-292849F847FE} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {E5CCAE24-D76A-4409-BED8-A4E3F188A64A} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {449DFAB8-C413-44E4-BEAE-C61595DBCBC2} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} + {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} + {5C279302-4206-49C5-B0FD-57DBBE60D404} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {623D46A5-8ED4-43CF-A01B-528F0A505090} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {039BB256-1BCF-4398-B586-C05F7C5225C4} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {65FFFD20-CE5D-4FC0-A525-1C308186A16F} = {A376B9EB-8223-464D-A8F5-0000B26254F4} diff --git a/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln b/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln index c5caa75015cc8..2a7e15f6516dc 100644 --- a/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln +++ b/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{6AC1A337-2D08-4230-8D95-B52F324F291F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{07A0059D-96B6-4E44-B776-744536F213D3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{1E3AD374-6B64-45E5-A09F-1D51EE6290BA}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{15569044-E5D8-40B5-B718-A51ECAA6B259}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0EFD8A36-ACB0-4451-800E-DA867389324D}" @@ -158,6 +162,42 @@ Global {6AC1A337-2D08-4230-8D95-B52F324F291F}.Checked|x64.Build.0 = Debug|Any CPU {6AC1A337-2D08-4230-8D95-B52F324F291F}.Checked|x86.ActiveCfg = Debug|Any CPU {6AC1A337-2D08-4230-8D95-B52F324F291F}.Checked|x86.Build.0 = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x64.ActiveCfg = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x64.Build.0 = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x86.ActiveCfg = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x86.Build.0 = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Release|Any CPU.Build.0 = Release|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x64.ActiveCfg = Release|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x64.Build.0 = Release|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x86.ActiveCfg = Release|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x86.Build.0 = Release|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|Any CPU.Build.0 = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x64.ActiveCfg = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x64.Build.0 = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x86.ActiveCfg = Debug|Any CPU + {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x86.Build.0 = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x64.ActiveCfg = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x64.Build.0 = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x86.ActiveCfg = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x86.Build.0 = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|Any CPU.Build.0 = Release|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x64.ActiveCfg = Release|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x64.Build.0 = Release|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x86.ActiveCfg = Release|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x86.Build.0 = Release|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|Any CPU.Build.0 = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x64.ActiveCfg = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x64.Build.0 = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x86.ActiveCfg = Debug|Any CPU + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {4E534B56-D245-41B7-B4D0-F8AB7BCC8877} = {15569044-E5D8-40B5-B718-A51ECAA6B259} {566DC861-7C05-45AE-8F59-83D1A175A619} = {15569044-E5D8-40B5-B718-A51ECAA6B259} {6AC1A337-2D08-4230-8D95-B52F324F291F} = {15569044-E5D8-40B5-B718-A51ECAA6B259} + {07A0059D-96B6-4E44-B776-744536F213D3} = {15569044-E5D8-40B5-B718-A51ECAA6B259} + {1E3AD374-6B64-45E5-A09F-1D51EE6290BA} = {15569044-E5D8-40B5-B718-A51ECAA6B259} {6FF6D8F0-403D-40DF-9D75-895E2AF22B88} = {0EFD8A36-ACB0-4451-800E-DA867389324D} {A63F3AEA-F4ED-4047-A11F-490325530D92} = {0EFD8A36-ACB0-4451-800E-DA867389324D} {E5F5CCFF-4DBA-4323-82A6-8D472C488C0B} = {F8D19CA8-D65B-4C4B-9851-8E2836CFD72E} diff --git a/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln b/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln index 3fe8e66fc37bb..0bc23d64fae8d 100644 --- a/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln +++ b/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln @@ -25,6 +25,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Extensions", "..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj", "{0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{E7BDDF6F-685D-49F8-8590-7E242E26CC26}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{067272CD-1753-4090-8E10-B9EC9CE67253}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{637E7769-42D2-4541-9A63-32301113FA5A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{7C0A6923-A9BC-4F10-81E0-C535EEF537BB}" @@ -282,6 +286,42 @@ Global {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}.Checked|x64.Build.0 = Debug|Any CPU {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}.Checked|x86.ActiveCfg = Debug|Any CPU {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}.Checked|x86.Build.0 = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x64.ActiveCfg = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x64.Build.0 = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x86.ActiveCfg = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x86.Build.0 = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|Any CPU.Build.0 = Release|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x64.ActiveCfg = Release|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x64.Build.0 = Release|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x86.ActiveCfg = Release|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x86.Build.0 = Release|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|Any CPU.Build.0 = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x64.ActiveCfg = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x64.Build.0 = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x86.ActiveCfg = Debug|Any CPU + {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x86.Build.0 = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|Any CPU.Build.0 = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x64.ActiveCfg = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x64.Build.0 = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x86.ActiveCfg = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x86.Build.0 = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|Any CPU.ActiveCfg = Release|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|Any CPU.Build.0 = Release|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x64.ActiveCfg = Release|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x64.Build.0 = Release|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x86.ActiveCfg = Release|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x86.Build.0 = Release|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|Any CPU.Build.0 = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x64.ActiveCfg = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x64.Build.0 = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x86.ActiveCfg = Debug|Any CPU + {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x86.Build.0 = Debug|Any CPU {637E7769-42D2-4541-9A63-32301113FA5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {637E7769-42D2-4541-9A63-32301113FA5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {637E7769-42D2-4541-9A63-32301113FA5A}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -332,6 +372,8 @@ Global {4DAA5CFC-C59D-4C1B-A12A-BC9863F38C0C} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {BFDA7EE4-2407-4799-82B0-D977F3363A0D} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5} = {315BC231-270B-456C-919A-3E9BB50CDD7A} + {E7BDDF6F-685D-49F8-8590-7E242E26CC26} = {315BC231-270B-456C-919A-3E9BB50CDD7A} + {067272CD-1753-4090-8E10-B9EC9CE67253} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {637E7769-42D2-4541-9A63-32301113FA5A} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {7C0A6923-A9BC-4F10-81E0-C535EEF537BB} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {F6BCA6EF-777E-408B-B49B-B055B5A0BA19} = {6BA02609-AE23-4E80-8B4B-9C6548AA147A} diff --git a/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln b/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln index 9784a658ee6ca..4f8ad0e099eed 100644 --- a/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln +++ b/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{7ED6F742-A58B-4352-AD32-88F53E65B763}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{724D36C1-71F6-40D6-9150-020675BECE48}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{43A929AA-2373-4109-BC31-AD6838503506}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{269A342C-D693-495C-8A07-11E08C881F6B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{21E11D21-3706-49C7-ACA7-10BA9A021908}" @@ -158,6 +162,42 @@ Global {7ED6F742-A58B-4352-AD32-88F53E65B763}.Checked|x64.Build.0 = Debug|Any CPU {7ED6F742-A58B-4352-AD32-88F53E65B763}.Checked|x86.ActiveCfg = Debug|Any CPU {7ED6F742-A58B-4352-AD32-88F53E65B763}.Checked|x86.Build.0 = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|Any CPU.Build.0 = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x64.ActiveCfg = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x64.Build.0 = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x86.ActiveCfg = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x86.Build.0 = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Release|Any CPU.ActiveCfg = Release|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Release|Any CPU.Build.0 = Release|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x64.ActiveCfg = Release|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x64.Build.0 = Release|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x86.ActiveCfg = Release|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x86.Build.0 = Release|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|Any CPU.Build.0 = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x64.ActiveCfg = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x64.Build.0 = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x86.ActiveCfg = Debug|Any CPU + {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x86.Build.0 = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x64.ActiveCfg = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x64.Build.0 = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x86.ActiveCfg = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x86.Build.0 = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Release|Any CPU.Build.0 = Release|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Release|x64.ActiveCfg = Release|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Release|x64.Build.0 = Release|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Release|x86.ActiveCfg = Release|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Release|x86.Build.0 = Release|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Checked|Any CPU.Build.0 = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x64.ActiveCfg = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x64.Build.0 = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x86.ActiveCfg = Debug|Any CPU + {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {370DCE61-CBDF-466E-91DB-5AE622BF2E52} = {269A342C-D693-495C-8A07-11E08C881F6B} {63783D6D-0848-4303-8E7A-BBB7F65DCE9E} = {269A342C-D693-495C-8A07-11E08C881F6B} {7ED6F742-A58B-4352-AD32-88F53E65B763} = {269A342C-D693-495C-8A07-11E08C881F6B} + {724D36C1-71F6-40D6-9150-020675BECE48} = {269A342C-D693-495C-8A07-11E08C881F6B} + {43A929AA-2373-4109-BC31-AD6838503506} = {269A342C-D693-495C-8A07-11E08C881F6B} {6E159831-C97C-40FD-AD1A-E8B1EE3E7168} = {21E11D21-3706-49C7-ACA7-10BA9A021908} {24605C4D-2465-433D-A393-45CB950E0834} = {21E11D21-3706-49C7-ACA7-10BA9A021908} {D7C16DED-127A-4CBB-BBCF-DF133816413B} = {61AC03AE-7090-458C-A3AB-5A4CCFF6AD08} diff --git a/src/libraries/System.DirectoryServices.Protocols/NuGet.config b/src/libraries/System.DirectoryServices.Protocols/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.DirectoryServices.Protocols/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.DirectoryServices/NuGet.config b/src/libraries/System.DirectoryServices/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.DirectoryServices/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Drawing.Common/NuGet.config b/src/libraries/System.Drawing.Common/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Drawing.Common/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Drawing.Primitives/NuGet.config b/src/libraries/System.Drawing.Primitives/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Drawing.Primitives/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln b/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln index 4c5b704b6ea74..7001aeddab7ae 100644 --- a/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln +++ b/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{82D06D01-23ED-4A72-9101-5C9E8255D93A}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{37875A74-8496-4B3B-828D-C397F5379B65}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4}" @@ -178,6 +182,42 @@ Global {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}.Checked|x64.Build.0 = Debug|Any CPU {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}.Checked|x86.ActiveCfg = Debug|Any CPU {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}.Checked|x86.Build.0 = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x64.ActiveCfg = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x64.Build.0 = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x86.ActiveCfg = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x86.Build.0 = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|Any CPU.Build.0 = Release|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x64.ActiveCfg = Release|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x64.Build.0 = Release|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x86.ActiveCfg = Release|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x86.Build.0 = Release|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|Any CPU.Build.0 = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x64.ActiveCfg = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x64.Build.0 = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x86.ActiveCfg = Debug|Any CPU + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x86.Build.0 = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x64.ActiveCfg = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x64.Build.0 = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x86.ActiveCfg = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x86.Build.0 = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|Any CPU.Build.0 = Release|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x64.ActiveCfg = Release|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x64.Build.0 = Release|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x86.ActiveCfg = Release|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x86.Build.0 = Release|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|Any CPU.Build.0 = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x64.ActiveCfg = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x64.Build.0 = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x86.ActiveCfg = Debug|Any CPU + {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -186,6 +226,8 @@ Global {E70B35E3-B6C3-4196-9FAB-1A0D45748E79} = {37875A74-8496-4B3B-828D-C397F5379B65} {705D0D71-8890-4893-824F-E302CDE5349F} = {37875A74-8496-4B3B-828D-C397F5379B65} {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4} = {37875A74-8496-4B3B-828D-C397F5379B65} + {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8} = {37875A74-8496-4B3B-828D-C397F5379B65} + {82D06D01-23ED-4A72-9101-5C9E8255D93A} = {37875A74-8496-4B3B-828D-C397F5379B65} {32F01C47-D495-45CE-9567-E4C434F7D627} = {CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4} {CD1CDCDD-64FA-4E75-A74F-16A978C56449} = {CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4} {BFEF5B19-7D03-42BA-9CD1-D1B53F35D706} = {CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4} diff --git a/src/libraries/System.Globalization/System.Globalization.sln b/src/libraries/System.Globalization/System.Globalization.sln index 2989f693701a9..68e08a273a33b 100644 --- a/src/libraries/System.Globalization/System.Globalization.sln +++ b/src/libraries/System.Globalization/System.Globalization.sln @@ -19,6 +19,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{F17D674C-0B0A-47FB-8B81-5B8664564E23}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2DFC9D02-52CC-47EE-B360-CD5358DC02C9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5D1149E9-95DB-45B9-A6F8-8285F289591E}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4B81A206-3C49-4224-A031-42583071751B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C223E72F-FD21-43C3-AC7A-62BCF4A5C379}" @@ -218,6 +222,42 @@ Global {F17D674C-0B0A-47FB-8B81-5B8664564E23}.Checked|x64.Build.0 = Debug|Any CPU {F17D674C-0B0A-47FB-8B81-5B8664564E23}.Checked|x86.ActiveCfg = Debug|Any CPU {F17D674C-0B0A-47FB-8B81-5B8664564E23}.Checked|x86.Build.0 = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x64.ActiveCfg = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x64.Build.0 = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x86.ActiveCfg = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x86.Build.0 = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|Any CPU.Build.0 = Release|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x64.ActiveCfg = Release|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x64.Build.0 = Release|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x86.ActiveCfg = Release|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x86.Build.0 = Release|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|Any CPU.Build.0 = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x64.ActiveCfg = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x64.Build.0 = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x86.ActiveCfg = Debug|Any CPU + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x86.Build.0 = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x64.ActiveCfg = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x64.Build.0 = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x86.ActiveCfg = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x86.Build.0 = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|Any CPU.Build.0 = Release|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x64.ActiveCfg = Release|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x64.Build.0 = Release|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x86.ActiveCfg = Release|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x86.Build.0 = Release|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|Any CPU.Build.0 = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x64.ActiveCfg = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x64.Build.0 = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x86.ActiveCfg = Debug|Any CPU + {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -226,6 +266,8 @@ Global {E269F8BB-F629-4C96-B9B2-03A00D8B1BFB} = {4B81A206-3C49-4224-A031-42583071751B} {4ABAB509-1210-43B4-B274-76B4FE02BD9B} = {4B81A206-3C49-4224-A031-42583071751B} {F17D674C-0B0A-47FB-8B81-5B8664564E23} = {4B81A206-3C49-4224-A031-42583071751B} + {2DFC9D02-52CC-47EE-B360-CD5358DC02C9} = {4B81A206-3C49-4224-A031-42583071751B} + {5D1149E9-95DB-45B9-A6F8-8285F289591E} = {4B81A206-3C49-4224-A031-42583071751B} {79613DED-481D-44EF-BB89-7AC6BD53026B} = {C223E72F-FD21-43C3-AC7A-62BCF4A5C379} {40231BCB-E151-45E0-A1C4-4D559A434362} = {C223E72F-FD21-43C3-AC7A-62BCF4A5C379} {DD7E56B4-65B7-4822-A4E1-ECDD51524927} = {C223E72F-FD21-43C3-AC7A-62BCF4A5C379} diff --git a/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln b/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln index ee55a67f3ebc5..722a2821992c1 100644 --- a/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln +++ b/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{864B86AD-4BC9-4997-8370-EC8B2055FE08}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{1BC1DCD5-DECC-4712-8539-56E6D71A17FF}" @@ -53,6 +57,14 @@ Global {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}.Release|Any CPU.Build.0 = Release|Any CPU + {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Release|Any CPU.Build.0 = Release|Any CPU + {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -65,6 +77,8 @@ Global {A50E06CB-B581-46AB-B91F-4AAAA62A9F8C} = {1BC1DCD5-DECC-4712-8539-56E6D71A17FF} {C2A30FF0-54C2-461B-BF16-5DC610F54B52} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} + {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} + {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {42B626C7-CDFD-459B-86D8-239917F86516} diff --git a/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln b/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln index c7a1280a599c1..8f502c1d0ceb5 100644 --- a/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln +++ b/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DBD14497-E65E-45FC-99BA-DFE6641135BE}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A46DB030-84B9-49C0-8F75-98FE1290EF88}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4}" @@ -47,6 +51,14 @@ Global {DBD14497-E65E-45FC-99BA-DFE6641135BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {DBD14497-E65E-45FC-99BA-DFE6641135BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {DBD14497-E65E-45FC-99BA-DFE6641135BE}.Release|Any CPU.Build.0 = Release|Any CPU + {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Release|Any CPU.Build.0 = Release|Any CPU + {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,6 +70,8 @@ Global {9D260F5B-F8EC-41D2-8A30-60D6ADF0910A} = {A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4} {A3C36A2F-2586-43DF-B39C-A9D14DF8524E} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} {DBD14497-E65E-45FC-99BA-DFE6641135BE} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} + {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} + {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D2E26432-A647-4E61-9A30-DE6C62BBD632} diff --git a/src/libraries/System.IO.Compression/System.IO.Compression.sln b/src/libraries/System.IO.Compression/System.IO.Compression.sln index 7378d594ea0d7..6999c4bd0eca2 100644 --- a/src/libraries/System.IO.Compression/System.IO.Compression.sln +++ b/src/libraries/System.IO.Compression/System.IO.Compression.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{65C7FDC3-D18B-4888-88C1-EA22B9247831}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2252FA2C-1919-4EC4-A9A7-35516EFDF76F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{A96AB805-19C0-4F48-9703-84939C7EED20}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BB657E6F-1D06-4E7A-B4C2-B40A071A2A44}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{350F6B1E-B006-4EA5-BA9E-41F57FF84FF1}" @@ -53,6 +57,14 @@ Global {65C7FDC3-D18B-4888-88C1-EA22B9247831}.Debug|Any CPU.Build.0 = Debug|Any CPU {65C7FDC3-D18B-4888-88C1-EA22B9247831}.Release|Any CPU.ActiveCfg = Release|Any CPU {65C7FDC3-D18B-4888-88C1-EA22B9247831}.Release|Any CPU.Build.0 = Release|Any CPU + {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Release|Any CPU.Build.0 = Release|Any CPU + {A96AB805-19C0-4F48-9703-84939C7EED20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A96AB805-19C0-4F48-9703-84939C7EED20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A96AB805-19C0-4F48-9703-84939C7EED20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A96AB805-19C0-4F48-9703-84939C7EED20}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -65,6 +77,8 @@ Global {BD3E0A9D-1E3D-4E5A-A095-AB33B234AFE7} = {350F6B1E-B006-4EA5-BA9E-41F57FF84FF1} {ED776381-E13D-4A0B-ACB4-74C5A784BD25} = {8541C42E-9FC4-4077-B828-720BD028F1F5} {65C7FDC3-D18B-4888-88C1-EA22B9247831} = {8541C42E-9FC4-4077-B828-720BD028F1F5} + {2252FA2C-1919-4EC4-A9A7-35516EFDF76F} = {8541C42E-9FC4-4077-B828-720BD028F1F5} + {A96AB805-19C0-4F48-9703-84939C7EED20} = {8541C42E-9FC4-4077-B828-720BD028F1F5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0F6F5B24-5CE5-45F2-9169-FEBEF2A3FE80} diff --git a/src/libraries/System.IO.FileSystem.AccessControl/NuGet.config b/src/libraries/System.IO.FileSystem.AccessControl/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.IO.FileSystem.AccessControl/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln b/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln index fe8ec0c1d5638..ad7dc3b80cad2 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln +++ b/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{C2CCE41E-FD28-4FF7-98AF-49965F051C4F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{8F141019-D882-4FE7-9A92-74415DBCD858}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F74D982D-DFE5-48DA-87C0-245FC612F118}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{4626E870-1F74-4ED4-AF80-DDDD42DEF47E}" @@ -47,6 +51,14 @@ Global {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}.Release|Any CPU.Build.0 = Release|Any CPU + {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Release|Any CPU.Build.0 = Release|Any CPU + {8F141019-D882-4FE7-9A92-74415DBCD858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F141019-D882-4FE7-9A92-74415DBCD858}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F141019-D882-4FE7-9A92-74415DBCD858}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F141019-D882-4FE7-9A92-74415DBCD858}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,6 +70,8 @@ Global {A0FB000A-C607-4CBB-9223-A5FCA85DF23F} = {4626E870-1F74-4ED4-AF80-DDDD42DEF47E} {03A51C60-B41B-409B-97AA-4084042C78D7} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} + {C2CCE41E-FD28-4FF7-98AF-49965F051C4F} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} + {8F141019-D882-4FE7-9A92-74415DBCD858} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF704C7D-836B-41D4-919E-B0874D934A08} diff --git a/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln b/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln index 8b12ed4d26ee3..fa986042e4728 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln +++ b/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{BB57F4F3-0519-4846-8CEC-04D2D2CFE144}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{24B02C33-7BFD-4D9A-90EB-551D81DEB58D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{88BDA307-9C09-4690-B3BE-6C67DA71E976}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A4E6A754-5006-4E2F-BC57-0A96E3A82A4D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{FB3E732D-C87B-41E9-ADC2-C2D84B87D04F}" @@ -47,6 +51,14 @@ Global {BB57F4F3-0519-4846-8CEC-04D2D2CFE144}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB57F4F3-0519-4846-8CEC-04D2D2CFE144}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB57F4F3-0519-4846-8CEC-04D2D2CFE144}.Release|Any CPU.Build.0 = Release|Any CPU + {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Release|Any CPU.Build.0 = Release|Any CPU + {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,6 +70,8 @@ Global {1D98691D-E3BD-483A-B449-F8F875A0BC0B} = {FB3E732D-C87B-41E9-ADC2-C2D84B87D04F} {310BA7DB-1A9E-46E1-B414-606474FFFFFA} = {BCDF2178-959A-48C9-B26D-18E62C80199C} {BB57F4F3-0519-4846-8CEC-04D2D2CFE144} = {BCDF2178-959A-48C9-B26D-18E62C80199C} + {24B02C33-7BFD-4D9A-90EB-551D81DEB58D} = {BCDF2178-959A-48C9-B26D-18E62C80199C} + {88BDA307-9C09-4690-B3BE-6C67DA71E976} = {BCDF2178-959A-48C9-B26D-18E62C80199C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3D76AA3-27C1-48BF-9474-42E0495BA814} diff --git a/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln b/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln index 1958430a9e5ab..736f6ce0b86d1 100644 --- a/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln +++ b/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln @@ -29,6 +29,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D7DF8034-3AE5-4DEF-BCC4-6353239391BF}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{40E79B9B-E9EA-4012-945B-5DB8E02F60E2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{6599D78B-6462-423C-9C31-62A4990FF5C6}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{5E9D796C-426C-47E0-AA28-6CAE530855B7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{E004B4E4-0D54-4CAA-89C5-FCDB72C99846}" @@ -113,6 +117,14 @@ Global {D7DF8034-3AE5-4DEF-BCC4-6353239391BF}.Debug|Any CPU.Build.0 = Debug|Any CPU {D7DF8034-3AE5-4DEF-BCC4-6353239391BF}.Release|Any CPU.ActiveCfg = Release|Any CPU {D7DF8034-3AE5-4DEF-BCC4-6353239391BF}.Release|Any CPU.Build.0 = Release|Any CPU + {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Release|Any CPU.Build.0 = Release|Any CPU + {6599D78B-6462-423C-9C31-62A4990FF5C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6599D78B-6462-423C-9C31-62A4990FF5C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6599D78B-6462-423C-9C31-62A4990FF5C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6599D78B-6462-423C-9C31-62A4990FF5C6}.Release|Any CPU.Build.0 = Release|Any CPU {5E9D796C-426C-47E0-AA28-6CAE530855B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E9D796C-426C-47E0-AA28-6CAE530855B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E9D796C-426C-47E0-AA28-6CAE530855B7}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -160,6 +172,8 @@ Global {8A502375-D99B-4C43-92C9-F5DFB336AF38} = {A0499117-998E-494E-943B-86F428E5C59F} {877E39A8-51CB-463A-AF4C-6FAE4F438075} = {A0499117-998E-494E-943B-86F428E5C59F} {D7DF8034-3AE5-4DEF-BCC4-6353239391BF} = {A0499117-998E-494E-943B-86F428E5C59F} + {40E79B9B-E9EA-4012-945B-5DB8E02F60E2} = {A0499117-998E-494E-943B-86F428E5C59F} + {6599D78B-6462-423C-9C31-62A4990FF5C6} = {A0499117-998E-494E-943B-86F428E5C59F} {5E9D796C-426C-47E0-AA28-6CAE530855B7} = {A0499117-998E-494E-943B-86F428E5C59F} {2069A1E6-5A4A-43F2-ACDE-050B3DBB0A7D} = {A0499117-998E-494E-943B-86F428E5C59F} {3E06E543-2562-4AFB-B04F-520485B876A8} = {A0499117-998E-494E-943B-86F428E5C59F} diff --git a/src/libraries/System.IO.IsolatedStorage/NuGet.config b/src/libraries/System.IO.IsolatedStorage/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.IO.IsolatedStorage/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln b/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln index 9624f9e282b08..1c16f29839472 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln +++ b/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{4B990529-DAA4-4AEC-A625-FDCA3EF64E25}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{9F271789-0931-4414-B006-0A1B8362D69C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E9193727-72AB-4A35-BABF-A11D7C1A8B04}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{E91F427C-6CD7-496B-B4E8-D837CB8B96F8}" @@ -53,6 +57,14 @@ Global {4B990529-DAA4-4AEC-A625-FDCA3EF64E25}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B990529-DAA4-4AEC-A625-FDCA3EF64E25}.Release|Any CPU.ActiveCfg = Release|Any CPU {4B990529-DAA4-4AEC-A625-FDCA3EF64E25}.Release|Any CPU.Build.0 = Release|Any CPU + {9F271789-0931-4414-B006-0A1B8362D69C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F271789-0931-4414-B006-0A1B8362D69C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F271789-0931-4414-B006-0A1B8362D69C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F271789-0931-4414-B006-0A1B8362D69C}.Release|Any CPU.Build.0 = Release|Any CPU + {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -65,6 +77,8 @@ Global {8B9258B7-1C54-4FFE-9512-2B7323AEF92A} = {E91F427C-6CD7-496B-B4E8-D837CB8B96F8} {4A95E6CD-A466-46BC-A6C7-C65DA45B3388} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} {4B990529-DAA4-4AEC-A625-FDCA3EF64E25} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} + {9F271789-0931-4414-B006-0A1B8362D69C} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} + {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F8DDBB46-7ACE-4C13-91B4-FFB7E93363D9} diff --git a/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln b/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln index e4668476e4742..3227bf2ddfeb9 100644 --- a/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln +++ b/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln @@ -7,14 +7,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes.AccessContr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes.AccessControl.Tests", "tests\System.IO.Pipes.AccessControl.Tests.csproj", "{7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\src\System.IO.Pipes.csproj", "{5AE837A0-E966-41E5-9230-0830BB3E727F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{A6554F7C-F4FC-463D-9C0F-396B976FDB90}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{04D36F0B-F60F-43E8-931D-A85E312EAD1D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2CFDBF7E-CDBE-43F4-A1B2-25E634672285}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{D9DEC09D-3DC0-428C-A7F0-116CDD43BC69}" @@ -47,10 +49,6 @@ Global {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}.Debug|Any CPU.Build.0 = Debug|Any CPU {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}.Release|Any CPU.ActiveCfg = Release|Any CPU {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}.Release|Any CPU.Build.0 = Release|Any CPU - {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Debug|Any CPU.Build.0 = Debug|Any CPU - {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Release|Any CPU.ActiveCfg = Release|Any CPU - {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Release|Any CPU.Build.0 = Release|Any CPU {5AE837A0-E966-41E5-9230-0830BB3E727F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5AE837A0-E966-41E5-9230-0830BB3E727F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AE837A0-E966-41E5-9230-0830BB3E727F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -63,6 +61,14 @@ Global {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}.Debug|Any CPU.Build.0 = Debug|Any CPU {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}.Release|Any CPU.ActiveCfg = Release|Any CPU {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}.Release|Any CPU.Build.0 = Release|Any CPU + {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Release|Any CPU.Build.0 = Release|Any CPU + {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Release|Any CPU.Build.0 = Release|Any CPU {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -79,11 +85,12 @@ Global {DF7DE1B3-C58E-4EBB-86C5-87EB59A177C6} = {E1F66F1E-923F-4B07-A1E9-3F1BB01F221A} {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38} = {E1F66F1E-923F-4B07-A1E9-3F1BB01F221A} {26E03980-4DB8-43B6-8737-1F7CAF7E5089} = {ADDC6FEE-EDF2-4EAD-B802-1BCF686E0D71} - {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542} = {ADDC6FEE-EDF2-4EAD-B802-1BCF686E0D71} {A6554F7C-F4FC-463D-9C0F-396B976FDB90} = {ADDC6FEE-EDF2-4EAD-B802-1BCF686E0D71} {B6731AC0-E4F2-4E6C-B6DF-63EF396FCB71} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {5AE837A0-E966-41E5-9230-0830BB3E727F} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} + {04D36F0B-F60F-43E8-931D-A85E312EAD1D} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} + {2CFDBF7E-CDBE-43F4-A1B2-25E634672285} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {D9DEC09D-3DC0-428C-A7F0-116CDD43BC69} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} EndGlobalSection diff --git a/src/libraries/System.IO.Pipes/System.IO.Pipes.sln b/src/libraries/System.IO.Pipes/System.IO.Pipes.sln index 6affa9ea08f6f..8f0070a29d784 100644 --- a/src/libraries/System.IO.Pipes/System.IO.Pipes.sln +++ b/src/libraries/System.IO.Pipes/System.IO.Pipes.sln @@ -37,6 +37,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DD675156-B16E-44C8-854B-AEC717FF4DE0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{FD0D06C7-A080-416E-975B-98BC8C4AE5D6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{54399E44-3A81-4983-85D3-2B88065FE76A}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.ProtectedData", "..\System.Security.Cryptography.ProtectedData\ref\System.Security.Cryptography.ProtectedData.csproj", "{25441E1F-971D-4FF3-BA5A-2FBAAC3EB9FF}" @@ -141,6 +145,14 @@ Global {DD675156-B16E-44C8-854B-AEC717FF4DE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD675156-B16E-44C8-854B-AEC717FF4DE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD675156-B16E-44C8-854B-AEC717FF4DE0}.Release|Any CPU.Build.0 = Release|Any CPU + {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Release|Any CPU.Build.0 = Release|Any CPU + {54399E44-3A81-4983-85D3-2B88065FE76A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54399E44-3A81-4983-85D3-2B88065FE76A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54399E44-3A81-4983-85D3-2B88065FE76A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54399E44-3A81-4983-85D3-2B88065FE76A}.Release|Any CPU.Build.0 = Release|Any CPU {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -200,6 +212,8 @@ Global {A15B634C-E8F4-4822-BB45-66B95DC1C38F} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {3A471AEB-FCCB-43DF-9C04-F00FA9AAF81E} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {DD675156-B16E-44C8-854B-AEC717FF4DE0} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} + {FD0D06C7-A080-416E-975B-98BC8C4AE5D6} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} + {54399E44-3A81-4983-85D3-2B88065FE76A} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {E565DD4A-0749-4F5E-8476-EF44D742E377} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {15CB5F16-593B-460D-BDC3-134A56EF3B5F} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} diff --git a/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln b/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln index 010316af865b0..7c02c42fbe8d5 100644 --- a/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln +++ b/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{B890249B-B590-4323-B1F6-0C1AB8E02D68}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{0B4B6C46-B848-43D3-B230-0A526ABAD1F5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D132DC37-ADF5-4210-A3C6-7480546CED7F}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A8D21009-1410-4367-8616-2075882003FF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7BB3C727-EA87-416E-84DD-34ADD5540067}" @@ -178,6 +182,42 @@ Global {B890249B-B590-4323-B1F6-0C1AB8E02D68}.Checked|x64.Build.0 = Debug|Any CPU {B890249B-B590-4323-B1F6-0C1AB8E02D68}.Checked|x86.ActiveCfg = Debug|Any CPU {B890249B-B590-4323-B1F6-0C1AB8E02D68}.Checked|x86.Build.0 = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x64.ActiveCfg = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x64.Build.0 = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x86.ActiveCfg = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x86.Build.0 = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|Any CPU.Build.0 = Release|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x64.ActiveCfg = Release|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x64.Build.0 = Release|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x86.ActiveCfg = Release|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x86.Build.0 = Release|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|Any CPU.Build.0 = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x64.ActiveCfg = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x64.Build.0 = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x86.ActiveCfg = Debug|Any CPU + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x86.Build.0 = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x64.ActiveCfg = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x64.Build.0 = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x86.ActiveCfg = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x86.Build.0 = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|Any CPU.Build.0 = Release|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x64.ActiveCfg = Release|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x64.Build.0 = Release|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x86.ActiveCfg = Release|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x86.Build.0 = Release|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|Any CPU.Build.0 = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x64.ActiveCfg = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x64.Build.0 = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x86.ActiveCfg = Debug|Any CPU + {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -186,6 +226,8 @@ Global {074D8726-9CC3-43B5-9D28-1AD33A6100F7} = {A8D21009-1410-4367-8616-2075882003FF} {658B1534-3B9E-4108-9AFE-161562723E9D} = {A8D21009-1410-4367-8616-2075882003FF} {B890249B-B590-4323-B1F6-0C1AB8E02D68} = {A8D21009-1410-4367-8616-2075882003FF} + {0B4B6C46-B848-43D3-B230-0A526ABAD1F5} = {A8D21009-1410-4367-8616-2075882003FF} + {D132DC37-ADF5-4210-A3C6-7480546CED7F} = {A8D21009-1410-4367-8616-2075882003FF} {9963A1DA-8EBD-47EF-8BF2-7B6444BE6FCE} = {7BB3C727-EA87-416E-84DD-34ADD5540067} {7DC8F0E9-5D6C-47F7-AE83-9AB1180AF51E} = {7BB3C727-EA87-416E-84DD-34ADD5540067} {D14DC8D4-F45E-412D-AE98-CA07F900347B} = {7BB3C727-EA87-416E-84DD-34ADD5540067} diff --git a/src/libraries/System.Management/NuGet.config b/src/libraries/System.Management/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Management/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Memory.Data/System.Memory.Data.sln b/src/libraries/System.Memory.Data/System.Memory.Data.sln index 7a63841312467..1d656b10ba26a 100644 --- a/src/libraries/System.Memory.Data/System.Memory.Data.sln +++ b/src/libraries/System.Memory.Data/System.Memory.Data.sln @@ -19,6 +19,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{9EB09AA4-4338-4242-9135-1E9BA3140B4A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{4EC32671-F20B-4012-8212-4146F89EB470}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{1D93DCD8-BF67-4FB5-A25A-7837F230B173}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{6A2B5C68-14C3-4989-8530-D51A138C72AE}" @@ -75,6 +79,14 @@ Global {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}.Debug|Any CPU.Build.0 = Debug|Any CPU {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}.Release|Any CPU.ActiveCfg = Release|Any CPU {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}.Release|Any CPU.Build.0 = Release|Any CPU + {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Release|Any CPU.Build.0 = Release|Any CPU + {4EC32671-F20B-4012-8212-4146F89EB470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EC32671-F20B-4012-8212-4146F89EB470}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EC32671-F20B-4012-8212-4146F89EB470}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EC32671-F20B-4012-8212-4146F89EB470}.Release|Any CPU.Build.0 = Release|Any CPU {1D93DCD8-BF67-4FB5-A25A-7837F230B173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D93DCD8-BF67-4FB5-A25A-7837F230B173}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D93DCD8-BF67-4FB5-A25A-7837F230B173}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -99,6 +111,8 @@ Global {ACDB56AF-7B9F-4762-9764-D6FF09118D09} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} {E17B915A-81CA-44D8-818E-512B65609475} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} + {9EB09AA4-4338-4242-9135-1E9BA3140B4A} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} + {4EC32671-F20B-4012-8212-4146F89EB470} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} {6A2B5C68-14C3-4989-8530-D51A138C72AE} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Memory/System.Memory.sln b/src/libraries/System.Memory/System.Memory.sln index c59ab842d2d4e..b78cd06b73466 100644 --- a/src/libraries/System.Memory/System.Memory.sln +++ b/src/libraries/System.Memory/System.Memory.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{4E9C4BA9-5FE2-4774-AC6F-A42913D57314}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{DE49AC8E-5D29-4093-B761-811AE382204A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{371ACE6F-1F94-4B14-80DE-4060249E31D3}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C352AC7D-959D-431F-AF83-2CA506B70D59}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FA259C32-B79B-4DE2-9677-055D5D25FA33}" @@ -158,6 +162,42 @@ Global {4E9C4BA9-5FE2-4774-AC6F-A42913D57314}.Checked|x64.Build.0 = Debug|Any CPU {4E9C4BA9-5FE2-4774-AC6F-A42913D57314}.Checked|x86.ActiveCfg = Debug|Any CPU {4E9C4BA9-5FE2-4774-AC6F-A42913D57314}.Checked|x86.Build.0 = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x64.ActiveCfg = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x64.Build.0 = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x86.ActiveCfg = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x86.Build.0 = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|Any CPU.Build.0 = Release|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x64.ActiveCfg = Release|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x64.Build.0 = Release|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x86.ActiveCfg = Release|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x86.Build.0 = Release|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|Any CPU.Build.0 = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x64.ActiveCfg = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x64.Build.0 = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x86.ActiveCfg = Debug|Any CPU + {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x86.Build.0 = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x64.ActiveCfg = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x64.Build.0 = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x86.ActiveCfg = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x86.Build.0 = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|Any CPU.Build.0 = Release|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x64.ActiveCfg = Release|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x64.Build.0 = Release|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x86.ActiveCfg = Release|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x86.Build.0 = Release|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|Any CPU.Build.0 = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x64.ActiveCfg = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x64.Build.0 = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x86.ActiveCfg = Debug|Any CPU + {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {7746BFD6-E6D6-4703-AA2D-43380B5DEA22} = {C352AC7D-959D-431F-AF83-2CA506B70D59} {C9417154-D8DB-4FF9-9DD8-6B2ED351FC92} = {C352AC7D-959D-431F-AF83-2CA506B70D59} {4E9C4BA9-5FE2-4774-AC6F-A42913D57314} = {C352AC7D-959D-431F-AF83-2CA506B70D59} + {DE49AC8E-5D29-4093-B761-811AE382204A} = {C352AC7D-959D-431F-AF83-2CA506B70D59} + {371ACE6F-1F94-4B14-80DE-4060249E31D3} = {C352AC7D-959D-431F-AF83-2CA506B70D59} {6A54FACA-933E-4C1D-92AB-1A5506CFC212} = {FA259C32-B79B-4DE2-9677-055D5D25FA33} {C2BC6AE7-7E8B-4AA2-8E9F-5D4B9127B297} = {FA259C32-B79B-4DE2-9677-055D5D25FA33} {9112BAE3-344D-4DD0-ADC9-478D82B84584} = {7212FBCF-E89D-4065-9DCE-D5F7E5D3EF1D} diff --git a/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln b/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln index 2313d1c589f82..e5379c37a82af 100644 --- a/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln +++ b/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln @@ -25,6 +25,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{8233C54C-797C-4CC0-B40E-68C1E82E509B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{EA992513-9CA4-4DEB-B0EE-A8FD0252B451}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{BC7D3412-DBCB-4863-8BF8-41899E32608C}" @@ -93,6 +97,14 @@ Global {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}.Debug|Any CPU.Build.0 = Debug|Any CPU {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}.Release|Any CPU.ActiveCfg = Release|Any CPU {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}.Release|Any CPU.Build.0 = Release|Any CPU + {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Release|Any CPU.Build.0 = Release|Any CPU + {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Release|Any CPU.Build.0 = Release|Any CPU {EA992513-9CA4-4DEB-B0EE-A8FD0252B451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EA992513-9CA4-4DEB-B0EE-A8FD0252B451}.Debug|Any CPU.Build.0 = Debug|Any CPU {EA992513-9CA4-4DEB-B0EE-A8FD0252B451}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -120,6 +132,8 @@ Global {7DC969DA-8BD3-4E64-88E8-26AFE65BFF7E} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} {3EEB6FCC-2592-4879-ADDD-0FDC7AEB7BC1} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} + {8233C54C-797C-4CC0-B40E-68C1E82E509B} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} + {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} {BC7D3412-DBCB-4863-8BF8-41899E32608C} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln b/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln index ad70edab4d906..ba3c9a80265d6 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln +++ b/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln @@ -33,6 +33,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{BACC5257-6CA8-45C7-970F-C8D501DA59AB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{77BCC140-E934-4A59-824A-0DE89D0955AF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{A6CF790E-772E-4265-A961-D47CA51F5757}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{8ABBBDC5-48A1-43BA-A629-AE58C35318AA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{E470810A-BAF2-4B3C-92CB-72007B7F1B6A}" @@ -117,6 +121,14 @@ Global {BACC5257-6CA8-45C7-970F-C8D501DA59AB}.Debug|Any CPU.Build.0 = Debug|Any CPU {BACC5257-6CA8-45C7-970F-C8D501DA59AB}.Release|Any CPU.ActiveCfg = Release|Any CPU {BACC5257-6CA8-45C7-970F-C8D501DA59AB}.Release|Any CPU.Build.0 = Release|Any CPU + {77BCC140-E934-4A59-824A-0DE89D0955AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77BCC140-E934-4A59-824A-0DE89D0955AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77BCC140-E934-4A59-824A-0DE89D0955AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77BCC140-E934-4A59-824A-0DE89D0955AF}.Release|Any CPU.Build.0 = Release|Any CPU + {A6CF790E-772E-4265-A961-D47CA51F5757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A6CF790E-772E-4265-A961-D47CA51F5757}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A6CF790E-772E-4265-A961-D47CA51F5757}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A6CF790E-772E-4265-A961-D47CA51F5757}.Release|Any CPU.Build.0 = Release|Any CPU {8ABBBDC5-48A1-43BA-A629-AE58C35318AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8ABBBDC5-48A1-43BA-A629-AE58C35318AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {8ABBBDC5-48A1-43BA-A629-AE58C35318AA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -148,6 +160,8 @@ Global {DE2A69CC-4962-4BF6-A714-41A87A6C045B} = {49E09973-383D-4AD6-9D88-B93A02031607} {28C24BF8-8E08-485F-8EEE-817EB847774C} = {49E09973-383D-4AD6-9D88-B93A02031607} {BACC5257-6CA8-45C7-970F-C8D501DA59AB} = {49E09973-383D-4AD6-9D88-B93A02031607} + {77BCC140-E934-4A59-824A-0DE89D0955AF} = {49E09973-383D-4AD6-9D88-B93A02031607} + {A6CF790E-772E-4265-A961-D47CA51F5757} = {49E09973-383D-4AD6-9D88-B93A02031607} {E470810A-BAF2-4B3C-92CB-72007B7F1B6A} = {49E09973-383D-4AD6-9D88-B93A02031607} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Http/NuGet.config b/src/libraries/System.Net.Http/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Net.Http/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Net.Http/System.Net.Http.sln b/src/libraries/System.Net.Http/System.Net.Http.sln index cb07432f85403..d83b980a894db 100644 --- a/src/libraries/System.Net.Http/System.Net.Http.sln +++ b/src/libraries/System.Net.Http/System.Net.Http.sln @@ -33,6 +33,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{ACDD8D8E-6945-41BC-87BD-1BD225653521}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3CD76528-2D01-42EF-BE32-888E4E9AFEFA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B99145D1-7A6A-4E72-905B-43D72C15C9A9}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{32FE3BA2-6FC8-4537-BD04-47236BAFE9F0}" @@ -117,6 +121,14 @@ Global {ACDD8D8E-6945-41BC-87BD-1BD225653521}.Debug|Any CPU.Build.0 = Debug|Any CPU {ACDD8D8E-6945-41BC-87BD-1BD225653521}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACDD8D8E-6945-41BC-87BD-1BD225653521}.Release|Any CPU.Build.0 = Release|Any CPU + {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Release|Any CPU.Build.0 = Release|Any CPU + {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Release|Any CPU.Build.0 = Release|Any CPU {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}.Debug|Any CPU.Build.0 = Debug|Any CPU {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -147,6 +159,8 @@ Global {F1FFB6F5-628E-4DF5-8FD0-9ADFB9EF5E91} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {819DB839-291D-4128-A2D8-719340A7DEBF} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {ACDD8D8E-6945-41BC-87BD-1BD225653521} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} + {3CD76528-2D01-42EF-BE32-888E4E9AFEFA} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} + {B99145D1-7A6A-4E72-905B-43D72C15C9A9} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {32FE3BA2-6FC8-4537-BD04-47236BAFE9F0} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} EndGlobalSection diff --git a/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln b/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln index 0258c96120588..b1db0d209d086 100644 --- a/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln +++ b/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D878C9A2-651A-4D46-BF8A-E4394F3F3967}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{8D838854-1462-48E8-9C06-E80F48364216}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{75DAAF3A-23E3-4C9C-A701-BA5494346925}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AE12BA12-7BDB-4361-922F-AAA100384926}" @@ -49,6 +53,14 @@ Global {D878C9A2-651A-4D46-BF8A-E4394F3F3967}.Debug|Any CPU.Build.0 = Debug|Any CPU {D878C9A2-651A-4D46-BF8A-E4394F3F3967}.Release|Any CPU.ActiveCfg = Release|Any CPU {D878C9A2-651A-4D46-BF8A-E4394F3F3967}.Release|Any CPU.Build.0 = Release|Any CPU + {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Release|Any CPU.Build.0 = Release|Any CPU + {8D838854-1462-48E8-9C06-E80F48364216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D838854-1462-48E8-9C06-E80F48364216}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D838854-1462-48E8-9C06-E80F48364216}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D838854-1462-48E8-9C06-E80F48364216}.Release|Any CPU.Build.0 = Release|Any CPU {75DAAF3A-23E3-4C9C-A701-BA5494346925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75DAAF3A-23E3-4C9C-A701-BA5494346925}.Debug|Any CPU.Build.0 = Debug|Any CPU {75DAAF3A-23E3-4C9C-A701-BA5494346925}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -64,6 +76,8 @@ Global {D48FCA59-B78B-4E81-8DB5-1B0B6596F71B} = {A3A29B10-F45E-487B-A2A0-EA809B62AF9D} {706D27A6-E66A-4FF5-9E6A-EA1B8BC52FB2} = {633A5486-7617-411C-B724-172F4B4E3A4F} {D878C9A2-651A-4D46-BF8A-E4394F3F3967} = {633A5486-7617-411C-B724-172F4B4E3A4F} + {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB} = {633A5486-7617-411C-B724-172F4B4E3A4F} + {8D838854-1462-48E8-9C06-E80F48364216} = {633A5486-7617-411C-B724-172F4B4E3A4F} {75DAAF3A-23E3-4C9C-A701-BA5494346925} = {633A5486-7617-411C-B724-172F4B4E3A4F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Mail/System.Net.Mail.sln b/src/libraries/System.Net.Mail/System.Net.Mail.sln index f8f24fa8580ce..9e9414252155a 100644 --- a/src/libraries/System.Net.Mail/System.Net.Mail.sln +++ b/src/libraries/System.Net.Mail/System.Net.Mail.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{02A90ADA-F294-4036-90BE-5040393BA37C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DFA479C6-DDF9-4AE0-91BB-08041FF1B7C8}" @@ -55,6 +59,14 @@ Global {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}.Release|Any CPU.Build.0 = Release|Any CPU + {02A90ADA-F294-4036-90BE-5040393BA37C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02A90ADA-F294-4036-90BE-5040393BA37C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02A90ADA-F294-4036-90BE-5040393BA37C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02A90ADA-F294-4036-90BE-5040393BA37C}.Release|Any CPU.Build.0 = Release|Any CPU + {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Release|Any CPU.Build.0 = Release|Any CPU {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -71,6 +83,8 @@ Global {1BB79710-16BD-4ED4-8BF4-13D25CBF4208} = {A08D08E8-610F-47A0-8747-01223F9430C5} {AF805BBD-C4A4-4D69-A911-D651E008C655} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} + {02A90ADA-F294-4036-90BE-5040393BA37C} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} + {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln b/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln index 72d2dd5a7d6fe..206e3e1095abf 100644 --- a/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln +++ b/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D62E59F2-BDF3-4060-85E0-20D1BB41B95E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3DDC9528-201B-465C-BE02-734582A5CACB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2262F921-FDFD-420C-9E2E-BC4A7985BF9D}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{FB254BF6-9C7C-4A35-A8B1-FB8832382442}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6E7B2B93-21B0-457F-84C3-AE62DABC73E2}" @@ -55,6 +59,14 @@ Global {D62E59F2-BDF3-4060-85E0-20D1BB41B95E}.Debug|Any CPU.Build.0 = Debug|Any CPU {D62E59F2-BDF3-4060-85E0-20D1BB41B95E}.Release|Any CPU.ActiveCfg = Release|Any CPU {D62E59F2-BDF3-4060-85E0-20D1BB41B95E}.Release|Any CPU.Build.0 = Release|Any CPU + {3DDC9528-201B-465C-BE02-734582A5CACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DDC9528-201B-465C-BE02-734582A5CACB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DDC9528-201B-465C-BE02-734582A5CACB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DDC9528-201B-465C-BE02-734582A5CACB}.Release|Any CPU.Build.0 = Release|Any CPU + {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Release|Any CPU.Build.0 = Release|Any CPU {FB254BF6-9C7C-4A35-A8B1-FB8832382442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FB254BF6-9C7C-4A35-A8B1-FB8832382442}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB254BF6-9C7C-4A35-A8B1-FB8832382442}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -71,6 +83,8 @@ Global {A3FC70CE-3746-4E03-A92F-0102716FA97E} = {47DBE178-9476-4595-9C71-424D54314C2E} {CC5371F7-FCD9-4BDE-8639-6DD5F3B71175} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} {D62E59F2-BDF3-4060-85E0-20D1BB41B95E} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} + {3DDC9528-201B-465C-BE02-734582A5CACB} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} + {2262F921-FDFD-420C-9E2E-BC4A7985BF9D} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} {FB254BF6-9C7C-4A35-A8B1-FB8832382442} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln b/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln index 20bda98c1c8a5..9bf2f46685f8f 100644 --- a/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln +++ b/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{1EBC1861-0CC0-45A6-9685-AF863383D81F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{347B7406-0C18-4716-BD38-BA01F73E203F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{33058B90-33C6-4731-AF47-DC7678DC2739}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{01C6C981-C56F-453F-B099-C8B9DF61CDEB}" @@ -47,6 +51,14 @@ Global {1EBC1861-0CC0-45A6-9685-AF863383D81F}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EBC1861-0CC0-45A6-9685-AF863383D81F}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EBC1861-0CC0-45A6-9685-AF863383D81F}.Release|Any CPU.Build.0 = Release|Any CPU + {347B7406-0C18-4716-BD38-BA01F73E203F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {347B7406-0C18-4716-BD38-BA01F73E203F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {347B7406-0C18-4716-BD38-BA01F73E203F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {347B7406-0C18-4716-BD38-BA01F73E203F}.Release|Any CPU.Build.0 = Release|Any CPU + {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,6 +70,8 @@ Global {23FF09C1-F2BF-4834-96CE-59BE5AA7F46A} = {01C6C981-C56F-453F-B099-C8B9DF61CDEB} {062F1189-143C-456B-A439-D9C1BE2DD640} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} {1EBC1861-0CC0-45A6-9685-AF863383D81F} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} + {347B7406-0C18-4716-BD38-BA01F73E203F} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} + {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6749EC2E-042F-4132-9B0A-82ED7F56513C} diff --git a/src/libraries/System.Net.Ping/System.Net.Ping.sln b/src/libraries/System.Net.Ping/System.Net.Ping.sln index ca637e285cb2e..2c7c872b46966 100644 --- a/src/libraries/System.Net.Ping/System.Net.Ping.sln +++ b/src/libraries/System.Net.Ping/System.Net.Ping.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{FDD8759A-E9E4-4899-BBE0-298C403BF02B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FABDD2DA-5365-4FD2-8C67-4C643E618CE9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73}" @@ -47,6 +51,14 @@ Global {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}.Release|Any CPU.Build.0 = Release|Any CPU + {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Release|Any CPU.Build.0 = Release|Any CPU + {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,6 +70,8 @@ Global {948D0208-37D1-48B7-91AE-138D9A2C7751} = {AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73} {65B08958-069E-4F8B-A996-2A987ACCAA49} = {A687595D-ACCE-4380-95B8-628F598C7229} {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4} = {A687595D-ACCE-4380-95B8-628F598C7229} + {FDD8759A-E9E4-4899-BBE0-298C403BF02B} = {A687595D-ACCE-4380-95B8-628F598C7229} + {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B} = {A687595D-ACCE-4380-95B8-628F598C7229} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {23612E2C-7AC3-4D7B-812D-44BB88E94278} diff --git a/src/libraries/System.Net.Primitives/System.Net.Primitives.sln b/src/libraries/System.Net.Primitives/System.Net.Primitives.sln index 9e860bc8844f6..f69f00cc575cb 100644 --- a/src/libraries/System.Net.Primitives/System.Net.Primitives.sln +++ b/src/libraries/System.Net.Primitives/System.Net.Primitives.sln @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{909A147A-476E-4E34-A931-C2C65FD656A6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{212A5562-EFE7-4220-94EC-6B49C0A6DCEF}" @@ -59,6 +63,14 @@ Global {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}.Release|Any CPU.Build.0 = Release|Any CPU + {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Release|Any CPU.Build.0 = Release|Any CPU + {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -72,6 +84,8 @@ Global {F1989258-F5D7-4056-9831-518BD04F5863} = {212A5562-EFE7-4220-94EC-6B49C0A6DCEF} {08C53516-56AB-4D3B-B22F-7DC1B27EA7CE} = {97419593-C13A-4407-B489-1651C8D3E813} {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0} = {97419593-C13A-4407-B489-1651C8D3E813} + {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC} = {97419593-C13A-4407-B489-1651C8D3E813} + {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4} = {97419593-C13A-4407-B489-1651C8D3E813} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E0D36CFB-AD15-487D-A647-F12B577FC5DF} diff --git a/src/libraries/System.Net.Quic/System.Net.Quic.sln b/src/libraries/System.Net.Quic/System.Net.Quic.sln index d8dec0958a499..ad5a7b2e2e8ec 100644 --- a/src/libraries/System.Net.Quic/System.Net.Quic.sln +++ b/src/libraries/System.Net.Quic/System.Net.Quic.sln @@ -17,6 +17,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{946D2E52-84D0-462E-9412-2471CB64AD88}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{12C4206E-D19B-44BF-8002-6236D65AAE1B}" @@ -67,6 +71,14 @@ Global {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}.Release|Any CPU.Build.0 = Release|Any CPU + {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Release|Any CPU.Build.0 = Release|Any CPU + {946D2E52-84D0-462E-9412-2471CB64AD88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {946D2E52-84D0-462E-9412-2471CB64AD88}.Debug|Any CPU.Build.0 = Debug|Any CPU + {946D2E52-84D0-462E-9412-2471CB64AD88}.Release|Any CPU.ActiveCfg = Release|Any CPU + {946D2E52-84D0-462E-9412-2471CB64AD88}.Release|Any CPU.Build.0 = Release|Any CPU {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}.Debug|Any CPU.Build.0 = Debug|Any CPU {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -85,6 +97,8 @@ Global {BF401CDC-5AED-4F3E-8C3F-96D8DFA7E241} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} {4F87758B-D1AF-4DE3-A9A2-68B1558C02B7} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} + {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} + {946D2E52-84D0-462E-9412-2471CB64AD88} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Security/System.Net.Security.sln b/src/libraries/System.Net.Security/System.Net.Security.sln index de6376a734952..994b8f2762e81 100644 --- a/src/libraries/System.Net.Security/System.Net.Security.sln +++ b/src/libraries/System.Net.Security/System.Net.Security.sln @@ -21,6 +21,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{754403CE-ECFC-4EBA-8540-BEB67476FF9F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{72F7B38A-0352-4505-8212-E636A5508C7F}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{E0D760D1-21BC-468F-B599-858ECFF4AB1D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{80F5CE39-D33D-4CDD-ACD2-FA7597B6CBB1}" @@ -81,6 +85,14 @@ Global {754403CE-ECFC-4EBA-8540-BEB67476FF9F}.Debug|Any CPU.Build.0 = Debug|Any CPU {754403CE-ECFC-4EBA-8540-BEB67476FF9F}.Release|Any CPU.ActiveCfg = Release|Any CPU {754403CE-ECFC-4EBA-8540-BEB67476FF9F}.Release|Any CPU.Build.0 = Release|Any CPU + {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Release|Any CPU.Build.0 = Release|Any CPU + {72F7B38A-0352-4505-8212-E636A5508C7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72F7B38A-0352-4505-8212-E636A5508C7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72F7B38A-0352-4505-8212-E636A5508C7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72F7B38A-0352-4505-8212-E636A5508C7F}.Release|Any CPU.Build.0 = Release|Any CPU {E0D760D1-21BC-468F-B599-858ECFF4AB1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E0D760D1-21BC-468F-B599-858ECFF4AB1D}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0D760D1-21BC-468F-B599-858ECFF4AB1D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -105,6 +117,8 @@ Global {441D4079-55B4-4C47-A0E5-1330DC9A31CB} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {20F20695-DB18-47EB-A005-AA432ADCF865} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {754403CE-ECFC-4EBA-8540-BEB67476FF9F} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} + {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} + {72F7B38A-0352-4505-8212-E636A5508C7F} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {E0D760D1-21BC-468F-B599-858ECFF4AB1D} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {80F5CE39-D33D-4CDD-ACD2-FA7597B6CBB1} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} EndGlobalSection diff --git a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln index e8a3b47b53f6b..8137b954d2b7b 100644 --- a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln +++ b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{3234071E-7F94-4471-8D29-F376DACD8130}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{625DDEA0-FA43-4DC4-92B4-7692237FF18B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D93419A9-52EA-4276-80D7-11B59C84E9FD}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FAD51322-998C-42D4-8FAA-EA479A3A0E82}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}" @@ -53,6 +57,14 @@ Global {3234071E-7F94-4471-8D29-F376DACD8130}.Debug|Any CPU.Build.0 = Debug|Any CPU {3234071E-7F94-4471-8D29-F376DACD8130}.Release|Any CPU.ActiveCfg = Release|Any CPU {3234071E-7F94-4471-8D29-F376DACD8130}.Release|Any CPU.Build.0 = Release|Any CPU + {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Release|Any CPU.Build.0 = Release|Any CPU + {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -65,6 +77,8 @@ Global {C746C235-7771-46F2-80B3-A67E0C62E436} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FD313302-FE04-414E-8A62-3BC8894115C1} = {2C7108F0-035E-44A5-8451-FE9535F53D43} {3234071E-7F94-4471-8D29-F376DACD8130} = {2C7108F0-035E-44A5-8451-FE9535F53D43} + {625DDEA0-FA43-4DC4-92B4-7692237FF18B} = {2C7108F0-035E-44A5-8451-FE9535F53D43} + {D93419A9-52EA-4276-80D7-11B59C84E9FD} = {2C7108F0-035E-44A5-8451-FE9535F53D43} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BA222465-FBD4-4377-8A8A-783BF85E01F7} diff --git a/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln b/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln index 059b20e11e31e..a1bc19d2f87f0 100644 --- a/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln +++ b/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{59A23CAB-D098-495F-A467-74C7553FF5BB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{F8329953-B5A4-46B4-9B2E-511DBD251F1C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2BB8BE7E-4084-42EB-A676-A86A1543C999}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BEE2F256-0489-4809-AB20-27ADB2D0E10C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A0314AC5-E490-4A6A-B946-8B9A21A2FA05}" @@ -59,6 +63,14 @@ Global {59A23CAB-D098-495F-A467-74C7553FF5BB}.Debug|Any CPU.Build.0 = Debug|Any CPU {59A23CAB-D098-495F-A467-74C7553FF5BB}.Release|Any CPU.ActiveCfg = Release|Any CPU {59A23CAB-D098-495F-A467-74C7553FF5BB}.Release|Any CPU.Build.0 = Release|Any CPU + {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Release|Any CPU.Build.0 = Release|Any CPU + {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -72,6 +84,8 @@ Global {0CD4C24D-7746-46F0-8D47-A396882B5468} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} {8CD4D190-F656-4970-9AE9-4A9F8B30A2F8} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} {59A23CAB-D098-495F-A467-74C7553FF5BB} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} + {F8329953-B5A4-46B4-9B2E-511DBD251F1C} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} + {2BB8BE7E-4084-42EB-A676-A86A1543C999} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D91D7DC5-24CC-4716-A357-8170C4EB1C32} diff --git a/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln b/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln index 2c97ffb0057df..d23ab31c15d19 100644 --- a/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln +++ b/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{5484692D-7093-4D79-8C77-D6A0A4ABE8E8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FC10C682-DF71-4EEA-A3A5-E716C1C88AC0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2C4425BA-8478-4BCB-B616-E6FC28ADEAB9}" @@ -158,6 +162,42 @@ Global {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}.Checked|x64.Build.0 = Debug|Any CPU {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}.Checked|x86.ActiveCfg = Debug|Any CPU {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}.Checked|x86.Build.0 = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x64.Build.0 = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x86.ActiveCfg = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x86.Build.0 = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|Any CPU.Build.0 = Release|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x64.ActiveCfg = Release|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x64.Build.0 = Release|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x86.ActiveCfg = Release|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x86.Build.0 = Release|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|Any CPU.Build.0 = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x64.ActiveCfg = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x64.Build.0 = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x86.ActiveCfg = Debug|Any CPU + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x86.Build.0 = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x64.ActiveCfg = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x64.Build.0 = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x86.ActiveCfg = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x86.Build.0 = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|Any CPU.Build.0 = Release|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x64.ActiveCfg = Release|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x64.Build.0 = Release|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x86.ActiveCfg = Release|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x86.Build.0 = Release|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|Any CPU.Build.0 = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x64.ActiveCfg = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x64.Build.0 = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x86.ActiveCfg = Debug|Any CPU + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {634A3B2B-09F5-4810-B630-ADE4D36C47DF} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} {ED450846-85A0-4CED-B4D9-9EB769CF794B} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} + {5484692D-7093-4D79-8C77-D6A0A4ABE8E8} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} + {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} {9EDBE037-EFE0-4B72-B602-E4C3F0C05F2F} = {2C4425BA-8478-4BCB-B616-E6FC28ADEAB9} {B38797B1-BB45-4B30-9D4F-79D9F4B3735B} = {2C4425BA-8478-4BCB-B616-E6FC28ADEAB9} {5B2027FA-F43A-4E80-880F-B3A7A2720AA7} = {ED90FF1C-59D4-4AB0-860E-2872ECA1BFEC} diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln index d628570614a5a..c7031ea2ff16a 100644 --- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln +++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{F1642F23-C510-423E-8598-4B3A09DA28DB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7E578260-A505-47DF-A00D-13072A4A4023}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0866D4B1-55B3-44F7-8683-61FF19EC2CFD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F323228E-200C-4069-98A1-E2400F3061B3}" @@ -41,6 +45,14 @@ Global {F1642F23-C510-423E-8598-4B3A09DA28DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {F1642F23-C510-423E-8598-4B3A09DA28DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {F1642F23-C510-423E-8598-4B3A09DA28DB}.Release|Any CPU.Build.0 = Release|Any CPU + {7E578260-A505-47DF-A00D-13072A4A4023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E578260-A505-47DF-A00D-13072A4A4023}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E578260-A505-47DF-A00D-13072A4A4023}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E578260-A505-47DF-A00D-13072A4A4023}.Release|Any CPU.Build.0 = Release|Any CPU + {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -50,6 +62,8 @@ Global {4A88DCA2-2A9F-4497-AE84-C15B81F21782} = {0866D4B1-55B3-44F7-8683-61FF19EC2CFD} {1EF4B421-0137-4C27-A6D2-DFC2B09E52F0} = {F323228E-200C-4069-98A1-E2400F3061B3} {F1642F23-C510-423E-8598-4B3A09DA28DB} = {F323228E-200C-4069-98A1-E2400F3061B3} + {7E578260-A505-47DF-A00D-13072A4A4023} = {F323228E-200C-4069-98A1-E2400F3061B3} + {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220} = {F323228E-200C-4069-98A1-E2400F3061B3} {9B76030A-9DBD-401E-90B7-18111831B0D9} = {B7387D02-A1E8-4ED1-833D-65D6112F00A0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Private.Uri/System.Private.Uri.sln b/src/libraries/System.Private.Uri/System.Private.Uri.sln index 353c268082eac..d7801e8c0faf3 100644 --- a/src/libraries/System.Private.Uri/System.Private.Uri.sln +++ b/src/libraries/System.Private.Uri/System.Private.Uri.sln @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{01EDF06D-BBBB-42D7-9414-A332292235D3}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{4F09BFD3-86CF-4B70-98C7-757C1EB38548}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A30957A2-C729-49F1-8C75-C42D5BCB8309}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05}" @@ -178,6 +182,42 @@ Global {01EDF06D-BBBB-42D7-9414-A332292235D3}.Checked|x64.Build.0 = Debug|Any CPU {01EDF06D-BBBB-42D7-9414-A332292235D3}.Checked|x86.ActiveCfg = Debug|Any CPU {01EDF06D-BBBB-42D7-9414-A332292235D3}.Checked|x86.Build.0 = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x64.ActiveCfg = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x64.Build.0 = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x86.ActiveCfg = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x86.Build.0 = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|Any CPU.Build.0 = Release|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x64.ActiveCfg = Release|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x64.Build.0 = Release|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x86.ActiveCfg = Release|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x86.Build.0 = Release|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|Any CPU.Build.0 = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x64.ActiveCfg = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x64.Build.0 = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x86.ActiveCfg = Debug|Any CPU + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x86.Build.0 = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x64.Build.0 = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x86.Build.0 = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|Any CPU.Build.0 = Release|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x64.ActiveCfg = Release|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x64.Build.0 = Release|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x86.ActiveCfg = Release|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x86.Build.0 = Release|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|Any CPU.Build.0 = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x64.ActiveCfg = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x64.Build.0 = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x86.ActiveCfg = Debug|Any CPU + {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -186,6 +226,8 @@ Global {C150B694-015F-48BD-8CB0-EFF1F7A84DCE} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} {98AC821B-892E-4F58-AF3D-503747FD6A8F} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} {01EDF06D-BBBB-42D7-9414-A332292235D3} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} + {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} + {4F09BFD3-86CF-4B70-98C7-757C1EB38548} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} {ADD88187-83E2-4EAF-BFB4-BC6249E76457} = {DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05} {37859855-7E5C-4772-B5D2-7029211EAB92} = {DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05} {BDD0866A-D856-40EE-A9D5-1DAC11095E42} = {DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05} diff --git a/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln b/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln index 559727cabe07c..e555e361be756 100644 --- a/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln +++ b/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln @@ -41,6 +41,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{F442C967-0D66-4EFF-8875-1D165AA80621}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{29BE8713-DD3F-4CFB-92C0-3416E5501398}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4CB964C2-C69D-4A48-96A7-ACB28FBCB223}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1C4146F1-CF77-449B-865C-5E67ECF0362B}" @@ -137,6 +141,14 @@ Global {F442C967-0D66-4EFF-8875-1D165AA80621}.Debug|Any CPU.Build.0 = Debug|Any CPU {F442C967-0D66-4EFF-8875-1D165AA80621}.Release|Any CPU.ActiveCfg = Release|Any CPU {F442C967-0D66-4EFF-8875-1D165AA80621}.Release|Any CPU.Build.0 = Release|Any CPU + {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Release|Any CPU.Build.0 = Release|Any CPU + {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -162,6 +174,8 @@ Global {61FD926A-2ED8-4CA5-8D75-854C8C9D9CCD} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} {A4F479E3-A0AD-4646-BD4B-F3CD2C29046B} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} {F442C967-0D66-4EFF-8875-1D165AA80621} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} + {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} + {29BE8713-DD3F-4CFB-92C0-3416E5501398} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} {28B0CB77-2187-4CCD-8190-283FCA9800B1} = {D82CEFE7-0F7E-4A18-80FE-6562E12E1283} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Private.Xml/System.Private.Xml.sln b/src/libraries/System.Private.Xml/System.Private.Xml.sln index 84ce418242e77..9f99f4a1da006 100644 --- a/src/libraries/System.Private.Xml/System.Private.Xml.sln +++ b/src/libraries/System.Private.Xml/System.Private.Xml.sln @@ -71,6 +71,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7D12E1FB-2034-47B0-9244-E3C51015CD04}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{0218E41A-B48A-4B36-8DD5-37AE2DA35364}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E96EBB95-6AC7-4ECD-AD77-30F089F2C1F9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{41E18B29-2DB1-495A-8460-E7A257F8EA07}" @@ -227,6 +231,14 @@ Global {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}.Release|Any CPU.Build.0 = Release|Any CPU + {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Release|Any CPU.Build.0 = Release|Any CPU + {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -267,6 +279,8 @@ Global {BBB6623D-BDF2-41B6-9165-A22A6C4D4159} = {E96EBB95-6AC7-4ECD-AD77-30F089F2C1F9} {B49AD269-3938-4F33-AEF8-029D3A94138F} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} + {7D12E1FB-2034-47B0-9244-E3C51015CD04} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} + {0218E41A-B48A-4B36-8DD5-37AE2DA35364} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} {D85F5D9C-A068-4F04-B081-0A3E20CB5D49} = {148C103A-1CDD-4CBF-AC5F-5BADBC14B6DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln b/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln index 55419e26ff29c..a9c7a96c18ea5 100644 --- a/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln +++ b/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2F96336D-6AB0-4463-9A9F-5ED91E737DEA}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{72C88956-EE24-4089-A1B0-939879F83038}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B02EB99E-A733-443E-B8F7-5FF527C89BCA}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C723F596-B189-428C-A090-F4965F87A73D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{61C529DF-66C4-42E9-AE70-3427838FAFE3}" @@ -158,6 +162,42 @@ Global {2F96336D-6AB0-4463-9A9F-5ED91E737DEA}.Checked|x64.Build.0 = Debug|Any CPU {2F96336D-6AB0-4463-9A9F-5ED91E737DEA}.Checked|x86.ActiveCfg = Debug|Any CPU {2F96336D-6AB0-4463-9A9F-5ED91E737DEA}.Checked|x86.Build.0 = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x64.ActiveCfg = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x64.Build.0 = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x86.ActiveCfg = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x86.Build.0 = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Release|Any CPU.Build.0 = Release|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Release|x64.ActiveCfg = Release|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Release|x64.Build.0 = Release|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Release|x86.ActiveCfg = Release|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Release|x86.Build.0 = Release|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Checked|Any CPU.Build.0 = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x64.ActiveCfg = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x64.Build.0 = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x86.ActiveCfg = Debug|Any CPU + {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x86.Build.0 = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x64.ActiveCfg = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x64.Build.0 = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x86.ActiveCfg = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x86.Build.0 = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|Any CPU.Build.0 = Release|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x64.ActiveCfg = Release|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x64.Build.0 = Release|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x86.ActiveCfg = Release|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x86.Build.0 = Release|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|Any CPU.Build.0 = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x64.ActiveCfg = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x64.Build.0 = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x86.ActiveCfg = Debug|Any CPU + {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {B1053D24-237E-4E55-9413-20B34ED79F23} = {C723F596-B189-428C-A090-F4965F87A73D} {A18E814C-13D6-4859-B6FA-3CAB8673B31F} = {C723F596-B189-428C-A090-F4965F87A73D} {2F96336D-6AB0-4463-9A9F-5ED91E737DEA} = {C723F596-B189-428C-A090-F4965F87A73D} + {72C88956-EE24-4089-A1B0-939879F83038} = {C723F596-B189-428C-A090-F4965F87A73D} + {B02EB99E-A733-443E-B8F7-5FF527C89BCA} = {C723F596-B189-428C-A090-F4965F87A73D} {05696F45-ACF1-4C02-B8D9-E8C1F5E28717} = {61C529DF-66C4-42E9-AE70-3427838FAFE3} {EA6F01DF-1F63-49FF-A6E8-CA9104296196} = {61C529DF-66C4-42E9-AE70-3427838FAFE3} {64BBA40A-8DB5-4829-815A-3D612A12222D} = {A20A0878-5647-4145-B224-C390446B7676} diff --git a/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln b/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln index 3928d565e1fbd..0b1a155a611d8 100644 --- a/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln +++ b/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{0285779D-C970-4E27-820E-C204E556DD19}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{E41E593C-7180-4134-8097-79B2E3C41E7B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9B8380D8-16E9-4A6C-A5B8-4523778722C9}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C3D946CF-3A37-4EA5-AE14-AC84AF9746F1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FF41EFDD-DD1F-428F-B25E-DD9B85D5A992}" @@ -158,6 +162,42 @@ Global {0285779D-C970-4E27-820E-C204E556DD19}.Checked|x64.Build.0 = Debug|Any CPU {0285779D-C970-4E27-820E-C204E556DD19}.Checked|x86.ActiveCfg = Debug|Any CPU {0285779D-C970-4E27-820E-C204E556DD19}.Checked|x86.Build.0 = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x64.ActiveCfg = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x64.Build.0 = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x86.ActiveCfg = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x86.Build.0 = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|Any CPU.Build.0 = Release|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x64.ActiveCfg = Release|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x64.Build.0 = Release|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x86.ActiveCfg = Release|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x86.Build.0 = Release|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|Any CPU.Build.0 = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x64.ActiveCfg = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x64.Build.0 = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x86.ActiveCfg = Debug|Any CPU + {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x86.Build.0 = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x64.ActiveCfg = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x64.Build.0 = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x86.ActiveCfg = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x86.Build.0 = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|Any CPU.Build.0 = Release|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x64.ActiveCfg = Release|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x64.Build.0 = Release|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x86.ActiveCfg = Release|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x86.Build.0 = Release|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|Any CPU.Build.0 = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x64.ActiveCfg = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x64.Build.0 = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x86.ActiveCfg = Debug|Any CPU + {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {209EDA22-1D20-4180-BE4C-53DEE1758B5D} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} {BC6947B4-C61B-4066-B75F-937992548E54} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} {0285779D-C970-4E27-820E-C204E556DD19} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} + {E41E593C-7180-4134-8097-79B2E3C41E7B} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} + {9B8380D8-16E9-4A6C-A5B8-4523778722C9} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} {ECDDE645-347C-46D8-B6B6-BCFF6B9AFD4A} = {FF41EFDD-DD1F-428F-B25E-DD9B85D5A992} {13447BAB-2762-4CCC-95DF-531FC82FE39A} = {FF41EFDD-DD1F-428F-B25E-DD9B85D5A992} {EE535D8F-D21B-4C18-A915-60E94CE19CA2} = {2AB40A0A-24D5-40B9-AA94-5BF17878879A} diff --git a/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln b/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln index 36776ca20d393..7c17f7be46204 100644 --- a/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln +++ b/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{C8601778-612D-4274-9F36-17F938E65603}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{A0FF616A-BB90-4508-BDEC-87F32F159607}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{27425166-37BE-4CE2-9588-9EC8D8982AF5}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{74F4AB97-3DBC-48FB-A2EA-2B4141749800}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2FC35C2F-76DB-4D84-B421-9700BEA4D161}" @@ -158,6 +162,42 @@ Global {C8601778-612D-4274-9F36-17F938E65603}.Checked|x64.Build.0 = Debug|Any CPU {C8601778-612D-4274-9F36-17F938E65603}.Checked|x86.ActiveCfg = Debug|Any CPU {C8601778-612D-4274-9F36-17F938E65603}.Checked|x86.Build.0 = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x64.ActiveCfg = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x64.Build.0 = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x86.ActiveCfg = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x86.Build.0 = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|Any CPU.Build.0 = Release|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x64.ActiveCfg = Release|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x64.Build.0 = Release|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x86.ActiveCfg = Release|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x86.Build.0 = Release|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|Any CPU.Build.0 = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x64.ActiveCfg = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x64.Build.0 = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x86.ActiveCfg = Debug|Any CPU + {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x86.Build.0 = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x64.ActiveCfg = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x64.Build.0 = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x86.ActiveCfg = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x86.Build.0 = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|Any CPU.Build.0 = Release|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x64.ActiveCfg = Release|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x64.Build.0 = Release|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x86.ActiveCfg = Release|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x86.Build.0 = Release|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|Any CPU.Build.0 = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x64.ActiveCfg = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x64.Build.0 = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x86.ActiveCfg = Debug|Any CPU + {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {772C93D4-FC45-46AA-B09F-26F01B672EDC} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} {B479A4BF-A3A5-4255-A3EF-135015BD877F} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} {C8601778-612D-4274-9F36-17F938E65603} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} + {A0FF616A-BB90-4508-BDEC-87F32F159607} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} + {27425166-37BE-4CE2-9588-9EC8D8982AF5} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} {E5543842-139D-43BD-B604-E65EBB91649E} = {2FC35C2F-76DB-4D84-B421-9700BEA4D161} {82899000-791E-42FF-A594-6DE65DE07C9E} = {2FC35C2F-76DB-4D84-B421-9700BEA4D161} {6A176C5B-206D-4550-AC36-0530218E29F5} = {C36D185D-9B3D-42E5-985F-E21B3BAF3B6D} diff --git a/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln b/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln index b83b1c060b7c0..e4cbbb1e90eb6 100644 --- a/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln +++ b/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln @@ -5,6 +5,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Reflection.Primitive EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Reflection.Primitives", "src\System.Reflection.Primitives.csproj", "{5D40069E-7CC2-4B40-A41D-6B003CCB4075}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{1F61BE04-C26A-447B-BD25-B90D669C5F53}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{24554C8E-9A88-4659-92CA-A18546239D6A}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{4599348B-0480-47D4-9763-F3C6716D3CCC}" @@ -76,6 +80,42 @@ Global {5D40069E-7CC2-4B40-A41D-6B003CCB4075}.Checked|x64.Build.0 = Debug|Any CPU {5D40069E-7CC2-4B40-A41D-6B003CCB4075}.Checked|x86.ActiveCfg = Debug|Any CPU {5D40069E-7CC2-4B40-A41D-6B003CCB4075}.Checked|x86.Build.0 = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x64.ActiveCfg = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x64.Build.0 = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x86.ActiveCfg = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x86.Build.0 = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|Any CPU.Build.0 = Release|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x64.ActiveCfg = Release|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x64.Build.0 = Release|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x86.ActiveCfg = Release|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x86.Build.0 = Release|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|Any CPU.Build.0 = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x64.ActiveCfg = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x64.Build.0 = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x86.ActiveCfg = Debug|Any CPU + {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x86.Build.0 = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x64.ActiveCfg = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x64.Build.0 = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x86.ActiveCfg = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x86.Build.0 = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|Any CPU.Build.0 = Release|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x64.ActiveCfg = Release|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x64.Build.0 = Release|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x86.ActiveCfg = Release|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x86.Build.0 = Release|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|Any CPU.Build.0 = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x64.ActiveCfg = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x64.Build.0 = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x86.ActiveCfg = Debug|Any CPU + {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -83,6 +123,8 @@ Global GlobalSection(NestedProjects) = preSolution {661E0A3D-E151-45B2-AA38-B30F8227A741} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} {5D40069E-7CC2-4B40-A41D-6B003CCB4075} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} + {1F61BE04-C26A-447B-BD25-B90D669C5F53} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} + {24554C8E-9A88-4659-92CA-A18546239D6A} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} {9D308994-9721-4883-B32D-531FA8D9025B} = {4599348B-0480-47D4-9763-F3C6716D3CCC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln b/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln index 03e23684bbe6a..9cd247b6bfb4d 100644 --- a/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln +++ b/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{C12B737F-2265-4F48-9BEA-B9023063AC91}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{165628C3-CB85-44FF-BDB8-6D0893EFCD60}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{723EA4AC-E9C8-4837-B784-D47CE16BD165}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3A79F8E8-9E66-44C6-94E7-DE8C24F80E59}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9BB99B5C-97D7-4247-B682-27CBBFCF1BB4}" @@ -158,6 +162,42 @@ Global {C12B737F-2265-4F48-9BEA-B9023063AC91}.Checked|x64.Build.0 = Debug|Any CPU {C12B737F-2265-4F48-9BEA-B9023063AC91}.Checked|x86.ActiveCfg = Debug|Any CPU {C12B737F-2265-4F48-9BEA-B9023063AC91}.Checked|x86.Build.0 = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|Any CPU.Build.0 = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x64.ActiveCfg = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x64.Build.0 = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x86.ActiveCfg = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x86.Build.0 = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|Any CPU.ActiveCfg = Release|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|Any CPU.Build.0 = Release|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x64.ActiveCfg = Release|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x64.Build.0 = Release|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x86.ActiveCfg = Release|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x86.Build.0 = Release|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|Any CPU.Build.0 = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x64.ActiveCfg = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x64.Build.0 = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x86.ActiveCfg = Debug|Any CPU + {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x86.Build.0 = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|Any CPU.Build.0 = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x64.ActiveCfg = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x64.Build.0 = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x86.ActiveCfg = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x86.Build.0 = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|Any CPU.ActiveCfg = Release|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|Any CPU.Build.0 = Release|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x64.ActiveCfg = Release|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x64.Build.0 = Release|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x86.ActiveCfg = Release|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x86.Build.0 = Release|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|Any CPU.Build.0 = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x64.ActiveCfg = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x64.Build.0 = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x86.ActiveCfg = Debug|Any CPU + {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -166,6 +206,8 @@ Global {F3F9D019-086A-4093-BD49-11B6B204D94A} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} {B958EACD-B145-4B48-A11B-C5E5B565E311} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} {C12B737F-2265-4F48-9BEA-B9023063AC91} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} + {165628C3-CB85-44FF-BDB8-6D0893EFCD60} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} + {723EA4AC-E9C8-4837-B784-D47CE16BD165} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} {41438432-4DC0-4724-8C8F-0D100083490F} = {9BB99B5C-97D7-4247-B682-27CBBFCF1BB4} {FEFD49C5-E2A2-411E-ABF4-DE7B58861750} = {9BB99B5C-97D7-4247-B682-27CBBFCF1BB4} {03C0F6B8-A04B-4822-8089-3918F02AD281} = {B05E90C8-0282-4D7D-955E-3BE8A400D3A6} diff --git a/src/libraries/System.Reflection/System.Reflection.sln b/src/libraries/System.Reflection/System.Reflection.sln index eddd292df3818..6c2ab32a7d54f 100644 --- a/src/libraries/System.Reflection/System.Reflection.sln +++ b/src/libraries/System.Reflection/System.Reflection.sln @@ -45,6 +45,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{B197B18A-A758-4501-A215-D5C909F39B42}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{6219E11D-A2C0-4591-B147-BC79CF48A524}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{89985471-FD93-4901-9E88-D6DFAEA1DE6D}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1BD23B5E-9944-4133-A162-94D4697616DD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{64590D3A-D464-4764-ABE3-EF62722D8FA7}" @@ -478,6 +482,42 @@ Global {B197B18A-A758-4501-A215-D5C909F39B42}.Checked|x64.Build.0 = Debug|Any CPU {B197B18A-A758-4501-A215-D5C909F39B42}.Checked|x86.ActiveCfg = Debug|Any CPU {B197B18A-A758-4501-A215-D5C909F39B42}.Checked|x86.Build.0 = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x64.ActiveCfg = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x64.Build.0 = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x86.ActiveCfg = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x86.Build.0 = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|Any CPU.Build.0 = Release|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x64.ActiveCfg = Release|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x64.Build.0 = Release|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x86.ActiveCfg = Release|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x86.Build.0 = Release|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|Any CPU.Build.0 = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x64.ActiveCfg = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x64.Build.0 = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x86.ActiveCfg = Debug|Any CPU + {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x86.Build.0 = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x64.ActiveCfg = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x64.Build.0 = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x86.ActiveCfg = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x86.Build.0 = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|Any CPU.Build.0 = Release|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x64.ActiveCfg = Release|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x64.Build.0 = Release|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x86.ActiveCfg = Release|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x86.Build.0 = Release|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|Any CPU.Build.0 = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x64.ActiveCfg = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x64.Build.0 = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x86.ActiveCfg = Debug|Any CPU + {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -486,6 +526,8 @@ Global {27A1A006-6882-4C70-AB81-775D3D2C95A2} = {1BD23B5E-9944-4133-A162-94D4697616DD} {2A4650E3-E199-41E4-AD2B-32818E57D1C7} = {1BD23B5E-9944-4133-A162-94D4697616DD} {B197B18A-A758-4501-A215-D5C909F39B42} = {1BD23B5E-9944-4133-A162-94D4697616DD} + {6219E11D-A2C0-4591-B147-BC79CF48A524} = {1BD23B5E-9944-4133-A162-94D4697616DD} + {89985471-FD93-4901-9E88-D6DFAEA1DE6D} = {1BD23B5E-9944-4133-A162-94D4697616DD} {C5A7E7E7-E43B-4C87-9A92-13C3C817E714} = {64590D3A-D464-4764-ABE3-EF62722D8FA7} {F5998D9E-69A3-4F43-9AA5-B1BB33B54C64} = {64590D3A-D464-4764-ABE3-EF62722D8FA7} {7873C6BF-74FA-4DCF-ADCD-15C75B20132D} = {64590D3A-D464-4764-ABE3-EF62722D8FA7} diff --git a/src/libraries/System.Resources.Extensions/NuGet.config b/src/libraries/System.Resources.Extensions/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Resources.Extensions/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Resources.ResourceManager/NuGet.config b/src/libraries/System.Resources.ResourceManager/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Resources.ResourceManager/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln b/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln index da05457c9c205..f995d4ea28978 100644 --- a/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln +++ b/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln @@ -25,6 +25,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{C411D7D4-7F9C-437E-A36D-022D30389B65}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3397F202-CCE5-420F-A8B3-E64DBA2C9300}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{E366242C-F4CD-4790-8472-84246E4533B6}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0F0E4254-2575-4B8B-982A-A3D98D6E11DB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8FA5B4E7-5580-4E8A-909E-F1D0B4E60195}" @@ -278,6 +282,42 @@ Global {C411D7D4-7F9C-437E-A36D-022D30389B65}.Checked|x64.Build.0 = Debug|Any CPU {C411D7D4-7F9C-437E-A36D-022D30389B65}.Checked|x86.ActiveCfg = Debug|Any CPU {C411D7D4-7F9C-437E-A36D-022D30389B65}.Checked|x86.Build.0 = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x64.ActiveCfg = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x64.Build.0 = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x86.ActiveCfg = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x86.Build.0 = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|Any CPU.Build.0 = Release|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x64.ActiveCfg = Release|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x64.Build.0 = Release|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x86.ActiveCfg = Release|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x86.Build.0 = Release|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|Any CPU.Build.0 = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x64.ActiveCfg = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x64.Build.0 = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x86.ActiveCfg = Debug|Any CPU + {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x86.Build.0 = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x64.ActiveCfg = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x64.Build.0 = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x86.ActiveCfg = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x86.Build.0 = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Release|Any CPU.Build.0 = Release|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x64.ActiveCfg = Release|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x64.Build.0 = Release|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x86.ActiveCfg = Release|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x86.Build.0 = Release|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|Any CPU.Build.0 = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x64.ActiveCfg = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x64.Build.0 = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x86.ActiveCfg = Debug|Any CPU + {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -289,6 +329,8 @@ Global {DE2EC027-CD6F-4C5B-8B49-66B5FE795472} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} {5C0A720D-EF35-4403-B246-89AFBFC6C7AF} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} {C411D7D4-7F9C-437E-A36D-022D30389B65} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} + {3397F202-CCE5-420F-A8B3-E64DBA2C9300} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} + {E366242C-F4CD-4790-8472-84246E4533B6} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} {B93B5C05-FB28-4173-8786-57B42CFE38F3} = {8FA5B4E7-5580-4E8A-909E-F1D0B4E60195} {DE363A06-8C3D-4DDA-AD67-3B6C253E0424} = {8FA5B4E7-5580-4E8A-909E-F1D0B4E60195} {AFC17385-4DE6-40FF-AEF9-F117B0F1C00B} = {5F76ABD3-6169-46FF-A7B7-CB6CF5FBBFCD} diff --git a/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln b/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln index c1678e9303b4a..09a1f87a231c2 100644 --- a/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln +++ b/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln @@ -25,6 +25,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAppOutsideOfTPA", "test EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VoidMainWithExitCodeApp", "tests\VoidMainWithExitCodeApp\VoidMainWithExitCodeApp.csproj", "{F55614A7-859C-4171-844B-46F37EDDD351}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{E2C0A4BC-A972-417F-90AC-F269482BDC70}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2C0F9815-558B-4CDF-B23C-F82B95BD7B61}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2642DD1A-F4C5-4B39-8170-7BC51A75F5D1}" @@ -280,6 +284,42 @@ Global {F55614A7-859C-4171-844B-46F37EDDD351}.Checked|x64.Build.0 = Debug|Any CPU {F55614A7-859C-4171-844B-46F37EDDD351}.Checked|x86.ActiveCfg = Debug|Any CPU {F55614A7-859C-4171-844B-46F37EDDD351}.Checked|x86.Build.0 = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x64.ActiveCfg = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x64.Build.0 = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x86.ActiveCfg = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x86.Build.0 = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|Any CPU.Build.0 = Release|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x64.ActiveCfg = Release|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x64.Build.0 = Release|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x86.ActiveCfg = Release|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x86.Build.0 = Release|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|Any CPU.Build.0 = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x64.ActiveCfg = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x64.Build.0 = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x86.ActiveCfg = Debug|Any CPU + {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x86.Build.0 = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x64.ActiveCfg = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x64.Build.0 = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x86.ActiveCfg = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x86.Build.0 = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|Any CPU.Build.0 = Release|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x64.ActiveCfg = Release|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x64.Build.0 = Release|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x86.ActiveCfg = Release|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x86.Build.0 = Release|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|Any CPU.Build.0 = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x64.ActiveCfg = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x64.Build.0 = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x86.ActiveCfg = Debug|Any CPU + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x86.Build.0 = Debug|Any CPU {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -307,6 +347,8 @@ Global {1E0C4DD8-3A04-4B4C-9699-DB5844F2CFB2} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {04BA3E3C-6979-4792-B19E-C797AD607F42} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {FF0EFAEE-3E1A-4C7B-8B4A-AAC8E0988A0A} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} + {E2C0A4BC-A972-417F-90AC-F269482BDC70} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} + {2C0F9815-558B-4CDF-B23C-F82B95BD7B61} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {D7A1E176-1515-41FE-86D0-A46C82B87B05} = {F4E65A6B-CBA4-40E2-A0B5-6C50C8AAB25C} {01EC2059-605F-472C-A255-ED76197F62CD} = {F4E65A6B-CBA4-40E2-A0B5-6C50C8AAB25C} diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln index 6f68cba53d55a..7e2519c5b7caf 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.RuntimeInformation.Tests", "tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csproj", "{4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{703BD7C4-DD4E-4486-BB69-530702F7093B}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ADA9FAB8-9FD5-4035-86D4-4BE1BB564791}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{D380D111-FFFE-4520-A0AE-3EA3E59F7820}" @@ -47,6 +51,14 @@ Global {4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}.Release|Any CPU.Build.0 = Release|Any CPU + {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Release|Any CPU.Build.0 = Release|Any CPU + {703BD7C4-DD4E-4486-BB69-530702F7093B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {703BD7C4-DD4E-4486-BB69-530702F7093B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {703BD7C4-DD4E-4486-BB69-530702F7093B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {703BD7C4-DD4E-4486-BB69-530702F7093B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,6 +70,8 @@ Global {B2937043-2666-41F2-A72B-FA9CDBBC012A} = {D380D111-FFFE-4520-A0AE-3EA3E59F7820} {0A1860C3-7207-49CE-B921-A9A76EA4A9DB} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} {375DB818-0E7E-4361-9C56-07658B666B8B} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} + {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} + {703BD7C4-DD4E-4486-BB69-530702F7093B} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8C10FECD-1847-429D-9777-81F246B05D48} diff --git a/src/libraries/System.Runtime.InteropServices/System.Runtime.InteropServices.sln b/src/libraries/System.Runtime.InteropServices/System.Runtime.InteropServices.sln index fa50a214c401d..a53cf6e074c08 100644 --- a/src/libraries/System.Runtime.InteropServices/System.Runtime.InteropServices.sln +++ b/src/libraries/System.Runtime.InteropServices/System.Runtime.InteropServices.sln @@ -7,13 +7,27 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{04BA3E3C-6979-4792-B19E-C797AD607F42}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "gen\DllImportGenerator\DllImportGenerator.csproj", "{07F19F91-D438-428D-99F0-61DAD87E78BA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{768B77B0-EA45-469D-B39E-545EB72F5A43}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices", "ref\System.Runtime.InteropServices.csproj", "{8671F164-F78C-44FA-93B7-A310F67890FE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices", "src\System.Runtime.InteropServices.csproj", "{4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.ComDisabled.Tests", "tests\ComDisabled\System.Runtime.InteropServices.ComDisabled.Tests.csproj", "{6D2197E6-D3DF-43AE-9BEE-3573018639F9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.Ancillary", "tests\Ancillary.Interop\Ancillary.Interop.csproj", "{79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DllImportGenerator.Tests", "tests\DllImportGenerator.Tests\DllImportGenerator.Tests.csproj", "{57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DllImportGenerator.UnitTests", "tests\DllImportGenerator.UnitTests\DllImportGenerator.UnitTests.csproj", "{4B516949-4AD4-44D6-AF86-C2E6058608D5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.ComDisabled.Tests", "tests\System.Runtime.InteropServices.ComDisabled.UnitTests\System.Runtime.InteropServices.ComDisabled.Tests.csproj", "{25D66424-2EAF-464D-8460-10C04EDEF3C3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.Tests", "tests\System.Runtime.InteropServices.UnitTests\System.Runtime.InteropServices.Tests.csproj", "{049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.Tests.NativeExports", "tests\TestAssets\NativeExports\NativeExports.csproj", "{866D295E-424A-4747-9417-CD7746936138}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.Tests", "tests\System.Runtime.InteropServices.Tests.csproj", "{E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedTypes", "tests\TestAssets\SharedTypes\SharedTypes.csproj", "{D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B1678CCD-95C8-4419-B9F9-14A03061BE4B}" EndProject @@ -106,6 +120,42 @@ Global {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x64.Build.0 = Debug|Any CPU {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.ActiveCfg = Debug|Any CPU {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.Build.0 = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Debug|x64.ActiveCfg = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Debug|x64.Build.0 = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Debug|x86.ActiveCfg = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Debug|x86.Build.0 = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Release|Any CPU.Build.0 = Release|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Release|x64.ActiveCfg = Release|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Release|x64.Build.0 = Release|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Release|x86.ActiveCfg = Release|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Release|x86.Build.0 = Release|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Checked|Any CPU.Build.0 = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Checked|x64.ActiveCfg = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Checked|x64.Build.0 = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Checked|x86.ActiveCfg = Debug|Any CPU + {07F19F91-D438-428D-99F0-61DAD87E78BA}.Checked|x86.Build.0 = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Debug|x64.ActiveCfg = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Debug|x64.Build.0 = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Debug|x86.ActiveCfg = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Debug|x86.Build.0 = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Release|Any CPU.Build.0 = Release|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Release|x64.ActiveCfg = Release|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Release|x64.Build.0 = Release|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Release|x86.ActiveCfg = Release|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Release|x86.Build.0 = Release|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Checked|Any CPU.Build.0 = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Checked|x64.ActiveCfg = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Checked|x64.Build.0 = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Checked|x86.ActiveCfg = Debug|Any CPU + {768B77B0-EA45-469D-B39E-545EB72F5A43}.Checked|x86.Build.0 = Debug|Any CPU {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -142,42 +192,132 @@ Global {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|x64.Build.0 = Debug|Any CPU {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|x86.ActiveCfg = Debug|Any CPU {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|x86.Build.0 = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x64.ActiveCfg = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x64.Build.0 = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x86.ActiveCfg = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x86.Build.0 = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|Any CPU.Build.0 = Release|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x64.ActiveCfg = Release|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x64.Build.0 = Release|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x86.ActiveCfg = Release|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x86.Build.0 = Release|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|Any CPU.Build.0 = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x64.ActiveCfg = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x64.Build.0 = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x86.ActiveCfg = Debug|Any CPU - {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x86.Build.0 = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x64.ActiveCfg = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x64.Build.0 = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x86.ActiveCfg = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x86.Build.0 = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|Any CPU.Build.0 = Release|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x64.ActiveCfg = Release|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x64.Build.0 = Release|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x86.ActiveCfg = Release|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x86.Build.0 = Release|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|Any CPU.Build.0 = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x64.ActiveCfg = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x64.Build.0 = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x86.ActiveCfg = Debug|Any CPU - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x86.Build.0 = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Debug|x64.ActiveCfg = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Debug|x64.Build.0 = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Debug|x86.ActiveCfg = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Debug|x86.Build.0 = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Release|Any CPU.Build.0 = Release|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Release|x64.ActiveCfg = Release|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Release|x64.Build.0 = Release|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Release|x86.ActiveCfg = Release|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Release|x86.Build.0 = Release|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Checked|Any CPU.Build.0 = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Checked|x64.ActiveCfg = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Checked|x64.Build.0 = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Checked|x86.ActiveCfg = Debug|Any CPU + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E}.Checked|x86.Build.0 = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Debug|x64.ActiveCfg = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Debug|x64.Build.0 = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Debug|x86.ActiveCfg = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Debug|x86.Build.0 = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Release|Any CPU.Build.0 = Release|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Release|x64.ActiveCfg = Release|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Release|x64.Build.0 = Release|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Release|x86.ActiveCfg = Release|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Release|x86.Build.0 = Release|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Checked|Any CPU.Build.0 = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Checked|x64.ActiveCfg = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Checked|x64.Build.0 = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Checked|x86.ActiveCfg = Debug|Any CPU + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3}.Checked|x86.Build.0 = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Debug|x64.ActiveCfg = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Debug|x64.Build.0 = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Debug|x86.ActiveCfg = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Debug|x86.Build.0 = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Release|Any CPU.Build.0 = Release|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Release|x64.ActiveCfg = Release|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Release|x64.Build.0 = Release|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Release|x86.ActiveCfg = Release|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Release|x86.Build.0 = Release|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Checked|Any CPU.Build.0 = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Checked|x64.ActiveCfg = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Checked|x64.Build.0 = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Checked|x86.ActiveCfg = Debug|Any CPU + {4B516949-4AD4-44D6-AF86-C2E6058608D5}.Checked|x86.Build.0 = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Debug|x64.ActiveCfg = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Debug|x64.Build.0 = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Debug|x86.ActiveCfg = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Debug|x86.Build.0 = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Release|Any CPU.Build.0 = Release|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Release|x64.ActiveCfg = Release|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Release|x64.Build.0 = Release|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Release|x86.ActiveCfg = Release|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Release|x86.Build.0 = Release|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Checked|Any CPU.Build.0 = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Checked|x64.ActiveCfg = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Checked|x64.Build.0 = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Checked|x86.ActiveCfg = Debug|Any CPU + {25D66424-2EAF-464D-8460-10C04EDEF3C3}.Checked|x86.Build.0 = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Debug|x64.ActiveCfg = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Debug|x64.Build.0 = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Debug|x86.ActiveCfg = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Debug|x86.Build.0 = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Release|Any CPU.Build.0 = Release|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Release|x64.ActiveCfg = Release|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Release|x64.Build.0 = Release|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Release|x86.ActiveCfg = Release|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Release|x86.Build.0 = Release|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Checked|Any CPU.Build.0 = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Checked|x64.ActiveCfg = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Checked|x64.Build.0 = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Checked|x86.ActiveCfg = Debug|Any CPU + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF}.Checked|x86.Build.0 = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Debug|Any CPU.Build.0 = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Debug|x64.ActiveCfg = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Debug|x64.Build.0 = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Debug|x86.ActiveCfg = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Debug|x86.Build.0 = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Release|Any CPU.ActiveCfg = Release|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Release|Any CPU.Build.0 = Release|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Release|x64.ActiveCfg = Release|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Release|x64.Build.0 = Release|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Release|x86.ActiveCfg = Release|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Release|x86.Build.0 = Release|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Checked|Any CPU.Build.0 = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Checked|x64.ActiveCfg = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Checked|x64.Build.0 = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Checked|x86.ActiveCfg = Debug|Any CPU + {866D295E-424A-4747-9417-CD7746936138}.Checked|x86.Build.0 = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Debug|x64.ActiveCfg = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Debug|x64.Build.0 = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Debug|x86.ActiveCfg = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Debug|x86.Build.0 = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Release|Any CPU.Build.0 = Release|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Release|x64.ActiveCfg = Release|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Release|x64.Build.0 = Release|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Release|x86.ActiveCfg = Release|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Release|x86.Build.0 = Release|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Checked|Any CPU.Build.0 = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Checked|x64.ActiveCfg = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Checked|x64.Build.0 = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Checked|x86.ActiveCfg = Debug|Any CPU + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -185,10 +325,17 @@ Global GlobalSection(NestedProjects) = preSolution {94B59BA0-491F-4B59-ADFF-A057EC3EC835} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} {04BA3E3C-6979-4792-B19E-C797AD607F42} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} + {07F19F91-D438-428D-99F0-61DAD87E78BA} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} + {768B77B0-EA45-469D-B39E-545EB72F5A43} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} - {6D2197E6-D3DF-43AE-9BEE-3573018639F9} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} - {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {79F7BE0E-01AA-4AFB-B047-CF7C0B38F81E} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {57A1A6FD-9231-4DFB-8619-F0EDEDA208E3} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {4B516949-4AD4-44D6-AF86-C2E6058608D5} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {25D66424-2EAF-464D-8460-10C04EDEF3C3} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {049B7FD4-ACEF-4BCD-A7A7-75C9BBEC4EBF} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {866D295E-424A-4747-9417-CD7746936138} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {D3A329E3-0FEB-4136-9CB6-B38319B0FFA5} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} {5BB5F99F-1052-4EB4-B12E-7863805661F3} = {D893B9AA-57C5-49E3-97B1-12CC62D84307} {8671F164-F78C-44FA-93B7-A310F67890FE} = {D893B9AA-57C5-49E3-97B1-12CC62D84307} EndGlobalSection diff --git a/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln b/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln index 0a16061bee488..d140c4e3a4ffa 100644 --- a/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln +++ b/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln @@ -1,6 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{5965CFFE-886A-418C-854F-5967D91DE914}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{173B5BE0-8306-4EAF-9613-2ACC1DC1710C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F4B604CE-7669-4579-BC56-9949DDE1CF65}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "ref\System.Runtime.Intrinsics.csproj", "{28B808CE-B1F8-4B05-9ADA-8884525BD87F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "src\System.Runtime.Intrinsics.csproj", "{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}" @@ -40,6 +44,42 @@ Global {5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x64.Build.0 = Checked|x64 {5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.ActiveCfg = Checked|x86 {5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.Build.0 = Checked|x86 + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x64.ActiveCfg = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x64.Build.0 = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x86.ActiveCfg = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x86.Build.0 = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|Any CPU.Build.0 = Release|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x64.ActiveCfg = Release|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x64.Build.0 = Release|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x86.ActiveCfg = Release|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x86.Build.0 = Release|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|Any CPU.Build.0 = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x64.ActiveCfg = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x64.Build.0 = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x86.ActiveCfg = Debug|Any CPU + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x86.Build.0 = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x64.ActiveCfg = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x64.Build.0 = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x86.ActiveCfg = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x86.Build.0 = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|Any CPU.Build.0 = Release|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x64.ActiveCfg = Release|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x64.Build.0 = Release|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x86.ActiveCfg = Release|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x86.Build.0 = Release|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|Any CPU.Build.0 = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x64.ActiveCfg = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x64.Build.0 = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x86.ActiveCfg = Debug|Any CPU + {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x86.Build.0 = Debug|Any CPU {28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.Build.0 = Debug|Any CPU {28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -82,6 +122,8 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {5965CFFE-886A-418C-854F-5967D91DE914} = {F110DBFA-22D7-486A-993D-5461A57A1D50} + {173B5BE0-8306-4EAF-9613-2ACC1DC1710C} = {F110DBFA-22D7-486A-993D-5461A57A1D50} + {F4B604CE-7669-4579-BC56-9949DDE1CF65} = {F110DBFA-22D7-486A-993D-5461A57A1D50} {5AD79501-BEA5-48C7-B466-021A9DCB9D5C} = {F110DBFA-22D7-486A-993D-5461A57A1D50} {28B808CE-B1F8-4B05-9ADA-8884525BD87F} = {E7A9B89D-A9F5-40FD-93CA-CAF4522A80E0} EndGlobalSection diff --git a/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln b/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln index e07426491b280..31de20f5cffa8 100644 --- a/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln +++ b/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{04BA3E3C-6979-4792-B19E-C797AD607F42}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{74497070-D782-4958-8D26-BC40A358F8D0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{7DC0688D-77E0-4A58-9966-7CA27CFDD424}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Loader", "ref\System.Runtime.Loader.csproj", "{95B66B14-BCC7-407A-930C-4B34D4F7EC98}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Loader", "src\System.Runtime.Loader.csproj", "{B8F22D73-B183-4F17-9D5E-04B80699E56A}" @@ -142,6 +146,42 @@ Global {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x64.Build.0 = Debug|Any CPU {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.ActiveCfg = Debug|Any CPU {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.Build.0 = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x64.ActiveCfg = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x64.Build.0 = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x86.ActiveCfg = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x86.Build.0 = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Release|Any CPU.Build.0 = Release|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x64.ActiveCfg = Release|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x64.Build.0 = Release|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x86.ActiveCfg = Release|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x86.Build.0 = Release|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|Any CPU.Build.0 = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x64.ActiveCfg = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x64.Build.0 = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x86.ActiveCfg = Debug|Any CPU + {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x86.Build.0 = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x64.Build.0 = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x86.Build.0 = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|Any CPU.Build.0 = Release|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x64.ActiveCfg = Release|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x64.Build.0 = Release|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x86.ActiveCfg = Release|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x86.Build.0 = Release|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|Any CPU.Build.0 = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x64.ActiveCfg = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x64.Build.0 = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x86.ActiveCfg = Debug|Any CPU + {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x86.Build.0 = Debug|Any CPU {95B66B14-BCC7-407A-930C-4B34D4F7EC98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95B66B14-BCC7-407A-930C-4B34D4F7EC98}.Debug|Any CPU.Build.0 = Debug|Any CPU {95B66B14-BCC7-407A-930C-4B34D4F7EC98}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -545,6 +585,8 @@ Global GlobalSection(NestedProjects) = preSolution {64DDD2AF-BF90-4DD8-AC24-D2084DB8D558} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} {04BA3E3C-6979-4792-B19E-C797AD607F42} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} + {74497070-D782-4958-8D26-BC40A358F8D0} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} + {7DC0688D-77E0-4A58-9966-7CA27CFDD424} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} {B8F22D73-B183-4F17-9D5E-04B80699E56A} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} {D6D16FFD-FD76-4700-B456-1DC4D093D1B5} = {F36F0790-5CF7-4CAD-B903-4A3EE0DC1345} {582AA5E5-051B-4774-B02D-747E197A5C56} = {F36F0790-5CF7-4CAD-B903-4A3EE0DC1345} diff --git a/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln b/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln index 3ef823819e0cd..8c5872f30a56b 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln +++ b/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln @@ -73,6 +73,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{4BFED8CA-1221-48EE-8229-BDB8951DB1C7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{09273711-79A7-4B5E-B4DC-6FB80DF5266A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{3E23308D-787F-4CAA-B6BF-70474775F22E}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Formatters", "ref\System.Runtime.Serialization.Formatters.csproj", "{C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Formatters", "src\System.Runtime.Serialization.Formatters.csproj", "{5944056C-E7A1-4A10-BAC4-E3AF91C12C5C}" @@ -792,6 +796,42 @@ Global {4BFED8CA-1221-48EE-8229-BDB8951DB1C7}.Checked|x64.Build.0 = Debug|Any CPU {4BFED8CA-1221-48EE-8229-BDB8951DB1C7}.Checked|x86.ActiveCfg = Debug|Any CPU {4BFED8CA-1221-48EE-8229-BDB8951DB1C7}.Checked|x86.Build.0 = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x64.ActiveCfg = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x64.Build.0 = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x86.ActiveCfg = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x86.Build.0 = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|Any CPU.Build.0 = Release|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x64.ActiveCfg = Release|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x64.Build.0 = Release|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x86.ActiveCfg = Release|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x86.Build.0 = Release|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|Any CPU.Build.0 = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x64.ActiveCfg = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x64.Build.0 = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x86.ActiveCfg = Debug|Any CPU + {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x86.Build.0 = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x64.ActiveCfg = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x64.Build.0 = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x86.ActiveCfg = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x86.Build.0 = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|Any CPU.Build.0 = Release|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x64.ActiveCfg = Release|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x64.Build.0 = Release|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x86.ActiveCfg = Release|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x86.Build.0 = Release|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|Any CPU.Build.0 = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x64.ActiveCfg = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x64.Build.0 = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x86.ActiveCfg = Debug|Any CPU + {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x86.Build.0 = Debug|Any CPU {C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1124,6 +1164,8 @@ Global {1E395137-871B-4D6F-A7DB-C92850FAB0D3} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {79F35586-A12D-4831-9D9D-5134FF07CC41} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {4BFED8CA-1221-48EE-8229-BDB8951DB1C7} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} + {09273711-79A7-4B5E-B4DC-6FB80DF5266A} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} + {3E23308D-787F-4CAA-B6BF-70474775F22E} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {5944056C-E7A1-4A10-BAC4-E3AF91C12C5C} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {711CBCE0-C21C-45DA-B0D2-D2298941058E} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {DF679A1A-1797-40EB-A8AA-E3AEA66C80E5} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} diff --git a/src/libraries/System.Runtime/System.Runtime.sln b/src/libraries/System.Runtime/System.Runtime.sln index e40250683ca63..58b33669354ef 100644 --- a/src/libraries/System.Runtime/System.Runtime.sln +++ b/src/libraries/System.Runtime/System.Runtime.sln @@ -19,6 +19,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{26541647-B653-4480-9448-BA275D53C81D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{52CF1C57-8352-419F-A5B8-DBF39438B70C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{3F401EEE-62E5-442B-8066-7834FDAC9A91}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "ref\System.Runtime.csproj", "{F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "src\System.Runtime.csproj", "{A83A8520-F5E2-49B4-83BC-0F82A412951D}" @@ -246,6 +250,42 @@ Global {26541647-B653-4480-9448-BA275D53C81D}.Checked|x64.Build.0 = Debug|Any CPU {26541647-B653-4480-9448-BA275D53C81D}.Checked|x86.ActiveCfg = Debug|Any CPU {26541647-B653-4480-9448-BA275D53C81D}.Checked|x86.Build.0 = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x64.ActiveCfg = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x64.Build.0 = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x86.ActiveCfg = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x86.Build.0 = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|Any CPU.Build.0 = Release|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x64.ActiveCfg = Release|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x64.Build.0 = Release|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x86.ActiveCfg = Release|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x86.Build.0 = Release|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|Any CPU.Build.0 = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x64.ActiveCfg = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x64.Build.0 = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x86.ActiveCfg = Debug|Any CPU + {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x86.Build.0 = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x64.ActiveCfg = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x64.Build.0 = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x86.ActiveCfg = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x86.Build.0 = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|Any CPU.Build.0 = Release|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x64.ActiveCfg = Release|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x64.Build.0 = Release|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x86.ActiveCfg = Release|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x86.Build.0 = Release|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|Any CPU.Build.0 = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x64.ActiveCfg = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x64.Build.0 = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x86.ActiveCfg = Debug|Any CPU + {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x86.Build.0 = Debug|Any CPU {F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -508,6 +548,8 @@ Global {F27DC16B-64F4-4BD7-AF9C-1C76F7ACC88B} = {28140562-A65A-48E9-ABAB-53BA939084F0} {E7A05515-DABE-4C09-83CB-CE84EFDCD4CC} = {28140562-A65A-48E9-ABAB-53BA939084F0} {26541647-B653-4480-9448-BA275D53C81D} = {28140562-A65A-48E9-ABAB-53BA939084F0} + {52CF1C57-8352-419F-A5B8-DBF39438B70C} = {28140562-A65A-48E9-ABAB-53BA939084F0} + {3F401EEE-62E5-442B-8066-7834FDAC9A91} = {28140562-A65A-48E9-ABAB-53BA939084F0} {A83A8520-F5E2-49B4-83BC-0F82A412951D} = {28140562-A65A-48E9-ABAB-53BA939084F0} {F6A8185B-07C6-401D-9B40-3C560239E05F} = {28140562-A65A-48E9-ABAB-53BA939084F0} {9CF6C6E6-0E9F-4A95-84B5-6083EAB6FA13} = {28140562-A65A-48E9-ABAB-53BA939084F0} diff --git a/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln b/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln index 1508b05a1bb4a..a3f613b3916a9 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln +++ b/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{11EF92B5-6C9B-4272-8360-F34A1109F831}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{EE97A768-EF3A-4BF9-BD6D-79EED544BE41}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Algorithms", "ref\System.Security.Cryptography.Algorithms.csproj", "{64C0BC45-368B-44E6-9E04-2F7787CDF153}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Algorithms", "src\System.Security.Cryptography.Algorithms.csproj", "{4146BAB4-BA7C-405E-BEBC-9BE9826514BA}" @@ -53,6 +57,14 @@ Global {11EF92B5-6C9B-4272-8360-F34A1109F831}.Debug|Any CPU.Build.0 = Debug|Any CPU {11EF92B5-6C9B-4272-8360-F34A1109F831}.Release|Any CPU.ActiveCfg = Release|Any CPU {11EF92B5-6C9B-4272-8360-F34A1109F831}.Release|Any CPU.Build.0 = Release|Any CPU + {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Release|Any CPU.Build.0 = Release|Any CPU + {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Release|Any CPU.Build.0 = Release|Any CPU {64C0BC45-368B-44E6-9E04-2F7787CDF153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {64C0BC45-368B-44E6-9E04-2F7787CDF153}.Debug|Any CPU.Build.0 = Debug|Any CPU {64C0BC45-368B-44E6-9E04-2F7787CDF153}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -90,6 +102,8 @@ Global {5BD4A2ED-6203-41E2-9892-002BCC40B0C8} = {FC920C3F-3A16-4258-9DF1-3B1BB3408C69} {AA21E963-CF6B-4474-81A6-D13279854954} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {11EF92B5-6C9B-4272-8360-F34A1109F831} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} + {EE97A768-EF3A-4BF9-BD6D-79EED544BE41} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} + {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {4146BAB4-BA7C-405E-BEBC-9BE9826514BA} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {3928EE57-D7D0-45B8-AACD-57DF67D7089A} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {E5E427F0-D149-4992-AF31-F8616600E188} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} diff --git a/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln b/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln index 84f9f43c9f616..aadc72c6281a9 100644 --- a/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln +++ b/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{39FEA352-F1A3-48AC-89FE-79E976218AC1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BB64DE6A-4AEE-4A7D-879F-28886267817F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{70AD43AF-3C27-4D54-B673-30A66EBB7780}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "ref\System.Security.Cryptography.Cng.csproj", "{B88D8B7E-7682-4F23-82AF-DF186BDD3255}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "src\System.Security.Cryptography.Cng.csproj", "{4BAA22AA-6F42-4C31-8CCF-256F30A26228}" @@ -49,6 +53,14 @@ Global {39FEA352-F1A3-48AC-89FE-79E976218AC1}.Debug|Any CPU.Build.0 = Debug|Any CPU {39FEA352-F1A3-48AC-89FE-79E976218AC1}.Release|Any CPU.ActiveCfg = Release|Any CPU {39FEA352-F1A3-48AC-89FE-79E976218AC1}.Release|Any CPU.Build.0 = Release|Any CPU + {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Release|Any CPU.Build.0 = Release|Any CPU + {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Release|Any CPU.Build.0 = Release|Any CPU {B88D8B7E-7682-4F23-82AF-DF186BDD3255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B88D8B7E-7682-4F23-82AF-DF186BDD3255}.Debug|Any CPU.Build.0 = Debug|Any CPU {B88D8B7E-7682-4F23-82AF-DF186BDD3255}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -77,6 +89,8 @@ Global {B88D8B7E-7682-4F23-82AF-DF186BDD3255} = {3B5CC70E-D006-426A-BC91-6A7DEE2F7181} {28FC516D-19C2-43C6-BCBE-10273185673D} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} {39FEA352-F1A3-48AC-89FE-79E976218AC1} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} + {BB64DE6A-4AEE-4A7D-879F-28886267817F} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} + {70AD43AF-3C27-4D54-B673-30A66EBB7780} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} {4BAA22AA-6F42-4C31-8CCF-256F30A26228} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} {929388A9-0224-4FF8-867A-267E47A03311} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln b/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln index b276f9a4ca5b6..1ccbabae402b8 100644 --- a/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln +++ b/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{441BBB8B-D6D7-4518-83B6-687AFC2C6202}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{3AD118FF-93FC-4B2D-B899-B90BB570455F}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Csp", "ref\System.Security.Cryptography.Csp.csproj", "{D960CDE1-79C4-46A5-A0E3-3F49AB63DEF9}" @@ -49,6 +53,14 @@ Global {441BBB8B-D6D7-4518-83B6-687AFC2C6202}.Debug|Any CPU.Build.0 = Debug|Any CPU {441BBB8B-D6D7-4518-83B6-687AFC2C6202}.Release|Any CPU.ActiveCfg = Release|Any CPU {441BBB8B-D6D7-4518-83B6-687AFC2C6202}.Release|Any CPU.Build.0 = Release|Any CPU + {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Release|Any CPU.Build.0 = Release|Any CPU + {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Release|Any CPU.Build.0 = Release|Any CPU {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -77,6 +89,8 @@ Global {D960CDE1-79C4-46A5-A0E3-3F49AB63DEF9} = {1F3677F4-9173-4B3A-BE7B-9616A7A5FDA9} {DA82AA17-5946-4454-B22E-11B3FC3F8D5C} = {004448ED-CE3D-4EEE-B176-458440B11AEB} {441BBB8B-D6D7-4518-83B6-687AFC2C6202} = {004448ED-CE3D-4EEE-B176-458440B11AEB} + {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4} = {004448ED-CE3D-4EEE-B176-458440B11AEB} + {3AD118FF-93FC-4B2D-B899-B90BB570455F} = {004448ED-CE3D-4EEE-B176-458440B11AEB} {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10} = {004448ED-CE3D-4EEE-B176-458440B11AEB} {153000A6-96D2-4E0D-8E34-13B85E8ECACD} = {004448ED-CE3D-4EEE-B176-458440B11AEB} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln b/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln index 57e684a8d44c0..df43d1f8698ad 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln +++ b/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln @@ -5,6 +5,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{43B33B0D-4009-4838-B9F4-E5308C1827F7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{4CFB0571-B19E-4524-A6A1-2B1503E574FC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{0FF5C465-AA5F-4C08-85BA-B6FE6D390569}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Encoding", "ref\System.Security.Cryptography.Encoding.csproj", "{465CB04B-D2D8-4E64-BA6D-571BE95391B4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Encoding", "src\System.Security.Cryptography.Encoding.csproj", "{4B1D276E-6576-4F42-9F38-C91C95437F20}" @@ -35,6 +39,14 @@ Global {43B33B0D-4009-4838-B9F4-E5308C1827F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {43B33B0D-4009-4838-B9F4-E5308C1827F7}.Release|Any CPU.ActiveCfg = Release|Any CPU {43B33B0D-4009-4838-B9F4-E5308C1827F7}.Release|Any CPU.Build.0 = Release|Any CPU + {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Release|Any CPU.Build.0 = Release|Any CPU + {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Release|Any CPU.Build.0 = Release|Any CPU {465CB04B-D2D8-4E64-BA6D-571BE95391B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {465CB04B-D2D8-4E64-BA6D-571BE95391B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {465CB04B-D2D8-4E64-BA6D-571BE95391B4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -57,6 +69,8 @@ Global {A428E072-E4DD-4F64-AFE3-DC9FC8D5563D} = {34B969D7-6BED-4597-8C25-502A29CF0518} {465CB04B-D2D8-4E64-BA6D-571BE95391B4} = {34B969D7-6BED-4597-8C25-502A29CF0518} {43B33B0D-4009-4838-B9F4-E5308C1827F7} = {0806AC6F-4837-437A-A32F-EED211934481} + {4CFB0571-B19E-4524-A6A1-2B1503E574FC} = {0806AC6F-4837-437A-A32F-EED211934481} + {0FF5C465-AA5F-4C08-85BA-B6FE6D390569} = {0806AC6F-4837-437A-A32F-EED211934481} {4B1D276E-6576-4F42-9F38-C91C95437F20} = {0806AC6F-4837-437A-A32F-EED211934481} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln b/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln index 6a45e071a54e7..69b6816eddfd7 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln +++ b/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{6C660B52-0FE3-43B9-838E-2F92B34E97D9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{4DB1DDA9-3749-49DF-9F52-FA977223C9D7}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{12345E87-4C47-4857-B7E4-6673D6ECC05F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "ref\System.Security.Cryptography.OpenSsl.csproj", "{5AC30FC5-0E64-4C71-AD80-FE758709E22B}" @@ -49,6 +53,14 @@ Global {6C660B52-0FE3-43B9-838E-2F92B34E97D9}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C660B52-0FE3-43B9-838E-2F92B34E97D9}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C660B52-0FE3-43B9-838E-2F92B34E97D9}.Release|Any CPU.Build.0 = Release|Any CPU + {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Release|Any CPU.Build.0 = Release|Any CPU + {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Release|Any CPU.Build.0 = Release|Any CPU {12345E87-4C47-4857-B7E4-6673D6ECC05F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {12345E87-4C47-4857-B7E4-6673D6ECC05F}.Debug|Any CPU.Build.0 = Debug|Any CPU {12345E87-4C47-4857-B7E4-6673D6ECC05F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -77,6 +89,8 @@ Global {5AC30FC5-0E64-4C71-AD80-FE758709E22B} = {8B6D53E6-8F7B-47D1-B6D7-890A783A9959} {A84FF2B2-5272-4F02-AA2B-C0FA61586AA4} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} {6C660B52-0FE3-43B9-838E-2F92B34E97D9} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} + {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} + {4DB1DDA9-3749-49DF-9F52-FA977223C9D7} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} {12345E87-4C47-4857-B7E4-6673D6ECC05F} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} {A0136D6F-CF53-42F8-9227-2FFF2A1841AA} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln b/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln index 623cbbcbd5fc4..530446da2e06d 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln +++ b/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DA204355-86E3-431D-B08E-483A49BEB3DB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{A76122D2-2C2C-464C-867F-DE25E9513F86}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{24219BEB-7226-4E84-8CF3-37CFF99A327E}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{906CF937-8BCE-4ABF-B35C-23D51D59232E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Pkcs", "ref\System.Security.Cryptography.Pkcs.csproj", "{1AFD2D0A-B962-449B-AC3B-12ED1F439E91}" @@ -49,6 +53,14 @@ Global {DA204355-86E3-431D-B08E-483A49BEB3DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA204355-86E3-431D-B08E-483A49BEB3DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA204355-86E3-431D-B08E-483A49BEB3DB}.Release|Any CPU.Build.0 = Release|Any CPU + {A76122D2-2C2C-464C-867F-DE25E9513F86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A76122D2-2C2C-464C-867F-DE25E9513F86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A76122D2-2C2C-464C-867F-DE25E9513F86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A76122D2-2C2C-464C-867F-DE25E9513F86}.Release|Any CPU.Build.0 = Release|Any CPU + {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Release|Any CPU.Build.0 = Release|Any CPU {906CF937-8BCE-4ABF-B35C-23D51D59232E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {906CF937-8BCE-4ABF-B35C-23D51D59232E}.Debug|Any CPU.Build.0 = Debug|Any CPU {906CF937-8BCE-4ABF-B35C-23D51D59232E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -77,6 +89,8 @@ Global {1AFD2D0A-B962-449B-AC3B-12ED1F439E91} = {FD768C8B-9BF1-4F02-A2C4-335B22615763} {A8D95486-BBE9-4AD2-9D7C-D5B7CF6B90FD} = {D5B768A4-9BA9-4E78-B735-60052C68035C} {DA204355-86E3-431D-B08E-483A49BEB3DB} = {D5B768A4-9BA9-4E78-B735-60052C68035C} + {A76122D2-2C2C-464C-867F-DE25E9513F86} = {D5B768A4-9BA9-4E78-B735-60052C68035C} + {24219BEB-7226-4E84-8CF3-37CFF99A327E} = {D5B768A4-9BA9-4E78-B735-60052C68035C} {906CF937-8BCE-4ABF-B35C-23D51D59232E} = {D5B768A4-9BA9-4E78-B735-60052C68035C} {DDD75646-C8BD-4B16-8E59-E6A3668FD9A2} = {D5B768A4-9BA9-4E78-B735-60052C68035C} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln b/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln index 6f05428ab2d83..3acdb21d974a1 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln +++ b/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{52FC346D-2936-43FD-93A6-02F019A5F5EC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{4D482398-BE79-40F1-A19D-67326A2628B9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9471A98A-28BF-43D6-9E54-F6A340442B32}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{97BBCB3E-6924-4EE7-94AD-9B2B793A7ABD}" @@ -55,6 +59,14 @@ Global {52FC346D-2936-43FD-93A6-02F019A5F5EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {52FC346D-2936-43FD-93A6-02F019A5F5EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {52FC346D-2936-43FD-93A6-02F019A5F5EC}.Release|Any CPU.Build.0 = Release|Any CPU + {4D482398-BE79-40F1-A19D-67326A2628B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D482398-BE79-40F1-A19D-67326A2628B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D482398-BE79-40F1-A19D-67326A2628B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D482398-BE79-40F1-A19D-67326A2628B9}.Release|Any CPU.Build.0 = Release|Any CPU + {9471A98A-28BF-43D6-9E54-F6A340442B32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9471A98A-28BF-43D6-9E54-F6A340442B32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9471A98A-28BF-43D6-9E54-F6A340442B32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9471A98A-28BF-43D6-9E54-F6A340442B32}.Release|Any CPU.Build.0 = Release|Any CPU {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}.Debug|Any CPU.Build.0 = Debug|Any CPU {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -96,6 +108,8 @@ Global {4EC57148-D181-49B9-BDAF-1735D4687C79} = {C79093E1-DEC3-4A35-93CB-216D1E87ACDD} {C2D74126-653E-41C9-9CF8-E58F1FD110B8} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {52FC346D-2936-43FD-93A6-02F019A5F5EC} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} + {4D482398-BE79-40F1-A19D-67326A2628B9} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} + {9471A98A-28BF-43D6-9E54-F6A340442B32} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {97BBCB3E-6924-4EE7-94AD-9B2B793A7ABD} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {76812DB0-A6A2-4F0C-B560-18FC7A97E419} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} diff --git a/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln b/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln index c1a2be6a07283..cf1b748e1ea6d 100644 --- a/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln +++ b/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln @@ -1,14 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{6893D05F-56C1-4454-B3C8-DF83B2791C62}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{013A3141-8CCB-477A-B4B2-A5A5F2CC7603}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{F2034D74-55F1-4055-AC85-12F80A7E56CD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{737DC738-86E3-4528-B7B5-6DB9981A8A7A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\ref\System.Formats.Asn1.csproj", "{69CF4D3A-5F10-4BCA-B975-0D6239447EDE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\src\System.Formats.Asn1.csproj", "{4412A97C-77C7-4C89-8F78-E26AEEDE8CA8}" @@ -27,14 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptograph EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Xml.Tests", "tests\System.Security.Cryptography.Xml.Tests.csproj", "{675D4EE3-1F0E-4445-A9CD-635ED3351751}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{42320794-D862-4CD4-9D67-F667A8820AA6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{B52971E5-EABD-4BE9-942A-EDAA290DB09B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{28200C76-F42D-4E11-B948-C8D9193A58A1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{404253AC-EAFF-488F-8980-2249F4703278}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F25E8B4D-D7E9-4086-A263-CB9D3B41074B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{B8C68464-1D28-4889-90BC-BC80B036B90B}" @@ -51,22 +35,6 @@ Global {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}.Debug|Any CPU.Build.0 = Debug|Any CPU {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}.Release|Any CPU.ActiveCfg = Release|Any CPU {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}.Release|Any CPU.Build.0 = Release|Any CPU - {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Release|Any CPU.Build.0 = Release|Any CPU - {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Debug|Any CPU.Build.0 = Debug|Any CPU - {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Release|Any CPU.ActiveCfg = Release|Any CPU - {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Release|Any CPU.Build.0 = Release|Any CPU - {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Release|Any CPU.Build.0 = Release|Any CPU - {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Release|Any CPU.Build.0 = Release|Any CPU {69CF4D3A-5F10-4BCA-B975-0D6239447EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69CF4D3A-5F10-4BCA-B975-0D6239447EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU {69CF4D3A-5F10-4BCA-B975-0D6239447EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -103,22 +71,6 @@ Global {675D4EE3-1F0E-4445-A9CD-635ED3351751}.Debug|Any CPU.Build.0 = Debug|Any CPU {675D4EE3-1F0E-4445-A9CD-635ED3351751}.Release|Any CPU.ActiveCfg = Release|Any CPU {675D4EE3-1F0E-4445-A9CD-635ED3351751}.Release|Any CPU.Build.0 = Release|Any CPU - {42320794-D862-4CD4-9D67-F667A8820AA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {42320794-D862-4CD4-9D67-F667A8820AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {42320794-D862-4CD4-9D67-F667A8820AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {42320794-D862-4CD4-9D67-F667A8820AA6}.Release|Any CPU.Build.0 = Release|Any CPU - {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Release|Any CPU.Build.0 = Release|Any CPU - {28200C76-F42D-4E11-B948-C8D9193A58A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {28200C76-F42D-4E11-B948-C8D9193A58A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {28200C76-F42D-4E11-B948-C8D9193A58A1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {28200C76-F42D-4E11-B948-C8D9193A58A1}.Release|Any CPU.Build.0 = Release|Any CPU - {404253AC-EAFF-488F-8980-2249F4703278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {404253AC-EAFF-488F-8980-2249F4703278}.Debug|Any CPU.Build.0 = Debug|Any CPU - {404253AC-EAFF-488F-8980-2249F4703278}.Release|Any CPU.ActiveCfg = Release|Any CPU - {404253AC-EAFF-488F-8980-2249F4703278}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -126,22 +78,14 @@ Global GlobalSection(NestedProjects) = preSolution {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77} = {F25E8B4D-D7E9-4086-A263-CB9D3B41074B} {675D4EE3-1F0E-4445-A9CD-635ED3351751} = {F25E8B4D-D7E9-4086-A263-CB9D3B41074B} - {6893D05F-56C1-4454-B3C8-DF83B2791C62} = {B8C68464-1D28-4889-90BC-BC80B036B90B} - {F2034D74-55F1-4055-AC85-12F80A7E56CD} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {69CF4D3A-5F10-4BCA-B975-0D6239447EDE} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {FB3C7609-962F-4414-8702-B3D4121AC51B} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {18882345-4F75-42DB-8DC9-A38AD5C4785E} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {2BB35F95-AD1A-45D3-B8E2-84CC690073A8} = {B8C68464-1D28-4889-90BC-BC80B036B90B} - {42320794-D862-4CD4-9D67-F667A8820AA6} = {B8C68464-1D28-4889-90BC-BC80B036B90B} - {28200C76-F42D-4E11-B948-C8D9193A58A1} = {B8C68464-1D28-4889-90BC-BC80B036B90B} - {013A3141-8CCB-477A-B4B2-A5A5F2CC7603} = {BA579BFF-D4D9-455A-A8AC-589361391420} - {737DC738-86E3-4528-B7B5-6DB9981A8A7A} = {BA579BFF-D4D9-455A-A8AC-589361391420} {4412A97C-77C7-4C89-8F78-E26AEEDE8CA8} = {BA579BFF-D4D9-455A-A8AC-589361391420} {158DDF64-D678-492E-A38A-0EE12E096F84} = {BA579BFF-D4D9-455A-A8AC-589361391420} {474CEFD4-533F-4A2E-8CF9-860F388BC332} = {BA579BFF-D4D9-455A-A8AC-589361391420} {848640EF-9F7D-4D01-AA87-E16617FDEE0B} = {BA579BFF-D4D9-455A-A8AC-589361391420} - {B52971E5-EABD-4BE9-942A-EDAA290DB09B} = {BA579BFF-D4D9-455A-A8AC-589361391420} - {404253AC-EAFF-488F-8980-2249F4703278} = {BA579BFF-D4D9-455A-A8AC-589361391420} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E0287BE2-B499-4885-8EE8-0B35585CA885} diff --git a/src/libraries/System.Security.Permissions/NuGet.config b/src/libraries/System.Security.Permissions/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Security.Permissions/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Security.Principal/System.Security.Principal.sln b/src/libraries/System.Security.Principal/System.Security.Principal.sln index 047d9dd5c7932..c2870898d4c8d 100644 --- a/src/libraries/System.Security.Principal/System.Security.Principal.sln +++ b/src/libraries/System.Security.Principal/System.Security.Principal.sln @@ -1,6 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{45602EBE-1508-43A8-A398-1B92BD243557}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{08FE96C0-8567-4DDC-821D-60429E5AD2C7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{60D524AF-8F46-47FD-BCDA-B388763FEC91}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal", "ref\System.Security.Principal.csproj", "{23171947-F933-47A6-9D1A-D43A186E7C43}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal", "src\System.Security.Principal.csproj", "{BCF529C8-91CA-44BE-A59C-C8FCAEC04D51}" @@ -40,6 +44,42 @@ Global {45602EBE-1508-43A8-A398-1B92BD243557}.Checked|x64.Build.0 = Checked|x64 {45602EBE-1508-43A8-A398-1B92BD243557}.Checked|x86.ActiveCfg = Checked|x86 {45602EBE-1508-43A8-A398-1B92BD243557}.Checked|x86.Build.0 = Checked|x86 + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x64.ActiveCfg = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x64.Build.0 = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x86.ActiveCfg = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x86.Build.0 = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|Any CPU.Build.0 = Release|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x64.ActiveCfg = Release|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x64.Build.0 = Release|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x86.ActiveCfg = Release|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x86.Build.0 = Release|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|Any CPU.Build.0 = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x64.ActiveCfg = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x64.Build.0 = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x86.ActiveCfg = Debug|Any CPU + {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x86.Build.0 = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x64.ActiveCfg = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x64.Build.0 = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x86.ActiveCfg = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x86.Build.0 = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|Any CPU.Build.0 = Release|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x64.ActiveCfg = Release|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x64.Build.0 = Release|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x86.ActiveCfg = Release|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x86.Build.0 = Release|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|Any CPU.Build.0 = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x64.ActiveCfg = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x64.Build.0 = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x86.ActiveCfg = Debug|Any CPU + {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x86.Build.0 = Debug|Any CPU {23171947-F933-47A6-9D1A-D43A186E7C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23171947-F933-47A6-9D1A-D43A186E7C43}.Debug|Any CPU.Build.0 = Debug|Any CPU {23171947-F933-47A6-9D1A-D43A186E7C43}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -82,6 +122,8 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {45602EBE-1508-43A8-A398-1B92BD243557} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} + {08FE96C0-8567-4DDC-821D-60429E5AD2C7} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} + {60D524AF-8F46-47FD-BCDA-B388763FEC91} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} {BCF529C8-91CA-44BE-A59C-C8FCAEC04D51} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} {23171947-F933-47A6-9D1A-D43A186E7C43} = {DC35DE57-330D-4DE1-822D-12AEA72B1015} EndGlobalSection diff --git a/src/libraries/System.Speech/NuGet.config b/src/libraries/System.Speech/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Speech/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln b/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln index 4ca8018532b55..450091714c56b 100644 --- a/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln +++ b/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{4EFA1701-458A-4318-9552-5BF0734D5C72}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding.Extensions", "ref\System.Text.Encoding.Extensions.csproj", "{F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding.Extensions", "src\System.Text.Encoding.Extensions.csproj", "{EF713897-15F9-42E4-979F-271FA1EF6ECA}" @@ -104,6 +108,42 @@ Global {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}.Checked|x64.Build.0 = Debug|Any CPU {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}.Checked|x86.ActiveCfg = Debug|Any CPU {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}.Checked|x86.Build.0 = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x64.ActiveCfg = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x64.Build.0 = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x86.ActiveCfg = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x86.Build.0 = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|Any CPU.Build.0 = Release|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x64.ActiveCfg = Release|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x64.Build.0 = Release|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x86.ActiveCfg = Release|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x86.Build.0 = Release|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|Any CPU.Build.0 = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x64.ActiveCfg = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x64.Build.0 = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x86.ActiveCfg = Debug|Any CPU + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x86.Build.0 = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x64.ActiveCfg = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x64.Build.0 = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x86.ActiveCfg = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x86.Build.0 = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|Any CPU.Build.0 = Release|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x64.ActiveCfg = Release|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x64.Build.0 = Release|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x86.ActiveCfg = Release|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x86.Build.0 = Release|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|Any CPU.Build.0 = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x64.ActiveCfg = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x64.Build.0 = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x86.ActiveCfg = Debug|Any CPU + {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x86.Build.0 = Debug|Any CPU {F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -165,6 +205,8 @@ Global GlobalSection(NestedProjects) = preSolution {E70D3A84-3053-4E44-82FC-A56A574BF6F8} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} + {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} + {4EFA1701-458A-4318-9552-5BF0734D5C72} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} {EF713897-15F9-42E4-979F-271FA1EF6ECA} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} {CC6D3524-D6C8-468B-B908-CE746C1DB175} = {6A521BB6-5A53-4871-8EF7-15C4FCF0B416} {777B4928-6EE5-42D2-8F95-E43EB027D14E} = {6A521BB6-5A53-4871-8EF7-15C4FCF0B416} diff --git a/src/libraries/System.Text.Encoding/System.Text.Encoding.sln b/src/libraries/System.Text.Encoding/System.Text.Encoding.sln index f8dbd8b951bde..963bc99b47931 100644 --- a/src/libraries/System.Text.Encoding/System.Text.Encoding.sln +++ b/src/libraries/System.Text.Encoding/System.Text.Encoding.sln @@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2E6A015C-B78A-4ABB-A623-73956CA3E5FC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{256D7821-23FE-4AF5-B126-75CF1E446D09}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{DDB04173-B88A-4578-A577-C41162D38721}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding", "ref\System.Text.Encoding.csproj", "{B4D27B82-8D9C-4699-9E37-06796D9981EB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding", "src\System.Text.Encoding.csproj", "{57B651DB-5817-4AB7-BF66-C440109F16F9}" @@ -164,6 +168,42 @@ Global {2E6A015C-B78A-4ABB-A623-73956CA3E5FC}.Checked|x64.Build.0 = Debug|Any CPU {2E6A015C-B78A-4ABB-A623-73956CA3E5FC}.Checked|x86.ActiveCfg = Debug|Any CPU {2E6A015C-B78A-4ABB-A623-73956CA3E5FC}.Checked|x86.Build.0 = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x64.ActiveCfg = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x64.Build.0 = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x86.ActiveCfg = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x86.Build.0 = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|Any CPU.Build.0 = Release|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x64.ActiveCfg = Release|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x64.Build.0 = Release|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x86.ActiveCfg = Release|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x86.Build.0 = Release|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|Any CPU.Build.0 = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x64.ActiveCfg = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x64.Build.0 = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x86.ActiveCfg = Debug|Any CPU + {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x86.Build.0 = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x64.ActiveCfg = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x64.Build.0 = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x86.ActiveCfg = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x86.Build.0 = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Release|Any CPU.Build.0 = Release|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Release|x64.ActiveCfg = Release|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Release|x64.Build.0 = Release|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Release|x86.ActiveCfg = Release|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Release|x86.Build.0 = Release|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Checked|Any CPU.Build.0 = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x64.ActiveCfg = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x64.Build.0 = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x86.ActiveCfg = Debug|Any CPU + {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x86.Build.0 = Debug|Any CPU {B4D27B82-8D9C-4699-9E37-06796D9981EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B4D27B82-8D9C-4699-9E37-06796D9981EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B4D27B82-8D9C-4699-9E37-06796D9981EB}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -226,6 +266,8 @@ Global {8E868804-E3B3-4933-BFA9-E69F7704B3A5} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {530C65D8-0440-4AF2-8975-F03EFF573195} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {2E6A015C-B78A-4ABB-A623-73956CA3E5FC} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} + {256D7821-23FE-4AF5-B126-75CF1E446D09} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} + {DDB04173-B88A-4578-A577-C41162D38721} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {57B651DB-5817-4AB7-BF66-C440109F16F9} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {9E01529D-6C36-4F34-84CB-68304E93E1F5} = {A4D340E7-AF75-4FA7-AB84-B743E8BB163E} {2B15EE47-1C5F-444F-A9CD-EABBE370718E} = {A4D340E7-AF75-4FA7-AB84-B743E8BB163E} diff --git a/src/libraries/System.Text.Json/System.Text.Json.sln b/src/libraries/System.Text.Json/System.Text.Json.sln index 42d1e7c1dd76c..425af9cef5db5 100644 --- a/src/libraries/System.Text.Json/System.Text.Json.sln +++ b/src/libraries/System.Text.Json/System.Text.Json.sln @@ -21,7 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{9BCCDA15-8907-4AE3-8871-2F17775DDE4C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn4.0", "gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{6485EED4-C313-4551-9865-8ADCED603629}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{6485EED4-C313-4551-9865-8ADCED603629}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "ref\System.Text.Json.csproj", "{7015E94D-D20D-48C8-86D7-6A996BE99E0E}" EndProject @@ -29,8 +31,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "src\Sys EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "System.Text.Json.FSharp.Tests", "tests\System.Text.Json.FSharp.Tests\System.Text.Json.FSharp.Tests.fsproj", "{5720BF06-2031-4AD8-B9B4-31A01E27ABB8}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Tests", "tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj", "{66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn4.0.Tests", "tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn4.0.Tests.csproj", "{33599A6C-F340-4E1B-9B4D-CB8946C22140}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests", "tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj", "{256A4653-4287-44B3-BDEF-67FC1522ED2F}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn4.0.Unit.Tests", "tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn4.0.Unit.Tests.csproj", "{F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.Tests", "tests\System.Text.Json.Tests\System.Text.Json.Tests.csproj", "{A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}" @@ -41,12 +47,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{0371C5D8-D5F EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E49881A9-09F6-442F-9E1D-6D87F5F837F1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11", "gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests", "tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj", "{256A4653-4287-44B3-BDEF-67FC1522ED2F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Tests", "tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj", "{66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,6 +97,10 @@ Global {9BCCDA15-8907-4AE3-8871-2F17775DDE4C}.Debug|Any CPU.Build.0 = Debug|Any CPU {9BCCDA15-8907-4AE3-8871-2F17775DDE4C}.Release|Any CPU.ActiveCfg = Release|Any CPU {9BCCDA15-8907-4AE3-8871-2F17775DDE4C}.Release|Any CPU.Build.0 = Release|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.Build.0 = Release|Any CPU {6485EED4-C313-4551-9865-8ADCED603629}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6485EED4-C313-4551-9865-8ADCED603629}.Debug|Any CPU.Build.0 = Debug|Any CPU {6485EED4-C313-4551-9865-8ADCED603629}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -113,10 +117,18 @@ Global {5720BF06-2031-4AD8-B9B4-31A01E27ABB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {5720BF06-2031-4AD8-B9B4-31A01E27ABB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {5720BF06-2031-4AD8-B9B4-31A01E27ABB8}.Release|Any CPU.Build.0 = Release|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.Build.0 = Release|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Debug|Any CPU.Build.0 = Debug|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Release|Any CPU.ActiveCfg = Release|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Release|Any CPU.Build.0 = Release|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.Build.0 = Release|Any CPU {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -125,44 +137,32 @@ Global {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}.Debug|Any CPU.Build.0 = Debug|Any CPU {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}.Release|Any CPU.Build.0 = Release|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.Build.0 = Release|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.Build.0 = Release|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {102945CA-3736-4B2C-8E68-242A0B247F2B} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {5720BF06-2031-4AD8-B9B4-31A01E27ABB8} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {33599A6C-F340-4E1B-9B4D-CB8946C22140} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {256A4653-4287-44B3-BDEF-67FC1522ED2F} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} {73D5739C-E382-4E22-A7D3-B82705C58C74} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {E9AA0AEB-AEAE-4B28-8D4D-17A6D7C89D17} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} {BE27618A-2916-4269-9AD5-6BC5EDC32B30} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {1C8262DB-7355-40A8-A2EC-4EED7363134A} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} {4774F56D-16A8-4ABB-8C73-5F57609F1773} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {D05FD93A-BC51-466E-BD56-3F3D6BBE6B06} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} {E2077991-EB83-471C-B17F-72F569FFCE6D} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {7909EB27-0D6E-46E6-B9F9-8A1EFD557018} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} {C56337BB-8CBC-4EE5-AB4D-8BB0A922813E} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} + {7015E94D-D20D-48C8-86D7-6A996BE99E0E} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} + {E9AA0AEB-AEAE-4B28-8D4D-17A6D7C89D17} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {1C8262DB-7355-40A8-A2EC-4EED7363134A} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {D05FD93A-BC51-466E-BD56-3F3D6BBE6B06} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {7909EB27-0D6E-46E6-B9F9-8A1EFD557018} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} {9BCCDA15-8907-4AE3-8871-2F17775DDE4C} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} {6485EED4-C313-4551-9865-8ADCED603629} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} - {7015E94D-D20D-48C8-86D7-6A996BE99E0E} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} {1285FF43-F491-4BE0-B92C-37DA689CBD4B} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} - {5720BF06-2031-4AD8-B9B4-31A01E27ABB8} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {33599A6C-F340-4E1B-9B4D-CB8946C22140} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} - {256A4653-4287-44B3-BDEF-67FC1522ED2F} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5868B757-D821-41FC-952E-2113A0519506} diff --git a/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln b/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln index c7430000eb0a3..16795eefa1b4c 100644 --- a/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln +++ b/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{217A3A01-70DC-4A0D-87C0-04D581B49183}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Overlapped", "ref\System.Threading.Overlapped.csproj", "{05F39036-EF46-438F-8033-084B5C14832B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Overlapped", "src\System.Threading.Overlapped.csproj", "{A3D9C10B-53A3-483C-8D90-BE7C078B82DF}" @@ -104,6 +108,42 @@ Global {217A3A01-70DC-4A0D-87C0-04D581B49183}.Checked|x64.Build.0 = Debug|Any CPU {217A3A01-70DC-4A0D-87C0-04D581B49183}.Checked|x86.ActiveCfg = Debug|Any CPU {217A3A01-70DC-4A0D-87C0-04D581B49183}.Checked|x86.Build.0 = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x64.ActiveCfg = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x64.Build.0 = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x86.ActiveCfg = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x86.Build.0 = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|Any CPU.Build.0 = Release|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x64.ActiveCfg = Release|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x64.Build.0 = Release|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x86.ActiveCfg = Release|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x86.Build.0 = Release|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|Any CPU.Build.0 = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x64.ActiveCfg = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x64.Build.0 = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x86.ActiveCfg = Debug|Any CPU + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x86.Build.0 = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x64.ActiveCfg = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x64.Build.0 = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x86.ActiveCfg = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x86.Build.0 = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|Any CPU.Build.0 = Release|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x64.ActiveCfg = Release|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x64.Build.0 = Release|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x86.ActiveCfg = Release|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x86.Build.0 = Release|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|Any CPU.Build.0 = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x64.ActiveCfg = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x64.Build.0 = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x86.ActiveCfg = Debug|Any CPU + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x86.Build.0 = Debug|Any CPU {05F39036-EF46-438F-8033-084B5C14832B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05F39036-EF46-438F-8033-084B5C14832B}.Debug|Any CPU.Build.0 = Debug|Any CPU {05F39036-EF46-438F-8033-084B5C14832B}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -165,6 +205,8 @@ Global GlobalSection(NestedProjects) = preSolution {2F704A4A-944B-487C-BB11-D66CA63F3B05} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} {217A3A01-70DC-4A0D-87C0-04D581B49183} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} + {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} + {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} {A3D9C10B-53A3-483C-8D90-BE7C078B82DF} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} {A4B84F3E-9C18-4CF7-8CA8-9F4AA4A1634F} = {8B1F1ACE-FD0A-4083-8DE6-8148C541A2CA} {3F9C730B-665F-49A3-AB6D-C0A08E4F7CD1} = {8B1F1ACE-FD0A-4083-8DE6-8148C541A2CA} diff --git a/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln b/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln index 3dbbd1b7ec7be..7c5defbd1b681 100644 --- a/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln +++ b/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{876CACCE-AD74-4548-ACD6-63F4B3E5D11C}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks.Extensions", "ref\System.Threading.Tasks.Extensions.csproj", "{8E73F6BD-A0A2-4C98-B4E3-42391B135943}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks.Extensions", "src\System.Threading.Tasks.Extensions.csproj", "{F67BB87D-2927-4BD4-B21B-5A403B6A2209}" @@ -104,6 +108,42 @@ Global {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}.Checked|x64.Build.0 = Debug|Any CPU {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}.Checked|x86.ActiveCfg = Debug|Any CPU {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}.Checked|x86.Build.0 = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x64.ActiveCfg = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x64.Build.0 = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x86.ActiveCfg = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x86.Build.0 = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|Any CPU.Build.0 = Release|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x64.ActiveCfg = Release|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x64.Build.0 = Release|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x86.ActiveCfg = Release|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x86.Build.0 = Release|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|Any CPU.Build.0 = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x64.ActiveCfg = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x64.Build.0 = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x86.ActiveCfg = Debug|Any CPU + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x86.Build.0 = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x64.ActiveCfg = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x64.Build.0 = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x86.ActiveCfg = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x86.Build.0 = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|Any CPU.Build.0 = Release|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x64.ActiveCfg = Release|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x64.Build.0 = Release|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x86.ActiveCfg = Release|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x86.Build.0 = Release|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|Any CPU.Build.0 = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x64.ActiveCfg = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x64.Build.0 = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x86.ActiveCfg = Debug|Any CPU + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x86.Build.0 = Debug|Any CPU {8E73F6BD-A0A2-4C98-B4E3-42391B135943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E73F6BD-A0A2-4C98-B4E3-42391B135943}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E73F6BD-A0A2-4C98-B4E3-42391B135943}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -165,6 +205,8 @@ Global GlobalSection(NestedProjects) = preSolution {CB976362-9258-4E98-B8C3-FAE11BDF3AA0} = {17308AE0-6049-4A2A-831C-5EAB57005A53} {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A} = {17308AE0-6049-4A2A-831C-5EAB57005A53} + {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B} = {17308AE0-6049-4A2A-831C-5EAB57005A53} + {876CACCE-AD74-4548-ACD6-63F4B3E5D11C} = {17308AE0-6049-4A2A-831C-5EAB57005A53} {F67BB87D-2927-4BD4-B21B-5A403B6A2209} = {17308AE0-6049-4A2A-831C-5EAB57005A53} {FFB40D04-17A5-4F9B-BD47-994E5616ABD9} = {30ACA65A-DBD9-46CD-9DA4-D7894118EBF8} {AE779AC7-EC2C-42BE-8E59-A2716799E098} = {30ACA65A-DBD9-46CD-9DA4-D7894118EBF8} diff --git a/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln b/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln index dc6c664dd9c1a..003b4703e0bf7 100644 --- a/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln +++ b/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{28CBE2F1-B283-4708-A33B-93886453BA83}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks", "ref\System.Threading.Tasks.csproj", "{8C762956-7AB1-4806-9144-5E13771CB22B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks", "src\System.Threading.Tasks.csproj", "{53FBD913-F587-441B-951A-195F65041CF7}" @@ -104,6 +108,42 @@ Global {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}.Checked|x64.Build.0 = Debug|Any CPU {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}.Checked|x86.ActiveCfg = Debug|Any CPU {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}.Checked|x86.Build.0 = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x64.ActiveCfg = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x64.Build.0 = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x86.ActiveCfg = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x86.Build.0 = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|Any CPU.Build.0 = Release|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x64.ActiveCfg = Release|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x64.Build.0 = Release|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x86.ActiveCfg = Release|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x86.Build.0 = Release|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|Any CPU.Build.0 = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x64.ActiveCfg = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x64.Build.0 = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x86.ActiveCfg = Debug|Any CPU + {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x86.Build.0 = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x64.ActiveCfg = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x64.Build.0 = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x86.ActiveCfg = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x86.Build.0 = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|Any CPU.Build.0 = Release|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x64.ActiveCfg = Release|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x64.Build.0 = Release|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x86.ActiveCfg = Release|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x86.Build.0 = Release|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|Any CPU.Build.0 = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x64.ActiveCfg = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x64.Build.0 = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x86.ActiveCfg = Debug|Any CPU + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x86.Build.0 = Debug|Any CPU {8C762956-7AB1-4806-9144-5E13771CB22B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C762956-7AB1-4806-9144-5E13771CB22B}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C762956-7AB1-4806-9144-5E13771CB22B}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -165,6 +205,8 @@ Global GlobalSection(NestedProjects) = preSolution {2738C2DB-E488-4EA2-B981-ADB8C520DCA6} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} + {28CBE2F1-B283-4708-A33B-93886453BA83} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} + {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} {53FBD913-F587-441B-951A-195F65041CF7} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} {695A5828-6CFC-4BE1-AE4E-6EC9796B4FC7} = {6C2B5085-E5A0-4732-90D5-BA35E9702990} {A8372DA8-B1DD-41ED-AD2C-C74DD5EE51D8} = {6C2B5085-E5A0-4732-90D5-BA35E9702990} diff --git a/src/libraries/System.Threading.Thread/System.Threading.Thread.sln b/src/libraries/System.Threading.Thread/System.Threading.Thread.sln index b5005523caac6..86d432c3ef348 100644 --- a/src/libraries/System.Threading.Thread/System.Threading.Thread.sln +++ b/src/libraries/System.Threading.Thread/System.Threading.Thread.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{EFE01BA2-5A04-4E14-BB16-9C84285C364F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7D9E2C13-436B-47F8-B5DC-D24079FEF705}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{753AC0A1-7EA1-4AD5-923E-D693C1105957}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Thread", "ref\System.Threading.Thread.csproj", "{AD5C441F-05EA-452D-B3D2-514B304AA673}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Thread", "src\System.Threading.Thread.csproj", "{A73DCB15-F3DF-48CB-A4CA-62102E94122C}" @@ -110,6 +114,42 @@ Global {EFE01BA2-5A04-4E14-BB16-9C84285C364F}.Checked|x64.Build.0 = Debug|Any CPU {EFE01BA2-5A04-4E14-BB16-9C84285C364F}.Checked|x86.ActiveCfg = Debug|Any CPU {EFE01BA2-5A04-4E14-BB16-9C84285C364F}.Checked|x86.Build.0 = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x64.ActiveCfg = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x64.Build.0 = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x86.ActiveCfg = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x86.Build.0 = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|Any CPU.Build.0 = Release|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x64.ActiveCfg = Release|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x64.Build.0 = Release|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x86.ActiveCfg = Release|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x86.Build.0 = Release|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|Any CPU.Build.0 = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x64.ActiveCfg = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x64.Build.0 = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x86.ActiveCfg = Debug|Any CPU + {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x86.Build.0 = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|Any CPU.Build.0 = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x64.ActiveCfg = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x64.Build.0 = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x86.ActiveCfg = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x86.Build.0 = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|Any CPU.ActiveCfg = Release|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|Any CPU.Build.0 = Release|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x64.ActiveCfg = Release|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x64.Build.0 = Release|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x86.ActiveCfg = Release|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x86.Build.0 = Release|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|Any CPU.Build.0 = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x64.ActiveCfg = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x64.Build.0 = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x86.ActiveCfg = Debug|Any CPU + {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x86.Build.0 = Debug|Any CPU {AD5C441F-05EA-452D-B3D2-514B304AA673}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AD5C441F-05EA-452D-B3D2-514B304AA673}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD5C441F-05EA-452D-B3D2-514B304AA673}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -225,6 +265,8 @@ Global GlobalSection(NestedProjects) = preSolution {B811926D-CFBB-4C22-80D2-0CCD566D980C} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} {EFE01BA2-5A04-4E14-BB16-9C84285C364F} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} + {7D9E2C13-436B-47F8-B5DC-D24079FEF705} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} + {753AC0A1-7EA1-4AD5-923E-D693C1105957} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} {A73DCB15-F3DF-48CB-A4CA-62102E94122C} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} {BF6A7CA7-DDF9-44D4-AD00-D807765663F9} = {73AA6FCA-8FDC-41AA-8539-91562296190B} {12A6F314-B08D-417D-82EC-0D8799D7C1A2} = {73AA6FCA-8FDC-41AA-8539-91562296190B} diff --git a/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln b/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln index 7a260859fb61b..da2fbee36e7ae 100644 --- a/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln +++ b/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{3440C79D-9158-4D66-9018-5194272AAD4B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{63A5C88E-CB60-4936-A489-566659D82D40}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{91C694FA-B623-45E8-B999-89AF70151EFD}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.ThreadPool", "ref\System.Threading.ThreadPool.csproj", "{54134937-585D-48D5-AB60-79493BE2C9E7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.ThreadPool", "src\System.Threading.ThreadPool.csproj", "{53A0D29E-8633-4FF8-AB0E-86EF331DD379}" @@ -104,6 +108,42 @@ Global {3440C79D-9158-4D66-9018-5194272AAD4B}.Checked|x64.Build.0 = Debug|Any CPU {3440C79D-9158-4D66-9018-5194272AAD4B}.Checked|x86.ActiveCfg = Debug|Any CPU {3440C79D-9158-4D66-9018-5194272AAD4B}.Checked|x86.Build.0 = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x64.ActiveCfg = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x64.Build.0 = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x86.ActiveCfg = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x86.Build.0 = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Release|Any CPU.Build.0 = Release|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x64.ActiveCfg = Release|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x64.Build.0 = Release|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x86.ActiveCfg = Release|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x86.Build.0 = Release|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|Any CPU.Build.0 = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x64.ActiveCfg = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x64.Build.0 = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x86.ActiveCfg = Debug|Any CPU + {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x86.Build.0 = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x64.ActiveCfg = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x64.Build.0 = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x86.ActiveCfg = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x86.Build.0 = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|Any CPU.Build.0 = Release|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x64.ActiveCfg = Release|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x64.Build.0 = Release|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x86.ActiveCfg = Release|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x86.Build.0 = Release|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|Any CPU.Build.0 = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x64.ActiveCfg = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x64.Build.0 = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x86.ActiveCfg = Debug|Any CPU + {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x86.Build.0 = Debug|Any CPU {54134937-585D-48D5-AB60-79493BE2C9E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {54134937-585D-48D5-AB60-79493BE2C9E7}.Debug|Any CPU.Build.0 = Debug|Any CPU {54134937-585D-48D5-AB60-79493BE2C9E7}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -165,6 +205,8 @@ Global GlobalSection(NestedProjects) = preSolution {BEACD8A1-3C09-450E-931F-561D44986BFB} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} {3440C79D-9158-4D66-9018-5194272AAD4B} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} + {63A5C88E-CB60-4936-A489-566659D82D40} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} + {91C694FA-B623-45E8-B999-89AF70151EFD} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} {53A0D29E-8633-4FF8-AB0E-86EF331DD379} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} {CD477FC8-AF27-46A2-A451-4A2D4C11600D} = {DB513386-C3B1-4891-92E1-1BE5D38562DC} {71ACA28C-A4F1-4A07-A1B3-39DB86C11A75} = {DB513386-C3B1-4891-92E1-1BE5D38562DC} diff --git a/src/libraries/System.Threading.Timer/System.Threading.Timer.sln b/src/libraries/System.Threading.Timer/System.Threading.Timer.sln index 4e4db9b810199..e64614e9f9438 100644 --- a/src/libraries/System.Threading.Timer/System.Threading.Timer.sln +++ b/src/libraries/System.Threading.Timer/System.Threading.Timer.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{98FBF74D-9544-4B64-B126-49FA876D62EC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{62835A52-BF00-471E-BF1D-D62EA1A27084}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{29EE1BE7-1976-49F3-9047-DD989D5040A5}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Timer", "ref\System.Threading.Timer.csproj", "{CF3D7FED-A927-4611-891F-AB3516B71D44}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Timer", "src\System.Threading.Timer.csproj", "{2B942D1B-20DE-427E-9D46-F1C513C7FFF5}" @@ -104,6 +108,42 @@ Global {98FBF74D-9544-4B64-B126-49FA876D62EC}.Checked|x64.Build.0 = Debug|Any CPU {98FBF74D-9544-4B64-B126-49FA876D62EC}.Checked|x86.ActiveCfg = Debug|Any CPU {98FBF74D-9544-4B64-B126-49FA876D62EC}.Checked|x86.Build.0 = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|Any CPU.Build.0 = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x64.ActiveCfg = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x64.Build.0 = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x86.ActiveCfg = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x86.Build.0 = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|Any CPU.ActiveCfg = Release|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|Any CPU.Build.0 = Release|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x64.ActiveCfg = Release|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x64.Build.0 = Release|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x86.ActiveCfg = Release|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x86.Build.0 = Release|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|Any CPU.Build.0 = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x64.ActiveCfg = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x64.Build.0 = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x86.ActiveCfg = Debug|Any CPU + {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x86.Build.0 = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x64.ActiveCfg = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x64.Build.0 = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x86.ActiveCfg = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x86.Build.0 = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|Any CPU.Build.0 = Release|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x64.ActiveCfg = Release|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x64.Build.0 = Release|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x86.ActiveCfg = Release|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x86.Build.0 = Release|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|Any CPU.Build.0 = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x64.ActiveCfg = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x64.Build.0 = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x86.ActiveCfg = Debug|Any CPU + {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x86.Build.0 = Debug|Any CPU {CF3D7FED-A927-4611-891F-AB3516B71D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CF3D7FED-A927-4611-891F-AB3516B71D44}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF3D7FED-A927-4611-891F-AB3516B71D44}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -165,6 +205,8 @@ Global GlobalSection(NestedProjects) = preSolution {74D4C464-F319-4A9D-8F09-C50FDBA1547A} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} {98FBF74D-9544-4B64-B126-49FA876D62EC} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} + {62835A52-BF00-471E-BF1D-D62EA1A27084} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} + {29EE1BE7-1976-49F3-9047-DD989D5040A5} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} {2B942D1B-20DE-427E-9D46-F1C513C7FFF5} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} {567E9CC8-5751-4786-BCC6-C2A6C38044DF} = {0149D5FD-7BFC-4421-8B5E-74FD45D9B3D7} {DAB761D6-EDD5-4F57-9BDE-E26589057403} = {0149D5FD-7BFC-4421-8B5E-74FD45D9B3D7} diff --git a/src/libraries/System.Threading/System.Threading.sln b/src/libraries/System.Threading/System.Threading.sln index 9c476c03dd1c6..55549b4f4f43b 100644 --- a/src/libraries/System.Threading/System.Threading.sln +++ b/src/libraries/System.Threading/System.Threading.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2CE21C30-5734-42DA-BB23-E72AD4F15F3F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{0BA360C6-6E32-4E77-A233-F48DE135B7E7}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "ref\System.Threading.csproj", "{0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "src\System.Threading.csproj", "{F4D0710C-6A53-44F9-A28B-63F008FEF808}" @@ -104,6 +108,42 @@ Global {2CE21C30-5734-42DA-BB23-E72AD4F15F3F}.Checked|x64.Build.0 = Debug|Any CPU {2CE21C30-5734-42DA-BB23-E72AD4F15F3F}.Checked|x86.ActiveCfg = Debug|Any CPU {2CE21C30-5734-42DA-BB23-E72AD4F15F3F}.Checked|x86.Build.0 = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x64.ActiveCfg = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x64.Build.0 = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x86.ActiveCfg = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x86.Build.0 = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|Any CPU.Build.0 = Release|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x64.ActiveCfg = Release|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x64.Build.0 = Release|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x86.ActiveCfg = Release|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x86.Build.0 = Release|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|Any CPU.Build.0 = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x64.ActiveCfg = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x64.Build.0 = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x86.ActiveCfg = Debug|Any CPU + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x86.Build.0 = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x64.ActiveCfg = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x64.Build.0 = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x86.ActiveCfg = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x86.Build.0 = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|Any CPU.Build.0 = Release|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x64.ActiveCfg = Release|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x64.Build.0 = Release|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x86.ActiveCfg = Release|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x86.Build.0 = Release|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|Any CPU.Build.0 = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x64.ActiveCfg = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x64.Build.0 = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x86.ActiveCfg = Debug|Any CPU + {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x86.Build.0 = Debug|Any CPU {0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}.Debug|Any CPU.Build.0 = Debug|Any CPU {0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -165,6 +205,8 @@ Global GlobalSection(NestedProjects) = preSolution {1F14F4DD-AE65-407B-9E10-F5786A847AD6} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} {2CE21C30-5734-42DA-BB23-E72AD4F15F3F} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} + {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} + {0BA360C6-6E32-4E77-A233-F48DE135B7E7} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} {F4D0710C-6A53-44F9-A28B-63F008FEF808} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} {387778C0-0405-4FE2-9D85-034254EAAD46} = {CCC80DF2-8B4E-497C-84A9-4E6344294566} {3DD929D8-346F-4CF3-B157-22E052F73A91} = {CCC80DF2-8B4E-497C-84A9-4E6344294566} diff --git a/src/libraries/System.Windows.Extensions/NuGet.config b/src/libraries/System.Windows.Extensions/NuGet.config deleted file mode 100644 index a66b7f9b01324..0000000000000 --- a/src/libraries/System.Windows.Extensions/NuGet.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln b/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln index 04e468f58e8ce..a6aaa33b6b948 100644 --- a/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln +++ b/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln @@ -1,6 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{4886A8C5-3546-459A-8800-ED0DA91C6B15}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{93D62540-9A64-4B14-B3FA-4A88307130E3}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.ReaderWriter", "ref\System.Xml.ReaderWriter.csproj", "{2FE5F437-4CE1-4A27-8547-B950F8043D89}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.ReaderWriter", "src\System.Xml.ReaderWriter.csproj", "{FA7C251C-D1FD-45C3-8CC8-D094F70A03AA}" @@ -19,6 +23,14 @@ Global {4886A8C5-3546-459A-8800-ED0DA91C6B15}.Debug|Any CPU.Build.0 = Debug|Any CPU {4886A8C5-3546-459A-8800-ED0DA91C6B15}.Release|Any CPU.ActiveCfg = Release|Any CPU {4886A8C5-3546-459A-8800-ED0DA91C6B15}.Release|Any CPU.Build.0 = Release|Any CPU + {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Release|Any CPU.Build.0 = Release|Any CPU + {93D62540-9A64-4B14-B3FA-4A88307130E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93D62540-9A64-4B14-B3FA-4A88307130E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93D62540-9A64-4B14-B3FA-4A88307130E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93D62540-9A64-4B14-B3FA-4A88307130E3}.Release|Any CPU.Build.0 = Release|Any CPU {2FE5F437-4CE1-4A27-8547-B950F8043D89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2FE5F437-4CE1-4A27-8547-B950F8043D89}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FE5F437-4CE1-4A27-8547-B950F8043D89}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -33,6 +45,8 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {4886A8C5-3546-459A-8800-ED0DA91C6B15} = {311C66CC-47AC-4965-B704-3C62E57FE29D} + {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC} = {311C66CC-47AC-4965-B704-3C62E57FE29D} + {93D62540-9A64-4B14-B3FA-4A88307130E3} = {311C66CC-47AC-4965-B704-3C62E57FE29D} {FA7C251C-D1FD-45C3-8CC8-D094F70A03AA} = {311C66CC-47AC-4965-B704-3C62E57FE29D} {2FE5F437-4CE1-4A27-8547-B950F8043D89} = {6AA53AA1-786A-4B35-B1C5-9D3B2EC10CF1} EndGlobalSection diff --git a/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln b/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln index 29b6090e241f9..42645d4497020 100644 --- a/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln +++ b/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln @@ -3,6 +3,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml.Linq", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{CE19D781-5542-4024-9829-FE589BA93146}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{86DDDD49-B840-4945-AA41-F9BBD157A27B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{FAB1AAB6-8352-4FFB-9543-F9F89067222D}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XDocument", "ref\System.Xml.XDocument.csproj", "{1516AD95-61E7-40F6-A9A8-59A6E8A0467A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XDocument", "src\System.Xml.XDocument.csproj", "{B229C42C-204A-43B4-AB71-587AD46F927E}" @@ -25,6 +29,14 @@ Global {CE19D781-5542-4024-9829-FE589BA93146}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE19D781-5542-4024-9829-FE589BA93146}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE19D781-5542-4024-9829-FE589BA93146}.Release|Any CPU.Build.0 = Release|Any CPU + {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Release|Any CPU.Build.0 = Release|Any CPU + {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Release|Any CPU.Build.0 = Release|Any CPU {1516AD95-61E7-40F6-A9A8-59A6E8A0467A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1516AD95-61E7-40F6-A9A8-59A6E8A0467A}.Debug|Any CPU.Build.0 = Debug|Any CPU {1516AD95-61E7-40F6-A9A8-59A6E8A0467A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -40,6 +52,8 @@ Global GlobalSection(NestedProjects) = preSolution {09DBC219-3DE1-40E1-ABD2-CD972410F03E} = {AFC9144B-DAD7-470E-B068-C17C24862D23} {CE19D781-5542-4024-9829-FE589BA93146} = {AFC9144B-DAD7-470E-B068-C17C24862D23} + {86DDDD49-B840-4945-AA41-F9BBD157A27B} = {AFC9144B-DAD7-470E-B068-C17C24862D23} + {FAB1AAB6-8352-4FFB-9543-F9F89067222D} = {AFC9144B-DAD7-470E-B068-C17C24862D23} {B229C42C-204A-43B4-AB71-587AD46F927E} = {AFC9144B-DAD7-470E-B068-C17C24862D23} {1516AD95-61E7-40F6-A9A8-59A6E8A0467A} = {8F3CD562-EA5E-4DD1-8B30-E6BA65887115} EndGlobalSection diff --git a/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln b/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln index b8bfe51567d23..24863d2cc3314 100644 --- a/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln +++ b/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln @@ -3,6 +3,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml.Linq", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{C1BE1D97-D078-4882-A772-C3CA11FD1F73}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{75961C7B-0125-41F4-98DF-5149EC1EB666}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath.XDocument", "ref\System.Xml.XPath.XDocument.csproj", "{E0E5B798-30CC-4D39-B164-C009141E2ABC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath.XDocument", "src\System.Xml.XPath.XDocument.csproj", "{D52C68D2-B6DD-4FFB-B3B5-011B76733202}" @@ -25,6 +29,14 @@ Global {C1BE1D97-D078-4882-A772-C3CA11FD1F73}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1BE1D97-D078-4882-A772-C3CA11FD1F73}.Release|Any CPU.ActiveCfg = Release|Any CPU {C1BE1D97-D078-4882-A772-C3CA11FD1F73}.Release|Any CPU.Build.0 = Release|Any CPU + {75961C7B-0125-41F4-98DF-5149EC1EB666}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75961C7B-0125-41F4-98DF-5149EC1EB666}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75961C7B-0125-41F4-98DF-5149EC1EB666}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75961C7B-0125-41F4-98DF-5149EC1EB666}.Release|Any CPU.Build.0 = Release|Any CPU + {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Release|Any CPU.Build.0 = Release|Any CPU {E0E5B798-30CC-4D39-B164-C009141E2ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E0E5B798-30CC-4D39-B164-C009141E2ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0E5B798-30CC-4D39-B164-C009141E2ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -40,6 +52,8 @@ Global GlobalSection(NestedProjects) = preSolution {A03326C2-C437-44C6-91C5-07AA8F24D51C} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} {C1BE1D97-D078-4882-A772-C3CA11FD1F73} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} + {75961C7B-0125-41F4-98DF-5149EC1EB666} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} + {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} {D52C68D2-B6DD-4FFB-B3B5-011B76733202} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} {E0E5B798-30CC-4D39-B164-C009141E2ABC} = {47B3DDCB-3A95-4315-9D49-A2653C6F3A17} EndGlobalSection diff --git a/src/libraries/System.Xml.XPath/System.Xml.XPath.sln b/src/libraries/System.Xml.XPath/System.Xml.XPath.sln index 951c5d774dac9..a052d56115a15 100644 --- a/src/libraries/System.Xml.XPath/System.Xml.XPath.sln +++ b/src/libraries/System.Xml.XPath/System.Xml.XPath.sln @@ -1,6 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{B7D48F78-4580-4398-A93F-FD02A15AD0BD}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{846BD820-3A18-4D7B-9E50-641608AAA3D5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath", "ref\System.Xml.XPath.csproj", "{38040AE0-59E4-46CE-861D-A33A383BB0FC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath", "src\System.Xml.XPath.csproj", "{F825C114-FF6D-4826-BC8A-586246369695}" @@ -19,6 +23,14 @@ Global {B7D48F78-4580-4398-A93F-FD02A15AD0BD}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7D48F78-4580-4398-A93F-FD02A15AD0BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7D48F78-4580-4398-A93F-FD02A15AD0BD}.Release|Any CPU.Build.0 = Release|Any CPU + {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Release|Any CPU.Build.0 = Release|Any CPU + {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Release|Any CPU.Build.0 = Release|Any CPU {38040AE0-59E4-46CE-861D-A33A383BB0FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {38040AE0-59E4-46CE-861D-A33A383BB0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {38040AE0-59E4-46CE-861D-A33A383BB0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -33,6 +45,8 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {B7D48F78-4580-4398-A93F-FD02A15AD0BD} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} + {846BD820-3A18-4D7B-9E50-641608AAA3D5} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} + {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} {F825C114-FF6D-4826-BC8A-586246369695} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} {38040AE0-59E4-46CE-861D-A33A383BB0FC} = {1EF0B525-2611-41AB-AA69-28A1B9689C3A} EndGlobalSection diff --git a/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln b/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln index 47755aa6bab67..9d6374c17845c 100644 --- a/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln +++ b/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln @@ -1,6 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{733E5502-5F1A-4ECC-8C44-0E057B11437D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{AA26E41D-F396-451F-8978-6FF3DAC927D8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5D76923D-117E-4D99-9740-C3D8AABF2C52}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlDocument", "ref\System.Xml.XmlDocument.csproj", "{9FA44EA8-BEDA-412E-A366-9334FDBA77A9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlDocument", "src\System.Xml.XmlDocument.csproj", "{8656FF2F-1024-4D56-B38C-F99BE27B732D}" @@ -19,6 +23,14 @@ Global {733E5502-5F1A-4ECC-8C44-0E057B11437D}.Debug|Any CPU.Build.0 = Debug|Any CPU {733E5502-5F1A-4ECC-8C44-0E057B11437D}.Release|Any CPU.ActiveCfg = Release|Any CPU {733E5502-5F1A-4ECC-8C44-0E057B11437D}.Release|Any CPU.Build.0 = Release|Any CPU + {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Release|Any CPU.Build.0 = Release|Any CPU + {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Release|Any CPU.Build.0 = Release|Any CPU {9FA44EA8-BEDA-412E-A366-9334FDBA77A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FA44EA8-BEDA-412E-A366-9334FDBA77A9}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FA44EA8-BEDA-412E-A366-9334FDBA77A9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -33,6 +45,8 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {733E5502-5F1A-4ECC-8C44-0E057B11437D} = {9EB72201-88D9-48A5-858D-82F01B2382B6} + {AA26E41D-F396-451F-8978-6FF3DAC927D8} = {9EB72201-88D9-48A5-858D-82F01B2382B6} + {5D76923D-117E-4D99-9740-C3D8AABF2C52} = {9EB72201-88D9-48A5-858D-82F01B2382B6} {8656FF2F-1024-4D56-B38C-F99BE27B732D} = {9EB72201-88D9-48A5-858D-82F01B2382B6} {9FA44EA8-BEDA-412E-A366-9334FDBA77A9} = {A6E661CC-CFD6-4866-BE5B-59ECB823DC70} EndGlobalSection diff --git a/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln b/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln index 3dd3461444214..f708893988b2e 100644 --- a/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln +++ b/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln @@ -1,6 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{EF514C0C-ECA7-419A-BDED-A6735FEA16F9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{71929DBB-35DB-457C-8B52-5CEA1ED83C2C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9143576D-B7B4-4289-9169-23832CB3E67C}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlSerializer", "ref\System.Xml.XmlSerializer.csproj", "{A463D0F1-1814-4276-B7A9-59780C755D0A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlSerializer", "src\System.Xml.XmlSerializer.csproj", "{67D79968-DF22-4273-B2FA-D3EEC905095C}" @@ -19,6 +23,14 @@ Global {EF514C0C-ECA7-419A-BDED-A6735FEA16F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF514C0C-ECA7-419A-BDED-A6735FEA16F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF514C0C-ECA7-419A-BDED-A6735FEA16F9}.Release|Any CPU.Build.0 = Release|Any CPU + {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Release|Any CPU.Build.0 = Release|Any CPU + {9143576D-B7B4-4289-9169-23832CB3E67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9143576D-B7B4-4289-9169-23832CB3E67C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9143576D-B7B4-4289-9169-23832CB3E67C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9143576D-B7B4-4289-9169-23832CB3E67C}.Release|Any CPU.Build.0 = Release|Any CPU {A463D0F1-1814-4276-B7A9-59780C755D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A463D0F1-1814-4276-B7A9-59780C755D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {A463D0F1-1814-4276-B7A9-59780C755D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -33,6 +45,8 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {EF514C0C-ECA7-419A-BDED-A6735FEA16F9} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} + {71929DBB-35DB-457C-8B52-5CEA1ED83C2C} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} + {9143576D-B7B4-4289-9169-23832CB3E67C} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} {67D79968-DF22-4273-B2FA-D3EEC905095C} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} {A463D0F1-1814-4276-B7A9-59780C755D0A} = {E0C34B2E-D8CC-4A13-9635-3FD9AF37EC9B} EndGlobalSection From 06b45925513ffd034cad3a8686df86b14d1e6682 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 24 Sep 2021 13:52:55 -0700 Subject: [PATCH 146/161] Remove target framework in the call to DllImportGenerator.csproj. This fixes an issue where a project that targets net7.0-windows accidentally ends up getting an output path pointing to the wrong directory for Microsoft.Interop.SourceGeneration.dll, which causes us to hit https://github.com/dotnet/roslyn/issues/56442. --- eng/generators.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/generators.targets b/eng/generators.targets index f81418273a34e..45f5cb6c4bac1 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -59,7 +59,8 @@ $(DefineConstants);DLLIMPORTGENERATOR_INTERNALUNSAFE - + From 7c87cc1aa5b16237e5924189de707f41a3d205b8 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 24 Sep 2021 14:21:57 -0700 Subject: [PATCH 147/161] Add license banner to source. (#59586) --- .../Common/tests/TestUtilities/System/LineEndingsHelper.cs | 3 +++ .../DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs | 5 ++++- .../Analyzers/ConvertToGeneratedDllImportAnalyzer.cs | 3 +++ .../Analyzers/ConvertToGeneratedDllImportFixer.cs | 3 +++ .../Analyzers/GeneratedDllImportAnalyzer.cs | 3 +++ .../Analyzers/ManualTypeMarshallingAnalyzer.cs | 3 +++ .../gen/DllImportGenerator/Comparers.cs | 5 ++++- .../gen/DllImportGenerator/Diagnostics/Events.cs | 5 ++++- .../gen/DllImportGenerator/DllImportGenerator.cs | 3 +++ .../gen/DllImportGenerator/DllImportGeneratorOptions.cs | 3 +++ .../gen/DllImportGenerator/DllImportStubContext.cs | 5 ++++- .../ForwarderMarshallingGeneratorFactory.cs | 5 ++++- .../gen/DllImportGenerator/GeneratedDllImportData.cs | 5 ++++- .../gen/DllImportGenerator/GeneratorDiagnostics.cs | 5 ++++- .../gen/DllImportGenerator/LanguageSupport.cs | 7 ++++--- .../NoPreserveSigMarshallingGeneratorFactory.cs | 5 ++++- .../gen/DllImportGenerator/PInvokeStubCodeGenerator.cs | 5 ++++- .../gen/DllImportGenerator/UnreachableException.cs | 5 ++++- .../ContiguousCollectionElementMarshallingCodeContext.cs | 3 +++ .../IGeneratorDiagnostics.cs | 5 ++++- .../InteropGenerationOptions.cs | 5 ++++- .../Microsoft.Interop.SourceGeneration/LanguageSupport.cs | 7 ++++--- .../Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs | 5 ++++- .../ManualTypeMarshallingHelper.cs | 4 +++- .../Marshalling/ArrayMarshaller.cs | 5 ++++- .../AttributedMarshallingModelGeneratorFactory.cs | 5 ++++- .../Marshalling/BlittableMarshaller.cs | 5 ++++- .../Marshalling/BoolMarshaller.cs | 5 ++++- .../Marshalling/ByValueContentsMarshalKindValidator.cs | 5 ++++- .../Marshalling/CharMarshaller.cs | 5 ++++- .../ConditionalStackallocMarshallingGenerator.cs | 5 ++++- .../Marshalling/CustomNativeTypeMarshallingGenerator.cs | 5 ++++- .../Marshalling/DelegateMarshaller.cs | 5 ++++- .../Marshalling/Forwarder.cs | 5 ++++- .../Marshalling/HResultExceptionMarshaller.cs | 5 ++++- .../Marshalling/ICustomNativeTypeMarshallingStrategy.cs | 5 ++++- .../Marshalling/MarshallerHelpers.cs | 5 ++++- .../Marshalling/MarshallingGenerator.cs | 5 ++++- .../Marshalling/MarshallingGeneratorFactory.cs | 5 ++++- .../Marshalling/PinnableManagedValueMarshaller.cs | 5 ++++- .../Marshalling/SafeHandleMarshaller.cs | 5 ++++- .../Marshalling/StringMarshaller.Ansi.cs | 5 ++++- .../Marshalling/StringMarshaller.PlatformDefined.cs | 5 ++++- .../Marshalling/StringMarshaller.Utf16.cs | 5 ++++- .../Marshalling/StringMarshaller.Utf8.cs | 5 ++++- .../MarshallingAttributeInfo.cs | 3 +++ .../Microsoft.Interop.SourceGeneration/StubCodeContext.cs | 5 ++++- .../gen/Microsoft.Interop.SourceGeneration/TypeNames.cs | 5 ++++- .../Microsoft.Interop.SourceGeneration/TypePositionInfo.cs | 5 ++++- .../TypeSymbolExtensions.cs | 3 +++ .../tests/Ancillary.Interop/MarshalEx.cs | 2 ++ .../tests/Ancillary.Interop/SpanMarshallers.cs | 4 +++- .../tests/DllImportGenerator.Tests/ArrayTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/BlittableStructTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/BooleanTests.cs | 5 ++++- .../DllImportGenerator.Tests/CallingConventionTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/CharacterTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/CollectionTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/Constants.cs | 5 ++++- .../DllImportGenerator.Tests/CustomMarshallingTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/DelegateTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/EnumTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/FunctionPointerTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/PointerTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/PreserveSigTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/SafeHandleTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/SetLastErrorTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/SpanTests.cs | 5 ++++- .../tests/DllImportGenerator.Tests/StringTests.cs | 5 ++++- .../AdditionalAttributesOnStub.cs | 5 ++++- .../DllImportGenerator.UnitTests/AttributeForwarding.cs | 5 ++++- .../tests/DllImportGenerator.UnitTests/CodeSnippets.cs | 5 ++++- .../tests/DllImportGenerator.UnitTests/CompileFails.cs | 5 ++++- .../tests/DllImportGenerator.UnitTests/Compiles.cs | 3 +++ .../ConvertToGeneratedDllImportAnalyzerTests.cs | 3 +++ .../ConvertToGeneratedDllImportFixerTests.cs | 5 ++++- .../tests/DllImportGenerator.UnitTests/Diagnostics.cs | 3 +++ .../DllImportGeneratorOptionsProvider.cs | 5 ++++- .../GeneratedDllImportAnalyzerTests.cs | 5 ++++- .../IncrementalGenerationTests.cs | 5 ++++- .../ManualTypeMarshallingAnalyzerTests.cs | 5 ++++- .../tests/DllImportGenerator.UnitTests/TestUtils.cs | 5 ++++- .../Verifiers/CSharpAnalyzerVerifier.cs | 4 +++- .../Verifiers/CSharpCodeFixVerifier.cs | 2 ++ .../Verifiers/CSharpVerifierHelper.cs | 5 ++++- .../tests/TestAssets/NativeExports/Arrays.cs | 5 ++++- .../tests/TestAssets/NativeExports/BlittableStructs.cs | 5 ++++- .../tests/TestAssets/NativeExports/Booleans.cs | 5 ++++- .../tests/TestAssets/NativeExports/CallingConventions.cs | 5 ++++- .../tests/TestAssets/NativeExports/Characters.cs | 5 ++++- .../tests/TestAssets/NativeExports/CustomMarshalling.cs | 5 ++++- .../NativeExports/DelegatesAndFunctionPointers.cs | 5 ++++- .../tests/TestAssets/NativeExports/Demo.cs | 5 ++++- .../tests/TestAssets/NativeExports/Error.cs | 5 ++++- .../tests/TestAssets/NativeExports/HResult.cs | 5 ++++- .../tests/TestAssets/NativeExports/Handles.cs | 5 ++++- .../tests/TestAssets/NativeExports/Numeric.cs | 5 ++++- .../tests/TestAssets/NativeExports/Strings.cs | 5 ++++- .../tests/TestAssets/SharedTypes/Blittable.cs | 5 ++++- .../tests/TestAssets/SharedTypes/DNNE.cs | 5 ++++- .../tests/TestAssets/SharedTypes/NonBlittable.cs | 3 +++ 101 files changed, 383 insertions(+), 89 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/LineEndingsHelper.cs b/src/libraries/Common/tests/TestUtilities/System/LineEndingsHelper.cs index 6aff6e9e4ad68..01fcc7794f748 100644 --- a/src/libraries/Common/tests/TestUtilities/System/LineEndingsHelper.cs +++ b/src/libraries/Common/tests/TestUtilities/System/LineEndingsHelper.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace System { public static class LineEndingsHelper diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs index dd6a675d56e69..4f4d7690fe05f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/AnalyzerDiagnostics.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; namespace Microsoft.Interop.Analyzers { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs index 398a26fa4a98f..da387be9aade7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System.Collections.Immutable; using System.Diagnostics; using System.Runtime.InteropServices; 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 509bb767da9c8..4e669942c6d12 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs @@ -1,3 +1,6 @@ +// 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.Collections.Immutable; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs index a0a0ceb3c67fd..c9a53d3ee19ff 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System.Collections.Immutable; using System.Linq; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 351a5e7a69019..73daa4fdd6402 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -1,3 +1,6 @@ +// 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.Immutable; using System.Linq; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs index e1ded7b4ab184..798ebe6185c9e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; using System.Collections.Generic; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs index ef78d0bc86b43..f1f34123af67a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs @@ -1,4 +1,7 @@ -using System; +// 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.Diagnostics.Tracing; namespace Microsoft.Interop.Diagnostics diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index de95cd752c296..c4410266c0fca 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs index d63f7c880b9c3..f99437e17e238 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using Microsoft.CodeAnalysis.Diagnostics; namespace Microsoft.Interop diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs index c3bfef462d522..e4fbe49c0fd4e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs @@ -1,4 +1,7 @@ -using System; +// 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.Collections.Immutable; using System.Linq; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs index 60c85b4baba0a..3b963d8f8a213 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs @@ -1,4 +1,7 @@ -using System; +// 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; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs index 9a4fc90a125bf..d3157782f488c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratedDllImportData.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using System.Text; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 77b018f4b880a..226beb9cf55dc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; using System.Collections.Generic; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs index ddf2c4203111c..4abeef8a7b1c3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs @@ -1,10 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + // Types defined to enable language support of various features // in the source generator. - - namespace System.Runtime.CompilerServices { // Define IsExternalInit type to support records. internal class IsExternalInit {} -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs index 1e8ae0159e454..8860fb0555eae 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using System; using System.Collections.Generic; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs index a7ecd31f8e453..b0514f7d83b84 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs @@ -1,4 +1,7 @@ -using System; +// 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.Collections.Immutable; using System.Diagnostics; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs index f33ae8b9564fd..ef9da5905e4b2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/UnreachableException.cs @@ -1,4 +1,7 @@ -using System; +// 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; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs index e0fac3b6427cd..01d8d2f45e921 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs @@ -1,3 +1,6 @@ +// 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.Diagnostics; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs index f02f7c28957ec..58375bd955ef6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs @@ -1,4 +1,7 @@ -using System; +// 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.Collections.Immutable; using System.Diagnostics; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs index fa4e46a3f3d31..cb3f7dbe62ddb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs @@ -1,4 +1,7 @@ -using System; +// 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; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs index ddf2c4203111c..4abeef8a7b1c3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs @@ -1,10 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + // Types defined to enable language support of various features // in the source generator. - - namespace System.Runtime.CompilerServices { // Define IsExternalInit type to support records. internal class IsExternalInit {} -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs index fe789e2e08865..2151a1a0dc447 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManagedTypeInfo.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs index 137f45f1040d5..f61eafe61aa1a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs @@ -1,3 +1,5 @@ +// 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.Linq; @@ -141,4 +143,4 @@ public static bool HasNativeValueStorageProperty(ITypeSymbol type, ITypeSymbol s && SymbolEqualityComparer.Default.Equals(p.Type, spanOfByte)); } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs index 53fc3655af912..bb7b26dabb256 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs index 1346356eee12f..277fbe6d6d31f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis.CSharp; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis.CSharp; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs index 8925ffc625553..a0af37cd1bac9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs index 7ceab5830c0df..74373f4e27047 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using System.Diagnostics; using Microsoft.CodeAnalysis; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs index dc9f64fde908f..909b261f886c3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs @@ -1,4 +1,7 @@ -using System; +// 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; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index ce3c97230ada2..03332e635b3b3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -1,4 +1,7 @@ -using System; +// 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.Diagnostics; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs index c2c0788b196fe..3504c526a43a9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System.Collections.Generic; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -242,4 +245,4 @@ protected virtual ExpressionSyntax GenerateNullCheckExpression( /// public abstract bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs index 1f81e5040cf6e..0859c4bf54d96 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs @@ -1,4 +1,7 @@ -using System; +// 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 Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs index c8854abb54bd5..da00e4c5bfa31 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs index 1f8f1c1756f21..fd924298201bd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using Microsoft.CodeAnalysis; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs index 349a651a9d5bc..6c875f569ee21 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs @@ -1,4 +1,7 @@ -using System; +// 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.Diagnostics; using System.Collections.Generic; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs index 6a11a61b46110..c9b47c8c45778 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -1,4 +1,7 @@ -using System; +// 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.Diagnostics; using System.Linq; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index b35e3c4816714..a17e625d2003d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -279,4 +282,4 @@ public static ExpressionSyntax FreeExpression(string nativeIdentifier) } } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs index e97191550f183..8b412a89e5d96 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs @@ -1,4 +1,7 @@ -using System; +// 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 Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs index 1efa6e495e576..adcd99143f39b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using Microsoft.CodeAnalysis; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs index d8e26f8d63348..1ba665ed1a3e2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs index 262de1be2d9bc..5cd7a22df4d20 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs index 97dd9328c8755..0ee3a62be733e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs @@ -1,4 +1,7 @@ -using System; +// 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 Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; 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 index 3de4c48a724bb..316dce2fb047e 100644 --- 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 @@ -1,4 +1,7 @@ -using System; +// 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; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs index 30e03da464b52..2b7331d89014f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs index c6ab3114565d6..6fdb99390090a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; 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 bbc2d7789145c..be5a1819b9943 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 @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using Microsoft.CodeAnalysis; using System; using System.Collections.Generic; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs index ab414c504269c..bea582b28cf5a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs @@ -1,4 +1,7 @@ -using System; +// 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; namespace Microsoft.Interop 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 8710e52abca51..de39a3f574a80 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,4 +1,7 @@ -using System; +// 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; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs index a7d730d08b081..5195372bc63c6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs @@ -1,4 +1,7 @@ -using System; +// 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 Microsoft.CodeAnalysis; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs index 8587c0780acc1..37eb22079edca 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs @@ -1,3 +1,6 @@ +// 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.Collections.Immutable; diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs index 4260b311ac02c..8bd0b2fd56488 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -1,3 +1,5 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; using System.Reflection; diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs index dccfa6a23ad58..453259feeda1b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs @@ -1,3 +1,5 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Runtime.CompilerServices; @@ -390,4 +392,4 @@ public void FreeNative() Marshal.FreeCoTaskMem((IntPtr)_allocatedMemory); } } -} \ No newline at end of file +} 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 9e885fb417786..fcdedc6ba004c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -1,4 +1,7 @@ -using SharedTypes; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using SharedTypes; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs index a6a32324495c5..5aa24bf1af91a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; using SharedTypes; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs index 40dbb9f1a653b..063174d3e3577 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using System.Runtime.InteropServices; using Xunit; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs index 6e8d702b8b575..161b94f8c39e9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CallingConventionTests.cs @@ -1,4 +1,7 @@ -using System; +// 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 System.Runtime.CompilerServices; 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 432f05f5482c9..3443a5df2bb19 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using System.Runtime.InteropServices; using Xunit; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs index 7effc5f3f9804..4a08b3f79d213 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CollectionTests.cs @@ -1,4 +1,7 @@ -using SharedTypes; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using SharedTypes; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs index 8c5a2812d08af..9ea08ea2fe8ae 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs @@ -1,7 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE); } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs index a52aae7029e80..134bf87256575 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using System.Text; using SharedTypes; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs index 72160892d97e3..01f86616972fb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; using Xunit; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs index d39b3805abc43..8002e260998d2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; using System.Runtime.InteropServices; using Xunit; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs index 9de487153f724..f083c24f4131f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs index 8a15c7ce36ef7..463ea434d3606 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; using SharedTypes; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs index 079f1d17bb9ba..ee1f351e66f9f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using Xunit; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs index fda3852b3d885..96c21224e9d95 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; @@ -98,4 +101,4 @@ public void ByRefDifferentValue_UsesNewHandleInstance() handle.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs index 6d6dca8cb8712..d6b3cac367c9c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using Xunit; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs index 53421dbc47d19..ad61c89cf0dcd 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SpanTests.cs @@ -1,4 +1,7 @@ -using SharedTypes; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using SharedTypes; using System; using System.Collections.Generic; using System.Linq; 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 cb2b9cb6853cb..db99bf81a8bc1 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using System.Text; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs index 0c0fe9a646b35..83872bdad7ec4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using System; using System.Collections.Generic; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs index 2c926a813035c..959a6402dda2f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; using System.Collections.Generic; 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 c35615cea115c..746646fd523b7 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CodeSnippets.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; namespace DllImportGenerator.UnitTests { 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 f121725e793fa..30895d04149d9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -1,4 +1,7 @@ -using System; +// 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 System.Runtime.InteropServices; 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 959e4005e30b6..a49ac3a06c515 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using Microsoft.CodeAnalysis; using System; using System.Collections.Generic; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs index 2f7b0efc79615..45cd06a401ccc 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs @@ -1,3 +1,6 @@ +// 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.Threading.Tasks; 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 fe4a101f2ee0f..5ac4063756c53 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs @@ -1,3 +1,6 @@ +// 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.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -364,4 +367,4 @@ await VerifyCS.VerifyCodeFixAsync( usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); } } -} \ No newline at end of file +} 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 8aa83bae201eb..df6da9008696a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs @@ -1,3 +1,6 @@ +// 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; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs index a774bd2ef353c..8459d2fd4425c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGeneratorOptionsProvider.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; @@ -68,4 +71,4 @@ public override bool TryGetValue(string key, [NotNullWhen(true)] out string? val public static AnalyzerConfigOptions Instance = new EmptyOptions(); } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs index 63c5497902e20..6aae75c8c5add 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System.Threading.Tasks; using Xunit; using static Microsoft.Interop.Analyzers.GeneratedDllImportAnalyzer; @@ -190,4 +193,4 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("Test")); } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs index 89269066b495e..75e5de8f546ed 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Text; using System; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index d82b84c9bb11b..dc8981b28c4fb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using System.Collections.Generic; @@ -1511,4 +1514,4 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(StackallocConstructorMustHaveStackBufferSizeConstantRule).WithLocation(0).WithArguments("Native")); } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index db7b0f3feccf8..41e52104f1643 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -1,4 +1,7 @@ -using Microsoft.CodeAnalysis; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs index bb0a07677ca23..bd54db652e4c2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpAnalyzerVerifier.cs @@ -1,3 +1,5 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. using System.Threading; using System.Threading.Tasks; @@ -40,4 +42,4 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes internal class Test : CSharpCodeFixVerifier.Test { } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs index 9074cc753c1af..136c88a9cd45d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs @@ -1,3 +1,5 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Immutable; using System.Linq; diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs index ab02eaae0452c..e55e91ea57f5d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpVerifierHelper.cs @@ -1,3 +1,6 @@ +// 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.Immutable; using Microsoft.CodeAnalysis; @@ -23,4 +26,4 @@ private static ImmutableDictionary GetNullableWarnings return commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs index 0357b593a2356..3e11f6c91298e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Arrays.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using SharedTypes; using System; using System.Collections.Generic; @@ -210,4 +213,4 @@ public static byte AndAllMembers([DNNE.C99Type("struct bool_struct*")] BoolStruc return res; } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs index 9bb1d2cc132ff..f9dbaf9b7e015 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/BlittableStructs.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; using SharedTypes; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs index ac729a1288217..20df4b754cdb3 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Booleans.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; namespace NativeExports { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs index 525dfe991c975..0b97aaae45ea7 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CallingConventions.cs @@ -1,4 +1,7 @@ -using System; +// 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 System.Runtime.CompilerServices; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs index 768b276b43e23..95c666eca4f60 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; namespace NativeExports { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs index 539b8d45b8c26..2da06a7540871 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/CustomMarshalling.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; using SharedTypes; diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs index 16fc451c9de89..50abe95c3a381 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; namespace NativeExports diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Demo.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Demo.cs index 6e82b412b6b72..42d55bc5ee9a2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Demo.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Demo.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; namespace NativeExports { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs index 8963c8138712d..add53a9f9f4ba 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Error.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; namespace NativeExports diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs index f960887e747f5..891dbade60b40 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/HResult.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; namespace NativeExports diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs index 4ab5b0b8445e7..76664b8820879 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Handles.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System.Collections.Generic; using System.Runtime.InteropServices; @@ -80,4 +83,4 @@ private static bool ReleaseHandleCore(nint handle) } } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs index 2fde4b3ac0a21..b6cff4680b93e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Numeric.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; namespace NativeExports { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs index 44458182ce311..acb72da759ce5 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Strings.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; namespace NativeExports diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs index cdc00dfd0d33e..dec9f74ab4923 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/Blittable.cs @@ -1,4 +1,7 @@ -using System; +// 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.Runtime.InteropServices; namespace SharedTypes diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs index 85f4a6e527285..0b3dd369433a9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/DNNE.cs @@ -1,4 +1,7 @@ -namespace DNNE +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace DNNE { public class C99DeclCodeAttribute : System.Attribute { diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs index 35275afa0916d..5d46f83e845ed 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/NonBlittable.cs @@ -1,3 +1,6 @@ +// 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.Diagnostics; From 3f78928969b37c3bb5b8b7b8592ddb726cce822a Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 27 Sep 2021 17:40:23 -0700 Subject: [PATCH 148/161] Enable running analyzers on DllImportGenerator and Microsoft.Interop.SourceGeneration (#59683) --- Directory.Build.targets | 2 +- .../ConvertToGeneratedDllImportAnalyzer.cs | 2 +- .../ConvertToGeneratedDllImportFixer.cs | 2 +- .../Analyzers/GeneratedDllImportAnalyzer.cs | 6 ++-- .../ManualTypeMarshallingAnalyzer.cs | 36 +++++++++---------- .../gen/DllImportGenerator/Comparers.cs | 4 +-- .../DllImportGenerator/DllImportGenerator.cs | 12 ++++--- .../DllImportGenerator.csproj | 1 + .../DllImportGeneratorOptions.cs | 2 +- .../DllImportStubContext.cs | 4 +-- .../ForwarderMarshallingGeneratorFactory.cs | 2 +- .../GeneratorDiagnostics.cs | 20 +++++------ ...oPreserveSigMarshallingGeneratorFactory.cs | 2 +- .../PInvokeStubCodeGenerator.cs | 2 +- .../ManualTypeMarshallingHelper.cs | 2 +- .../Marshalling/ArrayMarshaller.cs | 2 +- .../Marshalling/BlittableMarshaller.cs | 3 +- .../Marshalling/BoolMarshaller.cs | 2 +- .../Marshalling/CharMarshaller.cs | 2 +- ...nditionalStackallocMarshallingGenerator.cs | 6 ++-- .../Marshalling/DelegateMarshaller.cs | 2 +- .../Marshalling/Forwarder.cs | 4 +-- .../Marshalling/HResultExceptionMarshaller.cs | 2 +- .../ICustomNativeTypeMarshallingStrategy.cs | 8 ++--- .../Marshalling/MarshallerHelpers.cs | 4 +-- .../MarshallingGeneratorFactory.cs | 4 +-- .../Marshalling/SafeHandleMarshaller.cs | 10 +++--- .../Marshalling/StringMarshaller.Ansi.cs | 2 +- .../StringMarshaller.PlatformDefined.cs | 8 ++--- .../Marshalling/StringMarshaller.Utf16.cs | 14 ++++---- .../Marshalling/StringMarshaller.Utf8.cs | 4 +-- .../MarshallingAttributeInfo.cs | 8 ++--- .../Microsoft.Interop.SourceGeneration.csproj | 1 + .../Properties/AssemblyInfo.cs | 4 +++ .../StubCodeContext.cs | 2 +- .../TypeNames.cs | 2 +- 36 files changed, 100 insertions(+), 93 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Properties/AssemblyInfo.cs diff --git a/Directory.Build.targets b/Directory.Build.targets index 6400a9069ded5..f59955242b29f 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -18,7 +18,7 @@ unconditionally in Microsoft.NETCoreSdk.BundledVersions.props. --> $(MajorVersion).$(MinorVersion) - false + $(RunAnalyzers) Microsoft%AE .NET diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs index da387be9aade7..2f9614d888b7c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs @@ -17,7 +17,7 @@ public class ConvertToGeneratedDllImportAnalyzer : DiagnosticAnalyzer { private const string Category = "Interoperability"; - public readonly static DiagnosticDescriptor ConvertToGeneratedDllImport = + public static readonly DiagnosticDescriptor ConvertToGeneratedDllImport = new DiagnosticDescriptor( Ids.ConvertToGeneratedDllImport, GetResourceString(nameof(Resources.ConvertToGeneratedDllImportTitle)), 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 4e669942c6d12..e29fae5f12beb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs @@ -276,7 +276,7 @@ private bool TryCreateUnmanagedCallConvAttributeToEmit( generator.AttributeArgument("CallConvs", generator.ArrayCreationExpression( generator.TypeExpression(editor.SemanticModel.Compilation.GetTypeByMetadataName(TypeNames.System_Type)), - new [] { generator.TypeOfExpression(generator.TypeExpression(callingConventionType)) }))); + new[] { generator.TypeOfExpression(generator.TypeExpression(callingConventionType)) }))); return true; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs index c9a53d3ee19ff..9854b5120084f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs @@ -17,8 +17,8 @@ namespace Microsoft.Interop.Analyzers public class GeneratedDllImportAnalyzer : DiagnosticAnalyzer { private const string Category = "Usage"; - - public readonly static DiagnosticDescriptor GeneratedDllImportMissingModifiers = + + public static readonly DiagnosticDescriptor GeneratedDllImportMissingModifiers = new DiagnosticDescriptor( Ids.GeneratedDllImportMissingRequiredModifiers, GetResourceString(nameof(Resources.GeneratedDllImportMissingModifiersTitle)), @@ -28,7 +28,7 @@ public class GeneratedDllImportAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.GeneratedDllImportMissingModifiersDescription))); - public readonly static DiagnosticDescriptor GeneratedDllImportContainingTypeMissingModifiers = + public static readonly DiagnosticDescriptor GeneratedDllImportContainingTypeMissingModifiers = new DiagnosticDescriptor( Ids.GeneratedDllImportContaiingTypeMissingRequiredModifiers, GetResourceString(nameof(Resources.GeneratedDllImportContainingTypeMissingModifiersTitle)), diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 73daa4fdd6402..7901b3f628a2f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -17,7 +17,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer { private const string Category = "Usage"; - public readonly static DiagnosticDescriptor BlittableTypeMustBeBlittableRule = + public static readonly DiagnosticDescriptor BlittableTypeMustBeBlittableRule = new DiagnosticDescriptor( Ids.BlittableTypeMustBeBlittable, "BlittableTypeMustBeBlittable", @@ -27,7 +27,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription))); - public readonly static DiagnosticDescriptor CannotHaveMultipleMarshallingAttributesRule = + public static readonly DiagnosticDescriptor CannotHaveMultipleMarshallingAttributesRule = new DiagnosticDescriptor( Ids.CannotHaveMultipleMarshallingAttributes, "CannotHaveMultipleMarshallingAttributes", @@ -37,7 +37,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesDescription))); - public readonly static DiagnosticDescriptor NativeTypeMustBeNonNullRule = + public static readonly DiagnosticDescriptor NativeTypeMustBeNonNullRule = new DiagnosticDescriptor( Ids.NativeTypeMustBeNonNull, "NativeTypeMustBeNonNull", @@ -47,7 +47,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.NativeTypeMustBeNonNullDescription))); - public readonly static DiagnosticDescriptor NativeTypeMustBeBlittableRule = + public static readonly DiagnosticDescriptor NativeTypeMustBeBlittableRule = new DiagnosticDescriptor( Ids.NativeTypeMustBeBlittable, "NativeTypeMustBeBlittable", @@ -57,7 +57,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.BlittableTypeMustBeBlittableDescription))); - public readonly static DiagnosticDescriptor GetPinnableReferenceReturnTypeBlittableRule = + public static readonly DiagnosticDescriptor GetPinnableReferenceReturnTypeBlittableRule = new DiagnosticDescriptor( Ids.GetPinnableReferenceReturnTypeBlittable, "GetPinnableReferenceReturnTypeBlittable", @@ -66,8 +66,8 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer DiagnosticSeverity.Error, isEnabledByDefault: true, description: GetResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableDescription))); - - public readonly static DiagnosticDescriptor NativeTypeMustBePointerSizedRule = + + public static readonly DiagnosticDescriptor NativeTypeMustBePointerSizedRule = new DiagnosticDescriptor( Ids.NativeTypeMustBePointerSized, "NativeTypeMustBePointerSized", @@ -77,7 +77,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.NativeTypeMustBePointerSizedDescription))); - public readonly static DiagnosticDescriptor NativeTypeMustHaveRequiredShapeRule = + public static readonly DiagnosticDescriptor NativeTypeMustHaveRequiredShapeRule = new DiagnosticDescriptor( Ids.NativeTypeMustHaveRequiredShape, "NativeTypeMustHaveRequiredShape", @@ -87,7 +87,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeDescription))); - public readonly static DiagnosticDescriptor CollectionNativeTypeMustHaveRequiredShapeRule = + public static readonly DiagnosticDescriptor CollectionNativeTypeMustHaveRequiredShapeRule = new DiagnosticDescriptor( Ids.NativeTypeMustHaveRequiredShape, "NativeTypeMustHaveRequiredShape", @@ -97,7 +97,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.CollectionNativeTypeMustHaveRequiredShapeDescription))); - public readonly static DiagnosticDescriptor ValuePropertyMustHaveSetterRule = + public static readonly DiagnosticDescriptor ValuePropertyMustHaveSetterRule = new DiagnosticDescriptor( Ids.ValuePropertyMustHaveSetter, "ValuePropertyMustHaveSetter", @@ -107,7 +107,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ValuePropertyMustHaveSetterDescription))); - public readonly static DiagnosticDescriptor ValuePropertyMustHaveGetterRule = + public static readonly DiagnosticDescriptor ValuePropertyMustHaveGetterRule = new DiagnosticDescriptor( Ids.ValuePropertyMustHaveGetter, "ValuePropertyMustHaveGetter", @@ -117,7 +117,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ValuePropertyMustHaveGetterDescription))); - public readonly static DiagnosticDescriptor GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule = + public static readonly DiagnosticDescriptor GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( Ids.GetPinnableReferenceShouldSupportAllocatingMarshallingFallback, "GetPinnableReferenceShouldSupportAllocatingMarshallingFallback", @@ -127,7 +127,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackDescription))); - public readonly static DiagnosticDescriptor StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule = + public static readonly DiagnosticDescriptor StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( Ids.StackallocMarshallingShouldSupportAllocatingMarshallingFallback, "StackallocMarshallingShouldSupportAllocatingMarshallingFallback", @@ -137,7 +137,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackDescription))); - public readonly static DiagnosticDescriptor StackallocConstructorMustHaveStackBufferSizeConstantRule = + public static readonly DiagnosticDescriptor StackallocConstructorMustHaveStackBufferSizeConstantRule = new DiagnosticDescriptor( Ids.StackallocConstructorMustHaveStackBufferSizeConstant, "StackallocConstructorMustHaveStackBufferSizeConstant", @@ -147,7 +147,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantDescription))); - public readonly static DiagnosticDescriptor RefValuePropertyUnsupportedRule = + public static readonly DiagnosticDescriptor RefValuePropertyUnsupportedRule = new DiagnosticDescriptor( Ids.RefValuePropertyUnsupported, "RefValuePropertyUnsupported", @@ -157,7 +157,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.RefValuePropertyUnsupportedDescription))); - public readonly static DiagnosticDescriptor NativeGenericTypeMustBeClosedOrMatchArityRule = + public static readonly DiagnosticDescriptor NativeGenericTypeMustBeClosedOrMatchArityRule = new DiagnosticDescriptor( Ids.NativeGenericTypeMustBeClosedOrMatchArity, "NativeGenericTypeMustBeClosedOrMatchArity", @@ -167,7 +167,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, description: GetResourceString(nameof(Resources.NativeGenericTypeMustBeClosedOrMatchArityDescription))); - public override ImmutableArray SupportedDiagnostics => + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create( BlittableTypeMustBeBlittableRule, CannotHaveMultipleMarshallingAttributesRule, @@ -223,7 +223,7 @@ private void PrepareForAnalysis(CompilationStartAnalysisContext context) } } - class PerCompilationAnalyzer + private class PerCompilationAnalyzer { private readonly INamedTypeSymbol GeneratedMarshallingAttribute; private readonly INamedTypeSymbol BlittableTypeAttribute; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs index 798ebe6185c9e..e830159c49f3d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs @@ -16,12 +16,12 @@ internal static class Comparers /// Comparer for the set of all of the generated stubs and diagnostics generated for each of them. /// public static readonly IEqualityComparer)>> GeneratedSourceSet = new ImmutableArraySequenceEqualComparer<(string, ImmutableArray)>(new CustomValueTupleElementComparer>(EqualityComparer.Default, new ImmutableArraySequenceEqualComparer(EqualityComparer.Default))); - + /// /// Comparer for an individual generated stub source as a string and the generated diagnostics for the stub. /// public static readonly IEqualityComparer<(string, ImmutableArray)> GeneratedSource = new CustomValueTupleElementComparer>(EqualityComparer.Default, new ImmutableArraySequenceEqualComparer(EqualityComparer.Default)); - + /// /// Comparer for an individual generated stub source as a syntax tree and the generated diagnostics for the stub. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index c4410266c0fca..94e26409c29d0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -15,6 +15,8 @@ using System.Threading; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +[assembly: System.Resources.NeutralResourcesLanguage("en-US")] + namespace Microsoft.Interop { [Generator] @@ -73,7 +75,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .CreateSyntaxProvider( static (node, ct) => ShouldVisitNode(node), static (context, ct) => - new + new { Syntax = (MethodDeclarationSyntax)context.Node, Symbol = (IMethodSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node, ct)! @@ -184,7 +186,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) context.AddSource("GeneratedDllImports.g.cs", data.Item1); }); } - + private static List GenerateSyntaxForForwardedAttributes(AttributeData? suppressGCTransitionAttribute, AttributeData? unmanagedCallConvAttribute) { const string CallConvsField = "CallConvs"; @@ -412,7 +414,7 @@ private static IncrementalStubGenerationContext CalculateStubInformation(MethodD } Debug.Assert(generatedDllImportAttr is not null); - + var generatorDiagnostics = new GeneratorDiagnostics(); // Process the GeneratedDllImport attribute @@ -427,7 +429,7 @@ private static IncrementalStubGenerationContext CalculateStubInformation(MethodD { generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr!, nameof(GeneratedDllImportData.ThrowOnUnmappableChar)); } - + if (stubDllImportData.IsUserDefined.HasFlag(DllImportMember.CallingConvention)) { generatorDiagnostics.ReportConfigurationNotSupported(generatedDllImportAttr!, nameof(GeneratedDllImportData.CallingConvention)); @@ -640,7 +642,7 @@ private static GeneratedDllImportData GetTargetDllImportDataFromStubData(Generat } private static bool ShouldVisitNode(SyntaxNode syntaxNode) - { + { // We only support C# method declarations. if (syntaxNode.Language != LanguageNames.CSharp || !syntaxNode.IsKind(SyntaxKind.MethodDeclaration)) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 8e517510aa0e4..0648253ef2c94 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -11,6 +11,7 @@ enable Microsoft.Interop true + true diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs index f99437e17e238..4e7f296e4d8d2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGeneratorOptions.cs @@ -5,7 +5,7 @@ namespace Microsoft.Interop { - record DllImportGeneratorOptions(bool GenerateForwarders, bool UseMarshalType, bool UseInternalUnsafeType) + internal record DllImportGeneratorOptions(bool GenerateForwarders, bool UseMarshalType, bool UseInternalUnsafeType) { public DllImportGeneratorOptions(AnalyzerConfigOptions options) : this(options.GenerateForwarders(), options.UseMarshalType(), options.UseInternalUnsafeType()) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs index e4fbe49c0fd4e..56c86a4d0f2cb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs @@ -91,7 +91,7 @@ public static DllImportStubContext Create( // Use the declaring syntax as a basis for this type declaration. // Since we're generating source for the method, we know that the current type // has to be declared in source. - TypeDeclarationSyntax typeDecl = (TypeDeclarationSyntax)currType.DeclaringSyntaxReferences[0].GetSyntax(); + TypeDeclarationSyntax typeDecl = (TypeDeclarationSyntax)currType.DeclaringSyntaxReferences[0].GetSyntax(token); // Remove current members, attributes, and base list so we don't double declare them. typeDecl = typeDecl.WithMembers(List()) .WithAttributeLists(List()) @@ -264,7 +264,7 @@ private static bool MethodIsSkipLocalsInit(StubEnvironment env, IMethodSymbol me return true; } } - + // We check the module case earlier, so we don't need to do it here. return false; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs index 3b963d8f8a213..26824f5d8a1ac 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs @@ -7,7 +7,7 @@ namespace Microsoft.Interop { - class ForwarderMarshallingGeneratorFactory : IMarshallingGeneratorFactory + internal class ForwarderMarshallingGeneratorFactory : IMarshallingGeneratorFactory { private static readonly Forwarder Forwarder = new Forwarder(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 226beb9cf55dc..5b6cc3518a41a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -27,7 +27,7 @@ public class Ids private const string Category = "SourceGeneration"; - public readonly static DiagnosticDescriptor ParameterTypeNotSupported = + public static readonly DiagnosticDescriptor ParameterTypeNotSupported = new DiagnosticDescriptor( Ids.TypeNotSupported, GetResourceString(nameof(Resources.TypeNotSupportedTitle)), @@ -37,7 +37,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); - public readonly static DiagnosticDescriptor ReturnTypeNotSupported = + public static readonly DiagnosticDescriptor ReturnTypeNotSupported = new DiagnosticDescriptor( Ids.TypeNotSupported, GetResourceString(nameof(Resources.TypeNotSupportedTitle)), @@ -47,7 +47,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); - public readonly static DiagnosticDescriptor ParameterTypeNotSupportedWithDetails = + public static readonly DiagnosticDescriptor ParameterTypeNotSupportedWithDetails = new DiagnosticDescriptor( Ids.TypeNotSupported, GetResourceString(nameof(Resources.TypeNotSupportedTitle)), @@ -57,7 +57,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); - public readonly static DiagnosticDescriptor ReturnTypeNotSupportedWithDetails = + public static readonly DiagnosticDescriptor ReturnTypeNotSupportedWithDetails = new DiagnosticDescriptor( Ids.TypeNotSupported, GetResourceString(nameof(Resources.TypeNotSupportedTitle)), @@ -67,7 +67,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.TypeNotSupportedDescription))); - public readonly static DiagnosticDescriptor ParameterConfigurationNotSupported = + public static readonly DiagnosticDescriptor ParameterConfigurationNotSupported = new DiagnosticDescriptor( Ids.ConfigurationNotSupported, GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), @@ -77,7 +77,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); - public readonly static DiagnosticDescriptor ReturnConfigurationNotSupported = + public static readonly DiagnosticDescriptor ReturnConfigurationNotSupported = new DiagnosticDescriptor( Ids.ConfigurationNotSupported, GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), @@ -87,7 +87,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); - public readonly static DiagnosticDescriptor ConfigurationNotSupported = + public static readonly DiagnosticDescriptor ConfigurationNotSupported = new DiagnosticDescriptor( Ids.ConfigurationNotSupported, GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), @@ -97,7 +97,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); - public readonly static DiagnosticDescriptor ConfigurationValueNotSupported = + public static readonly DiagnosticDescriptor ConfigurationValueNotSupported = new DiagnosticDescriptor( Ids.ConfigurationNotSupported, GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), @@ -107,7 +107,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); - public readonly static DiagnosticDescriptor MarshallingAttributeConfigurationNotSupported = + public static readonly DiagnosticDescriptor MarshallingAttributeConfigurationNotSupported = new DiagnosticDescriptor( Ids.ConfigurationNotSupported, GetResourceString(nameof(Resources.ConfigurationNotSupportedTitle)), @@ -117,7 +117,7 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.ConfigurationNotSupportedDescription))); - public readonly static DiagnosticDescriptor TargetFrameworkNotSupported = + public static readonly DiagnosticDescriptor TargetFrameworkNotSupported = new DiagnosticDescriptor( Ids.TargetFrameworkNotSupported, GetResourceString(nameof(Resources.TargetFrameworkNotSupportedTitle)), diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs index 8860fb0555eae..d46e1d42325c2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs @@ -9,7 +9,7 @@ namespace Microsoft.Interop { - class NoPreserveSigMarshallingGeneratorFactory : IMarshallingGeneratorFactory + internal class NoPreserveSigMarshallingGeneratorFactory : IMarshallingGeneratorFactory { private static readonly HResultExceptionMarshaller HResultException = new HResultExceptionMarshaller(); private readonly IMarshallingGeneratorFactory inner; diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs index b0514f7d83b84..74c5322881879 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs @@ -165,7 +165,7 @@ static int GetInfoIndex(TypePositionInfo info) } return info.ManagedIndex; } - + BoundGenerator CreateGenerator(TypePositionInfo p) { try diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs index f61eafe61aa1a..e3a0406870d58 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs @@ -139,7 +139,7 @@ public static bool HasNativeValueStorageProperty(ITypeSymbol type, ITypeSymbol s return type .GetMembers(NativeValueStoragePropertyName) .OfType() - .Any(p => p is {IsStatic: false, GetMethod: not null, ReturnsByRef: false, ReturnsByRefReadonly: false } + .Any(p => p is {IsStatic: false, GetMethod: not null, ReturnsByRef: false, ReturnsByRefReadonly: false } && SymbolEqualityComparer.Default.Equals(p.Type, spanOfByte)); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs index bb7b26dabb256..566c81dd550bd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs @@ -83,7 +83,7 @@ private IEnumerable GeneratePinningPath(TypePositionInfo info, TypeSyntax arrayElementType = elementType; if (context.CurrentStage == StubCodeContext.Stage.Marshal) { - // [COMPAT] We use explicit byref calculations here instead of just using a fixed statement + // [COMPAT] We use explicit byref calculations here instead of just using a fixed statement // since a fixed statement converts a zero-length array to a null pointer. // Many native APIs, such as GDI+, ICU, etc. validate that an array parameter is non-null // even when the passed in array length is zero. To avoid breaking customers that want to move diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs index a0af37cd1bac9..31584e68d72e2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs @@ -35,7 +35,6 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) else if (context.SingleFrameSpansNativeContext && !info.IsManagedReturnPosition) { return Argument(IdentifierName(context.GetIdentifiers(info).native)); - } return Argument( PrefixUnaryExpression( @@ -102,7 +101,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { return info.IsByRef && !info.IsManagedReturnPosition && !context.SingleFrameSpansNativeContext; } - + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs index 74373f4e27047..6a3f529d9d99c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs @@ -103,7 +103,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; - + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index 03332e635b3b3..bc61f5e39c7c5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -87,7 +87,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; - + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs index 3504c526a43a9..89ee8e2d1cdfa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -45,12 +45,12 @@ protected bool TryGenerateSetupSyntax(TypePositionInfo info, StubCodeContext con } protected IEnumerable GenerateConditionalAllocationSyntax( - TypePositionInfo info, + TypePositionInfo info, StubCodeContext context, int stackallocMaxSize) { (_, string nativeIdentifier) = context.GetIdentifiers(info); - + string allocationMarkerIdentifier = GetAllocationMarkerIdentifier(info, context); string byteLenIdentifier = GetByteLengthIdentifier(info, context); string stackAllocPtrIdentifier = GetStackAllocIdentifier(info, context); @@ -210,7 +210,7 @@ protected abstract StatementSyntax GenerateStackallocOnlyValueMarshalling( protected abstract ExpressionSyntax GenerateFreeExpression( TypePositionInfo info, StubCodeContext context); - + /// /// Generate code to check if the managed value is not null. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs index da00e4c5bfa31..820a36fc14329 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs @@ -112,7 +112,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; - + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs index fd924298201bd..4ef59de028a48 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs @@ -34,7 +34,7 @@ private bool TryRehydrateMarshalAsAttribute(TypePositionInfo info, out Attribute Literal((int)marshalAs.UnmanagedType))))))); return true; } - + if (info.MarshallingAttributeInfo is NativeContiguousCollectionMarshallingInfo collectionMarshalling && collectionMarshalling.UseDefaultMarshalling && collectionMarshalling.ElementCountInfo is NoCountInfo or SizeAndParamIndexInfo @@ -112,7 +112,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; - + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => true; public AttributeListSyntax? GenerateAttributesForReturnType(TypePositionInfo info) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs index 6c875f569ee21..2b97467a8fd6a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs @@ -44,7 +44,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; - + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs index c9b47c8c45778..917a2a55cf735 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -15,7 +15,7 @@ namespace Microsoft.Interop /// /// The base interface for implementing various different aspects of the custom native type and collection marshalling specs. /// - interface ICustomNativeTypeMarshallingStrategy + internal interface ICustomNativeTypeMarshallingStrategy { TypeSyntax AsNativeType(TypePositionInfo info); @@ -630,7 +630,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i { foreach (var statement in GenerateUnmarshallerCollectionInitialization(info, context)) { - yield return statement; + yield return statement; } } @@ -686,7 +686,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo // and NativeValueStorage spans when the actual collection value is unmarshalled from native to the marshaller. foreach (var statement in GenerateUnmarshallerCollectionInitialization(info, context)) { - yield return statement; + yield return statement; } foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) @@ -974,7 +974,7 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i { yield return statement; } - + if (!info.IsByRef && info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.Out) { // If the parameter is marshalled by-value [Out], then we don't marshal the contents of the collection. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index a17e625d2003d..1edc06838b6db 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -139,7 +139,7 @@ public static IEnumerable GetTopologicallySortedElements( // Now that we have initialized our map of edges and we have our list of nodes, // we'll use Khan's algorithm to calculate a topological sort of the elements. - // Algorithm adapted from A. B. Kahn. 1962. Topological sorting of large networks. Commun. ACM 5, 11 (Nov. 1962), 558562. DOI:https://doi.org/10.1145/368996.369025 + // Algorithm adapted from A. B. Kahn. 1962. Topological sorting of large networks. Commun. ACM 5, 11 (Nov. 1962), 558-562. DOI:https://doi.org/10.1145/368996.369025 // L is the sorted list List L = new(elements.Count); @@ -245,7 +245,7 @@ public static ExpressionSyntax AllocationExpression(CharEncoding encoding, strin { string methodName = encoding switch { - CharEncoding.Utf8 => "StringToCoTaskMemUTF8", // Not in .NET Standard 2.0, so we use the hard-coded name + CharEncoding.Utf8 => "StringToCoTaskMemUTF8", // Not in .NET Standard 2.0, so we use the hard-coded name CharEncoding.Utf16 => nameof(System.Runtime.InteropServices.Marshal.StringToCoTaskMemUni), CharEncoding.Ansi => nameof(System.Runtime.InteropServices.Marshal.StringToCoTaskMemAnsi), _ => throw new System.ArgumentOutOfRangeException(nameof(encoding)) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs index adcd99143f39b..6d17c99ae84e2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs @@ -78,7 +78,7 @@ public IMarshallingGenerator Create( // Enum with no marshalling info case { ManagedType: EnumTypeInfo enumType, MarshallingAttributeInfo: NoMarshallingInfo }: // Check that the underlying type is not bool or char. C# does not allow this, but ECMA-335 does. - var underlyingSpecialType = enumType.UnderlyingType; + var underlyingSpecialType = enumType.UnderlyingType; if (underlyingSpecialType == SpecialType.System_Boolean || underlyingSpecialType == SpecialType.System_Char) { throw new MarshallingNotSupportedException(info, context); @@ -117,7 +117,7 @@ public IMarshallingGenerator Create( NotSupportedDetails = Resources.SafeHandleByRefMustBeConcrete }; } - return new SafeHandleMarshaller(); + return SafeHandle; case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Char } }: return CreateCharMarshaller(info, context); diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs index 5cd7a22df4d20..c9b765be61d48 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs @@ -90,7 +90,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont .WithArgumentList( ArgumentList( SeparatedList( - new []{ + new[]{ Argument( TypeOfExpression( info.ManagedType.Syntax)), @@ -151,7 +151,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont .WithRefKindKeyword(Token(SyntaxKind.RefKeyword)))))); - ExpressionSyntax assignHandleToNativeExpression = + ExpressionSyntax assignHandleToNativeExpression = AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(nativeIdentifier), InvocationExpression( @@ -179,7 +179,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont ParseTypeName(TypeNames.System_Runtime_InteropServices_Marshal), IdentifierName("InitHandle")), ArgumentList(SeparatedList( - new [] + new[] { Argument(IdentifierName(newHandleObjectIdentifier)), Argument(IdentifierName(nativeIdentifier)) @@ -208,7 +208,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont IdentifierName(managedIdentifier), IdentifierName(nameof(SafeHandle.DangerousRelease))), ArgumentList()))); - + // Do not unmarshal the handle if the value didn't change. yield return IfStatement( BinaryExpression(SyntaxKind.NotEqualsExpression, @@ -241,7 +241,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; - + public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs index 0ee3a62be733e..8809740b3e1dc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs @@ -150,7 +150,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } 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. 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 index 316dce2fb047e..26f45d820757b 100644 --- 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 @@ -35,7 +35,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext if (windowsExpr.IsEquivalentTo(nonWindowsExpr)) return Argument(windowsExpr); - // OperatingSystem.IsWindows() ? << Windows code >> : << non-Windows code >> + // OperatingSystem.IsWindows() ? << Windows code >> : << non-Windows code >> return Argument( ConditionalExpression( IsWindows, @@ -88,10 +88,10 @@ public override IEnumerable Generate(TypePositionInfo info, Stu // any platform, it is done on every platform. foreach (var s in this.windowsMarshaller.Generate(info, context)) yield return s; - + foreach (var s in this.nonWindowsMarshaller.Generate(info, context)) yield return s; - + break; case StubCodeContext.Stage.Unmarshal: if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) @@ -112,7 +112,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } 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. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs index 2b7331d89014f..36eb1c1a14fbd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs @@ -128,16 +128,16 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } break; case StubCodeContext.Stage.Cleanup: - yield return GenerateConditionalAllocationFreeSyntax(info ,context); + yield return GenerateConditionalAllocationFreeSyntax(info, context); break; } } public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; - + public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; - + protected override ExpressionSyntax GenerateAllocationExpression( TypePositionInfo info, StubCodeContext context, @@ -155,7 +155,7 @@ protected override ExpressionSyntax GenerateByteLengthCalculationExpression(Type // +1 for null terminator // *2 for number of bytes per char // int = (.Length + 1) * 2; - return + return BinaryExpression( SyntaxKind.MultiplyExpression, ParenthesizedExpression( @@ -176,7 +176,7 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( SyntaxToken stackAllocPtrIdentifier) { // ((ReadOnlySpan)).CopyTo(new Span(, .Length + 1)); - return + return ExpressionStatement( InvocationExpression( MemberAccessExpression( @@ -189,14 +189,14 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( IdentifierName(context.GetIdentifiers(info).managed))), IdentifierName("CopyTo")), ArgumentList( - SeparatedList(new [] { + SeparatedList(new[] { Argument( ObjectCreationExpression( GenericName(Identifier(TypeNames.System_Span), TypeArgumentList(SingletonSeparatedList( PredefinedType(Token(SyntaxKind.CharKeyword))))), ArgumentList( - SeparatedList(new []{ + SeparatedList(new[]{ Argument(IdentifierName(stackAllocPtrIdentifier)), Argument(IdentifierName(byteLengthIdentifier))})), initializer: null))})))); diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs index 6fdb99390090a..c5c9b4eda1a96 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs @@ -103,9 +103,9 @@ public override IEnumerable Generate(TypePositionInfo info, Stu } public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; - + public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; - + protected override ExpressionSyntax GenerateAllocationExpression( TypePositionInfo info, StubCodeContext context, 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 be5a1819b9943..30cea9d1bfd94 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 @@ -322,7 +322,7 @@ private MarshallingInfo GetMarshallingInfo( return NoMarshallingInfo.Instance; } - CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet inspectedElements) + private CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet inspectedElements) { int? constSize = null; string? elementName = null; @@ -442,7 +442,7 @@ CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashSet inspectedElements, @@ -559,7 +559,7 @@ MarshallingInfo CreateInfoFromMarshalAs( ElementMarshallingInfo: elementMarshallingInfo); } - MarshallingInfo CreateNativeMarshallingInfo( + private MarshallingInfo CreateNativeMarshallingInfo( ITypeSymbol type, AttributeData attrData, bool isMarshalUsingAttribute, @@ -695,7 +695,7 @@ MarshallingInfo CreateNativeMarshallingInfo( UseDefaultMarshalling: !isMarshalUsingAttribute); } - bool TryCreateTypeBasedMarshallingInfo( + private bool TryCreateTypeBasedMarshallingInfo( ITypeSymbol type, CountInfo parsedCountInfo, int indirectionLevel, diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj index c1768eedb4da2..e8f403d2f8329 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj @@ -5,6 +5,7 @@ false enable Microsoft.Interop + true diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Properties/AssemblyInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..dcac8d25f61d5 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +[assembly: System.Resources.NeutralResourcesLanguage("en-US")] diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs index bea582b28cf5a..4f3229265eebe 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs @@ -51,7 +51,7 @@ public enum Stage /// Perform any cleanup required /// Cleanup, - + /// /// Keep alive any managed objects that need to stay alive across the call. /// 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 de39a3f574a80..1925d2ece51bb 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 @@ -52,7 +52,7 @@ public static string MarshalEx(InteropGenerationOptions options) } public const string System_Runtime_InteropServices_UnmanagedType = "System.Runtime.InteropServices.UnmanagedType"; - + public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal"; public const string System_Runtime_InteropServices_GeneratedMarshalling_ArrayMarshaller_Metadata = "System.Runtime.InteropServices.GeneratedMarshalling.ArrayMarshaller`1"; From b7283efb781581f633e2ab613aeded969372f4a5 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 28 Sep 2021 13:45:46 -0700 Subject: [PATCH 149/161] Make Utf16CharMarshaller pin ref parameters (#59700) --- .../DllImportGenerator/Compatibility.md | 4 ++ .../Marshalling/CharMarshaller.cs | 65 ++++++++++++++++--- .../CharacterTests.cs | 19 +++++- .../TestAssets/NativeExports/Characters.cs | 8 +++ 4 files changed, 87 insertions(+), 9 deletions(-) diff --git a/docs/design/libraries/DllImportGenerator/Compatibility.md b/docs/design/libraries/DllImportGenerator/Compatibility.md index e98b6a4ec5fa2..3a6ab0e6c94d5 100644 --- a/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -69,6 +69,10 @@ Jagged arrays (arrays of arrays) are technically unsupported as was the case in In the source-generated marshalling, arrays will be allocated on the stack (instead of through [`AllocCoTaskMem`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.alloccotaskmem)) if they are passed by value or by read-only reference if they contain at most 256 bytes of data. The built-in system does not support this optimization for arrays. +### `in` keyword + +For some types - blittable or Unicode `char` - passed by read-only reference via the [`in` keyword](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/in-parameter-modifier), the built-in system simply pins the parameter. The generated marshalling code does the same. A consequence of this behaviour is that any modifications made by the invoked function will be reflected in the caller. It is left to the user to avoid the situation in which `in` is used for a parameter that will actually be modified by the invoked function. + ### `LCIDConversion` support [`LCIDConversionAttribute`](`https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.lcidconversionattribute`) will not be supported for methods marked with `GeneratedDllImportAttribute`. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index bc61f5e39c7c5..fe77d1aba9266 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -22,16 +22,29 @@ public Utf16CharMarshaller() public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - string identifier = context.GetIdentifiers(info).native; - if (info.IsByRef) + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + if (!info.IsByRef) + { + // (ushort) + return Argument( + CastExpression( + AsNativeType(info), + IdentifierName(managedIdentifier))); + } + else if (IsPinningPathSupported(info, context)) { + // (ushort*) return Argument( - PrefixUnaryExpression( - SyntaxKind.AddressOfExpression, - IdentifierName(identifier))); + CastExpression( + PointerType(AsNativeType(info)), + IdentifierName(PinnedIdentifier(info.InstanceIdentifier)))); } - return Argument(IdentifierName(identifier)); + // & + return Argument( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(nativeIdentifier))); } public TypeSyntax AsNativeType(TypePositionInfo info) @@ -52,12 +65,36 @@ public ParameterSyntax AsParameter(TypePositionInfo info) public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) { (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + + if (IsPinningPathSupported(info, context)) + { + if (context.CurrentStage == StubCodeContext.Stage.Pin) + { + // fixed (char* = &) + yield return FixedStatement( + VariableDeclaration( + PointerType(PredefinedType(Token(SyntaxKind.CharKeyword))), + SingletonSeparatedList( + VariableDeclarator(Identifier(PinnedIdentifier(info.InstanceIdentifier))) + .WithInitializer(EqualsValueClause( + PrefixUnaryExpression( + SyntaxKind.AddressOfExpression, + IdentifierName(Identifier(managedIdentifier))) + )) + ) + ), + EmptyStatement() + ); + } + yield break; + } + switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: break; case StubCodeContext.Stage.Marshal: - if (info.RefKind != RefKind.Out) + if (info.IsByRef && info.RefKind != RefKind.Out) { yield return ExpressionStatement( AssignmentExpression( @@ -86,8 +123,20 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont } } - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true; + public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + { + return info.IsManagedReturnPosition || (info.IsByRef && !context.SingleFrameSpansNativeContext); + } public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false; + + private bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) + { + return context.SingleFrameSpansNativeContext + && !info.IsManagedReturnPosition + && info.IsByRef; + } + + private static string PinnedIdentifier(string identifier) => $"{identifier}__pinned"; } } 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 3443a5df2bb19..d68aef5f91b88 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs @@ -1,7 +1,9 @@ // 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 System.Runtime.InteropServices; using Xunit; @@ -32,6 +34,9 @@ partial class NativeExportsNE [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.Ansi)] [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)] + public static partial void ReverseBuffer(ref char buffer, int len); } public class CharacterTests @@ -70,7 +75,7 @@ public void ValidateUnicodeReturns(char expected, uint value) result = initial; NativeExportsNE.ReturnUIntAsUnicode_In(value, in result); - Assert.Equal(initial, result); // Should not be updated when using 'in' + Assert.Equal(expected, result); // Value is updated even when passed with 'in' keyword (matches built-in system) } [Theory] @@ -81,5 +86,17 @@ public void ValidateIgnoreCharSet(char value, uint expectedUInt) Assert.Equal(expected, NativeExportsNE.ReturnU2AsU2IgnoreCharSet(value)); Assert.Equal(expected, NativeExportsNE.ReturnI2AsI2IgnoreCharSet(value)); } + + [Fact] + public void ValidateRefCharAsBuffer() + { + char[] chars = CharacterMappings().Select(o => (char)o[0]).ToArray(); + char[] expected = new char[chars.Length]; + Array.Copy(chars, expected, chars.Length); + Array.Reverse(expected); + + NativeExportsNE.ReverseBuffer(ref MemoryMarshal.GetArrayDataReference(chars), chars.Length); + Assert.Equal(expected, chars); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs index 95c666eca4f60..ed4e18e22e19d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs @@ -1,6 +1,7 @@ // 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.Runtime.InteropServices; namespace NativeExports @@ -24,5 +25,12 @@ public static void ReturnUIntAsRefUInt(uint input, uint* res) { *res = input; } + + [UnmanagedCallersOnly(EntryPoint = "char_reverse_buffer_ref")] + public static void ReverseBuffer(ushort *buffer, int len) + { + var span = new Span(buffer, len); + span.Reverse(); + } } } From 27d5e8dd3c9fba4666154aabff3f96b918b2c576 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 28 Sep 2021 15:04:42 -0700 Subject: [PATCH 150/161] Fix null termination for generated marshalling of read-only ref string (#59726) --- .../Marshalling/StringMarshaller.Utf16.cs | 34 ++++++++++++++++--- .../SetLastErrorTests.cs | 2 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs index 36eb1c1a14fbd..78733f1ce62e5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs @@ -175,8 +175,9 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( SyntaxToken byteLengthIdentifier, SyntaxToken stackAllocPtrIdentifier) { - // ((ReadOnlySpan)).CopyTo(new Span(, .Length + 1)); - return + string managedIdentifier = context.GetIdentifiers(info).managed; + return Block( + // ((ReadOnlySpan)).CopyTo(new Span(, .Length)); ExpressionStatement( InvocationExpression( MemberAccessExpression( @@ -186,7 +187,7 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( GenericName(Identifier("System.ReadOnlySpan"), TypeArgumentList(SingletonSeparatedList( PredefinedType(Token(SyntaxKind.CharKeyword))))), - IdentifierName(context.GetIdentifiers(info).managed))), + IdentifierName(managedIdentifier))), IdentifierName("CopyTo")), ArgumentList( SeparatedList(new[] { @@ -198,8 +199,31 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( ArgumentList( SeparatedList(new[]{ Argument(IdentifierName(stackAllocPtrIdentifier)), - Argument(IdentifierName(byteLengthIdentifier))})), - initializer: null))})))); + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName("Length")))})), + initializer: null))})))), + // ((char*))[.Length] = '\0'; + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + ElementAccessExpression( + ParenthesizedExpression( + CastExpression( + PointerType(PredefinedType(Token(SyntaxKind.CharKeyword))), + IdentifierName(stackAllocPtrIdentifier))), + BracketedArgumentList( + SingletonSeparatedList( + Argument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(managedIdentifier), + IdentifierName("Length")))))), + LiteralExpression( + SyntaxKind.CharacterLiteralExpression, + Literal('\0'))))); } protected override ExpressionSyntax GenerateFreeExpression( diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs index d6b3cac367c9c..f6ee7fff32a47 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -33,7 +33,7 @@ public partial class SetLastError [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] public static partial int SetError(int error, byte shouldSetError); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error_return_string", SetLastError = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] [return: MarshalUsing(typeof(SetLastErrorMarshaller))] public static partial int SetError_CustomMarshallingSetsError(int error, byte shouldSetError); From 853297ab1f5d2ba66032bf53cf38fbd6c7e8a5ca Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 30 Sep 2021 16:21:24 -0700 Subject: [PATCH 151/161] Update DllImportGenerator style to match repo conventions (#59753) --- .../InteropServices/ArrayMarshaller.cs | 2 +- .../GeneratedMarshallingAttribute.cs | 2 +- .../ConvertToGeneratedDllImportFixer.cs | 3 +- .../ManualTypeMarshallingAnalyzer.cs | 48 ++-- .../gen/DllImportGenerator/Comparers.cs | 16 +- .../DllImportGenerator/Diagnostics/Events.cs | 4 +- .../DllImportGenerator/DllImportGenerator.cs | 12 +- .../DllImportStubContext.cs | 6 +- .../ForwarderMarshallingGeneratorFactory.cs | 4 +- .../GeneratorDiagnostics.cs | 24 +- .../gen/DllImportGenerator/LanguageSupport.cs | 2 +- ...oPreserveSigMarshallingGeneratorFactory.cs | 10 +- .../PInvokeStubCodeGenerator.cs | 72 +++--- ...CollectionElementMarshallingCodeContext.cs | 8 +- .../LanguageSupport.cs | 2 +- .../ManualTypeMarshallingHelper.cs | 12 +- .../Marshalling/ArrayMarshaller.cs | 34 +-- ...ributedMarshallingModelGeneratorFactory.cs | 14 +- .../ByValueContentsMarshalKindValidator.cs | 6 +- .../Marshalling/CharMarshaller.cs | 4 +- .../CustomNativeTypeMarshallingGenerator.cs | 28 +-- .../Marshalling/Forwarder.cs | 6 +- .../Marshalling/HResultExceptionMarshaller.cs | 4 +- .../ICustomNativeTypeMarshallingStrategy.cs | 224 +++++++++--------- .../Marshalling/MarshallerHelpers.cs | 12 +- .../Marshalling/MarshallingGenerator.cs | 4 +- .../MarshallingGeneratorFactory.cs | 70 +++--- .../PinnableManagedValueMarshaller.cs | 16 +- .../Marshalling/StringMarshaller.Ansi.cs | 12 +- .../StringMarshaller.PlatformDefined.cs | 32 +-- .../Marshalling/StringMarshaller.Utf16.cs | 4 +- .../Marshalling/StringMarshaller.Utf8.cs | 8 +- .../MarshallingAttributeInfo.cs | 8 +- .../TypePositionInfo.cs | 4 +- .../TypeSymbolExtensions.cs | 34 +-- 35 files changed, 375 insertions(+), 376 deletions(-) diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs index 4014154b4824c..2293743aa87fe 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs @@ -26,7 +26,7 @@ unsafe ref struct ArrayMarshaller private IntPtr _allocatedMemory; public ArrayMarshaller(int sizeOfNativeElement) - :this() + : this() { _sizeOfNativeElement = sizeOfNativeElement; } diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs index f9308081c2b2f..2fc73b41e3cb8 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs @@ -57,7 +57,7 @@ public MarshalUsingAttribute() } public MarshalUsingAttribute(Type nativeType) - :this() + : this() { NativeType = nativeType; } 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 e29fae5f12beb..e61f3b6aa9caa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs @@ -55,8 +55,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) return; // Make sure the method has the DllImportAttribute - AttributeData? dllImportAttr; - if (!TryGetAttribute(methodSymbol, dllImportAttrType, out dllImportAttr)) + if (!TryGetAttribute(methodSymbol, dllImportAttrType, out AttributeData? dllImportAttr)) return; // Register code fixes with two options for the fix - using preprocessor or not. diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index 7901b3f628a2f..d7aab5dc9329d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -225,13 +225,13 @@ private void PrepareForAnalysis(CompilationStartAnalysisContext context) private class PerCompilationAnalyzer { - private readonly INamedTypeSymbol GeneratedMarshallingAttribute; - private readonly INamedTypeSymbol BlittableTypeAttribute; - private readonly INamedTypeSymbol NativeMarshallingAttribute; - private readonly INamedTypeSymbol MarshalUsingAttribute; - private readonly INamedTypeSymbol GenericContiguousCollectionMarshallerAttribute; - private readonly INamedTypeSymbol SpanOfByte; - private readonly INamedTypeSymbol StructLayoutAttribute; + private readonly INamedTypeSymbol _generatedMarshallingAttribute; + private readonly INamedTypeSymbol _blittableTypeAttribute; + private readonly INamedTypeSymbol _nativeMarshallingAttribute; + private readonly INamedTypeSymbol _marshalUsingAttribute; + private readonly INamedTypeSymbol _genericContiguousCollectionMarshallerAttribute; + private readonly INamedTypeSymbol _spanOfByte; + private readonly INamedTypeSymbol _structLayoutAttribute; public PerCompilationAnalyzer(INamedTypeSymbol generatedMarshallingAttribute, INamedTypeSymbol blittableTypeAttribute, @@ -241,13 +241,13 @@ public PerCompilationAnalyzer(INamedTypeSymbol generatedMarshallingAttribute, INamedTypeSymbol spanOfByte, INamedTypeSymbol structLayoutAttribute) { - GeneratedMarshallingAttribute = generatedMarshallingAttribute; - BlittableTypeAttribute = blittableTypeAttribute; - NativeMarshallingAttribute = nativeMarshallingAttribute; - MarshalUsingAttribute = marshalUsingAttribute; - GenericContiguousCollectionMarshallerAttribute = genericContiguousCollectionMarshallerAttribute; - SpanOfByte = spanOfByte; - StructLayoutAttribute = structLayoutAttribute; + _generatedMarshallingAttribute = generatedMarshallingAttribute; + _blittableTypeAttribute = blittableTypeAttribute; + _nativeMarshallingAttribute = nativeMarshallingAttribute; + _marshalUsingAttribute = marshalUsingAttribute; + _genericContiguousCollectionMarshallerAttribute = genericContiguousCollectionMarshallerAttribute; + _spanOfByte = spanOfByte; + _structLayoutAttribute = structLayoutAttribute; } public void AnalyzeTypeDefinition(SymbolAnalysisContext context) @@ -258,17 +258,17 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) AttributeData? nativeMarshallingAttributeData = null; foreach (var attr in type.GetAttributes()) { - if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, GeneratedMarshallingAttribute)) + if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, _generatedMarshallingAttribute)) { // If the type has the GeneratedMarshallingAttribute, // we let the source generator handle error checking. return; } - else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, BlittableTypeAttribute)) + else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, _blittableTypeAttribute)) { blittableTypeAttributeData = attr; } - else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, NativeMarshallingAttribute)) + else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, _nativeMarshallingAttribute)) { nativeMarshallingAttributeData = attr; } @@ -281,7 +281,7 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) CannotHaveMultipleMarshallingAttributesRule, type.ToDisplayString())); } - else if (blittableTypeAttributeData is not null && (!type.HasOnlyBlittableFields() || type.IsAutoLayout(StructLayoutAttribute))) + else if (blittableTypeAttributeData is not null && (!type.HasOnlyBlittableFields() || type.IsAutoLayout(_structLayoutAttribute))) { context.ReportDiagnostic( blittableTypeAttributeData.CreateDiagnostic( @@ -290,7 +290,7 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) } else if (nativeMarshallingAttributeData is not null) { - AnalyzeNativeMarshalerType(context, type, nativeMarshallingAttributeData, isNativeMarshallingAttribute:true); + AnalyzeNativeMarshalerType(context, type, nativeMarshallingAttributeData, isNativeMarshallingAttribute: true); } } @@ -307,7 +307,7 @@ private bool HasMultipleMarshallingAttributes(AttributeData? blittableTypeAttrib public void AnalyzeElement(SymbolAnalysisContext context) { - AttributeData? attrData = context.Symbol.GetAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(MarshalUsingAttribute, attr.AttributeClass)); + AttributeData? attrData = context.Symbol.GetAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(_marshalUsingAttribute, attr.AttributeClass)); if (attrData is not null) { if (context.Symbol is IParameterSymbol param) @@ -324,7 +324,7 @@ public void AnalyzeElement(SymbolAnalysisContext context) public void AnalyzeReturnType(SymbolAnalysisContext context) { var method = (IMethodSymbol)context.Symbol; - AttributeData? attrData = method.GetReturnTypeAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(MarshalUsingAttribute, attr.AttributeClass)); + AttributeData? attrData = method.GetReturnTypeAttributes().FirstOrDefault(attr => SymbolEqualityComparer.Default.Equals(_marshalUsingAttribute, attr.AttributeClass)); if (attrData is not null) { AnalyzeNativeMarshalerType(context, method.ReturnType, attrData, isNativeMarshallingAttribute: false); @@ -364,12 +364,12 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb DiagnosticDescriptor requiredShapeRule = NativeTypeMustHaveRequiredShapeRule; ManualTypeMarshallingHelper.NativeTypeMarshallingVariant variant = ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard; - if (marshalerType.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(GenericContiguousCollectionMarshallerAttribute, a.AttributeClass))) + if (marshalerType.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(_genericContiguousCollectionMarshallerAttribute, a.AttributeClass))) { variant = ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.ContiguousCollection; requiredShapeRule = CollectionNativeTypeMustHaveRequiredShapeRule; if (!ManualTypeMarshallingHelper.TryGetManagedValuesProperty(marshalerType, out _) - || !ManualTypeMarshallingHelper.HasNativeValueStorageProperty(marshalerType, SpanOfByte)) + || !ManualTypeMarshallingHelper.HasNativeValueStorageProperty(marshalerType, _spanOfByte)) { context.ReportDiagnostic( GetDiagnosticLocations(context, marshalerType, nativeMarshalerAttributeData).CreateDiagnostic( @@ -425,7 +425,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb hasConstructor = hasConstructor || ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type, variant); - if (!hasStackallocConstructor && ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, SpanOfByte, variant)) + if (!hasStackallocConstructor && ManualTypeMarshallingHelper.IsStackallocConstructor(ctor, type, _spanOfByte, variant)) { hasStackallocConstructor = true; IFieldSymbol stackAllocSizeField = nativeType.GetMembers("StackBufferSize").OfType().FirstOrDefault(); diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs index e830159c49f3d..71ecae6a88860 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Comparers.cs @@ -39,7 +39,7 @@ internal static class Comparers /// The type of immutable array element. internal class ImmutableArraySequenceEqualComparer : IEqualityComparer> { - private readonly IEqualityComparer elementComparer; + private readonly IEqualityComparer _elementComparer; /// /// Creates an with a custom comparer for the elements of the collection. @@ -47,12 +47,12 @@ internal class ImmutableArraySequenceEqualComparer : IEqualityComparerThe comparer instance for the collection elements. public ImmutableArraySequenceEqualComparer(IEqualityComparer elementComparer) { - this.elementComparer = elementComparer; + _elementComparer = elementComparer; } public bool Equals(ImmutableArray x, ImmutableArray y) { - return x.SequenceEqual(y, elementComparer); + return x.SequenceEqual(y, _elementComparer); } public int GetHashCode(ImmutableArray obj) @@ -76,18 +76,18 @@ public int GetHashCode(SyntaxNode obj) internal class CustomValueTupleElementComparer : IEqualityComparer<(T, U)> { - private readonly IEqualityComparer item1Comparer; - private readonly IEqualityComparer item2Comparer; + private readonly IEqualityComparer _item1Comparer; + private readonly IEqualityComparer _item2Comparer; public CustomValueTupleElementComparer(IEqualityComparer item1Comparer, IEqualityComparer item2Comparer) { - this.item1Comparer = item1Comparer; - this.item2Comparer = item2Comparer; + _item1Comparer = item1Comparer; + _item2Comparer = item2Comparer; } public bool Equals((T, U) x, (T, U) y) { - return item1Comparer.Equals(x.Item1, y.Item1) && item2Comparer.Equals(x.Item2, y.Item2); + return _item1Comparer.Equals(x.Item1, y.Item1) && _item2Comparer.Equals(x.Item2, y.Item2); } public int GetHashCode((T, U) obj) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs index f1f34123af67a..785d253bdcd9e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Diagnostics/Events.cs @@ -45,7 +45,7 @@ public static IDisposable SourceGenerationStartStop(int methodCount) [Event(StartSourceGenerationEventId, Level = EventLevel.Informational, Keywords = Keywords.SourceGeneration)] public void SourceGenerationStart(int methodCount) { - this.WriteEvent(StartSourceGenerationEventId, methodCount); + WriteEvent(StartSourceGenerationEventId, methodCount); } /// @@ -54,7 +54,7 @@ public void SourceGenerationStart(int methodCount) [Event(StopSourceGenerationEventId, Level = EventLevel.Informational, Keywords = Keywords.SourceGeneration)] public void SourceGenerationStop() { - this.WriteEvent(StopSourceGenerationEventId); + WriteEvent(StopSourceGenerationEventId); } private class StartStopEvent : IDisposable diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index 94e26409c29d0..d2f357636456e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -25,7 +25,7 @@ public sealed class DllImportGenerator : IIncrementalGenerator private const string GeneratedDllImport = nameof(GeneratedDllImport); private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute); - private static readonly Version MinimumSupportedFrameworkVersion = new Version(5, 0); + private static readonly Version s_minimumSupportedFrameworkVersion = new Version(5, 0); internal sealed record IncrementalStubGenerationContext(DllImportStubContext StubContext, ImmutableArray ForwardedAttributes, GeneratedDllImportData DllImportData, ImmutableArray Diagnostics) { @@ -57,10 +57,10 @@ public enum StepName public record ExecutedStepInfo(StepName Step, object Input); - private List executedSteps = new(); - public IEnumerable ExecutedSteps => executedSteps; + private readonly List _executedSteps = new(); + public IEnumerable ExecutedSteps => _executedSteps; - internal void RecordExecutedStep(ExecutedStepInfo step) => executedSteps.Add(step); + internal void RecordExecutedStep(ExecutedStepInfo step) => _executedSteps.Add(step); } /// @@ -106,7 +106,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) Diagnostic.Create( GeneratorDiagnostics.TargetFrameworkNotSupported, Location.None, - MinimumSupportedFrameworkVersion.ToString(2))); + s_minimumSupportedFrameworkVersion.ToString(2))); } }); @@ -294,7 +294,7 @@ private static bool IsSupportedTargetFramework(Compilation compilation, out Vers // .NET Standard "netstandard" => false, // .NET Core (when version < 5.0) or .NET - "System.Runtime" or "System.Private.CoreLib" => version >= MinimumSupportedFrameworkVersion, + "System.Runtime" or "System.Private.CoreLib" => version >= s_minimumSupportedFrameworkVersion, _ => false, }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs index 56c86a4d0f2cb..81e10ff2ae6a8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs @@ -25,9 +25,9 @@ internal record StubEnvironment( internal sealed class DllImportStubContext : IEquatable { -// We don't need the warnings around not setting the various -// non-nullable fields/properties on this type in the constructor -// since we always use a property initializer. + // We don't need the warnings around not setting the various + // non-nullable fields/properties on this type in the constructor + // since we always use a property initializer. #pragma warning disable 8618 private DllImportStubContext() { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs index 26824f5d8a1ac..53fb3235c2d8b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs @@ -9,8 +9,8 @@ namespace Microsoft.Interop { internal class ForwarderMarshallingGeneratorFactory : IMarshallingGeneratorFactory { - private static readonly Forwarder Forwarder = new Forwarder(); + private static readonly Forwarder s_forwarder = new Forwarder(); - public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) => Forwarder; + public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) => s_forwarder; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs index 5b6cc3518a41a..0ebfe4830d8ba 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/GeneratorDiagnostics.cs @@ -127,9 +127,9 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(Resources.TargetFrameworkNotSupportedDescription))); - private readonly List diagnostics = new List(); + private readonly List _diagnostics = new List(); - public IEnumerable Diagnostics => diagnostics; + public IEnumerable Diagnostics => _diagnostics; /// /// Report diagnostic for configuration that is not supported by the DLL import source generator @@ -144,14 +144,14 @@ public void ReportConfigurationNotSupported( { if (unsupportedValue == null) { - diagnostics.Add( + _diagnostics.Add( attributeData.CreateDiagnostic( GeneratorDiagnostics.ConfigurationNotSupported, configurationName)); } else { - diagnostics.Add( + _diagnostics.Add( attributeData.CreateDiagnostic( GeneratorDiagnostics.ConfigurationValueNotSupported, unsupportedValue, @@ -191,7 +191,7 @@ public void ReportMarshallingNotSupported( // Report the specific not-supported reason. if (info.IsManagedReturnPosition) { - diagnostics.Add( + _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails, notSupportedDetails!, @@ -199,7 +199,7 @@ public void ReportMarshallingNotSupported( } else { - diagnostics.Add( + _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails, notSupportedDetails!, @@ -213,7 +213,7 @@ public void ReportMarshallingNotSupported( // than when there is no attribute and the type itself is not supported. if (info.IsManagedReturnPosition) { - diagnostics.Add( + _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnConfigurationNotSupported, nameof(System.Runtime.InteropServices.MarshalAsAttribute), @@ -221,7 +221,7 @@ public void ReportMarshallingNotSupported( } else { - diagnostics.Add( + _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterConfigurationNotSupported, nameof(System.Runtime.InteropServices.MarshalAsAttribute), @@ -233,7 +233,7 @@ public void ReportMarshallingNotSupported( // Report that the type is not supported if (info.IsManagedReturnPosition) { - diagnostics.Add( + _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnTypeNotSupported, info.ManagedType.DiagnosticFormattedName, @@ -241,7 +241,7 @@ public void ReportMarshallingNotSupported( } else { - diagnostics.Add( + _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterTypeNotSupported, info.ManagedType.DiagnosticFormattedName, @@ -255,7 +255,7 @@ public void ReportInvalidMarshallingAttributeInfo( string reasonResourceName, params string[] reasonArgs) { - diagnostics.Add( + _diagnostics.Add( attributeData.CreateDiagnostic( GeneratorDiagnostics.MarshallingAttributeConfigurationNotSupported, new LocalizableResourceString(reasonResourceName, Resources.ResourceManager, typeof(Resources), reasonArgs))); @@ -267,7 +267,7 @@ public void ReportInvalidMarshallingAttributeInfo( /// Minimum supported version of .NET public void ReportTargetFrameworkNotSupported(Version minimumSupportedVersion) { - diagnostics.Add( + _diagnostics.Add( Diagnostic.Create( TargetFrameworkNotSupported, Location.None, diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs index 4abeef8a7b1c3..0f983ddc28671 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/LanguageSupport.cs @@ -7,5 +7,5 @@ namespace System.Runtime.CompilerServices { // Define IsExternalInit type to support records. internal class IsExternalInit - {} + { } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs index d46e1d42325c2..d06e7db251cfd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs @@ -11,12 +11,12 @@ namespace Microsoft.Interop { internal class NoPreserveSigMarshallingGeneratorFactory : IMarshallingGeneratorFactory { - private static readonly HResultExceptionMarshaller HResultException = new HResultExceptionMarshaller(); - private readonly IMarshallingGeneratorFactory inner; + private static readonly HResultExceptionMarshaller s_hResultException = new HResultExceptionMarshaller(); + private readonly IMarshallingGeneratorFactory _inner; public NoPreserveSigMarshallingGeneratorFactory(IMarshallingGeneratorFactory inner) { - this.inner = inner; + _inner = inner; } public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) @@ -25,9 +25,9 @@ public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext conte { // Use marshaller for native HRESULT return / exception throwing System.Diagnostics.Debug.Assert(info.ManagedType.Equals(SpecialTypeInfo.Int32)); - return HResultException; + return s_hResultException; } - return inner.Create(info, context); + return _inner.Create(info, context); } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs index 74c5322881879..27ee9e161e94b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs @@ -55,11 +55,11 @@ private record struct BoundGenerator(TypePositionInfo TypeInfo, IMarshallingGene // Error code representing success. This maps to S_OK for Windows HRESULT semantics and 0 for POSIX errno semantics. private const int SuccessErrorCode = 0; - private readonly bool setLastError; - private readonly List paramMarshallers; - private readonly BoundGenerator retMarshaller; - private readonly List sortedMarshallers; - private readonly bool stubReturnsVoid; + private readonly bool _setLastError; + private readonly List _paramMarshallers; + private readonly BoundGenerator _retMarshaller; + private readonly List _sortedMarshallers; + private readonly bool _stubReturnsVoid; public PInvokeStubCodeGenerator( IEnumerable argTypes, @@ -67,7 +67,7 @@ public PInvokeStubCodeGenerator( Action marshallingNotSupportedCallback, IMarshallingGeneratorFactory generatorFactory) { - this.setLastError = setLastError; + _setLastError = setLastError; List allMarshallers = new(); List paramMarshallers = new(); @@ -98,17 +98,17 @@ public PInvokeStubCodeGenerator( } } - this.stubReturnsVoid = managedRetMarshaller.TypeInfo.ManagedType == SpecialTypeInfo.Void; + _stubReturnsVoid = managedRetMarshaller.TypeInfo.ManagedType == SpecialTypeInfo.Void; - if (!managedRetMarshaller.TypeInfo.IsNativeReturnPosition && !this.stubReturnsVoid) + if (!managedRetMarshaller.TypeInfo.IsNativeReturnPosition && !_stubReturnsVoid) { // If the managed ret marshaller isn't the native ret marshaller, then the managed ret marshaller // is a parameter. paramMarshallers.Add(managedRetMarshaller); } - this.retMarshaller = nativeRetMarshaller; - this.paramMarshallers = paramMarshallers; + _retMarshaller = nativeRetMarshaller; + _paramMarshallers = paramMarshallers; // We are doing a topological sort of our marshallers to ensure that each parameter/return value's // dependencies are unmarshalled before their dependents. This comes up in the case of contiguous @@ -132,7 +132,7 @@ public PInvokeStubCodeGenerator( // the return value has dependencies on numRows and numColumns and numRows has a dependency on numColumns, // we want to unmarshal numColumns, then numRows, then the return value. // A topological sort ensures we get this order correct. - this.sortedMarshallers = MarshallerHelpers.GetTopologicallySortedElements( + _sortedMarshallers = MarshallerHelpers.GetTopologicallySortedElements( allMarshallers, static m => GetInfoIndex(m.TypeInfo), static m => GetInfoDependencies(m.TypeInfo)) @@ -141,7 +141,7 @@ public PInvokeStubCodeGenerator( if (managedRetMarshaller.Generator.UsesNativeIdentifier(managedRetMarshaller.TypeInfo, this)) { // Update the native identifier for the return value - this.ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; + ReturnNativeIdentifier = $"{ReturnIdentifier}{GeneratedNativeIdentifierSuffix}"; } static IEnumerable GetInfoDependencies(TypePositionInfo info) @@ -214,7 +214,7 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) { var setupStatements = new List(); - foreach (var marshaller in paramMarshallers) + foreach (var marshaller in _paramMarshallers) { TypePositionInfo info = marshaller.TypeInfo; if (info.IsManagedReturnPosition) @@ -236,15 +236,15 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) AppendVariableDeclations(setupStatements, info, marshaller.Generator); } - bool invokeReturnsVoid = retMarshaller.TypeInfo.ManagedType == SpecialTypeInfo.Void; + bool invokeReturnsVoid = _retMarshaller.TypeInfo.ManagedType == SpecialTypeInfo.Void; // Stub return is not the same as invoke return - if (!stubReturnsVoid && !retMarshaller.TypeInfo.IsManagedReturnPosition) + if (!_stubReturnsVoid && !_retMarshaller.TypeInfo.IsManagedReturnPosition) { // Stub return should be the last parameter for the invoke - Debug.Assert(paramMarshallers.Any() && paramMarshallers.Last().TypeInfo.IsManagedReturnPosition, "Expected stub return to be the last parameter for the invoke"); + Debug.Assert(_paramMarshallers.Any() && _paramMarshallers.Last().TypeInfo.IsManagedReturnPosition, "Expected stub return to be the last parameter for the invoke"); - (TypePositionInfo stubRetTypeInfo, IMarshallingGenerator stubRetGenerator) = paramMarshallers.Last(); + (TypePositionInfo stubRetTypeInfo, IMarshallingGenerator stubRetGenerator) = _paramMarshallers.Last(); // Declare variables for stub return value AppendVariableDeclations(setupStatements, stubRetTypeInfo, stubRetGenerator); @@ -253,12 +253,12 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) if (!invokeReturnsVoid) { // Declare variables for invoke return value - AppendVariableDeclations(setupStatements, retMarshaller.TypeInfo, retMarshaller.Generator); + AppendVariableDeclations(setupStatements, _retMarshaller.TypeInfo, _retMarshaller.Generator); } // Do not manually handle SetLastError when generating forwarders. // We want the runtime to handle everything. - if (this.setLastError) + if (_setLastError) { // Declare variable for last error setupStatements.Add(MarshallerHelpers.DeclareWithDefault( @@ -304,7 +304,7 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) allStatements.AddRange(tryStatements); } - if (this.setLastError) + if (_setLastError) { // Marshal.SetLastPInvokeError(); allStatements.Add(ExpressionStatement( @@ -318,7 +318,7 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) } // Return - if (!stubReturnsVoid) + if (!_stubReturnsVoid) allStatements.Add(ReturnStatement(IdentifierName(ReturnIdentifier))); // Wrap all statements in an unsafe block @@ -327,11 +327,11 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) void GenerateStatementsForStage(Stage stage, List statementsToUpdate) { int initialCount = statementsToUpdate.Count; - this.CurrentStage = stage; + CurrentStage = stage; if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Cleanup)) { - var retStatements = retMarshaller.Generator.Generate(retMarshaller.TypeInfo, this); + var retStatements = _retMarshaller.Generator.Generate(_retMarshaller.TypeInfo, this); statementsToUpdate.AddRange(retStatements); } @@ -340,7 +340,7 @@ void GenerateStatementsForStage(Stage stage, List statementsToU // For Unmarshal and GuaranteedUnmarshal stages, use the topologically sorted // marshaller list to generate the marshalling statements - foreach (var marshaller in sortedMarshallers) + foreach (var marshaller in _sortedMarshallers) { statementsToUpdate.AddRange(marshaller.Generator.Generate(marshaller.TypeInfo, this)); } @@ -348,7 +348,7 @@ void GenerateStatementsForStage(Stage stage, List statementsToU else { // Generate code for each parameter for the current stage in declaration order. - foreach (var marshaller in paramMarshallers) + foreach (var marshaller in _paramMarshallers) { var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); statementsToUpdate.AddRange(generatedStatements); @@ -371,9 +371,9 @@ void GenerateStatementsForStage(Stage stage, List statementsToU void GenerateStatementsForInvoke(List statementsToUpdate, InvocationExpressionSyntax invoke) { var fixedStatements = new List(); - this.CurrentStage = Stage.Pin; + CurrentStage = Stage.Pin; // Generate code for each parameter for the current stage - foreach (var marshaller in paramMarshallers) + foreach (var marshaller in _paramMarshallers) { var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); // Collect all the fixed statements. These will be used in the Invoke stage. @@ -386,9 +386,9 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc } } - this.CurrentStage = Stage.Invoke; + CurrentStage = Stage.Invoke; // Generate code for each parameter for the current stage - foreach (var marshaller in paramMarshallers) + foreach (var marshaller in _paramMarshallers) { // Get arguments for invocation ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, this); @@ -406,13 +406,13 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc invokeStatement = ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, - IdentifierName(this.GetIdentifiers(retMarshaller.TypeInfo).native), + IdentifierName(GetIdentifiers(_retMarshaller.TypeInfo).native), invoke)); } // Do not manually handle SetLastError when generating forwarders. // We want the runtime to handle everything. - if (setLastError) + if (_setLastError) { // Marshal.SetLastSystemError(0); var clearLastError = ExpressionStatement( @@ -464,17 +464,17 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc return ( ParameterList( SeparatedList( - paramMarshallers.Select(marshaler => marshaler.Generator.AsParameter(marshaler.TypeInfo)))), - retMarshaller.Generator.AsNativeType(retMarshaller.TypeInfo), - retMarshaller.Generator is IAttributedReturnTypeMarshallingGenerator attributedReturn - ? attributedReturn.GenerateAttributesForReturnType(retMarshaller.TypeInfo) + _paramMarshallers.Select(marshaler => marshaler.Generator.AsParameter(marshaler.TypeInfo)))), + _retMarshaller.Generator.AsNativeType(_retMarshaller.TypeInfo), + _retMarshaller.Generator is IAttributedReturnTypeMarshallingGenerator attributedReturn + ? attributedReturn.GenerateAttributesForReturnType(_retMarshaller.TypeInfo) : null ); } private void AppendVariableDeclations(List statementsToUpdate, TypePositionInfo info, IMarshallingGenerator generator) { - var (managed, native) = this.GetIdentifiers(info); + var (managed, native) = GetIdentifiers(info); // Declare variable for return value if (info.IsManagedReturnPosition || info.IsNativeReturnPosition) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs index 01d8d2f45e921..82eb6f3f2686f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs @@ -15,7 +15,7 @@ namespace Microsoft.Interop { internal sealed class ContiguousCollectionElementMarshallingCodeContext : StubCodeContext { - private readonly string nativeSpanIdentifier; + private readonly string _nativeSpanIdentifier; public override bool SingleFrameSpansNativeContext => false; @@ -37,7 +37,7 @@ public ContiguousCollectionElementMarshallingCodeContext( { CurrentStage = currentStage; IndexerIdentifier = CalculateIndexerIdentifierBasedOnParentContext(parentContext); - this.nativeSpanIdentifier = nativeSpanIdentifier; + _nativeSpanIdentifier = nativeSpanIdentifier; ParentContext = parentContext; } @@ -51,13 +51,13 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo var (_, native) = ParentContext!.GetIdentifiers(info); return ( $"{native}.ManagedValues[{IndexerIdentifier}]", - $"{nativeSpanIdentifier}[{IndexerIdentifier}]" + $"{_nativeSpanIdentifier}[{IndexerIdentifier}]" ); } public override string GetAdditionalIdentifier(TypePositionInfo info, string name) { - return $"{nativeSpanIdentifier}__{IndexerIdentifier}__{name}"; + return $"{_nativeSpanIdentifier}__{IndexerIdentifier}__{name}"; } private static string CalculateIndexerIdentifierBasedOnParentContext(StubCodeContext? parentContext) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs index 4abeef8a7b1c3..0f983ddc28671 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/LanguageSupport.cs @@ -7,5 +7,5 @@ namespace System.Runtime.CompilerServices { // Define IsExternalInit type to support records. internal class IsExternalInit - {} + { } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs index e3a0406870d58..503cae185ec9d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs @@ -127,11 +127,11 @@ public static bool HasSetUnmarshalledCollectionLengthMethod(ITypeSymbol type) return type.GetMembers(SetUnmarshalledCollectionLengthMethodName) .OfType() .Any(m => m is - { - IsStatic: false, - Parameters: { Length: 1 }, - ReturnType: { SpecialType: SpecialType.System_Void } - } && m.Parameters[0].Type.SpecialType == SpecialType.System_Int32); + { + IsStatic: false, + Parameters: { Length: 1 }, + ReturnType: { SpecialType: SpecialType.System_Void } + } && m.Parameters[0].Type.SpecialType == SpecialType.System_Int32); } public static bool HasNativeValueStorageProperty(ITypeSymbol type, ITypeSymbol spanOfByte) @@ -139,7 +139,7 @@ public static bool HasNativeValueStorageProperty(ITypeSymbol type, ITypeSymbol s return type .GetMembers(NativeValueStoragePropertyName) .OfType() - .Any(p => p is {IsStatic: false, GetMethod: not null, ReturnsByRef: false, ReturnsByRefReadonly: false } + .Any(p => p is { IsStatic: false, GetMethod: not null, ReturnsByRef: false, ReturnsByRefReadonly: false } && SymbolEqualityComparer.Default.Equals(p.Type, spanOfByte)); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs index 566c81dd550bd..b9319b751febb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs @@ -11,17 +11,17 @@ namespace Microsoft.Interop { public sealed class ArrayMarshaller : IMarshallingGenerator { - private readonly IMarshallingGenerator manualMarshallingGenerator; - private readonly TypeSyntax elementType; - private readonly bool enablePinning; - private readonly InteropGenerationOptions options; + private readonly IMarshallingGenerator _manualMarshallingGenerator; + private readonly TypeSyntax _elementType; + private readonly bool _enablePinning; + private readonly InteropGenerationOptions _options; public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning, InteropGenerationOptions options) { - this.manualMarshallingGenerator = manualMarshallingGenerator; - this.elementType = elementType; - this.enablePinning = enablePinning; - this.options = options; + _manualMarshallingGenerator = manualMarshallingGenerator; + _elementType = elementType; + _enablePinning = enablePinning; + _options = options; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -31,17 +31,17 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) string identifier = context.GetIdentifiers(info).native; return Argument(CastExpression(AsNativeType(info), IdentifierName(identifier))); } - return manualMarshallingGenerator.AsArgument(info, context); + return _manualMarshallingGenerator.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return manualMarshallingGenerator.AsNativeType(info); + return _manualMarshallingGenerator.AsNativeType(info); } public ParameterSyntax AsParameter(TypePositionInfo info) { - return manualMarshallingGenerator.AsParameter(info); + return _manualMarshallingGenerator.AsParameter(info); } public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) @@ -50,12 +50,12 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont { return GeneratePinningPath(info, context); } - return manualMarshallingGenerator.Generate(info, context); + return _manualMarshallingGenerator.Generate(info, context); } public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) { - if (context.SingleFrameSpansNativeContext && enablePinning) + if (context.SingleFrameSpansNativeContext && _enablePinning) { return false; } @@ -68,19 +68,19 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { return false; } - return manualMarshallingGenerator.UsesNativeIdentifier(info, context); + return _manualMarshallingGenerator.UsesNativeIdentifier(info, context); } private bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) { - return context.SingleFrameSpansNativeContext && enablePinning && !info.IsByRef && !info.IsManagedReturnPosition; + return context.SingleFrameSpansNativeContext && _enablePinning && !info.IsByRef && !info.IsManagedReturnPosition; } private IEnumerable GeneratePinningPath(TypePositionInfo info, StubCodeContext context) { var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); string byRefIdentifier = $"__byref_{managedIdentifer}"; - TypeSyntax arrayElementType = elementType; + TypeSyntax arrayElementType = _elementType; if (context.CurrentStage == StubCodeContext.Stage.Marshal) { // [COMPAT] We use explicit byref calculations here instead of just using a fixed statement @@ -133,7 +133,7 @@ private IEnumerable GeneratePinningPath(TypePositionInfo info, PrefixUnaryExpression(SyntaxKind.AddressOfExpression, InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName(TypeNames.Unsafe(options)), + ParseTypeName(TypeNames.Unsafe(_options)), GenericName("As").AddTypeArgumentListArguments( arrayElementType, PredefinedType(Token(SyntaxKind.ByteKeyword))))) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs index 277fbe6d6d31f..8a8aae6fca7ad 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs @@ -14,15 +14,15 @@ namespace Microsoft.Interop { public class AttributedMarshallingModelGeneratorFactory : IMarshallingGeneratorFactory { - private static readonly BlittableMarshaller Blittable = new BlittableMarshaller(); - private static readonly Forwarder Forwarder = new Forwarder(); + private static readonly BlittableMarshaller s_blittable = new BlittableMarshaller(); + private static readonly Forwarder s_forwarder = new Forwarder(); - private readonly IMarshallingGeneratorFactory innerMarshallingGenerator; + private readonly IMarshallingGeneratorFactory _innerMarshallingGenerator; public AttributedMarshallingModelGeneratorFactory(IMarshallingGeneratorFactory innerMarshallingGenerator, InteropGenerationOptions options) { Options = options; - this.innerMarshallingGenerator = innerMarshallingGenerator; + _innerMarshallingGenerator = innerMarshallingGenerator; ElementMarshallingGeneratorFactory = this; } @@ -39,9 +39,9 @@ public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext conte return info.MarshallingAttributeInfo switch { NativeMarshallingAttributeInfo marshalInfo => CreateCustomNativeTypeMarshaller(info, context, marshalInfo), - BlittableTypeAttributeInfo => Blittable, - GeneratedNativeMarshallingAttributeInfo => Forwarder, - _ => innerMarshallingGenerator.Create(info, context) + BlittableTypeAttributeInfo => s_blittable, + GeneratedNativeMarshallingAttributeInfo => s_forwarder, + _ => _innerMarshallingGenerator.Create(info, context) }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs index 909b261f886c3..1d36a8789c925 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs @@ -12,16 +12,16 @@ namespace Microsoft.Interop /// public class ByValueContentsMarshalKindValidator : IMarshallingGeneratorFactory { - private readonly IMarshallingGeneratorFactory inner; + private readonly IMarshallingGeneratorFactory _inner; public ByValueContentsMarshalKindValidator(IMarshallingGeneratorFactory inner) { - this.inner = inner; + _inner = inner; } public IMarshallingGenerator Create(TypePositionInfo info, StubCodeContext context) { - return ValidateByValueMarshalKind(info, context, inner.Create(info, context)); + return ValidateByValueMarshalKind(info, context, _inner.Create(info, context)); } private static IMarshallingGenerator ValidateByValueMarshalKind(TypePositionInfo info, StubCodeContext context, IMarshallingGenerator generator) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index fe77d1aba9266..466b715e80c6a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -14,7 +14,7 @@ namespace Microsoft.Interop { public sealed class Utf16CharMarshaller : IMarshallingGenerator { - private static readonly PredefinedTypeSyntax NativeType = PredefinedType(Token(SyntaxKind.UShortKeyword)); + private static readonly PredefinedTypeSyntax s_nativeType = PredefinedType(Token(SyntaxKind.UShortKeyword)); public Utf16CharMarshaller() { @@ -50,7 +50,7 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) public TypeSyntax AsNativeType(TypePositionInfo info) { Debug.Assert(info.ManagedType is SpecialTypeInfo(_, _, SpecialType.System_Char)); - return NativeType; + return s_nativeType; } public ParameterSyntax AsParameter(TypePositionInfo info) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs index 0859c4bf54d96..d114c9092aaa7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs @@ -14,23 +14,23 @@ namespace Microsoft.Interop /// internal sealed class CustomNativeTypeMarshallingGenerator : IMarshallingGenerator { - private readonly ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller; - private readonly bool enableByValueContentsMarshalling; + private readonly ICustomNativeTypeMarshallingStrategy _nativeTypeMarshaller; + private readonly bool _enableByValueContentsMarshalling; public CustomNativeTypeMarshallingGenerator(ICustomNativeTypeMarshallingStrategy nativeTypeMarshaller, bool enableByValueContentsMarshalling) { - this.nativeTypeMarshaller = nativeTypeMarshaller; - this.enableByValueContentsMarshalling = enableByValueContentsMarshalling; + _nativeTypeMarshaller = nativeTypeMarshaller; + _enableByValueContentsMarshalling = enableByValueContentsMarshalling; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - return nativeTypeMarshaller.AsArgument(info, context); + return _nativeTypeMarshaller.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return nativeTypeMarshaller.AsNativeType(info); + return _nativeTypeMarshaller.AsNativeType(info); } public ParameterSyntax AsParameter(TypePositionInfo info) @@ -49,28 +49,28 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - return nativeTypeMarshaller.GenerateSetupStatements(info, context); + return _nativeTypeMarshaller.GenerateSetupStatements(info, context); case StubCodeContext.Stage.Marshal: if (!info.IsManagedReturnPosition && info.RefKind != RefKind.Out) { - return nativeTypeMarshaller.GenerateMarshalStatements(info, context, nativeTypeMarshaller.GetNativeTypeConstructorArguments(info, context)); + return _nativeTypeMarshaller.GenerateMarshalStatements(info, context, _nativeTypeMarshaller.GetNativeTypeConstructorArguments(info, context)); } break; case StubCodeContext.Stage.Pin: if (!info.IsByRef || info.RefKind == RefKind.In) { - return nativeTypeMarshaller.GeneratePinStatements(info, context); + return _nativeTypeMarshaller.GeneratePinStatements(info, context); } break; case StubCodeContext.Stage.Unmarshal: if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In) - || (enableByValueContentsMarshalling && !info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out))) + || (_enableByValueContentsMarshalling && !info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out))) { - return nativeTypeMarshaller.GenerateUnmarshalStatements(info, context); + return _nativeTypeMarshaller.GenerateUnmarshalStatements(info, context); } break; case StubCodeContext.Stage.Cleanup: - return nativeTypeMarshaller.GenerateCleanupStatements(info, context); + return _nativeTypeMarshaller.GenerateCleanupStatements(info, context); default: break; } @@ -80,12 +80,12 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) { - return enableByValueContentsMarshalling; + return _enableByValueContentsMarshalling; } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return nativeTypeMarshaller.UsesNativeIdentifier(info, context); + return _nativeTypeMarshaller.UsesNativeIdentifier(info, context); } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs index 4ef59de028a48..fd4ca6a37ae62 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs @@ -41,13 +41,13 @@ private bool TryRehydrateMarshalAsAttribute(TypePositionInfo info, out Attribute && collectionMarshalling.ElementMarshallingInfo is NoMarshallingInfo or MarshalAsInfo { UnmanagedType: not UnmanagedType.CustomMarshaler } && info.ManagedType is IArrayTypeSymbol) { - List marshalAsArguments = new List(); - marshalAsArguments.Add( + List marshalAsArguments = new List + { AttributeArgument( CastExpression(ParseTypeName(TypeNames.System_Runtime_InteropServices_UnmanagedType), LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal((int)UnmanagedType.LPArray)))) - ); + }; if (collectionMarshalling.ElementCountInfo is SizeAndParamIndexInfo countInfo) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs index 2b97467a8fd6a..446750e2bc5ca 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs @@ -14,12 +14,12 @@ namespace Microsoft.Interop { public sealed class HResultExceptionMarshaller : IMarshallingGenerator { - private static readonly TypeSyntax NativeType = PredefinedType(Token(SyntaxKind.IntKeyword)); + private static readonly TypeSyntax s_nativeType = PredefinedType(Token(SyntaxKind.IntKeyword)); public TypeSyntax AsNativeType(TypePositionInfo info) { Debug.Assert(info.ManagedType is SpecialTypeInfo(_, _, SpecialType.System_Int32)); - return NativeType; + return s_nativeType; } // Should only be used for return value diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs index 917a2a55cf735..87e25faf55445 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -41,11 +41,11 @@ internal interface ICustomNativeTypeMarshallingStrategy /// internal sealed class SimpleCustomNativeTypeMarshalling : ICustomNativeTypeMarshallingStrategy { - private readonly TypeSyntax nativeTypeSyntax; + private readonly TypeSyntax _nativeTypeSyntax; public SimpleCustomNativeTypeMarshalling(TypeSyntax nativeTypeSyntax) { - this.nativeTypeSyntax = nativeTypeSyntax; + _nativeTypeSyntax = nativeTypeSyntax; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -64,7 +64,7 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) public TypeSyntax AsNativeType(TypePositionInfo info) { - return nativeTypeSyntax; + return _nativeTypeSyntax; } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) @@ -151,13 +151,13 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo /// internal sealed class CustomNativeTypeWithValuePropertyMarshalling : ICustomNativeTypeMarshallingStrategy { - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; - private readonly TypeSyntax valuePropertyType; + private readonly ICustomNativeTypeMarshallingStrategy _innerMarshaller; + private readonly TypeSyntax _valuePropertyType; public CustomNativeTypeWithValuePropertyMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, TypeSyntax valuePropertyType) { - this.innerMarshaller = innerMarshaller; - this.valuePropertyType = valuePropertyType; + _innerMarshaller = innerMarshaller; + _valuePropertyType = valuePropertyType; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -176,7 +176,7 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) public TypeSyntax AsNativeType(TypePositionInfo info) { - return valuePropertyType; + return _valuePropertyType; } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) @@ -196,7 +196,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i yield return GenerateValuePropertyAssignment(info, context, subContext); } - foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, subContext)) + foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, subContext)) { yield return statement; } @@ -205,7 +205,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) + foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) { yield return statement; } @@ -238,7 +238,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo yield return GenerateValuePropertyAssignment(info, context, subContext); - foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, subContext)) + foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext)) { yield return statement; } @@ -247,7 +247,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - return innerMarshaller.GetNativeTypeConstructorArguments(info, subContext); + return _innerMarshaller.GetNativeTypeConstructorArguments(info, subContext); } public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) @@ -255,12 +255,12 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); yield return LocalDeclarationStatement( VariableDeclaration( - innerMarshaller.AsNativeType(info), + _innerMarshaller.AsNativeType(info), SingletonSeparatedList( VariableDeclarator(subContext.GetIdentifiers(info).native) .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); - foreach (var statement in innerMarshaller.GenerateSetupStatements(info, subContext)) + foreach (var statement in _innerMarshaller.GenerateSetupStatements(info, subContext)) { yield return statement; } @@ -269,7 +269,7 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - return innerMarshaller.GeneratePinStatements(info, subContext); + return _innerMarshaller.GeneratePinStatements(info, subContext); } } @@ -278,26 +278,26 @@ public IEnumerable GeneratePinStatements(TypePositionInfo info, /// internal sealed class StackallocOptimizationMarshalling : ICustomNativeTypeMarshallingStrategy { - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + private readonly ICustomNativeTypeMarshallingStrategy _innerMarshaller; public StackallocOptimizationMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller) { - this.innerMarshaller = innerMarshaller; + _innerMarshaller = innerMarshaller; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.AsArgument(info, context); + return _innerMarshaller.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return innerMarshaller.AsNativeType(info); + return _innerMarshaller.AsNativeType(info); } public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateCleanupStatements(info, context); + return _innerMarshaller.GenerateCleanupStatements(info, context); } public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) @@ -321,7 +321,7 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i )))))))))); } - foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) { yield return statement; } @@ -339,22 +339,22 @@ private static string GetStackAllocPointerIdentifier(TypePositionInfo info, Stub public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GeneratePinStatements(info, context); + return _innerMarshaller.GeneratePinStatements(info, context); } public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateSetupStatements(info, context); + return _innerMarshaller.GenerateSetupStatements(info, context); } public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateUnmarshalStatements(info, context); + return _innerMarshaller.GenerateUnmarshalStatements(info, context); } public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - foreach (var arg in innerMarshaller.GetNativeTypeConstructorArguments(info, context)) + foreach (var arg in _innerMarshaller.GetNativeTypeConstructorArguments(info, context)) { yield return arg; } @@ -378,7 +378,7 @@ public IEnumerable GetNativeTypeConstructorArguments(TypePositio public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.UsesNativeIdentifier(info, context); + return _innerMarshaller.UsesNativeIdentifier(info, context); } } @@ -387,26 +387,26 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) /// internal sealed class FreeNativeCleanupStrategy : ICustomNativeTypeMarshallingStrategy { - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; + private readonly ICustomNativeTypeMarshallingStrategy _innerMarshaller; public FreeNativeCleanupStrategy(ICustomNativeTypeMarshallingStrategy innerMarshaller) { - this.innerMarshaller = innerMarshaller; + _innerMarshaller = innerMarshaller; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.AsArgument(info, context); + return _innerMarshaller.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return innerMarshaller.AsNativeType(info); + return _innerMarshaller.AsNativeType(info); } public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { - foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, context)) + foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, context)) { yield return statement; } @@ -421,32 +421,32 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { - return innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments); + return _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments); } public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GeneratePinStatements(info, context); + return _innerMarshaller.GeneratePinStatements(info, context); } public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateSetupStatements(info, context); + return _innerMarshaller.GenerateSetupStatements(info, context); } public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateUnmarshalStatements(info, context); + return _innerMarshaller.GenerateUnmarshalStatements(info, context); } public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + return _innerMarshaller.GetNativeTypeConstructorArguments(info, context); } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.UsesNativeIdentifier(info, context); + return _innerMarshaller.UsesNativeIdentifier(info, context); } } @@ -455,13 +455,13 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) /// internal sealed class PinnableMarshallerTypeMarshalling : ICustomNativeTypeMarshallingStrategy { - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; - private readonly TypeSyntax valuePropertyType; + private readonly ICustomNativeTypeMarshallingStrategy _innerMarshaller; + private readonly TypeSyntax _valuePropertyType; public PinnableMarshallerTypeMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, TypeSyntax valuePropertyType) { - this.innerMarshaller = innerMarshaller; - this.valuePropertyType = valuePropertyType; + _innerMarshaller = innerMarshaller; + _valuePropertyType = valuePropertyType; } private bool CanPinMarshaller(TypePositionInfo info, StubCodeContext context) @@ -471,12 +471,12 @@ private bool CanPinMarshaller(TypePositionInfo info, StubCodeContext context) public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.AsArgument(info, context); + return _innerMarshaller.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return valuePropertyType; + return _valuePropertyType; } public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) @@ -489,7 +489,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i yield return GenerateValuePropertyAssignment(info, context, subContext); } - foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, subContext)) + foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, subContext)) { yield return statement; } @@ -498,7 +498,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) + foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) { yield return statement; } @@ -522,7 +522,7 @@ public IEnumerable GeneratePinStatements(TypePositionInfo info, var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); yield return FixedStatement( VariableDeclaration( - valuePropertyType, + _valuePropertyType, SingletonSeparatedList( VariableDeclarator(context.GetIdentifiers(info).native) .WithInitializer(EqualsValueClause( @@ -540,12 +540,12 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); yield return LocalDeclarationStatement( VariableDeclaration( - innerMarshaller.AsNativeType(info), + _innerMarshaller.AsNativeType(info), SingletonSeparatedList( VariableDeclarator(subContext.GetIdentifiers(info).native) .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); - foreach (var statement in innerMarshaller.GenerateSetupStatements(info, subContext)) + foreach (var statement in _innerMarshaller.GenerateSetupStatements(info, subContext)) { yield return statement; } @@ -573,7 +573,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo yield return GenerateValuePropertyAssignment(info, context, subContext); } - foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, subContext)) + foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext)) { yield return statement; } @@ -582,7 +582,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - return innerMarshaller.GetNativeTypeConstructorArguments(info, subContext); + return _innerMarshaller.GetNativeTypeConstructorArguments(info, subContext); } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) @@ -591,7 +591,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { return false; } - return innerMarshaller.UsesNativeIdentifier(info, context); + return _innerMarshaller.UsesNativeIdentifier(info, context); } } @@ -600,25 +600,25 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) /// internal sealed class NumElementsExpressionMarshalling : ICustomNativeTypeMarshallingStrategy { - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; - private readonly ExpressionSyntax numElementsExpression; - private readonly ExpressionSyntax sizeOfElementExpression; + private readonly ICustomNativeTypeMarshallingStrategy _innerMarshaller; + private readonly ExpressionSyntax _numElementsExpression; + private readonly ExpressionSyntax _sizeOfElementExpression; public NumElementsExpressionMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, ExpressionSyntax numElementsExpression, ExpressionSyntax sizeOfElementExpression) { - this.innerMarshaller = innerMarshaller; - this.numElementsExpression = numElementsExpression; - this.sizeOfElementExpression = sizeOfElementExpression; + _innerMarshaller = innerMarshaller; + _numElementsExpression = numElementsExpression; + _sizeOfElementExpression = sizeOfElementExpression; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.AsArgument(info, context); + return _innerMarshaller.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return innerMarshaller.AsNativeType(info); + return _innerMarshaller.AsNativeType(info); } public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) @@ -634,7 +634,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i } } - foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, context)) + foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, context)) { yield return statement; } @@ -642,17 +642,17 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { - return innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments); + return _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments); } public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GeneratePinStatements(info, context); + return _innerMarshaller.GeneratePinStatements(info, context); } public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateSetupStatements(info, context); + return _innerMarshaller.GenerateSetupStatements(info, context); } private IEnumerable GenerateUnmarshallerCollectionInitialization(TypePositionInfo info, StubCodeContext context) @@ -662,7 +662,7 @@ private IEnumerable GenerateUnmarshallerCollectionInitializatio { yield return ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(marshalerIdentifier), - ImplicitObjectCreationExpression().AddArgumentListArguments(Argument(sizeOfElementExpression)))); + ImplicitObjectCreationExpression().AddArgumentListArguments(Argument(_sizeOfElementExpression)))); } if (info.IsByRef || !info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) @@ -673,7 +673,7 @@ private IEnumerable GenerateUnmarshallerCollectionInitializatio SyntaxKind.SimpleMemberAccessExpression, IdentifierName(marshalerIdentifier), IdentifierName(ManualTypeMarshallingHelper.SetUnmarshalledCollectionLengthMethodName))) - .AddArgumentListArguments(Argument(numElementsExpression))); + .AddArgumentListArguments(Argument(_numElementsExpression))); } } @@ -689,7 +689,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo yield return statement; } - foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) + foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) { yield return statement; } @@ -697,16 +697,16 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - foreach (var arg in innerMarshaller.GetNativeTypeConstructorArguments(info, context)) + foreach (var arg in _innerMarshaller.GetNativeTypeConstructorArguments(info, context)) { yield return arg; } - yield return Argument(sizeOfElementExpression); + yield return Argument(_sizeOfElementExpression); } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.UsesNativeIdentifier(info, context); + return _innerMarshaller.UsesNativeIdentifier(info, context); } } @@ -715,34 +715,34 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) /// internal sealed class ContiguousBlittableElementCollectionMarshalling : ICustomNativeTypeMarshallingStrategy { - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; - private readonly TypeSyntax elementType; + private readonly ICustomNativeTypeMarshallingStrategy _innerMarshaller; + private readonly TypeSyntax _elementType; public ContiguousBlittableElementCollectionMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, TypeSyntax elementType) { - this.innerMarshaller = innerMarshaller; - this.elementType = elementType; + _innerMarshaller = innerMarshaller; + _elementType = elementType; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.AsArgument(info, context); + return _innerMarshaller.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return innerMarshaller.AsNativeType(info); + return _innerMarshaller.AsNativeType(info); } public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateCleanupStatements(info, context); + return _innerMarshaller.GenerateCleanupStatements(info, context); } public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { string nativeIdentifier = context.GetIdentifiers(info).native; - foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) { yield return statement; } @@ -777,7 +777,7 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i new[] { PredefinedType(Token(SyntaxKind.ByteKeyword)), - elementType + _elementType }))))) .AddArgumentListArguments( Argument( @@ -789,12 +789,12 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GeneratePinStatements(info, context); + return _innerMarshaller.GeneratePinStatements(info, context); } public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateSetupStatements(info, context); + return _innerMarshaller.GenerateSetupStatements(info, context); } public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) @@ -817,7 +817,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo new[] { PredefinedType(Token(SyntaxKind.ByteKeyword)), - elementType + _elementType }))))) .AddArgumentListArguments( Argument( @@ -833,7 +833,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo IdentifierName(nativeIdentifier), IdentifierName(ManualTypeMarshallingHelper.ManagedValuesPropertyName))))); - foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) + foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) { yield return statement; } @@ -841,12 +841,12 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + return _innerMarshaller.GetNativeTypeConstructorArguments(info, context); } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.UsesNativeIdentifier(info, context); + return _innerMarshaller.UsesNativeIdentifier(info, context); } } @@ -855,17 +855,17 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) /// internal sealed class ContiguousNonBlittableElementCollectionMarshalling : ICustomNativeTypeMarshallingStrategy { - private readonly ICustomNativeTypeMarshallingStrategy innerMarshaller; - private readonly IMarshallingGenerator elementMarshaller; - private readonly TypePositionInfo elementInfo; + private readonly ICustomNativeTypeMarshallingStrategy _innerMarshaller; + private readonly IMarshallingGenerator _elementMarshaller; + private readonly TypePositionInfo _elementInfo; public ContiguousNonBlittableElementCollectionMarshalling(ICustomNativeTypeMarshallingStrategy innerMarshaller, IMarshallingGenerator elementMarshaller, TypePositionInfo elementInfo) { - this.innerMarshaller = innerMarshaller; - this.elementMarshaller = elementMarshaller; - this.elementInfo = elementInfo; + _innerMarshaller = innerMarshaller; + _elementMarshaller = elementMarshaller; + _elementInfo = elementInfo; } private LocalDeclarationStatementSyntax GenerateNativeSpanDeclaration(TypePositionInfo info, StubCodeContext context) @@ -876,7 +876,7 @@ private LocalDeclarationStatementSyntax GenerateNativeSpanDeclaration(TypePositi GenericName( Identifier(TypeNames.System_Span), TypeArgumentList( - SingletonSeparatedList(elementMarshaller.AsNativeType(elementInfo).GetCompatibleGenericTypeParameterSyntax())) + SingletonSeparatedList(_elementMarshaller.AsNativeType(_elementInfo).GetCompatibleGenericTypeParameterSyntax())) ), SingletonSeparatedList( VariableDeclarator(Identifier(nativeSpanIdentifier)) @@ -893,7 +893,7 @@ private LocalDeclarationStatementSyntax GenerateNativeSpanDeclaration(TypePositi new[] { PredefinedType(Token(SyntaxKind.ByteKeyword)), - elementMarshaller.AsNativeType(elementInfo).GetCompatibleGenericTypeParameterSyntax() + _elementMarshaller.AsNativeType(_elementInfo).GetCompatibleGenericTypeParameterSyntax() }))))) .AddArgumentListArguments( Argument(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, @@ -918,7 +918,7 @@ private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo in ? $"{nativeIdentifier}.{ManualTypeMarshallingHelper.ManagedValuesPropertyName}" : nativeSpanIdentifier; - TypePositionInfo localElementInfo = elementInfo with + TypePositionInfo localElementInfo = _elementInfo with { InstanceIdentifier = info.InstanceIdentifier, RefKind = info.IsByRef ? info.RefKind : info.ByValueContentsMarshalKind.GetRefKindForByValueContentsKind(), @@ -926,15 +926,15 @@ private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo in NativeIndex = info.NativeIndex }; - List elementStatements = elementMarshaller.Generate(localElementInfo, elementSubContext).ToList(); + List elementStatements = _elementMarshaller.Generate(localElementInfo, elementSubContext).ToList(); if (elementStatements.Any()) { StatementSyntax marshallingStatement = Block( - List(elementMarshaller.Generate(localElementInfo, elementSetupSubContext) + List(_elementMarshaller.Generate(localElementInfo, elementSetupSubContext) .Concat(elementStatements))); - if (elementMarshaller.AsNativeType(elementInfo) is PointerTypeSyntax elementNativeType) + if (_elementMarshaller.AsNativeType(_elementInfo) is PointerTypeSyntax elementNativeType) { PointerNativeTypeAssignmentRewriter rewriter = new(elementSubContext.GetIdentifiers(localElementInfo).native, elementNativeType); marshallingStatement = (StatementSyntax)rewriter.Visit(marshallingStatement); @@ -951,18 +951,18 @@ private StatementSyntax GenerateContentsMarshallingStatement(TypePositionInfo in public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.AsArgument(info, context); + return _innerMarshaller.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return innerMarshaller.AsNativeType(info); + return _innerMarshaller.AsNativeType(info); } public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { yield return GenerateContentsMarshallingStatement(info, context, useManagedSpanForLength: false); - foreach (var statement in innerMarshaller.GenerateCleanupStatements(info, context)) + foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, context)) { yield return statement; } @@ -970,7 +970,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { - foreach (var statement in innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) { yield return statement; } @@ -986,18 +986,18 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i public IEnumerable GeneratePinStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GeneratePinStatements(info, context); + return _innerMarshaller.GeneratePinStatements(info, context); } public IEnumerable GenerateSetupStatements(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GenerateSetupStatements(info, context); + return _innerMarshaller.GenerateSetupStatements(info, context); } public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) { yield return GenerateContentsMarshallingStatement(info, context, useManagedSpanForLength: false); - foreach (var statement in innerMarshaller.GenerateUnmarshalStatements(info, context)) + foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) { yield return statement; } @@ -1005,12 +1005,12 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.GetNativeTypeConstructorArguments(info, context); + return _innerMarshaller.GetNativeTypeConstructorArguments(info, context); } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { - return innerMarshaller.UsesNativeIdentifier(info, context); + return _innerMarshaller.UsesNativeIdentifier(info, context); } /// @@ -1020,25 +1020,25 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) /// private class PointerNativeTypeAssignmentRewriter : CSharpSyntaxRewriter { - private readonly string nativeIdentifier; - private readonly PointerTypeSyntax nativeType; + private readonly string _nativeIdentifier; + private readonly PointerTypeSyntax _nativeType; public PointerNativeTypeAssignmentRewriter(string nativeIdentifier, PointerTypeSyntax nativeType) { - this.nativeIdentifier = nativeIdentifier; - this.nativeType = nativeType; + _nativeIdentifier = nativeIdentifier; + _nativeType = nativeType; } public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax node) { - if (node.Left.ToString() == nativeIdentifier) + if (node.Left.ToString() == _nativeIdentifier) { return node.WithRight( CastExpression(MarshallerHelpers.SystemIntPtrType, node.Right)); } - if (node.Right.ToString() == nativeIdentifier) + if (node.Right.ToString() == _nativeIdentifier) { - return node.WithRight(CastExpression(nativeType, node.Right)); + return node.WithRight(CastExpression(_nativeType, node.Right)); } return node; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index 1edc06838b6db..2adc953ce3c3a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -192,12 +192,12 @@ public static IEnumerable GetTopologicallySortedElements( private struct EdgeMap { - private readonly bool[] edgeMap; + private readonly bool[] _edgeMap; public EdgeMap(int numNodes) { NodeCount = numNodes; - edgeMap = new bool[NodeCount * NodeCount]; + _edgeMap = new bool[NodeCount * NodeCount]; } /// @@ -209,17 +209,17 @@ public EdgeMap(int numNodes) /// If there exists an edge that starts at and ends at public bool this[int to, int from] { - get => edgeMap[to * NodeCount + from]; - set => edgeMap[to * NodeCount + from] = value; + get => _edgeMap[to * NodeCount + from]; + set => _edgeMap[to * NodeCount + from] = value; } - public bool AnyEdges => Array.IndexOf(edgeMap, true) != -1; + public bool AnyEdges => Array.IndexOf(_edgeMap, true) != -1; public int NodeCount { get; } public bool AnyIncomingEdge(int to) { - return Array.IndexOf(edgeMap, true, to * NodeCount, NodeCount) != -1; + return Array.IndexOf(_edgeMap, true, to * NodeCount, NodeCount) != -1; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs index 8b412a89e5d96..74e7a517a4707 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs @@ -97,8 +97,8 @@ public sealed class MarshallingNotSupportedException : Exception /// instance public MarshallingNotSupportedException(TypePositionInfo info, StubCodeContext context) { - this.TypePositionInfo = info; - this.StubCodeContext = context; + TypePositionInfo = info; + StubCodeContext = context; } /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs index 6d17c99ae84e2..bc496a1982eb8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs @@ -27,25 +27,25 @@ public IMarshallingGenerator Create( public sealed class DefaultMarshallingGeneratorFactory : IMarshallingGeneratorFactory { - private static readonly ByteBoolMarshaller ByteBool = new(); - private static readonly WinBoolMarshaller WinBool = new(); - private static readonly VariantBoolMarshaller VariantBool = new(); - - private static readonly Utf16CharMarshaller Utf16Char = new(); - private static readonly Utf16StringMarshaller Utf16String = new(); - private static readonly Utf8StringMarshaller Utf8String = new(); - private static readonly AnsiStringMarshaller AnsiString = new AnsiStringMarshaller(Utf8String); - private static readonly PlatformDefinedStringMarshaller PlatformDefinedString = new PlatformDefinedStringMarshaller(Utf16String, Utf8String); - - private static readonly Forwarder Forwarder = new(); - private static readonly BlittableMarshaller Blittable = new(); - private static readonly DelegateMarshaller Delegate = new(); - private static readonly SafeHandleMarshaller SafeHandle = new(); + private static readonly ByteBoolMarshaller s_byteBool = new(); + private static readonly WinBoolMarshaller s_winBool = new(); + private static readonly VariantBoolMarshaller s_variantBool = new(); + + private static readonly Utf16CharMarshaller s_utf16Char = new(); + 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(); + private static readonly DelegateMarshaller s_delegate = new(); + private static readonly SafeHandleMarshaller s_safeHandle = new(); private InteropGenerationOptions Options { get; } public DefaultMarshallingGeneratorFactory(InteropGenerationOptions options) { - this.Options = options; + Options = options; } /// @@ -73,7 +73,7 @@ public IMarshallingGenerator Create( or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysUInt, _) } or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: - return Blittable; + return s_blittable; // Enum with no marshalling info case { ManagedType: EnumTypeInfo enumType, MarshallingAttributeInfo: NoMarshallingInfo }: @@ -83,27 +83,27 @@ public IMarshallingGenerator Create( { throw new MarshallingNotSupportedException(info, context); } - return Blittable; + return s_blittable; // Pointer with no marshalling info case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer: false), MarshallingAttributeInfo: NoMarshallingInfo }: - return Blittable; + return s_blittable; // Function pointer with no marshalling info case { ManagedType: PointerTypeInfo(_, _, IsFunctionPointer: true), MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: - return Blittable; + return s_blittable; case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: NoMarshallingInfo }: - return WinBool; // [Compat] Matching the default for the built-in runtime marshallers. + return s_winBool; // [Compat] Matching the default for the built-in runtime marshallers. case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1 or UnmanagedType.U1, _) }: - return ByteBool; + return s_byteBool; case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I4 or UnmanagedType.U4 or UnmanagedType.Bool, _) }: - return WinBool; + return s_winBool; case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: - return VariantBool; + return s_variantBool; case { ManagedType: DelegateTypeInfo, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: - return Delegate; + return s_delegate; case { MarshallingAttributeInfo: SafeHandleMarshallingInfo(_, bool isAbstract) }: if (!context.AdditionalTemporaryStateLivesAcrossStages) @@ -117,7 +117,7 @@ public IMarshallingGenerator Create( NotSupportedDetails = Resources.SafeHandleByRefMustBeConcrete }; } - return SafeHandle; + return s_safeHandle; case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Char } }: return CreateCharMarshaller(info, context); @@ -126,7 +126,7 @@ public IMarshallingGenerator Create( return CreateStringMarshaller(info, context); case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Void } }: - return Forwarder; + return s_forwarder; default: throw new MarshallingNotSupportedException(info, context); @@ -152,7 +152,7 @@ private IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCo { case UnmanagedType.I2: case UnmanagedType.U2: - return Utf16Char; + return s_utf16Char; } } else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) @@ -160,7 +160,7 @@ private IMarshallingGenerator CreateCharMarshaller(TypePositionInfo info, StubCo switch (marshalStringInfo.CharEncoding) { case CharEncoding.Utf16: - return Utf16Char; + return s_utf16Char; case CharEncoding.Ansi: throw new MarshallingNotSupportedException(info, context) // [Compat] ANSI is not supported for char { @@ -195,12 +195,12 @@ private IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, Stub switch (marshalAsInfo.UnmanagedType) { case UnmanagedType.LPStr: - return AnsiString; + return s_ansiString; case UnmanagedType.LPTStr: case UnmanagedType.LPWStr: - return Utf16String; + return s_utf16String; case (UnmanagedType)0x30:// UnmanagedType.LPUTF8Str - return Utf8String; + return s_utf8String; } } else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) @@ -208,13 +208,13 @@ private IMarshallingGenerator CreateStringMarshaller(TypePositionInfo info, Stub switch (marshalStringInfo.CharEncoding) { case CharEncoding.Ansi: - return AnsiString; + return s_ansiString; case CharEncoding.Utf16: - return Utf16String; + return s_utf16String; case CharEncoding.Utf8: - return Utf8String; + return s_utf8String; case CharEncoding.PlatformDefined: - return PlatformDefinedString; + return s_platformDefinedString; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs index 1ba665ed1a3e2..8a17dd5aeba3d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs @@ -10,11 +10,11 @@ namespace Microsoft.Interop { public sealed class PinnableManagedValueMarshaller : IMarshallingGenerator { - private readonly IMarshallingGenerator manualMarshallingGenerator; + private readonly IMarshallingGenerator _manualMarshallingGenerator; public PinnableManagedValueMarshaller(IMarshallingGenerator manualMarshallingGenerator) { - this.manualMarshallingGenerator = manualMarshallingGenerator; + _manualMarshallingGenerator = manualMarshallingGenerator; } public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -24,17 +24,17 @@ public ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) string identifier = context.GetIdentifiers(info).native; return Argument(CastExpression(AsNativeType(info), IdentifierName(identifier))); } - return manualMarshallingGenerator.AsArgument(info, context); + return _manualMarshallingGenerator.AsArgument(info, context); } public TypeSyntax AsNativeType(TypePositionInfo info) { - return manualMarshallingGenerator.AsNativeType(info); + return _manualMarshallingGenerator.AsNativeType(info); } public ParameterSyntax AsParameter(TypePositionInfo info) { - return manualMarshallingGenerator.AsParameter(info); + return _manualMarshallingGenerator.AsParameter(info); } public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) @@ -43,12 +43,12 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont { return GeneratePinningPath(info, context); } - return manualMarshallingGenerator.Generate(info, context); + return _manualMarshallingGenerator.Generate(info, context); } public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) { - return manualMarshallingGenerator.SupportsByValueMarshalKind(marshalKind, context); + return _manualMarshallingGenerator.SupportsByValueMarshalKind(marshalKind, context); } public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) @@ -57,7 +57,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) { return false; } - return manualMarshallingGenerator.UsesNativeIdentifier(info, context); + return _manualMarshallingGenerator.UsesNativeIdentifier(info, context); } private static bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs index 8809740b3e1dc..c26ea8467d866 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs @@ -14,13 +14,13 @@ namespace Microsoft.Interop { public sealed class AnsiStringMarshaller : ConditionalStackallocMarshallingGenerator { - private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); + private static readonly TypeSyntax s_nativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); - private readonly Utf8StringMarshaller utf8StringMarshaller; + private readonly Utf8StringMarshaller _utf8StringMarshaller; public AnsiStringMarshaller(Utf8StringMarshaller utf8StringMarshaller) { - this.utf8StringMarshaller = utf8StringMarshaller; + _utf8StringMarshaller = utf8StringMarshaller; } public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) @@ -42,7 +42,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext public override TypeSyntax AsNativeType(TypePositionInfo info) { // byte* - return NativeType; + return s_nativeType; } public override ParameterSyntax AsParameter(TypePositionInfo info) @@ -105,7 +105,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu yield return IfStatement(IsWindows, windowsBlock, ElseClause( - Block(this.utf8StringMarshaller.Generate(info, context)))); + Block(_utf8StringMarshaller.Generate(info, context)))); } break; case StubCodeContext.Stage.Unmarshal: @@ -140,7 +140,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu IdentifierName(nativeIdentifier))))), initializer: null))))), ElseClause( - Block(this.utf8StringMarshaller.Generate(info, context)))); + Block(_utf8StringMarshaller.Generate(info, context)))); } break; case StubCodeContext.Stage.Cleanup: 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 index 26f45d820757b..0b30170f1e0ec 100644 --- 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 @@ -15,21 +15,21 @@ namespace Microsoft.Interop { public sealed class PlatformDefinedStringMarshaller : ConditionalStackallocMarshallingGenerator { - private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))); + private static readonly TypeSyntax s_nativeType = PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))); - private readonly IMarshallingGenerator windowsMarshaller; - private readonly IMarshallingGenerator nonWindowsMarshaller; + private readonly IMarshallingGenerator _windowsMarshaller; + private readonly IMarshallingGenerator _nonWindowsMarshaller; public PlatformDefinedStringMarshaller(IMarshallingGenerator windowsMarshaller, IMarshallingGenerator nonWindowsMarshaller) { - this.windowsMarshaller = windowsMarshaller; - this.nonWindowsMarshaller = nonWindowsMarshaller; + _windowsMarshaller = windowsMarshaller; + _nonWindowsMarshaller = nonWindowsMarshaller; } public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - var windowsExpr = this.windowsMarshaller.AsArgument(info, context).Expression; - var nonWindowsExpr = this.nonWindowsMarshaller.AsArgument(info, context).Expression; + var windowsExpr = _windowsMarshaller.AsArgument(info, context).Expression; + var nonWindowsExpr = _nonWindowsMarshaller.AsArgument(info, context).Expression; // If the Windows and non-Windows syntax are equivalent, just return one of them. if (windowsExpr.IsEquivalentTo(nonWindowsExpr)) @@ -46,7 +46,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext public override TypeSyntax AsNativeType(TypePositionInfo info) { // void* - return NativeType; + return s_nativeType; } public override ParameterSyntax AsParameter(TypePositionInfo info) @@ -73,9 +73,9 @@ public override IEnumerable Generate(TypePositionInfo info, Stu case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) { - if (this.TryGetConditionalBlockForStatements( - this.windowsMarshaller.Generate(info, context), - this.nonWindowsMarshaller.Generate(info, context), + if (TryGetConditionalBlockForStatements( + _windowsMarshaller.Generate(info, context), + _nonWindowsMarshaller.Generate(info, context), out StatementSyntax marshal)) { yield return marshal; @@ -86,19 +86,19 @@ public override IEnumerable Generate(TypePositionInfo info, Stu // [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 (var s in this.windowsMarshaller.Generate(info, context)) + foreach (var s in _windowsMarshaller.Generate(info, context)) yield return s; - foreach (var s in this.nonWindowsMarshaller.Generate(info, context)) + foreach (var s in _nonWindowsMarshaller.Generate(info, context)) yield return s; break; case StubCodeContext.Stage.Unmarshal: if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In)) { - if (this.TryGetConditionalBlockForStatements( - this.windowsMarshaller.Generate(info, context), - this.nonWindowsMarshaller.Generate(info, context), + if (TryGetConditionalBlockForStatements( + _windowsMarshaller.Generate(info, context), + _nonWindowsMarshaller.Generate(info, context), out StatementSyntax unmarshal)) { yield return unmarshal; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs index 78733f1ce62e5..d374fbb77b892 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs @@ -18,7 +18,7 @@ public sealed class Utf16StringMarshaller : ConditionalStackallocMarshallingGene // so the threshold for optimized allocation is based on that length. private const int StackAllocBytesThreshold = 260 * sizeof(ushort); - private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.UShortKeyword))); + private static readonly TypeSyntax s_nativeType = PointerType(PredefinedType(Token(SyntaxKind.UShortKeyword))); private static string PinnedIdentifier(string nativeIdentifier) => $"{nativeIdentifier}__pinned"; @@ -49,7 +49,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext public override TypeSyntax AsNativeType(TypePositionInfo info) { // ushort* - return NativeType; + return s_nativeType; } public override ParameterSyntax AsParameter(TypePositionInfo info) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs index c5c9b4eda1a96..9afc473842cf6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs @@ -26,8 +26,8 @@ public sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGener // maximum number of bytes per 'char' is 3. private const int MaxByteCountPerChar = 3; - private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); - private static readonly TypeSyntax UTF8EncodingType = ParseTypeName("System.Text.Encoding.UTF8"); + private static readonly TypeSyntax s_nativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword))); + private static readonly TypeSyntax s_utf8EncodingType = ParseTypeName("System.Text.Encoding.UTF8"); public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { @@ -43,7 +43,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext return Argument(IdentifierName(identifier)); } - public override TypeSyntax AsNativeType(TypePositionInfo info) => NativeType; + public override TypeSyntax AsNativeType(TypePositionInfo info) => s_nativeType; public override ParameterSyntax AsParameter(TypePositionInfo info) { @@ -155,7 +155,7 @@ protected override StatementSyntax GenerateStackallocOnlyValueMarshalling( InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - UTF8EncodingType, + s_utf8EncodingType, IdentifierName("GetBytes")), ArgumentList( SeparatedList(new ArgumentSyntax[] { 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 30cea9d1bfd94..139e7abe11487 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 @@ -28,7 +28,7 @@ public abstract record MarshallingInfo // Add a constructor that can only be called by derived types in the same assembly // to enforce that this type cannot be extended by users of this library. private protected MarshallingInfo() - {} + { } } public sealed record NoMarshallingInfo : MarshallingInfo @@ -87,7 +87,7 @@ public enum CustomMarshallingFeatures public abstract record CountInfo { - private protected CountInfo() {} + private protected CountInfo() { } } public sealed record NoCountInfo : CountInfo @@ -449,8 +449,8 @@ private MarshallingInfo CreateInfoFromMarshalAs( ref int maxIndirectionLevelUsed) { object unmanagedTypeObj = attrData.ConstructorArguments[0].Value!; - UnmanagedType unmanagedType = unmanagedTypeObj is short - ? (UnmanagedType)(short)unmanagedTypeObj + UnmanagedType unmanagedType = unmanagedTypeObj is short unmanagedTypeAsShort + ? (UnmanagedType)unmanagedTypeAsShort : (UnmanagedType)unmanagedTypeObj; if (!Enum.IsDefined(typeof(UnmanagedType), unmanagedType) || unmanagedType == UnmanagedType.CustomMarshaler diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs index 5195372bc63c6..baa8c150fda06 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs @@ -57,8 +57,8 @@ public sealed record TypePositionInfo(ManagedTypeInfo ManagedType, MarshallingIn public ByValueContentsMarshalKind ByValueContentsMarshalKind { get; init; } - public bool IsManagedReturnPosition { get => this.ManagedIndex == ReturnIndex; } - public bool IsNativeReturnPosition { get => this.NativeIndex == ReturnIndex; } + public bool IsManagedReturnPosition { get => ManagedIndex == ReturnIndex; } + public bool IsNativeReturnPosition { get => NativeIndex == ReturnIndex; } public int ManagedIndex { get; init; } = UnsetIndex; public int NativeIndex { get; init; } = UnsetIndex; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs index 37eb22079edca..051c65e837283 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs @@ -56,23 +56,23 @@ private static bool HasOnlyBlittableFields(this ITypeSymbol type, ImmutableHashS } private static bool IsSpecialTypeBlittable(SpecialType specialType) - => specialType switch - { - SpecialType.System_Void - or SpecialType.System_SByte - or SpecialType.System_Byte - or SpecialType.System_Int16 - or SpecialType.System_UInt16 - or SpecialType.System_Int32 - or SpecialType.System_UInt32 - or SpecialType.System_Int64 - or SpecialType.System_UInt64 - or SpecialType.System_Single - or SpecialType.System_Double - or SpecialType.System_IntPtr - or SpecialType.System_UIntPtr => true, - _ => false - }; + => specialType switch + { + SpecialType.System_Void + or SpecialType.System_SByte + or SpecialType.System_Byte + or SpecialType.System_Int16 + or SpecialType.System_UInt16 + or SpecialType.System_Int32 + or SpecialType.System_UInt32 + or SpecialType.System_Int64 + or SpecialType.System_UInt64 + or SpecialType.System_Single + or SpecialType.System_Double + or SpecialType.System_IntPtr + or SpecialType.System_UIntPtr => true, + _ => false + }; public static bool IsConsideredBlittable(this ITypeSymbol type) => IsConsideredBlittable(type, ImmutableHashSet.Create(SymbolEqualityComparer.Default)); From c97c4dfdb4fc0753ab5aecfdb0873480d25e78c9 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 1 Oct 2021 15:50:04 -0700 Subject: [PATCH 152/161] Change some P/Invokes back to non-blittable + GeneratedDllImport for better usability (#59876) --- .../Common/src/Interop/OSX/Interop.RunLoop.cs | 4 +-- .../OSX/Interop.SystemConfiguration.cs | 4 +-- .../Interop.X509.cs | 14 ++------ ...nterop.ConfigureTerminalForChildProcess.cs | 4 +-- .../Interop.IPPacketInformation.cs | 4 +-- ...terop.NetSecurityNative.IsNtlmInstalled.cs | 4 +-- .../Interop.BIO.cs | 5 +-- .../Interop.Dsa.cs | 5 +-- .../Interop.ERR.cs | 34 ++++++++----------- .../Interop.EcKey.cs | 5 +-- .../Interop.X509.cs | 5 +-- .../Interop.AllocateLocallyUniqueId.cs | 4 +-- .../IpHlpApi/Interop.NetworkInformation.cs | 16 ++++----- .../Windows/User32/Interop.EnumWindows.cs | 2 +- .../Win32/SafeHandles/GssSafeHandles.cs | 2 +- .../Win32/SafeHandles/SafeBioHandle.Unix.cs | 2 +- .../Win32/SafeHandles/SafeDsaHandle.Unix.cs | 2 +- .../Win32/SafeHandles/SafeEcKeyHandle.Unix.cs | 2 +- .../System/Net/Capability.Security.Unix.cs | 2 +- ...ConfigureTerminalForChildProcesses.Unix.cs | 6 ++-- .../NetworkAddressChange.OSX.cs | 6 ++-- .../SystemIPGlobalProperties.cs | 16 ++++----- .../System.Net.Security.Tests.csproj | 1 + .../src/System/Net/Sockets/SocketPal.Unix.cs | 2 +- .../Pal.Unix/OpenSslX509CertificateReader.cs | 2 +- .../System.Security.Principal.Windows.csproj | 1 + .../Security/Principal/WindowsIdentity.cs | 2 +- 27 files changed, 75 insertions(+), 81 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs b/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs index e06862f7efe3a..6c662e6c3e68f 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.RunLoop.cs @@ -87,7 +87,7 @@ internal static partial class RunLoop /// waiting for a source or timer to become ready to fire; /// false if rl either is not running or is currently processing /// a source, timer, or observer. - [DllImport(Interop.Libraries.CoreFoundationLibrary)] - internal static extern int CFRunLoopIsWaiting(CFRunLoopRef rl); + [GeneratedDllImport(Interop.Libraries.CoreFoundationLibrary)] + internal static partial bool CFRunLoopIsWaiting(CFRunLoopRef rl); } } diff --git a/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs b/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs index ffe34c226aa1f..f0e4e471667e9 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.SystemConfiguration.cs @@ -126,7 +126,7 @@ internal static SafeCreateHandle SCDynamicStoreCreateRunLoopSource(SCDynamicStor /// An array of POSIX regex pattern strings used to match keys to be monitored, /// or IntPtr.Zero if no key patterns are to be monitored. /// Non-zero if the set of notification keys and patterns was successfully updated; zero otherwise. - [DllImport(Libraries.SystemConfigurationLibrary)] - internal static extern int SCDynamicStoreSetNotificationKeys(SCDynamicStoreRef store, CFArrayRef keys, CFArrayRef patterns); + [GeneratedDllImport(Libraries.SystemConfigurationLibrary)] + internal static partial bool SCDynamicStoreSetNotificationKeys(SCDynamicStoreRef store, CFArrayRef keys, CFArrayRef patterns); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs index 6f167de970b25..efb189b27662d 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.X509.cs @@ -29,18 +29,10 @@ private static partial int AppleCryptoNative_X509GetSubjectSummary( private static partial int AppleCryptoNative_X509GetPublicKey(SafeSecCertificateHandle cert, out SafeSecKeyRefHandle publicKey, out int pOSStatus); internal static X509ContentType X509GetContentType(ReadOnlySpan data) - { - unsafe - { - fixed (byte* dataPtr = &MemoryMarshal.GetReference(data)) - { - return X509GetContentType(dataPtr, data.Length); - } - } - } + => X509GetContentType(ref MemoryMarshal.GetReference(data), data.Length); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509GetContentType")] - private static unsafe extern X509ContentType X509GetContentType(byte* pbData, int cbData); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509GetContentType")] + private static partial X509ContentType X509GetContentType(ref byte pbData, int cbData); [GeneratedDllImport(Libraries.AppleCryptoNative)] private static partial int AppleCryptoNative_X509CopyCertFromIdentity( diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs index da8e47395d885..2c2318ea79710 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ConfigureTerminalForChildProcess.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConfigureTerminalForChildProcess")] - internal static extern void ConfigureTerminalForChildProcess(int childUsesTerminal); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConfigureTerminalForChildProcess")] + internal static partial void ConfigureTerminalForChildProcess(bool childUsesTerminal); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs index fe25a9eb5eeb6..37dab53c69365 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPPacketInformation.cs @@ -20,7 +20,7 @@ internal struct IPPacketInformation [SuppressGCTransition] internal static extern int GetControlMessageBufferSize(int isIPv4, int isIPv6); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_TryGetIPPacketInformation")] - internal static unsafe extern int TryGetIPPacketInformation(MessageHeader* messageHeader, int isIPv4, IPPacketInformation* packetInfo); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_TryGetIPPacketInformation")] + internal static unsafe partial bool TryGetIPPacketInformation(MessageHeader* messageHeader, bool isIPv4, IPPacketInformation* packetInfo); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs index e8d4dd6fb43ce..cae5d6ad0642c 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.IsNtlmInstalled.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class NetSecurityNative { - [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_IsNtlmInstalled")] - internal static extern int IsNtlmInstalled(); + [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_IsNtlmInstalled")] + internal static partial bool IsNtlmInstalled(); [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint = "NetSecurityNative_EnsureGssInitialized")] private static extern int EnsureGssInitialized(); 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 c972c12d4f08d..64c1be633986f 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 @@ -15,8 +15,9 @@ internal static partial class Crypto [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioNewFile", CharSet = CharSet.Ansi)] internal static partial SafeBioHandle BioNewFile(string filename, string mode); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioDestroy")] - internal static extern int BioDestroy(IntPtr a); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioDestroy")] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool BioDestroy(IntPtr a); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioGets")] internal static partial int BioGets(SafeBioHandle b, byte[] buf, int size); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs index 559fb650e0a3f..54d868ecc185c 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs @@ -11,8 +11,9 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaUpRef")] - internal static extern int DsaUpRef(IntPtr dsa); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaUpRef")] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool DsaUpRef(IntPtr dsa); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaDestroy")] internal static extern void DsaDestroy(IntPtr dsa); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs index 3f77618d3d5c9..c61707e71c3d8 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs @@ -13,8 +13,8 @@ internal static partial class Crypto [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrClearError")] internal static extern ulong ErrClearError(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrGetErrorAlloc")] - private static extern unsafe ulong ErrGetErrorAlloc(int* isAllocFailure); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrGetErrorAlloc")] + private static partial ulong ErrGetErrorAlloc([MarshalAs(UnmanagedType.Bool)] out bool isAllocFailure); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrPeekError")] internal static extern ulong ErrPeekError(); @@ -53,23 +53,19 @@ internal static Exception CreateOpenSslCryptographicException() // Windows code and the OpenSSL-calling code, drain the queue // whenever an Exception is desired, and report the exception // related to the last value in the queue. - int isAllocFailure = 0; - ulong error = 0; - unsafe + bool isAllocFailure; + ulong error = ErrGetErrorAlloc(out isAllocFailure); + ulong lastRead = error; + bool lastIsAllocFailure = isAllocFailure; + + // 0 (there's no named constant) is only returned when the calls + // to ERR_get_error exceed the calls to ERR_set_error. + while (lastRead != 0) { - int lastIsAllocFailure = isAllocFailure; - while (true) - { - ulong lastRead = ErrGetErrorAlloc(&lastIsAllocFailure); - - // 0 (there's no named constant) is only returned when the calls - // to ERR_get_error exceed the calls to ERR_set_error. - if (lastRead == 0) - break; - - error = lastRead; - isAllocFailure = lastIsAllocFailure; - } + error = lastRead; + isAllocFailure = lastIsAllocFailure; + + lastRead = ErrGetErrorAlloc(out lastIsAllocFailure); } // If we're in an error flow which results in an Exception, but @@ -80,7 +76,7 @@ internal static Exception CreateOpenSslCryptographicException() return new CryptographicException(); } - if (isAllocFailure != 0) + if (isAllocFailure) { return new OutOfMemoryException(); } 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 fa8b4f04a0d38..44cc49e07be94 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 @@ -30,8 +30,9 @@ internal static partial class Crypto [return: MarshalAs(UnmanagedType.Bool)] internal static partial bool EcKeyGenerateKey(SafeEcKeyHandle eckey); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyUpRef")] - internal static extern int EcKeyUpRef(IntPtr r); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyUpRef")] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool EcKeyUpRef(IntPtr r); [GeneratedDllImport(Libraries.CryptoNative)] private static partial int CryptoNative_EcKeyGetSize(SafeEcKeyHandle ecKey, out int keySize); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs index f3779453cc0b0..6e3775df4bf6a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs @@ -138,8 +138,9 @@ internal static SafeSharedAsn1OctetStringHandle X509FindExtensionData(SafeX509Ha [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionGetData")] internal static extern IntPtr X509ExtensionGetData(IntPtr ex); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionGetCritical")] - internal static extern int X509ExtensionGetCritical(IntPtr ex); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509ExtensionGetCritical")] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool X509ExtensionGetCritical(IntPtr ex); [GeneratedDllImport(Libraries.CryptoNative)] private static partial SafeX509StoreHandle CryptoNative_X509ChainNew(SafeX509StackHandle systemTrust, SafeX509StackHandle userTrust); diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs index 594464a5efc03..e587b759d45fd 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.AllocateLocallyUniqueId.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32)] - internal static unsafe extern int AllocateLocallyUniqueId(LUID* Luid); + [GeneratedDllImport(Libraries.Advapi32)] + internal static unsafe partial bool AllocateLocallyUniqueId(LUID* Luid); } } diff --git a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs index 5b4fe4ed49195..40d3df8e16079 100644 --- a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs @@ -537,18 +537,18 @@ internal static unsafe extern uint GetAdaptersAddresses( [DllImport(Interop.Libraries.IpHlpApi)] internal static extern uint GetIcmpStatisticsEx(out MibIcmpInfoEx statistics, AddressFamily family); - [DllImport(Interop.Libraries.IpHlpApi)] - internal static unsafe extern uint GetTcpTable(IntPtr pTcpTable, uint* dwOutBufLen, int order); + [GeneratedDllImport(Interop.Libraries.IpHlpApi)] + internal static unsafe partial uint GetTcpTable(IntPtr pTcpTable, uint* dwOutBufLen, bool order); - [DllImport(Interop.Libraries.IpHlpApi)] - internal static unsafe extern uint GetExtendedTcpTable(IntPtr pTcpTable, uint* dwOutBufLen, int order, + [GeneratedDllImport(Interop.Libraries.IpHlpApi)] + internal static unsafe partial uint GetExtendedTcpTable(IntPtr pTcpTable, uint* dwOutBufLen, bool order, uint IPVersion, TcpTableClass tableClass, uint reserved); - [DllImport(Interop.Libraries.IpHlpApi)] - internal static unsafe extern uint GetUdpTable(IntPtr pUdpTable, uint* dwOutBufLen, int order); + [GeneratedDllImport(Interop.Libraries.IpHlpApi)] + internal static unsafe partial uint GetUdpTable(IntPtr pUdpTable, uint* dwOutBufLen, bool order); - [DllImport(Interop.Libraries.IpHlpApi)] - internal static unsafe extern uint GetExtendedUdpTable(IntPtr pUdpTable, uint* dwOutBufLen, int order, + [GeneratedDllImport(Interop.Libraries.IpHlpApi)] + internal static unsafe partial uint GetExtendedUdpTable(IntPtr pUdpTable, uint* dwOutBufLen, bool order, uint IPVersion, UdpTableClass tableClass, uint reserved); [DllImport(Interop.Libraries.IpHlpApi)] diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs index a7a0fa0bec1cd..eff18b1b9d409 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs @@ -9,6 +9,6 @@ internal static partial class Interop internal static partial class User32 { [DllImport(Libraries.User32)] - public static extern unsafe int EnumWindows(delegate* unmanaged callback, IntPtr extraData); + public static extern unsafe Interop.BOOL EnumWindows(delegate* unmanaged callback, IntPtr extraData); } } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs index 99b8629bb9b88..7d1c8874191a9 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs @@ -157,7 +157,7 @@ protected override unsafe bool ReleaseHandle() private static bool InitIsNtlmInstalled() { - return Interop.NetSecurityNative.IsNtlmInstalled() != 0; + return Interop.NetSecurityNative.IsNtlmInstalled(); } } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs index a7961c34a67d1..8bfdb74716d78 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeBioHandle.Unix.cs @@ -31,7 +31,7 @@ protected override bool ReleaseHandle() } else { - return Interop.Crypto.BioDestroy(h) != 0; + return Interop.Crypto.BioDestroy(h); } } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs index 4af8065ab7d81..0899f2f1938b9 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeDsaHandle.Unix.cs @@ -35,7 +35,7 @@ internal static SafeDsaHandle DuplicateHandle(IntPtr handle) // that we don't lose a tracked reference in low-memory situations. SafeDsaHandle safeHandle = new SafeDsaHandle(); - if (Interop.Crypto.DsaUpRef(handle) == 0) + if (!Interop.Crypto.DsaUpRef(handle)) { throw Interop.Crypto.CreateOpenSslCryptographicException(); } diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs index b307f9cfc139b..1a72392bd08aa 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeEcKeyHandle.Unix.cs @@ -35,7 +35,7 @@ internal static SafeEcKeyHandle DuplicateHandle(IntPtr handle) // that we don't lose a tracked reference in low-memory situations. SafeEcKeyHandle safeHandle = new SafeEcKeyHandle(); - if (Interop.Crypto.EcKeyUpRef(handle) == 0) + if (!Interop.Crypto.EcKeyUpRef(handle)) { throw Interop.Crypto.CreateOpenSslCryptographicException(); } diff --git a/src/libraries/Common/tests/System/Net/Capability.Security.Unix.cs b/src/libraries/Common/tests/System/Net/Capability.Security.Unix.cs index 8497203ffeb69..d2b303ac81073 100644 --- a/src/libraries/Common/tests/System/Net/Capability.Security.Unix.cs +++ b/src/libraries/Common/tests/System/Net/Capability.Security.Unix.cs @@ -7,7 +7,7 @@ public static partial class Capability { public static bool IsNtlmInstalled() { - return Interop.NetSecurityNative.IsNtlmInstalled() != 0; + return Interop.NetSecurityNative.IsNtlmInstalled(); } } } diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs index 57e1361e28b73..b51957fb881bf 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.ConfigureTerminalForChildProcesses.Unix.cs @@ -21,7 +21,7 @@ internal static void ConfigureTerminalForChildProcesses(int increment, bool conf Debug.Assert(configureConsole); // At least one child is using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 1); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: true); } else { @@ -30,7 +30,7 @@ internal static void ConfigureTerminalForChildProcesses(int increment, bool conf if (childrenUsingTerminalRemaining == 0 && configureConsole) { // No more children are using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 0); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: false); } } } @@ -50,7 +50,7 @@ private static void DelayedSigChildConsoleConfiguration() if (s_childrenUsingTerminalCount == 0) { // No more children are using the terminal. - Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: 0); + Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: false); } } finally diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs index 44604d57148d5..b7c14cad78dae 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs @@ -161,10 +161,10 @@ private static unsafe void CreateAndStartRunLoop() }, (UIntPtr)2)) { // Try to register our pattern strings with the dynamic store instance. - if (patterns.IsInvalid || Interop.SystemConfiguration.SCDynamicStoreSetNotificationKeys( + if (patterns.IsInvalid || !Interop.SystemConfiguration.SCDynamicStoreSetNotificationKeys( s_dynamicStoreRef.DangerousGetHandle(), IntPtr.Zero, - patterns.DangerousGetHandle()) == 0) + patterns.DangerousGetHandle())) { s_dynamicStoreRef.Dispose(); s_dynamicStoreRef = null; @@ -222,7 +222,7 @@ private static void StopRunLoop() Debug.Assert(s_dynamicStoreRef != null); // Allow RunLoop to finish current processing. - SpinWait.SpinUntil(() => Interop.RunLoop.CFRunLoopIsWaiting(s_runLoop) != 0); + SpinWait.SpinUntil(() => Interop.RunLoop.CFRunLoopIsWaiting(s_runLoop)); Interop.RunLoop.CFRunLoopStop(s_runLoop); s_runLoopEndedEvent.WaitOne(); diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs index a15e1eff8351a..7a65e6e7a16c8 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs @@ -112,7 +112,7 @@ private unsafe List GetAllTcpConnections() if (Socket.OSSupportsIPv4) { // Get the buffer size needed. - result = Interop.IpHlpApi.GetTcpTable(IntPtr.Zero, &size, order: 1); + result = Interop.IpHlpApi.GetTcpTable(IntPtr.Zero, &size, order: true); while (result == Interop.IpHlpApi.ERROR_INSUFFICIENT_BUFFER) { @@ -120,7 +120,7 @@ private unsafe List GetAllTcpConnections() IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetTcpTable(buffer, &size, order: 1); + result = Interop.IpHlpApi.GetTcpTable(buffer, &size, order: true); if (result == Interop.IpHlpApi.ERROR_SUCCESS) { @@ -159,7 +159,7 @@ private unsafe List GetAllTcpConnections() { // Get the buffer size needed. size = 0; - result = Interop.IpHlpApi.GetExtendedTcpTable(IntPtr.Zero, &size, order: 1, + result = Interop.IpHlpApi.GetExtendedTcpTable(IntPtr.Zero, &size, order: true, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0); @@ -169,7 +169,7 @@ private unsafe List GetAllTcpConnections() IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetExtendedTcpTable(buffer, &size, order: 1, + result = Interop.IpHlpApi.GetExtendedTcpTable(buffer, &size, order: true, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0); if (result == Interop.IpHlpApi.ERROR_SUCCESS) @@ -221,7 +221,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() if (Socket.OSSupportsIPv4) { // Get the buffer size needed. - result = Interop.IpHlpApi.GetUdpTable(IntPtr.Zero, &size, order: 1); + result = Interop.IpHlpApi.GetUdpTable(IntPtr.Zero, &size, order: true); while (result == Interop.IpHlpApi.ERROR_INSUFFICIENT_BUFFER) { // Allocate the buffer and get the UDP table. @@ -229,7 +229,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() try { - result = Interop.IpHlpApi.GetUdpTable(buffer, &size, order: 1); + result = Interop.IpHlpApi.GetUdpTable(buffer, &size, order: true); if (result == Interop.IpHlpApi.ERROR_SUCCESS) { @@ -273,7 +273,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() { // Get the buffer size needed. size = 0; - result = Interop.IpHlpApi.GetExtendedUdpTable(IntPtr.Zero, &size, order: 1, + result = Interop.IpHlpApi.GetExtendedUdpTable(IntPtr.Zero, &size, order: true, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0); while (result == Interop.IpHlpApi.ERROR_INSUFFICIENT_BUFFER) @@ -282,7 +282,7 @@ public unsafe override IPEndPoint[] GetActiveUdpListeners() IntPtr buffer = Marshal.AllocHGlobal((int)size); try { - result = Interop.IpHlpApi.GetExtendedUdpTable(buffer, &size, order: 1, + result = Interop.IpHlpApi.GetExtendedUdpTable(buffer, &size, order: true, (uint)AddressFamily.InterNetworkV6, Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj b/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj index 3dc537ad91deb..a6a21cc91e155 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj @@ -5,6 +5,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS annotations true + true diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs index 2dc198f6dd7b4..f160dd0cc0d9a 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs @@ -46,7 +46,7 @@ private static unsafe IPPacketInformation GetIPPacketInformation(Interop.Sys.Mes } Interop.Sys.IPPacketInformation nativePacketInfo = default; - if (Interop.Sys.TryGetIPPacketInformation(messageHeader, Convert.ToInt32(isIPv4), &nativePacketInfo) == 0) + if (!Interop.Sys.TryGetIPPacketInformation(messageHeader, isIPv4, &nativePacketInfo)) { return default(IPPacketInformation); } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs index 74b25bcff5c67..27f1df388e7f1 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs @@ -514,7 +514,7 @@ public IEnumerable Extensions Interop.Crypto.CheckValidOpenSslHandle(dataPtr); byte[] extData = Interop.Crypto.GetAsn1StringBytes(dataPtr); - bool critical = Interop.Crypto.X509ExtensionGetCritical(ext) != 0; + bool critical = Interop.Crypto.X509ExtensionGetCritical(ext); extensions[i] = new X509Extension(oid, extData, critical); } diff --git a/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj b/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj index 99d5b3a776b91..7217065c078e5 100644 --- a/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj +++ b/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj @@ -139,6 +139,7 @@ + diff --git a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs index bfc4ea887b61d..e627638c6fe09 100644 --- a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs +++ b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs @@ -130,7 +130,7 @@ public WindowsIdentity(string sUserPrincipalName) TOKEN_SOURCE sourceContext; unsafe { - if (Interop.Advapi32.AllocateLocallyUniqueId(&sourceContext.SourceIdentifier) == 0) + if (!Interop.Advapi32.AllocateLocallyUniqueId(&sourceContext.SourceIdentifier)) throw new SecurityException(new Win32Exception().Message); } From b4773b0ca2afa7100b6f0ce197541d2d5b8c66b3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 4 Oct 2021 15:45:27 -0700 Subject: [PATCH 153/161] Fix IDE0008 in DllImportGenerator and Microsoft.Interop.SourceGeneration (#59885) --- .../ConvertToGeneratedDllImportAnalyzer.cs | 3 +- .../ConvertToGeneratedDllImportFixer.cs | 9 ++- .../Analyzers/GeneratedDllImportAnalyzer.cs | 8 +-- .../ManualTypeMarshallingAnalyzer.cs | 17 +++-- .../DllImportGenerator/DllImportGenerator.cs | 68 +++++++++---------- .../DllImportStubContext.cs | 14 ++-- .../PInvokeStubCodeGenerator.cs | 37 +++++----- ...CollectionElementMarshallingCodeContext.cs | 12 +--- .../Marshalling/ArrayMarshaller.cs | 7 +- ...ributedMarshallingModelGeneratorFactory.cs | 13 ++-- .../Marshalling/BlittableMarshaller.cs | 2 +- .../Marshalling/BoolMarshaller.cs | 4 +- .../Marshalling/CharMarshaller.cs | 2 +- ...nditionalStackallocMarshallingGenerator.cs | 8 +-- .../CustomNativeTypeMarshallingGenerator.cs | 2 +- .../Marshalling/DelegateMarshaller.cs | 2 +- .../ICustomNativeTypeMarshallingStrategy.cs | 45 ++++++------ .../Marshalling/MarshallerHelpers.cs | 8 +-- .../MarshallingGeneratorFactory.cs | 8 +-- .../PinnableManagedValueMarshaller.cs | 2 +- .../Marshalling/SafeHandleMarshaller.cs | 7 +- .../Marshalling/StringMarshaller.Ansi.cs | 4 +- .../StringMarshaller.PlatformDefined.cs | 12 ++-- .../Marshalling/StringMarshaller.Utf16.cs | 4 +- .../Marshalling/StringMarshaller.Utf8.cs | 4 +- .../MarshallingAttributeInfo.cs | 16 ++--- .../TypePositionInfo.cs | 2 +- .../TypeSymbolExtensions.cs | 10 +-- 28 files changed, 150 insertions(+), 180 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs index 2f9614d888b7c..cf1437251279b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Runtime.InteropServices; @@ -101,7 +102,7 @@ private static bool RequiresMarshalling(IMethodSymbol method, DllImportData dllI } Debug.Assert(dllImportAttr != null); - foreach (var namedArg in dllImportAttr!.NamedArguments) + foreach (KeyValuePair namedArg in dllImportAttr!.NamedArguments) { if (namedArg.Key != nameof(DllImportAttribute.PreserveSig)) continue; 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 e61f3b6aa9caa..4b4a719057b5d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportFixer.cs @@ -1,7 +1,6 @@ // 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.Collections.Immutable; using System.Runtime.InteropServices; @@ -103,7 +102,7 @@ private async Task ConvertToGeneratedDllImport( var dllImportSyntax = (AttributeSyntax)dllImportAttr!.ApplicationSyntaxReference!.GetSyntax(cancellationToken); // Create GeneratedDllImport attribute based on the DllImport attribute - var generatedDllImportSyntax = GetGeneratedDllImportAttribute( + SyntaxNode generatedDllImportSyntax = GetGeneratedDllImportAttribute( editor, generator, dllImportSyntax, @@ -154,7 +153,7 @@ private async Task ConvertToGeneratedDllImport( })); // Remove existing leading trivia - it will be on the GeneratedDllImport method - var updatedDeclaration = methodSyntax.WithLeadingTrivia(); + MethodDeclarationSyntax updatedDeclaration = methodSyntax.WithLeadingTrivia(); // #endif updatedDeclaration = updatedDeclaration.WithTrailingTrivia( @@ -184,7 +183,7 @@ private SyntaxNode GetGeneratedDllImportAttribute( { unmanagedCallConvAttributeMaybe = null; // Create GeneratedDllImport based on the DllImport attribute - var generatedDllImportSyntax = generator.ReplaceNode(dllImportSyntax, + SyntaxNode generatedDllImportSyntax = generator.ReplaceNode(dllImportSyntax, dllImportSyntax.Name, generator.TypeExpression(generatedDllImportAttrType)); @@ -283,7 +282,7 @@ private bool TryCreateUnmanagedCallConvAttributeToEmit( private static bool TryGetAttribute(IMethodSymbol method, INamedTypeSymbol attributeType, out AttributeData? attr) { attr = default; - foreach (var attrLocal in method.GetAttributes()) + foreach (AttributeData attrLocal in method.GetAttributes()) { if (SymbolEqualityComparer.Default.Equals(attrLocal.AttributeClass, attributeType)) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs index 9854b5120084f..b3d2b3a5cf38a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs @@ -74,9 +74,9 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbo { // Make sure declarations are marked partial. Technically, we can just check one // declaration, since Roslyn would error on inconsistent partial declarations. - foreach (var reference in methodSymbol.DeclaringSyntaxReferences) + foreach (SyntaxReference reference in methodSymbol.DeclaringSyntaxReferences) { - var syntax = reference.GetSyntax(context.CancellationToken); + SyntaxNode syntax = reference.GetSyntax(context.CancellationToken); if (syntax is MethodDeclarationSyntax methodSyntax && !methodSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) { // Must be marked partial @@ -87,9 +87,9 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbo for (INamedTypeSymbol? typeSymbol = methodSymbol.ContainingType; typeSymbol is not null; typeSymbol = typeSymbol.ContainingType) { - foreach (var reference in typeSymbol.DeclaringSyntaxReferences) + foreach (SyntaxReference reference in typeSymbol.DeclaringSyntaxReferences) { - var syntax = reference.GetSyntax(context.CancellationToken); + SyntaxNode syntax = reference.GetSyntax(context.CancellationToken); if (syntax is TypeDeclarationSyntax typeSyntax && !typeSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) { // Must be marked partial diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs index d7aab5dc9329d..f975a68c58f37 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs @@ -1,7 +1,6 @@ // 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.Immutable; using System.Linq; @@ -195,12 +194,12 @@ public override void Initialize(AnalysisContext context) private void PrepareForAnalysis(CompilationStartAnalysisContext context) { - var generatedMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute); - var blittableTypeAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute); - var nativeMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute); - var marshalUsingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute); - var genericContiguousCollectionMarshallerAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.GenericContiguousCollectionMarshallerAttribute); - var spanOfByte = context.Compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(context.Compilation.GetSpecialType(SpecialType.System_Byte)); + INamedTypeSymbol? generatedMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.GeneratedMarshallingAttribute); + INamedTypeSymbol? blittableTypeAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute); + INamedTypeSymbol? nativeMarshallingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.NativeMarshallingAttribute); + INamedTypeSymbol? marshalUsingAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute); + INamedTypeSymbol? genericContiguousCollectionMarshallerAttribute = context.Compilation.GetTypeByMetadataName(TypeNames.GenericContiguousCollectionMarshallerAttribute); + INamedTypeSymbol? spanOfByte = context.Compilation.GetTypeByMetadataName(TypeNames.System_Span_Metadata)!.Construct(context.Compilation.GetSpecialType(SpecialType.System_Byte)); if (generatedMarshallingAttribute is not null && blittableTypeAttribute is not null @@ -256,7 +255,7 @@ public void AnalyzeTypeDefinition(SymbolAnalysisContext context) AttributeData? blittableTypeAttributeData = null; AttributeData? nativeMarshallingAttributeData = null; - foreach (var attr in type.GetAttributes()) + foreach (AttributeData attr in type.GetAttributes()) { if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, _generatedMarshallingAttribute)) { @@ -416,7 +415,7 @@ private void AnalyzeNativeMarshalerType(SymbolAnalysisContext context, ITypeSymb bool hasConstructor = false; bool hasStackallocConstructor = false; - foreach (var ctor in marshalerType.Constructors) + foreach (IMethodSymbol ctor in marshalerType.Constructors) { if (ctor.IsStatic) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs index d2f357636456e..dcc977e49d581 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -13,6 +9,9 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; [assembly: System.Resources.NeutralResourcesLanguage("en-US")] @@ -85,7 +84,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) static attribute => attribute.AttributeClass?.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) ); - var compilationAndTargetFramework = context.CompilationProvider + IncrementalValueProvider<(Compilation compilation, bool isSupported, Version targetFrameworkVersion)> compilationAndTargetFramework = context.CompilationProvider .Select(static (compilation, ct) => { bool isSupported = IsSupportedTargetFramework(compilation, out Version targetFrameworkVersion); @@ -110,9 +109,10 @@ public void Initialize(IncrementalGeneratorInitializationContext context) } }); - var stubOptions = context.AnalyzerConfigOptionsProvider.Select((options, ct) => new DllImportGeneratorOptions(options.GlobalOptions)); + IncrementalValueProvider stubOptions = context.AnalyzerConfigOptionsProvider + .Select((options, ct) => new DllImportGeneratorOptions(options.GlobalOptions)); - var stubEnvironment = compilationAndTargetFramework + IncrementalValueProvider stubEnvironment = compilationAndTargetFramework .Combine(stubOptions) .Select( static (data, ct) => @@ -124,7 +124,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) data.Right) ); - var methodSourceAndDiagnostics = methodsToGenerate + IncrementalValueProvider<(string, ImmutableArray)> methodSourceAndDiagnostics = methodsToGenerate .Combine(stubEnvironment) .Select(static (data, ct) => new { @@ -165,7 +165,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) // Mark in source that the file is auto-generated. source.AppendLine("// "); ImmutableArray.Builder diagnostics = ImmutableArray.CreateBuilder(); - foreach (var generated in generatedSources) + foreach ((string, ImmutableArray) generated in generatedSources) { source.AppendLine(generated.Item1); diagnostics.AddRange(generated.Item2); @@ -178,7 +178,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) (context, data) => { IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.OutputSourceFile, data)); - foreach (var diagnostic in data.Item2) + foreach (Diagnostic diagnostic in data.Item2) { context.ReportDiagnostic(diagnostic); } @@ -200,12 +200,12 @@ private static List GenerateSyntaxForForwardedAttributes(Attrib if (unmanagedCallConvAttribute is not null) { AttributeSyntax unmanagedCallConvSyntax = Attribute(ParseName(TypeNames.UnmanagedCallConvAttribute)); - foreach (var arg in unmanagedCallConvAttribute.NamedArguments) + foreach (KeyValuePair arg in unmanagedCallConvAttribute.NamedArguments) { if (arg.Key == CallConvsField) { InitializerExpressionSyntax callConvs = InitializerExpression(SyntaxKind.ArrayInitializerExpression); - foreach (var callConv in arg.Value.Values) + foreach (TypedConstant callConv in arg.Value.Values) { callConvs = callConvs.AddExpressions( TypeOfExpression(((ITypeSymbol)callConv.Value!).AsTypeSyntax())); @@ -250,7 +250,7 @@ private static MemberDeclarationSyntax PrintGeneratedSource( BlockSyntax stubCode) { // Create stub function - var stubMethod = MethodDeclaration(stub.StubReturnType, userDeclaredMethod.Identifier) + MethodDeclarationSyntax stubMethod = MethodDeclaration(stub.StubReturnType, userDeclaredMethod.Identifier) .AddAttributeLists(stub.AdditionalAttributes.ToArray()) .WithModifiers(StripTriviaFromModifiers(userDeclaredMethod.Modifiers)) .WithParameterList(ParameterList(SeparatedList(stub.StubParameters))) @@ -264,7 +264,7 @@ private static MemberDeclarationSyntax PrintGeneratedSource( .AddMembers(stubMethod); // Add type to the remaining containing types (skipping the first which was handled above) - foreach (var typeDecl in stub.StubContainingTypes.Skip(1)) + foreach (TypeDeclarationSyntax typeDecl in stub.StubContainingTypes.Skip(1)) { containingType = CreateTypeDeclarationWithoutTrivia(typeDecl) .WithMembers(SingletonList(containingType)); @@ -326,7 +326,7 @@ private static GeneratedDllImportData ProcessGeneratedDllImportAttribute(Attribu var stubDllImportData = new GeneratedDllImportData(attrData.ConstructorArguments[0].Value!.ToString()); // All other data on attribute is defined as NamedArguments. - foreach (var namedArg in attrData.NamedArguments) + foreach (KeyValuePair namedArg in attrData.NamedArguments) { switch (namedArg.Key) { @@ -392,7 +392,7 @@ private static IncrementalStubGenerationContext CalculateStubInformation(MethodD AttributeData? lcidConversionAttr = null; AttributeData? suppressGCTransitionAttribute = null; AttributeData? unmanagedCallConvAttribute = null; - foreach (var attr in symbol.GetAttributes()) + foreach (AttributeData attr in symbol.GetAttributes()) { if (attr.AttributeClass is not null && attr.AttributeClass.ToDisplayString() == TypeNames.GeneratedDllImportAttribute) @@ -466,9 +466,9 @@ private static IncrementalStubGenerationContext CalculateStubInformation(MethodD const string innerPInvokeName = "__PInvoke__"; - var code = stubGenerator.GeneratePInvokeBody(innerPInvokeName); + BlockSyntax code = stubGenerator.GeneratePInvokeBody(innerPInvokeName); - var dllImport = CreateTargetFunctionAsLocalStatement( + LocalFunctionStatementSyntax dllImport = CreateTargetFunctionAsLocalStatement( stubGenerator, dllImportStub.StubContext.Options, dllImportStub.DllImportData, @@ -493,8 +493,8 @@ private static LocalFunctionStatementSyntax CreateTargetFunctionAsLocalStatement string stubTargetName, string stubMethodName) { - var (parameterList, returnType, returnTypeAttributes) = stubGenerator.GenerateTargetMethodSignatureData(); - var localDllImport = LocalFunctionStatement(returnType, stubTargetName) + (ParameterListSyntax parameterList, TypeSyntax returnType, AttributeListSyntax returnTypeAttributes) = stubGenerator.GenerateTargetMethodSignatureData(); + LocalFunctionStatementSyntax localDllImport = LocalFunctionStatement(returnType, stubTargetName) .AddModifiers( Token(SyntaxKind.ExternKeyword), Token(SyntaxKind.StaticKeyword), @@ -531,44 +531,44 @@ private static AttributeSyntax CreateDllImportAttributeForTarget(GeneratedDllImp if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.BestFitMapping)) { - var name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); - var value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); + NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.BestFitMapping)); + ExpressionSyntax value = CreateBoolExpressionSyntax(targetDllImportData.BestFitMapping); newAttributeArgs.Add(AttributeArgument(name, null, value)); } if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CallingConvention)) { - var name = NameEquals(nameof(DllImportAttribute.CallingConvention)); - var value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); + NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.CallingConvention)); + ExpressionSyntax value = CreateEnumExpressionSyntax(targetDllImportData.CallingConvention); newAttributeArgs.Add(AttributeArgument(name, null, value)); } if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet)) { - var name = NameEquals(nameof(DllImportAttribute.CharSet)); - var value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); + NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.CharSet)); + ExpressionSyntax value = CreateEnumExpressionSyntax(targetDllImportData.CharSet); newAttributeArgs.Add(AttributeArgument(name, null, value)); } if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ExactSpelling)) { - var name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); - var value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); + NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.ExactSpelling)); + ExpressionSyntax value = CreateBoolExpressionSyntax(targetDllImportData.ExactSpelling); newAttributeArgs.Add(AttributeArgument(name, null, value)); } if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.PreserveSig)) { - var name = NameEquals(nameof(DllImportAttribute.PreserveSig)); - var value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); + NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.PreserveSig)); + ExpressionSyntax value = CreateBoolExpressionSyntax(targetDllImportData.PreserveSig); newAttributeArgs.Add(AttributeArgument(name, null, value)); } if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.SetLastError)) { - var name = NameEquals(nameof(DllImportAttribute.SetLastError)); - var value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); + NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.SetLastError)); + ExpressionSyntax value = CreateBoolExpressionSyntax(targetDllImportData.SetLastError); newAttributeArgs.Add(AttributeArgument(name, null, value)); } if (targetDllImportData.IsUserDefined.HasFlag(DllImportMember.ThrowOnUnmappableChar)) { - var name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); - var value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); + NameEqualsSyntax name = NameEquals(nameof(DllImportAttribute.ThrowOnUnmappableChar)); + ExpressionSyntax value = CreateBoolExpressionSyntax(targetDllImportData.ThrowOnUnmappableChar); newAttributeArgs.Add(AttributeArgument(name, null, value)); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs index 81e10ff2ae6a8..853422ab5a1ff 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportStubContext.cs @@ -46,7 +46,7 @@ public IEnumerable StubParameters { get { - foreach (var typeInfo in ElementTypeInformation) + foreach (TypePositionInfo typeInfo in ElementTypeInformation) { if (typeInfo.ManagedIndex != TypePositionInfo.UnsetIndex && typeInfo.ManagedIndex != TypePositionInfo.ReturnIndex) @@ -84,7 +84,7 @@ public static DllImportStubContext Create( } // Determine containing type(s) - var containingTypes = ImmutableArray.CreateBuilder(); + ImmutableArray.Builder containingTypes = ImmutableArray.CreateBuilder(); INamedTypeSymbol currType = method.ContainingType; while (!(currType is null)) { @@ -102,9 +102,9 @@ public static DllImportStubContext Create( currType = currType.ContainingType; } - var (typeInfos, generatorFactory) = GenerateTypeInformation(method, dllImportData, diagnostics, env); + (ImmutableArray typeInfos, IMarshallingGeneratorFactory generatorFactory) = GenerateTypeInformation(method, dllImportData, diagnostics, env); - var additionalAttrs = ImmutableArray.CreateBuilder(); + ImmutableArray.Builder additionalAttrs = ImmutableArray.CreateBuilder(); // Define additional attributes for the stub definition. if (env.TargetFrameworkVersion >= new Version(5, 0) && !MethodIsSkipLocalsInit(env, method)) @@ -135,7 +135,7 @@ public static DllImportStubContext Create( private static (ImmutableArray, IMarshallingGeneratorFactory) GenerateTypeInformation(IMethodSymbol method, GeneratedDllImportData dllImportData, GeneratorDiagnostics diagnostics, StubEnvironment env) { // Compute the current default string encoding value. - var defaultEncoding = CharEncoding.Undefined; + CharEncoding defaultEncoding = CharEncoding.Undefined; if (dllImportData.IsUserDefined.HasFlag(DllImportMember.CharSet)) { defaultEncoding = dllImportData.CharSet switch @@ -152,10 +152,10 @@ private static (ImmutableArray, IMarshallingGeneratorFactory) var marshallingAttributeParser = new MarshallingAttributeInfoParser(env.Compilation, diagnostics, defaultInfo, method); // Determine parameter and return types - var typeInfos = ImmutableArray.CreateBuilder(); + ImmutableArray.Builder typeInfos = ImmutableArray.CreateBuilder(); for (int i = 0; i < method.Parameters.Length; i++) { - var param = method.Parameters[i]; + IParameterSymbol param = method.Parameters[i]; MarshallingInfo marshallingInfo = marshallingAttributeParser.ParseMarshallingInfo(param.Type, param.GetAttributes()); var typeInfo = TypePositionInfo.CreateForParameter(param, marshallingInfo, env.Compilation); typeInfo = typeInfo with diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs index 27ee9e161e94b..aa7242694afb1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/PInvokeStubCodeGenerator.cs @@ -3,15 +3,12 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Diagnostics; using System.Linq; -using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using static Microsoft.Interop.StubCodeContext; namespace Microsoft.Interop { @@ -76,7 +73,7 @@ public PInvokeStubCodeGenerator( BoundGenerator nativeRetMarshaller = new(new TypePositionInfo(SpecialTypeInfo.Void, NoMarshallingInfo.Instance), new Forwarder()); BoundGenerator managedRetMarshaller = new(new TypePositionInfo(SpecialTypeInfo.Void, NoMarshallingInfo.Instance), new Forwarder()); - foreach (var argType in argTypes) + foreach (TypePositionInfo argType in argTypes) { BoundGenerator generator = CreateGenerator(argType); allMarshallers.Add(generator); @@ -214,7 +211,7 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) { var setupStatements = new List(); - foreach (var marshaller in _paramMarshallers) + foreach (BoundGenerator marshaller in _paramMarshallers) { TypePositionInfo info = marshaller.TypeInfo; if (info.IsManagedReturnPosition) @@ -269,7 +266,7 @@ public BlockSyntax GeneratePInvokeBody(string dllImportName) var tryStatements = new List(); var guaranteedUnmarshalStatements = new List(); var cleanupStatements = new List(); - var invoke = InvocationExpression(IdentifierName(dllImportName)); + InvocationExpressionSyntax invoke = InvocationExpression(IdentifierName(dllImportName)); // Handle GuaranteedUnmarshal first since that stage producing statements affects multiple other stages. GenerateStatementsForStage(Stage.GuaranteedUnmarshal, guaranteedUnmarshalStatements); @@ -331,7 +328,7 @@ void GenerateStatementsForStage(Stage stage, List statementsToU if (!invokeReturnsVoid && (stage is Stage.Setup or Stage.Cleanup)) { - var retStatements = _retMarshaller.Generator.Generate(_retMarshaller.TypeInfo, this); + IEnumerable retStatements = _retMarshaller.Generator.Generate(_retMarshaller.TypeInfo, this); statementsToUpdate.AddRange(retStatements); } @@ -340,7 +337,7 @@ void GenerateStatementsForStage(Stage stage, List statementsToU // For Unmarshal and GuaranteedUnmarshal stages, use the topologically sorted // marshaller list to generate the marshalling statements - foreach (var marshaller in _sortedMarshallers) + foreach (BoundGenerator marshaller in _sortedMarshallers) { statementsToUpdate.AddRange(marshaller.Generator.Generate(marshaller.TypeInfo, this)); } @@ -348,9 +345,9 @@ void GenerateStatementsForStage(Stage stage, List statementsToU else { // Generate code for each parameter for the current stage in declaration order. - foreach (var marshaller in _paramMarshallers) + foreach (BoundGenerator marshaller in _paramMarshallers) { - var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); + IEnumerable generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); statementsToUpdate.AddRange(generatedStatements); } } @@ -358,11 +355,11 @@ void GenerateStatementsForStage(Stage stage, List statementsToU if (statementsToUpdate.Count > initialCount) { // Comment separating each stage - var newLeadingTrivia = TriviaList( + SyntaxTriviaList newLeadingTrivia = TriviaList( Comment($"//"), Comment($"// {stage}"), Comment($"//")); - var firstStatementInStage = statementsToUpdate[initialCount]; + StatementSyntax firstStatementInStage = statementsToUpdate[initialCount]; newLeadingTrivia = newLeadingTrivia.AddRange(firstStatementInStage.GetLeadingTrivia()); statementsToUpdate[initialCount] = firstStatementInStage.WithLeadingTrivia(newLeadingTrivia); } @@ -373,11 +370,11 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc var fixedStatements = new List(); CurrentStage = Stage.Pin; // Generate code for each parameter for the current stage - foreach (var marshaller in _paramMarshallers) + foreach (BoundGenerator marshaller in _paramMarshallers) { - var generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); + IEnumerable generatedStatements = marshaller.Generator.Generate(marshaller.TypeInfo, this); // Collect all the fixed statements. These will be used in the Invoke stage. - foreach (var statement in generatedStatements) + foreach (StatementSyntax statement in generatedStatements) { if (statement is not FixedStatementSyntax fixedStatement) continue; @@ -388,7 +385,7 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc CurrentStage = Stage.Invoke; // Generate code for each parameter for the current stage - foreach (var marshaller in _paramMarshallers) + foreach (BoundGenerator marshaller in _paramMarshallers) { // Get arguments for invocation ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, this); @@ -415,7 +412,7 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc if (_setLastError) { // Marshal.SetLastSystemError(0); - var clearLastError = ExpressionStatement( + ExpressionStatementSyntax clearLastError = ExpressionStatement( InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, @@ -425,7 +422,7 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(SuccessErrorCode))))))); // = Marshal.GetLastSystemError(); - var getLastError = ExpressionStatement( + ExpressionStatementSyntax getLastError = ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, IdentifierName(LastErrorIdentifier), @@ -442,7 +439,7 @@ void GenerateStatementsForInvoke(List statementsToUpdate, Invoc { fixedStatements.Reverse(); invokeStatement = fixedStatements.First().WithStatement(invokeStatement); - foreach (var fixedStatement in fixedStatements.Skip(1)) + foreach (FixedStatementSyntax fixedStatement in fixedStatements.Skip(1)) { invokeStatement = fixedStatement.WithStatement(Block(invokeStatement)); } @@ -474,7 +471,7 @@ _retMarshaller.Generator is IAttributedReturnTypeMarshallingGenerator attributed private void AppendVariableDeclations(List statementsToUpdate, TypePositionInfo info, IMarshallingGenerator generator) { - var (managed, native) = GetIdentifiers(info); + (string managed, string native) = GetIdentifiers(info); // Declare variable for return value if (info.IsManagedReturnPosition || info.IsNativeReturnPosition) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs index 82eb6f3f2686f..02d965c9f29ce 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ContiguousCollectionElementMarshallingCodeContext.cs @@ -1,16 +1,6 @@ // 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.Diagnostics; -using System.Linq; -using System.Text; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - namespace Microsoft.Interop { internal sealed class ContiguousCollectionElementMarshallingCodeContext : StubCodeContext @@ -48,7 +38,7 @@ public ContiguousCollectionElementMarshallingCodeContext( /// Managed and native identifiers public override (string managed, string native) GetIdentifiers(TypePositionInfo info) { - var (_, native) = ParentContext!.GetIdentifiers(info); + (string _, string native) = ParentContext!.GetIdentifiers(info); return ( $"{native}.ManagedValues[{IndexerIdentifier}]", $"{_nativeSpanIdentifier}[{IndexerIdentifier}]" diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs index b9319b751febb..82ee55861816f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ArrayMarshaller.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -78,7 +77,7 @@ private bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext conte private IEnumerable GeneratePinningPath(TypePositionInfo info, StubCodeContext context) { - var (managedIdentifer, nativeIdentifier) = context.GetIdentifiers(info); + (string managedIdentifer, string nativeIdentifier) = context.GetIdentifiers(info); string byRefIdentifier = $"__byref_{managedIdentifer}"; TypeSyntax arrayElementType = _elementType; if (context.CurrentStage == StubCodeContext.Stage.Marshal) @@ -92,13 +91,13 @@ private IEnumerable GeneratePinningPath(TypePositionInfo info, // for single-dimensional zero-based arrays. // ref = == null ? ref *(); - var nullRef = + PrefixUnaryExpressionSyntax nullRef = PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, CastExpression( PointerType(arrayElementType), LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))); - var getArrayDataReference = + InvocationExpressionSyntax getArrayDataReference = InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs index 8a8aae6fca7ad..69114bfc341e3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs @@ -1,14 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.CodeAnalysis.CSharp; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using System; using System.Collections.Generic; -using System.Text; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { @@ -239,10 +236,10 @@ private IMarshallingGenerator CreateNativeCollectionMarshaller( ICustomNativeTypeMarshallingStrategy marshallingStrategy) { var elementInfo = new TypePositionInfo(collectionInfo.ElementType, collectionInfo.ElementMarshallingInfo) { ManagedIndex = info.ManagedIndex }; - var elementMarshaller = Create( + IMarshallingGenerator elementMarshaller = Create( elementInfo, new ContiguousCollectionElementMarshallingCodeContext(StubCodeContext.Stage.Setup, string.Empty, context)); - var elementType = elementMarshaller.AsNativeType(elementInfo); + TypeSyntax elementType = elementMarshaller.AsNativeType(elementInfo); bool isBlittable = elementMarshaller is BlittableMarshaller; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs index 31584e68d72e2..c68037306af57 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs @@ -19,7 +19,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public ParameterSyntax AsParameter(TypePositionInfo info) { - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs index 6a3f529d9d99c..a11a5243575fa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs @@ -34,7 +34,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public ParameterSyntax AsParameter(TypePositionInfo info) { - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) @@ -85,7 +85,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont // = == _trueValue; // or // = != _falseValue; - var (binaryOp, comparand) = _compareToTrue ? (SyntaxKind.EqualsExpression, _trueValue) : (SyntaxKind.NotEqualsExpression, _falseValue); + (SyntaxKind binaryOp, int comparand) = _compareToTrue ? (SyntaxKind.EqualsExpression, _trueValue) : (SyntaxKind.NotEqualsExpression, _falseValue); yield return ExpressionStatement( AssignmentExpression( diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index 466b715e80c6a..fb18cb531f513 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -55,7 +55,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public ParameterSyntax AsParameter(TypePositionInfo info) { - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs index 89ee8e2d1cdfa..2b638538904e0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs @@ -55,14 +55,14 @@ protected IEnumerable GenerateConditionalAllocationSyntax( string byteLenIdentifier = GetByteLengthIdentifier(info, context); string stackAllocPtrIdentifier = GetStackAllocIdentifier(info, context); // = ; - var allocationStatement = ExpressionStatement( + ExpressionStatementSyntax allocationStatement = ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, IdentifierName(nativeIdentifier), GenerateAllocationExpression(info, context, Identifier(byteLenIdentifier), out bool allocationRequiresByteLength))); // int = ; - var byteLenAssignment = LocalDeclarationStatement( + LocalDeclarationStatementSyntax byteLenAssignment = LocalDeclarationStatement( VariableDeclaration( PredefinedType(Token(SyntaxKind.IntKeyword)), SingletonSeparatedList( @@ -88,7 +88,7 @@ protected IEnumerable GenerateConditionalAllocationSyntax( } // Code block for stackalloc if number of bytes is below threshold size - var marshalOnStack = Block( + BlockSyntax marshalOnStack = Block( // byte* = stackalloc byte[]; LocalDeclarationStatement( VariableDeclaration( @@ -123,7 +123,7 @@ protected IEnumerable GenerateConditionalAllocationSyntax( // ; // = (); // } - var allocBlock = IfStatement( + IfStatementSyntax allocBlock = IfStatement( BinaryExpression( SyntaxKind.GreaterThanExpression, IdentifierName(byteLenIdentifier), diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs index d114c9092aaa7..f01c2741ea7e0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshallingGenerator.cs @@ -35,7 +35,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public ParameterSyntax AsParameter(TypePositionInfo info) { - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs index 820a36fc14329..32fe10c6ec9c7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs @@ -18,7 +18,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public ParameterSyntax AsParameter(TypePositionInfo info) { - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs index 87e25faf55445..338c7ee379b0d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -97,7 +96,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo yield break; } - var (managedIdentifier, nativeIdentifier) = context.GetIdentifiers(info); + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); // = .ToManaged(); yield return ExpressionStatement( AssignmentExpression( @@ -196,7 +195,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i yield return GenerateValuePropertyAssignment(info, context, subContext); } - foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, subContext)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateCleanupStatements(info, subContext)) { yield return statement; } @@ -205,7 +204,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) { yield return statement; } @@ -238,7 +237,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo yield return GenerateValuePropertyAssignment(info, context, subContext); - foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext)) { yield return statement; } @@ -260,7 +259,7 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf VariableDeclarator(subContext.GetIdentifiers(info).native) .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); - foreach (var statement in _innerMarshaller.GenerateSetupStatements(info, subContext)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateSetupStatements(info, subContext)) { yield return statement; } @@ -321,7 +320,7 @@ public IEnumerable GenerateMarshalStatements(TypePositionInfo i )))))))))); } - foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) { yield return statement; } @@ -354,7 +353,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - foreach (var arg in _innerMarshaller.GetNativeTypeConstructorArguments(info, context)) + foreach (ArgumentSyntax arg in _innerMarshaller.GetNativeTypeConstructorArguments(info, context)) { yield return arg; } @@ -406,7 +405,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { - foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, context)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateCleanupStatements(info, context)) { yield return statement; } @@ -489,7 +488,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i yield return GenerateValuePropertyAssignment(info, context, subContext); } - foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, subContext)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateCleanupStatements(info, subContext)) { yield return statement; } @@ -498,7 +497,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { var subContext = new CustomNativeTypeWithValuePropertyStubContext(context); - foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateMarshalStatements(info, subContext, nativeTypeConstructorArguments)) { yield return statement; } @@ -545,7 +544,7 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf VariableDeclarator(subContext.GetIdentifiers(info).native) .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.DefaultLiteralExpression)))))); - foreach (var statement in _innerMarshaller.GenerateSetupStatements(info, subContext)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateSetupStatements(info, subContext)) { yield return statement; } @@ -573,7 +572,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo yield return GenerateValuePropertyAssignment(info, context, subContext); } - foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext)) { yield return statement; } @@ -628,13 +627,13 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i // from the native data so we can safely run any cleanup functionality in the marshaller. if (!context.AdditionalTemporaryStateLivesAcrossStages) { - foreach (var statement in GenerateUnmarshallerCollectionInitialization(info, context)) + foreach (StatementSyntax statement in GenerateUnmarshallerCollectionInitialization(info, context)) { yield return statement; } } - foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, context)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateCleanupStatements(info, context)) { yield return statement; } @@ -684,12 +683,12 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo // and set the unmanaged collection length before we marshal back the native data. // This ensures that the marshaller object has enough state to successfully set up the ManagedValues // and NativeValueStorage spans when the actual collection value is unmarshalled from native to the marshaller. - foreach (var statement in GenerateUnmarshallerCollectionInitialization(info, context)) + foreach (StatementSyntax statement in GenerateUnmarshallerCollectionInitialization(info, context)) { yield return statement; } - foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) { yield return statement; } @@ -697,7 +696,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo public IEnumerable GetNativeTypeConstructorArguments(TypePositionInfo info, StubCodeContext context) { - foreach (var arg in _innerMarshaller.GetNativeTypeConstructorArguments(info, context)) + foreach (ArgumentSyntax arg in _innerMarshaller.GetNativeTypeConstructorArguments(info, context)) { yield return arg; } @@ -742,7 +741,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { string nativeIdentifier = context.GetIdentifiers(info).native; - foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) { yield return statement; } @@ -833,7 +832,7 @@ public IEnumerable GenerateUnmarshalStatements(TypePositionInfo IdentifierName(nativeIdentifier), IdentifierName(ManualTypeMarshallingHelper.ManagedValuesPropertyName))))); - foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) { yield return statement; } @@ -962,7 +961,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public IEnumerable GenerateCleanupStatements(TypePositionInfo info, StubCodeContext context) { yield return GenerateContentsMarshallingStatement(info, context, useManagedSpanForLength: false); - foreach (var statement in _innerMarshaller.GenerateCleanupStatements(info, context)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateCleanupStatements(info, context)) { yield return statement; } @@ -970,7 +969,7 @@ public IEnumerable GenerateCleanupStatements(TypePositionInfo i public IEnumerable GenerateMarshalStatements(TypePositionInfo info, StubCodeContext context, IEnumerable nativeTypeConstructorArguments) { - foreach (var statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateMarshalStatements(info, context, nativeTypeConstructorArguments)) { yield return statement; } @@ -997,7 +996,7 @@ public IEnumerable GenerateSetupStatements(TypePositionInfo inf public IEnumerable GenerateUnmarshalStatements(TypePositionInfo info, StubCodeContext context) { yield return GenerateContentsMarshallingStatement(info, context, useManagedSpanForLength: false); - foreach (var statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) + foreach (StatementSyntax statement in _innerMarshaller.GenerateUnmarshalStatements(info, context)) { yield return statement; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index 2adc953ce3c3a..12420cca3d078 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -120,16 +120,16 @@ public static IEnumerable GetTopologicallySortedElements( EdgeMap edgeMap = new(elements.Count); int nextEdgeMapIndex = 0; - foreach (var element in elements) + foreach (T element in elements) { elementIndexToEdgeMapNodeId.Add(keyFn(element), nextEdgeMapIndex++); nodeIdToElement.Add(element); } - foreach (var element in elements) + foreach (T element in elements) { U elementIndex = keyFn(element); - foreach (var dependentElementIndex in getDependentIndicesFn(element)) + foreach (U dependentElementIndex in getDependentIndicesFn(element)) { // Add an edge from the node for dependentElementIndex-> the node for elementIndex // This way, elements that have no dependencies have no edges pointing to them. @@ -232,7 +232,7 @@ public static IEnumerable GetDependentElementsOfMarshallingInf { yield return nestedCountElement; } - foreach (var nestedElements in GetDependentElementsOfMarshallingInfo(nestedCollection.ElementMarshallingInfo)) + foreach (TypePositionInfo nestedElements in GetDependentElementsOfMarshallingInfo(nestedCollection.ElementMarshallingInfo)) { yield return nestedElements; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs index bc496a1982eb8..2170b4978b9d1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs @@ -1,14 +1,8 @@ // 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.Runtime.InteropServices; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop { @@ -78,7 +72,7 @@ public IMarshallingGenerator Create( // Enum with no marshalling info case { ManagedType: EnumTypeInfo enumType, MarshallingAttributeInfo: NoMarshallingInfo }: // Check that the underlying type is not bool or char. C# does not allow this, but ECMA-335 does. - var underlyingSpecialType = enumType.UnderlyingType; + SpecialType underlyingSpecialType = enumType.UnderlyingType; if (underlyingSpecialType == SpecialType.System_Boolean || underlyingSpecialType == SpecialType.System_Char) { throw new MarshallingNotSupportedException(info, context); diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs index 8a17dd5aeba3d..aa47a55409cd2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/PinnableManagedValueMarshaller.cs @@ -68,7 +68,7 @@ private IEnumerable GeneratePinningPath(TypePositionInfo info, { if (context.CurrentStage == StubCodeContext.Stage.Pin) { - var (managedIdentifier, nativeIdentifier) = context.GetIdentifiers(info); + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); yield return FixedStatement( VariableDeclaration( PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword))), diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs index c9b765be61d48..4a663542f52c1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs @@ -6,7 +6,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Microsoft.Interop @@ -20,7 +19,7 @@ public TypeSyntax AsNativeType(TypePositionInfo info) public ParameterSyntax AsParameter(TypePositionInfo info) { - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) @@ -78,8 +77,8 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont .WithInitializer(EqualsValueClause(LiteralExpression(SyntaxKind.FalseLiteralExpression)))))); } - var safeHandleCreationExpression = ((SafeHandleMarshallingInfo)info.MarshallingAttributeInfo).AccessibleDefaultConstructor - ? (ExpressionSyntax)ObjectCreationExpression(info.ManagedType.Syntax, ArgumentList(), initializer: null) + ExpressionSyntax safeHandleCreationExpression = ((SafeHandleMarshallingInfo)info.MarshallingAttributeInfo).AccessibleDefaultConstructor + ? ObjectCreationExpression(info.ManagedType.Syntax, ArgumentList(), initializer: null) : CastExpression( info.ManagedType.Syntax, InvocationExpression( diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs index c26ea8467d866..40c09b0ed1890 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs @@ -50,7 +50,7 @@ public override ParameterSyntax AsParameter(TypePositionInfo info) // byte** // or // byte* - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) @@ -71,7 +71,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu if (info.RefKind != RefKind.Out) { // = (byte*)Marshal.StringToCoTaskMemAnsi(); - var windowsBlock = Block( + BlockSyntax windowsBlock = Block( ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, 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 index 0b30170f1e0ec..655e2fe1b218a 100644 --- 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 @@ -28,8 +28,8 @@ public PlatformDefinedStringMarshaller(IMarshallingGenerator windowsMarshaller, public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context) { - var windowsExpr = _windowsMarshaller.AsArgument(info, context).Expression; - var nonWindowsExpr = _nonWindowsMarshaller.AsArgument(info, context).Expression; + 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)) @@ -54,7 +54,7 @@ public override ParameterSyntax AsParameter(TypePositionInfo info) // void** // or // void* - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) @@ -86,10 +86,10 @@ public override IEnumerable Generate(TypePositionInfo info, Stu // [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 (var s in _windowsMarshaller.Generate(info, context)) + foreach (StatementSyntax s in _windowsMarshaller.Generate(info, context)) yield return s; - foreach (var s in _nonWindowsMarshaller.Generate(info, context)) + foreach (StatementSyntax s in _nonWindowsMarshaller.Generate(info, context)) yield return s; break; @@ -137,7 +137,7 @@ private bool TryGetConditionalBlockForStatements( bool hasNonWindowsStatements = nonWindowsStatements.Any(); if (hasWindowsStatements) { - var windowsIfBlock = IfStatement(IsWindows, Block(windowsStatements)); + IfStatementSyntax windowsIfBlock = IfStatement(IsWindows, Block(windowsStatements)); if (hasNonWindowsStatements) { // if (OperatingSystem.IsWindows()) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs index d374fbb77b892..aca7252e6f39d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs @@ -57,7 +57,7 @@ public override ParameterSyntax AsParameter(TypePositionInfo info) // ushort** // or // ushort* - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) @@ -94,7 +94,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) { - foreach (var statement in GenerateConditionalAllocationSyntax( + foreach (StatementSyntax statement in GenerateConditionalAllocationSyntax( info, context, StackAllocBytesThreshold)) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs index 9afc473842cf6..8414b271b0ef6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs @@ -47,7 +47,7 @@ public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext public override ParameterSyntax AsParameter(TypePositionInfo info) { - var type = info.IsByRef + TypeSyntax type = info.IsByRef ? PointerType(AsNativeType(info)) : AsNativeType(info); return Parameter(Identifier(info.InstanceIdentifier)) @@ -67,7 +67,7 @@ public override IEnumerable Generate(TypePositionInfo info, Stu case StubCodeContext.Stage.Marshal: if (info.RefKind != RefKind.Out) { - foreach (var statement in GenerateConditionalAllocationSyntax( + foreach (StatementSyntax statement in GenerateConditionalAllocationSyntax( info, context, StackAllocBytesThreshold)) 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 139e7abe11487..6924088f311fd 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 @@ -265,7 +265,7 @@ private MarshallingInfo GetMarshallingInfo( // If we aren't overriding the marshalling at usage time, // then fall back to the information on the element type itself. - foreach (var typeAttribute in type.GetAttributes()) + foreach (AttributeData typeAttribute in type.GetAttributes()) { INamedTypeSymbol attributeClass = typeAttribute.AttributeClass!; @@ -326,7 +326,7 @@ private CountInfo CreateCountInfo(AttributeData marshalUsingData, ImmutableHashS { int? constSize = null; string? elementName = null; - foreach (var arg in marshalUsingData.NamedArguments) + foreach (KeyValuePair arg in marshalUsingData.NamedArguments) { if (arg.Key == ManualTypeMarshallingHelper.MarshalUsingProperties.ConstantElementCount) { @@ -463,7 +463,7 @@ private MarshallingInfo CreateInfoFromMarshalAs( SizeAndParamIndexInfo arraySizeInfo = SizeAndParamIndexInfo.Unspecified; // All other data on attribute is defined as NamedArguments. - foreach (var namedArg in attrData.NamedArguments) + foreach (KeyValuePair namedArg in attrData.NamedArguments) { switch (namedArg.Key) { @@ -611,12 +611,12 @@ private MarshallingInfo CreateNativeMarshallingInfo( bool isContiguousCollectionMarshaller = nativeType.GetAttributes().Any(attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, contiguousCollectionMarshalerAttribute)); IPropertySymbol? valueProperty = ManualTypeMarshallingHelper.FindValueProperty(nativeType); - var marshallingVariant = isContiguousCollectionMarshaller + ManualTypeMarshallingHelper.NativeTypeMarshallingVariant marshallingVariant = isContiguousCollectionMarshaller ? ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.ContiguousCollection : ManualTypeMarshallingHelper.NativeTypeMarshallingVariant.Standard; bool hasInt32Constructor = false; - foreach (var ctor in nativeType.Constructors) + foreach (IMethodSymbol ctor in nativeType.Constructors) { if (ManualTypeMarshallingHelper.IsManagedToNativeConstructor(ctor, type, marshallingVariant) && (valueProperty is null or { GetMethod: not null })) { @@ -705,7 +705,7 @@ private bool TryCreateTypeBasedMarshallingInfo( out MarshallingInfo marshallingInfo) { // Check for an implicit SafeHandle conversion. - var conversion = _compilation.ClassifyCommonConversion(type, _compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); + CodeAnalysis.Operations.CommonConversion conversion = _compilation.ClassifyCommonConversion(type, _compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_SafeHandle)!); if (conversion.Exists && conversion.IsImplicit && (conversion.IsReference || conversion.IsIdentity)) @@ -713,7 +713,7 @@ private bool TryCreateTypeBasedMarshallingInfo( bool hasAccessibleDefaultConstructor = false; if (type is INamedTypeSymbol named && !named.IsAbstract && named.InstanceConstructors.Length > 0) { - foreach (var ctor in named.InstanceConstructors) + foreach (IMethodSymbol ctor in named.InstanceConstructors) { if (ctor.Parameters.Length == 0) { @@ -786,7 +786,7 @@ private bool TryGetAttributeIndirectionLevel(AttributeData attrData, out int ind return false; } - foreach (var arg in attrData.NamedArguments) + foreach (KeyValuePair arg in attrData.NamedArguments) { if (arg.Key == ManualTypeMarshallingHelper.MarshalUsingProperties.ElementIndirectionLevel) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs index baa8c150fda06..5c5b6b48948d7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs @@ -83,7 +83,7 @@ private static ByValueContentsMarshalKind GetByValueContentsMarshalKind(IEnumera ByValueContentsMarshalKind marshalKind = ByValueContentsMarshalKind.Default; - foreach (var attr in attributes) + foreach (AttributeData attr in attributes) { if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, outAttributeType)) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs index 051c65e837283..9768e2d03ce69 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs @@ -1,11 +1,7 @@ // 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.Collections.Immutable; -using System.Diagnostics; -using System.Linq; using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; @@ -28,7 +24,7 @@ private static bool HasOnlyBlittableFields(this ITypeSymbol type, ImmutableHashS return false; } - foreach (var field in type.GetMembers().OfType()) + foreach (IFieldSymbol field in type.GetMembers().OfType()) { if (!field.IsStatic) { @@ -101,7 +97,7 @@ private static bool IsConsideredBlittable(this ITypeSymbol type, ImmutableHashSe bool hasNativeMarshallingAttribute = false; bool hasGeneratedMarshallingAttribute = false; // [TODO]: Match attributes on full name or symbol, not just on type name. - foreach (var attr in type.GetAttributes()) + foreach (AttributeData attr in type.GetAttributes()) { if (attr.AttributeClass is null) { @@ -151,7 +147,7 @@ private static bool IsConsideredBlittable(this ITypeSymbol type, ImmutableHashSe public static bool IsAutoLayout(this INamedTypeSymbol type, ITypeSymbol structLayoutAttributeType) { - foreach (var attr in type.GetAttributes()) + foreach (AttributeData attr in type.GetAttributes()) { if (SymbolEqualityComparer.Default.Equals(structLayoutAttributeType, attr.AttributeClass)) { From d81945e1e904cde6589db27c30032102fe659971 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 6 Oct 2021 07:47:45 -0700 Subject: [PATCH 154/161] Fix inconsistencies in order of GeneratedDllImport fields (#60049) --- .../Linux/System.Native/Interop.INotify.cs | 2 +- .../Unix/System.Native/Interop.Access.cs | 2 +- .../Interop.ForkAndExecProcess.cs | 2 +- .../System.Native/Interop.GetGroupList.cs | 2 +- .../System.Native/Interop.GetPeerUserName.cs | 2 +- .../Unix/System.Native/Interop.GetPwUid.cs | 2 +- .../Unix/System.Native/Interop.Open.cs | 2 +- .../Unix/System.Native/Interop.PathConf.cs | 2 +- .../Unix/System.Native/Interop.RealPath.cs | 2 +- .../Unix/System.Native/Interop.SNPrintF.cs | 4 ++-- .../Unix/System.Native/Interop.ShmOpen.cs | 4 ++-- .../Advapi32/Interop.ConvertSdToStringSd.cs | 4 ++-- .../Advapi32/Interop.ConvertStringSdToSd.cs | 4 ++-- .../Advapi32/Interop.ConvertStringSidToSid.cs | 4 ++-- .../Interop.CreateProcessWithLogon.cs | 2 +- .../Advapi32/Interop.CreateWellKnownSid.cs | 4 ++-- .../Advapi32/Interop.CryptAcquireContext.cs | 4 ++-- .../Windows/Advapi32/Interop.CryptSignHash.cs | 4 ++-- .../Advapi32/Interop.EncryptDecrypt.cs | 8 ++++---- .../Interop.GetSecurityDescriptorLength.cs | 2 +- .../Advapi32/Interop.GetSecurityInfoByName.cs | 4 ++-- .../Interop.GetWindowsAccountDomainSid.cs | 4 ++-- .../Advapi32/Interop.IsEqualDomainSid.cs | 4 ++-- .../Advapi32/Interop.IsWellKnownSid.cs | 4 ++-- .../Advapi32/Interop.LookupPrivilegeValue.cs | 4 ++-- .../Windows/Advapi32/Interop.LsaLookupSids.cs | 4 ++-- .../Windows/Advapi32/Interop.LsaOpenPolicy.cs | 4 ++-- .../Advapi32/Interop.RegConnectRegistry.cs | 4 ++-- .../Advapi32/Interop.RegCreateKeyEx.cs | 4 ++-- .../Advapi32/Interop.RegDeleteKeyEx.cs | 4 ++-- .../Advapi32/Interop.RegDeleteValue.cs | 4 ++-- .../Windows/Advapi32/Interop.RegOpenKeyEx.cs | 8 ++++---- .../Windows/Advapi32/Interop.RegSetValueEx.cs | 20 +++++++++---------- .../Windows/Advapi32/Interop.RevertToSelf.cs | 4 ++-- .../Interop.SetSecurityInfoByHandle.cs | 4 ++-- .../Advapi32/Interop.SetSecurityInfoByName.cs | 4 ++-- .../Common/src/Interop/Windows/BCrypt/Cng.cs | 2 +- .../Windows/Crypt32/Interop.CertNameToStr.cs | 4 ++-- .../Windows/Kernel32/Interop.CopyFileEx.cs | 4 ++-- .../Kernel32/Interop.CreateDirectory.cs | 4 ++-- .../Windows/Kernel32/Interop.CreateFile.cs | 4 ++-- .../Kernel32/Interop.CreateFile_IntPtr.cs | 4 ++-- .../Kernel32/Interop.CreateNamedPipe.cs | 2 +- .../Windows/Kernel32/Interop.CreateProcess.cs | 2 +- .../Windows/Kernel32/Interop.DeleteFile.cs | 4 ++-- .../Interop.DeleteVolumeMountPoint.cs | 4 ++-- .../Kernel32/Interop.EnumProcessModules.cs | 2 +- .../Windows/Kernel32/Interop.EnumProcesses.cs | 2 +- .../Interop.FillConsoleOutputAttribute.cs | 2 +- .../Interop.FillConsoleOutputCharacter.cs | 2 +- .../Windows/Kernel32/Interop.FormatMessage.cs | 4 ++-- .../Kernel32/Interop.GetConsoleTitle.cs | 2 +- .../Kernel32/Interop.GetFileAttributesEx.cs | 4 ++-- .../Kernel32/Interop.GetFullPathNameW.cs | 4 ++-- .../Kernel32/Interop.GetLongPathNameW.cs | 4 ++-- .../Kernel32/Interop.GetModuleBaseName.cs | 2 +- .../Kernel32/Interop.GetModuleFileNameEx.cs | 2 +- .../Kernel32/Interop.GetModuleInformation.cs | 2 +- .../Interop.GetNamedPipeHandleState.cs | 2 +- .../Kernel32/Interop.LoadLibraryEx_IntPtr.cs | 2 +- .../Windows/Kernel32/Interop.MoveFileEx.cs | 4 ++-- .../Kernel32/Interop.PeekConsoleInput.cs | 2 +- .../Windows/Kernel32/Interop.ReadConsole.cs | 2 +- .../Kernel32/Interop.ReadConsoleInput.cs | 4 +--- .../Kernel32/Interop.ReadConsoleOutput.cs | 2 +- .../Kernel32/Interop.RemoveDirectory.cs | 4 ++-- .../Windows/Kernel32/Interop.ReplaceFile.cs | 4 ++-- .../Kernel32/Interop.SetConsoleTitle.cs | 2 +- .../Kernel32/Interop.SetFileAttributes.cs | 4 ++-- .../Interop.SetFileInformationByHandle.cs | 4 ++-- .../Kernel32/Interop.SetThreadErrorMode.cs | 4 ++-- .../Windows/Kernel32/Interop.VirtualAlloc.cs | 2 +- .../Windows/Kernel32/Interop.VirtualQuery.cs | 4 ++-- .../Windows/Kernel32/Interop.WaitNamedPipe.cs | 2 +- .../Windows/Kernel32/Interop.WriteConsole.cs | 2 +- .../Kernel32/Interop.WriteConsoleOutput.cs | 2 +- .../Shell32/Interop.ShellExecuteExW.cs | 2 +- .../Interop/Windows/SspiCli/Interop.SSPI.cs | 12 +++++------ .../User32/Interop.GetWindowTextLengthW.cs | 2 +- .../Windows/User32/Interop.GetWindowTextW.cs | 2 +- .../Version/Interop.GetFileVersionInfoEx.cs | 2 +- .../Interop.GetFileVersionInfoSizeEx.cs | 2 +- .../Windows/Version/Interop.VerQueryValue.cs | 2 +- .../Windows/WinSock/Interop.GetAddrInfoExW.cs | 2 +- .../Windows/WinSock/Interop.GetAddrInfoW.cs | 2 +- .../Windows/WinSock/Interop.WSAIoctl.cs | 2 +- .../Pal.Windows/Native/Interop.crypt32.cs | 12 +++++------ .../Pal.Windows/Native/Interop.cryptoapi.cs | 2 +- 88 files changed, 153 insertions(+), 155 deletions(-) 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 7a900b6378d6b..f93f542f7229f 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_INotifyAddWatch", CharSet = CharSet.Ansi, 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/Unix/System.Native/Interop.Access.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs index fa33ed0947169..70728287b22ba 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Access", CharSet = CharSet.Ansi, SetLastError = true)] internal static partial int Access(string path, AccessMode mode); } } 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 6f50e53615553..295caba93c28d 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ForkAndExecProcess", CharSet = CharSet.Ansi, 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.GetGroupList.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroupList.cs index ec6228c91d77a..1b00355f570f0 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroupList", CharSet = CharSet.Ansi, 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 f45a343b60ab8..9dea586f1d6a0 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPeerUserName", CharSet = CharSet.Ansi, SetLastError = true)] internal static partial string GetPeerUserName(SafeHandle socket); } } 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 086a7b686535c..06b431cbffd0e 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", SetLastError = false, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwNamR", CharSet = CharSet.Ansi, 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.Open.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Open.cs index d80adcce03cfb..2024ee616943f 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Open", CharSet = CharSet.Ansi, 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 dc0501f171648..4ed5bbb552d92 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PathConf", CharSet = CharSet.Ansi, SetLastError = true)] private static partial int PathConf(string path, PathConfName name); } } 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 fc8983fd4cdff..8ff4105dae6bf 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RealPath", CharSet = CharSet.Ansi, SetLastError = true)] internal static partial string RealPath(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 ec3b5472066e8..47a20fd435727 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", CharSet = CharSet.Ansi, 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SNPrintF", CharSet = CharSet.Ansi, 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 5ebd90191cf33..7d559cb34f4a7 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", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmOpen", CharSet = CharSet.Ansi, SetLastError = true)] internal static partial SafeFileHandle ShmOpen(string name, OpenFlags flags, int mode); - [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", SetLastError = true, CharSet = CharSet.Ansi)] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", CharSet = CharSet.Ansi, SetLastError = true)] internal static partial int ShmUnlink(string name); } } 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 e975e09097069..a675aed0aefb9 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertSdToStringSd.cs @@ -10,11 +10,11 @@ internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertSecurityDescriptorToStringSecurityDescriptorW", - CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial bool ConvertSdToStringSd( #else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertSecurityDescriptorToStringSecurityDescriptorW", - CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern bool ConvertSdToStringSd( #endif byte[] securityDescriptor, 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 514b5ffa2d539..7e0aa27470b8b 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSdToSd.cs @@ -10,11 +10,11 @@ internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW", - CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial bool ConvertStringSdToSd( #else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW", - CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern bool ConvertStringSdToSd( #endif string stringSd, 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 b017d16e48157..63f5b0a0d44c5 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSidToSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSidToSid.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial int ConvertStringSidToSid( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int ConvertStringSidToSid( #endif string stringSid, 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 53e713e1931d3..a8bf04dae447b 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, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, EntryPoint = "CreateProcessWithLogonW")] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CreateProcessWithLogonW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static unsafe partial bool CreateProcessWithLogonW( string userName, string domain, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs index 3ed45cf793ff1..69c014a936236 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateWellKnownSid.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial int CreateWellKnownSid( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int CreateWellKnownSid( #endif int sidType, 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 df73355b41257..d45b7e14e9200 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext.cs @@ -21,10 +21,10 @@ internal enum CryptAcquireContextFlags : uint } #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CryptAcquireContextW")] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", CharSet = CharSet.Unicode, SetLastError = true)] public static partial bool CryptAcquireContext( #else - [DllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CryptAcquireContextW")] + [DllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", CharSet = CharSet.Unicode, SetLastError = true)] public static extern bool CryptAcquireContext( #endif out SafeProvHandle phProv, 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 a4fca2955717e..0d9f3a1703141 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptSignHashW")] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptSignHashW", CharSet = CharSet.Unicode, SetLastError = true)] 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptVerifySignatureW")] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptVerifySignatureW", CharSet = CharSet.Unicode, SetLastError = true)] 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 ace11221bddd8..659fbe352c687 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EncryptDecrypt.cs @@ -12,10 +12,10 @@ internal static partial class Advapi32 /// WARNING: This method does not implicitly handle long paths. Use EncryptFile. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool EncryptFilePrivate(string lpFileName); #else - [DllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool EncryptFilePrivate(string lpFileName); #endif @@ -29,10 +29,10 @@ internal static bool EncryptFile(string path) /// WARNING: This method does not implicitly handle long paths. Use DecryptFile. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool DecryptFileFilePrivate( #else - [DllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool DecryptFileFilePrivate( #endif string lpFileName, 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 388f5d4289784..e94bd4b0f18c2 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs @@ -9,7 +9,7 @@ internal static partial class Interop internal static partial class Advapi32 { [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityDescriptorLength", CallingConvention = CallingConvention.Winapi, - ExactSpelling = true, CharSet = CharSet.Unicode)] + CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern /*DWORD*/ 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 a140d1f02d819..9b480db68b3fa 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityInfoByName.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial uint GetSecurityInfoByName( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern /*DWORD*/ uint GetSecurityInfoByName( #endif string name, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs index b34b47f44e6b0..6070b3e70c9e0 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetWindowsAccountDomainSid.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial int GetWindowsAccountDomainSid( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int GetWindowsAccountDomainSid( #endif byte[] sid, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs index c18d90e335b2e..80fa089f74e01 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsEqualDomainSid.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial int IsEqualDomainSid( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int IsEqualDomainSid( #endif byte[] sid1, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs index c12c218c31aab..fa63e7e406442 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.IsWellKnownSid.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial int IsWellKnownSid( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int IsWellKnownSid( #endif 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 87b7b56cd63be..c4276f4af72ee 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupPrivilegeValue.cs @@ -8,10 +8,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "LookupPrivilegeValueW")] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "LookupPrivilegeValueW", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial bool LookupPrivilegeValue( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "LookupPrivilegeValueW")] + [DllImport(Libraries.Advapi32, EntryPoint = "LookupPrivilegeValueW", CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)] internal static extern bool LookupPrivilegeValue( #endif [MarshalAs(UnmanagedType.LPTStr)] string? lpSystemName, [MarshalAs(UnmanagedType.LPTStr)] string lpName, out LUID lpLuid); diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs index 03829ca35da3e..f49432c0654ab 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs @@ -10,10 +10,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial uint LsaLookupSids( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern uint LsaLookupSids( #endif SafeLsaPolicyHandle handle, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs index ea6366e9c7095..ca2278a70c55b 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs @@ -10,10 +10,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", CharSet = CharSet.Unicode, SetLastError = true)] private static partial uint LsaOpenPolicy( #else - [DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", CharSet = CharSet.Unicode, SetLastError = true)] private static extern uint LsaOpenPolicy( #endif ref UNICODE_STRING SystemName, 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 48f23e3adeef1..83206d9f75ced 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs @@ -15,10 +15,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegConnectRegistryW")] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegConnectRegistryW", CharSet = CharSet.Unicode)] internal static partial int RegConnectRegistry( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegConnectRegistryW")] + [DllImport(Libraries.Advapi32, EntryPoint = "RegConnectRegistryW", CharSet = CharSet.Unicode, BestFitMapping = false)] internal static extern int RegConnectRegistry( #endif string machineName, 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 13615b73722f6..44671dd679c0c 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs @@ -15,10 +15,10 @@ internal static partial class Advapi32 // Note: RegCreateKeyEx won't set the last error on failure - it returns // an error code if it fails. #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegCreateKeyExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegCreateKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegCreateKeyEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegCreateKeyExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegCreateKeyExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegCreateKeyEx( #endif SafeRegistryHandle hKey, 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 2f0fe680d2509..d7a5752143430 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs @@ -13,10 +13,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegDeleteKeyExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegDeleteKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegDeleteKeyEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteKeyExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegDeleteKeyExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegDeleteKeyEx( #endif SafeRegistryHandle hKey, 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 7fd43861c8e90..50824a4ede142 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs @@ -13,10 +13,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegDeleteValueW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegDeleteValueW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegDeleteValue( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteValueW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegDeleteValueW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegDeleteValue( #endif SafeRegistryHandle hKey, 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 b6db23b7da19a..4ffba18c4a2c6 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs @@ -14,10 +14,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegOpenKeyEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegOpenKeyEx( #endif SafeRegistryHandle hKey, @@ -28,10 +28,10 @@ internal static extern int RegOpenKeyEx( #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegOpenKeyEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegOpenKeyExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegOpenKeyEx( #endif IntPtr hKey, 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 fca1abbed5f30..8bb444aa563f3 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs @@ -13,10 +13,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegSetValueEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegSetValueEx( #endif SafeRegistryHandle hKey, @@ -27,10 +27,10 @@ internal static extern int RegSetValueEx( int cbData); #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegSetValueEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegSetValueEx( #endif SafeRegistryHandle hKey, @@ -41,10 +41,10 @@ internal static extern int RegSetValueEx( int cbData); #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegSetValueEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegSetValueEx( #endif SafeRegistryHandle hKey, @@ -55,10 +55,10 @@ internal static extern int RegSetValueEx( int cbData); #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegSetValueEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegSetValueEx( #endif SafeRegistryHandle hKey, @@ -69,10 +69,10 @@ internal static extern int RegSetValueEx( int cbData); #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static partial int RegSetValueEx( #else - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW", ExactSpelling = true)] + [DllImport(Libraries.Advapi32, EntryPoint = "RegSetValueExW", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int RegSetValueEx( #endif SafeRegistryHandle hKey, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs index d314a941100df..5b1eb051b00d4 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RevertToSelf.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial bool RevertToSelf(); #else - [DllImport(Interop.Libraries.Advapi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern bool RevertToSelf(); #endif } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs index 1fb0133cc151c..1a4d74d887651 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByHandle.cs @@ -10,11 +10,11 @@ internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "SetSecurityInfo", CallingConvention = CallingConvention.Winapi, - SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial uint SetSecurityInfoByHandle( #else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "SetSecurityInfo", CallingConvention = CallingConvention.Winapi, - SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern /*DWORD*/ uint SetSecurityInfoByHandle( #endif SafeHandle handle, 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 1022b647c3bb6..ae52e9ed1a088 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetSecurityInfoByName.cs @@ -10,11 +10,11 @@ internal static partial class Advapi32 { #if DLLIMPORTGENERATOR_ENABLED [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "SetNamedSecurityInfoW", CallingConvention = CallingConvention.Winapi, - SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial uint SetSecurityInfoByName( #else [DllImport(Interop.Libraries.Advapi32, EntryPoint = "SetNamedSecurityInfoW", CallingConvention = CallingConvention.Winapi, - SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern /*DWORD*/ uint SetSecurityInfoByName( #endif string name, diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs index 5be6c3754f64d..eaafec4d7f807 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs @@ -127,7 +127,7 @@ internal static partial class Interop [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] public static partial NTSTATUS BCryptSetProperty(SafeAlgorithmHandle hObject, string pszProperty, string pbInput, int cbInput, int dwFlags); - [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode, EntryPoint = "BCryptSetProperty")] + [GeneratedDllImport(Libraries.BCrypt, EntryPoint = "BCryptSetProperty", CharSet = CharSet.Unicode)] 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/Crypt32/Interop.CertNameToStr.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs index ebb45e1a86829..534dc6418c9c7 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertNameToStr.cs @@ -8,10 +8,10 @@ internal static partial class Interop internal static partial class Crypt32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertNameToStrW")] + [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertNameToStrW", CharSet = CharSet.Unicode, SetLastError = true)] internal static unsafe partial int CertNameToStr( #else - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertNameToStrW")] + [DllImport(Libraries.Crypt32, EntryPoint = "CertNameToStrW", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern unsafe int CertNameToStr( #endif int dwCertEncodingType, 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 c878ec9ca1f20..2dd22d45b3ae4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CopyFileEx.cs @@ -13,10 +13,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use CopyFileEx. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool CopyFileExPrivate( #else - [DllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool CopyFileExPrivate( #endif string src, 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 e642ed22fff60..60c13362b8eda 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateDirectory.cs @@ -13,10 +13,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use CreateDirectory. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool CreateDirectoryPrivate( #else - [DllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool CreateDirectoryPrivate( #endif string path, 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 0702187ea4f92..f26661c5e2635 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFile.cs @@ -14,10 +14,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static unsafe partial SafeFileHandle CreateFilePrivate( #else - [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static unsafe extern SafeFileHandle CreateFilePrivate( #endif string lpFileName, 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 cc3bee28befd7..41b2f88d22343 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 @@ -13,10 +13,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use CreateFile. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static unsafe partial IntPtr CreateFilePrivate_IntPtr( #else - [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static unsafe extern IntPtr CreateFilePrivate_IntPtr( #endif string lpFileName, 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 9afae1e1430ec..cc190de6989c7 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CreateNamedPipeW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateNamedPipeW", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial SafePipeHandle CreateNamedPipe( string pipeName, int openMode, 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 f794ecd3453eb..c31f8a36755cb 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CreateProcessW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateProcessW", CharSet = CharSet.Unicode, SetLastError = true)] internal static unsafe partial bool CreateProcess( string? lpApplicationName, char* lpCommandLine, 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 41f2e58cdf767..a811e31f4f49f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteFile.cs @@ -13,10 +13,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use DeleteFile. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool DeleteFilePrivate(string path); #else - [DllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool DeleteFilePrivate(string path); #endif 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 9461da826576b..e898e36613477 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeleteVolumeMountPoint.cs @@ -13,10 +13,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use DeleteVolumeMountPoint. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial bool DeleteVolumeMountPointPrivate(string mountPoint); #else - [DllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool DeleteVolumeMountPointPrivate(string mountPoint); #endif 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 019e4e9a7db0e..e88e5050b84cb 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32EnumProcessModules")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32EnumProcessModules", CharSet = CharSet.Unicode, SetLastError = true)] 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 60cc47d3e6113..6ffb508d3f018 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32EnumProcesses")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32EnumProcesses", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial bool EnumProcesses(int[] processIds, int size, out int needed); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs index 5cad2a13ba0b0..9d8542a8a3449 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FillConsoleOutputAttribute.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] internal static partial bool FillConsoleOutputAttribute(IntPtr hConsoleOutput, short wColorAttribute, int numCells, COORD startCoord, out int pNumBytesWritten); } } 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 3bb435cad7468..4e9f464e4702a 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, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FillConsoleOutputCharacterW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FillConsoleOutputCharacterW", CharSet = CharSet.Unicode, SetLastError = true)] 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.FormatMessage.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs index e327cb2851f45..056451573f127 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs @@ -16,10 +16,10 @@ internal static partial class Kernel32 private const int ERROR_INSUFFICIENT_BUFFER = 0x7A; #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FormatMessageW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static unsafe partial int FormatMessage( #else - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, BestFitMapping = true, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, EntryPoint = "FormatMessageW", BestFitMapping = true, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static extern unsafe int FormatMessage( #endif int dwFlags, 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 bfeac321ec592..f757cfa892cd3 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, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static unsafe partial uint GetConsoleTitleW(char* title, 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 d7c4f3ec51c02..25ca04d5c2eb8 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs @@ -12,10 +12,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use GetFileAttributesEx. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static partial bool GetFileAttributesExPrivate( #else - [DllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, EntryPoint = "GetFileAttributesExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static extern bool GetFileAttributesExPrivate( #endif string? name, 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 f824fd79d76fe..191cfd64591d1 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs @@ -12,10 +12,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use GetFullPathName or PathHelper. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial uint GetFullPathNameW( #else - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern uint GetFullPathNameW( #endif ref char lpFileName, 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 b3be36d9007f5..d37dc3c673e66 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs @@ -11,10 +11,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use GetFullPath/PathHelper. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial uint GetLongPathNameW( #else - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern uint GetLongPathNameW( #endif ref char lpszShortPath, 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 9903c0c0c573d..930b96442f112 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32GetModuleBaseNameW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleBaseNameW", CharSet = CharSet.Unicode, SetLastError = true)] 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.GetModuleFileNameEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileNameEx.cs index 9e84b60d47519..285ad50403d8f 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32GetModuleFileNameExW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleFileNameExW", CharSet = CharSet.Unicode, SetLastError = true)] 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.GetModuleInformation.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleInformation.cs index a63d7592a54c6..73470ceecb841 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "K32GetModuleInformation")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "K32GetModuleInformation", CharSet = CharSet.Unicode, SetLastError = true)] 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 74c60e6376116..a8c28bf9ca4ea 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, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static unsafe partial bool GetNamedPipeHandleStateW( SafePipeHandle hNamedPipe, uint* lpState, 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 92e78b85ac044..78d1c184fb8a2 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, CharSet = CharSet.Unicode, EntryPoint = "LoadLibraryExW", SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "LoadLibraryExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial IntPtr LoadLibraryEx(string libFilename, IntPtr reserved, int flags); } } 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 a0b3a39b6bde0..b76e051ab114f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MoveFileEx.cs @@ -16,10 +16,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use MoveFile. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool MoveFileExPrivate( #else - [DllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool MoveFileExPrivate( #endif string src, string dst, uint flags); 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 ed972c79dcc72..179d0b29dbe6f 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, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PeekConsoleInputW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "PeekConsoleInputW", CharSet = CharSet.Unicode, SetLastError = true)] 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 adfd028aade3b..022d0849b5e38 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "ReadConsoleW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleW", CharSet = CharSet.Unicode, SetLastError = true)] 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 a2fb18ecc76df..c6ed13076daf5 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReadConsoleInput.cs @@ -32,9 +32,7 @@ internal struct InputRecord internal static partial class Kernel32 { - - [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "ReadConsoleInputW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleInputW", CharSet = CharSet.Unicode, SetLastError = true)] 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 c755198df6914..d5722aea5ecb9 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, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "ReadConsoleOutputW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReadConsoleOutputW", CharSet = CharSet.Unicode, SetLastError = true)] 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.RemoveDirectory.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs index f1a6683cace38..96754abc2f5a8 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.RemoveDirectory.cs @@ -13,10 +13,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use RemoveDirectory. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool RemoveDirectoryPrivate(string path); #else - [DllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool RemoveDirectoryPrivate(string path); #endif 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 051f6c6295696..cb1353628b3af 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ReplaceFile.cs @@ -10,10 +10,10 @@ internal static partial class Interop internal static partial class Kernel32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool ReplaceFilePrivate( #else - [DllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool ReplaceFilePrivate( #endif string replacedFileName, string replacementFileName, string? backupFileName, 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 f25b7ba251130..246f395c9a024 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "SetConsoleTitleW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetConsoleTitleW", CharSet = CharSet.Unicode, SetLastError = true)] internal static partial bool SetConsoleTitle(string title); } } 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 03de746fce808..4e436e0c49dc0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileAttributes.cs @@ -12,10 +12,10 @@ internal static partial class Kernel32 /// WARNING: This method does not implicitly handle long paths. Use SetFileAttributes. /// #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", CharSet = CharSet.Unicode, SetLastError = true)] private static partial bool SetFileAttributesPrivate( #else - [DllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool SetFileAttributesPrivate( #endif string name, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs index 9987aeccbebe4..28361c06f9134 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFileInformationByHandle.cs @@ -10,10 +10,10 @@ internal static partial class Interop internal static partial class Kernel32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static unsafe partial bool SetFileInformationByHandle( #else - [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static unsafe extern bool SetFileInformationByHandle( #endif SafeFileHandle hFile, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs index ff10cfef54791..8028a1256e44a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs @@ -9,10 +9,10 @@ internal static partial class Kernel32 { [SuppressGCTransition] #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static partial bool SetThreadErrorMode( #else - [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static extern bool SetThreadErrorMode( #endif uint dwNewMode, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs index 02bcf91db320d..1d5ec8ec56848 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static partial IntPtr VirtualAlloc(SafeHandle lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs index 856191602bda2..9ede606895a45 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs @@ -9,10 +9,10 @@ internal static partial class Interop internal static partial class Kernel32 { #if DLLIMPORTGENERATOR_ENABLED - [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static partial UIntPtr VirtualQuery( #else - [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] + [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static extern UIntPtr VirtualQuery( #endif SafeHandle lpAddress, 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 76abe2bca8ea4..118464eac29fb 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "WaitNamedPipeW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WaitNamedPipeW", CharSet = CharSet.Unicode, SetLastError = true)] [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 bb56c3e165cdb..95b6495d216db 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, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "WriteConsoleW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WriteConsoleW", CharSet = CharSet.Unicode, SetLastError = true)] 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 9cb88c72fb14a..d656cebed02c3 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, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "WriteConsoleOutputW")] + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "WriteConsoleOutputW", CharSet = CharSet.Unicode, SetLastError = true)] 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/Shell32/Interop.ShellExecuteExW.cs b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ShellExecuteExW.cs index eab55a0f92914..b9af6b4b5df46 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Libraries.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true, 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 3a9de198153f2..cc4ee4b7b5904 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static partial SECURITY_STATUS SspiEncodeStringsAsAuthIdentity( string userName, string domainName, @@ -476,7 +476,7 @@ internal static partial SECURITY_STATUS SspiEncodeStringsAsAuthIdentity( out SafeSspiAuthDataHandle authData); // TODO: Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) - [DllImport(Interop.Libraries.SspiCli, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [DllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern SECURITY_STATUS SetCredentialsAttributesW( in CredHandle handlePtr, long ulAttribute, diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs index 24d2cdde6438a..59cf89deed657 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowTextLengthW.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [GeneratedDllImport(Libraries.User32, SetLastError = true, ExactSpelling = true)] + [GeneratedDllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] public static partial int GetWindowTextLengthW(IntPtr hWnd); } } 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 2e11079cd1096..f83224da351ad 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, ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] public static unsafe partial int GetWindowTextW(IntPtr hWnd, char* lpString, int nMaxCount); } } 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 330b4626b867d..f5ce78b9bafe4 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, CharSet = CharSet.Unicode, EntryPoint = "GetFileVersionInfoExW")] + [GeneratedDllImport(Libraries.Version, EntryPoint = "GetFileVersionInfoExW", CharSet = CharSet.Unicode)] 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 6eddc000b3463..db3286789798d 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, CharSet = CharSet.Unicode, EntryPoint = "GetFileVersionInfoSizeExW")] + [GeneratedDllImport(Libraries.Version, EntryPoint = "GetFileVersionInfoSizeExW", CharSet = CharSet.Unicode)] 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 8dffcdb22a018..a3674ed10300a 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, CharSet = CharSet.Unicode, EntryPoint = "VerQueryValueW")] + [GeneratedDllImport(Libraries.Version, EntryPoint = "VerQueryValueW", CharSet = CharSet.Unicode)] internal static partial bool VerQueryValue(IntPtr pBlock, string lpSubBlock, out IntPtr lplpBuffer, out uint puLen); } } 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 8501c538ba0e0..2467400c6dc3d 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Libraries.Ws2_32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] 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 d3a28a4808e21..bca3683b7b4fe 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, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] + [GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static unsafe partial int GetAddrInfoW( string pNameName, string? pServiceName, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs index 53f7738ab9ac9..37265789dc827 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs @@ -22,7 +22,7 @@ internal static extern SocketError WSAIoctl( [In] IntPtr shouldBeNull, [In] IntPtr shouldBeNull2); - [GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true, EntryPoint = "WSAIoctl")] + [GeneratedDllImport(Interop.Libraries.Ws2_32, EntryPoint = "WSAIoctl", SetLastError = true)] internal static partial SocketError WSAIoctl_Blocking( SafeSocketHandle socketHandle, int ioControlCode, diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs index 8c6f33c1991ab..24eb1081904a4 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs @@ -77,7 +77,7 @@ IntPtr ppvContext [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] public static partial bool CertGetCertificateContextProperty(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, out IntPtr pvData, ref int pcbData); - [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertGetCertificateContextProperty")] + [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertGetCertificateContextProperty", CharSet = CharSet.Unicode, SetLastError = true)] public static unsafe partial bool CertGetCertificateContextPropertyString(SafeCertContextHandle pCertContext, CertContextPropId dwPropId, byte* pvData, ref int pcbData); [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] @@ -114,7 +114,7 @@ public static unsafe string CertGetNameString( } } - [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertGetNameStringW")] + [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertGetNameStringW", CharSet = CharSet.Unicode, SetLastError = true)] private static unsafe partial int CertGetNameString(SafeCertContextHandle pCertContext, CertNameType dwType, CertNameFlags dwFlags, in CertNameStringType pvTypePara, char* pszNameString, int cchNameString); [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] @@ -126,7 +126,7 @@ public static unsafe string CertGetNameString( [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] internal static partial SafeCertStoreHandle CertDuplicateStore(IntPtr hCertStore); - [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertDuplicateCertificateContext")] + [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertDuplicateCertificateContext", CharSet = CharSet.Unicode, SetLastError = true)] public static partial SafeCertContextHandleWithKeyContainerDeletion CertDuplicateCertificateContextWithKeyContainerDeletion(IntPtr pCertContext); public static SafeCertStoreHandle CertOpenStore(CertStoreProvider lpszStoreProvider, CertEncodingType dwMsgAndCertEncodingType, IntPtr hCryptProv, CertStoreFlags dwFlags, string? pvPara) @@ -192,7 +192,7 @@ public static unsafe bool CertEnumCertificatesInStore(SafeCertStoreHandle hCertS [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] public static partial bool PFXExportCertStore(SafeCertStoreHandle hStore, ref CRYPTOAPI_BLOB pPFX, SafePasswordHandle szPassword, PFXExportFlags dwFlags); - [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CertStrToNameW")] + [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertStrToNameW", CharSet = CharSet.Unicode, SetLastError = true)] public static partial bool CertStrToName(CertEncodingType dwCertEncodingType, string pszX500, CertNameStrTypeAndFlags dwStrType, IntPtr pvReserved, byte[]? pbEncoded, ref int pcbEncoded, IntPtr ppszError); public static bool CryptDecodeObject(CertEncodingType dwCertEncodingType, CryptDecodeObjectStructType lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, byte[]? pvStructInfo, ref int pcbStructInfo) @@ -208,10 +208,10 @@ public static unsafe bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodi return CryptDecodeObjectPointer(dwCertEncodingType, (IntPtr)lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo, ref pcbStructInfo); } - [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptDecodeObject")] + [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CryptDecodeObject", CharSet = CharSet.Unicode, SetLastError = true)] private static unsafe partial bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodingType, IntPtr lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo); - [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CryptDecodeObject")] + [GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CryptDecodeObject", CharSet = CharSet.Unicode, SetLastError = true)] public static unsafe partial bool CryptDecodeObjectPointer(CertEncodingType dwCertEncodingType, [MarshalAs(UnmanagedType.LPStr)] string lpszStructType, byte[] pbEncoded, int cbEncoded, CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo); public static unsafe bool CryptEncodeObject(CertEncodingType dwCertEncodingType, CryptDecodeObjectStructType lpszStructType, void* pvStructInfo, byte[]? pbEncoded, ref int pcbEncoded) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs index 8037dac0ec0af..8b3c2d043b457 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.cryptoapi.cs @@ -14,7 +14,7 @@ internal static partial class Interop { public static partial class cryptoapi { - [GeneratedDllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CryptAcquireContextW")] + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static unsafe partial bool CryptAcquireContext(out IntPtr psafeProvHandle, char* pszContainer, char* pszProvider, int dwProvType, CryptAcquireContextFlags dwFlags); } From 2dff7cd61bc28fadda30e44591cee34f54def726 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 6 Oct 2021 09:40:26 -0700 Subject: [PATCH 155/161] Dllimport generator build and test fixes (#59658) --- eng/Versions.props | 2 +- eng/generators.targets | 10 +- eng/native/output-toolchain-info.cmake | 21 ++++ .../Windows/Kernel32/Interop.CloseHandle.cs | 7 +- .../Windows/Kernel32/Interop.FormatMessage.cs | 8 +- .../Kernel32/Interop.GetFullPathNameW.cs | 2 +- .../Kernel32/Interop.GetLongPathNameW.cs | 3 +- ...System.IO.Compression.ZipFile.Tests.csproj | 2 + ...ileSystem.DisabledFileLocking.Tests.csproj | 1 + .../System.Net.Http.Functional.Tests.csproj | 1 + .../DllImportGenerator.Tests/AssemblyInfo.cs | 10 ++ .../DllImportGenerator.Tests.csproj | 2 +- .../FunctionPointerTests.cs | 4 +- .../DllImportGenerator.UnitTests.csproj | 2 +- .../DelegatesAndFunctionPointers.cs | 21 ++++ .../NativeExports/NativeExports.csproj | 96 +++++++++++++++++++ src/libraries/tests.proj | 15 +++ src/samples/Directory.Build.props | 8 ++ src/samples/Directory.Build.targets | 5 + .../DllImportGeneratorSample.csproj | 1 + .../DllImportGeneratorSample/Program.cs | 11 ++- 21 files changed, 206 insertions(+), 26 deletions(-) create mode 100644 eng/native/output-toolchain-info.cmake create mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs create mode 100644 src/samples/Directory.Build.props create mode 100644 src/samples/Directory.Build.targets diff --git a/eng/Versions.props b/eng/Versions.props index bee17626e1f47..b7e09d4ad6e62 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -144,7 +144,7 @@ 1.0.0-beta-build0015 1.0.4-preview6.19326.1 0.2.61701 - 1.0.23 + 1.0.26 $(NetCoreAppCurrent)-Unix diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj index 718551f9b65d5..29bbd6f8f083e 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj @@ -7,6 +7,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX + true diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs new file mode 100644 index 0000000000000..f95036d8de482 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit; + +// We build the libraries tests in CI once per target OS+Arch+Configuration, but we share it between runtime test runs. +// As a result, we need to exclude the Mono run here since we build the tests once for CoreCLR and Mono for desktop test runs. +// We should switch this to another mechanism in the future so we don't submit a work item of this assembly that skips every test +// for Mono-on-Desktop-Platforms test runs. +[assembly:ActiveIssue("https://github.com/dotnet/runtime/issues/59815", TestRuntimes.Mono)] diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 887a041b0e061..351241b66278d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppCurrent) + $(NetCoreAppCurrent) false Preview true diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs index f083c24f4131f..87332f16e2d67 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs @@ -13,7 +13,7 @@ partial class NativeExportsNE { public partial class FunctionPointer { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_after_gc")] public static unsafe partial void InvokeAfterGC(delegate* cb); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] @@ -22,7 +22,7 @@ public partial class FunctionPointer [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] public static unsafe partial void InvokeAfterGC(delegate* unmanaged[Stdcall] cb); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_blittable_args")] public static unsafe partial int InvokeWithBlittableArgument(delegate* cb, int a, int b); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index 89b2d192140ce..6186cea54a53b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -1,7 +1,7 @@  - $(NetCoreAppCurrent) + $(NetCoreAppCurrent) false Preview enable diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs index 50abe95c3a381..8925bcd038f2b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs @@ -23,10 +23,31 @@ public static void InvokeCallbackAfterGCCollect(delegate* unmanaged fptr) fptr(); } + [UnmanagedCallersOnly(EntryPoint = "invoke_managed_callback_after_gc")] + public static void InvokeManagedCallbackAfterGCCollect(void* fptr) + { + // We are at the mercy of the GC to verify our delegate has been retain + // across the native function call. This is a best effort validation. + for (int i = 0; i < 5; ++i) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + + // If the corresponding Delegate was collected, the runtime will rudely abort. + ((delegate*)fptr)(); + } + [UnmanagedCallersOnly(EntryPoint = "invoke_callback_blittable_args")] public static int InvokeCallbackWithBlittableArgument(delegate* unmanaged fptr, int a, int b) { return fptr(a, b); } + + [UnmanagedCallersOnly(EntryPoint = "invoke_managed_callback_blittable_args")] + public static int InvokeManagedCallbackWithBlittableArgument(void* fptr, int a, int b) + { + return ((delegate*)fptr)(a, b); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 00a8f53fd133b..c93a8ac56d9e0 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -7,6 +7,9 @@ true true Major + + $(OutputRid) + $(OutputRid) @@ -17,4 +20,97 @@ + + + $(Compiler) + clang + + + + + + + + + + + + + + + + + + + + + --target=$(TargetTriple) --gcc-toolchain=$(ROOTFS_DIR)/usr --sysroot=$(ROOTFS_DIR) + $(CommonToolchainArgs) $(DnneLinkerUserFlags.Replace(';',' ')) + $(CommonToolchainArgs) $(DnneCompilerUserFlags.Replace(';',' ')) + + + + + + arm64-apple-ios14.2-macabi + x86_64-apple-ios13.5-macabi + + + arm64-apple-macos11 + x86_64-apple-macos10.13 + macosx + + + + + + + + + + + + + + + + -target $(TargetTriple) + -isysroot "$(SysRootIncludePath)" -target $(TargetTriple) + + + + + + $([System.IO.Path]::GetDirectoryName('$(AppHostSourcePath)')) + + diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index aefca41a35b6b..05d56f00feedd 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -32,6 +32,21 @@ + + + + + + + + + + + + + + + diff --git a/src/samples/Directory.Build.props b/src/samples/Directory.Build.props new file mode 100644 index 0000000000000..4590be123eb7f --- /dev/null +++ b/src/samples/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + true + true + + diff --git a/src/samples/Directory.Build.targets b/src/samples/Directory.Build.targets new file mode 100644 index 0000000000000..74fb272013ea8 --- /dev/null +++ b/src/samples/Directory.Build.targets @@ -0,0 +1,5 @@ + + + + + diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index f42621f44c254..32bd062dfe8c7 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -16,6 +16,7 @@ + diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index 6e2f1defd97c7..4a1c8335bf418 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -1,9 +1,12 @@ -using System; +// 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.Runtime.InteropServices; namespace Demo { - partial class NativeExportsNE + internal static partial class NativeExportsNE { public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE); @@ -17,9 +20,9 @@ partial class NativeExportsNE public static partial void Sum(int a, ref int b); } - class Program + internal static class Program { - static void Main(string[] args) + public static void Main(string[] args) { int a = 12; int b = 13; From a8b691d6c769c4521f3e72cd5999cf8d53daddcc Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 6 Oct 2021 12:03:01 -0700 Subject: [PATCH 156/161] Fix incorrect endif location that broke the build. --- .../src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs | 2 +- .../src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 2c8777610129e..191cfd64591d1 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs @@ -16,8 +16,8 @@ internal static partial class Kernel32 internal static partial uint GetFullPathNameW( #else [DllImport(Libraries.Kernel32, BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] -#endif internal static extern uint GetFullPathNameW( +#endif ref char lpFileName, uint nBufferLength, ref char lpBuffer, 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 90c999b80ed54..10d536df0964e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs @@ -15,8 +15,8 @@ internal static partial class Kernel32 internal static partial uint GetLongPathNameW( #else [DllImport(Libraries.Kernel32, BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] -#endif internal static extern uint GetLongPathNameW( +#endif ref char lpszShortPath, ref char lpszLongPath, uint cchBuffer); From cc8ed0015859ca222f986c9c2eceaffefbb3194c Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Sat, 9 Oct 2021 09:33:14 -0700 Subject: [PATCH 157/161] Updates to DllImportGenerator docs (#60211) --- .../DllImportGenerator/Compatibility.md | 8 ++-- .../DllImportGenerator/RuntimeConsumption.md | 43 ------------------- 2 files changed, 3 insertions(+), 48 deletions(-) delete mode 100644 docs/design/libraries/DllImportGenerator/RuntimeConsumption.md diff --git a/docs/design/libraries/DllImportGenerator/Compatibility.md b/docs/design/libraries/DllImportGenerator/Compatibility.md index 3a6ab0e6c94d5..2790eff6e8943 100644 --- a/docs/design/libraries/DllImportGenerator/Compatibility.md +++ b/docs/design/libraries/DllImportGenerator/Compatibility.md @@ -47,7 +47,7 @@ When converting from native to managed, the built-in system would throw a [`Mars 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`, `CharSet.Auto`, or `UnmanagedType.LPStr`): +When marshalling as [ANSI](https://docs.microsoft.com/windows/win32/intl/code-pages) on Windows (using `CharSet.Ansi` or `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`. @@ -65,13 +65,11 @@ Specifying array-specific marshalling members on the `MarshalAsAttribute` such a Only single-dimensional arrays are supported for source generated marshalling. -Jagged arrays (arrays of arrays) are technically unsupported as was the case in the built-in marshalling system, but currently are not explicitly blocked by the source generator since they are not blocked at an architectural level, which was the case in the built-in system. - In the source-generated marshalling, arrays will be allocated on the stack (instead of through [`AllocCoTaskMem`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.alloccotaskmem)) if they are passed by value or by read-only reference if they contain at most 256 bytes of data. The built-in system does not support this optimization for arrays. ### `in` keyword -For some types - blittable or Unicode `char` - passed by read-only reference via the [`in` keyword](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/in-parameter-modifier), the built-in system simply pins the parameter. The generated marshalling code does the same. A consequence of this behaviour is that any modifications made by the invoked function will be reflected in the caller. It is left to the user to avoid the situation in which `in` is used for a parameter that will actually be modified by the invoked function. +For some types - blittable or Unicode `char` - passed by read-only reference via the [`in` keyword](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/in-parameter-modifier), the built-in system simply pins the parameter. The generated marshalling code does the same, such that there is no behavioural difference. A consequence of this behaviour is that any modifications made by the invoked function will be reflected in the caller. It is left to the user to avoid the situation in which `in` is used for a parameter that will actually be modified by the invoked function. ### `LCIDConversion` support @@ -92,6 +90,6 @@ Unlike the built-in system, the source generator does not support marshalling fo - [`HandleRef`](https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.handleref) - [`StringBuilder`](https://docs.microsoft.com/dotnet/api/system.text.stringbuilder) -## Verison 0 +## Version 0 This version is the built-in IL Stub generation system that is triggered whenever a method marked with `DllImport` is invoked. diff --git a/docs/design/libraries/DllImportGenerator/RuntimeConsumption.md b/docs/design/libraries/DllImportGenerator/RuntimeConsumption.md deleted file mode 100644 index fa087a8db5ebd..0000000000000 --- a/docs/design/libraries/DllImportGenerator/RuntimeConsumption.md +++ /dev/null @@ -1,43 +0,0 @@ -# Integration into dotnet/runtime - -The prototype phase of the `DllImport` source generator is complete. The process and work done was tracked at [dotnet/runtime@43060](https://github.com/dotnet/runtime/issues/43060). The results of the prototype have provided us with some confidence that the current approach is viable and can move forward to consume the source generator in the .NET 7 timeframe. The plan for integration into the dotnet/runtime repository follows. - -Converting the prototype into a production ready product is required prior to consumption in the product. This means integration will be done in two phases, production-ready and consumption, that can be done in parallel in many cases. There is a third phase that is considered a stretch goal – productization. - -## Production-ready - -The following items must be considered to make this prototype production-ready. - -**Move source from dotnet/runtimelab** – Move the prototype source from its branch in [dotnet/runtimelab](https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator/DllImportGenerator) to [dotnet/runtime](https://github.com/dotnet/runtime). Guidance on destination can be found at [`project-guidelines.md`](https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/project-guidelines.md) – plan is under `libraries/System.Runtime.InteropServices`. Commit history should be retained during this move. - - Includes unit and scenario test integration into the `libraries/` pattern. - -**Attributes into `System.Private.CoreLib`** – Prior to productization, triggering and support attributes should be moved into a global space for consumption by `NetCoreApp`. - -**Product impact tenets** – Size impact, security, and convention reviews. Patterns have been uncovered that could be improved upon in the source generation step. Collapsing some of these patterns would help with reducing size impact and addressing potential security issues. Code generation convention changes may result in API proposals for marshal helpers – see [struct marshalling](./StructMarshalling.md). - -**UX** – Source generators can run from a command line build as well as from the IDE. Running from within the IDE will impact the UX of the IDE and therefore performance investigations are needed to ensure the generator doesn't degrade the developer inner-loop. - -**Stakeholder feedback** – An exit criteria for the prototype was to reach out to stakeholders and get feedback on the experience and generated code. Responses to all feedback prior to product consumption is expected. - -## Consumption - -The following items must be considered to make the prototype consumable in [dotnet/runtime repository](https://github.com/dotnet/runtime). - -**In-box source generation** – Guidance for [providing an in-box source generator has been documented](https://github.com/dotnet/designs/blob/main/accepted/2021/InboxSourceGenerators.md). The document should be considered a primary source for best-practices that will eventually be needed for productization. - -**Versioning/Shipping/Servicing** – Partially captured in the "In-box source generation" document, but stated item is being called out. - -**Merge in feature branch** – Integration work for updates to `NetCoreApp` have started in [`feature/use-dllimport-generator`](https://github.com/dotnet/runtime/tree/feature/use-dllimport-generator). - - Question on the impact of [source build](https://github.com/dotnet/source-build) for dotnet/runtime. - -## Productization - -The following items must be considered to make this prototype into a product. - -**Localization** – We must ensure user observed messages are properly localized and adhere to the Globalization/Localization tenets. - -**API Review** – [`GeneratedDllImportAttribute`](https://github.com/dotnet/runtime/issues/46822); Supporting [attributes](https://github.com/dotnet/runtime/issues/46838) and marshalling helper types. - -**Distribution** – The consumption of the source generator product is assumed to be in-box and/or as a standalone NuPkg. If not distributed as NuPkg there is no known additional work here. - -**Documentation/Sample** – Productization will require new documentation and at least one official example. From 45c1dc3a323512cc9b14882afa79064068ffefd9 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 11 Oct 2021 11:19:06 -0700 Subject: [PATCH 158/161] Re-enable running DllImportGenerator.Tests suite on Mono. (#60259) --- .../tests/DllImportGenerator.Tests/AssemblyInfo.cs | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs deleted file mode 100644 index f95036d8de482..0000000000000 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs +++ /dev/null @@ -1,10 +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 Xunit; - -// We build the libraries tests in CI once per target OS+Arch+Configuration, but we share it between runtime test runs. -// As a result, we need to exclude the Mono run here since we build the tests once for CoreCLR and Mono for desktop test runs. -// We should switch this to another mechanism in the future so we don't submit a work item of this assembly that skips every test -// for Mono-on-Desktop-Platforms test runs. -[assembly:ActiveIssue("https://github.com/dotnet/runtime/issues/59815", TestRuntimes.Mono)] From 8990b0acbdafb3924e3428f5a8b2bdc69f13db9d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 11 Oct 2021 15:32:31 -0700 Subject: [PATCH 159/161] Disable ClearPreviousError test on Mono (#60272) --- .../tests/DllImportGenerator.Tests/SetLastErrorTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs index f6ee7fff32a47..4f05e0e568e88 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -71,6 +71,7 @@ public void LastWin32Error_HasExpectedValue(int error) } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/60271", TestRuntimes.Mono)] public void ClearPreviousError() { int error = 100; From cfe257f79db0824fe976f589ea3c8cbb636a67de Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 13 Oct 2021 17:59:51 -0700 Subject: [PATCH 160/161] Add design details regarding dynamic buffers in struct marshalling (#60374) * Update StructMarshalling.md with details Co-authored-by: Elinor Fung Co-authored-by: Jeremy Koritzinsky --- .../DllImportGenerator/StructMarshalling.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/design/libraries/DllImportGenerator/StructMarshalling.md b/docs/design/libraries/DllImportGenerator/StructMarshalling.md index 3bc6033cec4cd..2852880103c6c 100644 --- a/docs/design/libraries/DllImportGenerator/StructMarshalling.md +++ b/docs/design/libraries/DllImportGenerator/StructMarshalling.md @@ -90,22 +90,24 @@ public struct TMarshaler Since C# 7.3 added a feature to enable custom pinning logic for user types, we should also add support for custom pinning logic. If the user provides a `GetPinnableReference` method that matches the requirements to be used in a `fixed` statement and the pointed-to type is blittable, then we will support using pinning to marshal the managed value when possible. The analyzer should issue a warning when the pointed-to type would not match the final native type, accounting for the `Value` property on the native type. Since `MarshalUsingAttribute` is applied at usage time instead of at type authoring time, we will not enable the pinning feature since the implementation of `GetPinnableReference` unless the pointed-to return type matches the native type. -#### Stackalloc +#### Caller-allocated memory -Custom marshalers of collection-like types or custom string encodings (such as UTF-32) may want to use stack space for extra storage for additional performance when possible. If the `TNative` type provides additional members with the following signatures, then it will opt in to using a stack-allocated buffer: +Custom marshalers of collection-like types or custom string encodings (such as UTF-32) may want to use stack space for extra storage for additional performance when possible. If the `TNative` type provides additional members with the following signatures, then it will opt in to using a caller-allocated buffer: ```csharp partial struct TNative { - public TNative(TManaged managed, Span stackSpace) {} + public TNative(TManaged managed, Span buffer) {} - public const int StackBufferSize = /* */; + public const int BufferSize = /* */; + + public const bool RequiresStackBuffer = /* */; } ``` -When these members are both present, the source generator will call the two-parameter constructor with a possibly stack-allocated buffer of `StackBufferSize` bytes when a stack-allocated buffer is usable. As a stack-allocated buffer is not usable in all scenarios, for example Reverse P/Invoke and struct marshalling, a one-parameter constructor must also be provided for usage in those scenarios. This may also be provided by providing a two-parameter constructor with a default value for the second parameter. +When these members are present, the source generator will call the two-parameter constructor with a possibly stack-allocated buffer of `BufferSize` bytes when a stack-allocated buffer is usable. If a stack-allocated buffer is a requirement, the `RequiresStackBuffer` field should be set to `true` and the `buffer` will be guaranteed to be allocated on the stack. Setting the `RequiresStackBuffer` field to `false` is the same as omitting the field definition. Since a dynamically allocated buffer is not usable in all scenarios, for example Reverse P/Invoke and struct marshalling, a one-parameter constructor must also be provided for usage in those scenarios. This may also be provided by providing a two-parameter constructor with a default value for the second parameter. -Type authors can pass down the `stackSpace` pointer to native code by defining a `GetPinnableReference` method on the native type that returns a reference to the first element of the span. +Type authors can pass down the `buffer` pointer to native code by defining a `GetPinnableReference()` method on the native type that returns a reference to the first element of the span. When the `RequiresStackBuffer` field is set to `true`, the type author is free to use APIs that would be dangerous in non-stack-allocated scenarios such as `MemoryMarshal.GetReference()` and `Unsafe.AsPointer()`. ### Usage From 39048dd5de272bf85650143d95168bf5470423b5 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 15 Oct 2021 11:06:12 -0700 Subject: [PATCH 161/161] Undo solution and config changes from DllImportGenerator (#60481) * Remove dotnet-experimental feed from NuGet.config * Revert changes to solution files and restore configs --- NuGet.config | 2 - src/libraries/Common/Common.Tests.sln | 14 ---- .../Microsoft.Extensions.Caching.Memory.sln | 14 ---- ...icrosoft.Extensions.Configuration.Json.sln | 14 ---- ...t.Extensions.Configuration.UserSecrets.sln | 14 ---- ...Microsoft.Extensions.Configuration.Xml.sln | 56 +++++++++++++++ .../Microsoft.Extensions.Configuration.sln | 70 +++++++++++++++---- .../Microsoft.Extensions.DependencyModel.sln | 14 ---- .../Microsoft.Extensions.Hosting.Systemd.sln | 28 -------- .../NuGet.config | 12 ++++ ...oft.Extensions.Hosting.WindowsServices.sln | 28 -------- .../Microsoft.Extensions.Hosting.sln | 28 -------- .../Microsoft.Extensions.Hosting/NuGet.config | 12 ++++ .../Microsoft.Extensions.Http.sln | 14 ---- ...rosoft.Extensions.Logging.Abstractions.sln | 48 ++++++------- ...osoft.Extensions.Logging.Configuration.sln | 14 ---- .../Microsoft.Extensions.Logging.Console.sln | 28 -------- .../Microsoft.Extensions.Logging.Debug.sln | 14 ---- .../Microsoft.Extensions.Logging.EventLog.sln | 14 ---- .../NuGet.config | 12 ++++ ...crosoft.Extensions.Logging.EventSource.sln | 28 -------- ...crosoft.Extensions.Logging.TraceSource.sln | 14 ---- .../Microsoft.Extensions.Logging.sln | 28 -------- .../Microsoft.Extensions.Logging/NuGet.config | 12 ++++ .../Microsoft.Extensions.Options.sln | 28 -------- .../Microsoft.Extensions.Options/NuGet.config | 12 ++++ .../Microsoft.VisualBasic.Core.sln | 7 ++ .../Microsoft.Win32.Primitives.sln | 42 ----------- ...Microsoft.Win32.Registry.AccessControl.sln | 7 ++ .../Microsoft.Win32.Registry.sln | 7 ++ .../Microsoft.Win32.SystemEvents/NuGet.config | 12 ++++ .../System.AppContext/System.AppContext.sln | 42 ----------- .../System.Buffers/System.Buffers.sln | 42 ----------- .../System.Collections.Concurrent.sln | 42 ----------- .../System.Collections/System.Collections.sln | 42 ----------- .../System.Console/System.Console.sln | 14 ---- .../System.Data.Common/System.Data.Common.sln | 42 ----------- .../System.Diagnostics.Contracts.sln | 42 ----------- .../System.Diagnostics.Debug.sln | 42 ----------- .../System.Diagnostics.EventLog/NuGet.config | 12 ++++ .../System.Diagnostics.FileVersionInfo.sln | 14 ---- .../System.Diagnostics.Process/NuGet.config | 12 ++++ .../System.Diagnostics.Process.sln | 21 ++---- .../System.Diagnostics.StackTrace.sln | 42 ----------- .../System.Diagnostics.Tools.sln | 42 ----------- .../System.Diagnostics.TraceSource.sln | 42 ----------- .../System.Diagnostics.Tracing.sln | 42 ----------- .../NuGet.config | 12 ++++ .../System.DirectoryServices/NuGet.config | 12 ++++ .../System.Drawing.Common/NuGet.config | 12 ++++ .../System.Drawing.Primitives/NuGet.config | 12 ++++ .../System.Globalization.Calendars.sln | 42 ----------- .../System.Globalization.sln | 42 ----------- .../System.IO.Compression.Brotli.sln | 14 ---- .../System.IO.Compression.ZipFile.sln | 14 ---- .../System.IO.Compression.sln | 14 ---- .../NuGet.config | 12 ++++ .../System.IO.FileSystem.DriveInfo.sln | 14 ---- .../System.IO.FileSystem.Watcher.sln | 14 ---- .../System.IO.FileSystem.sln | 14 ---- .../System.IO.IsolatedStorage/NuGet.config | 12 ++++ .../System.IO.MemoryMappedFiles.sln | 14 ---- .../System.IO.Pipes.AccessControl.sln | 21 ++---- .../System.IO.Pipes/System.IO.Pipes.sln | 14 ---- .../System.IO.UnmanagedMemoryStream.sln | 42 ----------- src/libraries/System.Management/NuGet.config | 12 ++++ .../System.Memory.Data/System.Memory.Data.sln | 14 ---- src/libraries/System.Memory/System.Memory.sln | 42 ----------- .../System.Net.Http.Json.sln | 14 ---- .../System.Net.Http.WinHttpHandler.sln | 14 ---- src/libraries/System.Net.Http/NuGet.config | 12 ++++ .../System.Net.Http/System.Net.Http.sln | 14 ---- .../System.Net.HttpListener.sln | 14 ---- .../System.Net.Mail/System.Net.Mail.sln | 14 ---- .../System.Net.NameResolution.sln | 14 ---- .../System.Net.NetworkInformation.sln | 14 ---- .../System.Net.Ping/System.Net.Ping.sln | 14 ---- .../System.Net.Primitives.sln | 14 ---- .../System.Net.Quic/System.Net.Quic.sln | 14 ---- .../System.Net.Security.sln | 14 ---- .../System.Net.Sockets/System.Net.Sockets.sln | 14 ---- .../System.Net.WebSockets.Client.sln | 14 ---- .../System.Numerics.Vectors.sln | 42 ----------- ...ate.Runtime.InteropServices.JavaScript.sln | 14 ---- .../System.Private.Uri/System.Private.Uri.sln | 42 ----------- .../System.Private.Xml.Linq.sln | 14 ---- .../System.Private.Xml/System.Private.Xml.sln | 14 ---- .../System.Reflection.Emit.ILGeneration.sln | 42 ----------- .../System.Reflection.Emit.Lightweight.sln | 42 ----------- .../System.Reflection.Emit.sln | 42 ----------- .../System.Reflection.Primitives.sln | 42 ----------- .../System.Reflection.TypeExtensions.sln | 42 ----------- .../System.Reflection/System.Reflection.sln | 42 ----------- .../System.Resources.Extensions/NuGet.config | 12 ++++ .../NuGet.config | 12 ++++ .../System.Resources.ResourceManager.sln | 42 ----------- .../System.Runtime.Extensions.sln | 42 ----------- ...ime.InteropServices.RuntimeInformation.sln | 14 ---- .../System.Runtime.Intrinsics.sln | 42 ----------- .../System.Runtime.Loader.sln | 42 ----------- ...ystem.Runtime.Serialization.Formatters.sln | 42 ----------- .../System.Runtime/System.Runtime.sln | 42 ----------- ...ystem.Security.Cryptography.Algorithms.sln | 14 ---- .../System.Security.Cryptography.Cng.sln | 14 ---- .../System.Security.Cryptography.Csp.sln | 14 ---- .../System.Security.Cryptography.Encoding.sln | 14 ---- .../System.Security.Cryptography.OpenSsl.sln | 14 ---- .../System.Security.Cryptography.Pkcs.sln | 14 ---- ...Security.Cryptography.X509Certificates.sln | 14 ---- .../System.Security.Cryptography.Xml.sln | 56 +++++++++++++++ .../System.Security.Permissions/NuGet.config | 12 ++++ .../System.Security.Principal.sln | 42 ----------- src/libraries/System.Speech/NuGet.config | 12 ++++ .../System.Text.Encoding.Extensions.sln | 42 ----------- .../System.Text.Encoding.sln | 42 ----------- .../System.Text.Json/System.Text.Json.sln | 62 ++++++++-------- .../System.Threading.Overlapped.sln | 42 ----------- .../System.Threading.Tasks.Extensions.sln | 42 ----------- .../System.Threading.Tasks.sln | 42 ----------- .../System.Threading.Thread.sln | 42 ----------- .../System.Threading.ThreadPool.sln | 42 ----------- .../System.Threading.Timer.sln | 42 ----------- .../System.Threading/System.Threading.sln | 42 ----------- .../System.Windows.Extensions/NuGet.config | 12 ++++ .../System.Xml.ReaderWriter.sln | 14 ---- .../System.Xml.XDocument.sln | 14 ---- .../System.Xml.XPath.XDocument.sln | 14 ---- .../System.Xml.XPath/System.Xml.XPath.sln | 14 ---- .../System.Xml.XmlDocument.sln | 14 ---- .../System.Xml.XmlSerializer.sln | 14 ---- 130 files changed, 510 insertions(+), 2689 deletions(-) create mode 100644 src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config create mode 100644 src/libraries/Microsoft.Extensions.Hosting/NuGet.config create mode 100644 src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config create mode 100644 src/libraries/Microsoft.Extensions.Logging/NuGet.config create mode 100644 src/libraries/Microsoft.Extensions.Options/NuGet.config create mode 100644 src/libraries/Microsoft.Win32.SystemEvents/NuGet.config create mode 100644 src/libraries/System.Diagnostics.EventLog/NuGet.config create mode 100644 src/libraries/System.Diagnostics.Process/NuGet.config create mode 100644 src/libraries/System.DirectoryServices.Protocols/NuGet.config create mode 100644 src/libraries/System.DirectoryServices/NuGet.config create mode 100644 src/libraries/System.Drawing.Common/NuGet.config create mode 100644 src/libraries/System.Drawing.Primitives/NuGet.config create mode 100644 src/libraries/System.IO.FileSystem.AccessControl/NuGet.config create mode 100644 src/libraries/System.IO.IsolatedStorage/NuGet.config create mode 100644 src/libraries/System.Management/NuGet.config create mode 100644 src/libraries/System.Net.Http/NuGet.config create mode 100644 src/libraries/System.Resources.Extensions/NuGet.config create mode 100644 src/libraries/System.Resources.ResourceManager/NuGet.config create mode 100644 src/libraries/System.Security.Permissions/NuGet.config create mode 100644 src/libraries/System.Speech/NuGet.config create mode 100644 src/libraries/System.Windows.Extensions/NuGet.config diff --git a/NuGet.config b/NuGet.config index c665193f05b83..f74e0c4a70248 100644 --- a/NuGet.config +++ b/NuGet.config @@ -22,8 +22,6 @@ - - diff --git a/src/libraries/Common/Common.Tests.sln b/src/libraries/Common/Common.Tests.sln index 0f7bc6f329113..23a9677e3b662 100644 --- a/src/libraries/Common/Common.Tests.sln +++ b/src/libraries/Common/Common.Tests.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2141FEEA-0422-4319-B88D-DA15CBD77599}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{0B795514-370A-4242-8810-DDD94E92877C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B0FE807A-573F-4DFB-94BE-AAB19AD31292}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F81003B8-54C4-42B1-AD93-255B62E9DC55}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A97E6A4A-8C69-4839-B3C5-3C7A716AC70A}" @@ -45,14 +41,6 @@ Global {2141FEEA-0422-4319-B88D-DA15CBD77599}.Debug|Any CPU.Build.0 = Debug|Any CPU {2141FEEA-0422-4319-B88D-DA15CBD77599}.Release|Any CPU.ActiveCfg = Release|Any CPU {2141FEEA-0422-4319-B88D-DA15CBD77599}.Release|Any CPU.Build.0 = Release|Any CPU - {0B795514-370A-4242-8810-DDD94E92877C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0B795514-370A-4242-8810-DDD94E92877C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0B795514-370A-4242-8810-DDD94E92877C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0B795514-370A-4242-8810-DDD94E92877C}.Release|Any CPU.Build.0 = Release|Any CPU - {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B0FE807A-573F-4DFB-94BE-AAB19AD31292}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -63,8 +51,6 @@ Global {10215DC2-1255-4B60-B0AC-D8B09BCEA179} = {F81003B8-54C4-42B1-AD93-255B62E9DC55} {A0A180C4-8292-45EE-A4B9-0A359BC9C2FC} = {A97E6A4A-8C69-4839-B3C5-3C7A716AC70A} {2141FEEA-0422-4319-B88D-DA15CBD77599} = {056FFC76-3DAC-4C6C-8E96-303B403EB50B} - {0B795514-370A-4242-8810-DDD94E92877C} = {056FFC76-3DAC-4C6C-8E96-303B403EB50B} - {B0FE807A-573F-4DFB-94BE-AAB19AD31292} = {056FFC76-3DAC-4C6C-8E96-303B403EB50B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4543E82B-8616-438A-B58B-EE47079D6956} diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln b/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln index 68cc71d9e374b..c16865355e47c 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/Microsoft.Extensions.Caching.Memory.sln @@ -23,10 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{78971B06-2519-45B7-B761-C8A30C168EBE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{3FCCE62E-3EE0-4629-B018-2B653DF43A62}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{C76753D0-F564-45E9-AA60-A846EFE0A414}" @@ -103,14 +99,6 @@ Global {78971B06-2519-45B7-B761-C8A30C168EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {78971B06-2519-45B7-B761-C8A30C168EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {78971B06-2519-45B7-B761-C8A30C168EBE}.Release|Any CPU.Build.0 = Release|Any CPU - {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636}.Release|Any CPU.Build.0 = Release|Any CPU - {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3FCCE62E-3EE0-4629-B018-2B653DF43A62}.Release|Any CPU.Build.0 = Release|Any CPU {BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}.Debug|Any CPU.Build.0 = Debug|Any CPU {BDC4E2D9-627A-4DE2-BF31-A95351C1CB7C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -164,8 +152,6 @@ Global {CD3D6F5B-0500-4035-A60A-592A2E231011} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {9A8C0B86-1CA3-4FFE-86FC-9EF0A733BEC0} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {78971B06-2519-45B7-B761-C8A30C168EBE} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} - {EC8B7B0A-992B-4F9B-8E40-9C4B80CD1636} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} - {3FCCE62E-3EE0-4629-B018-2B653DF43A62} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {C76753D0-F564-45E9-AA60-A846EFE0A414} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {5A9310B4-82AB-46F8-83C1-72D21A6A761F} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} {DA43AA92-35BA-4B84-BAA2-C3BB56C8BB3B} = {67719AA1-52DC-4E35-B6F7-2F53A50B913A} diff --git a/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln b/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln index d8cc52a78a485..adac4faa2384b 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln +++ b/src/libraries/Microsoft.Extensions.Configuration.Json/Microsoft.Extensions.Configuration.Json.sln @@ -51,10 +51,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{BD19B1E7-CAFF-4009-874A-760D5A466E28}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{6EB2865B-C9F6-4F9B-82DA-4C577587B577}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{A49023C8-173A-4B8F-84B3-2FF37FE8344A}" @@ -175,14 +171,6 @@ Global {BD19B1E7-CAFF-4009-874A-760D5A466E28}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD19B1E7-CAFF-4009-874A-760D5A466E28}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD19B1E7-CAFF-4009-874A-760D5A466E28}.Release|Any CPU.Build.0 = Release|Any CPU - {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B}.Release|Any CPU.Build.0 = Release|Any CPU - {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288}.Release|Any CPU.Build.0 = Release|Any CPU {6EB2865B-C9F6-4F9B-82DA-4C577587B577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EB2865B-C9F6-4F9B-82DA-4C577587B577}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EB2865B-C9F6-4F9B-82DA-4C577587B577}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -223,8 +211,6 @@ Global {B1723D4C-15E3-4A39-8976-C3E1740E5F00} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} {7517D0A0-5596-48B7-96EF-CB24DAD72675} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} {BD19B1E7-CAFF-4009-874A-760D5A466E28} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} - {AC48C19A-FCF1-4E4C-BBC1-8E499576D71B} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} - {B3C83FA0-5A0D-4BD4-A3C8-4340DEBAB288} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} {A49023C8-173A-4B8F-84B3-2FF37FE8344A} = {1789A282-9C08-40AB-9FD0-0FB1FAB99621} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln index e48a8b06647d9..829b1febeb55b 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Microsoft.Extensions.Configuration.UserSecrets.sln @@ -51,10 +51,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{1555B38A-E9CB-4734-AAB1-59CFB833A06D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{D541ED18-720A-47E8-82F8-7B994EB408A3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{705F880D-3E27-4ACA-87CC-808BB7DDA610}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{82700778-D9AD-4B9D-8A1C-CDC1A19E4D54}" @@ -175,14 +171,6 @@ Global {1555B38A-E9CB-4734-AAB1-59CFB833A06D}.Debug|Any CPU.Build.0 = Debug|Any CPU {1555B38A-E9CB-4734-AAB1-59CFB833A06D}.Release|Any CPU.ActiveCfg = Release|Any CPU {1555B38A-E9CB-4734-AAB1-59CFB833A06D}.Release|Any CPU.Build.0 = Release|Any CPU - {D541ED18-720A-47E8-82F8-7B994EB408A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D541ED18-720A-47E8-82F8-7B994EB408A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D541ED18-720A-47E8-82F8-7B994EB408A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D541ED18-720A-47E8-82F8-7B994EB408A3}.Release|Any CPU.Build.0 = Release|Any CPU - {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859}.Release|Any CPU.Build.0 = Release|Any CPU {705F880D-3E27-4ACA-87CC-808BB7DDA610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {705F880D-3E27-4ACA-87CC-808BB7DDA610}.Debug|Any CPU.Build.0 = Debug|Any CPU {705F880D-3E27-4ACA-87CC-808BB7DDA610}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -223,8 +211,6 @@ Global {BD85452C-1434-40FF-8A2C-36BF135A22FE} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} {1EF04395-4D84-43F1-BD99-7F6D6C3D70BB} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} {1555B38A-E9CB-4734-AAB1-59CFB833A06D} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} - {D541ED18-720A-47E8-82F8-7B994EB408A3} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} - {BC5FDB4B-C4B3-45F4-BAD0-43571AE96859} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} {82700778-D9AD-4B9D-8A1C-CDC1A19E4D54} = {B5EF5DDD-EB92-414C-B9D2-826BA6CECCBF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln b/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln index c395b07245135..16bd8851fe576 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/Microsoft.Extensions.Configuration.Xml.sln @@ -39,6 +39,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primit EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primitives", "..\Microsoft.Extensions.Primitives\src\Microsoft.Extensions.Primitives.csproj", "{26C61EB7-2798-4314-B750-8CD2837D4216}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{7A133F28-55F2-4143-8529-6DC7E994D852}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{1AE88632-F602-4B2F-A269-A7631A361FA7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{83270DD0-3E9F-460B-8EAA-4F33A6EB9025}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\ref\System.Formats.Asn1.csproj", "{F7D18116-335D-4CE6-980A-3330AAD05507}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\src\System.Formats.Asn1.csproj", "{84E43ED2-A2ED-49F9-B592-92270F0F2EC3}" @@ -55,6 +63,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptograph EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Xml", "..\System.Security.Cryptography.Xml\src\System.Security.Cryptography.Xml.csproj", "{8CBDDA63-8388-42AF-934E-7C60832A9B1C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{00C86D9C-1A45-49C7-91E6-24BBBF8950CB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{B25AD126-F78D-45CC-AD06-6F1E03D570DA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{00DA7CF9-86B4-4991-B760-CB3AAB31EED0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{C77305BE-823E-487F-825E-9C26E0674CC6}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AC596411-85F4-49FD-8A23-BE2983825CF1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{AB0BAC3A-1FE6-4649-83DF-DC165669C74F}" @@ -147,6 +163,22 @@ Global {26C61EB7-2798-4314-B750-8CD2837D4216}.Debug|Any CPU.Build.0 = Debug|Any CPU {26C61EB7-2798-4314-B750-8CD2837D4216}.Release|Any CPU.ActiveCfg = Release|Any CPU {26C61EB7-2798-4314-B750-8CD2837D4216}.Release|Any CPU.Build.0 = Release|Any CPU + {7A133F28-55F2-4143-8529-6DC7E994D852}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A133F28-55F2-4143-8529-6DC7E994D852}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A133F28-55F2-4143-8529-6DC7E994D852}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A133F28-55F2-4143-8529-6DC7E994D852}.Release|Any CPU.Build.0 = Release|Any CPU + {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF}.Release|Any CPU.Build.0 = Release|Any CPU + {1AE88632-F602-4B2F-A269-A7631A361FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1AE88632-F602-4B2F-A269-A7631A361FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1AE88632-F602-4B2F-A269-A7631A361FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1AE88632-F602-4B2F-A269-A7631A361FA7}.Release|Any CPU.Build.0 = Release|Any CPU + {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83270DD0-3E9F-460B-8EAA-4F33A6EB9025}.Release|Any CPU.Build.0 = Release|Any CPU {F7D18116-335D-4CE6-980A-3330AAD05507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F7D18116-335D-4CE6-980A-3330AAD05507}.Debug|Any CPU.Build.0 = Debug|Any CPU {F7D18116-335D-4CE6-980A-3330AAD05507}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -179,6 +211,22 @@ Global {8CBDDA63-8388-42AF-934E-7C60832A9B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CBDDA63-8388-42AF-934E-7C60832A9B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CBDDA63-8388-42AF-934E-7C60832A9B1C}.Release|Any CPU.Build.0 = Release|Any CPU + {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00C86D9C-1A45-49C7-91E6-24BBBF8950CB}.Release|Any CPU.Build.0 = Release|Any CPU + {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B25AD126-F78D-45CC-AD06-6F1E03D570DA}.Release|Any CPU.Build.0 = Release|Any CPU + {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00DA7CF9-86B4-4991-B760-CB3AAB31EED0}.Release|Any CPU.Build.0 = Release|Any CPU + {C77305BE-823E-487F-825E-9C26E0674CC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C77305BE-823E-487F-825E-9C26E0674CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C77305BE-823E-487F-825E-9C26E0674CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C77305BE-823E-487F-825E-9C26E0674CC6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -195,10 +243,14 @@ Global {600CBFCA-5F97-47EE-8AE9-B6262E1A764B} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {981358A2-F5ED-45CE-B037-446BB0F4E859} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {4039B868-612D-420F-BC25-481660475CA8} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} + {7A133F28-55F2-4143-8529-6DC7E994D852} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} + {1AE88632-F602-4B2F-A269-A7631A361FA7} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {F7D18116-335D-4CE6-980A-3330AAD05507} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {78F4F9EE-7E1D-41B5-B55A-850C1282EA99} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {91F63A74-902E-44DF-8A78-FD74D030E619} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {A3C9F01C-6D4D-413B-BADE-A8B9046F985F} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} + {00C86D9C-1A45-49C7-91E6-24BBBF8950CB} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} + {00DA7CF9-86B4-4991-B760-CB3AAB31EED0} = {AB0BAC3A-1FE6-4649-83DF-DC165669C74F} {9C73A2E3-B370-4B24-ACB0-0C3A9069250D} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {21E44CA2-5355-4092-9EF7-A94520EBDD40} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {EFC0C2A3-1F51-4299-BE43-78284F6AC670} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} @@ -208,10 +260,14 @@ Global {03A8EBF2-F912-480F-99E1-34A9A33DD525} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {6824AD93-4154-4710-A018-81DA1FA98C40} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {26C61EB7-2798-4314-B750-8CD2837D4216} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} + {2CD88C05-D0CB-49FE-B1D8-341BFDAE4BEF} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} + {83270DD0-3E9F-460B-8EAA-4F33A6EB9025} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {84E43ED2-A2ED-49F9-B592-92270F0F2EC3} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {5B866430-6F0B-49F1-8294-7B07F766797A} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {A00E22C3-A552-4F4C-AF2C-813B96A54582} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} {8CBDDA63-8388-42AF-934E-7C60832A9B1C} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} + {B25AD126-F78D-45CC-AD06-6F1E03D570DA} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} + {C77305BE-823E-487F-825E-9C26E0674CC6} = {373E0EA7-D9A1-4D7A-A300-9B2583AA09FD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {830494DE-07B3-4C63-9D74-4A123677D469} diff --git a/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln b/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln index ab806d3dffa45..e74c06668b9c6 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln +++ b/src/libraries/Microsoft.Extensions.Configuration/Microsoft.Extensions.Configuration.sln @@ -65,6 +65,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primit EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Primitives", "..\Microsoft.Extensions.Primitives\src\Microsoft.Extensions.Primitives.csproj", "{165EBE5E-E512-4E7E-8C2D-1F4297483D3E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{52B5874C-5860-473C-9A7D-8F70C01A0EBF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{9DC9CC89-E2F2-41F6-8684-81AA41B469FF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{38313D23-EB52-423C-9369-42995954CFCA}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\ref\System.Formats.Asn1.csproj", "{AA6BA95D-613F-4878-BF58-409A78FC3D1B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\src\System.Formats.Asn1.csproj", "{F50B881E-8A70-48C3-80B0-2094F6868974}" @@ -81,18 +89,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptograph EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Xml", "..\System.Security.Cryptography.Xml\src\System.Security.Cryptography.Xml.csproj", "{BAA953EF-6529-4F2C-8F89-C76A05258677}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\ref\System.Text.Encodings.Web.csproj", "{39AA6ECB-A46E-47B8-A90B-286C1C59D962}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{E2181F3B-BDC4-4373-9DA8-F3B50159C65E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{23F4102D-67BD-4865-BB19-195C47945733}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{6CCBE9AB-E620-4616-9B80-1F9D3E722B87}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{D8E6322D-6862-469C-9617-F3D423E4944B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\ref\System.Text.Encodings.Web.csproj", "{39AA6ECB-A46E-47B8-A90B-286C1C59D962}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{C4B32219-B834-46A9-9756-F624DDF4346D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{23F4102D-67BD-4865-BB19-195C47945733}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{41234DB5-1F3A-4E4A-8BD9-4A277C249666}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{6CDFD705-28EC-4D58-A2F9-715A3B06661B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CEC96DEF-9D43-4EFC-962B-B4F80EFA5C78}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{DC224BF8-12E5-4992-B750-B12011238C26}" @@ -237,6 +249,22 @@ Global {165EBE5E-E512-4E7E-8C2D-1F4297483D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU {165EBE5E-E512-4E7E-8C2D-1F4297483D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU {165EBE5E-E512-4E7E-8C2D-1F4297483D3E}.Release|Any CPU.Build.0 = Release|Any CPU + {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52B5874C-5860-473C-9A7D-8F70C01A0EBF}.Release|Any CPU.Build.0 = Release|Any CPU + {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DC9CC89-E2F2-41F6-8684-81AA41B469FF}.Release|Any CPU.Build.0 = Release|Any CPU + {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74}.Release|Any CPU.Build.0 = Release|Any CPU + {38313D23-EB52-423C-9369-42995954CFCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38313D23-EB52-423C-9369-42995954CFCA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38313D23-EB52-423C-9369-42995954CFCA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38313D23-EB52-423C-9369-42995954CFCA}.Release|Any CPU.Build.0 = Release|Any CPU {AA6BA95D-613F-4878-BF58-409A78FC3D1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA6BA95D-613F-4878-BF58-409A78FC3D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA6BA95D-613F-4878-BF58-409A78FC3D1B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -269,6 +297,14 @@ Global {BAA953EF-6529-4F2C-8F89-C76A05258677}.Debug|Any CPU.Build.0 = Debug|Any CPU {BAA953EF-6529-4F2C-8F89-C76A05258677}.Release|Any CPU.ActiveCfg = Release|Any CPU {BAA953EF-6529-4F2C-8F89-C76A05258677}.Release|Any CPU.Build.0 = Release|Any CPU + {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2181F3B-BDC4-4373-9DA8-F3B50159C65E}.Release|Any CPU.Build.0 = Release|Any CPU + {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CCBE9AB-E620-4616-9B80-1F9D3E722B87}.Release|Any CPU.Build.0 = Release|Any CPU {39AA6ECB-A46E-47B8-A90B-286C1C59D962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {39AA6ECB-A46E-47B8-A90B-286C1C59D962}.Debug|Any CPU.Build.0 = Debug|Any CPU {39AA6ECB-A46E-47B8-A90B-286C1C59D962}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -277,14 +313,6 @@ Global {23F4102D-67BD-4865-BB19-195C47945733}.Debug|Any CPU.Build.0 = Debug|Any CPU {23F4102D-67BD-4865-BB19-195C47945733}.Release|Any CPU.ActiveCfg = Release|Any CPU {23F4102D-67BD-4865-BB19-195C47945733}.Release|Any CPU.Build.0 = Release|Any CPU - {D8E6322D-6862-469C-9617-F3D423E4944B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D8E6322D-6862-469C-9617-F3D423E4944B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D8E6322D-6862-469C-9617-F3D423E4944B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D8E6322D-6862-469C-9617-F3D423E4944B}.Release|Any CPU.Build.0 = Release|Any CPU - {C4B32219-B834-46A9-9756-F624DDF4346D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C4B32219-B834-46A9-9756-F624DDF4346D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C4B32219-B834-46A9-9756-F624DDF4346D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C4B32219-B834-46A9-9756-F624DDF4346D}.Release|Any CPU.Build.0 = Release|Any CPU {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}.Debug|Any CPU.Build.0 = Debug|Any CPU {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -293,6 +321,14 @@ Global {41234DB5-1F3A-4E4A-8BD9-4A277C249666}.Debug|Any CPU.Build.0 = Debug|Any CPU {41234DB5-1F3A-4E4A-8BD9-4A277C249666}.Release|Any CPU.ActiveCfg = Release|Any CPU {41234DB5-1F3A-4E4A-8BD9-4A277C249666}.Release|Any CPU.Build.0 = Release|Any CPU + {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CDFD705-28EC-4D58-A2F9-715A3B06661B}.Release|Any CPU.Build.0 = Release|Any CPU + {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -316,12 +352,16 @@ Global {53E4909F-FC0B-4727-A73D-686C5115E8C9} = {DC224BF8-12E5-4992-B750-B12011238C26} {F4B7B95E-F732-474A-BED7-782AD2F4A1A4} = {DC224BF8-12E5-4992-B750-B12011238C26} {EC8DB110-890E-4388-97FC-0E25D98BC6F4} = {DC224BF8-12E5-4992-B750-B12011238C26} + {52B5874C-5860-473C-9A7D-8F70C01A0EBF} = {DC224BF8-12E5-4992-B750-B12011238C26} + {C53F8E4E-442C-48BF-9B6F-3E7381C0FD74} = {DC224BF8-12E5-4992-B750-B12011238C26} {AA6BA95D-613F-4878-BF58-409A78FC3D1B} = {DC224BF8-12E5-4992-B750-B12011238C26} {5D0D6749-312A-4400-89D8-A7252D9A879B} = {DC224BF8-12E5-4992-B750-B12011238C26} {8EA7F25A-0748-4EF4-ABE8-67688B646D47} = {DC224BF8-12E5-4992-B750-B12011238C26} {F74DB3B7-243F-447D-AE39-672348F661A1} = {DC224BF8-12E5-4992-B750-B12011238C26} + {E2181F3B-BDC4-4373-9DA8-F3B50159C65E} = {DC224BF8-12E5-4992-B750-B12011238C26} {39AA6ECB-A46E-47B8-A90B-286C1C59D962} = {DC224BF8-12E5-4992-B750-B12011238C26} {CFDBC0E2-792D-4F88-8AB5-978DF8E2167D} = {DC224BF8-12E5-4992-B750-B12011238C26} + {6CDFD705-28EC-4D58-A2F9-715A3B06661B} = {DC224BF8-12E5-4992-B750-B12011238C26} {CDC60461-56B7-4941-AD08-90228BD450CE} = {76107BEB-02C0-4A83-9631-B226340752A7} {9AF25AFA-6E25-4CA1-AD4F-FF77FD771714} = {76107BEB-02C0-4A83-9631-B226340752A7} {71F50A26-C4A8-4142-B0FD-E5D9EFEF34A1} = {76107BEB-02C0-4A83-9631-B226340752A7} @@ -337,14 +377,16 @@ Global {42C10152-F747-443F-9AC1-5738CB62EA6C} = {76107BEB-02C0-4A83-9631-B226340752A7} {8F65DFBB-9196-4E69-879A-C99C641B3E49} = {76107BEB-02C0-4A83-9631-B226340752A7} {165EBE5E-E512-4E7E-8C2D-1F4297483D3E} = {76107BEB-02C0-4A83-9631-B226340752A7} + {9DC9CC89-E2F2-41F6-8684-81AA41B469FF} = {76107BEB-02C0-4A83-9631-B226340752A7} + {38313D23-EB52-423C-9369-42995954CFCA} = {76107BEB-02C0-4A83-9631-B226340752A7} {F50B881E-8A70-48C3-80B0-2094F6868974} = {76107BEB-02C0-4A83-9631-B226340752A7} {75A03875-DC97-42AE-9EFE-78DC736B8BD6} = {76107BEB-02C0-4A83-9631-B226340752A7} {95FB3CCD-3174-4BAA-8BF6-67E0A16B8965} = {76107BEB-02C0-4A83-9631-B226340752A7} {BAA953EF-6529-4F2C-8F89-C76A05258677} = {76107BEB-02C0-4A83-9631-B226340752A7} + {6CCBE9AB-E620-4616-9B80-1F9D3E722B87} = {76107BEB-02C0-4A83-9631-B226340752A7} {23F4102D-67BD-4865-BB19-195C47945733} = {76107BEB-02C0-4A83-9631-B226340752A7} - {D8E6322D-6862-469C-9617-F3D423E4944B} = {76107BEB-02C0-4A83-9631-B226340752A7} - {C4B32219-B834-46A9-9756-F624DDF4346D} = {76107BEB-02C0-4A83-9631-B226340752A7} {41234DB5-1F3A-4E4A-8BD9-4A277C249666} = {76107BEB-02C0-4A83-9631-B226340752A7} + {7CFEB13D-63D5-42A7-868C-CE1D0049EAF0} = {76107BEB-02C0-4A83-9631-B226340752A7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {81EEF2A5-6387-4CC4-B7CD-908EEA4E5C79} diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln b/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln index 5752a958a3479..dd011a00b411a 100644 --- a/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln +++ b/src/libraries/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.sln @@ -21,10 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{7902A0CA-E94D-4C96-A112-455A1E5E2390}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{613D2C4B-4D2C-4036-A673-6B7FF25E4699}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{8F58A0B7-0F39-4E2B-A6E9-3030728E4426}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{8E212A9D-391B-4EFA-943D-7D104A9D3D7E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{FA7201FE-097D-4197-BDEC-329986814D8D}" @@ -85,14 +81,6 @@ Global {7902A0CA-E94D-4C96-A112-455A1E5E2390}.Debug|Any CPU.Build.0 = Debug|Any CPU {7902A0CA-E94D-4C96-A112-455A1E5E2390}.Release|Any CPU.ActiveCfg = Release|Any CPU {7902A0CA-E94D-4C96-A112-455A1E5E2390}.Release|Any CPU.Build.0 = Release|Any CPU - {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Debug|Any CPU.Build.0 = Debug|Any CPU - {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Release|Any CPU.ActiveCfg = Release|Any CPU - {613D2C4B-4D2C-4036-A673-6B7FF25E4699}.Release|Any CPU.Build.0 = Release|Any CPU - {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F58A0B7-0F39-4E2B-A6E9-3030728E4426}.Release|Any CPU.Build.0 = Release|Any CPU {8E212A9D-391B-4EFA-943D-7D104A9D3D7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E212A9D-391B-4EFA-943D-7D104A9D3D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E212A9D-391B-4EFA-943D-7D104A9D3D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -118,8 +106,6 @@ Global {5C580568-6072-4F27-B5C6-FA04556E3B98} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} {4A28B457-D950-486B-B59B-A4C977A733B1} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} {7902A0CA-E94D-4C96-A112-455A1E5E2390} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} - {613D2C4B-4D2C-4036-A673-6B7FF25E4699} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} - {8F58A0B7-0F39-4E2B-A6E9-3030728E4426} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} {FA7201FE-097D-4197-BDEC-329986814D8D} = {5725D7DF-DC33-47D2-90C9-D8736C579E77} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln index e1a1394f225f0..2c41ba20253e6 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Microsoft.Extensions.Hosting.Systemd.sln @@ -71,10 +71,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting", "..\Microsoft.Extensions.Hosting\src\Microsoft.Extensions.Hosting.csproj", "{AFC1BDAA-7E40-4118-BB80-F8057752A600}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{FAE962EE-A0E7-4411-8ECF-57669E39B07C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{860B845B-929F-4442-AED1-1F4186DBF497}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{A0AF82AE-ED18-4EEB-AD9A-B44017510F0C}" @@ -137,10 +133,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{E282BA2D-9D71-4DFB-B757-50731B8922D0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{7F1D776F-A653-4FE4-BBA4-ECE38192832A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{AA2CD494-414F-42BF-9C68-7822DEB09255}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{25474DE2-4D3D-4950-BDA7-CF6FE3CCD940}" @@ -303,14 +295,6 @@ Global {AFC1BDAA-7E40-4118-BB80-F8057752A600}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFC1BDAA-7E40-4118-BB80-F8057752A600}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFC1BDAA-7E40-4118-BB80-F8057752A600}.Release|Any CPU.Build.0 = Release|Any CPU - {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FAE962EE-A0E7-4411-8ECF-57669E39B07C}.Release|Any CPU.Build.0 = Release|Any CPU - {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F}.Release|Any CPU.Build.0 = Release|Any CPU {860B845B-929F-4442-AED1-1F4186DBF497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {860B845B-929F-4442-AED1-1F4186DBF497}.Debug|Any CPU.Build.0 = Debug|Any CPU {860B845B-929F-4442-AED1-1F4186DBF497}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -435,14 +419,6 @@ Global {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9}.Release|Any CPU.Build.0 = Release|Any CPU - {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E282BA2D-9D71-4DFB-B757-50731B8922D0}.Release|Any CPU.Build.0 = Release|Any CPU - {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F1D776F-A653-4FE4-BBA4-ECE38192832A}.Release|Any CPU.Build.0 = Release|Any CPU {AA2CD494-414F-42BF-9C68-7822DEB09255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA2CD494-414F-42BF-9C68-7822DEB09255}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA2CD494-414F-42BF-9C68-7822DEB09255}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -514,8 +490,6 @@ Global {4B72FC27-F786-44B4-88DF-996D478873B8} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {CFF29AA4-794A-416B-BF4C-FD2A442FB83F} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {AFC1BDAA-7E40-4118-BB80-F8057752A600} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} - {FAE962EE-A0E7-4411-8ECF-57669E39B07C} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} - {BBD8F514-389D-4A6C-BEEC-3E3D723E3D4F} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {A0AF82AE-ED18-4EEB-AD9A-B44017510F0C} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {D61B6530-0055-4DFE-85D1-58BEDFC7AA2F} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {509B5AB4-8F9F-4856-811F-7C8E727BF2E6} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} @@ -531,8 +505,6 @@ Global {578661A4-C136-4533-819E-AF3352F79953} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {E1053E73-AB5D-4593-8E00-7E048C314A28} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {47A3CDB0-8252-4536-B61F-C2E10F6EC2B9} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} - {E282BA2D-9D71-4DFB-B757-50731B8922D0} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} - {7F1D776F-A653-4FE4-BBA4-ECE38192832A} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} {25474DE2-4D3D-4950-BDA7-CF6FE3CCD940} = {192FD259-E55F-40C5-82EE-9E924EA6C3CB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config b/src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln index 374c947fb7877..08a2b2bb2e83a 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/Microsoft.Extensions.Hosting.WindowsServices.sln @@ -67,10 +67,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting", "..\Microsoft.Extensions.Hosting\src\Microsoft.Extensions.Hosting.csproj", "{36FAE390-EAAE-4193-98E7-34F10D3FA8E1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{498998A1-3AB9-4109-91A3-80917BF7107C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{B17D5318-2568-4898-8B86-27F63CEA025C}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{723957C4-C433-4B6D-BF0C-28AE36AEDDBD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{E5F61C36-FB9B-4DA7-96C0-056FBEADBB53}" @@ -137,10 +133,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{E45DC225-377C-4CDE-975D-15F9088562A3}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{C50BBD27-2445-4DF4-9A1D-C7919D016BBC}" @@ -293,14 +285,6 @@ Global {36FAE390-EAAE-4193-98E7-34F10D3FA8E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {36FAE390-EAAE-4193-98E7-34F10D3FA8E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {36FAE390-EAAE-4193-98E7-34F10D3FA8E1}.Release|Any CPU.Build.0 = Release|Any CPU - {498998A1-3AB9-4109-91A3-80917BF7107C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {498998A1-3AB9-4109-91A3-80917BF7107C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {498998A1-3AB9-4109-91A3-80917BF7107C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {498998A1-3AB9-4109-91A3-80917BF7107C}.Release|Any CPU.Build.0 = Release|Any CPU - {B17D5318-2568-4898-8B86-27F63CEA025C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B17D5318-2568-4898-8B86-27F63CEA025C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B17D5318-2568-4898-8B86-27F63CEA025C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B17D5318-2568-4898-8B86-27F63CEA025C}.Release|Any CPU.Build.0 = Release|Any CPU {723957C4-C433-4B6D-BF0C-28AE36AEDDBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {723957C4-C433-4B6D-BF0C-28AE36AEDDBD}.Debug|Any CPU.Build.0 = Debug|Any CPU {723957C4-C433-4B6D-BF0C-28AE36AEDDBD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -433,14 +417,6 @@ Global {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5}.Release|Any CPU.Build.0 = Release|Any CPU - {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385}.Release|Any CPU.Build.0 = Release|Any CPU - {E45DC225-377C-4CDE-975D-15F9088562A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E45DC225-377C-4CDE-975D-15F9088562A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E45DC225-377C-4CDE-975D-15F9088562A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E45DC225-377C-4CDE-975D-15F9088562A3}.Release|Any CPU.Build.0 = Release|Any CPU {35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {35F7F32D-B404-46B3-8FCE-CFEBEC7114C3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -511,8 +487,6 @@ Global {FB7C602E-3ED6-472A-85BD-420B61BA293D} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {89A6E38E-1118-4FC6-957D-17751DAD8EAF} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {36FAE390-EAAE-4193-98E7-34F10D3FA8E1} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} - {498998A1-3AB9-4109-91A3-80917BF7107C} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} - {B17D5318-2568-4898-8B86-27F63CEA025C} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {E5F61C36-FB9B-4DA7-96C0-056FBEADBB53} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {B0D60DB8-2A4A-4B8B-83DF-A1C66BDD0982} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {C573763D-C24C-4222-AAF0-66B0C2260EB4} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} @@ -529,8 +503,6 @@ Global {78706510-4F89-4896-8E29-723C8F4B90AF} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {3636C4FF-4BBD-4BB8-B60B-E62F2C429EA4} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {2D8B86CE-7A3A-45F0-9127-AE6CDCEC6EA5} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} - {DFCE4BC5-CEF3-476E-8FE5-BABA36BA9385} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} - {E45DC225-377C-4CDE-975D-15F9088562A3} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} {C50BBD27-2445-4DF4-9A1D-C7919D016BBC} = {76933DF1-12AA-4B5B-8863-EF38F10B1EC9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln b/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln index 27f58cab19403..9648a317d00cc 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln +++ b/src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln @@ -71,10 +71,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting.Unit.Tests", "tests\UnitTests\Microsoft.Extensions.Hosting.Unit.Tests.csproj", "{33C3D8F0-297F-4471-92B0-F4E8717F10E3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{185FEEC3-5178-4073-B014-F8EA85F464E1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{0B44803E-8F07-4174-9F78-630689EDE438}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{42E1BF94-6FE0-4017-9702-55913BD95EDE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{8845E6FF-94B2-4994-A8F4-DF30844A2168}" @@ -137,10 +133,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{B41AA17B-5129-41CC-8EA4-250B80BABF87}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{EFF1671F-7283-48A7-BF84-35359CE6079B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{562A8338-829C-46B8-9B72-75D44163DA36}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{0813853E-8C78-429A-B01A-3FB2EF1898F8}" @@ -303,14 +295,6 @@ Global {33C3D8F0-297F-4471-92B0-F4E8717F10E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {33C3D8F0-297F-4471-92B0-F4E8717F10E3}.Release|Any CPU.ActiveCfg = Release|Any CPU {33C3D8F0-297F-4471-92B0-F4E8717F10E3}.Release|Any CPU.Build.0 = Release|Any CPU - {185FEEC3-5178-4073-B014-F8EA85F464E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {185FEEC3-5178-4073-B014-F8EA85F464E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {185FEEC3-5178-4073-B014-F8EA85F464E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {185FEEC3-5178-4073-B014-F8EA85F464E1}.Release|Any CPU.Build.0 = Release|Any CPU - {0B44803E-8F07-4174-9F78-630689EDE438}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0B44803E-8F07-4174-9F78-630689EDE438}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0B44803E-8F07-4174-9F78-630689EDE438}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0B44803E-8F07-4174-9F78-630689EDE438}.Release|Any CPU.Build.0 = Release|Any CPU {42E1BF94-6FE0-4017-9702-55913BD95EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {42E1BF94-6FE0-4017-9702-55913BD95EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU {42E1BF94-6FE0-4017-9702-55913BD95EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -435,14 +419,6 @@ Global {B41AA17B-5129-41CC-8EA4-250B80BABF87}.Debug|Any CPU.Build.0 = Debug|Any CPU {B41AA17B-5129-41CC-8EA4-250B80BABF87}.Release|Any CPU.ActiveCfg = Release|Any CPU {B41AA17B-5129-41CC-8EA4-250B80BABF87}.Release|Any CPU.Build.0 = Release|Any CPU - {EFF1671F-7283-48A7-BF84-35359CE6079B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EFF1671F-7283-48A7-BF84-35359CE6079B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EFF1671F-7283-48A7-BF84-35359CE6079B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EFF1671F-7283-48A7-BF84-35359CE6079B}.Release|Any CPU.Build.0 = Release|Any CPU - {562A8338-829C-46B8-9B72-75D44163DA36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {562A8338-829C-46B8-9B72-75D44163DA36}.Debug|Any CPU.Build.0 = Debug|Any CPU - {562A8338-829C-46B8-9B72-75D44163DA36}.Release|Any CPU.ActiveCfg = Release|Any CPU - {562A8338-829C-46B8-9B72-75D44163DA36}.Release|Any CPU.Build.0 = Release|Any CPU {1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}.Debug|Any CPU.Build.0 = Debug|Any CPU {1E3D79D4-51D6-46C6-BF0F-DF51A47C5952}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -514,8 +490,6 @@ Global {9C06E60B-2D45-4284-B7C8-7AE6D8194CE0} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {973CE6DA-B55D-4E55-88D5-53BE69D44410} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {F5CF1FC4-8F56-49BD-BFC2-5AD42AE6302D} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} - {185FEEC3-5178-4073-B014-F8EA85F464E1} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} - {0B44803E-8F07-4174-9F78-630689EDE438} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {8845E6FF-94B2-4994-A8F4-DF30844A2168} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {99C8FB58-8718-4E76-AEFA-3C42F2F729B1} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {F3230087-28E2-4ADF-A7D1-D48C5D9CFFE9} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} @@ -531,8 +505,6 @@ Global {4ED9C0A9-C1EF-47ED-99F8-74B7411C971B} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {A9EFBE7D-6AE1-4F05-B9C5-2586835ADC4D} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {B41AA17B-5129-41CC-8EA4-250B80BABF87} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} - {EFF1671F-7283-48A7-BF84-35359CE6079B} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} - {562A8338-829C-46B8-9B72-75D44163DA36} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} {0813853E-8C78-429A-B01A-3FB2EF1898F8} = {59A29BF0-B76B-41F8-A733-E2A0847AB992} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Hosting/NuGet.config b/src/libraries/Microsoft.Extensions.Hosting/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Hosting/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln b/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln index ee68065148d01..19bcbc7a86705 100644 --- a/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln +++ b/src/libraries/Microsoft.Extensions.Http/Microsoft.Extensions.Http.sln @@ -19,10 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Http", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Http.Tests", "tests\Microsoft.Extensions.Http.Tests\Microsoft.Extensions.Http.Tests.csproj", "{58A1E42E-5DA1-452A-B39C-A1819171970A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{A455F39F-362E-4E90-ABF5-A32AA568FAEB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{53592813-75CD-46BF-8F7F-3DFD6240183E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{85615392-9242-4CAF-A0FE-A439FF615462}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{BAFF07C7-1F5F-4706-B7D7-9D5D309CBFE2}" @@ -99,14 +95,6 @@ Global {58A1E42E-5DA1-452A-B39C-A1819171970A}.Debug|Any CPU.Build.0 = Debug|Any CPU {58A1E42E-5DA1-452A-B39C-A1819171970A}.Release|Any CPU.ActiveCfg = Release|Any CPU {58A1E42E-5DA1-452A-B39C-A1819171970A}.Release|Any CPU.Build.0 = Release|Any CPU - {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A455F39F-362E-4E90-ABF5-A32AA568FAEB}.Release|Any CPU.Build.0 = Release|Any CPU - {53592813-75CD-46BF-8F7F-3DFD6240183E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {53592813-75CD-46BF-8F7F-3DFD6240183E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {53592813-75CD-46BF-8F7F-3DFD6240183E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {53592813-75CD-46BF-8F7F-3DFD6240183E}.Release|Any CPU.Build.0 = Release|Any CPU {85615392-9242-4CAF-A0FE-A439FF615462}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {85615392-9242-4CAF-A0FE-A439FF615462}.Debug|Any CPU.Build.0 = Debug|Any CPU {85615392-9242-4CAF-A0FE-A439FF615462}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -176,8 +164,6 @@ Global {A0EBE0C7-F63B-477C-BDE5-6B57AB9DB540} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {B792E72A-0513-4359-B754-D0372610DDCE} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {1236A517-6B61-4A62-9495-1C945EDA4D12} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} - {A455F39F-362E-4E90-ABF5-A32AA568FAEB} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} - {53592813-75CD-46BF-8F7F-3DFD6240183E} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {BAFF07C7-1F5F-4706-B7D7-9D5D309CBFE2} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {65079F8F-0653-4474-B105-551A9B6F102B} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} {A12B92C6-071A-4C61-8934-371DBB240873} = {96EA71C4-C73B-4C6C-AA06-05635B20A2DC} diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln b/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln index bf9829d652330..7946e4528c808 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.sln @@ -1,16 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{79CE8C7E-A4AF-413C-A54D-86F17073559C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{1491B9C9-955D-4DB0-B1D5-70137A78EAAE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{A5439E79-96D6-4F02-8DD0-23DFF979851D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{7F536552-0E2A-4642-B7CF-863727C2F9CD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "src\Microsoft.Extensions.Logging.Abstractions.csproj", "{75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests", "tests\Microsoft.Extensions.Logging.Generators.Tests\Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests.csproj", "{C333EC5A-F386-4A01-AE20-12D499551304}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn4.0.Tests", "tests\Microsoft.Extensions.Logging.Generators.Tests\Microsoft.Extensions.Logging.Generators.Roslyn4.0.Tests.csproj", "{1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{DAA1349E-960E-49EB-81F3-FF4F99D8A325}" @@ -23,6 +17,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{548DF5F7-790 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{7631380A-FB73-4241-9987-0891A21E9769}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn4.0", "gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{A5439E79-96D6-4F02-8DD0-23DFF979851D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn3.11", "gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{1491B9C9-955D-4DB0-B1D5-70137A78EAAE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests", "tests\Microsoft.Extensions.Logging.Generators.Tests\Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests.csproj", "{C333EC5A-F386-4A01-AE20-12D499551304}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,14 +33,6 @@ Global {79CE8C7E-A4AF-413C-A54D-86F17073559C}.Debug|Any CPU.Build.0 = Debug|Any CPU {79CE8C7E-A4AF-413C-A54D-86F17073559C}.Release|Any CPU.ActiveCfg = Release|Any CPU {79CE8C7E-A4AF-413C-A54D-86F17073559C}.Release|Any CPU.Build.0 = Release|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.Build.0 = Release|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.Build.0 = Release|Any CPU {7F536552-0E2A-4642-B7CF-863727C2F9CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7F536552-0E2A-4642-B7CF-863727C2F9CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F536552-0E2A-4642-B7CF-863727C2F9CD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -49,10 +41,6 @@ Global {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE}.Release|Any CPU.Build.0 = Release|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.Build.0 = Release|Any CPU {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}.Debug|Any CPU.Build.0 = Debug|Any CPU {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -65,20 +53,32 @@ Global {F8CF3192-B902-4631-972A-C405FDECC48D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8CF3192-B902-4631-972A-C405FDECC48D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8CF3192-B902-4631-972A-C405FDECC48D}.Release|Any CPU.Build.0 = Release|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5439E79-96D6-4F02-8DD0-23DFF979851D}.Release|Any CPU.Build.0 = Release|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE}.Release|Any CPU.Build.0 = Release|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C333EC5A-F386-4A01-AE20-12D499551304}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {79CE8C7E-A4AF-413C-A54D-86F17073559C} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} - {C333EC5A-F386-4A01-AE20-12D499551304} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} - {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} - {1491B9C9-955D-4DB0-B1D5-70137A78EAAE} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} - {A5439E79-96D6-4F02-8DD0-23DFF979851D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} - {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} - {F8CF3192-B902-4631-972A-C405FDECC48D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} {7F536552-0E2A-4642-B7CF-863727C2F9CD} = {7631380A-FB73-4241-9987-0891A21E9769} + {75C579F7-F20B-41F1-8CAF-641DE7ADA4EE} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {1CB869A7-2EEC-4A53-9C33-DF9E0C75825B} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} {DAA1349E-960E-49EB-81F3-FF4F99D8A325} = {7631380A-FB73-4241-9987-0891A21E9769} + {F8CF3192-B902-4631-972A-C405FDECC48D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {A5439E79-96D6-4F02-8DD0-23DFF979851D} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {1491B9C9-955D-4DB0-B1D5-70137A78EAAE} = {548DF5F7-790C-4A1C-89EB-BD904CA1BA86} + {C333EC5A-F386-4A01-AE20-12D499551304} = {4DE63935-DCA9-4D63-9C1F-AAE79C89CA8B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {450DA749-CBDC-4BDC-950F-8A491CF59D49} diff --git a/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln b/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln index 0d56345c8a8b7..84bddda3fbee1 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.sln @@ -23,10 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{788150B7-B822-4466-A1DC-C875449DE449}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{1EC5859E-7550-42FC-9414-7A95EB419E7A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{3E92E46A-871B-4433-86B8-5E58D21248D6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{E7035B72-0180-437E-A696-1F0CD8921279}" @@ -117,14 +113,6 @@ Global {788150B7-B822-4466-A1DC-C875449DE449}.Debug|Any CPU.Build.0 = Debug|Any CPU {788150B7-B822-4466-A1DC-C875449DE449}.Release|Any CPU.ActiveCfg = Release|Any CPU {788150B7-B822-4466-A1DC-C875449DE449}.Release|Any CPU.Build.0 = Release|Any CPU - {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1EC5859E-7550-42FC-9414-7A95EB419E7A}.Release|Any CPU.Build.0 = Release|Any CPU - {3E92E46A-871B-4433-86B8-5E58D21248D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E92E46A-871B-4433-86B8-5E58D21248D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E92E46A-871B-4433-86B8-5E58D21248D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E92E46A-871B-4433-86B8-5E58D21248D6}.Release|Any CPU.Build.0 = Release|Any CPU {C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4F75024-EA9D-46C5-B2D9-CAE8FC5EFF38}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -214,8 +202,6 @@ Global {71755B81-EF5C-4C36-A278-60D69ECCC158} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {36176FF1-8C33-494D-A496-1D7E0DCFCD86} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {788150B7-B822-4466-A1DC-C875449DE449} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} - {1EC5859E-7550-42FC-9414-7A95EB419E7A} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} - {3E92E46A-871B-4433-86B8-5E58D21248D6} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {E7035B72-0180-437E-A696-1F0CD8921279} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {B3829B05-AA4A-4A0D-B076-D0C3031C9D33} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} {BBCC241D-0980-4735-8187-229D37ADC0E5} = {ED0ADAC4-705C-421A-A8D2-69CFFFCF734B} diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln b/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln index 90fe55880518d..e254e84bd558d 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.sln @@ -25,10 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{C63090AA-A232-4638-99F8-3CCB2442BBAD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{AD2EADCD-BFF7-41D0-A119-E07618302A39}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{6A02D298-6899-4DD0-BFF4-40702BC30BCD}" @@ -71,10 +67,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{EA4F2339-D7E6-4B5C-9203-6920D623D8BC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{C9F3D8F9-8646-432E-82FC-2E4E8411CFFE}" @@ -143,14 +135,6 @@ Global {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8}.Release|Any CPU.Build.0 = Release|Any CPU - {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C63090AA-A232-4638-99F8-3CCB2442BBAD}.Release|Any CPU.Build.0 = Release|Any CPU - {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD2EADCD-BFF7-41D0-A119-E07618302A39}.Release|Any CPU.Build.0 = Release|Any CPU {9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}.Debug|Any CPU.Build.0 = Debug|Any CPU {9BCECFDA-BF6E-4BD8-BFE2-A25C61F57874}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -235,14 +219,6 @@ Global {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429}.Release|Any CPU.Build.0 = Release|Any CPU - {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EA4F2339-D7E6-4B5C-9203-6920D623D8BC}.Release|Any CPU.Build.0 = Release|Any CPU - {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75}.Release|Any CPU.Build.0 = Release|Any CPU {8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C8B3A3F-A9C1-4E72-BA3F-DE8A8FE5B040}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -281,8 +257,6 @@ Global {EF05AB17-527F-40BC-B4D1-AAE510267F4E} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {1F272F82-E9D1-454A-8E3C-6BEAF02219D4} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {2E4D0EB0-E34B-4D47-A7F1-E35C696066E8} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} - {C63090AA-A232-4638-99F8-3CCB2442BBAD} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} - {AD2EADCD-BFF7-41D0-A119-E07618302A39} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {6A02D298-6899-4DD0-BFF4-40702BC30BCD} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {E09FB553-28C4-4C1C-8E86-CFAB3374A656} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {974792E2-0311-446A-BABF-18B3A8DDDEC5} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} @@ -293,8 +267,6 @@ Global {5DCD1587-CC45-4105-8FFE-E4A43C60DA8D} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {EB05EC17-2C21-47EC-A39D-90ABBA053318} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {BF5E5B5A-AC50-4FF1-AADB-0DFC1AA8E429} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} - {EA4F2339-D7E6-4B5C-9203-6920D623D8BC} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} - {C0EF8157-1E2C-45E9-9AC4-2A23C92D5F75} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} {C9F3D8F9-8646-432E-82FC-2E4E8411CFFE} = {F3BAE0A3-1AF5-4F38-ADBE-6FEC99664322} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln b/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln index af8f2933ae731..cfece23e2113a 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln +++ b/src/libraries/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{850FBE78-DE29-480D-B4EE-6D260B0341B4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{FDEE14F9-39BF-4438-94E2-4F6233FB774B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{16E075F3-372C-4A98-BDAF-FF615B8A9855}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{3DDCFBB7-A438-46BB-9094-A1A39060DD2A}" @@ -77,14 +73,6 @@ Global {850FBE78-DE29-480D-B4EE-6D260B0341B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {850FBE78-DE29-480D-B4EE-6D260B0341B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {850FBE78-DE29-480D-B4EE-6D260B0341B4}.Release|Any CPU.Build.0 = Release|Any CPU - {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FDEE14F9-39BF-4438-94E2-4F6233FB774B}.Release|Any CPU.Build.0 = Release|Any CPU - {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25}.Release|Any CPU.Build.0 = Release|Any CPU {16E075F3-372C-4A98-BDAF-FF615B8A9855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {16E075F3-372C-4A98-BDAF-FF615B8A9855}.Debug|Any CPU.Build.0 = Debug|Any CPU {16E075F3-372C-4A98-BDAF-FF615B8A9855}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -159,8 +147,6 @@ Global {544BBE63-3650-42E0-AD83-B613907BE753} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {5B4734D0-7CF9-4F4B-B27A-FAED72A81C71} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {850FBE78-DE29-480D-B4EE-6D260B0341B4} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} - {FDEE14F9-39BF-4438-94E2-4F6233FB774B} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} - {5E3DB0B5-AD83-4AB1-B159-7B2E3ACA3D25} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {3DDCFBB7-A438-46BB-9094-A1A39060DD2A} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {81AB6F03-2FF8-4F0F-AB21-B80A6C345DC1} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} {7B89700F-897A-4CE8-B789-C9F915631845} = {FC2F4F53-DFE7-4A0B-A85C-D266FDD51526} diff --git a/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln b/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln index 0070fa99dccee..7299154a81820 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln +++ b/src/libraries/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{62D0B220-DABD-4C56-A0E2-640D74465328}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{E93CA456-7B60-4250-8CEA-51D478E1A9B7}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{B1BE2665-7E3F-46FB-BCE1-774D5984F76C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{6C2850C7-56F0-4DCF-BFBF-4365DE2FC439}" @@ -89,14 +85,6 @@ Global {62D0B220-DABD-4C56-A0E2-640D74465328}.Debug|Any CPU.Build.0 = Debug|Any CPU {62D0B220-DABD-4C56-A0E2-640D74465328}.Release|Any CPU.ActiveCfg = Release|Any CPU {62D0B220-DABD-4C56-A0E2-640D74465328}.Release|Any CPU.Build.0 = Release|Any CPU - {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77}.Release|Any CPU.Build.0 = Release|Any CPU - {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E93CA456-7B60-4250-8CEA-51D478E1A9B7}.Release|Any CPU.Build.0 = Release|Any CPU {B1BE2665-7E3F-46FB-BCE1-774D5984F76C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B1BE2665-7E3F-46FB-BCE1-774D5984F76C}.Debug|Any CPU.Build.0 = Debug|Any CPU {B1BE2665-7E3F-46FB-BCE1-774D5984F76C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -199,8 +187,6 @@ Global {B67E21A5-9B87-46DB-99A1-F04074CBE466} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {A21DEE4B-F49B-4A19-95AC-7589757B8962} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {62D0B220-DABD-4C56-A0E2-640D74465328} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} - {CDAB26EF-FB5B-4399-B2AC-6EBA1B32BF77} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} - {E93CA456-7B60-4250-8CEA-51D478E1A9B7} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {6C2850C7-56F0-4DCF-BFBF-4365DE2FC439} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {5EA9057E-5887-4BDB-8785-A752D96D89F9} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} {515F097D-9FFB-4728-8B9E-18CFA6916AD3} = {FD104C22-7ECA-47DD-8877-26AC1E0E5ECC} diff --git a/src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config b/src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Logging.EventLog/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln b/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln index aacc6f46afd22..90beb958088b7 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{AE3375E0-30D5-4C99-9A0F-C515B822D8AD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{13D1623E-1506-4CD0-8501-41D14711AD18}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{F5B4A3CF-03B5-40A2-BE78-DA6230270113}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{F4A703F8-3D69-4113-A86F-9AD908086092}" @@ -51,10 +47,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{9735A60C-FCAA-423D-85FF-D0C6545693F5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{3E80E645-8642-4944-9B45-0F317A8D2E58}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{5A956452-F322-4C4F-8689-D2B425764293}" @@ -99,14 +91,6 @@ Global {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}.Debug|Any CPU.Build.0 = Debug|Any CPU {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}.Release|Any CPU.ActiveCfg = Release|Any CPU {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84}.Release|Any CPU.Build.0 = Release|Any CPU - {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE3375E0-30D5-4C99-9A0F-C515B822D8AD}.Release|Any CPU.Build.0 = Release|Any CPU - {13D1623E-1506-4CD0-8501-41D14711AD18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {13D1623E-1506-4CD0-8501-41D14711AD18}.Debug|Any CPU.Build.0 = Debug|Any CPU - {13D1623E-1506-4CD0-8501-41D14711AD18}.Release|Any CPU.ActiveCfg = Release|Any CPU - {13D1623E-1506-4CD0-8501-41D14711AD18}.Release|Any CPU.Build.0 = Release|Any CPU {F5B4A3CF-03B5-40A2-BE78-DA6230270113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F5B4A3CF-03B5-40A2-BE78-DA6230270113}.Debug|Any CPU.Build.0 = Debug|Any CPU {F5B4A3CF-03B5-40A2-BE78-DA6230270113}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -175,14 +159,6 @@ Global {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}.Debug|Any CPU.Build.0 = Debug|Any CPU {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}.Release|Any CPU.ActiveCfg = Release|Any CPU {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86}.Release|Any CPU.Build.0 = Release|Any CPU - {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9735A60C-FCAA-423D-85FF-D0C6545693F5}.Release|Any CPU.Build.0 = Release|Any CPU - {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D}.Release|Any CPU.Build.0 = Release|Any CPU {3E80E645-8642-4944-9B45-0F317A8D2E58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3E80E645-8642-4944-9B45-0F317A8D2E58}.Debug|Any CPU.Build.0 = Debug|Any CPU {3E80E645-8642-4944-9B45-0F317A8D2E58}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -213,8 +189,6 @@ Global {9B5DD499-7FE6-4E35-8084-EAF9D0E4CFDE} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {AD133460-B832-44BE-BF0A-A699A77FA718} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {7834A5FC-A39B-4435-9D8C-2EEABFFA7A84} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} - {AE3375E0-30D5-4C99-9A0F-C515B822D8AD} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} - {13D1623E-1506-4CD0-8501-41D14711AD18} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {F4A703F8-3D69-4113-A86F-9AD908086092} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {85D5D364-5D5F-4D9F-A6DA-1EF4C9E5503F} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {4B621745-2446-4A51-96C1-E1F9D4FCE1E3} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} @@ -223,8 +197,6 @@ Global {23F45D4C-4E33-4334-A5BF-D34E24165E0B} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {9A16DEC0-1F88-4335-95B3-D7923FEB5283} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {50CC33E5-CB2C-4CFB-9CDE-BBD41B30FB86} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} - {9735A60C-FCAA-423D-85FF-D0C6545693F5} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} - {7A0ACB15-0D41-4578-AE57-4D1669FBAE8D} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} {5A956452-F322-4C4F-8689-D2B425764293} = {887BF6A4-CB22-4DF4-8E24-A1B267161ECB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln b/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln index 0908e70b541b0..0cd8e629878e2 100644 --- a/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln +++ b/src/libraries/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Depend EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.DependencyInjection", "..\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj", "{A64CC82B-B781-4469-B009-49A43A0A2A96}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{8293FA5A-58DE-4238-8E3E-E153AA92766F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{367922CE-A24E-4977-89BE-D1F2F678F8B2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{F63AB9DB-6E62-4FEC-BA06-E146615C08AC}" @@ -77,14 +73,6 @@ Global {A64CC82B-B781-4469-B009-49A43A0A2A96}.Debug|Any CPU.Build.0 = Debug|Any CPU {A64CC82B-B781-4469-B009-49A43A0A2A96}.Release|Any CPU.ActiveCfg = Release|Any CPU {A64CC82B-B781-4469-B009-49A43A0A2A96}.Release|Any CPU.Build.0 = Release|Any CPU - {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1}.Release|Any CPU.Build.0 = Release|Any CPU - {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8293FA5A-58DE-4238-8E3E-E153AA92766F}.Release|Any CPU.Build.0 = Release|Any CPU {367922CE-A24E-4977-89BE-D1F2F678F8B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {367922CE-A24E-4977-89BE-D1F2F678F8B2}.Debug|Any CPU.Build.0 = Debug|Any CPU {367922CE-A24E-4977-89BE-D1F2F678F8B2}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -159,8 +147,6 @@ Global {1B7B708C-F860-478E-B3D4-1CB70E71A440} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {A9250A96-9B27-46C5-A043-11F67D63B128} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {A64CC82B-B781-4469-B009-49A43A0A2A96} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} - {154E1251-C5D5-4AFF-B4F7-80701F9C5EC1} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} - {8293FA5A-58DE-4238-8E3E-E153AA92766F} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {F63AB9DB-6E62-4FEC-BA06-E146615C08AC} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {BC92BF65-8FA0-49C0-911F-426F21090774} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} {C0A5172A-162E-4CD8-B4E4-C8AE137EBC64} = {DFF3B3E7-DC70-46BC-8EDC-DC73CD69F7FC} diff --git a/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln b/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln index 0c7f5d1f1ad65..6070ed9135aad 100644 --- a/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln +++ b/src/libraries/Microsoft.Extensions.Logging/Microsoft.Extensions.Logging.sln @@ -45,10 +45,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.FileSy EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.FileSystemGlobbing", "..\Microsoft.Extensions.FileSystemGlobbing\src\Microsoft.Extensions.FileSystemGlobbing.csproj", "{7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{B9E9944F-0170-478C-9BEF-136168FDBE2B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{5CC86773-7762-4FB7-9B6E-F4002F286AD4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{4BEF5648-8DBF-4E16-B6E6-6F80694E140D}" @@ -115,10 +111,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{B5B30447-25D0-42C0-920A-092247C95664}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{C00A8442-D7CE-464F-92A1-207427755FF6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{BB1EF0C4-822E-4476-8872-8620EA665C35}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{34C22E86-B0A3-457D-B8D9-7CF47AAF2570}" @@ -229,14 +221,6 @@ Global {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A}.Release|Any CPU.Build.0 = Release|Any CPU - {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822}.Release|Any CPU.Build.0 = Release|Any CPU - {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9E9944F-0170-478C-9BEF-136168FDBE2B}.Release|Any CPU.Build.0 = Release|Any CPU {5CC86773-7762-4FB7-9B6E-F4002F286AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5CC86773-7762-4FB7-9B6E-F4002F286AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU {5CC86773-7762-4FB7-9B6E-F4002F286AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -369,14 +353,6 @@ Global {B5B30447-25D0-42C0-920A-092247C95664}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5B30447-25D0-42C0-920A-092247C95664}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5B30447-25D0-42C0-920A-092247C95664}.Release|Any CPU.Build.0 = Release|Any CPU - {C00A8442-D7CE-464F-92A1-207427755FF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C00A8442-D7CE-464F-92A1-207427755FF6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C00A8442-D7CE-464F-92A1-207427755FF6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C00A8442-D7CE-464F-92A1-207427755FF6}.Release|Any CPU.Build.0 = Release|Any CPU - {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C}.Release|Any CPU.Build.0 = Release|Any CPU {BB1EF0C4-822E-4476-8872-8620EA665C35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BB1EF0C4-822E-4476-8872-8620EA665C35}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB1EF0C4-822E-4476-8872-8620EA665C35}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -437,8 +413,6 @@ Global {31E317F8-F766-4EC3-8101-2D92CDB407CD} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {5F0CF40F-D54D-4101-94EA-8FE7F9C843CB} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {7C562B37-19E5-44BE-85D5-15FFA9FAEF5A} = {D8928AB2-2939-4421-90C5-56B789BF93E5} - {E4343B13-DF3F-4B44-8E0E-DDC42B4C3822} = {D8928AB2-2939-4421-90C5-56B789BF93E5} - {B9E9944F-0170-478C-9BEF-136168FDBE2B} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {4BEF5648-8DBF-4E16-B6E6-6F80694E140D} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {9D96B3BD-B371-4E44-A43F-50B8EEBEC889} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {F700E4AF-073D-4C1D-A8C2-84E744EBC374} = {D8928AB2-2939-4421-90C5-56B789BF93E5} @@ -454,8 +428,6 @@ Global {425C299F-7D53-49EC-92D0-22B77BEA12D2} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {04BA3E3C-6979-4792-B19E-C797AD607F42} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {B5B30447-25D0-42C0-920A-092247C95664} = {D8928AB2-2939-4421-90C5-56B789BF93E5} - {C00A8442-D7CE-464F-92A1-207427755FF6} = {D8928AB2-2939-4421-90C5-56B789BF93E5} - {ECE0A1B2-A068-4A99-90D9-D3858FD35F5C} = {D8928AB2-2939-4421-90C5-56B789BF93E5} {34C22E86-B0A3-457D-B8D9-7CF47AAF2570} = {D8928AB2-2939-4421-90C5-56B789BF93E5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Logging/NuGet.config b/src/libraries/Microsoft.Extensions.Logging/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Logging/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln b/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln index 5703183eec058..0fe5055533f24 100644 --- a/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln +++ b/src/libraries/Microsoft.Extensions.Options/Microsoft.Extensions.Options.sln @@ -65,10 +65,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hosting", "..\Microsoft.Extensions.Hosting\src\Microsoft.Extensions.Hosting.csproj", "{6AD51705-102E-4E9D-B62E-6BF19025F3A7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn3.11.csproj", "{E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Generators", "..\Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj", "{EBEF8790-8095-4FD9-8436-1354B30E1529}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj", "{EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "..\Microsoft.Extensions.Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj", "{56D37CB2-68A3-42D3-AA0E-416813ABAD8B}" @@ -137,10 +133,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{59D31D62-3BF9-4F4A-9FF7-3A61F297F714}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{7B06FF78-A95C-4703-AB80-E7509D6CB3D7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{F249D915-DA90-4C96-B26B-147574801988}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{6E2398EA-A64A-4493-A79B-63D2F072A690}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{D7CEC738-5D2D-4FCB-9268-9650EB01BF31}" @@ -291,14 +283,6 @@ Global {6AD51705-102E-4E9D-B62E-6BF19025F3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU {6AD51705-102E-4E9D-B62E-6BF19025F3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU {6AD51705-102E-4E9D-B62E-6BF19025F3A7}.Release|Any CPU.Build.0 = Release|Any CPU - {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D}.Release|Any CPU.Build.0 = Release|Any CPU - {EBEF8790-8095-4FD9-8436-1354B30E1529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EBEF8790-8095-4FD9-8436-1354B30E1529}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EBEF8790-8095-4FD9-8436-1354B30E1529}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EBEF8790-8095-4FD9-8436-1354B30E1529}.Release|Any CPU.Build.0 = Release|Any CPU {EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}.Debug|Any CPU.Build.0 = Debug|Any CPU {EFFB59C1-CAF4-4347-B996-4C773E1AFAA8}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -435,14 +419,6 @@ Global {59D31D62-3BF9-4F4A-9FF7-3A61F297F714}.Debug|Any CPU.Build.0 = Debug|Any CPU {59D31D62-3BF9-4F4A-9FF7-3A61F297F714}.Release|Any CPU.ActiveCfg = Release|Any CPU {59D31D62-3BF9-4F4A-9FF7-3A61F297F714}.Release|Any CPU.Build.0 = Release|Any CPU - {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7B06FF78-A95C-4703-AB80-E7509D6CB3D7}.Release|Any CPU.Build.0 = Release|Any CPU - {F249D915-DA90-4C96-B26B-147574801988}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F249D915-DA90-4C96-B26B-147574801988}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F249D915-DA90-4C96-B26B-147574801988}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F249D915-DA90-4C96-B26B-147574801988}.Release|Any CPU.Build.0 = Release|Any CPU {6E2398EA-A64A-4493-A79B-63D2F072A690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6E2398EA-A64A-4493-A79B-63D2F072A690}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E2398EA-A64A-4493-A79B-63D2F072A690}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -513,8 +489,6 @@ Global {36D778AF-5EC3-433F-B03D-EB244DB3C227} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {D0932BA0-70BF-4A98-9A30-ED563AB2BFB9} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {6AD51705-102E-4E9D-B62E-6BF19025F3A7} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} - {E00A72D2-A6C2-4334-92AC-7CF7ECC87F4D} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} - {EBEF8790-8095-4FD9-8436-1354B30E1529} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {56D37CB2-68A3-42D3-AA0E-416813ABAD8B} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {9EBA168F-239A-46C4-8614-E1D3DB25DD0E} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {47B5D904-4787-49E3-9894-31F8B7BE6755} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} @@ -531,8 +505,6 @@ Global {9175023F-6982-45CD-B360-C4FC1E145B25} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {8E7256F3-ACCF-4576-B091-CC8ADC60C33E} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {59D31D62-3BF9-4F4A-9FF7-3A61F297F714} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} - {7B06FF78-A95C-4703-AB80-E7509D6CB3D7} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} - {F249D915-DA90-4C96-B26B-147574801988} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} {D7CEC738-5D2D-4FCB-9268-9650EB01BF31} = {7028EE0A-D314-4F48-91CA-51A1633BC3F4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/Microsoft.Extensions.Options/NuGet.config b/src/libraries/Microsoft.Extensions.Options/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Options/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln b/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln index f463dfd2be002..fe2625c0a4dda 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln +++ b/src/libraries/Microsoft.VisualBasic.Core/Microsoft.VisualBasic.Core.sln @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualBasic.Core. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry", "..\Microsoft.Win32.Registry\src\Microsoft.Win32.Registry.csproj", "{1970A570-2766-49C2-83A4-9898E295D6AF}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{3B27E66C-3E44-4DC7-9434-9B66475B80E5}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{40E6CFD8-4203-49CA-A3D7-A93A2344F876}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{EE74172D-1E18-4130-B71E-C9FDF04DA0F6}" @@ -53,6 +55,10 @@ Global {1970A570-2766-49C2-83A4-9898E295D6AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {1970A570-2766-49C2-83A4-9898E295D6AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {1970A570-2766-49C2-83A4-9898E295D6AF}.Release|Any CPU.Build.0 = Release|Any CPU + {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B27E66C-3E44-4DC7-9434-9B66475B80E5}.Release|Any CPU.Build.0 = Release|Any CPU {40E6CFD8-4203-49CA-A3D7-A93A2344F876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {40E6CFD8-4203-49CA-A3D7-A93A2344F876}.Debug|Any CPU.Build.0 = Debug|Any CPU {40E6CFD8-4203-49CA-A3D7-A93A2344F876}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -85,6 +91,7 @@ Global {009D39C7-821B-44E4-ABB9-8ED94464A5CB} = {3FD0B41F-6CEA-4AE2-832F-60C8686858C4} {476C0AEB-48CB-4978-9D35-06AA49F800B9} = {3FD0B41F-6CEA-4AE2-832F-60C8686858C4} {EA1B5DA0-F263-4298-A8FC-564E9DF00771} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} + {3B27E66C-3E44-4DC7-9434-9B66475B80E5} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} {40E6CFD8-4203-49CA-A3D7-A93A2344F876} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} {744F821F-99E9-4FF5-A84A-85432CC77548} = {3BC7B60B-4BE3-4D6F-8C03-8D6BDACC845E} {E741B977-6B3F-4DA7-A22B-251A1B3E42F7} = {2FC8E7CF-2E28-42BB-BCC0-DD0EDF96A483} diff --git a/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln b/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln index 453f96fba333f..dd8549340ff50 100644 --- a/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln +++ b/src/libraries/Microsoft.Win32.Primitives/Microsoft.Win32.Primitives.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{75E8E37F-C551-47B1-A62B-EE78C96BBDF0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{39EC49B3-3F54-4302-AA73-2C6CB63C054B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{71A636C5-93CD-41C5-8177-345127143843}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{44B79C97-BA70-4955-8478-87D5CB5CD3B5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CEC48784-C8F0-46DF-AA1E-07850E754180}" @@ -162,42 +158,6 @@ Global {75E8E37F-C551-47B1-A62B-EE78C96BBDF0}.Checked|x64.Build.0 = Debug|Any CPU {75E8E37F-C551-47B1-A62B-EE78C96BBDF0}.Checked|x86.ActiveCfg = Debug|Any CPU {75E8E37F-C551-47B1-A62B-EE78C96BBDF0}.Checked|x86.Build.0 = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x64.ActiveCfg = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x64.Build.0 = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x86.ActiveCfg = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Debug|x86.Build.0 = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|Any CPU.Build.0 = Release|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x64.ActiveCfg = Release|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x64.Build.0 = Release|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x86.ActiveCfg = Release|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Release|x86.Build.0 = Release|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|Any CPU.Build.0 = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x64.ActiveCfg = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x64.Build.0 = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x86.ActiveCfg = Debug|Any CPU - {39EC49B3-3F54-4302-AA73-2C6CB63C054B}.Checked|x86.Build.0 = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Debug|Any CPU.Build.0 = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Debug|x64.ActiveCfg = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Debug|x64.Build.0 = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Debug|x86.ActiveCfg = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Debug|x86.Build.0 = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Release|Any CPU.ActiveCfg = Release|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Release|Any CPU.Build.0 = Release|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Release|x64.ActiveCfg = Release|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Release|x64.Build.0 = Release|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Release|x86.ActiveCfg = Release|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Release|x86.Build.0 = Release|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Checked|Any CPU.Build.0 = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Checked|x64.ActiveCfg = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Checked|x64.Build.0 = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Checked|x86.ActiveCfg = Debug|Any CPU - {71A636C5-93CD-41C5-8177-345127143843}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {7D1AFE3C-882D-4D27-A915-B87A1BC82D2D} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} {B3BBD7D9-30F3-43D3-9D6A-C9BD5E19D32E} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} {75E8E37F-C551-47B1-A62B-EE78C96BBDF0} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} - {39EC49B3-3F54-4302-AA73-2C6CB63C054B} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} - {71A636C5-93CD-41C5-8177-345127143843} = {44B79C97-BA70-4955-8478-87D5CB5CD3B5} {069C76AC-B41A-4E17-A066-12233592145D} = {CEC48784-C8F0-46DF-AA1E-07850E754180} {B43D6BB6-1760-4DB9-87CB-792D42846C62} = {CEC48784-C8F0-46DF-AA1E-07850E754180} {EA142E29-EE37-4751-868B-27516AE0A209} = {08BAF9E0-068B-4201-91E6-91B725ABE3D2} diff --git a/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln b/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln index 427a3cc8ee23b..7e971e101f740 100644 --- a/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln +++ b/src/libraries/Microsoft.Win32.Registry.AccessControl/Microsoft.Win32.Registry.AccessControl.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry.Ac EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry.AccessControl.Tests", "tests\Microsoft.Win32.Registry.AccessControl.Tests.csproj", "{BC8FAA75-A595-475E-B947-FA2D1E225B48}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{CF3D0A58-974A-484E-A897-634C5FF78DFB}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{9341070F-8A24-45FD-96FF-DC936EC9FE4C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DD5B2888-463A-4AB6-911F-EB0BEA47951A}" @@ -39,6 +41,10 @@ Global {BC8FAA75-A595-475E-B947-FA2D1E225B48}.Debug|Any CPU.Build.0 = Debug|Any CPU {BC8FAA75-A595-475E-B947-FA2D1E225B48}.Release|Any CPU.ActiveCfg = Release|Any CPU {BC8FAA75-A595-475E-B947-FA2D1E225B48}.Release|Any CPU.Build.0 = Release|Any CPU + {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF3D0A58-974A-484E-A897-634C5FF78DFB}.Release|Any CPU.Build.0 = Release|Any CPU {9341070F-8A24-45FD-96FF-DC936EC9FE4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9341070F-8A24-45FD-96FF-DC936EC9FE4C}.Debug|Any CPU.Build.0 = Debug|Any CPU {9341070F-8A24-45FD-96FF-DC936EC9FE4C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -55,6 +61,7 @@ Global {F9B18052-9FB9-474A-9A6A-F322DED4F7CD} = {BF17487D-E9E3-4054-85A7-E64243B91780} {BC8FAA75-A595-475E-B947-FA2D1E225B48} = {BF17487D-E9E3-4054-85A7-E64243B91780} {97F37414-7633-4B76-AFA4-284E26894FB4} = {84D58703-7569-445A-89B8-14D024FB6091} + {CF3D0A58-974A-484E-A897-634C5FF78DFB} = {84D58703-7569-445A-89B8-14D024FB6091} {9341070F-8A24-45FD-96FF-DC936EC9FE4C} = {84D58703-7569-445A-89B8-14D024FB6091} {9A0E9CD8-33FA-4E02-8EB6-5685CD84D727} = {29A3E154-E50B-49E7-96C3-32A91CAB9BA0} {DD5B2888-463A-4AB6-911F-EB0BEA47951A} = {29A3E154-E50B-49E7-96C3-32A91CAB9BA0} diff --git a/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln b/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln index c6f781e6c07f5..dcb2f6929969e 100644 --- a/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln +++ b/src/libraries/Microsoft.Win32.Registry/Microsoft.Win32.Registry.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry.Tests", "tests\Microsoft.Win32.Registry.Tests.csproj", "{E9123189-58BC-41A8-83A0-C46E74ED8160}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{9923CC23-8CA1-4FE4-B561-D3487502518F}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{CC7AEF63-5AE0-4A16-9DD7-0A55B539D906}" @@ -43,6 +45,10 @@ Global {E9123189-58BC-41A8-83A0-C46E74ED8160}.Debug|Any CPU.Build.0 = Debug|Any CPU {E9123189-58BC-41A8-83A0-C46E74ED8160}.Release|Any CPU.ActiveCfg = Release|Any CPU {E9123189-58BC-41A8-83A0-C46E74ED8160}.Release|Any CPU.Build.0 = Release|Any CPU + {9923CC23-8CA1-4FE4-B561-D3487502518F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9923CC23-8CA1-4FE4-B561-D3487502518F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9923CC23-8CA1-4FE4-B561-D3487502518F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9923CC23-8CA1-4FE4-B561-D3487502518F}.Release|Any CPU.Build.0 = Release|Any CPU {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -67,6 +73,7 @@ Global {F4F537EB-4436-4407-9A42-A75FE9CEECE0} = {D3839339-AF88-4867-BF81-44915AA883A2} {E9123189-58BC-41A8-83A0-C46E74ED8160} = {D3839339-AF88-4867-BF81-44915AA883A2} {FC5B0E37-024C-4A09-9080-AA78F2BCE4A0} = {DE8642D5-1264-473C-9896-35F348E89DBF} + {9923CC23-8CA1-4FE4-B561-D3487502518F} = {DE8642D5-1264-473C-9896-35F348E89DBF} {F8FEEEB3-1CEA-4EE9-ACE4-D147860E7A0F} = {DE8642D5-1264-473C-9896-35F348E89DBF} {3446E090-1587-4D16-AE6A-99C1788E86A6} = {66BCDB38-AFF7-4B7C-97F5-8869D5C2EDA9} {CC7AEF63-5AE0-4A16-9DD7-0A55B539D906} = {66BCDB38-AFF7-4B7C-97F5-8869D5C2EDA9} diff --git a/src/libraries/Microsoft.Win32.SystemEvents/NuGet.config b/src/libraries/Microsoft.Win32.SystemEvents/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/Microsoft.Win32.SystemEvents/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.AppContext/System.AppContext.sln b/src/libraries/System.AppContext/System.AppContext.sln index f727ce0c812fa..e2367001426d0 100644 --- a/src/libraries/System.AppContext/System.AppContext.sln +++ b/src/libraries/System.AppContext/System.AppContext.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{207F66C5-1274-445C-B69E-E2C5F0776843}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{262B61F6-470E-46B6-B392-858692D3FB23}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AE25156-94A3-4936-80FD-8343290DF4B4}" @@ -162,42 +158,6 @@ Global {207F66C5-1274-445C-B69E-E2C5F0776843}.Checked|x64.Build.0 = Debug|Any CPU {207F66C5-1274-445C-B69E-E2C5F0776843}.Checked|x86.ActiveCfg = Debug|Any CPU {207F66C5-1274-445C-B69E-E2C5F0776843}.Checked|x86.Build.0 = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x64.ActiveCfg = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x64.Build.0 = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x86.ActiveCfg = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Debug|x86.Build.0 = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|Any CPU.Build.0 = Release|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x64.ActiveCfg = Release|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x64.Build.0 = Release|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x86.ActiveCfg = Release|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Release|x86.Build.0 = Release|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|Any CPU.Build.0 = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x64.ActiveCfg = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x64.Build.0 = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x86.ActiveCfg = Debug|Any CPU - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0}.Checked|x86.Build.0 = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x64.ActiveCfg = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x64.Build.0 = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x86.ActiveCfg = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Debug|x86.Build.0 = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|Any CPU.Build.0 = Release|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x64.ActiveCfg = Release|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x64.Build.0 = Release|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x86.ActiveCfg = Release|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Release|x86.Build.0 = Release|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|Any CPU.Build.0 = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x64.ActiveCfg = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x64.Build.0 = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x86.ActiveCfg = Debug|Any CPU - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {751F6E52-BD51-406F-9EB6-06D3C27BF469} = {262B61F6-470E-46B6-B392-858692D3FB23} {1648AC4C-3BEF-4B93-933B-5EC520BF11D5} = {262B61F6-470E-46B6-B392-858692D3FB23} {207F66C5-1274-445C-B69E-E2C5F0776843} = {262B61F6-470E-46B6-B392-858692D3FB23} - {3C8675C1-42E4-4AAA-A4F7-F0B8492487F0} = {262B61F6-470E-46B6-B392-858692D3FB23} - {C82D15A8-53F4-4CD6-8F08-59FE0AFC718E} = {262B61F6-470E-46B6-B392-858692D3FB23} {F9B2FCA3-69C0-45A6-B1FA-E989263536C4} = {0AE25156-94A3-4936-80FD-8343290DF4B4} {007AD19C-8A80-4463-834C-BE7AE1808A04} = {0AE25156-94A3-4936-80FD-8343290DF4B4} {BB689125-CDA7-4CFA-A4D6-1C932092A67F} = {4E4CBD83-24E2-49A2-B0A5-57368BB1A055} diff --git a/src/libraries/System.Buffers/System.Buffers.sln b/src/libraries/System.Buffers/System.Buffers.sln index ffedd75f6d907..008b853144ce1 100644 --- a/src/libraries/System.Buffers/System.Buffers.sln +++ b/src/libraries/System.Buffers/System.Buffers.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{27D2947E-56F1-4046-805E-5DA3F636E15C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{97103694-085A-4CC9-9CF2-822B5472B236}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{07A3DCA1-A687-4607-81A5-3341D331D144}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A11072BB-28A6-44B6-A0A3-CAFE5E5309E5}" @@ -162,42 +158,6 @@ Global {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}.Checked|x64.Build.0 = Debug|Any CPU {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}.Checked|x86.ActiveCfg = Debug|Any CPU {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5}.Checked|x86.Build.0 = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x64.ActiveCfg = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x64.Build.0 = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x86.ActiveCfg = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Debug|x86.Build.0 = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|Any CPU.Build.0 = Release|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x64.ActiveCfg = Release|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x64.Build.0 = Release|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x86.ActiveCfg = Release|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Release|x86.Build.0 = Release|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|Any CPU.Build.0 = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x64.ActiveCfg = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x64.Build.0 = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x86.ActiveCfg = Debug|Any CPU - {27D2947E-56F1-4046-805E-5DA3F636E15C}.Checked|x86.Build.0 = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|Any CPU.Build.0 = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x64.ActiveCfg = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x64.Build.0 = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x86.ActiveCfg = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Debug|x86.Build.0 = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Release|Any CPU.ActiveCfg = Release|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Release|Any CPU.Build.0 = Release|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x64.ActiveCfg = Release|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x64.Build.0 = Release|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x86.ActiveCfg = Release|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Release|x86.Build.0 = Release|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|Any CPU.Build.0 = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x64.ActiveCfg = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x64.Build.0 = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x86.ActiveCfg = Debug|Any CPU - {97103694-085A-4CC9-9CF2-822B5472B236}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {006429DB-0860-4688-BD1D-459C9364594D} = {07A3DCA1-A687-4607-81A5-3341D331D144} {4BA09CF8-2B90-43E1-AB35-8A48FF8ECEC6} = {07A3DCA1-A687-4607-81A5-3341D331D144} {5368CFB4-8C6C-4350-9FF0-2FFCB1912AB5} = {07A3DCA1-A687-4607-81A5-3341D331D144} - {27D2947E-56F1-4046-805E-5DA3F636E15C} = {07A3DCA1-A687-4607-81A5-3341D331D144} - {97103694-085A-4CC9-9CF2-822B5472B236} = {07A3DCA1-A687-4607-81A5-3341D331D144} {350A679C-F690-49B3-AB97-340AF05E1250} = {A11072BB-28A6-44B6-A0A3-CAFE5E5309E5} {FF86CB73-2E54-4E89-9491-258324F291D0} = {A11072BB-28A6-44B6-A0A3-CAFE5E5309E5} {7F713B83-1256-4108-B40D-FDD380BB9DB6} = {914126D6-2C5E-49E9-B9BF-F94749FB2329} diff --git a/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln b/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln index e93b1d4613565..15d7747bbcf6f 100644 --- a/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln +++ b/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln @@ -17,10 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{A27E93BA-7A0C-417E-B178-F1727D50B7FF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{4F023286-853F-4B12-B0BC-ED3E42D38A13}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0}" @@ -204,42 +200,6 @@ Global {A27E93BA-7A0C-417E-B178-F1727D50B7FF}.Checked|x64.Build.0 = Debug|Any CPU {A27E93BA-7A0C-417E-B178-F1727D50B7FF}.Checked|x86.ActiveCfg = Debug|Any CPU {A27E93BA-7A0C-417E-B178-F1727D50B7FF}.Checked|x86.Build.0 = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x64.ActiveCfg = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x64.Build.0 = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x86.ActiveCfg = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Debug|x86.Build.0 = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|Any CPU.Build.0 = Release|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x64.ActiveCfg = Release|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x64.Build.0 = Release|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x86.ActiveCfg = Release|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Release|x86.Build.0 = Release|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|Any CPU.Build.0 = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x64.ActiveCfg = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x64.Build.0 = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x86.ActiveCfg = Debug|Any CPU - {4F023286-853F-4B12-B0BC-ED3E42D38A13}.Checked|x86.Build.0 = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x64.ActiveCfg = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x64.Build.0 = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x86.ActiveCfg = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Debug|x86.Build.0 = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|Any CPU.Build.0 = Release|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x64.ActiveCfg = Release|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x64.Build.0 = Release|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x86.ActiveCfg = Release|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Release|x86.Build.0 = Release|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|Any CPU.Build.0 = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x64.ActiveCfg = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x64.Build.0 = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x86.ActiveCfg = Debug|Any CPU - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6}.Checked|x86.Build.0 = Debug|Any CPU {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}.Debug|Any CPU.Build.0 = Debug|Any CPU {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -268,8 +228,6 @@ Global {34C59132-692C-45D7-87BD-869A18F09E2C} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {93FB3527-B9E6-4ECA-8F36-56835F4F9236} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {A27E93BA-7A0C-417E-B178-F1727D50B7FF} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} - {4F023286-853F-4B12-B0BC-ED3E42D38A13} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} - {7F53C9B5-37A9-4D29-A70C-378A41A8A6D6} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {FA6BD4D3-8D9B-4CA2-B8C6-A1A21F946AC2} = {C4EA7573-E0AC-45D9-A29A-F6C6DECED4B0} {7C2B8279-F7BB-4AD4-BA44-B9071090AF46} = {64657647-6C2C-4D36-A5D4-7E7534F3C66F} {C391ADBE-DD23-4F4A-B3EC-011974CC6CE8} = {64657647-6C2C-4D36-A5D4-7E7534F3C66F} diff --git a/src/libraries/System.Collections/System.Collections.sln b/src/libraries/System.Collections/System.Collections.sln index c338ea9b5d647..296a4cd2a17c1 100644 --- a/src/libraries/System.Collections/System.Collections.sln +++ b/src/libraries/System.Collections/System.Collections.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{68E94039-C5BC-47C8-87EA-DCCE549CA0B8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C848C534-DD16-4A69-81FF-894456E4B099}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6CD2C5E3-B5BA-4219-B8EF-9B5D486BF805}" @@ -162,42 +158,6 @@ Global {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}.Checked|x64.Build.0 = Debug|Any CPU {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}.Checked|x86.ActiveCfg = Debug|Any CPU {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6}.Checked|x86.Build.0 = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x64.ActiveCfg = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x64.Build.0 = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x86.ActiveCfg = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Debug|x86.Build.0 = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|Any CPU.Build.0 = Release|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x64.ActiveCfg = Release|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x64.Build.0 = Release|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x86.ActiveCfg = Release|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Release|x86.Build.0 = Release|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|Any CPU.Build.0 = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x64.ActiveCfg = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x64.Build.0 = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x86.ActiveCfg = Debug|Any CPU - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8}.Checked|x86.Build.0 = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x64.ActiveCfg = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x64.Build.0 = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x86.ActiveCfg = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Debug|x86.Build.0 = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|Any CPU.Build.0 = Release|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x64.ActiveCfg = Release|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x64.Build.0 = Release|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x86.ActiveCfg = Release|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Release|x86.Build.0 = Release|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|Any CPU.Build.0 = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x64.ActiveCfg = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x64.Build.0 = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x86.ActiveCfg = Debug|Any CPU - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {4385739F-14A1-4F21-96E3-12EA90580575} = {C848C534-DD16-4A69-81FF-894456E4B099} {DF501250-4105-4F79-A508-90B3A13A975A} = {C848C534-DD16-4A69-81FF-894456E4B099} {39FCF17F-5CBD-4BF1-BDEF-37F5BA3EE4F6} = {C848C534-DD16-4A69-81FF-894456E4B099} - {68E94039-C5BC-47C8-87EA-DCCE549CA0B8} = {C848C534-DD16-4A69-81FF-894456E4B099} - {F8374DBB-4DCD-4C3F-B37C-95CDA6918B62} = {C848C534-DD16-4A69-81FF-894456E4B099} {38D8F258-655E-459B-B2CE-0DED144AFBF7} = {6CD2C5E3-B5BA-4219-B8EF-9B5D486BF805} {BB54ED9D-FF71-4D91-B7C0-984AB0976798} = {6CD2C5E3-B5BA-4219-B8EF-9B5D486BF805} {77E9C47D-4AC4-4402-8613-40DF427174BD} = {06AE90FB-F007-4E70-BCD2-5CAD106A7C97} diff --git a/src/libraries/System.Console/System.Console.sln b/src/libraries/System.Console/System.Console.sln index a3e38e37197c0..f2e12502dda45 100644 --- a/src/libraries/System.Console/System.Console.sln +++ b/src/libraries/System.Console/System.Console.sln @@ -15,10 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BADDD400-7CBE-436D-BF12-BB47E83D7910}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9DAEBF55-6A76-4037-B119-5E48C2121D30}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DF6461C4-C26B-4911-BA9F-E9EBE09BE018}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{87011BFC-F4A7-4BEB-A794-ED75999604BF}" @@ -63,14 +59,6 @@ Global {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}.Debug|Any CPU.Build.0 = Debug|Any CPU {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B}.Release|Any CPU.Build.0 = Release|Any CPU - {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BADDD400-7CBE-436D-BF12-BB47E83D7910}.Release|Any CPU.Build.0 = Release|Any CPU - {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9DAEBF55-6A76-4037-B119-5E48C2121D30}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,8 +72,6 @@ Global {7EAA30FF-8911-4427-BFAC-9FC8BF8B3606} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} {BAA75C96-57D9-4EDF-8DDF-392DB08B2047} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} {ED2ED9D3-EC2E-4573-AFE6-46385CD3CE8B} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} - {BADDD400-7CBE-436D-BF12-BB47E83D7910} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} - {9DAEBF55-6A76-4037-B119-5E48C2121D30} = {5F676CAA-AE1E-4ACE-9769-FA07DA7F0F99} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E14E904-00F2-414A-BCF1-0EB09A861A21} diff --git a/src/libraries/System.Data.Common/System.Data.Common.sln b/src/libraries/System.Data.Common/System.Data.Common.sln index c651a9922ee8b..b3d0dd392c331 100644 --- a/src/libraries/System.Data.Common/System.Data.Common.sln +++ b/src/libraries/System.Data.Common/System.Data.Common.sln @@ -23,10 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Extensions", "..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj", "{68D868F6-1311-47A2-9DDE-22B64B5FF85E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{69D59191-E55C-485C-987F-A7539A0D791A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{09129981-6B0D-44C7-9F0A-AD2426106332}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5924BF80-8349-4021-A4A3-853FE714A7C7}" @@ -264,42 +260,6 @@ Global {68D868F6-1311-47A2-9DDE-22B64B5FF85E}.Checked|x64.Build.0 = Debug|Any CPU {68D868F6-1311-47A2-9DDE-22B64B5FF85E}.Checked|x86.ActiveCfg = Debug|Any CPU {68D868F6-1311-47A2-9DDE-22B64B5FF85E}.Checked|x86.Build.0 = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x64.ActiveCfg = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x64.Build.0 = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x86.ActiveCfg = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Debug|x86.Build.0 = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|Any CPU.Build.0 = Release|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x64.ActiveCfg = Release|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x64.Build.0 = Release|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x86.ActiveCfg = Release|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Release|x86.Build.0 = Release|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|Any CPU.Build.0 = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x64.ActiveCfg = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x64.Build.0 = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x86.ActiveCfg = Debug|Any CPU - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4}.Checked|x86.Build.0 = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x64.ActiveCfg = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x64.Build.0 = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x86.ActiveCfg = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Debug|x86.Build.0 = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Release|Any CPU.Build.0 = Release|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x64.ActiveCfg = Release|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x64.Build.0 = Release|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x86.ActiveCfg = Release|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Release|x86.Build.0 = Release|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|Any CPU.Build.0 = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x64.ActiveCfg = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x64.Build.0 = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x86.ActiveCfg = Debug|Any CPU - {69D59191-E55C-485C-987F-A7539A0D791A}.Checked|x86.Build.0 = Debug|Any CPU {09129981-6B0D-44C7-9F0A-AD2426106332}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {09129981-6B0D-44C7-9F0A-AD2426106332}.Debug|Any CPU.Build.0 = Debug|Any CPU {09129981-6B0D-44C7-9F0A-AD2426106332}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -331,8 +291,6 @@ Global {7AB121D2-0AAC-48E0-A834-6E220ECFEC4D} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {6E353933-8CBD-467D-8FF1-00133C3F2036} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {68D868F6-1311-47A2-9DDE-22B64B5FF85E} = {5924BF80-8349-4021-A4A3-853FE714A7C7} - {B12DBAAA-DB0C-419D-AB50-E551AAAFF4B4} = {5924BF80-8349-4021-A4A3-853FE714A7C7} - {69D59191-E55C-485C-987F-A7539A0D791A} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {09129981-6B0D-44C7-9F0A-AD2426106332} = {5924BF80-8349-4021-A4A3-853FE714A7C7} {0BD22D2A-C12C-4641-8F12-73D21AAAFBA3} = {B1861E5E-4FCA-4CA5-9BB5-5A3C3DBC7F7D} {BEBD7B5B-9544-42EB-B878-F009560CAAF4} = {B1861E5E-4FCA-4CA5-9BB5-5A3C3DBC7F7D} diff --git a/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln b/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln index bf18acd8a81aa..f50b8dfb693fd 100644 --- a/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln +++ b/src/libraries/System.Diagnostics.Contracts/System.Diagnostics.Contracts.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2D1EDC33-64F1-4145-B8A9-6CCC7961E195}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{A56373F2-05A6-4A91-A823-3FC2B63CA913}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ABC2D63C-77D2-49D8-AF86-2530D6672269}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{56A31E71-2D11-484D-A9D0-97E4A2AD9354}" @@ -162,42 +158,6 @@ Global {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}.Checked|x64.Build.0 = Debug|Any CPU {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}.Checked|x86.ActiveCfg = Debug|Any CPU {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB}.Checked|x86.Build.0 = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x64.ActiveCfg = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x64.Build.0 = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x86.ActiveCfg = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Debug|x86.Build.0 = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|Any CPU.Build.0 = Release|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x64.ActiveCfg = Release|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x64.Build.0 = Release|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x86.ActiveCfg = Release|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Release|x86.Build.0 = Release|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|Any CPU.Build.0 = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x64.ActiveCfg = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x64.Build.0 = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x86.ActiveCfg = Debug|Any CPU - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195}.Checked|x86.Build.0 = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x64.ActiveCfg = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x64.Build.0 = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x86.ActiveCfg = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Debug|x86.Build.0 = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|Any CPU.Build.0 = Release|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x64.ActiveCfg = Release|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x64.Build.0 = Release|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x86.ActiveCfg = Release|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Release|x86.Build.0 = Release|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|Any CPU.Build.0 = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x64.ActiveCfg = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x64.Build.0 = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x86.ActiveCfg = Debug|Any CPU - {A56373F2-05A6-4A91-A823-3FC2B63CA913}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {D5A81248-C2F8-464A-8EA4-2AB2528206BC} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} {158DD2BA-5789-49B8-A801-77EF5D4FD324} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} {CE9500E9-92BE-4357-8CE9-876DCF5CEFEB} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} - {2D1EDC33-64F1-4145-B8A9-6CCC7961E195} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} - {A56373F2-05A6-4A91-A823-3FC2B63CA913} = {ABC2D63C-77D2-49D8-AF86-2530D6672269} {E4B95B10-EC2A-4874-8E71-858A90A4BDFE} = {56A31E71-2D11-484D-A9D0-97E4A2AD9354} {2F113EAD-602B-4EBD-97E4-24C97CDFEB50} = {56A31E71-2D11-484D-A9D0-97E4A2AD9354} {DD15B8D0-013A-43B3-AC3D-1B0D626B35E0} = {8B71FA04-1D67-4607-94A4-E2A85977B1FA} diff --git a/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln b/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln index 13609c26482a0..51956da5b4f41 100644 --- a/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln +++ b/src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln @@ -15,10 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{019B8700-7F84-4DCF-B3F1-3A19D951BA3E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{C4E264C7-91E7-4100-BA47-47CB12964025}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{C61770DF-C267-4B18-8822-D9C062FE806E}" @@ -186,42 +182,6 @@ Global {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}.Checked|x64.Build.0 = Debug|Any CPU {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}.Checked|x86.ActiveCfg = Debug|Any CPU {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B}.Checked|x86.Build.0 = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x64.ActiveCfg = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x64.Build.0 = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x86.ActiveCfg = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Debug|x86.Build.0 = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|Any CPU.Build.0 = Release|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x64.ActiveCfg = Release|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x64.Build.0 = Release|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x86.ActiveCfg = Release|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Release|x86.Build.0 = Release|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|Any CPU.Build.0 = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x64.ActiveCfg = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x64.Build.0 = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x86.ActiveCfg = Debug|Any CPU - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E}.Checked|x86.Build.0 = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x64.ActiveCfg = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x64.Build.0 = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x86.ActiveCfg = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Debug|x86.Build.0 = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|Any CPU.Build.0 = Release|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x64.ActiveCfg = Release|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x64.Build.0 = Release|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x86.ActiveCfg = Release|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Release|x86.Build.0 = Release|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|Any CPU.Build.0 = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x64.ActiveCfg = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x64.Build.0 = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x86.ActiveCfg = Debug|Any CPU - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69}.Checked|x86.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -267,8 +227,6 @@ Global {05AA43B5-733A-43EF-8CE5-8BF4A18BD516} = {6C5230A5-919B-465B-9C98-852B85C96947} {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04} = {6C5230A5-919B-465B-9C98-852B85C96947} {5DF0CE4D-A949-457F-9FD9-8A8AB8E4809B} = {6C5230A5-919B-465B-9C98-852B85C96947} - {019B8700-7F84-4DCF-B3F1-3A19D951BA3E} = {6C5230A5-919B-465B-9C98-852B85C96947} - {A5C8E1E7-B1B0-41BC-B130-D80E1D388F69} = {6C5230A5-919B-465B-9C98-852B85C96947} {C4E264C7-91E7-4100-BA47-47CB12964025} = {6C5230A5-919B-465B-9C98-852B85C96947} {C61770DF-C267-4B18-8822-D9C062FE806E} = {6C5230A5-919B-465B-9C98-852B85C96947} {1C01EFBD-2332-4392-BB4A-918178861EDC} = {8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311} diff --git a/src/libraries/System.Diagnostics.EventLog/NuGet.config b/src/libraries/System.Diagnostics.EventLog/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Diagnostics.EventLog/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln b/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln index f169b9af521f9..d49a50d2ab3a9 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln +++ b/src/libraries/System.Diagnostics.FileVersionInfo/System.Diagnostics.FileVersionInfo.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2391C35B-E06E-4BD8-ABF0-C7EE981336D1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{98DEBCAB-4C9E-46E8-BE0C-4717218556C2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9B348261-5B6D-47C9-8042-93B19FBF6780}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8042448A-EB54-4EBB-A1E0-BAA0B5A343D8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{36141B8B-E6F5-4AAF-A053-BDD189531BAF}" @@ -57,14 +53,6 @@ Global {2391C35B-E06E-4BD8-ABF0-C7EE981336D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {2391C35B-E06E-4BD8-ABF0-C7EE981336D1}.Release|Any CPU.ActiveCfg = Release|Any CPU {2391C35B-E06E-4BD8-ABF0-C7EE981336D1}.Release|Any CPU.Build.0 = Release|Any CPU - {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98DEBCAB-4C9E-46E8-BE0C-4717218556C2}.Release|Any CPU.Build.0 = Release|Any CPU - {9B348261-5B6D-47C9-8042-93B19FBF6780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9B348261-5B6D-47C9-8042-93B19FBF6780}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B348261-5B6D-47C9-8042-93B19FBF6780}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9B348261-5B6D-47C9-8042-93B19FBF6780}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,8 +65,6 @@ Global {E75BB739-AE88-4CAA-82CA-72224A39D8CE} = {36141B8B-E6F5-4AAF-A053-BDD189531BAF} {922C96F5-9F92-4F0E-A83D-D1BCDDD187F2} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} {2391C35B-E06E-4BD8-ABF0-C7EE981336D1} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} - {98DEBCAB-4C9E-46E8-BE0C-4717218556C2} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} - {9B348261-5B6D-47C9-8042-93B19FBF6780} = {888B9739-0B73-4F21-A3CC-4694AEFE55CA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9FDF2FF3-5DFC-45E8-9959-B59FF906E689} diff --git a/src/libraries/System.Diagnostics.Process/NuGet.config b/src/libraries/System.Diagnostics.Process/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Diagnostics.Process/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln b/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln index b0cd46b3d2bf8..b3031e86d29ae 100644 --- a/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln +++ b/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln @@ -23,14 +23,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", ".. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{65CC713C-0735-4043-A4F2-9E1A2057A21B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{AEE4DD02-E38C-43E8-9150-3F034DA5979B}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{2E775DDC-C58B-4EBA-BE62-9B08D7C48059}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{68690ADA-7203-479B-B4B9-B7CE23E349A6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5862A6EC-A500-4335-9006-51699482E1B2}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{A0DE3634-6C95-4AA2-AFD5-733D352B6756}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{97763BA2-BD91-480C-8173-65EA2A72EAA8}" @@ -103,6 +101,10 @@ Global {65CC713C-0735-4043-A4F2-9E1A2057A21B}.Debug|Any CPU.Build.0 = Debug|Any CPU {65CC713C-0735-4043-A4F2-9E1A2057A21B}.Release|Any CPU.ActiveCfg = Release|Any CPU {65CC713C-0735-4043-A4F2-9E1A2057A21B}.Release|Any CPU.Build.0 = Release|Any CPU + {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEE4DD02-E38C-43E8-9150-3F034DA5979B}.Release|Any CPU.Build.0 = Release|Any CPU {2E775DDC-C58B-4EBA-BE62-9B08D7C48059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E775DDC-C58B-4EBA-BE62-9B08D7C48059}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E775DDC-C58B-4EBA-BE62-9B08D7C48059}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -111,14 +113,6 @@ Global {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F}.Release|Any CPU.Build.0 = Release|Any CPU - {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {68690ADA-7203-479B-B4B9-B7CE23E349A6}.Release|Any CPU.Build.0 = Release|Any CPU - {5862A6EC-A500-4335-9006-51699482E1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5862A6EC-A500-4335-9006-51699482E1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5862A6EC-A500-4335-9006-51699482E1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5862A6EC-A500-4335-9006-51699482E1B2}.Release|Any CPU.Build.0 = Release|Any CPU {A0DE3634-6C95-4AA2-AFD5-733D352B6756}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A0DE3634-6C95-4AA2-AFD5-733D352B6756}.Debug|Any CPU.Build.0 = Debug|Any CPU {A0DE3634-6C95-4AA2-AFD5-733D352B6756}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -157,8 +151,6 @@ Global {84075D59-9D5E-40F7-A914-911087419FE4} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {65CC713C-0735-4043-A4F2-9E1A2057A21B} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {3BF99E45-BBB6-47B5-A3F3-B7844A9E7D5F} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} - {68690ADA-7203-479B-B4B9-B7CE23E349A6} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} - {5862A6EC-A500-4335-9006-51699482E1B2} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {A0DE3634-6C95-4AA2-AFD5-733D352B6756} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {B8F3933C-7C0D-41B3-8B1F-D507EF92156B} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} {6CB8C6A4-3D21-47F6-A9A3-A9D1DA3E6B9F} = {B27D0964-41D3-4520-8D68-AD69F010A6B9} @@ -167,6 +159,7 @@ Global {4792FFA1-1AD2-4230-8DE3-D2BCF1CF804F} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {F485B36D-8DDB-44EE-A993-2FCAEC81BE3E} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {6155E80C-6CE0-4A93-8BDF-80494E489BB1} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} + {AEE4DD02-E38C-43E8-9150-3F034DA5979B} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {2E775DDC-C58B-4EBA-BE62-9B08D7C48059} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {97763BA2-BD91-480C-8173-65EA2A72EAA8} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} {546D7B53-3A00-47A4-BBE0-F4BA12126D6F} = {8A0AABD7-E3CA-40EA-8290-CEB1D3D0F9AD} diff --git a/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln b/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln index 679b4b9794975..d803d8f5effe4 100644 --- a/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln +++ b/src/libraries/System.Diagnostics.StackTrace/System.Diagnostics.StackTrace.sln @@ -33,10 +33,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Extensions", "..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj", "{449DFAB8-C413-44E4-BEAE-C61595DBCBC2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5C279302-4206-49C5-B0FD-57DBBE60D404}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{623D46A5-8ED4-43CF-A01B-528F0A505090}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{039BB256-1BCF-4398-B586-C05F7C5225C4}" @@ -366,42 +362,6 @@ Global {449DFAB8-C413-44E4-BEAE-C61595DBCBC2}.Checked|x64.Build.0 = Debug|Any CPU {449DFAB8-C413-44E4-BEAE-C61595DBCBC2}.Checked|x86.ActiveCfg = Debug|Any CPU {449DFAB8-C413-44E4-BEAE-C61595DBCBC2}.Checked|x86.Build.0 = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x64.ActiveCfg = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x64.Build.0 = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x86.ActiveCfg = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Debug|x86.Build.0 = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|Any CPU.Build.0 = Release|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x64.ActiveCfg = Release|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x64.Build.0 = Release|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x86.ActiveCfg = Release|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Release|x86.Build.0 = Release|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|Any CPU.Build.0 = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x64.ActiveCfg = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x64.Build.0 = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x86.ActiveCfg = Debug|Any CPU - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7}.Checked|x86.Build.0 = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x64.ActiveCfg = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x64.Build.0 = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x86.ActiveCfg = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Debug|x86.Build.0 = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|Any CPU.Build.0 = Release|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x64.ActiveCfg = Release|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x64.Build.0 = Release|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x86.ActiveCfg = Release|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Release|x86.Build.0 = Release|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|Any CPU.Build.0 = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x64.ActiveCfg = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x64.Build.0 = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x86.ActiveCfg = Debug|Any CPU - {5C279302-4206-49C5-B0FD-57DBBE60D404}.Checked|x86.Build.0 = Debug|Any CPU {623D46A5-8ED4-43CF-A01B-528F0A505090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {623D46A5-8ED4-43CF-A01B-528F0A505090}.Debug|Any CPU.Build.0 = Debug|Any CPU {623D46A5-8ED4-43CF-A01B-528F0A505090}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -453,8 +413,6 @@ Global {E5EB0B0B-FFAC-4C1B-AD59-292849F847FE} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {E5CCAE24-D76A-4409-BED8-A4E3F188A64A} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {449DFAB8-C413-44E4-BEAE-C61595DBCBC2} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} - {83DE7D4C-BB3E-47E5-A26E-6BD84405D9B7} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} - {5C279302-4206-49C5-B0FD-57DBBE60D404} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {623D46A5-8ED4-43CF-A01B-528F0A505090} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {039BB256-1BCF-4398-B586-C05F7C5225C4} = {C81302E5-C312-4C10-ACC7-D7201A16FAC6} {65FFFD20-CE5D-4FC0-A525-1C308186A16F} = {A376B9EB-8223-464D-A8F5-0000B26254F4} diff --git a/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln b/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln index 2a7e15f6516dc..c5caa75015cc8 100644 --- a/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln +++ b/src/libraries/System.Diagnostics.Tools/System.Diagnostics.Tools.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{6AC1A337-2D08-4230-8D95-B52F324F291F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{07A0059D-96B6-4E44-B776-744536F213D3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{1E3AD374-6B64-45E5-A09F-1D51EE6290BA}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{15569044-E5D8-40B5-B718-A51ECAA6B259}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0EFD8A36-ACB0-4451-800E-DA867389324D}" @@ -162,42 +158,6 @@ Global {6AC1A337-2D08-4230-8D95-B52F324F291F}.Checked|x64.Build.0 = Debug|Any CPU {6AC1A337-2D08-4230-8D95-B52F324F291F}.Checked|x86.ActiveCfg = Debug|Any CPU {6AC1A337-2D08-4230-8D95-B52F324F291F}.Checked|x86.Build.0 = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x64.ActiveCfg = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x64.Build.0 = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x86.ActiveCfg = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Debug|x86.Build.0 = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Release|Any CPU.Build.0 = Release|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x64.ActiveCfg = Release|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x64.Build.0 = Release|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x86.ActiveCfg = Release|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Release|x86.Build.0 = Release|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|Any CPU.Build.0 = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x64.ActiveCfg = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x64.Build.0 = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x86.ActiveCfg = Debug|Any CPU - {07A0059D-96B6-4E44-B776-744536F213D3}.Checked|x86.Build.0 = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x64.ActiveCfg = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x64.Build.0 = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x86.ActiveCfg = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Debug|x86.Build.0 = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|Any CPU.Build.0 = Release|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x64.ActiveCfg = Release|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x64.Build.0 = Release|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x86.ActiveCfg = Release|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Release|x86.Build.0 = Release|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|Any CPU.Build.0 = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x64.ActiveCfg = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x64.Build.0 = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x86.ActiveCfg = Debug|Any CPU - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {4E534B56-D245-41B7-B4D0-F8AB7BCC8877} = {15569044-E5D8-40B5-B718-A51ECAA6B259} {566DC861-7C05-45AE-8F59-83D1A175A619} = {15569044-E5D8-40B5-B718-A51ECAA6B259} {6AC1A337-2D08-4230-8D95-B52F324F291F} = {15569044-E5D8-40B5-B718-A51ECAA6B259} - {07A0059D-96B6-4E44-B776-744536F213D3} = {15569044-E5D8-40B5-B718-A51ECAA6B259} - {1E3AD374-6B64-45E5-A09F-1D51EE6290BA} = {15569044-E5D8-40B5-B718-A51ECAA6B259} {6FF6D8F0-403D-40DF-9D75-895E2AF22B88} = {0EFD8A36-ACB0-4451-800E-DA867389324D} {A63F3AEA-F4ED-4047-A11F-490325530D92} = {0EFD8A36-ACB0-4451-800E-DA867389324D} {E5F5CCFF-4DBA-4323-82A6-8D472C488C0B} = {F8D19CA8-D65B-4C4B-9851-8E2836CFD72E} diff --git a/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln b/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln index 0bc23d64fae8d..3fe8e66fc37bb 100644 --- a/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln +++ b/src/libraries/System.Diagnostics.TraceSource/System.Diagnostics.TraceSource.sln @@ -25,10 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Extensions", "..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj", "{0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{E7BDDF6F-685D-49F8-8590-7E242E26CC26}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{067272CD-1753-4090-8E10-B9EC9CE67253}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{637E7769-42D2-4541-9A63-32301113FA5A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{7C0A6923-A9BC-4F10-81E0-C535EEF537BB}" @@ -286,42 +282,6 @@ Global {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}.Checked|x64.Build.0 = Debug|Any CPU {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}.Checked|x86.ActiveCfg = Debug|Any CPU {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5}.Checked|x86.Build.0 = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x64.ActiveCfg = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x64.Build.0 = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x86.ActiveCfg = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Debug|x86.Build.0 = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|Any CPU.Build.0 = Release|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x64.ActiveCfg = Release|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x64.Build.0 = Release|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x86.ActiveCfg = Release|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Release|x86.Build.0 = Release|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|Any CPU.Build.0 = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x64.ActiveCfg = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x64.Build.0 = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x86.ActiveCfg = Debug|Any CPU - {E7BDDF6F-685D-49F8-8590-7E242E26CC26}.Checked|x86.Build.0 = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|Any CPU.Build.0 = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x64.ActiveCfg = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x64.Build.0 = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x86.ActiveCfg = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Debug|x86.Build.0 = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|Any CPU.ActiveCfg = Release|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|Any CPU.Build.0 = Release|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x64.ActiveCfg = Release|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x64.Build.0 = Release|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x86.ActiveCfg = Release|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Release|x86.Build.0 = Release|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|Any CPU.Build.0 = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x64.ActiveCfg = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x64.Build.0 = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x86.ActiveCfg = Debug|Any CPU - {067272CD-1753-4090-8E10-B9EC9CE67253}.Checked|x86.Build.0 = Debug|Any CPU {637E7769-42D2-4541-9A63-32301113FA5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {637E7769-42D2-4541-9A63-32301113FA5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {637E7769-42D2-4541-9A63-32301113FA5A}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -372,8 +332,6 @@ Global {4DAA5CFC-C59D-4C1B-A12A-BC9863F38C0C} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {BFDA7EE4-2407-4799-82B0-D977F3363A0D} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {0A5BC6DA-7ADB-4BF7-8313-DFCE49787EE5} = {315BC231-270B-456C-919A-3E9BB50CDD7A} - {E7BDDF6F-685D-49F8-8590-7E242E26CC26} = {315BC231-270B-456C-919A-3E9BB50CDD7A} - {067272CD-1753-4090-8E10-B9EC9CE67253} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {637E7769-42D2-4541-9A63-32301113FA5A} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {7C0A6923-A9BC-4F10-81E0-C535EEF537BB} = {315BC231-270B-456C-919A-3E9BB50CDD7A} {F6BCA6EF-777E-408B-B49B-B055B5A0BA19} = {6BA02609-AE23-4E80-8B4B-9C6548AA147A} diff --git a/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln b/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln index 4f8ad0e099eed..9784a658ee6ca 100644 --- a/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln +++ b/src/libraries/System.Diagnostics.Tracing/System.Diagnostics.Tracing.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{7ED6F742-A58B-4352-AD32-88F53E65B763}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{724D36C1-71F6-40D6-9150-020675BECE48}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{43A929AA-2373-4109-BC31-AD6838503506}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{269A342C-D693-495C-8A07-11E08C881F6B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{21E11D21-3706-49C7-ACA7-10BA9A021908}" @@ -162,42 +158,6 @@ Global {7ED6F742-A58B-4352-AD32-88F53E65B763}.Checked|x64.Build.0 = Debug|Any CPU {7ED6F742-A58B-4352-AD32-88F53E65B763}.Checked|x86.ActiveCfg = Debug|Any CPU {7ED6F742-A58B-4352-AD32-88F53E65B763}.Checked|x86.Build.0 = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|Any CPU.Build.0 = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x64.ActiveCfg = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x64.Build.0 = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x86.ActiveCfg = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Debug|x86.Build.0 = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Release|Any CPU.ActiveCfg = Release|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Release|Any CPU.Build.0 = Release|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x64.ActiveCfg = Release|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x64.Build.0 = Release|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x86.ActiveCfg = Release|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Release|x86.Build.0 = Release|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|Any CPU.Build.0 = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x64.ActiveCfg = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x64.Build.0 = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x86.ActiveCfg = Debug|Any CPU - {724D36C1-71F6-40D6-9150-020675BECE48}.Checked|x86.Build.0 = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Debug|Any CPU.Build.0 = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x64.ActiveCfg = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x64.Build.0 = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x86.ActiveCfg = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Debug|x86.Build.0 = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Release|Any CPU.ActiveCfg = Release|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Release|Any CPU.Build.0 = Release|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Release|x64.ActiveCfg = Release|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Release|x64.Build.0 = Release|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Release|x86.ActiveCfg = Release|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Release|x86.Build.0 = Release|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Checked|Any CPU.Build.0 = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x64.ActiveCfg = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x64.Build.0 = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x86.ActiveCfg = Debug|Any CPU - {43A929AA-2373-4109-BC31-AD6838503506}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {370DCE61-CBDF-466E-91DB-5AE622BF2E52} = {269A342C-D693-495C-8A07-11E08C881F6B} {63783D6D-0848-4303-8E7A-BBB7F65DCE9E} = {269A342C-D693-495C-8A07-11E08C881F6B} {7ED6F742-A58B-4352-AD32-88F53E65B763} = {269A342C-D693-495C-8A07-11E08C881F6B} - {724D36C1-71F6-40D6-9150-020675BECE48} = {269A342C-D693-495C-8A07-11E08C881F6B} - {43A929AA-2373-4109-BC31-AD6838503506} = {269A342C-D693-495C-8A07-11E08C881F6B} {6E159831-C97C-40FD-AD1A-E8B1EE3E7168} = {21E11D21-3706-49C7-ACA7-10BA9A021908} {24605C4D-2465-433D-A393-45CB950E0834} = {21E11D21-3706-49C7-ACA7-10BA9A021908} {D7C16DED-127A-4CBB-BBCF-DF133816413B} = {61AC03AE-7090-458C-A3AB-5A4CCFF6AD08} diff --git a/src/libraries/System.DirectoryServices.Protocols/NuGet.config b/src/libraries/System.DirectoryServices.Protocols/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.DirectoryServices.Protocols/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.DirectoryServices/NuGet.config b/src/libraries/System.DirectoryServices/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.DirectoryServices/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Drawing.Common/NuGet.config b/src/libraries/System.Drawing.Common/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Drawing.Common/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Drawing.Primitives/NuGet.config b/src/libraries/System.Drawing.Primitives/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Drawing.Primitives/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln b/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln index 7001aeddab7ae..4c5b704b6ea74 100644 --- a/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln +++ b/src/libraries/System.Globalization.Calendars/System.Globalization.Calendars.sln @@ -15,10 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{82D06D01-23ED-4A72-9101-5C9E8255D93A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{37875A74-8496-4B3B-828D-C397F5379B65}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4}" @@ -182,42 +178,6 @@ Global {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}.Checked|x64.Build.0 = Debug|Any CPU {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}.Checked|x86.ActiveCfg = Debug|Any CPU {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4}.Checked|x86.Build.0 = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x64.ActiveCfg = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x64.Build.0 = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x86.ActiveCfg = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Debug|x86.Build.0 = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|Any CPU.Build.0 = Release|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x64.ActiveCfg = Release|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x64.Build.0 = Release|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x86.ActiveCfg = Release|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Release|x86.Build.0 = Release|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|Any CPU.Build.0 = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x64.ActiveCfg = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x64.Build.0 = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x86.ActiveCfg = Debug|Any CPU - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8}.Checked|x86.Build.0 = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x64.ActiveCfg = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x64.Build.0 = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x86.ActiveCfg = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Debug|x86.Build.0 = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|Any CPU.Build.0 = Release|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x64.ActiveCfg = Release|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x64.Build.0 = Release|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x86.ActiveCfg = Release|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Release|x86.Build.0 = Release|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|Any CPU.Build.0 = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x64.ActiveCfg = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x64.Build.0 = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x86.ActiveCfg = Debug|Any CPU - {82D06D01-23ED-4A72-9101-5C9E8255D93A}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -226,8 +186,6 @@ Global {E70B35E3-B6C3-4196-9FAB-1A0D45748E79} = {37875A74-8496-4B3B-828D-C397F5379B65} {705D0D71-8890-4893-824F-E302CDE5349F} = {37875A74-8496-4B3B-828D-C397F5379B65} {DE8D220F-4A0B-4B79-A6AD-B20FD67CC7A4} = {37875A74-8496-4B3B-828D-C397F5379B65} - {67CAC5E0-BCFF-4184-BA84-D0322A4ED1A8} = {37875A74-8496-4B3B-828D-C397F5379B65} - {82D06D01-23ED-4A72-9101-5C9E8255D93A} = {37875A74-8496-4B3B-828D-C397F5379B65} {32F01C47-D495-45CE-9567-E4C434F7D627} = {CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4} {CD1CDCDD-64FA-4E75-A74F-16A978C56449} = {CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4} {BFEF5B19-7D03-42BA-9CD1-D1B53F35D706} = {CDAC58B3-78D7-482F-B3EF-798DFAF7A1A4} diff --git a/src/libraries/System.Globalization/System.Globalization.sln b/src/libraries/System.Globalization/System.Globalization.sln index 68e08a273a33b..2989f693701a9 100644 --- a/src/libraries/System.Globalization/System.Globalization.sln +++ b/src/libraries/System.Globalization/System.Globalization.sln @@ -19,10 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{F17D674C-0B0A-47FB-8B81-5B8664564E23}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2DFC9D02-52CC-47EE-B360-CD5358DC02C9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5D1149E9-95DB-45B9-A6F8-8285F289591E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4B81A206-3C49-4224-A031-42583071751B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C223E72F-FD21-43C3-AC7A-62BCF4A5C379}" @@ -222,42 +218,6 @@ Global {F17D674C-0B0A-47FB-8B81-5B8664564E23}.Checked|x64.Build.0 = Debug|Any CPU {F17D674C-0B0A-47FB-8B81-5B8664564E23}.Checked|x86.ActiveCfg = Debug|Any CPU {F17D674C-0B0A-47FB-8B81-5B8664564E23}.Checked|x86.Build.0 = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x64.ActiveCfg = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x64.Build.0 = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x86.ActiveCfg = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Debug|x86.Build.0 = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|Any CPU.Build.0 = Release|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x64.ActiveCfg = Release|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x64.Build.0 = Release|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x86.ActiveCfg = Release|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Release|x86.Build.0 = Release|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|Any CPU.Build.0 = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x64.ActiveCfg = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x64.Build.0 = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x86.ActiveCfg = Debug|Any CPU - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9}.Checked|x86.Build.0 = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x64.ActiveCfg = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x64.Build.0 = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x86.ActiveCfg = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Debug|x86.Build.0 = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|Any CPU.Build.0 = Release|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x64.ActiveCfg = Release|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x64.Build.0 = Release|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x86.ActiveCfg = Release|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Release|x86.Build.0 = Release|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|Any CPU.Build.0 = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x64.ActiveCfg = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x64.Build.0 = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x86.ActiveCfg = Debug|Any CPU - {5D1149E9-95DB-45B9-A6F8-8285F289591E}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -266,8 +226,6 @@ Global {E269F8BB-F629-4C96-B9B2-03A00D8B1BFB} = {4B81A206-3C49-4224-A031-42583071751B} {4ABAB509-1210-43B4-B274-76B4FE02BD9B} = {4B81A206-3C49-4224-A031-42583071751B} {F17D674C-0B0A-47FB-8B81-5B8664564E23} = {4B81A206-3C49-4224-A031-42583071751B} - {2DFC9D02-52CC-47EE-B360-CD5358DC02C9} = {4B81A206-3C49-4224-A031-42583071751B} - {5D1149E9-95DB-45B9-A6F8-8285F289591E} = {4B81A206-3C49-4224-A031-42583071751B} {79613DED-481D-44EF-BB89-7AC6BD53026B} = {C223E72F-FD21-43C3-AC7A-62BCF4A5C379} {40231BCB-E151-45E0-A1C4-4D559A434362} = {C223E72F-FD21-43C3-AC7A-62BCF4A5C379} {DD7E56B4-65B7-4822-A4E1-ECDD51524927} = {C223E72F-FD21-43C3-AC7A-62BCF4A5C379} diff --git a/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln b/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln index 722a2821992c1..ee55a67f3ebc5 100644 --- a/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln +++ b/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{864B86AD-4BC9-4997-8370-EC8B2055FE08}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{1BC1DCD5-DECC-4712-8539-56E6D71A17FF}" @@ -57,14 +53,6 @@ Global {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1}.Release|Any CPU.Build.0 = Release|Any CPU - {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6}.Release|Any CPU.Build.0 = Release|Any CPU - {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,8 +65,6 @@ Global {A50E06CB-B581-46AB-B91F-4AAAA62A9F8C} = {1BC1DCD5-DECC-4712-8539-56E6D71A17FF} {C2A30FF0-54C2-461B-BF16-5DC610F54B52} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} {8AD9C0AC-E4C4-48D6-A191-67C4DA4399E1} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} - {3D859AEB-3BC4-4940-BCEB-DBC1AA34CFE6} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} - {D3EB3812-5C3C-4F64-BE79-A638B5ED4CDB} = {D7FE73BB-2F95-42D3-9392-FBAD87A73436} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {42B626C7-CDFD-459B-86D8-239917F86516} diff --git a/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln b/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln index 8f502c1d0ceb5..c7a1280a599c1 100644 --- a/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln +++ b/src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DBD14497-E65E-45FC-99BA-DFE6641135BE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A46DB030-84B9-49C0-8F75-98FE1290EF88}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4}" @@ -51,14 +47,6 @@ Global {DBD14497-E65E-45FC-99BA-DFE6641135BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {DBD14497-E65E-45FC-99BA-DFE6641135BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {DBD14497-E65E-45FC-99BA-DFE6641135BE}.Release|Any CPU.Build.0 = Release|Any CPU - {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7}.Release|Any CPU.Build.0 = Release|Any CPU - {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -70,8 +58,6 @@ Global {9D260F5B-F8EC-41D2-8A30-60D6ADF0910A} = {A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4} {A3C36A2F-2586-43DF-B39C-A9D14DF8524E} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} {DBD14497-E65E-45FC-99BA-DFE6641135BE} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} - {7DF8BBFD-7A6E-46C7-A86A-3E99BA00C3C7} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} - {F8BB0247-5D5B-42A0-9725-479D0FE3DE7C} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D2E26432-A647-4E61-9A30-DE6C62BBD632} diff --git a/src/libraries/System.IO.Compression/System.IO.Compression.sln b/src/libraries/System.IO.Compression/System.IO.Compression.sln index 6999c4bd0eca2..7378d594ea0d7 100644 --- a/src/libraries/System.IO.Compression/System.IO.Compression.sln +++ b/src/libraries/System.IO.Compression/System.IO.Compression.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{65C7FDC3-D18B-4888-88C1-EA22B9247831}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2252FA2C-1919-4EC4-A9A7-35516EFDF76F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{A96AB805-19C0-4F48-9703-84939C7EED20}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BB657E6F-1D06-4E7A-B4C2-B40A071A2A44}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{350F6B1E-B006-4EA5-BA9E-41F57FF84FF1}" @@ -57,14 +53,6 @@ Global {65C7FDC3-D18B-4888-88C1-EA22B9247831}.Debug|Any CPU.Build.0 = Debug|Any CPU {65C7FDC3-D18B-4888-88C1-EA22B9247831}.Release|Any CPU.ActiveCfg = Release|Any CPU {65C7FDC3-D18B-4888-88C1-EA22B9247831}.Release|Any CPU.Build.0 = Release|Any CPU - {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2252FA2C-1919-4EC4-A9A7-35516EFDF76F}.Release|Any CPU.Build.0 = Release|Any CPU - {A96AB805-19C0-4F48-9703-84939C7EED20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A96AB805-19C0-4F48-9703-84939C7EED20}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A96AB805-19C0-4F48-9703-84939C7EED20}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A96AB805-19C0-4F48-9703-84939C7EED20}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,8 +65,6 @@ Global {BD3E0A9D-1E3D-4E5A-A095-AB33B234AFE7} = {350F6B1E-B006-4EA5-BA9E-41F57FF84FF1} {ED776381-E13D-4A0B-ACB4-74C5A784BD25} = {8541C42E-9FC4-4077-B828-720BD028F1F5} {65C7FDC3-D18B-4888-88C1-EA22B9247831} = {8541C42E-9FC4-4077-B828-720BD028F1F5} - {2252FA2C-1919-4EC4-A9A7-35516EFDF76F} = {8541C42E-9FC4-4077-B828-720BD028F1F5} - {A96AB805-19C0-4F48-9703-84939C7EED20} = {8541C42E-9FC4-4077-B828-720BD028F1F5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0F6F5B24-5CE5-45F2-9169-FEBEF2A3FE80} diff --git a/src/libraries/System.IO.FileSystem.AccessControl/NuGet.config b/src/libraries/System.IO.FileSystem.AccessControl/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.IO.FileSystem.AccessControl/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln b/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln index ad7dc3b80cad2..fe8ec0c1d5638 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln +++ b/src/libraries/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{C2CCE41E-FD28-4FF7-98AF-49965F051C4F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{8F141019-D882-4FE7-9A92-74415DBCD858}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F74D982D-DFE5-48DA-87C0-245FC612F118}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{4626E870-1F74-4ED4-AF80-DDDD42DEF47E}" @@ -51,14 +47,6 @@ Global {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8}.Release|Any CPU.Build.0 = Release|Any CPU - {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C2CCE41E-FD28-4FF7-98AF-49965F051C4F}.Release|Any CPU.Build.0 = Release|Any CPU - {8F141019-D882-4FE7-9A92-74415DBCD858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F141019-D882-4FE7-9A92-74415DBCD858}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F141019-D882-4FE7-9A92-74415DBCD858}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F141019-D882-4FE7-9A92-74415DBCD858}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -70,8 +58,6 @@ Global {A0FB000A-C607-4CBB-9223-A5FCA85DF23F} = {4626E870-1F74-4ED4-AF80-DDDD42DEF47E} {03A51C60-B41B-409B-97AA-4084042C78D7} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} {0DF4EEAD-A1DF-4543-98B0-8975CC1AC8C8} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} - {C2CCE41E-FD28-4FF7-98AF-49965F051C4F} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} - {8F141019-D882-4FE7-9A92-74415DBCD858} = {F20F7286-4DFA-42EE-947B-8ABC6B7E088F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF704C7D-836B-41D4-919E-B0874D934A08} diff --git a/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln b/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln index fa986042e4728..8b12ed4d26ee3 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln +++ b/src/libraries/System.IO.FileSystem.Watcher/System.IO.FileSystem.Watcher.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{BB57F4F3-0519-4846-8CEC-04D2D2CFE144}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{24B02C33-7BFD-4D9A-90EB-551D81DEB58D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{88BDA307-9C09-4690-B3BE-6C67DA71E976}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A4E6A754-5006-4E2F-BC57-0A96E3A82A4D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{FB3E732D-C87B-41E9-ADC2-C2D84B87D04F}" @@ -51,14 +47,6 @@ Global {BB57F4F3-0519-4846-8CEC-04D2D2CFE144}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB57F4F3-0519-4846-8CEC-04D2D2CFE144}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB57F4F3-0519-4846-8CEC-04D2D2CFE144}.Release|Any CPU.Build.0 = Release|Any CPU - {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24B02C33-7BFD-4D9A-90EB-551D81DEB58D}.Release|Any CPU.Build.0 = Release|Any CPU - {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88BDA307-9C09-4690-B3BE-6C67DA71E976}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -70,8 +58,6 @@ Global {1D98691D-E3BD-483A-B449-F8F875A0BC0B} = {FB3E732D-C87B-41E9-ADC2-C2D84B87D04F} {310BA7DB-1A9E-46E1-B414-606474FFFFFA} = {BCDF2178-959A-48C9-B26D-18E62C80199C} {BB57F4F3-0519-4846-8CEC-04D2D2CFE144} = {BCDF2178-959A-48C9-B26D-18E62C80199C} - {24B02C33-7BFD-4D9A-90EB-551D81DEB58D} = {BCDF2178-959A-48C9-B26D-18E62C80199C} - {88BDA307-9C09-4690-B3BE-6C67DA71E976} = {BCDF2178-959A-48C9-B26D-18E62C80199C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3D76AA3-27C1-48BF-9474-42E0495BA814} diff --git a/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln b/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln index 736f6ce0b86d1..1958430a9e5ab 100644 --- a/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln +++ b/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln @@ -29,10 +29,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D7DF8034-3AE5-4DEF-BCC4-6353239391BF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{40E79B9B-E9EA-4012-945B-5DB8E02F60E2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{6599D78B-6462-423C-9C31-62A4990FF5C6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{5E9D796C-426C-47E0-AA28-6CAE530855B7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{E004B4E4-0D54-4CAA-89C5-FCDB72C99846}" @@ -117,14 +113,6 @@ Global {D7DF8034-3AE5-4DEF-BCC4-6353239391BF}.Debug|Any CPU.Build.0 = Debug|Any CPU {D7DF8034-3AE5-4DEF-BCC4-6353239391BF}.Release|Any CPU.ActiveCfg = Release|Any CPU {D7DF8034-3AE5-4DEF-BCC4-6353239391BF}.Release|Any CPU.Build.0 = Release|Any CPU - {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {40E79B9B-E9EA-4012-945B-5DB8E02F60E2}.Release|Any CPU.Build.0 = Release|Any CPU - {6599D78B-6462-423C-9C31-62A4990FF5C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6599D78B-6462-423C-9C31-62A4990FF5C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6599D78B-6462-423C-9C31-62A4990FF5C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6599D78B-6462-423C-9C31-62A4990FF5C6}.Release|Any CPU.Build.0 = Release|Any CPU {5E9D796C-426C-47E0-AA28-6CAE530855B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E9D796C-426C-47E0-AA28-6CAE530855B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E9D796C-426C-47E0-AA28-6CAE530855B7}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -172,8 +160,6 @@ Global {8A502375-D99B-4C43-92C9-F5DFB336AF38} = {A0499117-998E-494E-943B-86F428E5C59F} {877E39A8-51CB-463A-AF4C-6FAE4F438075} = {A0499117-998E-494E-943B-86F428E5C59F} {D7DF8034-3AE5-4DEF-BCC4-6353239391BF} = {A0499117-998E-494E-943B-86F428E5C59F} - {40E79B9B-E9EA-4012-945B-5DB8E02F60E2} = {A0499117-998E-494E-943B-86F428E5C59F} - {6599D78B-6462-423C-9C31-62A4990FF5C6} = {A0499117-998E-494E-943B-86F428E5C59F} {5E9D796C-426C-47E0-AA28-6CAE530855B7} = {A0499117-998E-494E-943B-86F428E5C59F} {2069A1E6-5A4A-43F2-ACDE-050B3DBB0A7D} = {A0499117-998E-494E-943B-86F428E5C59F} {3E06E543-2562-4AFB-B04F-520485B876A8} = {A0499117-998E-494E-943B-86F428E5C59F} diff --git a/src/libraries/System.IO.IsolatedStorage/NuGet.config b/src/libraries/System.IO.IsolatedStorage/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.IO.IsolatedStorage/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln b/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln index 1c16f29839472..9624f9e282b08 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln +++ b/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{4B990529-DAA4-4AEC-A625-FDCA3EF64E25}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{9F271789-0931-4414-B006-0A1B8362D69C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E9193727-72AB-4A35-BABF-A11D7C1A8B04}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{E91F427C-6CD7-496B-B4E8-D837CB8B96F8}" @@ -57,14 +53,6 @@ Global {4B990529-DAA4-4AEC-A625-FDCA3EF64E25}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B990529-DAA4-4AEC-A625-FDCA3EF64E25}.Release|Any CPU.ActiveCfg = Release|Any CPU {4B990529-DAA4-4AEC-A625-FDCA3EF64E25}.Release|Any CPU.Build.0 = Release|Any CPU - {9F271789-0931-4414-B006-0A1B8362D69C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9F271789-0931-4414-B006-0A1B8362D69C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F271789-0931-4414-B006-0A1B8362D69C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9F271789-0931-4414-B006-0A1B8362D69C}.Release|Any CPU.Build.0 = Release|Any CPU - {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,8 +65,6 @@ Global {8B9258B7-1C54-4FFE-9512-2B7323AEF92A} = {E91F427C-6CD7-496B-B4E8-D837CB8B96F8} {4A95E6CD-A466-46BC-A6C7-C65DA45B3388} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} {4B990529-DAA4-4AEC-A625-FDCA3EF64E25} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} - {9F271789-0931-4414-B006-0A1B8362D69C} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} - {BE6C573D-3F07-4C7D-87E4-0D7E9DC988CC} = {7CDB9185-B436-4B6A-91A2-DD2C30BB49D9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F8DDBB46-7ACE-4C13-91B4-FFB7E93363D9} diff --git a/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln b/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln index 3227bf2ddfeb9..e4668476e4742 100644 --- a/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln +++ b/src/libraries/System.IO.Pipes.AccessControl/System.IO.Pipes.AccessControl.sln @@ -7,16 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes.AccessContr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes.AccessControl.Tests", "tests\System.IO.Pipes.AccessControl.Tests.csproj", "{7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\ref\System.IO.Pipes.csproj", "{26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "..\System.IO.Pipes\src\System.IO.Pipes.csproj", "{5AE837A0-E966-41E5-9230-0830BB3E727F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{A6554F7C-F4FC-463D-9C0F-396B976FDB90}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{04D36F0B-F60F-43E8-931D-A85E312EAD1D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2CFDBF7E-CDBE-43F4-A1B2-25E634672285}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{D9DEC09D-3DC0-428C-A7F0-116CDD43BC69}" @@ -49,6 +47,10 @@ Global {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}.Debug|Any CPU.Build.0 = Debug|Any CPU {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}.Release|Any CPU.ActiveCfg = Release|Any CPU {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38}.Release|Any CPU.Build.0 = Release|Any CPU + {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542}.Release|Any CPU.Build.0 = Release|Any CPU {5AE837A0-E966-41E5-9230-0830BB3E727F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5AE837A0-E966-41E5-9230-0830BB3E727F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AE837A0-E966-41E5-9230-0830BB3E727F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -61,14 +63,6 @@ Global {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}.Debug|Any CPU.Build.0 = Debug|Any CPU {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}.Release|Any CPU.ActiveCfg = Release|Any CPU {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D}.Release|Any CPU.Build.0 = Release|Any CPU - {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {04D36F0B-F60F-43E8-931D-A85E312EAD1D}.Release|Any CPU.Build.0 = Release|Any CPU - {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2CFDBF7E-CDBE-43F4-A1B2-25E634672285}.Release|Any CPU.Build.0 = Release|Any CPU {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -85,12 +79,11 @@ Global {DF7DE1B3-C58E-4EBB-86C5-87EB59A177C6} = {E1F66F1E-923F-4B07-A1E9-3F1BB01F221A} {7E5965B1-EDF8-4FCC-AAC4-C91DFB043E38} = {E1F66F1E-923F-4B07-A1E9-3F1BB01F221A} {26E03980-4DB8-43B6-8737-1F7CAF7E5089} = {ADDC6FEE-EDF2-4EAD-B802-1BCF686E0D71} + {26DAACCD-8D9A-4F97-8AFC-BF1D3B4BC542} = {ADDC6FEE-EDF2-4EAD-B802-1BCF686E0D71} {A6554F7C-F4FC-463D-9C0F-396B976FDB90} = {ADDC6FEE-EDF2-4EAD-B802-1BCF686E0D71} {B6731AC0-E4F2-4E6C-B6DF-63EF396FCB71} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {5AE837A0-E966-41E5-9230-0830BB3E727F} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {846D56B2-A309-41B2-8BF8-89CFB3AF5F1D} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} - {04D36F0B-F60F-43E8-931D-A85E312EAD1D} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} - {2CFDBF7E-CDBE-43F4-A1B2-25E634672285} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {D8BA6A7D-73FF-428D-9527-65B9BC36E7E0} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} {D9DEC09D-3DC0-428C-A7F0-116CDD43BC69} = {F8E1D6D4-F8BF-4B79-8E2B-49BFE4145670} EndGlobalSection diff --git a/src/libraries/System.IO.Pipes/System.IO.Pipes.sln b/src/libraries/System.IO.Pipes/System.IO.Pipes.sln index 8f0070a29d784..6affa9ea08f6f 100644 --- a/src/libraries/System.IO.Pipes/System.IO.Pipes.sln +++ b/src/libraries/System.IO.Pipes/System.IO.Pipes.sln @@ -37,10 +37,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DD675156-B16E-44C8-854B-AEC717FF4DE0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{FD0D06C7-A080-416E-975B-98BC8C4AE5D6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{54399E44-3A81-4983-85D3-2B88065FE76A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.AccessControl", "..\System.Security.AccessControl\src\System.Security.AccessControl.csproj", "{5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.ProtectedData", "..\System.Security.Cryptography.ProtectedData\ref\System.Security.Cryptography.ProtectedData.csproj", "{25441E1F-971D-4FF3-BA5A-2FBAAC3EB9FF}" @@ -145,14 +141,6 @@ Global {DD675156-B16E-44C8-854B-AEC717FF4DE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD675156-B16E-44C8-854B-AEC717FF4DE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD675156-B16E-44C8-854B-AEC717FF4DE0}.Release|Any CPU.Build.0 = Release|Any CPU - {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FD0D06C7-A080-416E-975B-98BC8C4AE5D6}.Release|Any CPU.Build.0 = Release|Any CPU - {54399E44-3A81-4983-85D3-2B88065FE76A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {54399E44-3A81-4983-85D3-2B88065FE76A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {54399E44-3A81-4983-85D3-2B88065FE76A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {54399E44-3A81-4983-85D3-2B88065FE76A}.Release|Any CPU.Build.0 = Release|Any CPU {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -212,8 +200,6 @@ Global {A15B634C-E8F4-4822-BB45-66B95DC1C38F} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {3A471AEB-FCCB-43DF-9C04-F00FA9AAF81E} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {DD675156-B16E-44C8-854B-AEC717FF4DE0} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} - {FD0D06C7-A080-416E-975B-98BC8C4AE5D6} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} - {54399E44-3A81-4983-85D3-2B88065FE76A} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {5E285C4E-BE83-458A-84A9-3C1F8D9FAAF6} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {E565DD4A-0749-4F5E-8476-EF44D742E377} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} {15CB5F16-593B-460D-BDC3-134A56EF3B5F} = {B90127A0-E005-44FE-9D2B-3DE06444CE37} diff --git a/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln b/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln index 7c02c42fbe8d5..010316af865b0 100644 --- a/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln +++ b/src/libraries/System.IO.UnmanagedMemoryStream/System.IO.UnmanagedMemoryStream.sln @@ -15,10 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{B890249B-B590-4323-B1F6-0C1AB8E02D68}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{0B4B6C46-B848-43D3-B230-0A526ABAD1F5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D132DC37-ADF5-4210-A3C6-7480546CED7F}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A8D21009-1410-4367-8616-2075882003FF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7BB3C727-EA87-416E-84DD-34ADD5540067}" @@ -182,42 +178,6 @@ Global {B890249B-B590-4323-B1F6-0C1AB8E02D68}.Checked|x64.Build.0 = Debug|Any CPU {B890249B-B590-4323-B1F6-0C1AB8E02D68}.Checked|x86.ActiveCfg = Debug|Any CPU {B890249B-B590-4323-B1F6-0C1AB8E02D68}.Checked|x86.Build.0 = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x64.ActiveCfg = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x64.Build.0 = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x86.ActiveCfg = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Debug|x86.Build.0 = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|Any CPU.Build.0 = Release|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x64.ActiveCfg = Release|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x64.Build.0 = Release|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x86.ActiveCfg = Release|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Release|x86.Build.0 = Release|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|Any CPU.Build.0 = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x64.ActiveCfg = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x64.Build.0 = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x86.ActiveCfg = Debug|Any CPU - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5}.Checked|x86.Build.0 = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x64.ActiveCfg = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x64.Build.0 = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x86.ActiveCfg = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Debug|x86.Build.0 = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|Any CPU.Build.0 = Release|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x64.ActiveCfg = Release|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x64.Build.0 = Release|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x86.ActiveCfg = Release|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Release|x86.Build.0 = Release|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|Any CPU.Build.0 = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x64.ActiveCfg = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x64.Build.0 = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x86.ActiveCfg = Debug|Any CPU - {D132DC37-ADF5-4210-A3C6-7480546CED7F}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -226,8 +186,6 @@ Global {074D8726-9CC3-43B5-9D28-1AD33A6100F7} = {A8D21009-1410-4367-8616-2075882003FF} {658B1534-3B9E-4108-9AFE-161562723E9D} = {A8D21009-1410-4367-8616-2075882003FF} {B890249B-B590-4323-B1F6-0C1AB8E02D68} = {A8D21009-1410-4367-8616-2075882003FF} - {0B4B6C46-B848-43D3-B230-0A526ABAD1F5} = {A8D21009-1410-4367-8616-2075882003FF} - {D132DC37-ADF5-4210-A3C6-7480546CED7F} = {A8D21009-1410-4367-8616-2075882003FF} {9963A1DA-8EBD-47EF-8BF2-7B6444BE6FCE} = {7BB3C727-EA87-416E-84DD-34ADD5540067} {7DC8F0E9-5D6C-47F7-AE83-9AB1180AF51E} = {7BB3C727-EA87-416E-84DD-34ADD5540067} {D14DC8D4-F45E-412D-AE98-CA07F900347B} = {7BB3C727-EA87-416E-84DD-34ADD5540067} diff --git a/src/libraries/System.Management/NuGet.config b/src/libraries/System.Management/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Management/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Memory.Data/System.Memory.Data.sln b/src/libraries/System.Memory.Data/System.Memory.Data.sln index 1d656b10ba26a..7a63841312467 100644 --- a/src/libraries/System.Memory.Data/System.Memory.Data.sln +++ b/src/libraries/System.Memory.Data/System.Memory.Data.sln @@ -19,10 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{9EB09AA4-4338-4242-9135-1E9BA3140B4A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{4EC32671-F20B-4012-8212-4146F89EB470}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{1D93DCD8-BF67-4FB5-A25A-7837F230B173}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{6A2B5C68-14C3-4989-8530-D51A138C72AE}" @@ -79,14 +75,6 @@ Global {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}.Debug|Any CPU.Build.0 = Debug|Any CPU {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}.Release|Any CPU.ActiveCfg = Release|Any CPU {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C}.Release|Any CPU.Build.0 = Release|Any CPU - {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9EB09AA4-4338-4242-9135-1E9BA3140B4A}.Release|Any CPU.Build.0 = Release|Any CPU - {4EC32671-F20B-4012-8212-4146F89EB470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4EC32671-F20B-4012-8212-4146F89EB470}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4EC32671-F20B-4012-8212-4146F89EB470}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4EC32671-F20B-4012-8212-4146F89EB470}.Release|Any CPU.Build.0 = Release|Any CPU {1D93DCD8-BF67-4FB5-A25A-7837F230B173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D93DCD8-BF67-4FB5-A25A-7837F230B173}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D93DCD8-BF67-4FB5-A25A-7837F230B173}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -111,8 +99,6 @@ Global {ACDB56AF-7B9F-4762-9764-D6FF09118D09} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} {E17B915A-81CA-44D8-818E-512B65609475} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} {0DE5E7DA-0AE0-4CF2-95AB-1E476FD68C5C} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} - {9EB09AA4-4338-4242-9135-1E9BA3140B4A} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} - {4EC32671-F20B-4012-8212-4146F89EB470} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} {6A2B5C68-14C3-4989-8530-D51A138C72AE} = {D908DCBE-EFA4-4CCA-9A1C-AEB48D59C504} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Memory/System.Memory.sln b/src/libraries/System.Memory/System.Memory.sln index b78cd06b73466..c59ab842d2d4e 100644 --- a/src/libraries/System.Memory/System.Memory.sln +++ b/src/libraries/System.Memory/System.Memory.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{4E9C4BA9-5FE2-4774-AC6F-A42913D57314}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{DE49AC8E-5D29-4093-B761-811AE382204A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{371ACE6F-1F94-4B14-80DE-4060249E31D3}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C352AC7D-959D-431F-AF83-2CA506B70D59}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FA259C32-B79B-4DE2-9677-055D5D25FA33}" @@ -162,42 +158,6 @@ Global {4E9C4BA9-5FE2-4774-AC6F-A42913D57314}.Checked|x64.Build.0 = Debug|Any CPU {4E9C4BA9-5FE2-4774-AC6F-A42913D57314}.Checked|x86.ActiveCfg = Debug|Any CPU {4E9C4BA9-5FE2-4774-AC6F-A42913D57314}.Checked|x86.Build.0 = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x64.ActiveCfg = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x64.Build.0 = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x86.ActiveCfg = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Debug|x86.Build.0 = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|Any CPU.Build.0 = Release|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x64.ActiveCfg = Release|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x64.Build.0 = Release|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x86.ActiveCfg = Release|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Release|x86.Build.0 = Release|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|Any CPU.Build.0 = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x64.ActiveCfg = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x64.Build.0 = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x86.ActiveCfg = Debug|Any CPU - {DE49AC8E-5D29-4093-B761-811AE382204A}.Checked|x86.Build.0 = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x64.ActiveCfg = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x64.Build.0 = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x86.ActiveCfg = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Debug|x86.Build.0 = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|Any CPU.Build.0 = Release|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x64.ActiveCfg = Release|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x64.Build.0 = Release|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x86.ActiveCfg = Release|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Release|x86.Build.0 = Release|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|Any CPU.Build.0 = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x64.ActiveCfg = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x64.Build.0 = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x86.ActiveCfg = Debug|Any CPU - {371ACE6F-1F94-4B14-80DE-4060249E31D3}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {7746BFD6-E6D6-4703-AA2D-43380B5DEA22} = {C352AC7D-959D-431F-AF83-2CA506B70D59} {C9417154-D8DB-4FF9-9DD8-6B2ED351FC92} = {C352AC7D-959D-431F-AF83-2CA506B70D59} {4E9C4BA9-5FE2-4774-AC6F-A42913D57314} = {C352AC7D-959D-431F-AF83-2CA506B70D59} - {DE49AC8E-5D29-4093-B761-811AE382204A} = {C352AC7D-959D-431F-AF83-2CA506B70D59} - {371ACE6F-1F94-4B14-80DE-4060249E31D3} = {C352AC7D-959D-431F-AF83-2CA506B70D59} {6A54FACA-933E-4C1D-92AB-1A5506CFC212} = {FA259C32-B79B-4DE2-9677-055D5D25FA33} {C2BC6AE7-7E8B-4AA2-8E9F-5D4B9127B297} = {FA259C32-B79B-4DE2-9677-055D5D25FA33} {9112BAE3-344D-4DD0-ADC9-478D82B84584} = {7212FBCF-E89D-4065-9DCE-D5F7E5D3EF1D} diff --git a/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln b/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln index e5379c37a82af..2313d1c589f82 100644 --- a/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln +++ b/src/libraries/System.Net.Http.Json/System.Net.Http.Json.sln @@ -25,10 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{8233C54C-797C-4CC0-B40E-68C1E82E509B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{EA992513-9CA4-4DEB-B0EE-A8FD0252B451}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{BC7D3412-DBCB-4863-8BF8-41899E32608C}" @@ -97,14 +93,6 @@ Global {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}.Debug|Any CPU.Build.0 = Debug|Any CPU {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}.Release|Any CPU.ActiveCfg = Release|Any CPU {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A}.Release|Any CPU.Build.0 = Release|Any CPU - {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8233C54C-797C-4CC0-B40E-68C1E82E509B}.Release|Any CPU.Build.0 = Release|Any CPU - {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1}.Release|Any CPU.Build.0 = Release|Any CPU {EA992513-9CA4-4DEB-B0EE-A8FD0252B451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EA992513-9CA4-4DEB-B0EE-A8FD0252B451}.Debug|Any CPU.Build.0 = Debug|Any CPU {EA992513-9CA4-4DEB-B0EE-A8FD0252B451}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -132,8 +120,6 @@ Global {7DC969DA-8BD3-4E64-88E8-26AFE65BFF7E} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} {3EEB6FCC-2592-4879-ADDD-0FDC7AEB7BC1} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} {FEBE9C47-A00B-40B2-A85B-74ECE2F8B80A} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} - {8233C54C-797C-4CC0-B40E-68C1E82E509B} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} - {3CE4DFEE-BFFE-4B0C-B2D1-CE2CE08BFFB1} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} {BC7D3412-DBCB-4863-8BF8-41899E32608C} = {2A66925D-3658-46BE-A730-5BF70D8D5B90} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln b/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln index ba3c9a80265d6..ad70edab4d906 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln +++ b/src/libraries/System.Net.Http.WinHttpHandler/System.Net.Http.WinHttpHandler.sln @@ -33,10 +33,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{BACC5257-6CA8-45C7-970F-C8D501DA59AB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{77BCC140-E934-4A59-824A-0DE89D0955AF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "..\System.Text.Json\gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{A6CF790E-772E-4265-A961-D47CA51F5757}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\ref\System.Text.Json.csproj", "{8ABBBDC5-48A1-43BA-A629-AE58C35318AA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "..\System.Text.Json\src\System.Text.Json.csproj", "{E470810A-BAF2-4B3C-92CB-72007B7F1B6A}" @@ -121,14 +117,6 @@ Global {BACC5257-6CA8-45C7-970F-C8D501DA59AB}.Debug|Any CPU.Build.0 = Debug|Any CPU {BACC5257-6CA8-45C7-970F-C8D501DA59AB}.Release|Any CPU.ActiveCfg = Release|Any CPU {BACC5257-6CA8-45C7-970F-C8D501DA59AB}.Release|Any CPU.Build.0 = Release|Any CPU - {77BCC140-E934-4A59-824A-0DE89D0955AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {77BCC140-E934-4A59-824A-0DE89D0955AF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {77BCC140-E934-4A59-824A-0DE89D0955AF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {77BCC140-E934-4A59-824A-0DE89D0955AF}.Release|Any CPU.Build.0 = Release|Any CPU - {A6CF790E-772E-4265-A961-D47CA51F5757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A6CF790E-772E-4265-A961-D47CA51F5757}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6CF790E-772E-4265-A961-D47CA51F5757}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A6CF790E-772E-4265-A961-D47CA51F5757}.Release|Any CPU.Build.0 = Release|Any CPU {8ABBBDC5-48A1-43BA-A629-AE58C35318AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8ABBBDC5-48A1-43BA-A629-AE58C35318AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {8ABBBDC5-48A1-43BA-A629-AE58C35318AA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -160,8 +148,6 @@ Global {DE2A69CC-4962-4BF6-A714-41A87A6C045B} = {49E09973-383D-4AD6-9D88-B93A02031607} {28C24BF8-8E08-485F-8EEE-817EB847774C} = {49E09973-383D-4AD6-9D88-B93A02031607} {BACC5257-6CA8-45C7-970F-C8D501DA59AB} = {49E09973-383D-4AD6-9D88-B93A02031607} - {77BCC140-E934-4A59-824A-0DE89D0955AF} = {49E09973-383D-4AD6-9D88-B93A02031607} - {A6CF790E-772E-4265-A961-D47CA51F5757} = {49E09973-383D-4AD6-9D88-B93A02031607} {E470810A-BAF2-4B3C-92CB-72007B7F1B6A} = {49E09973-383D-4AD6-9D88-B93A02031607} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Http/NuGet.config b/src/libraries/System.Net.Http/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Net.Http/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Net.Http/System.Net.Http.sln b/src/libraries/System.Net.Http/System.Net.Http.sln index d83b980a894db..cb07432f85403 100644 --- a/src/libraries/System.Net.Http/System.Net.Http.sln +++ b/src/libraries/System.Net.Http/System.Net.Http.sln @@ -33,10 +33,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{ACDD8D8E-6945-41BC-87BD-1BD225653521}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3CD76528-2D01-42EF-BE32-888E4E9AFEFA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B99145D1-7A6A-4E72-905B-43D72C15C9A9}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{32FE3BA2-6FC8-4537-BD04-47236BAFE9F0}" @@ -121,14 +117,6 @@ Global {ACDD8D8E-6945-41BC-87BD-1BD225653521}.Debug|Any CPU.Build.0 = Debug|Any CPU {ACDD8D8E-6945-41BC-87BD-1BD225653521}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACDD8D8E-6945-41BC-87BD-1BD225653521}.Release|Any CPU.Build.0 = Release|Any CPU - {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3CD76528-2D01-42EF-BE32-888E4E9AFEFA}.Release|Any CPU.Build.0 = Release|Any CPU - {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B99145D1-7A6A-4E72-905B-43D72C15C9A9}.Release|Any CPU.Build.0 = Release|Any CPU {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}.Debug|Any CPU.Build.0 = Debug|Any CPU {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -159,8 +147,6 @@ Global {F1FFB6F5-628E-4DF5-8FD0-9ADFB9EF5E91} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {819DB839-291D-4128-A2D8-719340A7DEBF} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {ACDD8D8E-6945-41BC-87BD-1BD225653521} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} - {3CD76528-2D01-42EF-BE32-888E4E9AFEFA} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} - {B99145D1-7A6A-4E72-905B-43D72C15C9A9} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {A33FBFF8-9EF6-4FF9-BD24-B73827DBA9E5} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} {32FE3BA2-6FC8-4537-BD04-47236BAFE9F0} = {145B4B2E-5EF8-46F2-A596-E1043BB22873} EndGlobalSection diff --git a/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln b/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln index b1db0d209d086..0258c96120588 100644 --- a/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln +++ b/src/libraries/System.Net.HttpListener/System.Net.HttpListener.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D878C9A2-651A-4D46-BF8A-E4394F3F3967}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{8D838854-1462-48E8-9C06-E80F48364216}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{75DAAF3A-23E3-4C9C-A701-BA5494346925}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AE12BA12-7BDB-4361-922F-AAA100384926}" @@ -53,14 +49,6 @@ Global {D878C9A2-651A-4D46-BF8A-E4394F3F3967}.Debug|Any CPU.Build.0 = Debug|Any CPU {D878C9A2-651A-4D46-BF8A-E4394F3F3967}.Release|Any CPU.ActiveCfg = Release|Any CPU {D878C9A2-651A-4D46-BF8A-E4394F3F3967}.Release|Any CPU.Build.0 = Release|Any CPU - {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB}.Release|Any CPU.Build.0 = Release|Any CPU - {8D838854-1462-48E8-9C06-E80F48364216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8D838854-1462-48E8-9C06-E80F48364216}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8D838854-1462-48E8-9C06-E80F48364216}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8D838854-1462-48E8-9C06-E80F48364216}.Release|Any CPU.Build.0 = Release|Any CPU {75DAAF3A-23E3-4C9C-A701-BA5494346925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75DAAF3A-23E3-4C9C-A701-BA5494346925}.Debug|Any CPU.Build.0 = Debug|Any CPU {75DAAF3A-23E3-4C9C-A701-BA5494346925}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -76,8 +64,6 @@ Global {D48FCA59-B78B-4E81-8DB5-1B0B6596F71B} = {A3A29B10-F45E-487B-A2A0-EA809B62AF9D} {706D27A6-E66A-4FF5-9E6A-EA1B8BC52FB2} = {633A5486-7617-411C-B724-172F4B4E3A4F} {D878C9A2-651A-4D46-BF8A-E4394F3F3967} = {633A5486-7617-411C-B724-172F4B4E3A4F} - {9C92E9EC-05B9-4FAA-A19C-84A04F2592FB} = {633A5486-7617-411C-B724-172F4B4E3A4F} - {8D838854-1462-48E8-9C06-E80F48364216} = {633A5486-7617-411C-B724-172F4B4E3A4F} {75DAAF3A-23E3-4C9C-A701-BA5494346925} = {633A5486-7617-411C-B724-172F4B4E3A4F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Mail/System.Net.Mail.sln b/src/libraries/System.Net.Mail/System.Net.Mail.sln index 9e9414252155a..f8f24fa8580ce 100644 --- a/src/libraries/System.Net.Mail/System.Net.Mail.sln +++ b/src/libraries/System.Net.Mail/System.Net.Mail.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{02A90ADA-F294-4036-90BE-5040393BA37C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DFA479C6-DDF9-4AE0-91BB-08041FF1B7C8}" @@ -59,14 +55,6 @@ Global {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892}.Release|Any CPU.Build.0 = Release|Any CPU - {02A90ADA-F294-4036-90BE-5040393BA37C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {02A90ADA-F294-4036-90BE-5040393BA37C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02A90ADA-F294-4036-90BE-5040393BA37C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {02A90ADA-F294-4036-90BE-5040393BA37C}.Release|Any CPU.Build.0 = Release|Any CPU - {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6}.Release|Any CPU.Build.0 = Release|Any CPU {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -83,8 +71,6 @@ Global {1BB79710-16BD-4ED4-8BF4-13D25CBF4208} = {A08D08E8-610F-47A0-8747-01223F9430C5} {AF805BBD-C4A4-4D69-A911-D651E008C655} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} {B0E01BDD-5CF1-482F-B0BC-BA6EE8E6D892} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} - {02A90ADA-F294-4036-90BE-5040393BA37C} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} - {9FF1E686-C7FA-421D-8A0C-E24E67D3ECC6} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} {8AE1AF68-EBDC-497B-A189-5B4C66FA57D8} = {04FF7F43-59FD-4A9A-AFE4-12D16836981C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln b/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln index 206e3e1095abf..72d2dd5a7d6fe 100644 --- a/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln +++ b/src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D62E59F2-BDF3-4060-85E0-20D1BB41B95E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3DDC9528-201B-465C-BE02-734582A5CACB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2262F921-FDFD-420C-9E2E-BC4A7985BF9D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{FB254BF6-9C7C-4A35-A8B1-FB8832382442}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6E7B2B93-21B0-457F-84C3-AE62DABC73E2}" @@ -59,14 +55,6 @@ Global {D62E59F2-BDF3-4060-85E0-20D1BB41B95E}.Debug|Any CPU.Build.0 = Debug|Any CPU {D62E59F2-BDF3-4060-85E0-20D1BB41B95E}.Release|Any CPU.ActiveCfg = Release|Any CPU {D62E59F2-BDF3-4060-85E0-20D1BB41B95E}.Release|Any CPU.Build.0 = Release|Any CPU - {3DDC9528-201B-465C-BE02-734582A5CACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3DDC9528-201B-465C-BE02-734582A5CACB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3DDC9528-201B-465C-BE02-734582A5CACB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3DDC9528-201B-465C-BE02-734582A5CACB}.Release|Any CPU.Build.0 = Release|Any CPU - {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2262F921-FDFD-420C-9E2E-BC4A7985BF9D}.Release|Any CPU.Build.0 = Release|Any CPU {FB254BF6-9C7C-4A35-A8B1-FB8832382442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FB254BF6-9C7C-4A35-A8B1-FB8832382442}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB254BF6-9C7C-4A35-A8B1-FB8832382442}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -83,8 +71,6 @@ Global {A3FC70CE-3746-4E03-A92F-0102716FA97E} = {47DBE178-9476-4595-9C71-424D54314C2E} {CC5371F7-FCD9-4BDE-8639-6DD5F3B71175} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} {D62E59F2-BDF3-4060-85E0-20D1BB41B95E} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} - {3DDC9528-201B-465C-BE02-734582A5CACB} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} - {2262F921-FDFD-420C-9E2E-BC4A7985BF9D} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} {FB254BF6-9C7C-4A35-A8B1-FB8832382442} = {3DDE175F-17B6-4F30-8AA6-04C0AEBF39D5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln b/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln index 9bf2f46685f8f..20bda98c1c8a5 100644 --- a/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln +++ b/src/libraries/System.Net.NetworkInformation/System.Net.NetworkInformation.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{1EBC1861-0CC0-45A6-9685-AF863383D81F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{347B7406-0C18-4716-BD38-BA01F73E203F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{33058B90-33C6-4731-AF47-DC7678DC2739}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{01C6C981-C56F-453F-B099-C8B9DF61CDEB}" @@ -51,14 +47,6 @@ Global {1EBC1861-0CC0-45A6-9685-AF863383D81F}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EBC1861-0CC0-45A6-9685-AF863383D81F}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EBC1861-0CC0-45A6-9685-AF863383D81F}.Release|Any CPU.Build.0 = Release|Any CPU - {347B7406-0C18-4716-BD38-BA01F73E203F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {347B7406-0C18-4716-BD38-BA01F73E203F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {347B7406-0C18-4716-BD38-BA01F73E203F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {347B7406-0C18-4716-BD38-BA01F73E203F}.Release|Any CPU.Build.0 = Release|Any CPU - {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -70,8 +58,6 @@ Global {23FF09C1-F2BF-4834-96CE-59BE5AA7F46A} = {01C6C981-C56F-453F-B099-C8B9DF61CDEB} {062F1189-143C-456B-A439-D9C1BE2DD640} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} {1EBC1861-0CC0-45A6-9685-AF863383D81F} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} - {347B7406-0C18-4716-BD38-BA01F73E203F} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} - {6D2FE1D6-3D82-498F-ABD9-4FE14B4A5F2E} = {A3CAA996-BF7C-48EE-A03A-2B2F78D88D86} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6749EC2E-042F-4132-9B0A-82ED7F56513C} diff --git a/src/libraries/System.Net.Ping/System.Net.Ping.sln b/src/libraries/System.Net.Ping/System.Net.Ping.sln index 2c7c872b46966..ca637e285cb2e 100644 --- a/src/libraries/System.Net.Ping/System.Net.Ping.sln +++ b/src/libraries/System.Net.Ping/System.Net.Ping.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{FDD8759A-E9E4-4899-BBE0-298C403BF02B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FABDD2DA-5365-4FD2-8C67-4C643E618CE9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73}" @@ -51,14 +47,6 @@ Global {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4}.Release|Any CPU.Build.0 = Release|Any CPU - {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FDD8759A-E9E4-4899-BBE0-298C403BF02B}.Release|Any CPU.Build.0 = Release|Any CPU - {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -70,8 +58,6 @@ Global {948D0208-37D1-48B7-91AE-138D9A2C7751} = {AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73} {65B08958-069E-4F8B-A996-2A987ACCAA49} = {A687595D-ACCE-4380-95B8-628F598C7229} {D5C17482-80DE-4E7F-A4BB-E6D80CD5B2F4} = {A687595D-ACCE-4380-95B8-628F598C7229} - {FDD8759A-E9E4-4899-BBE0-298C403BF02B} = {A687595D-ACCE-4380-95B8-628F598C7229} - {10C37A62-4DDB-4E4B-8F11-0F1C439DEA4B} = {A687595D-ACCE-4380-95B8-628F598C7229} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {23612E2C-7AC3-4D7B-812D-44BB88E94278} diff --git a/src/libraries/System.Net.Primitives/System.Net.Primitives.sln b/src/libraries/System.Net.Primitives/System.Net.Primitives.sln index f69f00cc575cb..9e860bc8844f6 100644 --- a/src/libraries/System.Net.Primitives/System.Net.Primitives.sln +++ b/src/libraries/System.Net.Primitives/System.Net.Primitives.sln @@ -15,10 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{909A147A-476E-4E34-A931-C2C65FD656A6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{212A5562-EFE7-4220-94EC-6B49C0A6DCEF}" @@ -63,14 +59,6 @@ Global {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0}.Release|Any CPU.Build.0 = Release|Any CPU - {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC}.Release|Any CPU.Build.0 = Release|Any CPU - {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,8 +72,6 @@ Global {F1989258-F5D7-4056-9831-518BD04F5863} = {212A5562-EFE7-4220-94EC-6B49C0A6DCEF} {08C53516-56AB-4D3B-B22F-7DC1B27EA7CE} = {97419593-C13A-4407-B489-1651C8D3E813} {8D5C59E4-66E7-4DC5-B1D5-711D5D3265C0} = {97419593-C13A-4407-B489-1651C8D3E813} - {CA5B9D3B-8ADC-4C7D-BBB2-EEF1FFC52ECC} = {97419593-C13A-4407-B489-1651C8D3E813} - {D7D40ED0-0347-46C8-8BAC-3EB65A99F1C4} = {97419593-C13A-4407-B489-1651C8D3E813} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E0D36CFB-AD15-487D-A647-F12B577FC5DF} diff --git a/src/libraries/System.Net.Quic/System.Net.Quic.sln b/src/libraries/System.Net.Quic/System.Net.Quic.sln index ad5a7b2e2e8ec..d8dec0958a499 100644 --- a/src/libraries/System.Net.Quic/System.Net.Quic.sln +++ b/src/libraries/System.Net.Quic/System.Net.Quic.sln @@ -17,10 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{946D2E52-84D0-462E-9412-2471CB64AD88}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{12C4206E-D19B-44BF-8002-6236D65AAE1B}" @@ -71,14 +67,6 @@ Global {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0}.Release|Any CPU.Build.0 = Release|Any CPU - {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0}.Release|Any CPU.Build.0 = Release|Any CPU - {946D2E52-84D0-462E-9412-2471CB64AD88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {946D2E52-84D0-462E-9412-2471CB64AD88}.Debug|Any CPU.Build.0 = Debug|Any CPU - {946D2E52-84D0-462E-9412-2471CB64AD88}.Release|Any CPU.ActiveCfg = Release|Any CPU - {946D2E52-84D0-462E-9412-2471CB64AD88}.Release|Any CPU.Build.0 = Release|Any CPU {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}.Debug|Any CPU.Build.0 = Debug|Any CPU {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -97,8 +85,6 @@ Global {BF401CDC-5AED-4F3E-8C3F-96D8DFA7E241} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} {4F87758B-D1AF-4DE3-A9A2-68B1558C02B7} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} {9D56BA9E-1B0D-4320-9FE9-A2D326A32BE0} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} - {BD16F2C6-EFC5-4FD9-BB3D-583FD548ACC0} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} - {946D2E52-84D0-462E-9412-2471CB64AD88} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} {23C03FB6-C11D-4F42-AD6C-66CAE2A8175A} = {8EF7F530-1F45-48CE-AA30-30FFD83147B9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Net.Security/System.Net.Security.sln b/src/libraries/System.Net.Security/System.Net.Security.sln index 994b8f2762e81..de6376a734952 100644 --- a/src/libraries/System.Net.Security/System.Net.Security.sln +++ b/src/libraries/System.Net.Security/System.Net.Security.sln @@ -21,10 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{754403CE-ECFC-4EBA-8540-BEB67476FF9F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{72F7B38A-0352-4505-8212-E636A5508C7F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{E0D760D1-21BC-468F-B599-858ECFF4AB1D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal.Windows", "..\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj", "{80F5CE39-D33D-4CDD-ACD2-FA7597B6CBB1}" @@ -85,14 +81,6 @@ Global {754403CE-ECFC-4EBA-8540-BEB67476FF9F}.Debug|Any CPU.Build.0 = Debug|Any CPU {754403CE-ECFC-4EBA-8540-BEB67476FF9F}.Release|Any CPU.ActiveCfg = Release|Any CPU {754403CE-ECFC-4EBA-8540-BEB67476FF9F}.Release|Any CPU.Build.0 = Release|Any CPU - {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6}.Release|Any CPU.Build.0 = Release|Any CPU - {72F7B38A-0352-4505-8212-E636A5508C7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72F7B38A-0352-4505-8212-E636A5508C7F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72F7B38A-0352-4505-8212-E636A5508C7F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72F7B38A-0352-4505-8212-E636A5508C7F}.Release|Any CPU.Build.0 = Release|Any CPU {E0D760D1-21BC-468F-B599-858ECFF4AB1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E0D760D1-21BC-468F-B599-858ECFF4AB1D}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0D760D1-21BC-468F-B599-858ECFF4AB1D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -117,8 +105,6 @@ Global {441D4079-55B4-4C47-A0E5-1330DC9A31CB} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {20F20695-DB18-47EB-A005-AA432ADCF865} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {754403CE-ECFC-4EBA-8540-BEB67476FF9F} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} - {2FF60EDD-B199-4A34-913C-C05C0AEFB7C6} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} - {72F7B38A-0352-4505-8212-E636A5508C7F} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {E0D760D1-21BC-468F-B599-858ECFF4AB1D} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} {80F5CE39-D33D-4CDD-ACD2-FA7597B6CBB1} = {70E29C1C-AC9B-4E71-AB74-9906EF973EBF} EndGlobalSection diff --git a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln index 8137b954d2b7b..e8a3b47b53f6b 100644 --- a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln +++ b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{3234071E-7F94-4471-8D29-F376DACD8130}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{625DDEA0-FA43-4DC4-92B4-7692237FF18B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{D93419A9-52EA-4276-80D7-11B59C84E9FD}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FAD51322-998C-42D4-8FAA-EA479A3A0E82}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}" @@ -57,14 +53,6 @@ Global {3234071E-7F94-4471-8D29-F376DACD8130}.Debug|Any CPU.Build.0 = Debug|Any CPU {3234071E-7F94-4471-8D29-F376DACD8130}.Release|Any CPU.ActiveCfg = Release|Any CPU {3234071E-7F94-4471-8D29-F376DACD8130}.Release|Any CPU.Build.0 = Release|Any CPU - {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {625DDEA0-FA43-4DC4-92B4-7692237FF18B}.Release|Any CPU.Build.0 = Release|Any CPU - {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D93419A9-52EA-4276-80D7-11B59C84E9FD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,8 +65,6 @@ Global {C746C235-7771-46F2-80B3-A67E0C62E436} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FD313302-FE04-414E-8A62-3BC8894115C1} = {2C7108F0-035E-44A5-8451-FE9535F53D43} {3234071E-7F94-4471-8D29-F376DACD8130} = {2C7108F0-035E-44A5-8451-FE9535F53D43} - {625DDEA0-FA43-4DC4-92B4-7692237FF18B} = {2C7108F0-035E-44A5-8451-FE9535F53D43} - {D93419A9-52EA-4276-80D7-11B59C84E9FD} = {2C7108F0-035E-44A5-8451-FE9535F53D43} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BA222465-FBD4-4377-8A8A-783BF85E01F7} diff --git a/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln b/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln index a1bc19d2f87f0..059b20e11e31e 100644 --- a/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln +++ b/src/libraries/System.Net.WebSockets.Client/System.Net.WebSockets.Client.sln @@ -15,10 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{59A23CAB-D098-495F-A467-74C7553FF5BB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{F8329953-B5A4-46B4-9B2E-511DBD251F1C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2BB8BE7E-4084-42EB-A676-A86A1543C999}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BEE2F256-0489-4809-AB20-27ADB2D0E10C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A0314AC5-E490-4A6A-B946-8B9A21A2FA05}" @@ -63,14 +59,6 @@ Global {59A23CAB-D098-495F-A467-74C7553FF5BB}.Debug|Any CPU.Build.0 = Debug|Any CPU {59A23CAB-D098-495F-A467-74C7553FF5BB}.Release|Any CPU.ActiveCfg = Release|Any CPU {59A23CAB-D098-495F-A467-74C7553FF5BB}.Release|Any CPU.Build.0 = Release|Any CPU - {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8329953-B5A4-46B4-9B2E-511DBD251F1C}.Release|Any CPU.Build.0 = Release|Any CPU - {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2BB8BE7E-4084-42EB-A676-A86A1543C999}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,8 +72,6 @@ Global {0CD4C24D-7746-46F0-8D47-A396882B5468} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} {8CD4D190-F656-4970-9AE9-4A9F8B30A2F8} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} {59A23CAB-D098-495F-A467-74C7553FF5BB} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} - {F8329953-B5A4-46B4-9B2E-511DBD251F1C} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} - {2BB8BE7E-4084-42EB-A676-A86A1543C999} = {6F9A42A0-A04B-4CD0-B8C9-9A728274C851} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D91D7DC5-24CC-4716-A357-8170C4EB1C32} diff --git a/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln b/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln index d23ab31c15d19..2c97ffb0057df 100644 --- a/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln +++ b/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{5484692D-7093-4D79-8C77-D6A0A4ABE8E8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FC10C682-DF71-4EEA-A3A5-E716C1C88AC0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2C4425BA-8478-4BCB-B616-E6FC28ADEAB9}" @@ -162,42 +158,6 @@ Global {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}.Checked|x64.Build.0 = Debug|Any CPU {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}.Checked|x86.ActiveCfg = Debug|Any CPU {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598}.Checked|x86.Build.0 = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x64.ActiveCfg = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x64.Build.0 = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x86.ActiveCfg = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Debug|x86.Build.0 = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|Any CPU.Build.0 = Release|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x64.ActiveCfg = Release|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x64.Build.0 = Release|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x86.ActiveCfg = Release|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Release|x86.Build.0 = Release|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|Any CPU.Build.0 = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x64.ActiveCfg = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x64.Build.0 = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x86.ActiveCfg = Debug|Any CPU - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8}.Checked|x86.Build.0 = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x64.ActiveCfg = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x64.Build.0 = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x86.ActiveCfg = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Debug|x86.Build.0 = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|Any CPU.Build.0 = Release|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x64.ActiveCfg = Release|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x64.Build.0 = Release|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x86.ActiveCfg = Release|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Release|x86.Build.0 = Release|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|Any CPU.Build.0 = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x64.ActiveCfg = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x64.Build.0 = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x86.ActiveCfg = Debug|Any CPU - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {634A3B2B-09F5-4810-B630-ADE4D36C47DF} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} {ED450846-85A0-4CED-B4D9-9EB769CF794B} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} {7FAD5E59-D362-4ED6-B3D5-FAD9CD5A2598} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} - {5484692D-7093-4D79-8C77-D6A0A4ABE8E8} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} - {96E9F7E1-81BC-420D-BE3B-CABD79E5E3DE} = {FC10C682-DF71-4EEA-A3A5-E716C1C88AC0} {9EDBE037-EFE0-4B72-B602-E4C3F0C05F2F} = {2C4425BA-8478-4BCB-B616-E6FC28ADEAB9} {B38797B1-BB45-4B30-9D4F-79D9F4B3735B} = {2C4425BA-8478-4BCB-B616-E6FC28ADEAB9} {5B2027FA-F43A-4E80-880F-B3A7A2720AA7} = {ED90FF1C-59D4-4AB0-860E-2872ECA1BFEC} diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln index c7031ea2ff16a..d628570614a5a 100644 --- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln +++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/System.Private.Runtime.InteropServices.JavaScript.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{F1642F23-C510-423E-8598-4B3A09DA28DB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7E578260-A505-47DF-A00D-13072A4A4023}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0866D4B1-55B3-44F7-8683-61FF19EC2CFD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F323228E-200C-4069-98A1-E2400F3061B3}" @@ -45,14 +41,6 @@ Global {F1642F23-C510-423E-8598-4B3A09DA28DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {F1642F23-C510-423E-8598-4B3A09DA28DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {F1642F23-C510-423E-8598-4B3A09DA28DB}.Release|Any CPU.Build.0 = Release|Any CPU - {7E578260-A505-47DF-A00D-13072A4A4023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7E578260-A505-47DF-A00D-13072A4A4023}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7E578260-A505-47DF-A00D-13072A4A4023}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7E578260-A505-47DF-A00D-13072A4A4023}.Release|Any CPU.Build.0 = Release|Any CPU - {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Debug|Any CPU.Build.0 = Debug|Any CPU - {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Release|Any CPU.ActiveCfg = Release|Any CPU - {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -62,8 +50,6 @@ Global {4A88DCA2-2A9F-4497-AE84-C15B81F21782} = {0866D4B1-55B3-44F7-8683-61FF19EC2CFD} {1EF4B421-0137-4C27-A6D2-DFC2B09E52F0} = {F323228E-200C-4069-98A1-E2400F3061B3} {F1642F23-C510-423E-8598-4B3A09DA28DB} = {F323228E-200C-4069-98A1-E2400F3061B3} - {7E578260-A505-47DF-A00D-13072A4A4023} = {F323228E-200C-4069-98A1-E2400F3061B3} - {47BB9FA9-5E9B-42E4-BBC2-7EBF14567220} = {F323228E-200C-4069-98A1-E2400F3061B3} {9B76030A-9DBD-401E-90B7-18111831B0D9} = {B7387D02-A1E8-4ED1-833D-65D6112F00A0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Private.Uri/System.Private.Uri.sln b/src/libraries/System.Private.Uri/System.Private.Uri.sln index d7801e8c0faf3..353c268082eac 100644 --- a/src/libraries/System.Private.Uri/System.Private.Uri.sln +++ b/src/libraries/System.Private.Uri/System.Private.Uri.sln @@ -15,10 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{01EDF06D-BBBB-42D7-9414-A332292235D3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{4F09BFD3-86CF-4B70-98C7-757C1EB38548}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A30957A2-C729-49F1-8C75-C42D5BCB8309}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05}" @@ -182,42 +178,6 @@ Global {01EDF06D-BBBB-42D7-9414-A332292235D3}.Checked|x64.Build.0 = Debug|Any CPU {01EDF06D-BBBB-42D7-9414-A332292235D3}.Checked|x86.ActiveCfg = Debug|Any CPU {01EDF06D-BBBB-42D7-9414-A332292235D3}.Checked|x86.Build.0 = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x64.ActiveCfg = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x64.Build.0 = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x86.ActiveCfg = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Debug|x86.Build.0 = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|Any CPU.Build.0 = Release|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x64.ActiveCfg = Release|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x64.Build.0 = Release|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x86.ActiveCfg = Release|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Release|x86.Build.0 = Release|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|Any CPU.Build.0 = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x64.ActiveCfg = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x64.Build.0 = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x86.ActiveCfg = Debug|Any CPU - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2}.Checked|x86.Build.0 = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x64.ActiveCfg = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x64.Build.0 = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x86.ActiveCfg = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Debug|x86.Build.0 = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|Any CPU.Build.0 = Release|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x64.ActiveCfg = Release|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x64.Build.0 = Release|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x86.ActiveCfg = Release|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Release|x86.Build.0 = Release|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|Any CPU.Build.0 = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x64.ActiveCfg = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x64.Build.0 = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x86.ActiveCfg = Debug|Any CPU - {4F09BFD3-86CF-4B70-98C7-757C1EB38548}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -226,8 +186,6 @@ Global {C150B694-015F-48BD-8CB0-EFF1F7A84DCE} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} {98AC821B-892E-4F58-AF3D-503747FD6A8F} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} {01EDF06D-BBBB-42D7-9414-A332292235D3} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} - {B23708F3-8AC6-47B9-9435-EFEF43CFEDC2} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} - {4F09BFD3-86CF-4B70-98C7-757C1EB38548} = {A30957A2-C729-49F1-8C75-C42D5BCB8309} {ADD88187-83E2-4EAF-BFB4-BC6249E76457} = {DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05} {37859855-7E5C-4772-B5D2-7029211EAB92} = {DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05} {BDD0866A-D856-40EE-A9D5-1DAC11095E42} = {DBF81CE3-B7A6-4A62-9C66-DDB2D87CBB05} diff --git a/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln b/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln index e555e361be756..559727cabe07c 100644 --- a/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln +++ b/src/libraries/System.Private.Xml.Linq/System.Private.Xml.Linq.sln @@ -41,10 +41,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{F442C967-0D66-4EFF-8875-1D165AA80621}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{29BE8713-DD3F-4CFB-92C0-3416E5501398}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4CB964C2-C69D-4A48-96A7-ACB28FBCB223}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1C4146F1-CF77-449B-865C-5E67ECF0362B}" @@ -141,14 +137,6 @@ Global {F442C967-0D66-4EFF-8875-1D165AA80621}.Debug|Any CPU.Build.0 = Debug|Any CPU {F442C967-0D66-4EFF-8875-1D165AA80621}.Release|Any CPU.ActiveCfg = Release|Any CPU {F442C967-0D66-4EFF-8875-1D165AA80621}.Release|Any CPU.Build.0 = Release|Any CPU - {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D}.Release|Any CPU.Build.0 = Release|Any CPU - {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29BE8713-DD3F-4CFB-92C0-3416E5501398}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -174,8 +162,6 @@ Global {61FD926A-2ED8-4CA5-8D75-854C8C9D9CCD} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} {A4F479E3-A0AD-4646-BD4B-F3CD2C29046B} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} {F442C967-0D66-4EFF-8875-1D165AA80621} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} - {D744EB1C-A19C-4224-B6A8-8E9BDB6D468D} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} - {29BE8713-DD3F-4CFB-92C0-3416E5501398} = {1C4146F1-CF77-449B-865C-5E67ECF0362B} {28B0CB77-2187-4CCD-8190-283FCA9800B1} = {D82CEFE7-0F7E-4A18-80FE-6562E12E1283} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Private.Xml/System.Private.Xml.sln b/src/libraries/System.Private.Xml/System.Private.Xml.sln index 9f99f4a1da006..84ce418242e77 100644 --- a/src/libraries/System.Private.Xml/System.Private.Xml.sln +++ b/src/libraries/System.Private.Xml/System.Private.Xml.sln @@ -71,10 +71,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7D12E1FB-2034-47B0-9244-E3C51015CD04}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{0218E41A-B48A-4B36-8DD5-37AE2DA35364}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E96EBB95-6AC7-4ECD-AD77-30F089F2C1F9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{41E18B29-2DB1-495A-8460-E7A257F8EA07}" @@ -231,14 +227,6 @@ Global {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7}.Release|Any CPU.Build.0 = Release|Any CPU - {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D12E1FB-2034-47B0-9244-E3C51015CD04}.Release|Any CPU.Build.0 = Release|Any CPU - {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0218E41A-B48A-4B36-8DD5-37AE2DA35364}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -279,8 +267,6 @@ Global {BBB6623D-BDF2-41B6-9165-A22A6C4D4159} = {E96EBB95-6AC7-4ECD-AD77-30F089F2C1F9} {B49AD269-3938-4F33-AEF8-029D3A94138F} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} {742BE9D1-C925-4B3D-8BCB-BF779B5B7AF7} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} - {7D12E1FB-2034-47B0-9244-E3C51015CD04} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} - {0218E41A-B48A-4B36-8DD5-37AE2DA35364} = {41E18B29-2DB1-495A-8460-E7A257F8EA07} {D85F5D9C-A068-4F04-B081-0A3E20CB5D49} = {148C103A-1CDD-4CBF-AC5F-5BADBC14B6DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln b/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln index a9c7a96c18ea5..55419e26ff29c 100644 --- a/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln +++ b/src/libraries/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2F96336D-6AB0-4463-9A9F-5ED91E737DEA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{72C88956-EE24-4089-A1B0-939879F83038}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B02EB99E-A733-443E-B8F7-5FF527C89BCA}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C723F596-B189-428C-A090-F4965F87A73D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{61C529DF-66C4-42E9-AE70-3427838FAFE3}" @@ -162,42 +158,6 @@ Global {2F96336D-6AB0-4463-9A9F-5ED91E737DEA}.Checked|x64.Build.0 = Debug|Any CPU {2F96336D-6AB0-4463-9A9F-5ED91E737DEA}.Checked|x86.ActiveCfg = Debug|Any CPU {2F96336D-6AB0-4463-9A9F-5ED91E737DEA}.Checked|x86.Build.0 = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x64.ActiveCfg = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x64.Build.0 = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x86.ActiveCfg = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Debug|x86.Build.0 = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Release|Any CPU.Build.0 = Release|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Release|x64.ActiveCfg = Release|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Release|x64.Build.0 = Release|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Release|x86.ActiveCfg = Release|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Release|x86.Build.0 = Release|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Checked|Any CPU.Build.0 = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x64.ActiveCfg = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x64.Build.0 = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x86.ActiveCfg = Debug|Any CPU - {72C88956-EE24-4089-A1B0-939879F83038}.Checked|x86.Build.0 = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x64.ActiveCfg = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x64.Build.0 = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x86.ActiveCfg = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Debug|x86.Build.0 = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|Any CPU.Build.0 = Release|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x64.ActiveCfg = Release|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x64.Build.0 = Release|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x86.ActiveCfg = Release|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Release|x86.Build.0 = Release|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|Any CPU.Build.0 = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x64.ActiveCfg = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x64.Build.0 = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x86.ActiveCfg = Debug|Any CPU - {B02EB99E-A733-443E-B8F7-5FF527C89BCA}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {B1053D24-237E-4E55-9413-20B34ED79F23} = {C723F596-B189-428C-A090-F4965F87A73D} {A18E814C-13D6-4859-B6FA-3CAB8673B31F} = {C723F596-B189-428C-A090-F4965F87A73D} {2F96336D-6AB0-4463-9A9F-5ED91E737DEA} = {C723F596-B189-428C-A090-F4965F87A73D} - {72C88956-EE24-4089-A1B0-939879F83038} = {C723F596-B189-428C-A090-F4965F87A73D} - {B02EB99E-A733-443E-B8F7-5FF527C89BCA} = {C723F596-B189-428C-A090-F4965F87A73D} {05696F45-ACF1-4C02-B8D9-E8C1F5E28717} = {61C529DF-66C4-42E9-AE70-3427838FAFE3} {EA6F01DF-1F63-49FF-A6E8-CA9104296196} = {61C529DF-66C4-42E9-AE70-3427838FAFE3} {64BBA40A-8DB5-4829-815A-3D612A12222D} = {A20A0878-5647-4145-B224-C390446B7676} diff --git a/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln b/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln index 0b1a155a611d8..3928d565e1fbd 100644 --- a/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln +++ b/src/libraries/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{0285779D-C970-4E27-820E-C204E556DD19}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{E41E593C-7180-4134-8097-79B2E3C41E7B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9B8380D8-16E9-4A6C-A5B8-4523778722C9}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C3D946CF-3A37-4EA5-AE14-AC84AF9746F1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FF41EFDD-DD1F-428F-B25E-DD9B85D5A992}" @@ -162,42 +158,6 @@ Global {0285779D-C970-4E27-820E-C204E556DD19}.Checked|x64.Build.0 = Debug|Any CPU {0285779D-C970-4E27-820E-C204E556DD19}.Checked|x86.ActiveCfg = Debug|Any CPU {0285779D-C970-4E27-820E-C204E556DD19}.Checked|x86.Build.0 = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x64.ActiveCfg = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x64.Build.0 = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x86.ActiveCfg = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Debug|x86.Build.0 = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|Any CPU.Build.0 = Release|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x64.ActiveCfg = Release|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x64.Build.0 = Release|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x86.ActiveCfg = Release|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Release|x86.Build.0 = Release|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|Any CPU.Build.0 = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x64.ActiveCfg = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x64.Build.0 = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x86.ActiveCfg = Debug|Any CPU - {E41E593C-7180-4134-8097-79B2E3C41E7B}.Checked|x86.Build.0 = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x64.ActiveCfg = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x64.Build.0 = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x86.ActiveCfg = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Debug|x86.Build.0 = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|Any CPU.Build.0 = Release|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x64.ActiveCfg = Release|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x64.Build.0 = Release|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x86.ActiveCfg = Release|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Release|x86.Build.0 = Release|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|Any CPU.Build.0 = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x64.ActiveCfg = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x64.Build.0 = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x86.ActiveCfg = Debug|Any CPU - {9B8380D8-16E9-4A6C-A5B8-4523778722C9}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {209EDA22-1D20-4180-BE4C-53DEE1758B5D} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} {BC6947B4-C61B-4066-B75F-937992548E54} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} {0285779D-C970-4E27-820E-C204E556DD19} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} - {E41E593C-7180-4134-8097-79B2E3C41E7B} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} - {9B8380D8-16E9-4A6C-A5B8-4523778722C9} = {C3D946CF-3A37-4EA5-AE14-AC84AF9746F1} {ECDDE645-347C-46D8-B6B6-BCFF6B9AFD4A} = {FF41EFDD-DD1F-428F-B25E-DD9B85D5A992} {13447BAB-2762-4CCC-95DF-531FC82FE39A} = {FF41EFDD-DD1F-428F-B25E-DD9B85D5A992} {EE535D8F-D21B-4C18-A915-60E94CE19CA2} = {2AB40A0A-24D5-40B9-AA94-5BF17878879A} diff --git a/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln b/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln index 7c17f7be46204..36776ca20d393 100644 --- a/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln +++ b/src/libraries/System.Reflection.Emit/System.Reflection.Emit.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{C8601778-612D-4274-9F36-17F938E65603}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{A0FF616A-BB90-4508-BDEC-87F32F159607}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{27425166-37BE-4CE2-9588-9EC8D8982AF5}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{74F4AB97-3DBC-48FB-A2EA-2B4141749800}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2FC35C2F-76DB-4D84-B421-9700BEA4D161}" @@ -162,42 +158,6 @@ Global {C8601778-612D-4274-9F36-17F938E65603}.Checked|x64.Build.0 = Debug|Any CPU {C8601778-612D-4274-9F36-17F938E65603}.Checked|x86.ActiveCfg = Debug|Any CPU {C8601778-612D-4274-9F36-17F938E65603}.Checked|x86.Build.0 = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x64.ActiveCfg = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x64.Build.0 = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x86.ActiveCfg = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Debug|x86.Build.0 = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|Any CPU.Build.0 = Release|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x64.ActiveCfg = Release|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x64.Build.0 = Release|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x86.ActiveCfg = Release|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Release|x86.Build.0 = Release|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|Any CPU.Build.0 = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x64.ActiveCfg = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x64.Build.0 = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x86.ActiveCfg = Debug|Any CPU - {A0FF616A-BB90-4508-BDEC-87F32F159607}.Checked|x86.Build.0 = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x64.ActiveCfg = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x64.Build.0 = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x86.ActiveCfg = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Debug|x86.Build.0 = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|Any CPU.Build.0 = Release|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x64.ActiveCfg = Release|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x64.Build.0 = Release|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x86.ActiveCfg = Release|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Release|x86.Build.0 = Release|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|Any CPU.Build.0 = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x64.ActiveCfg = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x64.Build.0 = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x86.ActiveCfg = Debug|Any CPU - {27425166-37BE-4CE2-9588-9EC8D8982AF5}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {772C93D4-FC45-46AA-B09F-26F01B672EDC} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} {B479A4BF-A3A5-4255-A3EF-135015BD877F} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} {C8601778-612D-4274-9F36-17F938E65603} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} - {A0FF616A-BB90-4508-BDEC-87F32F159607} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} - {27425166-37BE-4CE2-9588-9EC8D8982AF5} = {74F4AB97-3DBC-48FB-A2EA-2B4141749800} {E5543842-139D-43BD-B604-E65EBB91649E} = {2FC35C2F-76DB-4D84-B421-9700BEA4D161} {82899000-791E-42FF-A594-6DE65DE07C9E} = {2FC35C2F-76DB-4D84-B421-9700BEA4D161} {6A176C5B-206D-4550-AC36-0530218E29F5} = {C36D185D-9B3D-42E5-985F-E21B3BAF3B6D} diff --git a/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln b/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln index e4cbbb1e90eb6..b83b1c060b7c0 100644 --- a/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln +++ b/src/libraries/System.Reflection.Primitives/System.Reflection.Primitives.sln @@ -5,10 +5,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Reflection.Primitive EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Reflection.Primitives", "src\System.Reflection.Primitives.csproj", "{5D40069E-7CC2-4B40-A41D-6B003CCB4075}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{1F61BE04-C26A-447B-BD25-B90D669C5F53}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{24554C8E-9A88-4659-92CA-A18546239D6A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{4599348B-0480-47D4-9763-F3C6716D3CCC}" @@ -80,42 +76,6 @@ Global {5D40069E-7CC2-4B40-A41D-6B003CCB4075}.Checked|x64.Build.0 = Debug|Any CPU {5D40069E-7CC2-4B40-A41D-6B003CCB4075}.Checked|x86.ActiveCfg = Debug|Any CPU {5D40069E-7CC2-4B40-A41D-6B003CCB4075}.Checked|x86.Build.0 = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x64.ActiveCfg = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x64.Build.0 = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x86.ActiveCfg = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Debug|x86.Build.0 = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|Any CPU.Build.0 = Release|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x64.ActiveCfg = Release|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x64.Build.0 = Release|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x86.ActiveCfg = Release|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Release|x86.Build.0 = Release|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|Any CPU.Build.0 = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x64.ActiveCfg = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x64.Build.0 = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x86.ActiveCfg = Debug|Any CPU - {1F61BE04-C26A-447B-BD25-B90D669C5F53}.Checked|x86.Build.0 = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x64.ActiveCfg = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x64.Build.0 = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x86.ActiveCfg = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Debug|x86.Build.0 = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|Any CPU.Build.0 = Release|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x64.ActiveCfg = Release|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x64.Build.0 = Release|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x86.ActiveCfg = Release|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Release|x86.Build.0 = Release|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|Any CPU.Build.0 = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x64.ActiveCfg = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x64.Build.0 = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x86.ActiveCfg = Debug|Any CPU - {24554C8E-9A88-4659-92CA-A18546239D6A}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -123,8 +83,6 @@ Global GlobalSection(NestedProjects) = preSolution {661E0A3D-E151-45B2-AA38-B30F8227A741} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} {5D40069E-7CC2-4B40-A41D-6B003CCB4075} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} - {1F61BE04-C26A-447B-BD25-B90D669C5F53} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} - {24554C8E-9A88-4659-92CA-A18546239D6A} = {8B893AF4-4C52-4EA7-B4DF-A5ED0E6BEA50} {9D308994-9721-4883-B32D-531FA8D9025B} = {4599348B-0480-47D4-9763-F3C6716D3CCC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln b/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln index 9cd247b6bfb4d..03e23684bbe6a 100644 --- a/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln +++ b/src/libraries/System.Reflection.TypeExtensions/System.Reflection.TypeExtensions.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{C12B737F-2265-4F48-9BEA-B9023063AC91}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{165628C3-CB85-44FF-BDB8-6D0893EFCD60}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{723EA4AC-E9C8-4837-B784-D47CE16BD165}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3A79F8E8-9E66-44C6-94E7-DE8C24F80E59}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9BB99B5C-97D7-4247-B682-27CBBFCF1BB4}" @@ -162,42 +158,6 @@ Global {C12B737F-2265-4F48-9BEA-B9023063AC91}.Checked|x64.Build.0 = Debug|Any CPU {C12B737F-2265-4F48-9BEA-B9023063AC91}.Checked|x86.ActiveCfg = Debug|Any CPU {C12B737F-2265-4F48-9BEA-B9023063AC91}.Checked|x86.Build.0 = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|Any CPU.Build.0 = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x64.ActiveCfg = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x64.Build.0 = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x86.ActiveCfg = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Debug|x86.Build.0 = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|Any CPU.ActiveCfg = Release|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|Any CPU.Build.0 = Release|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x64.ActiveCfg = Release|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x64.Build.0 = Release|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x86.ActiveCfg = Release|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Release|x86.Build.0 = Release|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|Any CPU.Build.0 = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x64.ActiveCfg = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x64.Build.0 = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x86.ActiveCfg = Debug|Any CPU - {165628C3-CB85-44FF-BDB8-6D0893EFCD60}.Checked|x86.Build.0 = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|Any CPU.Build.0 = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x64.ActiveCfg = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x64.Build.0 = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x86.ActiveCfg = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Debug|x86.Build.0 = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|Any CPU.ActiveCfg = Release|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|Any CPU.Build.0 = Release|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x64.ActiveCfg = Release|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x64.Build.0 = Release|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x86.ActiveCfg = Release|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Release|x86.Build.0 = Release|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|Any CPU.Build.0 = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x64.ActiveCfg = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x64.Build.0 = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x86.ActiveCfg = Debug|Any CPU - {723EA4AC-E9C8-4837-B784-D47CE16BD165}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,8 +166,6 @@ Global {F3F9D019-086A-4093-BD49-11B6B204D94A} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} {B958EACD-B145-4B48-A11B-C5E5B565E311} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} {C12B737F-2265-4F48-9BEA-B9023063AC91} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} - {165628C3-CB85-44FF-BDB8-6D0893EFCD60} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} - {723EA4AC-E9C8-4837-B784-D47CE16BD165} = {3A79F8E8-9E66-44C6-94E7-DE8C24F80E59} {41438432-4DC0-4724-8C8F-0D100083490F} = {9BB99B5C-97D7-4247-B682-27CBBFCF1BB4} {FEFD49C5-E2A2-411E-ABF4-DE7B58861750} = {9BB99B5C-97D7-4247-B682-27CBBFCF1BB4} {03C0F6B8-A04B-4822-8089-3918F02AD281} = {B05E90C8-0282-4D7D-955E-3BE8A400D3A6} diff --git a/src/libraries/System.Reflection/System.Reflection.sln b/src/libraries/System.Reflection/System.Reflection.sln index 6c2ab32a7d54f..eddd292df3818 100644 --- a/src/libraries/System.Reflection/System.Reflection.sln +++ b/src/libraries/System.Reflection/System.Reflection.sln @@ -45,10 +45,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{B197B18A-A758-4501-A215-D5C909F39B42}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{6219E11D-A2C0-4591-B147-BC79CF48A524}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{89985471-FD93-4901-9E88-D6DFAEA1DE6D}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1BD23B5E-9944-4133-A162-94D4697616DD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{64590D3A-D464-4764-ABE3-EF62722D8FA7}" @@ -482,42 +478,6 @@ Global {B197B18A-A758-4501-A215-D5C909F39B42}.Checked|x64.Build.0 = Debug|Any CPU {B197B18A-A758-4501-A215-D5C909F39B42}.Checked|x86.ActiveCfg = Debug|Any CPU {B197B18A-A758-4501-A215-D5C909F39B42}.Checked|x86.Build.0 = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x64.ActiveCfg = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x64.Build.0 = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x86.ActiveCfg = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Debug|x86.Build.0 = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|Any CPU.Build.0 = Release|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x64.ActiveCfg = Release|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x64.Build.0 = Release|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x86.ActiveCfg = Release|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Release|x86.Build.0 = Release|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|Any CPU.Build.0 = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x64.ActiveCfg = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x64.Build.0 = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x86.ActiveCfg = Debug|Any CPU - {6219E11D-A2C0-4591-B147-BC79CF48A524}.Checked|x86.Build.0 = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x64.ActiveCfg = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x64.Build.0 = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x86.ActiveCfg = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Debug|x86.Build.0 = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|Any CPU.Build.0 = Release|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x64.ActiveCfg = Release|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x64.Build.0 = Release|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x86.ActiveCfg = Release|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Release|x86.Build.0 = Release|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|Any CPU.Build.0 = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x64.ActiveCfg = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x64.Build.0 = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x86.ActiveCfg = Debug|Any CPU - {89985471-FD93-4901-9E88-D6DFAEA1DE6D}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -526,8 +486,6 @@ Global {27A1A006-6882-4C70-AB81-775D3D2C95A2} = {1BD23B5E-9944-4133-A162-94D4697616DD} {2A4650E3-E199-41E4-AD2B-32818E57D1C7} = {1BD23B5E-9944-4133-A162-94D4697616DD} {B197B18A-A758-4501-A215-D5C909F39B42} = {1BD23B5E-9944-4133-A162-94D4697616DD} - {6219E11D-A2C0-4591-B147-BC79CF48A524} = {1BD23B5E-9944-4133-A162-94D4697616DD} - {89985471-FD93-4901-9E88-D6DFAEA1DE6D} = {1BD23B5E-9944-4133-A162-94D4697616DD} {C5A7E7E7-E43B-4C87-9A92-13C3C817E714} = {64590D3A-D464-4764-ABE3-EF62722D8FA7} {F5998D9E-69A3-4F43-9AA5-B1BB33B54C64} = {64590D3A-D464-4764-ABE3-EF62722D8FA7} {7873C6BF-74FA-4DCF-ADCD-15C75B20132D} = {64590D3A-D464-4764-ABE3-EF62722D8FA7} diff --git a/src/libraries/System.Resources.Extensions/NuGet.config b/src/libraries/System.Resources.Extensions/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Resources.Extensions/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Resources.ResourceManager/NuGet.config b/src/libraries/System.Resources.ResourceManager/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Resources.ResourceManager/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln b/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln index f995d4ea28978..da05457c9c205 100644 --- a/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln +++ b/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln @@ -25,10 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{C411D7D4-7F9C-437E-A36D-022D30389B65}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{3397F202-CCE5-420F-A8B3-E64DBA2C9300}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{E366242C-F4CD-4790-8472-84246E4533B6}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0F0E4254-2575-4B8B-982A-A3D98D6E11DB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8FA5B4E7-5580-4E8A-909E-F1D0B4E60195}" @@ -282,42 +278,6 @@ Global {C411D7D4-7F9C-437E-A36D-022D30389B65}.Checked|x64.Build.0 = Debug|Any CPU {C411D7D4-7F9C-437E-A36D-022D30389B65}.Checked|x86.ActiveCfg = Debug|Any CPU {C411D7D4-7F9C-437E-A36D-022D30389B65}.Checked|x86.Build.0 = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x64.ActiveCfg = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x64.Build.0 = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x86.ActiveCfg = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Debug|x86.Build.0 = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|Any CPU.Build.0 = Release|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x64.ActiveCfg = Release|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x64.Build.0 = Release|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x86.ActiveCfg = Release|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Release|x86.Build.0 = Release|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|Any CPU.Build.0 = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x64.ActiveCfg = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x64.Build.0 = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x86.ActiveCfg = Debug|Any CPU - {3397F202-CCE5-420F-A8B3-E64DBA2C9300}.Checked|x86.Build.0 = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x64.ActiveCfg = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x64.Build.0 = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x86.ActiveCfg = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Debug|x86.Build.0 = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Release|Any CPU.Build.0 = Release|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x64.ActiveCfg = Release|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x64.Build.0 = Release|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x86.ActiveCfg = Release|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Release|x86.Build.0 = Release|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|Any CPU.Build.0 = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x64.ActiveCfg = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x64.Build.0 = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x86.ActiveCfg = Debug|Any CPU - {E366242C-F4CD-4790-8472-84246E4533B6}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -329,8 +289,6 @@ Global {DE2EC027-CD6F-4C5B-8B49-66B5FE795472} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} {5C0A720D-EF35-4403-B246-89AFBFC6C7AF} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} {C411D7D4-7F9C-437E-A36D-022D30389B65} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} - {3397F202-CCE5-420F-A8B3-E64DBA2C9300} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} - {E366242C-F4CD-4790-8472-84246E4533B6} = {0F0E4254-2575-4B8B-982A-A3D98D6E11DB} {B93B5C05-FB28-4173-8786-57B42CFE38F3} = {8FA5B4E7-5580-4E8A-909E-F1D0B4E60195} {DE363A06-8C3D-4DDA-AD67-3B6C253E0424} = {8FA5B4E7-5580-4E8A-909E-F1D0B4E60195} {AFC17385-4DE6-40FF-AEF9-F117B0F1C00B} = {5F76ABD3-6169-46FF-A7B7-CB6CF5FBBFCD} diff --git a/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln b/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln index 09a1f87a231c2..c1678e9303b4a 100644 --- a/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln +++ b/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln @@ -25,10 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAppOutsideOfTPA", "test EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VoidMainWithExitCodeApp", "tests\VoidMainWithExitCodeApp\VoidMainWithExitCodeApp.csproj", "{F55614A7-859C-4171-844B-46F37EDDD351}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{E2C0A4BC-A972-417F-90AC-F269482BDC70}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{2C0F9815-558B-4CDF-B23C-F82B95BD7B61}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2642DD1A-F4C5-4B39-8170-7BC51A75F5D1}" @@ -284,42 +280,6 @@ Global {F55614A7-859C-4171-844B-46F37EDDD351}.Checked|x64.Build.0 = Debug|Any CPU {F55614A7-859C-4171-844B-46F37EDDD351}.Checked|x86.ActiveCfg = Debug|Any CPU {F55614A7-859C-4171-844B-46F37EDDD351}.Checked|x86.Build.0 = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x64.ActiveCfg = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x64.Build.0 = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x86.ActiveCfg = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Debug|x86.Build.0 = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|Any CPU.Build.0 = Release|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x64.ActiveCfg = Release|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x64.Build.0 = Release|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x86.ActiveCfg = Release|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Release|x86.Build.0 = Release|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|Any CPU.Build.0 = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x64.ActiveCfg = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x64.Build.0 = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x86.ActiveCfg = Debug|Any CPU - {E2C0A4BC-A972-417F-90AC-F269482BDC70}.Checked|x86.Build.0 = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x64.ActiveCfg = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x64.Build.0 = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x86.ActiveCfg = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Debug|x86.Build.0 = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|Any CPU.Build.0 = Release|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x64.ActiveCfg = Release|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x64.Build.0 = Release|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x86.ActiveCfg = Release|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Release|x86.Build.0 = Release|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|Any CPU.Build.0 = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x64.ActiveCfg = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x64.Build.0 = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x86.ActiveCfg = Debug|Any CPU - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61}.Checked|x86.Build.0 = Debug|Any CPU {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -347,8 +307,6 @@ Global {1E0C4DD8-3A04-4B4C-9699-DB5844F2CFB2} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {04BA3E3C-6979-4792-B19E-C797AD607F42} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {FF0EFAEE-3E1A-4C7B-8B4A-AAC8E0988A0A} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} - {E2C0A4BC-A972-417F-90AC-F269482BDC70} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} - {2C0F9815-558B-4CDF-B23C-F82B95BD7B61} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {2F9303F6-6EF0-4B14-80B9-A4D9BDA10AE8} = {2642DD1A-F4C5-4B39-8170-7BC51A75F5D1} {D7A1E176-1515-41FE-86D0-A46C82B87B05} = {F4E65A6B-CBA4-40E2-A0B5-6C50C8AAB25C} {01EC2059-605F-472C-A255-ED76197F62CD} = {F4E65A6B-CBA4-40E2-A0B5-6C50C8AAB25C} diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln index 7e2519c5b7caf..6f68cba53d55a 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.sln @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.RuntimeInformation.Tests", "tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csproj", "{4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{703BD7C4-DD4E-4486-BB69-530702F7093B}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ADA9FAB8-9FD5-4035-86D4-4BE1BB564791}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{D380D111-FFFE-4520-A0AE-3EA3E59F7820}" @@ -51,14 +47,6 @@ Global {4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {4DFEE89A-C5B1-4D3E-9B34-96A2D6E98DB8}.Release|Any CPU.Build.0 = Release|Any CPU - {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5}.Release|Any CPU.Build.0 = Release|Any CPU - {703BD7C4-DD4E-4486-BB69-530702F7093B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {703BD7C4-DD4E-4486-BB69-530702F7093B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {703BD7C4-DD4E-4486-BB69-530702F7093B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {703BD7C4-DD4E-4486-BB69-530702F7093B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -70,8 +58,6 @@ Global {B2937043-2666-41F2-A72B-FA9CDBBC012A} = {D380D111-FFFE-4520-A0AE-3EA3E59F7820} {0A1860C3-7207-49CE-B921-A9A76EA4A9DB} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} {375DB818-0E7E-4361-9C56-07658B666B8B} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} - {FE946DA7-E160-4D8E-A0F3-855FE87BB9D5} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} - {703BD7C4-DD4E-4486-BB69-530702F7093B} = {504FF0B7-B77B-4D63-9A18-C5614C9F4F0C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8C10FECD-1847-429D-9777-81F246B05D48} diff --git a/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln b/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln index d140c4e3a4ffa..0a16061bee488 100644 --- a/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln +++ b/src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln @@ -1,10 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{5965CFFE-886A-418C-854F-5967D91DE914}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{173B5BE0-8306-4EAF-9613-2ACC1DC1710C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F4B604CE-7669-4579-BC56-9949DDE1CF65}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "ref\System.Runtime.Intrinsics.csproj", "{28B808CE-B1F8-4B05-9ADA-8884525BD87F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "src\System.Runtime.Intrinsics.csproj", "{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}" @@ -44,42 +40,6 @@ Global {5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x64.Build.0 = Checked|x64 {5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.ActiveCfg = Checked|x86 {5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.Build.0 = Checked|x86 - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x64.ActiveCfg = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x64.Build.0 = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x86.ActiveCfg = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Debug|x86.Build.0 = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|Any CPU.Build.0 = Release|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x64.ActiveCfg = Release|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x64.Build.0 = Release|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x86.ActiveCfg = Release|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Release|x86.Build.0 = Release|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|Any CPU.Build.0 = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x64.ActiveCfg = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x64.Build.0 = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x86.ActiveCfg = Debug|Any CPU - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C}.Checked|x86.Build.0 = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x64.ActiveCfg = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x64.Build.0 = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x86.ActiveCfg = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Debug|x86.Build.0 = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|Any CPU.Build.0 = Release|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x64.ActiveCfg = Release|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x64.Build.0 = Release|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x86.ActiveCfg = Release|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Release|x86.Build.0 = Release|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|Any CPU.Build.0 = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x64.ActiveCfg = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x64.Build.0 = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x86.ActiveCfg = Debug|Any CPU - {F4B604CE-7669-4579-BC56-9949DDE1CF65}.Checked|x86.Build.0 = Debug|Any CPU {28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.Build.0 = Debug|Any CPU {28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -122,8 +82,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {5965CFFE-886A-418C-854F-5967D91DE914} = {F110DBFA-22D7-486A-993D-5461A57A1D50} - {173B5BE0-8306-4EAF-9613-2ACC1DC1710C} = {F110DBFA-22D7-486A-993D-5461A57A1D50} - {F4B604CE-7669-4579-BC56-9949DDE1CF65} = {F110DBFA-22D7-486A-993D-5461A57A1D50} {5AD79501-BEA5-48C7-B466-021A9DCB9D5C} = {F110DBFA-22D7-486A-993D-5461A57A1D50} {28B808CE-B1F8-4B05-9ADA-8884525BD87F} = {E7A9B89D-A9F5-40FD-93CA-CAF4522A80E0} EndGlobalSection diff --git a/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln b/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln index 31de20f5cffa8..e07426491b280 100644 --- a/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln +++ b/src/libraries/System.Runtime.Loader/System.Runtime.Loader.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{04BA3E3C-6979-4792-B19E-C797AD607F42}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{74497070-D782-4958-8D26-BC40A358F8D0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{7DC0688D-77E0-4A58-9966-7CA27CFDD424}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Loader", "ref\System.Runtime.Loader.csproj", "{95B66B14-BCC7-407A-930C-4B34D4F7EC98}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Loader", "src\System.Runtime.Loader.csproj", "{B8F22D73-B183-4F17-9D5E-04B80699E56A}" @@ -146,42 +142,6 @@ Global {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x64.Build.0 = Debug|Any CPU {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.ActiveCfg = Debug|Any CPU {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.Build.0 = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x64.ActiveCfg = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x64.Build.0 = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x86.ActiveCfg = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Debug|x86.Build.0 = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Release|Any CPU.Build.0 = Release|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x64.ActiveCfg = Release|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x64.Build.0 = Release|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x86.ActiveCfg = Release|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Release|x86.Build.0 = Release|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|Any CPU.Build.0 = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x64.ActiveCfg = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x64.Build.0 = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x86.ActiveCfg = Debug|Any CPU - {74497070-D782-4958-8D26-BC40A358F8D0}.Checked|x86.Build.0 = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x64.ActiveCfg = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x64.Build.0 = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x86.ActiveCfg = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Debug|x86.Build.0 = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|Any CPU.Build.0 = Release|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x64.ActiveCfg = Release|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x64.Build.0 = Release|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x86.ActiveCfg = Release|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Release|x86.Build.0 = Release|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|Any CPU.Build.0 = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x64.ActiveCfg = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x64.Build.0 = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x86.ActiveCfg = Debug|Any CPU - {7DC0688D-77E0-4A58-9966-7CA27CFDD424}.Checked|x86.Build.0 = Debug|Any CPU {95B66B14-BCC7-407A-930C-4B34D4F7EC98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95B66B14-BCC7-407A-930C-4B34D4F7EC98}.Debug|Any CPU.Build.0 = Debug|Any CPU {95B66B14-BCC7-407A-930C-4B34D4F7EC98}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -585,8 +545,6 @@ Global GlobalSection(NestedProjects) = preSolution {64DDD2AF-BF90-4DD8-AC24-D2084DB8D558} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} {04BA3E3C-6979-4792-B19E-C797AD607F42} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} - {74497070-D782-4958-8D26-BC40A358F8D0} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} - {7DC0688D-77E0-4A58-9966-7CA27CFDD424} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} {B8F22D73-B183-4F17-9D5E-04B80699E56A} = {6963C709-FD2F-45A7-9A9D-431B1E9A4796} {D6D16FFD-FD76-4700-B456-1DC4D093D1B5} = {F36F0790-5CF7-4CAD-B903-4A3EE0DC1345} {582AA5E5-051B-4774-B02D-747E197A5C56} = {F36F0790-5CF7-4CAD-B903-4A3EE0DC1345} diff --git a/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln b/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln index 8c5872f30a56b..3ef823819e0cd 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln +++ b/src/libraries/System.Runtime.Serialization.Formatters/System.Runtime.Serialization.Formatters.sln @@ -73,10 +73,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{4BFED8CA-1221-48EE-8229-BDB8951DB1C7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{09273711-79A7-4B5E-B4DC-6FB80DF5266A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{3E23308D-787F-4CAA-B6BF-70474775F22E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Formatters", "ref\System.Runtime.Serialization.Formatters.csproj", "{C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Formatters", "src\System.Runtime.Serialization.Formatters.csproj", "{5944056C-E7A1-4A10-BAC4-E3AF91C12C5C}" @@ -796,42 +792,6 @@ Global {4BFED8CA-1221-48EE-8229-BDB8951DB1C7}.Checked|x64.Build.0 = Debug|Any CPU {4BFED8CA-1221-48EE-8229-BDB8951DB1C7}.Checked|x86.ActiveCfg = Debug|Any CPU {4BFED8CA-1221-48EE-8229-BDB8951DB1C7}.Checked|x86.Build.0 = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x64.ActiveCfg = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x64.Build.0 = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x86.ActiveCfg = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Debug|x86.Build.0 = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|Any CPU.Build.0 = Release|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x64.ActiveCfg = Release|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x64.Build.0 = Release|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x86.ActiveCfg = Release|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Release|x86.Build.0 = Release|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|Any CPU.Build.0 = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x64.ActiveCfg = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x64.Build.0 = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x86.ActiveCfg = Debug|Any CPU - {09273711-79A7-4B5E-B4DC-6FB80DF5266A}.Checked|x86.Build.0 = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x64.ActiveCfg = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x64.Build.0 = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x86.ActiveCfg = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Debug|x86.Build.0 = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|Any CPU.Build.0 = Release|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x64.ActiveCfg = Release|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x64.Build.0 = Release|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x86.ActiveCfg = Release|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Release|x86.Build.0 = Release|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|Any CPU.Build.0 = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x64.ActiveCfg = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x64.Build.0 = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x86.ActiveCfg = Debug|Any CPU - {3E23308D-787F-4CAA-B6BF-70474775F22E}.Checked|x86.Build.0 = Debug|Any CPU {C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1D7364E-C24B-460E-B0A0-E49BA6D9FFEC}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1164,8 +1124,6 @@ Global {1E395137-871B-4D6F-A7DB-C92850FAB0D3} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {79F35586-A12D-4831-9D9D-5134FF07CC41} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {4BFED8CA-1221-48EE-8229-BDB8951DB1C7} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} - {09273711-79A7-4B5E-B4DC-6FB80DF5266A} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} - {3E23308D-787F-4CAA-B6BF-70474775F22E} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {5944056C-E7A1-4A10-BAC4-E3AF91C12C5C} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {711CBCE0-C21C-45DA-B0D2-D2298941058E} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} {DF679A1A-1797-40EB-A8AA-E3AEA66C80E5} = {38DE9ACA-E3C9-44BC-B7C3-A5BF363D85D7} diff --git a/src/libraries/System.Runtime/System.Runtime.sln b/src/libraries/System.Runtime/System.Runtime.sln index 58b33669354ef..e40250683ca63 100644 --- a/src/libraries/System.Runtime/System.Runtime.sln +++ b/src/libraries/System.Runtime/System.Runtime.sln @@ -19,10 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{26541647-B653-4480-9448-BA275D53C81D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{52CF1C57-8352-419F-A5B8-DBF39438B70C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{3F401EEE-62E5-442B-8066-7834FDAC9A91}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "ref\System.Runtime.csproj", "{F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "src\System.Runtime.csproj", "{A83A8520-F5E2-49B4-83BC-0F82A412951D}" @@ -250,42 +246,6 @@ Global {26541647-B653-4480-9448-BA275D53C81D}.Checked|x64.Build.0 = Debug|Any CPU {26541647-B653-4480-9448-BA275D53C81D}.Checked|x86.ActiveCfg = Debug|Any CPU {26541647-B653-4480-9448-BA275D53C81D}.Checked|x86.Build.0 = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x64.ActiveCfg = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x64.Build.0 = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x86.ActiveCfg = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Debug|x86.Build.0 = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|Any CPU.Build.0 = Release|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x64.ActiveCfg = Release|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x64.Build.0 = Release|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x86.ActiveCfg = Release|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Release|x86.Build.0 = Release|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|Any CPU.Build.0 = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x64.ActiveCfg = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x64.Build.0 = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x86.ActiveCfg = Debug|Any CPU - {52CF1C57-8352-419F-A5B8-DBF39438B70C}.Checked|x86.Build.0 = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x64.ActiveCfg = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x64.Build.0 = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x86.ActiveCfg = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Debug|x86.Build.0 = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|Any CPU.Build.0 = Release|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x64.ActiveCfg = Release|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x64.Build.0 = Release|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x86.ActiveCfg = Release|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Release|x86.Build.0 = Release|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|Any CPU.Build.0 = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x64.ActiveCfg = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x64.Build.0 = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x86.ActiveCfg = Debug|Any CPU - {3F401EEE-62E5-442B-8066-7834FDAC9A91}.Checked|x86.Build.0 = Debug|Any CPU {F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F39E2C7E-5FE1-460C-AC2C-7E2B50955F2C}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -548,8 +508,6 @@ Global {F27DC16B-64F4-4BD7-AF9C-1C76F7ACC88B} = {28140562-A65A-48E9-ABAB-53BA939084F0} {E7A05515-DABE-4C09-83CB-CE84EFDCD4CC} = {28140562-A65A-48E9-ABAB-53BA939084F0} {26541647-B653-4480-9448-BA275D53C81D} = {28140562-A65A-48E9-ABAB-53BA939084F0} - {52CF1C57-8352-419F-A5B8-DBF39438B70C} = {28140562-A65A-48E9-ABAB-53BA939084F0} - {3F401EEE-62E5-442B-8066-7834FDAC9A91} = {28140562-A65A-48E9-ABAB-53BA939084F0} {A83A8520-F5E2-49B4-83BC-0F82A412951D} = {28140562-A65A-48E9-ABAB-53BA939084F0} {F6A8185B-07C6-401D-9B40-3C560239E05F} = {28140562-A65A-48E9-ABAB-53BA939084F0} {9CF6C6E6-0E9F-4A95-84B5-6083EAB6FA13} = {28140562-A65A-48E9-ABAB-53BA939084F0} diff --git a/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln b/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln index a3f613b3916a9..1508b05a1bb4a 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln +++ b/src/libraries/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{11EF92B5-6C9B-4272-8360-F34A1109F831}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{EE97A768-EF3A-4BF9-BD6D-79EED544BE41}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Algorithms", "ref\System.Security.Cryptography.Algorithms.csproj", "{64C0BC45-368B-44E6-9E04-2F7787CDF153}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Algorithms", "src\System.Security.Cryptography.Algorithms.csproj", "{4146BAB4-BA7C-405E-BEBC-9BE9826514BA}" @@ -57,14 +53,6 @@ Global {11EF92B5-6C9B-4272-8360-F34A1109F831}.Debug|Any CPU.Build.0 = Debug|Any CPU {11EF92B5-6C9B-4272-8360-F34A1109F831}.Release|Any CPU.ActiveCfg = Release|Any CPU {11EF92B5-6C9B-4272-8360-F34A1109F831}.Release|Any CPU.Build.0 = Release|Any CPU - {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EE97A768-EF3A-4BF9-BD6D-79EED544BE41}.Release|Any CPU.Build.0 = Release|Any CPU - {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0}.Release|Any CPU.Build.0 = Release|Any CPU {64C0BC45-368B-44E6-9E04-2F7787CDF153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {64C0BC45-368B-44E6-9E04-2F7787CDF153}.Debug|Any CPU.Build.0 = Debug|Any CPU {64C0BC45-368B-44E6-9E04-2F7787CDF153}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -102,8 +90,6 @@ Global {5BD4A2ED-6203-41E2-9892-002BCC40B0C8} = {FC920C3F-3A16-4258-9DF1-3B1BB3408C69} {AA21E963-CF6B-4474-81A6-D13279854954} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {11EF92B5-6C9B-4272-8360-F34A1109F831} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} - {EE97A768-EF3A-4BF9-BD6D-79EED544BE41} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} - {9DB985AB-00F0-4EA5-BC4A-9EA0A03C75B0} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {4146BAB4-BA7C-405E-BEBC-9BE9826514BA} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {3928EE57-D7D0-45B8-AACD-57DF67D7089A} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} {E5E427F0-D149-4992-AF31-F8616600E188} = {5D6E7D5F-CA32-4F61-8664-ED39FEFB01D1} diff --git a/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln b/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln index aadc72c6281a9..84f9f43c9f616 100644 --- a/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln +++ b/src/libraries/System.Security.Cryptography.Cng/System.Security.Cryptography.Cng.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{39FEA352-F1A3-48AC-89FE-79E976218AC1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BB64DE6A-4AEE-4A7D-879F-28886267817F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{70AD43AF-3C27-4D54-B673-30A66EBB7780}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "ref\System.Security.Cryptography.Cng.csproj", "{B88D8B7E-7682-4F23-82AF-DF186BDD3255}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "src\System.Security.Cryptography.Cng.csproj", "{4BAA22AA-6F42-4C31-8CCF-256F30A26228}" @@ -53,14 +49,6 @@ Global {39FEA352-F1A3-48AC-89FE-79E976218AC1}.Debug|Any CPU.Build.0 = Debug|Any CPU {39FEA352-F1A3-48AC-89FE-79E976218AC1}.Release|Any CPU.ActiveCfg = Release|Any CPU {39FEA352-F1A3-48AC-89FE-79E976218AC1}.Release|Any CPU.Build.0 = Release|Any CPU - {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB64DE6A-4AEE-4A7D-879F-28886267817F}.Release|Any CPU.Build.0 = Release|Any CPU - {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Debug|Any CPU.Build.0 = Debug|Any CPU - {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Release|Any CPU.ActiveCfg = Release|Any CPU - {70AD43AF-3C27-4D54-B673-30A66EBB7780}.Release|Any CPU.Build.0 = Release|Any CPU {B88D8B7E-7682-4F23-82AF-DF186BDD3255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B88D8B7E-7682-4F23-82AF-DF186BDD3255}.Debug|Any CPU.Build.0 = Debug|Any CPU {B88D8B7E-7682-4F23-82AF-DF186BDD3255}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -89,8 +77,6 @@ Global {B88D8B7E-7682-4F23-82AF-DF186BDD3255} = {3B5CC70E-D006-426A-BC91-6A7DEE2F7181} {28FC516D-19C2-43C6-BCBE-10273185673D} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} {39FEA352-F1A3-48AC-89FE-79E976218AC1} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} - {BB64DE6A-4AEE-4A7D-879F-28886267817F} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} - {70AD43AF-3C27-4D54-B673-30A66EBB7780} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} {4BAA22AA-6F42-4C31-8CCF-256F30A26228} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} {929388A9-0224-4FF8-867A-267E47A03311} = {EC42BE1B-70E9-4248-9E0F-288C6677A579} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln b/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln index 1ccbabae402b8..b276f9a4ca5b6 100644 --- a/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln +++ b/src/libraries/System.Security.Cryptography.Csp/System.Security.Cryptography.Csp.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{441BBB8B-D6D7-4518-83B6-687AFC2C6202}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{3AD118FF-93FC-4B2D-B899-B90BB570455F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Csp", "ref\System.Security.Cryptography.Csp.csproj", "{D960CDE1-79C4-46A5-A0E3-3F49AB63DEF9}" @@ -53,14 +49,6 @@ Global {441BBB8B-D6D7-4518-83B6-687AFC2C6202}.Debug|Any CPU.Build.0 = Debug|Any CPU {441BBB8B-D6D7-4518-83B6-687AFC2C6202}.Release|Any CPU.ActiveCfg = Release|Any CPU {441BBB8B-D6D7-4518-83B6-687AFC2C6202}.Release|Any CPU.Build.0 = Release|Any CPU - {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4}.Release|Any CPU.Build.0 = Release|Any CPU - {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3AD118FF-93FC-4B2D-B899-B90BB570455F}.Release|Any CPU.Build.0 = Release|Any CPU {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -89,8 +77,6 @@ Global {D960CDE1-79C4-46A5-A0E3-3F49AB63DEF9} = {1F3677F4-9173-4B3A-BE7B-9616A7A5FDA9} {DA82AA17-5946-4454-B22E-11B3FC3F8D5C} = {004448ED-CE3D-4EEE-B176-458440B11AEB} {441BBB8B-D6D7-4518-83B6-687AFC2C6202} = {004448ED-CE3D-4EEE-B176-458440B11AEB} - {BD19F501-EC40-4758-AD06-FFCBFAB5DBA4} = {004448ED-CE3D-4EEE-B176-458440B11AEB} - {3AD118FF-93FC-4B2D-B899-B90BB570455F} = {004448ED-CE3D-4EEE-B176-458440B11AEB} {3CA5ECAF-C3E1-48F2-905F-BFEE4E164E10} = {004448ED-CE3D-4EEE-B176-458440B11AEB} {153000A6-96D2-4E0D-8E34-13B85E8ECACD} = {004448ED-CE3D-4EEE-B176-458440B11AEB} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln b/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln index df43d1f8698ad..57e684a8d44c0 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln +++ b/src/libraries/System.Security.Cryptography.Encoding/System.Security.Cryptography.Encoding.sln @@ -5,10 +5,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{43B33B0D-4009-4838-B9F4-E5308C1827F7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{4CFB0571-B19E-4524-A6A1-2B1503E574FC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{0FF5C465-AA5F-4C08-85BA-B6FE6D390569}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Encoding", "ref\System.Security.Cryptography.Encoding.csproj", "{465CB04B-D2D8-4E64-BA6D-571BE95391B4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Encoding", "src\System.Security.Cryptography.Encoding.csproj", "{4B1D276E-6576-4F42-9F38-C91C95437F20}" @@ -39,14 +35,6 @@ Global {43B33B0D-4009-4838-B9F4-E5308C1827F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {43B33B0D-4009-4838-B9F4-E5308C1827F7}.Release|Any CPU.ActiveCfg = Release|Any CPU {43B33B0D-4009-4838-B9F4-E5308C1827F7}.Release|Any CPU.Build.0 = Release|Any CPU - {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4CFB0571-B19E-4524-A6A1-2B1503E574FC}.Release|Any CPU.Build.0 = Release|Any CPU - {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0FF5C465-AA5F-4C08-85BA-B6FE6D390569}.Release|Any CPU.Build.0 = Release|Any CPU {465CB04B-D2D8-4E64-BA6D-571BE95391B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {465CB04B-D2D8-4E64-BA6D-571BE95391B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {465CB04B-D2D8-4E64-BA6D-571BE95391B4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -69,8 +57,6 @@ Global {A428E072-E4DD-4F64-AFE3-DC9FC8D5563D} = {34B969D7-6BED-4597-8C25-502A29CF0518} {465CB04B-D2D8-4E64-BA6D-571BE95391B4} = {34B969D7-6BED-4597-8C25-502A29CF0518} {43B33B0D-4009-4838-B9F4-E5308C1827F7} = {0806AC6F-4837-437A-A32F-EED211934481} - {4CFB0571-B19E-4524-A6A1-2B1503E574FC} = {0806AC6F-4837-437A-A32F-EED211934481} - {0FF5C465-AA5F-4C08-85BA-B6FE6D390569} = {0806AC6F-4837-437A-A32F-EED211934481} {4B1D276E-6576-4F42-9F38-C91C95437F20} = {0806AC6F-4837-437A-A32F-EED211934481} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln b/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln index 69b6816eddfd7..6a45e071a54e7 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln +++ b/src/libraries/System.Security.Cryptography.OpenSsl/System.Security.Cryptography.OpenSsl.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{6C660B52-0FE3-43B9-838E-2F92B34E97D9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{4DB1DDA9-3749-49DF-9F52-FA977223C9D7}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{12345E87-4C47-4857-B7E4-6673D6ECC05F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "ref\System.Security.Cryptography.OpenSsl.csproj", "{5AC30FC5-0E64-4C71-AD80-FE758709E22B}" @@ -53,14 +49,6 @@ Global {6C660B52-0FE3-43B9-838E-2F92B34E97D9}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C660B52-0FE3-43B9-838E-2F92B34E97D9}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C660B52-0FE3-43B9-838E-2F92B34E97D9}.Release|Any CPU.Build.0 = Release|Any CPU - {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9}.Release|Any CPU.Build.0 = Release|Any CPU - {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4DB1DDA9-3749-49DF-9F52-FA977223C9D7}.Release|Any CPU.Build.0 = Release|Any CPU {12345E87-4C47-4857-B7E4-6673D6ECC05F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {12345E87-4C47-4857-B7E4-6673D6ECC05F}.Debug|Any CPU.Build.0 = Debug|Any CPU {12345E87-4C47-4857-B7E4-6673D6ECC05F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -89,8 +77,6 @@ Global {5AC30FC5-0E64-4C71-AD80-FE758709E22B} = {8B6D53E6-8F7B-47D1-B6D7-890A783A9959} {A84FF2B2-5272-4F02-AA2B-C0FA61586AA4} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} {6C660B52-0FE3-43B9-838E-2F92B34E97D9} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} - {75CAD00A-8EEA-4F5F-AFBD-DCC6E812E2C9} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} - {4DB1DDA9-3749-49DF-9F52-FA977223C9D7} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} {12345E87-4C47-4857-B7E4-6673D6ECC05F} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} {A0136D6F-CF53-42F8-9227-2FFF2A1841AA} = {4562CA8C-1A07-4AFB-B5BC-977FD19605CB} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln b/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln index 530446da2e06d..623cbbcbd5fc4 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln +++ b/src/libraries/System.Security.Cryptography.Pkcs/System.Security.Cryptography.Pkcs.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DA204355-86E3-431D-B08E-483A49BEB3DB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{A76122D2-2C2C-464C-867F-DE25E9513F86}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{24219BEB-7226-4E84-8CF3-37CFF99A327E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{906CF937-8BCE-4ABF-B35C-23D51D59232E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Pkcs", "ref\System.Security.Cryptography.Pkcs.csproj", "{1AFD2D0A-B962-449B-AC3B-12ED1F439E91}" @@ -53,14 +49,6 @@ Global {DA204355-86E3-431D-B08E-483A49BEB3DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA204355-86E3-431D-B08E-483A49BEB3DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA204355-86E3-431D-B08E-483A49BEB3DB}.Release|Any CPU.Build.0 = Release|Any CPU - {A76122D2-2C2C-464C-867F-DE25E9513F86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A76122D2-2C2C-464C-867F-DE25E9513F86}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A76122D2-2C2C-464C-867F-DE25E9513F86}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A76122D2-2C2C-464C-867F-DE25E9513F86}.Release|Any CPU.Build.0 = Release|Any CPU - {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24219BEB-7226-4E84-8CF3-37CFF99A327E}.Release|Any CPU.Build.0 = Release|Any CPU {906CF937-8BCE-4ABF-B35C-23D51D59232E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {906CF937-8BCE-4ABF-B35C-23D51D59232E}.Debug|Any CPU.Build.0 = Debug|Any CPU {906CF937-8BCE-4ABF-B35C-23D51D59232E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -89,8 +77,6 @@ Global {1AFD2D0A-B962-449B-AC3B-12ED1F439E91} = {FD768C8B-9BF1-4F02-A2C4-335B22615763} {A8D95486-BBE9-4AD2-9D7C-D5B7CF6B90FD} = {D5B768A4-9BA9-4E78-B735-60052C68035C} {DA204355-86E3-431D-B08E-483A49BEB3DB} = {D5B768A4-9BA9-4E78-B735-60052C68035C} - {A76122D2-2C2C-464C-867F-DE25E9513F86} = {D5B768A4-9BA9-4E78-B735-60052C68035C} - {24219BEB-7226-4E84-8CF3-37CFF99A327E} = {D5B768A4-9BA9-4E78-B735-60052C68035C} {906CF937-8BCE-4ABF-B35C-23D51D59232E} = {D5B768A4-9BA9-4E78-B735-60052C68035C} {DDD75646-C8BD-4B16-8E59-E6A3668FD9A2} = {D5B768A4-9BA9-4E78-B735-60052C68035C} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln b/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln index 3acdb21d974a1..6f05428ab2d83 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln +++ b/src/libraries/System.Security.Cryptography.X509Certificates/System.Security.Cryptography.X509Certificates.sln @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{52FC346D-2936-43FD-93A6-02F019A5F5EC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{4D482398-BE79-40F1-A19D-67326A2628B9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9471A98A-28BF-43D6-9E54-F6A340442B32}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Cng", "..\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj", "{EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.OpenSsl", "..\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj", "{97BBCB3E-6924-4EE7-94AD-9B2B793A7ABD}" @@ -59,14 +55,6 @@ Global {52FC346D-2936-43FD-93A6-02F019A5F5EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {52FC346D-2936-43FD-93A6-02F019A5F5EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {52FC346D-2936-43FD-93A6-02F019A5F5EC}.Release|Any CPU.Build.0 = Release|Any CPU - {4D482398-BE79-40F1-A19D-67326A2628B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4D482398-BE79-40F1-A19D-67326A2628B9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4D482398-BE79-40F1-A19D-67326A2628B9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4D482398-BE79-40F1-A19D-67326A2628B9}.Release|Any CPU.Build.0 = Release|Any CPU - {9471A98A-28BF-43D6-9E54-F6A340442B32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9471A98A-28BF-43D6-9E54-F6A340442B32}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9471A98A-28BF-43D6-9E54-F6A340442B32}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9471A98A-28BF-43D6-9E54-F6A340442B32}.Release|Any CPU.Build.0 = Release|Any CPU {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}.Debug|Any CPU.Build.0 = Debug|Any CPU {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -108,8 +96,6 @@ Global {4EC57148-D181-49B9-BDAF-1735D4687C79} = {C79093E1-DEC3-4A35-93CB-216D1E87ACDD} {C2D74126-653E-41C9-9CF8-E58F1FD110B8} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {52FC346D-2936-43FD-93A6-02F019A5F5EC} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} - {4D482398-BE79-40F1-A19D-67326A2628B9} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} - {9471A98A-28BF-43D6-9E54-F6A340442B32} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {EEFBEDAF-C620-4C4E-867E-80A1EFEC4357} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {97BBCB3E-6924-4EE7-94AD-9B2B793A7ABD} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} {76812DB0-A6A2-4F0C-B560-18FC7A97E419} = {D171D0CF-B04B-4D8A-A678-7BB41E4A96FD} diff --git a/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln b/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln index cf1b748e1ea6d..c1a2be6a07283 100644 --- a/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln +++ b/src/libraries/System.Security.Cryptography.Xml/System.Security.Cryptography.Xml.sln @@ -1,6 +1,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{6893D05F-56C1-4454-B3C8-DF83B2791C62}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{013A3141-8CCB-477A-B4B2-A5A5F2CC7603}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{F2034D74-55F1-4055-AC85-12F80A7E56CD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{737DC738-86E3-4528-B7B5-6DB9981A8A7A}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\ref\System.Formats.Asn1.csproj", "{69CF4D3A-5F10-4BCA-B975-0D6239447EDE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Formats.Asn1", "..\System.Formats.Asn1\src\System.Formats.Asn1.csproj", "{4412A97C-77C7-4C89-8F78-E26AEEDE8CA8}" @@ -19,6 +27,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptograph EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Xml.Tests", "tests\System.Security.Cryptography.Xml.Tests.csproj", "{675D4EE3-1F0E-4445-A9CD-635ED3351751}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{42320794-D862-4CD4-9D67-F667A8820AA6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{B52971E5-EABD-4BE9-942A-EDAA290DB09B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{28200C76-F42D-4E11-B948-C8D9193A58A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{404253AC-EAFF-488F-8980-2249F4703278}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F25E8B4D-D7E9-4086-A263-CB9D3B41074B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{B8C68464-1D28-4889-90BC-BC80B036B90B}" @@ -35,6 +51,22 @@ Global {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}.Debug|Any CPU.Build.0 = Debug|Any CPU {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}.Release|Any CPU.ActiveCfg = Release|Any CPU {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77}.Release|Any CPU.Build.0 = Release|Any CPU + {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6893D05F-56C1-4454-B3C8-DF83B2791C62}.Release|Any CPU.Build.0 = Release|Any CPU + {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Debug|Any CPU.Build.0 = Debug|Any CPU + {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Release|Any CPU.ActiveCfg = Release|Any CPU + {013A3141-8CCB-477A-B4B2-A5A5F2CC7603}.Release|Any CPU.Build.0 = Release|Any CPU + {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2034D74-55F1-4055-AC85-12F80A7E56CD}.Release|Any CPU.Build.0 = Release|Any CPU + {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {737DC738-86E3-4528-B7B5-6DB9981A8A7A}.Release|Any CPU.Build.0 = Release|Any CPU {69CF4D3A-5F10-4BCA-B975-0D6239447EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69CF4D3A-5F10-4BCA-B975-0D6239447EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU {69CF4D3A-5F10-4BCA-B975-0D6239447EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -71,6 +103,22 @@ Global {675D4EE3-1F0E-4445-A9CD-635ED3351751}.Debug|Any CPU.Build.0 = Debug|Any CPU {675D4EE3-1F0E-4445-A9CD-635ED3351751}.Release|Any CPU.ActiveCfg = Release|Any CPU {675D4EE3-1F0E-4445-A9CD-635ED3351751}.Release|Any CPU.Build.0 = Release|Any CPU + {42320794-D862-4CD4-9D67-F667A8820AA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42320794-D862-4CD4-9D67-F667A8820AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42320794-D862-4CD4-9D67-F667A8820AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42320794-D862-4CD4-9D67-F667A8820AA6}.Release|Any CPU.Build.0 = Release|Any CPU + {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B52971E5-EABD-4BE9-942A-EDAA290DB09B}.Release|Any CPU.Build.0 = Release|Any CPU + {28200C76-F42D-4E11-B948-C8D9193A58A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28200C76-F42D-4E11-B948-C8D9193A58A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28200C76-F42D-4E11-B948-C8D9193A58A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28200C76-F42D-4E11-B948-C8D9193A58A1}.Release|Any CPU.Build.0 = Release|Any CPU + {404253AC-EAFF-488F-8980-2249F4703278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {404253AC-EAFF-488F-8980-2249F4703278}.Debug|Any CPU.Build.0 = Debug|Any CPU + {404253AC-EAFF-488F-8980-2249F4703278}.Release|Any CPU.ActiveCfg = Release|Any CPU + {404253AC-EAFF-488F-8980-2249F4703278}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -78,14 +126,22 @@ Global GlobalSection(NestedProjects) = preSolution {B3180E55-B9B3-4B71-8A52-DDDCB3E39F77} = {F25E8B4D-D7E9-4086-A263-CB9D3B41074B} {675D4EE3-1F0E-4445-A9CD-635ED3351751} = {F25E8B4D-D7E9-4086-A263-CB9D3B41074B} + {6893D05F-56C1-4454-B3C8-DF83B2791C62} = {B8C68464-1D28-4889-90BC-BC80B036B90B} + {F2034D74-55F1-4055-AC85-12F80A7E56CD} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {69CF4D3A-5F10-4BCA-B975-0D6239447EDE} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {FB3C7609-962F-4414-8702-B3D4121AC51B} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {18882345-4F75-42DB-8DC9-A38AD5C4785E} = {B8C68464-1D28-4889-90BC-BC80B036B90B} {2BB35F95-AD1A-45D3-B8E2-84CC690073A8} = {B8C68464-1D28-4889-90BC-BC80B036B90B} + {42320794-D862-4CD4-9D67-F667A8820AA6} = {B8C68464-1D28-4889-90BC-BC80B036B90B} + {28200C76-F42D-4E11-B948-C8D9193A58A1} = {B8C68464-1D28-4889-90BC-BC80B036B90B} + {013A3141-8CCB-477A-B4B2-A5A5F2CC7603} = {BA579BFF-D4D9-455A-A8AC-589361391420} + {737DC738-86E3-4528-B7B5-6DB9981A8A7A} = {BA579BFF-D4D9-455A-A8AC-589361391420} {4412A97C-77C7-4C89-8F78-E26AEEDE8CA8} = {BA579BFF-D4D9-455A-A8AC-589361391420} {158DDF64-D678-492E-A38A-0EE12E096F84} = {BA579BFF-D4D9-455A-A8AC-589361391420} {474CEFD4-533F-4A2E-8CF9-860F388BC332} = {BA579BFF-D4D9-455A-A8AC-589361391420} {848640EF-9F7D-4D01-AA87-E16617FDEE0B} = {BA579BFF-D4D9-455A-A8AC-589361391420} + {B52971E5-EABD-4BE9-942A-EDAA290DB09B} = {BA579BFF-D4D9-455A-A8AC-589361391420} + {404253AC-EAFF-488F-8980-2249F4703278} = {BA579BFF-D4D9-455A-A8AC-589361391420} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E0287BE2-B499-4885-8EE8-0B35585CA885} diff --git a/src/libraries/System.Security.Permissions/NuGet.config b/src/libraries/System.Security.Permissions/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Security.Permissions/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Security.Principal/System.Security.Principal.sln b/src/libraries/System.Security.Principal/System.Security.Principal.sln index c2870898d4c8d..047d9dd5c7932 100644 --- a/src/libraries/System.Security.Principal/System.Security.Principal.sln +++ b/src/libraries/System.Security.Principal/System.Security.Principal.sln @@ -1,10 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{45602EBE-1508-43A8-A398-1B92BD243557}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{08FE96C0-8567-4DDC-821D-60429E5AD2C7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{60D524AF-8F46-47FD-BCDA-B388763FEC91}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal", "ref\System.Security.Principal.csproj", "{23171947-F933-47A6-9D1A-D43A186E7C43}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Principal", "src\System.Security.Principal.csproj", "{BCF529C8-91CA-44BE-A59C-C8FCAEC04D51}" @@ -44,42 +40,6 @@ Global {45602EBE-1508-43A8-A398-1B92BD243557}.Checked|x64.Build.0 = Checked|x64 {45602EBE-1508-43A8-A398-1B92BD243557}.Checked|x86.ActiveCfg = Checked|x86 {45602EBE-1508-43A8-A398-1B92BD243557}.Checked|x86.Build.0 = Checked|x86 - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x64.ActiveCfg = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x64.Build.0 = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x86.ActiveCfg = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Debug|x86.Build.0 = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|Any CPU.Build.0 = Release|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x64.ActiveCfg = Release|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x64.Build.0 = Release|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x86.ActiveCfg = Release|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Release|x86.Build.0 = Release|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|Any CPU.Build.0 = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x64.ActiveCfg = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x64.Build.0 = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x86.ActiveCfg = Debug|Any CPU - {08FE96C0-8567-4DDC-821D-60429E5AD2C7}.Checked|x86.Build.0 = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|Any CPU.Build.0 = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x64.ActiveCfg = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x64.Build.0 = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x86.ActiveCfg = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Debug|x86.Build.0 = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|Any CPU.ActiveCfg = Release|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|Any CPU.Build.0 = Release|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x64.ActiveCfg = Release|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x64.Build.0 = Release|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x86.ActiveCfg = Release|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Release|x86.Build.0 = Release|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|Any CPU.Build.0 = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x64.ActiveCfg = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x64.Build.0 = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x86.ActiveCfg = Debug|Any CPU - {60D524AF-8F46-47FD-BCDA-B388763FEC91}.Checked|x86.Build.0 = Debug|Any CPU {23171947-F933-47A6-9D1A-D43A186E7C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23171947-F933-47A6-9D1A-D43A186E7C43}.Debug|Any CPU.Build.0 = Debug|Any CPU {23171947-F933-47A6-9D1A-D43A186E7C43}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -122,8 +82,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {45602EBE-1508-43A8-A398-1B92BD243557} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} - {08FE96C0-8567-4DDC-821D-60429E5AD2C7} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} - {60D524AF-8F46-47FD-BCDA-B388763FEC91} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} {BCF529C8-91CA-44BE-A59C-C8FCAEC04D51} = {CB111901-48ED-4097-AAC2-7E8E9A41796D} {23171947-F933-47A6-9D1A-D43A186E7C43} = {DC35DE57-330D-4DE1-822D-12AEA72B1015} EndGlobalSection diff --git a/src/libraries/System.Speech/NuGet.config b/src/libraries/System.Speech/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Speech/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln b/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln index 450091714c56b..4ca8018532b55 100644 --- a/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln +++ b/src/libraries/System.Text.Encoding.Extensions/System.Text.Encoding.Extensions.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{4EFA1701-458A-4318-9552-5BF0734D5C72}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding.Extensions", "ref\System.Text.Encoding.Extensions.csproj", "{F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding.Extensions", "src\System.Text.Encoding.Extensions.csproj", "{EF713897-15F9-42E4-979F-271FA1EF6ECA}" @@ -108,42 +104,6 @@ Global {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}.Checked|x64.Build.0 = Debug|Any CPU {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}.Checked|x86.ActiveCfg = Debug|Any CPU {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F}.Checked|x86.Build.0 = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x64.ActiveCfg = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x64.Build.0 = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x86.ActiveCfg = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Debug|x86.Build.0 = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|Any CPU.Build.0 = Release|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x64.ActiveCfg = Release|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x64.Build.0 = Release|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x86.ActiveCfg = Release|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Release|x86.Build.0 = Release|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|Any CPU.Build.0 = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x64.ActiveCfg = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x64.Build.0 = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x86.ActiveCfg = Debug|Any CPU - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6}.Checked|x86.Build.0 = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x64.ActiveCfg = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x64.Build.0 = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x86.ActiveCfg = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Debug|x86.Build.0 = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|Any CPU.Build.0 = Release|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x64.ActiveCfg = Release|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x64.Build.0 = Release|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x86.ActiveCfg = Release|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Release|x86.Build.0 = Release|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|Any CPU.Build.0 = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x64.ActiveCfg = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x64.Build.0 = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x86.ActiveCfg = Debug|Any CPU - {4EFA1701-458A-4318-9552-5BF0734D5C72}.Checked|x86.Build.0 = Debug|Any CPU {F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F66FD767-48C4-4AD2-B5CF-36AB39AEB78C}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -205,8 +165,6 @@ Global GlobalSection(NestedProjects) = preSolution {E70D3A84-3053-4E44-82FC-A56A574BF6F8} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} {E79A9AD6-FA8F-4D25-83CA-A5CB5B96AF6F} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} - {6DBDCB95-460B-4EDC-91BF-F3E6A869FEC6} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} - {4EFA1701-458A-4318-9552-5BF0734D5C72} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} {EF713897-15F9-42E4-979F-271FA1EF6ECA} = {B98CEFA4-10F4-49B1-A922-5ECBB4C20599} {CC6D3524-D6C8-468B-B908-CE746C1DB175} = {6A521BB6-5A53-4871-8EF7-15C4FCF0B416} {777B4928-6EE5-42D2-8F95-E43EB027D14E} = {6A521BB6-5A53-4871-8EF7-15C4FCF0B416} diff --git a/src/libraries/System.Text.Encoding/System.Text.Encoding.sln b/src/libraries/System.Text.Encoding/System.Text.Encoding.sln index 963bc99b47931..f8dbd8b951bde 100644 --- a/src/libraries/System.Text.Encoding/System.Text.Encoding.sln +++ b/src/libraries/System.Text.Encoding/System.Text.Encoding.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2E6A015C-B78A-4ABB-A623-73956CA3E5FC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{256D7821-23FE-4AF5-B126-75CF1E446D09}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{DDB04173-B88A-4578-A577-C41162D38721}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding", "ref\System.Text.Encoding.csproj", "{B4D27B82-8D9C-4699-9E37-06796D9981EB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding", "src\System.Text.Encoding.csproj", "{57B651DB-5817-4AB7-BF66-C440109F16F9}" @@ -168,42 +164,6 @@ Global {2E6A015C-B78A-4ABB-A623-73956CA3E5FC}.Checked|x64.Build.0 = Debug|Any CPU {2E6A015C-B78A-4ABB-A623-73956CA3E5FC}.Checked|x86.ActiveCfg = Debug|Any CPU {2E6A015C-B78A-4ABB-A623-73956CA3E5FC}.Checked|x86.Build.0 = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|Any CPU.Build.0 = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x64.ActiveCfg = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x64.Build.0 = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x86.ActiveCfg = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Debug|x86.Build.0 = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|Any CPU.ActiveCfg = Release|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|Any CPU.Build.0 = Release|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x64.ActiveCfg = Release|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x64.Build.0 = Release|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x86.ActiveCfg = Release|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Release|x86.Build.0 = Release|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|Any CPU.Build.0 = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x64.ActiveCfg = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x64.Build.0 = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x86.ActiveCfg = Debug|Any CPU - {256D7821-23FE-4AF5-B126-75CF1E446D09}.Checked|x86.Build.0 = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x64.ActiveCfg = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x64.Build.0 = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x86.ActiveCfg = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Debug|x86.Build.0 = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Release|Any CPU.Build.0 = Release|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Release|x64.ActiveCfg = Release|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Release|x64.Build.0 = Release|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Release|x86.ActiveCfg = Release|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Release|x86.Build.0 = Release|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Checked|Any CPU.Build.0 = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x64.ActiveCfg = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x64.Build.0 = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x86.ActiveCfg = Debug|Any CPU - {DDB04173-B88A-4578-A577-C41162D38721}.Checked|x86.Build.0 = Debug|Any CPU {B4D27B82-8D9C-4699-9E37-06796D9981EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B4D27B82-8D9C-4699-9E37-06796D9981EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B4D27B82-8D9C-4699-9E37-06796D9981EB}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -266,8 +226,6 @@ Global {8E868804-E3B3-4933-BFA9-E69F7704B3A5} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {530C65D8-0440-4AF2-8975-F03EFF573195} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {2E6A015C-B78A-4ABB-A623-73956CA3E5FC} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} - {256D7821-23FE-4AF5-B126-75CF1E446D09} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} - {DDB04173-B88A-4578-A577-C41162D38721} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {57B651DB-5817-4AB7-BF66-C440109F16F9} = {CC986F0C-EA00-485E-B6F9-6D8823D9CF84} {9E01529D-6C36-4F34-84CB-68304E93E1F5} = {A4D340E7-AF75-4FA7-AB84-B743E8BB163E} {2B15EE47-1C5F-444F-A9CD-EABBE370718E} = {A4D340E7-AF75-4FA7-AB84-B743E8BB163E} diff --git a/src/libraries/System.Text.Json/System.Text.Json.sln b/src/libraries/System.Text.Json/System.Text.Json.sln index 425af9cef5db5..42d1e7c1dd76c 100644 --- a/src/libraries/System.Text.Json/System.Text.Json.sln +++ b/src/libraries/System.Text.Json/System.Text.Json.sln @@ -21,9 +21,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encodings.Web", "..\System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj", "{9BCCDA15-8907-4AE3-8871-2F17775DDE4C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration", "gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{6485EED4-C313-4551-9865-8ADCED603629}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn4.0", "gen\System.Text.Json.SourceGeneration.Roslyn4.0.csproj", "{6485EED4-C313-4551-9865-8ADCED603629}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "ref\System.Text.Json.csproj", "{7015E94D-D20D-48C8-86D7-6A996BE99E0E}" EndProject @@ -31,12 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json", "src\Sys EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "System.Text.Json.FSharp.Tests", "tests\System.Text.Json.FSharp.Tests\System.Text.Json.FSharp.Tests.fsproj", "{5720BF06-2031-4AD8-B9B4-31A01E27ABB8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Tests", "tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj", "{66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn4.0.Tests", "tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn4.0.Tests.csproj", "{33599A6C-F340-4E1B-9B4D-CB8946C22140}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests", "tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj", "{256A4653-4287-44B3-BDEF-67FC1522ED2F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn4.0.Unit.Tests", "tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn4.0.Unit.Tests.csproj", "{F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.Tests", "tests\System.Text.Json.Tests\System.Text.Json.Tests.csproj", "{A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}" @@ -47,6 +41,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{0371C5D8-D5F EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E49881A9-09F6-442F-9E1D-6D87F5F837F1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11", "gen\System.Text.Json.SourceGeneration.Roslyn3.11.csproj", "{04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests", "tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj", "{256A4653-4287-44B3-BDEF-67FC1522ED2F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Json.SourceGeneration.Roslyn3.11.Tests", "tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj", "{66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,10 +97,6 @@ Global {9BCCDA15-8907-4AE3-8871-2F17775DDE4C}.Debug|Any CPU.Build.0 = Debug|Any CPU {9BCCDA15-8907-4AE3-8871-2F17775DDE4C}.Release|Any CPU.ActiveCfg = Release|Any CPU {9BCCDA15-8907-4AE3-8871-2F17775DDE4C}.Release|Any CPU.Build.0 = Release|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.Build.0 = Release|Any CPU {6485EED4-C313-4551-9865-8ADCED603629}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6485EED4-C313-4551-9865-8ADCED603629}.Debug|Any CPU.Build.0 = Debug|Any CPU {6485EED4-C313-4551-9865-8ADCED603629}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -117,18 +113,10 @@ Global {5720BF06-2031-4AD8-B9B4-31A01E27ABB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {5720BF06-2031-4AD8-B9B4-31A01E27ABB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {5720BF06-2031-4AD8-B9B4-31A01E27ABB8}.Release|Any CPU.Build.0 = Release|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.Build.0 = Release|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Debug|Any CPU.Build.0 = Debug|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Release|Any CPU.ActiveCfg = Release|Any CPU {33599A6C-F340-4E1B-9B4D-CB8946C22140}.Release|Any CPU.Build.0 = Release|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.Build.0 = Release|Any CPU {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -137,32 +125,44 @@ Global {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}.Debug|Any CPU.Build.0 = Debug|Any CPU {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC}.Release|Any CPU.Build.0 = Release|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4}.Release|Any CPU.Build.0 = Release|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {256A4653-4287-44B3-BDEF-67FC1522ED2F}.Release|Any CPU.Build.0 = Release|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {102945CA-3736-4B2C-8E68-242A0B247F2B} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {5720BF06-2031-4AD8-B9B4-31A01E27ABB8} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {33599A6C-F340-4E1B-9B4D-CB8946C22140} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {256A4653-4287-44B3-BDEF-67FC1522ED2F} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} - {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} {73D5739C-E382-4E22-A7D3-B82705C58C74} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {BE27618A-2916-4269-9AD5-6BC5EDC32B30} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {4774F56D-16A8-4ABB-8C73-5F57609F1773} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {E2077991-EB83-471C-B17F-72F569FFCE6D} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {C56337BB-8CBC-4EE5-AB4D-8BB0A922813E} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} - {7015E94D-D20D-48C8-86D7-6A996BE99E0E} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} {E9AA0AEB-AEAE-4B28-8D4D-17A6D7C89D17} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {BE27618A-2916-4269-9AD5-6BC5EDC32B30} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} {1C8262DB-7355-40A8-A2EC-4EED7363134A} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {4774F56D-16A8-4ABB-8C73-5F57609F1773} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} {D05FD93A-BC51-466E-BD56-3F3D6BBE6B06} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {E2077991-EB83-471C-B17F-72F569FFCE6D} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} {7909EB27-0D6E-46E6-B9F9-8A1EFD557018} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {C56337BB-8CBC-4EE5-AB4D-8BB0A922813E} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} {9BCCDA15-8907-4AE3-8871-2F17775DDE4C} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} - {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} {6485EED4-C313-4551-9865-8ADCED603629} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {7015E94D-D20D-48C8-86D7-6A996BE99E0E} = {0371C5D8-D5F5-4747-9810-D91D71D8C0E4} {1285FF43-F491-4BE0-B92C-37DA689CBD4B} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {5720BF06-2031-4AD8-B9B4-31A01E27ABB8} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {33599A6C-F340-4E1B-9B4D-CB8946C22140} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {F6A18EB5-A8CC-4A39-9E85-5FA226019C3D} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {A0178BAA-A1AF-4C69-8E4A-A700A2723DDC} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {04AEB008-EE4F-44DE-A361-2DBD2D0FD6A4} = {E49881A9-09F6-442F-9E1D-6D87F5F837F1} + {256A4653-4287-44B3-BDEF-67FC1522ED2F} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} + {66AD4B7E-CF15-4A8F-8BF8-7E1BC6176D07} = {E07C6980-EB71-4D19-A80A-7BEB80B635B1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5868B757-D821-41FC-952E-2113A0519506} diff --git a/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln b/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln index 16795eefa1b4c..c7430000eb0a3 100644 --- a/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln +++ b/src/libraries/System.Threading.Overlapped/System.Threading.Overlapped.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{217A3A01-70DC-4A0D-87C0-04D581B49183}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Overlapped", "ref\System.Threading.Overlapped.csproj", "{05F39036-EF46-438F-8033-084B5C14832B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Overlapped", "src\System.Threading.Overlapped.csproj", "{A3D9C10B-53A3-483C-8D90-BE7C078B82DF}" @@ -108,42 +104,6 @@ Global {217A3A01-70DC-4A0D-87C0-04D581B49183}.Checked|x64.Build.0 = Debug|Any CPU {217A3A01-70DC-4A0D-87C0-04D581B49183}.Checked|x86.ActiveCfg = Debug|Any CPU {217A3A01-70DC-4A0D-87C0-04D581B49183}.Checked|x86.Build.0 = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x64.ActiveCfg = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x64.Build.0 = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x86.ActiveCfg = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Debug|x86.Build.0 = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|Any CPU.Build.0 = Release|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x64.ActiveCfg = Release|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x64.Build.0 = Release|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x86.ActiveCfg = Release|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Release|x86.Build.0 = Release|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|Any CPU.Build.0 = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x64.ActiveCfg = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x64.Build.0 = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x86.ActiveCfg = Debug|Any CPU - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E}.Checked|x86.Build.0 = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x64.ActiveCfg = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x64.Build.0 = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x86.ActiveCfg = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Debug|x86.Build.0 = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|Any CPU.Build.0 = Release|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x64.ActiveCfg = Release|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x64.Build.0 = Release|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x86.ActiveCfg = Release|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Release|x86.Build.0 = Release|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|Any CPU.Build.0 = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x64.ActiveCfg = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x64.Build.0 = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x86.ActiveCfg = Debug|Any CPU - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3}.Checked|x86.Build.0 = Debug|Any CPU {05F39036-EF46-438F-8033-084B5C14832B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05F39036-EF46-438F-8033-084B5C14832B}.Debug|Any CPU.Build.0 = Debug|Any CPU {05F39036-EF46-438F-8033-084B5C14832B}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -205,8 +165,6 @@ Global GlobalSection(NestedProjects) = preSolution {2F704A4A-944B-487C-BB11-D66CA63F3B05} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} {217A3A01-70DC-4A0D-87C0-04D581B49183} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} - {923FCE5F-AE57-4FEE-B28D-97C73DFCD80E} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} - {FF431EB8-BFDD-48DD-B2AF-11DD07F6E3F3} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} {A3D9C10B-53A3-483C-8D90-BE7C078B82DF} = {4741C000-E701-406A-93B9-ABE5A5CF3D1C} {A4B84F3E-9C18-4CF7-8CA8-9F4AA4A1634F} = {8B1F1ACE-FD0A-4083-8DE6-8148C541A2CA} {3F9C730B-665F-49A3-AB6D-C0A08E4F7CD1} = {8B1F1ACE-FD0A-4083-8DE6-8148C541A2CA} diff --git a/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln b/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln index 7c5defbd1b681..3dbbd1b7ec7be 100644 --- a/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln +++ b/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{876CACCE-AD74-4548-ACD6-63F4B3E5D11C}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks.Extensions", "ref\System.Threading.Tasks.Extensions.csproj", "{8E73F6BD-A0A2-4C98-B4E3-42391B135943}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks.Extensions", "src\System.Threading.Tasks.Extensions.csproj", "{F67BB87D-2927-4BD4-B21B-5A403B6A2209}" @@ -108,42 +104,6 @@ Global {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}.Checked|x64.Build.0 = Debug|Any CPU {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}.Checked|x86.ActiveCfg = Debug|Any CPU {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A}.Checked|x86.Build.0 = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x64.ActiveCfg = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x64.Build.0 = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x86.ActiveCfg = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Debug|x86.Build.0 = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|Any CPU.Build.0 = Release|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x64.ActiveCfg = Release|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x64.Build.0 = Release|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x86.ActiveCfg = Release|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Release|x86.Build.0 = Release|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|Any CPU.Build.0 = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x64.ActiveCfg = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x64.Build.0 = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x86.ActiveCfg = Debug|Any CPU - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B}.Checked|x86.Build.0 = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x64.ActiveCfg = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x64.Build.0 = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x86.ActiveCfg = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Debug|x86.Build.0 = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|Any CPU.Build.0 = Release|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x64.ActiveCfg = Release|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x64.Build.0 = Release|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x86.ActiveCfg = Release|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Release|x86.Build.0 = Release|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|Any CPU.Build.0 = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x64.ActiveCfg = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x64.Build.0 = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x86.ActiveCfg = Debug|Any CPU - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C}.Checked|x86.Build.0 = Debug|Any CPU {8E73F6BD-A0A2-4C98-B4E3-42391B135943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E73F6BD-A0A2-4C98-B4E3-42391B135943}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E73F6BD-A0A2-4C98-B4E3-42391B135943}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -205,8 +165,6 @@ Global GlobalSection(NestedProjects) = preSolution {CB976362-9258-4E98-B8C3-FAE11BDF3AA0} = {17308AE0-6049-4A2A-831C-5EAB57005A53} {DADBC5F2-02BB-4F7F-AFA8-BE10977FCB4A} = {17308AE0-6049-4A2A-831C-5EAB57005A53} - {CA2669B2-95A4-4664-8F9C-55C7CEF4CD5B} = {17308AE0-6049-4A2A-831C-5EAB57005A53} - {876CACCE-AD74-4548-ACD6-63F4B3E5D11C} = {17308AE0-6049-4A2A-831C-5EAB57005A53} {F67BB87D-2927-4BD4-B21B-5A403B6A2209} = {17308AE0-6049-4A2A-831C-5EAB57005A53} {FFB40D04-17A5-4F9B-BD47-994E5616ABD9} = {30ACA65A-DBD9-46CD-9DA4-D7894118EBF8} {AE779AC7-EC2C-42BE-8E59-A2716799E098} = {30ACA65A-DBD9-46CD-9DA4-D7894118EBF8} diff --git a/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln b/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln index 003b4703e0bf7..dc6c664dd9c1a 100644 --- a/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln +++ b/src/libraries/System.Threading.Tasks/System.Threading.Tasks.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{28CBE2F1-B283-4708-A33B-93886453BA83}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks", "ref\System.Threading.Tasks.csproj", "{8C762956-7AB1-4806-9144-5E13771CB22B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks", "src\System.Threading.Tasks.csproj", "{53FBD913-F587-441B-951A-195F65041CF7}" @@ -108,42 +104,6 @@ Global {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}.Checked|x64.Build.0 = Debug|Any CPU {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}.Checked|x86.ActiveCfg = Debug|Any CPU {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB}.Checked|x86.Build.0 = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|Any CPU.Build.0 = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x64.ActiveCfg = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x64.Build.0 = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x86.ActiveCfg = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Debug|x86.Build.0 = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|Any CPU.ActiveCfg = Release|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|Any CPU.Build.0 = Release|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x64.ActiveCfg = Release|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x64.Build.0 = Release|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x86.ActiveCfg = Release|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Release|x86.Build.0 = Release|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|Any CPU.Build.0 = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x64.ActiveCfg = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x64.Build.0 = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x86.ActiveCfg = Debug|Any CPU - {28CBE2F1-B283-4708-A33B-93886453BA83}.Checked|x86.Build.0 = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|Any CPU.Build.0 = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x64.ActiveCfg = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x64.Build.0 = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x86.ActiveCfg = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Debug|x86.Build.0 = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|Any CPU.ActiveCfg = Release|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|Any CPU.Build.0 = Release|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x64.ActiveCfg = Release|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x64.Build.0 = Release|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x86.ActiveCfg = Release|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Release|x86.Build.0 = Release|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|Any CPU.Build.0 = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x64.ActiveCfg = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x64.Build.0 = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x86.ActiveCfg = Debug|Any CPU - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38}.Checked|x86.Build.0 = Debug|Any CPU {8C762956-7AB1-4806-9144-5E13771CB22B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C762956-7AB1-4806-9144-5E13771CB22B}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C762956-7AB1-4806-9144-5E13771CB22B}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -205,8 +165,6 @@ Global GlobalSection(NestedProjects) = preSolution {2738C2DB-E488-4EA2-B981-ADB8C520DCA6} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} {6B6FDB5A-92D8-4FCB-8EFD-04F3B9B3B0BB} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} - {28CBE2F1-B283-4708-A33B-93886453BA83} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} - {79C83FDE-63B3-4BD4-9119-A4DBC5EA5C38} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} {53FBD913-F587-441B-951A-195F65041CF7} = {9BDEA799-400E-4D1B-B34A-5E910B50FA69} {695A5828-6CFC-4BE1-AE4E-6EC9796B4FC7} = {6C2B5085-E5A0-4732-90D5-BA35E9702990} {A8372DA8-B1DD-41ED-AD2C-C74DD5EE51D8} = {6C2B5085-E5A0-4732-90D5-BA35E9702990} diff --git a/src/libraries/System.Threading.Thread/System.Threading.Thread.sln b/src/libraries/System.Threading.Thread/System.Threading.Thread.sln index 86d432c3ef348..b5005523caac6 100644 --- a/src/libraries/System.Threading.Thread/System.Threading.Thread.sln +++ b/src/libraries/System.Threading.Thread/System.Threading.Thread.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{EFE01BA2-5A04-4E14-BB16-9C84285C364F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{7D9E2C13-436B-47F8-B5DC-D24079FEF705}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{753AC0A1-7EA1-4AD5-923E-D693C1105957}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Thread", "ref\System.Threading.Thread.csproj", "{AD5C441F-05EA-452D-B3D2-514B304AA673}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Thread", "src\System.Threading.Thread.csproj", "{A73DCB15-F3DF-48CB-A4CA-62102E94122C}" @@ -114,42 +110,6 @@ Global {EFE01BA2-5A04-4E14-BB16-9C84285C364F}.Checked|x64.Build.0 = Debug|Any CPU {EFE01BA2-5A04-4E14-BB16-9C84285C364F}.Checked|x86.ActiveCfg = Debug|Any CPU {EFE01BA2-5A04-4E14-BB16-9C84285C364F}.Checked|x86.Build.0 = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x64.ActiveCfg = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x64.Build.0 = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x86.ActiveCfg = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Debug|x86.Build.0 = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|Any CPU.Build.0 = Release|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x64.ActiveCfg = Release|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x64.Build.0 = Release|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x86.ActiveCfg = Release|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Release|x86.Build.0 = Release|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|Any CPU.Build.0 = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x64.ActiveCfg = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x64.Build.0 = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x86.ActiveCfg = Debug|Any CPU - {7D9E2C13-436B-47F8-B5DC-D24079FEF705}.Checked|x86.Build.0 = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|Any CPU.Build.0 = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x64.ActiveCfg = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x64.Build.0 = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x86.ActiveCfg = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Debug|x86.Build.0 = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|Any CPU.ActiveCfg = Release|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|Any CPU.Build.0 = Release|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x64.ActiveCfg = Release|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x64.Build.0 = Release|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x86.ActiveCfg = Release|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Release|x86.Build.0 = Release|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|Any CPU.Build.0 = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x64.ActiveCfg = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x64.Build.0 = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x86.ActiveCfg = Debug|Any CPU - {753AC0A1-7EA1-4AD5-923E-D693C1105957}.Checked|x86.Build.0 = Debug|Any CPU {AD5C441F-05EA-452D-B3D2-514B304AA673}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AD5C441F-05EA-452D-B3D2-514B304AA673}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD5C441F-05EA-452D-B3D2-514B304AA673}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -265,8 +225,6 @@ Global GlobalSection(NestedProjects) = preSolution {B811926D-CFBB-4C22-80D2-0CCD566D980C} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} {EFE01BA2-5A04-4E14-BB16-9C84285C364F} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} - {7D9E2C13-436B-47F8-B5DC-D24079FEF705} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} - {753AC0A1-7EA1-4AD5-923E-D693C1105957} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} {A73DCB15-F3DF-48CB-A4CA-62102E94122C} = {576969A4-D9EB-4AD1-8767-240EDD9C23DF} {BF6A7CA7-DDF9-44D4-AD00-D807765663F9} = {73AA6FCA-8FDC-41AA-8539-91562296190B} {12A6F314-B08D-417D-82EC-0D8799D7C1A2} = {73AA6FCA-8FDC-41AA-8539-91562296190B} diff --git a/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln b/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln index da2fbee36e7ae..7a260859fb61b 100644 --- a/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln +++ b/src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{3440C79D-9158-4D66-9018-5194272AAD4B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{63A5C88E-CB60-4936-A489-566659D82D40}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{91C694FA-B623-45E8-B999-89AF70151EFD}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.ThreadPool", "ref\System.Threading.ThreadPool.csproj", "{54134937-585D-48D5-AB60-79493BE2C9E7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.ThreadPool", "src\System.Threading.ThreadPool.csproj", "{53A0D29E-8633-4FF8-AB0E-86EF331DD379}" @@ -108,42 +104,6 @@ Global {3440C79D-9158-4D66-9018-5194272AAD4B}.Checked|x64.Build.0 = Debug|Any CPU {3440C79D-9158-4D66-9018-5194272AAD4B}.Checked|x86.ActiveCfg = Debug|Any CPU {3440C79D-9158-4D66-9018-5194272AAD4B}.Checked|x86.Build.0 = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|Any CPU.Build.0 = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x64.ActiveCfg = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x64.Build.0 = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x86.ActiveCfg = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Debug|x86.Build.0 = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Release|Any CPU.ActiveCfg = Release|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Release|Any CPU.Build.0 = Release|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x64.ActiveCfg = Release|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x64.Build.0 = Release|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x86.ActiveCfg = Release|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Release|x86.Build.0 = Release|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|Any CPU.Build.0 = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x64.ActiveCfg = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x64.Build.0 = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x86.ActiveCfg = Debug|Any CPU - {63A5C88E-CB60-4936-A489-566659D82D40}.Checked|x86.Build.0 = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x64.ActiveCfg = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x64.Build.0 = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x86.ActiveCfg = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Debug|x86.Build.0 = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|Any CPU.Build.0 = Release|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x64.ActiveCfg = Release|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x64.Build.0 = Release|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x86.ActiveCfg = Release|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Release|x86.Build.0 = Release|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|Any CPU.Build.0 = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x64.ActiveCfg = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x64.Build.0 = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x86.ActiveCfg = Debug|Any CPU - {91C694FA-B623-45E8-B999-89AF70151EFD}.Checked|x86.Build.0 = Debug|Any CPU {54134937-585D-48D5-AB60-79493BE2C9E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {54134937-585D-48D5-AB60-79493BE2C9E7}.Debug|Any CPU.Build.0 = Debug|Any CPU {54134937-585D-48D5-AB60-79493BE2C9E7}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -205,8 +165,6 @@ Global GlobalSection(NestedProjects) = preSolution {BEACD8A1-3C09-450E-931F-561D44986BFB} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} {3440C79D-9158-4D66-9018-5194272AAD4B} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} - {63A5C88E-CB60-4936-A489-566659D82D40} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} - {91C694FA-B623-45E8-B999-89AF70151EFD} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} {53A0D29E-8633-4FF8-AB0E-86EF331DD379} = {3358539E-11F4-4294-8D94-A9A31E9F47F5} {CD477FC8-AF27-46A2-A451-4A2D4C11600D} = {DB513386-C3B1-4891-92E1-1BE5D38562DC} {71ACA28C-A4F1-4A07-A1B3-39DB86C11A75} = {DB513386-C3B1-4891-92E1-1BE5D38562DC} diff --git a/src/libraries/System.Threading.Timer/System.Threading.Timer.sln b/src/libraries/System.Threading.Timer/System.Threading.Timer.sln index e64614e9f9438..4e4db9b810199 100644 --- a/src/libraries/System.Threading.Timer/System.Threading.Timer.sln +++ b/src/libraries/System.Threading.Timer/System.Threading.Timer.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{98FBF74D-9544-4B64-B126-49FA876D62EC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{62835A52-BF00-471E-BF1D-D62EA1A27084}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{29EE1BE7-1976-49F3-9047-DD989D5040A5}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Timer", "ref\System.Threading.Timer.csproj", "{CF3D7FED-A927-4611-891F-AB3516B71D44}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Timer", "src\System.Threading.Timer.csproj", "{2B942D1B-20DE-427E-9D46-F1C513C7FFF5}" @@ -108,42 +104,6 @@ Global {98FBF74D-9544-4B64-B126-49FA876D62EC}.Checked|x64.Build.0 = Debug|Any CPU {98FBF74D-9544-4B64-B126-49FA876D62EC}.Checked|x86.ActiveCfg = Debug|Any CPU {98FBF74D-9544-4B64-B126-49FA876D62EC}.Checked|x86.Build.0 = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|Any CPU.Build.0 = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x64.ActiveCfg = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x64.Build.0 = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x86.ActiveCfg = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Debug|x86.Build.0 = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|Any CPU.ActiveCfg = Release|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|Any CPU.Build.0 = Release|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x64.ActiveCfg = Release|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x64.Build.0 = Release|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x86.ActiveCfg = Release|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Release|x86.Build.0 = Release|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|Any CPU.Build.0 = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x64.ActiveCfg = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x64.Build.0 = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x86.ActiveCfg = Debug|Any CPU - {62835A52-BF00-471E-BF1D-D62EA1A27084}.Checked|x86.Build.0 = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x64.ActiveCfg = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x64.Build.0 = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x86.ActiveCfg = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Debug|x86.Build.0 = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|Any CPU.Build.0 = Release|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x64.ActiveCfg = Release|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x64.Build.0 = Release|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x86.ActiveCfg = Release|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Release|x86.Build.0 = Release|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|Any CPU.Build.0 = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x64.ActiveCfg = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x64.Build.0 = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x86.ActiveCfg = Debug|Any CPU - {29EE1BE7-1976-49F3-9047-DD989D5040A5}.Checked|x86.Build.0 = Debug|Any CPU {CF3D7FED-A927-4611-891F-AB3516B71D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CF3D7FED-A927-4611-891F-AB3516B71D44}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF3D7FED-A927-4611-891F-AB3516B71D44}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -205,8 +165,6 @@ Global GlobalSection(NestedProjects) = preSolution {74D4C464-F319-4A9D-8F09-C50FDBA1547A} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} {98FBF74D-9544-4B64-B126-49FA876D62EC} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} - {62835A52-BF00-471E-BF1D-D62EA1A27084} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} - {29EE1BE7-1976-49F3-9047-DD989D5040A5} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} {2B942D1B-20DE-427E-9D46-F1C513C7FFF5} = {DE255038-9D63-46EB-8AD0-A508EB5B76C7} {567E9CC8-5751-4786-BCC6-C2A6C38044DF} = {0149D5FD-7BFC-4421-8B5E-74FD45D9B3D7} {DAB761D6-EDD5-4F57-9BDE-E26589057403} = {0149D5FD-7BFC-4421-8B5E-74FD45D9B3D7} diff --git a/src/libraries/System.Threading/System.Threading.sln b/src/libraries/System.Threading/System.Threading.sln index 55549b4f4f43b..9c476c03dd1c6 100644 --- a/src/libraries/System.Threading/System.Threading.sln +++ b/src/libraries/System.Threading/System.Threading.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{2CE21C30-5734-42DA-BB23-E72AD4F15F3F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{0BA360C6-6E32-4E77-A233-F48DE135B7E7}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "ref\System.Threading.csproj", "{0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "src\System.Threading.csproj", "{F4D0710C-6A53-44F9-A28B-63F008FEF808}" @@ -108,42 +104,6 @@ Global {2CE21C30-5734-42DA-BB23-E72AD4F15F3F}.Checked|x64.Build.0 = Debug|Any CPU {2CE21C30-5734-42DA-BB23-E72AD4F15F3F}.Checked|x86.ActiveCfg = Debug|Any CPU {2CE21C30-5734-42DA-BB23-E72AD4F15F3F}.Checked|x86.Build.0 = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x64.ActiveCfg = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x64.Build.0 = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x86.ActiveCfg = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Debug|x86.Build.0 = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|Any CPU.Build.0 = Release|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x64.ActiveCfg = Release|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x64.Build.0 = Release|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x86.ActiveCfg = Release|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Release|x86.Build.0 = Release|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|Any CPU.Build.0 = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x64.ActiveCfg = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x64.Build.0 = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x86.ActiveCfg = Debug|Any CPU - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0}.Checked|x86.Build.0 = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x64.ActiveCfg = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x64.Build.0 = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x86.ActiveCfg = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Debug|x86.Build.0 = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|Any CPU.Build.0 = Release|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x64.ActiveCfg = Release|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x64.Build.0 = Release|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x86.ActiveCfg = Release|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Release|x86.Build.0 = Release|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|Any CPU.Build.0 = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x64.ActiveCfg = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x64.Build.0 = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x86.ActiveCfg = Debug|Any CPU - {0BA360C6-6E32-4E77-A233-F48DE135B7E7}.Checked|x86.Build.0 = Debug|Any CPU {0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}.Debug|Any CPU.Build.0 = Debug|Any CPU {0B7B0E9C-6B63-42F2-ABFF-DB46EE7EAD49}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -205,8 +165,6 @@ Global GlobalSection(NestedProjects) = preSolution {1F14F4DD-AE65-407B-9E10-F5786A847AD6} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} {2CE21C30-5734-42DA-BB23-E72AD4F15F3F} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} - {C4D3E842-0C4D-4C9E-9AA6-6A2A78837CB0} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} - {0BA360C6-6E32-4E77-A233-F48DE135B7E7} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} {F4D0710C-6A53-44F9-A28B-63F008FEF808} = {C50DDA85-E391-4BC7-BF37-758B9CD35CF3} {387778C0-0405-4FE2-9D85-034254EAAD46} = {CCC80DF2-8B4E-497C-84A9-4E6344294566} {3DD929D8-346F-4CF3-B157-22E052F73A91} = {CCC80DF2-8B4E-497C-84A9-4E6344294566} diff --git a/src/libraries/System.Windows.Extensions/NuGet.config b/src/libraries/System.Windows.Extensions/NuGet.config new file mode 100644 index 0000000000000..a66b7f9b01324 --- /dev/null +++ b/src/libraries/System.Windows.Extensions/NuGet.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln b/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln index a6aaa33b6b948..04e468f58e8ce 100644 --- a/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln +++ b/src/libraries/System.Xml.ReaderWriter/System.Xml.ReaderWriter.sln @@ -1,10 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{4886A8C5-3546-459A-8800-ED0DA91C6B15}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{93D62540-9A64-4B14-B3FA-4A88307130E3}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.ReaderWriter", "ref\System.Xml.ReaderWriter.csproj", "{2FE5F437-4CE1-4A27-8547-B950F8043D89}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.ReaderWriter", "src\System.Xml.ReaderWriter.csproj", "{FA7C251C-D1FD-45C3-8CC8-D094F70A03AA}" @@ -23,14 +19,6 @@ Global {4886A8C5-3546-459A-8800-ED0DA91C6B15}.Debug|Any CPU.Build.0 = Debug|Any CPU {4886A8C5-3546-459A-8800-ED0DA91C6B15}.Release|Any CPU.ActiveCfg = Release|Any CPU {4886A8C5-3546-459A-8800-ED0DA91C6B15}.Release|Any CPU.Build.0 = Release|Any CPU - {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC}.Release|Any CPU.Build.0 = Release|Any CPU - {93D62540-9A64-4B14-B3FA-4A88307130E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {93D62540-9A64-4B14-B3FA-4A88307130E3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {93D62540-9A64-4B14-B3FA-4A88307130E3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {93D62540-9A64-4B14-B3FA-4A88307130E3}.Release|Any CPU.Build.0 = Release|Any CPU {2FE5F437-4CE1-4A27-8547-B950F8043D89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2FE5F437-4CE1-4A27-8547-B950F8043D89}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FE5F437-4CE1-4A27-8547-B950F8043D89}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -45,8 +33,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {4886A8C5-3546-459A-8800-ED0DA91C6B15} = {311C66CC-47AC-4965-B704-3C62E57FE29D} - {097D5C7E-E0D1-4B06-9026-8C0E9ED2F1FC} = {311C66CC-47AC-4965-B704-3C62E57FE29D} - {93D62540-9A64-4B14-B3FA-4A88307130E3} = {311C66CC-47AC-4965-B704-3C62E57FE29D} {FA7C251C-D1FD-45C3-8CC8-D094F70A03AA} = {311C66CC-47AC-4965-B704-3C62E57FE29D} {2FE5F437-4CE1-4A27-8547-B950F8043D89} = {6AA53AA1-786A-4B35-B1C5-9D3B2EC10CF1} EndGlobalSection diff --git a/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln b/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln index 42645d4497020..29b6090e241f9 100644 --- a/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln +++ b/src/libraries/System.Xml.XDocument/System.Xml.XDocument.sln @@ -3,10 +3,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml.Linq", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{CE19D781-5542-4024-9829-FE589BA93146}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{86DDDD49-B840-4945-AA41-F9BBD157A27B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{FAB1AAB6-8352-4FFB-9543-F9F89067222D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XDocument", "ref\System.Xml.XDocument.csproj", "{1516AD95-61E7-40F6-A9A8-59A6E8A0467A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XDocument", "src\System.Xml.XDocument.csproj", "{B229C42C-204A-43B4-AB71-587AD46F927E}" @@ -29,14 +25,6 @@ Global {CE19D781-5542-4024-9829-FE589BA93146}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE19D781-5542-4024-9829-FE589BA93146}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE19D781-5542-4024-9829-FE589BA93146}.Release|Any CPU.Build.0 = Release|Any CPU - {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {86DDDD49-B840-4945-AA41-F9BBD157A27B}.Release|Any CPU.Build.0 = Release|Any CPU - {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FAB1AAB6-8352-4FFB-9543-F9F89067222D}.Release|Any CPU.Build.0 = Release|Any CPU {1516AD95-61E7-40F6-A9A8-59A6E8A0467A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1516AD95-61E7-40F6-A9A8-59A6E8A0467A}.Debug|Any CPU.Build.0 = Debug|Any CPU {1516AD95-61E7-40F6-A9A8-59A6E8A0467A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -52,8 +40,6 @@ Global GlobalSection(NestedProjects) = preSolution {09DBC219-3DE1-40E1-ABD2-CD972410F03E} = {AFC9144B-DAD7-470E-B068-C17C24862D23} {CE19D781-5542-4024-9829-FE589BA93146} = {AFC9144B-DAD7-470E-B068-C17C24862D23} - {86DDDD49-B840-4945-AA41-F9BBD157A27B} = {AFC9144B-DAD7-470E-B068-C17C24862D23} - {FAB1AAB6-8352-4FFB-9543-F9F89067222D} = {AFC9144B-DAD7-470E-B068-C17C24862D23} {B229C42C-204A-43B4-AB71-587AD46F927E} = {AFC9144B-DAD7-470E-B068-C17C24862D23} {1516AD95-61E7-40F6-A9A8-59A6E8A0467A} = {8F3CD562-EA5E-4DD1-8B30-E6BA65887115} EndGlobalSection diff --git a/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln b/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln index 24863d2cc3314..b8bfe51567d23 100644 --- a/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln +++ b/src/libraries/System.Xml.XPath.XDocument/System.Xml.XPath.XDocument.sln @@ -3,10 +3,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml.Linq", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{C1BE1D97-D078-4882-A772-C3CA11FD1F73}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{75961C7B-0125-41F4-98DF-5149EC1EB666}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath.XDocument", "ref\System.Xml.XPath.XDocument.csproj", "{E0E5B798-30CC-4D39-B164-C009141E2ABC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath.XDocument", "src\System.Xml.XPath.XDocument.csproj", "{D52C68D2-B6DD-4FFB-B3B5-011B76733202}" @@ -29,14 +25,6 @@ Global {C1BE1D97-D078-4882-A772-C3CA11FD1F73}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1BE1D97-D078-4882-A772-C3CA11FD1F73}.Release|Any CPU.ActiveCfg = Release|Any CPU {C1BE1D97-D078-4882-A772-C3CA11FD1F73}.Release|Any CPU.Build.0 = Release|Any CPU - {75961C7B-0125-41F4-98DF-5149EC1EB666}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75961C7B-0125-41F4-98DF-5149EC1EB666}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75961C7B-0125-41F4-98DF-5149EC1EB666}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75961C7B-0125-41F4-98DF-5149EC1EB666}.Release|Any CPU.Build.0 = Release|Any CPU - {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59}.Release|Any CPU.Build.0 = Release|Any CPU {E0E5B798-30CC-4D39-B164-C009141E2ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E0E5B798-30CC-4D39-B164-C009141E2ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0E5B798-30CC-4D39-B164-C009141E2ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -52,8 +40,6 @@ Global GlobalSection(NestedProjects) = preSolution {A03326C2-C437-44C6-91C5-07AA8F24D51C} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} {C1BE1D97-D078-4882-A772-C3CA11FD1F73} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} - {75961C7B-0125-41F4-98DF-5149EC1EB666} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} - {B7E9FE31-47E6-42B8-B1AC-F3B7F0EC2E59} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} {D52C68D2-B6DD-4FFB-B3B5-011B76733202} = {7C3C9BDE-3FF9-4B26-BACB-59EB827A5C0C} {E0E5B798-30CC-4D39-B164-C009141E2ABC} = {47B3DDCB-3A95-4315-9D49-A2653C6F3A17} EndGlobalSection diff --git a/src/libraries/System.Xml.XPath/System.Xml.XPath.sln b/src/libraries/System.Xml.XPath/System.Xml.XPath.sln index a052d56115a15..951c5d774dac9 100644 --- a/src/libraries/System.Xml.XPath/System.Xml.XPath.sln +++ b/src/libraries/System.Xml.XPath/System.Xml.XPath.sln @@ -1,10 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{B7D48F78-4580-4398-A93F-FD02A15AD0BD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{846BD820-3A18-4D7B-9E50-641608AAA3D5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath", "ref\System.Xml.XPath.csproj", "{38040AE0-59E4-46CE-861D-A33A383BB0FC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XPath", "src\System.Xml.XPath.csproj", "{F825C114-FF6D-4826-BC8A-586246369695}" @@ -23,14 +19,6 @@ Global {B7D48F78-4580-4398-A93F-FD02A15AD0BD}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7D48F78-4580-4398-A93F-FD02A15AD0BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7D48F78-4580-4398-A93F-FD02A15AD0BD}.Release|Any CPU.Build.0 = Release|Any CPU - {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {846BD820-3A18-4D7B-9E50-641608AAA3D5}.Release|Any CPU.Build.0 = Release|Any CPU - {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D}.Release|Any CPU.Build.0 = Release|Any CPU {38040AE0-59E4-46CE-861D-A33A383BB0FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {38040AE0-59E4-46CE-861D-A33A383BB0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {38040AE0-59E4-46CE-861D-A33A383BB0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -45,8 +33,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {B7D48F78-4580-4398-A93F-FD02A15AD0BD} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} - {846BD820-3A18-4D7B-9E50-641608AAA3D5} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} - {F2BF826D-8CAB-48C5-9D0C-B88F0B53BC8D} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} {F825C114-FF6D-4826-BC8A-586246369695} = {73688A49-11B7-47C8-BF09-A6C1C11EA0BD} {38040AE0-59E4-46CE-861D-A33A383BB0FC} = {1EF0B525-2611-41AB-AA69-28A1B9689C3A} EndGlobalSection diff --git a/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln b/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln index 9d6374c17845c..47755aa6bab67 100644 --- a/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln +++ b/src/libraries/System.Xml.XmlDocument/System.Xml.XmlDocument.sln @@ -1,10 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{733E5502-5F1A-4ECC-8C44-0E057B11437D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{AA26E41D-F396-451F-8978-6FF3DAC927D8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5D76923D-117E-4D99-9740-C3D8AABF2C52}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlDocument", "ref\System.Xml.XmlDocument.csproj", "{9FA44EA8-BEDA-412E-A366-9334FDBA77A9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlDocument", "src\System.Xml.XmlDocument.csproj", "{8656FF2F-1024-4D56-B38C-F99BE27B732D}" @@ -23,14 +19,6 @@ Global {733E5502-5F1A-4ECC-8C44-0E057B11437D}.Debug|Any CPU.Build.0 = Debug|Any CPU {733E5502-5F1A-4ECC-8C44-0E057B11437D}.Release|Any CPU.ActiveCfg = Release|Any CPU {733E5502-5F1A-4ECC-8C44-0E057B11437D}.Release|Any CPU.Build.0 = Release|Any CPU - {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AA26E41D-F396-451F-8978-6FF3DAC927D8}.Release|Any CPU.Build.0 = Release|Any CPU - {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5D76923D-117E-4D99-9740-C3D8AABF2C52}.Release|Any CPU.Build.0 = Release|Any CPU {9FA44EA8-BEDA-412E-A366-9334FDBA77A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FA44EA8-BEDA-412E-A366-9334FDBA77A9}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FA44EA8-BEDA-412E-A366-9334FDBA77A9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -45,8 +33,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {733E5502-5F1A-4ECC-8C44-0E057B11437D} = {9EB72201-88D9-48A5-858D-82F01B2382B6} - {AA26E41D-F396-451F-8978-6FF3DAC927D8} = {9EB72201-88D9-48A5-858D-82F01B2382B6} - {5D76923D-117E-4D99-9740-C3D8AABF2C52} = {9EB72201-88D9-48A5-858D-82F01B2382B6} {8656FF2F-1024-4D56-B38C-F99BE27B732D} = {9EB72201-88D9-48A5-858D-82F01B2382B6} {9FA44EA8-BEDA-412E-A366-9334FDBA77A9} = {A6E661CC-CFD6-4866-BE5B-59ECB823DC70} EndGlobalSection diff --git a/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln b/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln index f708893988b2e..3dd3461444214 100644 --- a/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln +++ b/src/libraries/System.Xml.XmlSerializer/System.Xml.XmlSerializer.sln @@ -1,10 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Xml", "..\System.Private.Xml\src\System.Private.Xml.csproj", "{EF514C0C-ECA7-419A-BDED-A6735FEA16F9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{71929DBB-35DB-457C-8B52-5CEA1ED83C2C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9143576D-B7B4-4289-9169-23832CB3E67C}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlSerializer", "ref\System.Xml.XmlSerializer.csproj", "{A463D0F1-1814-4276-B7A9-59780C755D0A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlSerializer", "src\System.Xml.XmlSerializer.csproj", "{67D79968-DF22-4273-B2FA-D3EEC905095C}" @@ -23,14 +19,6 @@ Global {EF514C0C-ECA7-419A-BDED-A6735FEA16F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF514C0C-ECA7-419A-BDED-A6735FEA16F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF514C0C-ECA7-419A-BDED-A6735FEA16F9}.Release|Any CPU.Build.0 = Release|Any CPU - {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {71929DBB-35DB-457C-8B52-5CEA1ED83C2C}.Release|Any CPU.Build.0 = Release|Any CPU - {9143576D-B7B4-4289-9169-23832CB3E67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9143576D-B7B4-4289-9169-23832CB3E67C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9143576D-B7B4-4289-9169-23832CB3E67C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9143576D-B7B4-4289-9169-23832CB3E67C}.Release|Any CPU.Build.0 = Release|Any CPU {A463D0F1-1814-4276-B7A9-59780C755D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A463D0F1-1814-4276-B7A9-59780C755D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {A463D0F1-1814-4276-B7A9-59780C755D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -45,8 +33,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {EF514C0C-ECA7-419A-BDED-A6735FEA16F9} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} - {71929DBB-35DB-457C-8B52-5CEA1ED83C2C} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} - {9143576D-B7B4-4289-9169-23832CB3E67C} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} {67D79968-DF22-4273-B2FA-D3EEC905095C} = {F0B2F254-B3E6-4BAA-8C92-2373990CF48B} {A463D0F1-1814-4276-B7A9-59780C755D0A} = {E0C34B2E-D8CC-4A13-9635-3FD9AF37EC9B} EndGlobalSection