-
Notifications
You must be signed in to change notification settings - Fork 56
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
SDK targets rework #173
SDK targets rework #173
Conversation
Would it be possible to add the function pointers work to this PR and remove SharpPatch completely? If possible I’d like to go down that route since IL patching is a pain and makes strong naming annoying. |
I can do that, of course, but I'd prefer to leave the old method in case someone can't upgrade Roslyn version (some enterprise backwaters, for instance) and use C# 9.0. In fact, I have also added |
Would be possible to add map directly to nuint and nint? And generation of void* instead of IntPtr? |
As these PRs are for SharpGenTools 2.0 and we’re already accepting breaking changes, I honestly don’t care if people can’t upgrade to an SDK that supports function pointers. 1.x doesn’t use them, so people can stay on that version. We have a servicing branch for 1.x that people can make changes to if need be. And if people are stuck on an LTS SDK for some enterprisey reason, that will be remedied when .NET 6.0 comes out in November. I’m also opposed to using Marshal delegates instead of function pointers. It was an explicit design decision for perf reasons and limiting allocations to use calli and not delegates. And if we bump the minimum version to C#9, we can probably update default mappings to use nint and nuint as requested. We could also convert the last step of the code generator to be a C# Source Generator and get out of the business of writing source files to disk. |
Sorry for bumping the topic, I agree with @jkoritzinsky , lets focus on future stuff. |
@amerkoleci it's not related to this PR, but I can answer it here:
|
Any change we can mute all those warnings about mapping already exists? see https://github.com/amerkoleci/Vortice.Windows/runs/1642426719?check_suite_focus=true I would bring also attention on parameters name, most function has the Ref suffix "dstRef" or when returning type the "p" prefix is omitted, like D3D12CreateDevice you'll have deviceOut. |
@jkoritzinsky okay, that's reasonable. I'm still not sure about doing it in this PR. I don't want to make it larger. @amerkoleci documentation & extensibility is in Episode 6. |
NativeLong and NativeULong are only identical at the interop boundary to nint and nuint on non Windows. On Windows they’re supposed to map to int and uint. Function pointers should only require updating the InvocationGenerator and the mapping phase. We already have the knowledge of the interop method we’re calling, so we should be able to construct the full signature. We have to emit it in other places today for SharpPatch to patch up. |
@jkoritzinsky yeah, it turned out to be not so simple. |
Ok. I’ll try to review this PR this week. Let’s get function pointers in soon after this one though. Really looking forward to removing SharpPatch and some of the complexity in the code base along with it. |
66c7982
to
1a42c38
Compare
@jkoritzinsky reminder |
What's the reasoning behind merging all of the different tasks together? I liked having the separation so I could actually debug the inputs and outputs of each step individually. Also, one of my goals for the future is to add a new format for the mapping files that allows true incremental builds so we only re-parse C++ when the includes or defines change. Merging all of the tasks makes that much more difficult. |
Merging it fixes all issues I've discovered with SharpGen invalidations: mostly it's overly aggressive bindings regenerations (most frequently seen when using IDEs: I remember at least once with VS and many times with Rider, when SharpGen started regenerating everything when there was no reason to do so). This also enhances current handling of files that are not visible to MSBuild (previously: no invalidations were done when changed, now: works as expected), or when properties are changed (due to whatever reason). Btw, it doesn't just try to duplicate what MSBuild does, it works together with MSBuild (by populating MSBuild target Inputs for the SharpGen target). A new format for mapping files is cool (I also wanted that, I planned on using existing MSBuild infra, so that we'd have proper conditionals and FS invalidations). But I'm not sure this is the 2.0 goal, since it's pretty massive. I see your point about incremental builds (it is something I was keeping in mind when working on this), but the current state is that incremental builds are broken, this PR fixes everything by dropping the malfunctioning incremental parts. If needed in the future, this can be partially brought back, but in a better way (I'm thinking actual MSBuild partial incremental builds for headers, by leveraging MSBuild item transforms), and with the Also, debugging SharpGen is possible, I even made some improvements in this area in this PR (related to It is also model serializability that I want to get rid of, at least for C# (this PR gets rid of both, for obvious reasons, but it doesn't remove the serialization cruft from the model). I can understand keeping it for C++ model (given the interest in incremental builds), but reading & writing huge XML files multiple times on each regeneration is a big red flag (at least for me). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a reasonable argument. We can revisit incrementability in the future.
* Merge SharpPatch into SharpGenTools.Sdk * Merge SharpGen tasks into a single one (SharpGenTask) * Rework MSBuild file invalidation to be well specified * Rework test infra to support large test matrices * Extensibility and documentation parts are expected in Episode 6
1a42c38
to
51f4f5c
Compare
8037e0f
to
16469ae
Compare
SharpPatch
intoSharpGenTools.Sdk
SharpGenTask
)Extensibility and documentation parts are expected in Episode 6