-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expose LibraryImportAttribute
#66434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
elinor-fung
merged 7 commits into
dotnet:main
from
elinor-fung:exposeLibraryImportAttribute
Mar 16, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bc65661
Expose LibraryImportAttribute
elinor-fung 569b855
Move under CoreLib and use #if SYSTEM_PRIVATE_CORELIB
elinor-fung 3085ad2
Move IsExternalInit, ExcludeFromCodeCoverageAttribute, and ReferenceE…
elinor-fung 76898f8
Apply suggestions from code review
elinor-fung 9b8a553
Apply suggestions from code review
elinor-fung 323a161
Apply suggestions from code review
elinor-fung 60d5416
Add test
elinor-fung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
src/libraries/Common/src/System/Runtime/InteropServices/LibraryImportAttribute.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
68 changes: 68 additions & 0 deletions
68
...aries/System.Private.CoreLib/src/System/Runtime/InteropServices/LibraryImportAttribute.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace System.Runtime.InteropServices | ||
| { | ||
| /// <summary> | ||
| /// Attribute used to indicate a source generator should create a function for marshalling | ||
| /// arguments instead of relying on the runtime to generate an equivalent marshalling function at run-time. | ||
| /// </summary> | ||
|
elinor-fung marked this conversation as resolved.
|
||
| /// <remarks> | ||
| /// This attribute is meaningless if the source generator associated with it is not enabled. | ||
| /// The current built-in source generator only supports C# and only supplies an implementation when | ||
| /// applied to static, partial, non-generic methods. | ||
| /// </remarks> | ||
| [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
| #if SYSTEM_PRIVATE_CORELIB | ||
| public | ||
| #else | ||
| internal | ||
| #endif | ||
|
jkotas marked this conversation as resolved.
|
||
| sealed class LibraryImportAttribute : Attribute | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="LibraryImportAttribute"/>. | ||
| /// </summary> | ||
| /// <param name="libraryName">Name of the library containing the import.</param> | ||
| public LibraryImportAttribute(string libraryName) | ||
| { | ||
| LibraryName = libraryName; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the name of the library containing the import. | ||
| /// </summary> | ||
| public string LibraryName { get; } | ||
|
AaronRobinsonMSFT marked this conversation as resolved.
|
||
|
|
||
| /// <summary> | ||
| /// Gets or sets the name of the entry point to be called. | ||
| /// </summary> | ||
| public string? EntryPoint { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets how to marshal string arguments to the method. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this field is set to a value other than <see cref="StringMarshalling.Custom" />, | ||
| /// <see cref="StringMarshallingCustomType" /> must not be specified. | ||
| /// </remarks> | ||
| public StringMarshalling StringMarshalling { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the <see cref="Type"/> used to control how string arguments to the method are marshalled. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this field is specified, <see cref="StringMarshalling" /> must not be specified | ||
| /// or must be set to <see cref="StringMarshalling.Custom" />. | ||
| /// </remarks> | ||
| public Type? StringMarshallingCustomType { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets whether the callee sets an error (SetLastError on Windows or errno | ||
| /// on other platforms) before returning from the attributed method. | ||
| /// </summary> | ||
| public bool SetLastError { get; set; } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.