Commit 25b0fcc
authored
Add [DebuggerTypeProxy] to generated quantities (#1390)
```
/// <summary>
/// Serves as a debug display proxy for a quantity, providing a convenient way to view various components of the
/// quantity during debugging.
/// </summary>
/// <remarks>
/// This struct provides a structured view of a quantity's components such as abbreviation, unit, value, and convertor
/// during debugging.
/// Each component is represented by a nested struct, which can be expanded in the debugger to inspect its properties.
/// </remarks>
internal readonly struct QuantityDisplay(IQuantity quantity)
```
This is added to all quantities such:
```
[DataContract]
[DebuggerTypeProxy(typeof(QuantityDisplay))]
public readonly partial struct Mass :
```
There are 4 properties visible, each of which can be further expanded:
1. `Abbreviation`: displays the `DefaultAbbreviation` and expands with
the list all abbreviations for the current unit, also holds a property
with the possible unit conversions (displaying the target abbreviation
in the `ConvertedQuantity[]`)
2. `Unit`: displays the `Unit` such as `Milligram` and expands to the
list of other options, where every other options expands to the
respective `ConvertedQuantity` (much like a _smart enum_).
3. `Value`: displays the `DoubleValue` by default and expands with the
`IsDecimal`, `DecimalValue` and `DoubleValue` properties
4. `ValueConversions`: displays the output of the `QuantityToString` by
default and expands with the list of possible QuantityToString options
(currently only has the `GeneralFormat` and `ShortFormat` properties) as
well as the list of possible unit conversions (`ConvertedQuantity[]`)
Note that I've had to carefully pick the property names such that they
are sorted (more or less) how I wanted, as visual studio sorts them
alphabetically, not by the order of declaration. Perhaps there (is /
would one day be) an option to change that behavior but, yeah- that's it
for now.
I've only tested this with Visual Studio 2022 - but i don't see why
there should by any issues with the other IDEs. I did observe that not
all things are always displayed on net48 (sometimes there is the
_"..requires thread to complete..").





If we open the visualizer view with the list from the `QuantityToUnit`
we get a nice little table:
1 parent cecef38 commit 25b0fcc
File tree
126 files changed
+393
-0
lines changed- CodeGen/Generators/UnitsNetGen
- UnitsNet
- GeneratedCode/Quantities
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
126 files changed
+393
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments