-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
LibraryImport cannot handle a property named "System" #90299
Comments
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsDescriptionIf there is a property named "System" in scope where LibraryImport is used, the generated code will fail to build with error CS0120. This is probably caused by ambiguity between "System" namespace and "System" property. Perhaps generated code should prefix types with Reproduction Stepsusing System;
using System.Runtime.InteropServices;
namespace ClassLibrary1;
public partial class Class1
{
public int System => GetSystem(out _);
[LibraryImport("foo.dll")]
private static partial int GetSystem(out IntPtr handle);
} Expected behaviorGenerated code builds successfully. Actual behaviorBuild fails with an error in generated code:
Regression?No response Known WorkaroundsNo response Configurationnet7.0 on Windows 10 x64, using VS 17.7.0 Other informationNo response
|
@jkoritzinsky Are we missing a |
Looks like in SkipInit and the DllImportAttribute application we're missing it. |
I assume this is an easy fix. |
I just looked at the PR 😬 #Jinx |
Description
If there is a property named "System" in scope where LibraryImport is used, the generated code will fail to build with error CS0120.
This is probably caused by ambiguity between "System" namespace and "System" property. Perhaps generated code should prefix types with
global::
?Reproduction Steps
Expected behavior
Generated code builds successfully.
Actual behavior
Build fails with an error in generated code:
Regression?
No response
Known Workarounds
No response
Configuration
net7.0 on Windows 10 x64, using VS 17.7.0
Other information
No response
The text was updated successfully, but these errors were encountered: