-
Notifications
You must be signed in to change notification settings - Fork 120
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
winspool.drv APIs missing SetLastError attribute #1446
Comments
Such functions are (or should be) documented as doing that. Take Ultimately, the reason CsWin32 does not emit |
@AArnott, i've been using the winspool API at work for quite some time and we've always used the GetLastError to detect errors in these API methods calls, for example, if i try to add a printer with a name that already exists on the system, i get 0x00000709 through GetLastError which is a error that makes sense in this case, we actually have a list of the possible errors for most of the winspool methods. Anyway, I think the metadata and docs are wrong in this case and not only for the AddPrinter method. The docs are wrong for not showing explicitly that the function uses the SetLastError. I can share the list of methods that we have mapped the errors using GetLastError if it's necessary. Even though i think the optimal solution would be fix the metadata, i don't know the complexity or heuristics that they use to generate this decorator, and if its possible... Do you think it's possible to generate it manually somehow, with configuration? Some json key/val that forces CsWin32 to generate the method signature with the SetLastError, or even in the NativeMethods.txt with some hint after the method name. Thanks! |
That would be very helpful.
No, such a feature does not exist, and give that would only help one user of one projection, we're far more interested in fixing the metadata itself so everyone benefits. I'll transfer the issue to the win32metadata repo, and if you can provide the list of APIs, I think we can get it fixed right away. |
The linked AddPrinter documentation says nothing about setting the last error value. So this will require someone at Microsoft to go look at the implementation. |
|
Great, thanks @kennykerr! |
Is it just AddPrinter that needs a change? |
I think we need a better way to figure out whether |
No, i was just cleaning a list that we have here at the company to give the methods that we are almost sure that call SetLastError because of the nature of the errors that they emit in specific scenarios: Here is the list: |
Actual behavior
Some methods from the Winspool.drv are not generated with SetLastError true, even tho the docs says that they should generate errors.
Expected behavior
The methods to be generated with SetLastError = true.
Repro steps
Some examples:
This method is alright.
But this one is not, and the docs says that it generates error in some cases: https://learn.microsoft.com/en-us/windows/win32/printdocs/addprinter
Does someone know why this happens? Should i fill an issue to the metadata team? Is this the expected behavior, and if so, why?
Thanks!
Context
0.4.422-beta
]netstandard2.0
]LangVersion
(if explicitly set by project): [e.g.9
]The text was updated successfully, but these errors were encountered: