Version: 0.11
meta:
id: csharp_optionalcast
endian: le
seq:
- id: version
type: u1
- id: cnt_old
type: s1
if: version <= 96
- id: cnt_new
type: b12
if: version > 96
instances:
count:
value: |
version <= 96 ? cnt_old : cnt_new
Generates
_count = (int) ((Version <= 96 ? CntOld : CntNew));
Where
private sbyte? _cntOld;
private ulong? _cntNew;
with errors:
error CS0029: Cannot implicitly convert type 'sbyte?' to 'int'
error CS0029: Cannot implicitly convert type 'ulong?' to 'int'
Similarly, same issue if a b1 is used as a secondary condition where the condition for the b1 existing is the same as the first condition, i.e.
meta:
id: csharp_optionalcast
endian: le
seq:
- id: version
type: u1
- id: has_more
type: b1
if: version > 96
- id: more
type: b2
if: version > 96
- id: old_stuff
type: u1
if: version <= 96
instances:
count:
value: |
version <= 96 ? old_stuff :
has_more ? more + 99 : more
Version: 0.11
Generates
Where
with errors:
Similarly, same issue if a
b1is used as a secondary condition where the condition for the b1 existing is the same as the first condition, i.e.