Skip to content

Add sample for custom marshalling in p/invoke source generation #5315

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
merged 3 commits into from
Sep 8, 2022

Conversation

elinor-fung
Copy link
Member

Summary

Add sample for custom marshalling in p/invoke source generation

Contributes to #5125

…rshalling/Program.cs

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@elinor-fung
Copy link
Member Author

elinor-fung commented Sep 6, 2022

@gewarren any ideas on how to get the CI snippets build working with this? Looks like merging is blocked if that doesn't pass.

Error: 😵 Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
Error: D:\a\samples\samples\core\interop\source-generation\custom-marshalling\src\nativelib\nativelib.vs.vcxproj(31,3): error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.

I guess it doesn't recognize build.proj at the root folder as the project? Is there a way to direct it to build that (as in dotnet build build.proj)?

For nativelib.vs.vcxproj that it is trying/failing to build, it is more for convenience of the VS experience, not for the main build. Is there a way to avoid building that?

@gewarren
Copy link
Contributor

gewarren commented Sep 6, 2022

@adegeo Can you answer Elinor's questions about Snippets 5000?

@adegeo
Copy link
Contributor

adegeo commented Sep 8, 2022

@elinor-fung You can force the nativelib.vs.vcxproj file to be compiled by Visual Studio instead of dotnet, would that help get rid of that error? Regarding the .proj file, we'll have to modify the build system to pass it through to the dotnet build command.

@elinor-fung
Copy link
Member Author

I know I can set "host": "visualstudio" in a snippets.5000.json, but is there a way to make that only apply to that one project? It is in the same folder as nativelib.csproj, which is the 'normal' build for the sample.

For the build.proj it is just used to reference the actual *.csproj which I think are being found/built (? how can I check?). If there's a way to say that it is okay that this top-level folder doesn't have project directly in it, I think that would be reasonable for us too.

@adegeo
Copy link
Contributor

adegeo commented Sep 8, 2022

@elinor-fung We don't have a way to set the host per project, I think we should. I'll look into adding this ability

@gewarren
Copy link
Contributor

gewarren commented Sep 8, 2022

@adegeo Should we remove the required status check and merge this for now?

@adegeo
Copy link
Contributor

adegeo commented Sep 8, 2022

We can add the known errors to the host file, which will let this pass cleanly. I'm trying to find an example of that 😁

@adegeo
Copy link
Contributor

adegeo commented Sep 8, 2022

@gewarren I looked more into this and we can't bypass the missing project error. I think it's OK to remove the check and merge for now.

@gewarren gewarren merged commit 0097460 into dotnet:main Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants