Commit e78bb77
Fix CS0266 in GetUnitInfo<TQuantity,TUnit> typed overload (#1677)
## Summary
Fixes the Azure Pipelines build failure introduced by #1657:
\`\`\`
error CS0266: Cannot implicitly convert type 'UnitsNet.UnitInfo<TUnit>'
to
'UnitsNet.UnitInfo<TQuantity, TUnit>'
\`\`\`
at
[UnitsNet/Extensions/QuantityExtensions.cs:47](UnitsNet/Extensions/QuantityExtensions.cs:47):
\`\`\`csharp
return quantity.QuantityInfo[quantity.Unit];
\`\`\`
## Why this happens
The receiver is statically `IQuantity<TQuantity, TUnit>`, whose
`QuantityInfo` getter is shadowed (`new`) to return the more specific
`QuantityInfo<TQuantity, TUnit>`. On the hosted Azure Pipelines image's
Roslyn build, member lookup resolves to the inherited
`IQuantity<TUnit>.QuantityInfo` (`QuantityInfo<TUnit>`) instead, so the
indexer returns `UnitInfo<TUnit>` and the conversion to
`UnitInfo<TQuantity, TUnit>` fails. Local builds on newer SDKs happened
to resolve the shadowed member and compiled cleanly, which is why
#1657's CI never tripped on the maintainer's machine.
## Fix
The runtime value is always the more derived type, so cast through
`QuantityInfo<TQuantity, TUnit>` explicitly to surface the typed
indexer. No behavior change.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 700617d commit e78bb77
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
0 commit comments