Inherit PlatformAttribute#5166
Conversation
Mark the attribute as not allowing multiple instances.
|
Thanks @manfred-brands I'll try to give this a look today before I head on vacation tomorrow. |
|
Thanks @manfred-brands Also, I wanted to double check with you and @OsirisTerje if that is actually what we want for this behaviour, or if both should be factored in. For example, a test suite like this may be a fairly common way to use inheritance for this attribute. Should [Platform("Win")]
public abstract class WindowsTests {}
[Platform("32-Bit")]
public class LegacyWindowsSupport : WindowsTests { }
[Platform("64-Bit")]
public class ModernWindowsSupport : WindowsTests { }
[Platform("Linux")]
public abstract class LinuxTests {}
[Platform("32-Bit")]
public class LegacyLinuxSupport : LinuxTests { }
[Platform("64-Bit")]
public class ModernLinuxSupport : LinuxTests { }I've left this as a "comment" instead of request for changes as I will be away soon, but I think these would be important behaviours to define and maybe even document as part of making this inheritable |
|
@stevenaw Would this not be the same as having multiple Platform attributes? I am actually a bit indifferent to this. We could document the behavior (or restrictions, if that is what this boils down to now) for now, and then consider if we should do something later. |
|
@OsirisTerje I haven't tested the runtime behavior, but from my earlier experimentation that will compile fine since attributes are applied to the type and different levels of an inheritance hierarchy are different types. In other words, my understanding then is that I'm also a bit indifferent as to what we want the behavior to be in that case. I'm mostly just asking to ensure we account for possible use cases and don't introduce unintended behaviors. My understanding is that the example above may need the child classes to duplicate the "Win" in their definitions to be specific to Win32 or Win64. Ex: -[Platform("32-bit")]
+[Platform("Win,32-bit")]I'm also fine to not change that for now so long as we document it. |
stevenaw
left a comment
There was a problem hiding this comment.
Having thought this through a bit more, I'm going to approve this as well. I suspect it's likely anyone seeking a fixture setup similar to the example is already likely duplicating the identifiers given the lack of Inherited support up until now.
I think it might still be helpful to add a test for where the attribute appears twice in a hierarchy in order to proof existing behavior. @manfred-brands I understand your limited bandwidth and I'd be happy to add it myself if it's still needed after I return from travels next week.
Thanks again for your change here
|
Thanks @OsirisTerje |
From my tests I added for In your example it would find |
Ah. Ok thanks for reconfirming @manfred-brands ! I had misunderstood earlier. Glad to hear that's the behavior with |
Fixes #5161
Fixes #4131
Replaces PR #5162 with renamed source branch and retargeted to 4.6
@stevenaw Same code, but with tests that utilize the inheritance of the PlatfromAttribute.