dotnet / dotnet/msbuild

Numeric comparison: 9 < 10 but 16.9 > 16.10

Open
#6,054 6 comments 0 reactions 0 assignees View on GitHub
bug triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

MSBuild seems to recognize integers when using inequality operators with string operands (which is good), but it fails to recognize floating point numbers as numeric, instead treating them like ordinary strings. This leads to unexpected evaluation of the conditionals.

As shown in the repro steps, MSBuild recognizes that `9 < 10`, but fails to recognize that `16.9 < 16.10`. It *does* recognize 4-component versions though, recognizing that `16.9.0.0 < 16.10.0.0`.

### Steps to Reproduce

```xml






```

### Expected Behavior

```
'9' <= '10'
true
'16.9' <= '16.10'
true
'16.9.0.0' <= '16.10.0.0'
true
```

### Actual Behavior

```
'9' <= '10'
true
'16.9' <= '16.10'
'16.9.0.0' <= '16.10.0.0'
true
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.