Skip to content

Commit a46a4c0

Browse files
tmilnthorpangularsen
authored andcommitted
Change extension methods to use generics
Allows for broader use wherever Convert.ToDouble can be used, and also reduces library size significantly.
1 parent a2cad45 commit a46a4c0

File tree

91 files changed

+2163
-21938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2163
-21938
lines changed

UnitsNet/GeneratedCode/Extensions/Number/NumberToAccelerationExtensions.g.cs

+26-338
Large diffs are not rendered by default.

UnitsNet/GeneratedCode/Extensions/Number/NumberToAmountOfSubstanceExtensions.g.cs

+28-364
Large diffs are not rendered by default.

UnitsNet/GeneratedCode/Extensions/Number/NumberToAmplitudeRatioExtensions.g.cs

+8-104
Original file line numberDiff line numberDiff line change
@@ -47,136 +47,40 @@ public static class NumberToAmplitudeRatioExtensions
4747
#region DecibelMicrovolt
4848

4949
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
50-
public static AmplitudeRatio DecibelMicrovolts(this int value) => AmplitudeRatio.FromDecibelMicrovolts(value);
50+
public static AmplitudeRatio DecibelMicrovolts<T>(this T value) => AmplitudeRatio.FromDecibelMicrovolts(Convert.ToDouble(value));
5151

5252
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
53-
public static AmplitudeRatio? DecibelMicrovolts(this int? value) => AmplitudeRatio.FromDecibelMicrovolts(value);
54-
55-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
56-
public static AmplitudeRatio DecibelMicrovolts(this long value) => AmplitudeRatio.FromDecibelMicrovolts(value);
57-
58-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
59-
public static AmplitudeRatio? DecibelMicrovolts(this long? value) => AmplitudeRatio.FromDecibelMicrovolts(value);
60-
61-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
62-
public static AmplitudeRatio DecibelMicrovolts(this double value) => AmplitudeRatio.FromDecibelMicrovolts(value);
63-
64-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
65-
public static AmplitudeRatio? DecibelMicrovolts(this double? value) => AmplitudeRatio.FromDecibelMicrovolts(value);
66-
67-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
68-
public static AmplitudeRatio DecibelMicrovolts(this float value) => AmplitudeRatio.FromDecibelMicrovolts(value);
69-
70-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
71-
public static AmplitudeRatio? DecibelMicrovolts(this float? value) => AmplitudeRatio.FromDecibelMicrovolts(value);
72-
73-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
74-
public static AmplitudeRatio DecibelMicrovolts(this decimal value) => AmplitudeRatio.FromDecibelMicrovolts(Convert.ToDouble(value));
75-
76-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMicrovolts(UnitsNet.QuantityValue)" />
77-
public static AmplitudeRatio? DecibelMicrovolts(this decimal? value) => AmplitudeRatio.FromDecibelMicrovolts(value == null ? (double?)null : Convert.ToDouble(value.Value));
53+
public static AmplitudeRatio? DecibelMicrovolts<T>(this T? value) where T : struct => AmplitudeRatio.FromDecibelMicrovolts(value == null ? (double?)null : Convert.ToDouble(value.Value));
7854

7955
#endregion
8056

8157
#region DecibelMillivolt
8258

8359
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
84-
public static AmplitudeRatio DecibelMillivolts(this int value) => AmplitudeRatio.FromDecibelMillivolts(value);
85-
86-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
87-
public static AmplitudeRatio? DecibelMillivolts(this int? value) => AmplitudeRatio.FromDecibelMillivolts(value);
88-
89-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
90-
public static AmplitudeRatio DecibelMillivolts(this long value) => AmplitudeRatio.FromDecibelMillivolts(value);
91-
92-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
93-
public static AmplitudeRatio? DecibelMillivolts(this long? value) => AmplitudeRatio.FromDecibelMillivolts(value);
94-
95-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
96-
public static AmplitudeRatio DecibelMillivolts(this double value) => AmplitudeRatio.FromDecibelMillivolts(value);
97-
98-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
99-
public static AmplitudeRatio? DecibelMillivolts(this double? value) => AmplitudeRatio.FromDecibelMillivolts(value);
100-
101-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
102-
public static AmplitudeRatio DecibelMillivolts(this float value) => AmplitudeRatio.FromDecibelMillivolts(value);
103-
104-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
105-
public static AmplitudeRatio? DecibelMillivolts(this float? value) => AmplitudeRatio.FromDecibelMillivolts(value);
106-
107-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
108-
public static AmplitudeRatio DecibelMillivolts(this decimal value) => AmplitudeRatio.FromDecibelMillivolts(Convert.ToDouble(value));
60+
public static AmplitudeRatio DecibelMillivolts<T>(this T value) => AmplitudeRatio.FromDecibelMillivolts(Convert.ToDouble(value));
10961

11062
/// <inheritdoc cref="AmplitudeRatio.FromDecibelMillivolts(UnitsNet.QuantityValue)" />
111-
public static AmplitudeRatio? DecibelMillivolts(this decimal? value) => AmplitudeRatio.FromDecibelMillivolts(value == null ? (double?)null : Convert.ToDouble(value.Value));
63+
public static AmplitudeRatio? DecibelMillivolts<T>(this T? value) where T : struct => AmplitudeRatio.FromDecibelMillivolts(value == null ? (double?)null : Convert.ToDouble(value.Value));
11264

11365
#endregion
11466

11567
#region DecibelUnloaded
11668

11769
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
118-
public static AmplitudeRatio DecibelsUnloaded(this int value) => AmplitudeRatio.FromDecibelsUnloaded(value);
70+
public static AmplitudeRatio DecibelsUnloaded<T>(this T value) => AmplitudeRatio.FromDecibelsUnloaded(Convert.ToDouble(value));
11971

12072
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
121-
public static AmplitudeRatio? DecibelsUnloaded(this int? value) => AmplitudeRatio.FromDecibelsUnloaded(value);
122-
123-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
124-
public static AmplitudeRatio DecibelsUnloaded(this long value) => AmplitudeRatio.FromDecibelsUnloaded(value);
125-
126-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
127-
public static AmplitudeRatio? DecibelsUnloaded(this long? value) => AmplitudeRatio.FromDecibelsUnloaded(value);
128-
129-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
130-
public static AmplitudeRatio DecibelsUnloaded(this double value) => AmplitudeRatio.FromDecibelsUnloaded(value);
131-
132-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
133-
public static AmplitudeRatio? DecibelsUnloaded(this double? value) => AmplitudeRatio.FromDecibelsUnloaded(value);
134-
135-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
136-
public static AmplitudeRatio DecibelsUnloaded(this float value) => AmplitudeRatio.FromDecibelsUnloaded(value);
137-
138-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
139-
public static AmplitudeRatio? DecibelsUnloaded(this float? value) => AmplitudeRatio.FromDecibelsUnloaded(value);
140-
141-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
142-
public static AmplitudeRatio DecibelsUnloaded(this decimal value) => AmplitudeRatio.FromDecibelsUnloaded(Convert.ToDouble(value));
143-
144-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelsUnloaded(UnitsNet.QuantityValue)" />
145-
public static AmplitudeRatio? DecibelsUnloaded(this decimal? value) => AmplitudeRatio.FromDecibelsUnloaded(value == null ? (double?)null : Convert.ToDouble(value.Value));
73+
public static AmplitudeRatio? DecibelsUnloaded<T>(this T? value) where T : struct => AmplitudeRatio.FromDecibelsUnloaded(value == null ? (double?)null : Convert.ToDouble(value.Value));
14674

14775
#endregion
14876

14977
#region DecibelVolt
15078

15179
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
152-
public static AmplitudeRatio DecibelVolts(this int value) => AmplitudeRatio.FromDecibelVolts(value);
153-
154-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
155-
public static AmplitudeRatio? DecibelVolts(this int? value) => AmplitudeRatio.FromDecibelVolts(value);
156-
157-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
158-
public static AmplitudeRatio DecibelVolts(this long value) => AmplitudeRatio.FromDecibelVolts(value);
159-
160-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
161-
public static AmplitudeRatio? DecibelVolts(this long? value) => AmplitudeRatio.FromDecibelVolts(value);
162-
163-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
164-
public static AmplitudeRatio DecibelVolts(this double value) => AmplitudeRatio.FromDecibelVolts(value);
165-
166-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
167-
public static AmplitudeRatio? DecibelVolts(this double? value) => AmplitudeRatio.FromDecibelVolts(value);
168-
169-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
170-
public static AmplitudeRatio DecibelVolts(this float value) => AmplitudeRatio.FromDecibelVolts(value);
171-
172-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
173-
public static AmplitudeRatio? DecibelVolts(this float? value) => AmplitudeRatio.FromDecibelVolts(value);
174-
175-
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
176-
public static AmplitudeRatio DecibelVolts(this decimal value) => AmplitudeRatio.FromDecibelVolts(Convert.ToDouble(value));
80+
public static AmplitudeRatio DecibelVolts<T>(this T value) => AmplitudeRatio.FromDecibelVolts(Convert.ToDouble(value));
17781

17882
/// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(UnitsNet.QuantityValue)" />
179-
public static AmplitudeRatio? DecibelVolts(this decimal? value) => AmplitudeRatio.FromDecibelVolts(value == null ? (double?)null : Convert.ToDouble(value.Value));
83+
public static AmplitudeRatio? DecibelVolts<T>(this T? value) where T : struct => AmplitudeRatio.FromDecibelVolts(value == null ? (double?)null : Convert.ToDouble(value.Value));
18084

18185
#endregion
18286

0 commit comments

Comments
 (0)