This repository was archived by the owner on Jul 26, 2023. It is now read-only.
Generate IntPtr overloads for BCrypt native pointer methods #117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces code generation that automatically adds
IntPtr
overloads of methods with native pointers.This will close #95 when merged to master. I'm merging to a staging branch for now so we can review it without also re-reviewing the changes to bcrypt and advapi32 that removed the intptr overloads.
Design
We rely on the new CodeGeneration.Roslyn nuget package for the framework in which we generate code. This frees us from much of the grunt work of code generation such as .targets and MSBuild Task authoring, locked files, etc. We can adjust the code generation code in VS and build the solution without any reloading and it immediately takes effect. We can even hit F5 and debug the code generation itself which of course can turn in handy.
All extra dependencies (on the nuget package and assemblies defining attributes and code generation) evaporate during the build. No references remain so the end user is not impacted.
The IntPtr overloads are generated into files that are created in the intermediate output directory. They are added to
@(Compile)
so the same assembly and same type that contains the native pointer method also contains the IntPtr overload. This generated code is available at design-time, so you can Go to Definition on it, find it in the member jump list at the top of the document, etc.