Skip to content
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

Strange error message from LibraryImport #69827

Closed
stephentoub opened this issue May 25, 2022 · 3 comments · Fixed by #69830
Closed

Strange error message from LibraryImport #69827

stephentoub opened this issue May 25, 2022 · 3 comments · Fixed by #69830

Comments

@stephentoub
Copy link
Member

Compiling:

using System.Runtime.InteropServices;

Console.WriteLine(Interop.MyFunction());

partial class Interop
{
    [LibraryImport(Abc)]
    internal static partial int MyFunction();
}

errors with the message:
"The 'Invalid syntax' configuration is not supported by source-generated P/Invokes."

That's a very strange error message 😄

Do we even need a diagnostic in this case? It's not going to compile, anyway, as the C# compiler itself also issues "error CS0103: The name 'Abc' does not exist in the current context".

@ghost
Copy link

ghost commented May 25, 2022

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Issue Details

Compiling:

using System.Runtime.InteropServices;

Console.WriteLine(Interop.MyFunction());

partial class Interop
{
    [LibraryImport(Abc)]
    internal static partial int MyFunction();
}

errors with the message:
"The 'Invalid syntax' configuration is not supported by source-generated P/Invokes."

That's a very strange error message 😄

Do we even need a diagnostic in this case? It's not going to compile, anyway, as the C# compiler itself also issues "error CS0103: The name 'Abc' does not exist in the current context".

Author: stephentoub
Assignees: -
Labels:

area-System.Runtime.InteropServices

Milestone: -

@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 25, 2022
@jkoritzinsky
Copy link
Member

We technically don't need a diagnostic. I'd be okay with removing it.

@elinor-fung
Copy link
Member

Agreed - we should just remove.

jkoritzinsky added a commit that referenced this issue May 25, 2022
… the attribute. The C# compiler will already fail so just let it emit its diagnostics.


Fixes #69827
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label May 25, 2022
@ghost ghost removed untriaged New issue has not been triaged by the area owner in-pr There is an active PR which will close this issue when it is merged labels May 26, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants