Skip to content

Commit 00d46d3

Browse files
committed
Fix WRC compile errors
Fix build warns about xmldoc
1 parent 03af845 commit 00d46d3

9 files changed

+146
-83
lines changed

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.WindowsRuntimeComponent.g.cs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
// THE SOFTWARE.
3737

3838
using System;
39+
using System.Globalization;
3940
using System.Linq;
4041
using JetBrains.Annotations;
4142
using UnitsNet.Units;
@@ -51,7 +52,7 @@ namespace UnitsNet
5152
// Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components
5253
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5354
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
54-
public sealed partial class Information
55+
public sealed partial class Information : IQuantity
5556
{
5657
/// <summary>
5758
/// The numeric value this quantity was constructed with.
@@ -308,8 +309,8 @@ public static string GetAbbreviation(InformationUnit unit)
308309
/// Get unit abbreviation string.
309310
/// </summary>
310311
/// <param name="unit">Unit to get abbreviation for.</param>
311-
/// <param name="provider">Format to use for localization. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
312312
/// <returns>Unit abbreviation string.</returns>
313+
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
313314
public static string GetAbbreviation(InformationUnit unit, [CanBeNull] string cultureName)
314315
{
315316
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
@@ -729,6 +730,8 @@ public static bool TryParseUnit(string str, out InformationUnit unit)
729730
/// </example>
730731
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
731732
public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out InformationUnit unit)
733+
{
734+
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
732735
return TryParseUnitInternal(str, provider, out unit);
733736
}
734737

@@ -777,7 +780,7 @@ private static Information ParseInternal(string str, [CanBeNull] IFormatProvider
777780
/// </example>
778781
private static bool TryParseInternal([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Information result)
779782
{
780-
result = default(Information);
783+
result = default;
781784

782785
if(string.IsNullOrWhiteSpace(str))
783786
return false;
@@ -845,26 +848,6 @@ private static bool TryParseUnitInternal(string str, IFormatProvider provider, o
845848

846849
#region Equality / IComparable
847850

848-
public static bool operator <=(Information left, Information right)
849-
{
850-
return left.Value <= right.AsBaseNumericType(left.Unit);
851-
}
852-
853-
public static bool operator >=(Information left, Information right)
854-
{
855-
return left.Value >= right.AsBaseNumericType(left.Unit);
856-
}
857-
858-
public static bool operator <(Information left, Information right)
859-
{
860-
return left.Value < right.AsBaseNumericType(left.Unit);
861-
}
862-
863-
public static bool operator >(Information left, Information right)
864-
{
865-
return left.Value > right.AsBaseNumericType(left.Unit);
866-
}
867-
868851
public int CompareTo(object obj)
869852
{
870853
if(obj is null) throw new ArgumentNullException(nameof(obj));
@@ -1077,7 +1060,7 @@ public string ToString(InformationUnit unit)
10771060
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
10781061
public string ToString(InformationUnit unit, [CanBeNull] string cultureName)
10791062
{
1080-
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
1063+
var provider = cultureName;
10811064
return ToString(unit, provider, 2);
10821065
}
10831066

@@ -1090,6 +1073,7 @@ public string ToString(InformationUnit unit, [CanBeNull] string cultureName)
10901073
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
10911074
public string ToString(InformationUnit unit, [CanBeNull] string cultureName, int significantDigitsAfterRadix)
10921075
{
1076+
var provider = cultureName;
10931077
double value = As(unit);
10941078
string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
10951079
return ToString(unit, provider, format);
@@ -1105,6 +1089,7 @@ public string ToString(InformationUnit unit, [CanBeNull] string cultureName, int
11051089
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
11061090
public string ToString(InformationUnit unit, [CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args)
11071091
{
1092+
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
11081093
if (format == null) throw new ArgumentNullException(nameof(format));
11091094
if (args == null) throw new ArgumentNullException(nameof(args));
11101095

@@ -1116,6 +1101,7 @@ public string ToString(InformationUnit unit, [CanBeNull] string cultureName, [No
11161101
}
11171102

11181103
#endregion
1104+
11191105
private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName)
11201106
{
11211107
return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null;

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.WindowsRuntimeComponent.g.cs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
// THE SOFTWARE.
3737

3838
using System;
39+
using System.Globalization;
3940
using System.Linq;
4041
using JetBrains.Annotations;
4142
using UnitsNet.Units;
@@ -51,7 +52,7 @@ namespace UnitsNet
5152
// Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components
5253
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5354
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
54-
public sealed partial class Length
55+
public sealed partial class Length : IQuantity
5556
{
5657
/// <summary>
5758
/// The numeric value this quantity was constructed with.
@@ -288,8 +289,8 @@ public static string GetAbbreviation(LengthUnit unit)
288289
/// Get unit abbreviation string.
289290
/// </summary>
290291
/// <param name="unit">Unit to get abbreviation for.</param>
291-
/// <param name="provider">Format to use for localization. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
292292
/// <returns>Unit abbreviation string.</returns>
293+
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
293294
public static string GetAbbreviation(LengthUnit unit, [CanBeNull] string cultureName)
294295
{
295296
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
@@ -669,6 +670,8 @@ public static bool TryParseUnit(string str, out LengthUnit unit)
669670
/// </example>
670671
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
671672
public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LengthUnit unit)
673+
{
674+
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
672675
return TryParseUnitInternal(str, provider, out unit);
673676
}
674677

@@ -717,7 +720,7 @@ private static Length ParseInternal(string str, [CanBeNull] IFormatProvider prov
717720
/// </example>
718721
private static bool TryParseInternal([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Length result)
719722
{
720-
result = default(Length);
723+
result = default;
721724

722725
if(string.IsNullOrWhiteSpace(str))
723726
return false;
@@ -785,26 +788,6 @@ private static bool TryParseUnitInternal(string str, IFormatProvider provider, o
785788

786789
#region Equality / IComparable
787790

788-
public static bool operator <=(Length left, Length right)
789-
{
790-
return left.Value <= right.AsBaseNumericType(left.Unit);
791-
}
792-
793-
public static bool operator >=(Length left, Length right)
794-
{
795-
return left.Value >= right.AsBaseNumericType(left.Unit);
796-
}
797-
798-
public static bool operator <(Length left, Length right)
799-
{
800-
return left.Value < right.AsBaseNumericType(left.Unit);
801-
}
802-
803-
public static bool operator >(Length left, Length right)
804-
{
805-
return left.Value > right.AsBaseNumericType(left.Unit);
806-
}
807-
808791
public int CompareTo(object obj)
809792
{
810793
if(obj is null) throw new ArgumentNullException(nameof(obj));
@@ -1009,7 +992,7 @@ public string ToString(LengthUnit unit)
1009992
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
1010993
public string ToString(LengthUnit unit, [CanBeNull] string cultureName)
1011994
{
1012-
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
995+
var provider = cultureName;
1013996
return ToString(unit, provider, 2);
1014997
}
1015998

@@ -1022,6 +1005,7 @@ public string ToString(LengthUnit unit, [CanBeNull] string cultureName)
10221005
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
10231006
public string ToString(LengthUnit unit, [CanBeNull] string cultureName, int significantDigitsAfterRadix)
10241007
{
1008+
var provider = cultureName;
10251009
double value = As(unit);
10261010
string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
10271011
return ToString(unit, provider, format);
@@ -1037,6 +1021,7 @@ public string ToString(LengthUnit unit, [CanBeNull] string cultureName, int sign
10371021
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
10381022
public string ToString(LengthUnit unit, [CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args)
10391023
{
1024+
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
10401025
if (format == null) throw new ArgumentNullException(nameof(format));
10411026
if (args == null) throw new ArgumentNullException(nameof(args));
10421027

@@ -1048,6 +1033,7 @@ public string ToString(LengthUnit unit, [CanBeNull] string cultureName, [NotNull
10481033
}
10491034

10501035
#endregion
1036+
10511037
private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName)
10521038
{
10531039
return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null;

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.WindowsRuntimeComponent.g.cs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
// THE SOFTWARE.
3737

3838
using System;
39+
using System.Globalization;
3940
using System.Linq;
4041
using JetBrains.Annotations;
4142
using UnitsNet.Units;
@@ -51,7 +52,7 @@ namespace UnitsNet
5152
// Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components
5253
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5354
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
54-
public sealed partial class Level
55+
public sealed partial class Level : IQuantity
5556
{
5657
/// <summary>
5758
/// The numeric value this quantity was constructed with.
@@ -188,8 +189,8 @@ public static string GetAbbreviation(LevelUnit unit)
188189
/// Get unit abbreviation string.
189190
/// </summary>
190191
/// <param name="unit">Unit to get abbreviation for.</param>
191-
/// <param name="provider">Format to use for localization. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
192192
/// <returns>Unit abbreviation string.</returns>
193+
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
193194
public static string GetAbbreviation(LevelUnit unit, [CanBeNull] string cultureName)
194195
{
195196
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
@@ -369,6 +370,8 @@ public static bool TryParseUnit(string str, out LevelUnit unit)
369370
/// </example>
370371
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
371372
public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LevelUnit unit)
373+
{
374+
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
372375
return TryParseUnitInternal(str, provider, out unit);
373376
}
374377

@@ -417,7 +420,7 @@ private static Level ParseInternal(string str, [CanBeNull] IFormatProvider provi
417420
/// </example>
418421
private static bool TryParseInternal([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Level result)
419422
{
420-
result = default(Level);
423+
result = default;
421424

422425
if(string.IsNullOrWhiteSpace(str))
423426
return false;
@@ -485,26 +488,6 @@ private static bool TryParseUnitInternal(string str, IFormatProvider provider, o
485488

486489
#region Equality / IComparable
487490

488-
public static bool operator <=(Level left, Level right)
489-
{
490-
return left.Value <= right.AsBaseNumericType(left.Unit);
491-
}
492-
493-
public static bool operator >=(Level left, Level right)
494-
{
495-
return left.Value >= right.AsBaseNumericType(left.Unit);
496-
}
497-
498-
public static bool operator <(Level left, Level right)
499-
{
500-
return left.Value < right.AsBaseNumericType(left.Unit);
501-
}
502-
503-
public static bool operator >(Level left, Level right)
504-
{
505-
return left.Value > right.AsBaseNumericType(left.Unit);
506-
}
507-
508491
public int CompareTo(object obj)
509492
{
510493
if(obj is null) throw new ArgumentNullException(nameof(obj));
@@ -669,7 +652,7 @@ public string ToString(LevelUnit unit)
669652
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
670653
public string ToString(LevelUnit unit, [CanBeNull] string cultureName)
671654
{
672-
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
655+
var provider = cultureName;
673656
return ToString(unit, provider, 2);
674657
}
675658

@@ -682,6 +665,7 @@ public string ToString(LevelUnit unit, [CanBeNull] string cultureName)
682665
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
683666
public string ToString(LevelUnit unit, [CanBeNull] string cultureName, int significantDigitsAfterRadix)
684667
{
668+
var provider = cultureName;
685669
double value = As(unit);
686670
string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
687671
return ToString(unit, provider, format);
@@ -697,6 +681,7 @@ public string ToString(LevelUnit unit, [CanBeNull] string cultureName, int signi
697681
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
698682
public string ToString(LevelUnit unit, [CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args)
699683
{
684+
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
700685
if (format == null) throw new ArgumentNullException(nameof(format));
701686
if (args == null) throw new ArgumentNullException(nameof(args));
702687

@@ -708,6 +693,7 @@ public string ToString(LevelUnit unit, [CanBeNull] string cultureName, [NotNull]
708693
}
709694

710695
#endregion
696+
711697
private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName)
712698
{
713699
return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null;

0 commit comments

Comments
 (0)