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

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElinor Fung <elfung@microsoft.com>2022-03-16 06:05:50 +0300
committerGitHub <noreply@github.com>2022-03-16 06:05:50 +0300
commitd2688883510318aa0114268930fb2022d3dc64cf (patch)
tree187dce6ec6afbcb180cac35f8ece1e1e8e457c37 /src/libraries/System.Runtime.InteropServices
parentc3dbdea91835d67cc461b22125e652ad5063d746 (diff)
Expose `LibraryImportAttribute` (#66434)
Diffstat (limited to 'src/libraries/System.Runtime.InteropServices')
-rw-r--r--src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj2
-rw-r--r--src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs16
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj2
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs2
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj1
-rw-r--r--src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/LibraryImportAttributeTests.cs19
6 files changed, 38 insertions, 4 deletions
diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj
index f2f1c273e5d..467bf762702 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj
+++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj
@@ -27,7 +27,7 @@
<ItemGroup>
<!-- Code included from System.Runtime.InteropServices -->
- <Compile Include="$(CommonPath)System\Runtime\InteropServices\StringMarshalling.cs" Link="Production\StringMarshalling.cs" />
+ <Compile Include="$(CoreLibSharedDir)System\Runtime\InteropServices\StringMarshalling.cs" Link="Production\StringMarshalling.cs" />
</ItemGroup>
<ItemGroup>
diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
index eac47acf63d..72b9191fd88 100644
--- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
+++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
@@ -484,6 +484,16 @@ namespace System.Runtime.InteropServices
public LCIDConversionAttribute(int lcid) { }
public int Value { get { throw null; } }
}
+ [System.AttributeUsageAttribute(System.AttributeTargets.Method, AllowMultiple = false, Inherited=false)]
+ public sealed partial class LibraryImportAttribute : System.Attribute
+ {
+ public LibraryImportAttribute(string libraryName) { }
+ public string LibraryName { get { throw null; } }
+ public string? EntryPoint { get { throw null; } set { } }
+ public bool SetLastError { get { throw null; } set { }}
+ public System.Runtime.InteropServices.StringMarshalling StringMarshalling { get { throw null; } set { } }
+ public System.Type? StringMarshallingCustomType { get { throw null; } set { } }
+ }
[System.AttributeUsageAttribute(System.AttributeTargets.Method, Inherited=false, AllowMultiple=false)]
public sealed partial class ManagedToNativeComInteropStubAttribute : System.Attribute
{
@@ -994,6 +1004,12 @@ namespace System.Runtime.InteropServices
{
protected StandardOleMarshalObject() { }
}
+ public enum StringMarshalling
+ {
+ Custom = 0,
+ Utf8 = 1,
+ Utf16 = 2,
+ }
[System.AttributeUsageAttribute(System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, AllowMultiple=false, Inherited=false)]
public sealed partial class TypeIdentifierAttribute : System.Attribute
{
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 60e536023fb..710d935b82f 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
@@ -11,9 +11,7 @@
</PropertyGroup>
<ItemGroup>
- <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/LibraryImportAttribute.cs" Link="LibraryImportAttribute.cs" />
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs" Link="GeneratedMarshallingAttribute.cs" />
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs" Link="ArrayMarshaller.cs" />
- <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/StringMarshalling.cs" Link="StringMarshalling.cs" />
</ItemGroup>
</Project>
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs
index cabfb327be4..f1d835ce585 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs
@@ -183,7 +183,7 @@ namespace LibraryImportGenerator.UnitTests
{
// 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(LibraryImportAttribute).GetTypeInfo().Assembly;
+ var attrAssem = typeof(MarshalUsingAttribute).GetTypeInfo().Assembly;
return MetadataReference.CreateFromFile(attrAssem.Location);
}
diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj
index 072080790a2..46d0d5d3a6e 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj
+++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj
@@ -48,6 +48,7 @@
<Compile Include="System\Runtime\InteropServices\IDispatchImplAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\InterfaceTypeAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\LCIDConversionAttributeTests.cs" />
+ <Compile Include="System\Runtime\InteropServices\LibraryImportAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\MarshalAsAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\Copy\ByteArrayTests.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\Copy\CharArrayTests.cs" />
diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/LibraryImportAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/LibraryImportAttributeTests.cs
new file mode 100644
index 00000000000..1ebda2c8883
--- /dev/null
+++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/LibraryImportAttributeTests.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using Xunit;
+
+namespace System.Runtime.InteropServices.Tests
+{
+ public class LibraryImportAttributeTests
+ {
+ [Theory]
+ [InlineData(null)]
+ [InlineData("LibraryName")]
+ public void Ctor(string libraryName)
+ {
+ var attribute = new LibraryImportAttribute(libraryName);
+ Assert.Equal(libraryName, attribute.LibraryName);
+ }
+ }
+}