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

Switch over miscellaneous DllImports to GeneratedDllImport. #62353

Merged
merged 13 commits into from Dec 9, 2021

Conversation

jkoritzinsky
Copy link
Member

These P/Invokes slipped through the cracks for their respective libraries because they're either only used on platforms where getting the analyzer to run in VS is more difficult (CoreLib for mobile platforms) or they were missed in the first pass.

These P/Invokes slipped through the cracks for their respective libraries because they're either only used on platforms where getting the analyzer to run in VS is more difficult (CoreLib for mobile platforms) or they were missed in the first pass.

[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
// TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we support non-blittable types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to reference tracking issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the comment pattern we've used even migrating over the rest of the DllImports, so I'd prefer to match that.

@jkoritzinsky jkoritzinsky merged commit 3dc93b3 into dotnet:main Dec 9, 2021
@jkoritzinsky jkoritzinsky deleted the misc-gendllimport branch December 9, 2021 00:47
@marek-safar
Copy link
Contributor

Curious why don't we have code analyzers/fixers for this?

@stephentoub
Copy link
Member

Curious why don't we have code analyzers/fixers for this?

See the opening PR comment:
"These P/Invokes slipped through the cracks for their respective libraries because they're either only used on platforms where getting the analyzer to run in VS is more difficult (CoreLib for mobile platforms)"

It's not blanketly enabled as a warning for the whole repo yet as the team has been working through the changeover library by library.

@marek-safar
Copy link
Contributor

Great news. I didn't know there is an analyzer available already.

@dotnet dotnet locked as resolved and limited conversation to collaborators Jan 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants