dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.27k stars 5.9k forks source link

Enable pinvoke source generation in netstandard2.0 project #37757

Open Danielku15 opened 1 year ago

Danielku15 commented 1 year ago

Type of issue

Missing information

Description

I would like to know if and how the source generation for platform invokes can be used in a netstandard2.0 project using .net 7 SDK. Are there any runtime dependencies for this feature, is there a NuGet package for netstandar2.0 projects or can some sources be added to the own project to make the generator work?

Page URL

https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke-source-generation

Content source URL

https://github.com/dotnet/docs/blob/main/docs/standard/native-interop/pinvoke-source-generation.md

Document Version Independent Id

572c0b50-a28d-d387-1e8c-4a271615a753

Article author

@jkoritzinsky

jkoritzinsky commented 11 months ago

PInvoke source generation is not supported when targeting .NET Standard 2.0. The source generator uses APIs that were introduced in .NET 5, 6, and 7 (and the version in .NET 8 uses APIs that were introduced in .NET 8).