-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
WmiLight integral types inconsistent with System.Management types #9
Comments
Hi, I implemtned WmiLight that is uses the types provided by the COM interface itself. System.Management teached me that i have to interprete the provided type identifie (CimType). Changing the implementation is not so easy. It would break the usage of old version. I have to think about an solution .... |
Could you please have a look to Version 4.0.0-pre? This version should behave like System.Management but also allows the "wrong" types to avoid breaking changes. |
It does seem to be able to be used as a drop-in replacement now. Thank you! I played around with the backward-compatibility functionality. I have some code that looks like e.g. If I change that So it will support backward compatibility to some degree, but certain usages won't work. |
I only adjusted the generic version of the Another option would be to introduce new methods (eg. I tend to the second options, because all other would be a compromise :-| What do you think? |
I don't think there's a way to cleanly support all use cases in a backward-compatible fashion. There's the use case of being a drop-in replacement. In order to still be a drop-in replacement and support WmiLight users that might have been using this API, you would you have to return a proxy object that can be casted to either of the types. That is, since it returns The only issue with this would be a separate use case where a caller simply used the A separate use case is the convenience accessor You could introduce a class You could make a separate library that's intended to be a complete drop-in replacement. That is, the only change you'd need to make is changing It seems like there's a compromise somewhere at any level that you pick. Some kind of costs or strange behavior. |
I alos had the idea with the proxy object but did not like the fact that it also does not work in all cases and introduces aditional complexety and reduces the performence. Therefore I decided to introduce a Version 4 with breaking changes. To get an idea how WmiLight is used, I searched on GitHub and found some usages:
Please have a log to version 4.0.0. and if it wokes as drop-in replacement. |
@rastrac-joel I'm working on a new verion thats compatible with AOT. I have reimplement a lot of code and like to test it. Could you provide the WmiTool from your screenshots? |
It's owned by my employer, I'm currently looking into whether I have permission to release the source or the tool. I'll give you an update next week. |
I already wrote a small compare tool 😁 Thanks! |
I've attached a screenshot of query output from both System.Management WMI interaction and WmiLight WMI interaction and you can see that WmiLight uses
int
for all integral types while System.Management uses other types likeuint
,ushort
, etc. This means you get anInvalidCastException
when casting and if you use the.GetPropertyValue<T>
overload, the same thing occurs.I looked at the code and it's not obvious to me where the
int
is materializing, but it does mean that WmiLight is difficult to drop in as a System.Management replacement. Additionally, in a case likeint
vsuint
orint
vslong
, it may cause semantic problems - though it seems like the library simply usesstring
forlong
. I'd like to use this library for its support for trimming; Microsoft.Management.Infrastructure sucks in not only the same ways that System.Management does, but also requires a very specificRuntimeIdentifier
.The text was updated successfully, but these errors were encountered: