I have the following code:
bool CheckStream(Stream stream) =>
stream.CanSeek && stream.Length < 42;
I want to change it to:
bool CheckStream(Stream stream) =>
stream is { CanSeek: true, Length < 42 };
Now I wonder, it this save? Meaning, is CanSeek evaluated before length in the property pattern? Because if not, it could throw a "NotSupportedException".
Can I expect property pattern always to be evaluated from left to right?
PS: When I tried it in C# Interactive it worked. And it throws the Exception, if I put Length: < 42 before CanSeek: true. But I wondered if this is defined this way. I didn't found anything about that. If not, I think it would be possible that the code behaves different after optimization.