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
using 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 behavior
Generated code builds successfully.
Actual behavior
Build fails with an error in generated code:
LibraryImports.g.cs(10,13,10,19): error CS0120: An object reference is required for the non-static field, method, or property 'Class1.System'
Regression?
No response
Known Workarounds
No response
Configuration
net7.0 on Windows 10 x64, using VS 17.7.0
Other information
No response
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