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
{{ message }}
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
Accidentally during memory profiling of our app, I've discovered that contracts for IDictionary https://github.com/Microsoft/CodeContracts/blob/master/Microsoft.Research/Contracts/MsCorlib/System.Collections.Generic.IDictionary.cs
Contains a lot of contracts like Contract.Requires(!ReferenceEquals(key, null));
and this lead to boxing of a value type keys (e.g. keys like ints, Guids are quite common) and performance penalties. Looks like a bug.
I suspect that those contracts should be more clever than that and consider that generic type could be a ValueType and such check does not make sense at all.
In the meantime I need a workaround: Is it possible to ask somehow code contracts rewriter do not use contracts for implemented interfaces? Some way to ignore them for a specific type only?
The text was updated successfully, but these errors were encountered:
IIRC there's an attribute you can apply to your specific types to tell the rewriter to ignore it. I forget the specifics, I think it's covered in the manual.
Accidentally during memory profiling of our app, I've discovered that contracts for IDictionary
https://github.com/Microsoft/CodeContracts/blob/master/Microsoft.Research/Contracts/MsCorlib/System.Collections.Generic.IDictionary.cs
Contains a lot of contracts like
Contract.Requires(!ReferenceEquals(key, null));
and this lead to boxing of a value type keys (e.g. keys like ints, Guids are quite common) and performance penalties. Looks like a bug.
I suspect that those contracts should be more clever than that and consider that generic type could be a ValueType and such check does not make sense at all.
In the meantime I need a workaround: Is it possible to ask somehow code contracts rewriter do not use contracts for implemented interfaces? Some way to ignore them for a specific type only?
The text was updated successfully, but these errors were encountered: