You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider (perhaps large) C structures received from native code and used in .NET via generated PInvoke bindings. If the structure contains padding bytes, the default equality comparison logic for ValueTypes will fallback to an inefficient implementation using runtime reflection for each struct field, not to mention boxing due to the signature of the Equals() method accepting object arguments. We would like ClangSharpPInvokeGenerator to conditionally generate IEquattable implementations for us.
I am aware that generated code uses partial annotation and so we can add IEquattable implementation ourselves, but that leaves a possibility of it getting out of sync with the generated code if new members are ever added in the future.
The text was updated successfully, but these errors were encountered:
Can you give some examples where types are being used in scenarios where equality like that is required?
It's not always valid to do element-wise comparisons and there are many C struct definitions where there is an explicitly equality method exported that you're meant to use instead.
So far this has been left off as a very niche scenario where generating it by default for all types would be likely undesirable.
Can you give some examples where types are being used in scenarios where equality like that is required?
Inside System.Net.Quic, we need to construct MsQuicConfiguration objects, the construction is expensive and those objects are expected to be reused across connections. To do this transparently, we cache these objects and one of the keys to the cache is the QUIC_SETTINGS struct
Consider (perhaps large) C structures received from native code and used in .NET via generated PInvoke bindings. If the structure contains padding bytes, the default equality comparison logic for
ValueType
s will fallback to an inefficient implementation using runtime reflection for each struct field, not to mention boxing due to the signature of the Equals() method acceptingobject
arguments. We would like ClangSharpPInvokeGenerator to conditionally generate IEquattable implementations for us.I am aware that generated code uses
partial
annotation and so we can add IEquattable implementation ourselves, but that leaves a possibility of it getting out of sync with the generated code if new members are ever added in the future.The text was updated successfully, but these errors were encountered: