When using bitwise operators on a flags enum, the resulting type is int, but it should be the enum type.
Here's a repro:
namespace DynamicLinqExample {
public class Example {
[Flags]
public enum ExampleFlags {
None = 0,
A = 1,
B = 2,
C = 4,
D = 8,
};
[Fact]
public void FlagsEnumBitwiseOperatorsWrongResultType() {
var query = new[] { 0 }.AsQueryable();
var result1 = query.Select(x => ExampleFlags.A | ExampleFlags.B).First();
Assert.IsType<ExampleFlags>(result1); // <-- succeeds
var result2 = query.Select("@0 | @1", ExampleFlags.A, ExampleFlags.B).First();
Assert.IsType<ExampleFlags>(result2); // <-- fails; type is int
}
}
}
This results in:
Assert.IsType() Failure
Expected: DynamicLinqExample.Example+ExampleFlags
Actual: System.Int32
Thanks!
When using bitwise operators on a flags enum, the resulting type is
int, but it should be the enum type.Here's a repro:
This results in:
Thanks!