Commit 33104bd
Fix: Cast Enum to integer when assigning to non-convertible types
- Update TypeConversionAnalyzer to only use EnumCastThenConversion if the target type is not an Enum and does not have a defined Conversions.To method.
- Add tests covering the reported issue (implicitly casting Enum to custom struct expecting int) and ensuring Enum-to-Boolean logic remains intact without extra (long) casts.
Co-authored-by: GrahamTheCoder <2490482+GrahamTheCoder@users.noreply.github.com>1 parent 11366b2 commit 33104bd
2 files changed
Lines changed: 35 additions & 3 deletions
File tree
- CodeConverter/CSharp
- Tests/CSharp/ExpressionTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
2931 | 2931 | | |
2932 | 2932 | | |
2933 | 2933 | | |
2934 | | - | |
2935 | 2934 | | |
2936 | 2935 | | |
2937 | 2936 | | |
| |||
2999 | 2998 | | |
3000 | 2999 | | |
3001 | 3000 | | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
3002 | 3022 | | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
0 commit comments