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
Describe the solution you'd like
This was something I thought I looked at before, but for some reason I can't find any notes. Anyway...
C# 11 added static abstract members in interfaces, or SAMIs. Part of the reason I didn't try to support it originally is that the attributes were generic, and you can't pass interfaces to type parameters that contain SAMIs. However, with the open generics feature implemented, I now have attributes that expect a Type to be passed in (typically with typeof(...)). That means I could add support for SAMIs, but there are a number of things to consider:
The mock type has to be public when SAMIs exist. This....shouldn't be problematic, but need to ensure that there are no name duplications. I may be able to narrow this down somewhat if we have SAMIs that are not operators, then the type will be made public (or maybe just internal). Rationale here is that if you're implementing an interface with just operators (like IAdditionOperators<,,> - https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditionOperators.cs,67cc175feb3d46df), I don't think there's a need to expose the mock type in that case.
If tests are run in parallel, some kind of mechanism needs to be put in place to ensure expectations on a static member work as expected. Using AsyncLocal<>may help here, though I need to do a POC outside of Rocks in testing frameworks to see if this would work.
Related to the previous point, I may need to make expectations disposable. The reason why is that I may need a context to clear out any underlying mechanism with expectations on static members, and having a Dispose() method may do the trick.
I may need to add an Operators "section" to the gen-d code, similar to what I do with Methods, Properties, and Indexers.
Describe alternatives you've considered
Leave things as-is
The text was updated successfully, but these errors were encountered:
Describe the solution you'd like
This was something I thought I looked at before, but for some reason I can't find any notes. Anyway...
C# 11 added static abstract members in interfaces, or SAMIs. Part of the reason I didn't try to support it originally is that the attributes were generic, and you can't pass interfaces to type parameters that contain SAMIs. However, with the open generics feature implemented, I now have attributes that expect a
Type
to be passed in (typically withtypeof(...)
). That means I could add support for SAMIs, but there are a number of things to consider:public
when SAMIs exist. This....shouldn't be problematic, but need to ensure that there are no name duplications. I may be able to narrow this down somewhat if we have SAMIs that are not operators, then the type will be madepublic
(or maybe justinternal
). Rationale here is that if you're implementing an interface with just operators (likeIAdditionOperators<,,>
- https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditionOperators.cs,67cc175feb3d46df), I don't think there's a need to expose the mock type in that case.AsyncLocal<>
may help here, though I need to do a POC outside of Rocks in testing frameworks to see if this would work.Dispose()
method may do the trick.Operators
"section" to the gen-d code, similar to what I do withMethods
,Properties
, andIndexers
.Describe alternatives you've considered
Leave things as-is
The text was updated successfully, but these errors were encountered: