Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed all build warnings #53

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Label="Disabled Warnings">
<!-- We get this meaningless warning because we have the same files shared in multiple projects -->
<NoWarn Label="Type conflicts with imported type">$(NoWarn);CS0436</NoWarn>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion src/ICU4N.Collation/Text/RuleBasedCollator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace ICU4N.Text
/// <remarks>
/// Create a <see cref="RuleBasedCollator"/> from a locale by calling the <see cref="Collator.GetInstance(System.Globalization.CultureInfo)"/> factory method in the base class
/// <see cref="Collator"/>. <see cref="Collator.GetInstance(System.Globalization.CultureInfo)"/> creates a <see cref="RuleBasedCollator"/> object based on the collation rules defined by the
/// argument locale. If a customized collation ordering or attributes is required, use the <see cref="RuleBasedCollator(string)"/>
/// argument locale. If a customized collation ordering or attributes is required, use the <see cref="RuleBasedCollator.RuleBasedCollator(string)"/>
/// constructor with the appropriate rules. The customized <see cref="RuleBasedCollator"/> will base its ordering on the CLDR root collation, while
/// re-adjusting the attributes and orders of the characters in the specified rule accordingly.
/// <para/>
Expand Down
16 changes: 8 additions & 8 deletions src/ICU4N/Impl/PluralRulesLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ public override UCultureInfo GetFunctionalEquivalent(UCultureInfo locale, out bo
public override UCultureInfo GetFunctionalEquivalent(UCultureInfo locale) // ICU4N specific: Added overload so we don't need to pass a null parameter
#pragma warning restore CS0672 // Type or member is obsolete
{
string rulesId = GetRulesIdForLocale(locale, PluralType.Cardinal);
string? rulesId = GetRulesIdForLocale(locale, PluralType.Cardinal);
if (rulesId is null || rulesId.Trim().Length == 0)
{
return UCultureInfo.InvariantCulture; // ultimate fallback
}

if (!RulesIdToEquivalentULocaleMap.TryGetValue(rulesId, out UCultureInfo result) || result is null)
if (!RulesIdToEquivalentULocaleMap.TryGetValue(rulesId, out UCultureInfo? result) || result is null)
{
return UCultureInfo.InvariantCulture; // ultimate fallback
}
Expand All @@ -100,7 +100,7 @@ public override UCultureInfo GetFunctionalEquivalent(UCultureInfo locale) // ICU
private IDictionary<string, string> GetLocaleIdToRulesIdMap(PluralType type)
{
CheckBuildRulesIdMaps();
return (type == PluralType.Cardinal) ? localeIdToCardinalRulesId : localeIdToOrdinalRulesId;
return (type == PluralType.Cardinal) ? localeIdToCardinalRulesId! : localeIdToOrdinalRulesId!;
}

/// <summary>
Expand All @@ -111,7 +111,7 @@ private IDictionary<string, UCultureInfo> RulesIdToEquivalentULocaleMap
get
{
CheckBuildRulesIdMaps();
return rulesIdToEquivalentULocale;
return rulesIdToEquivalentULocale!;
}
}

Expand Down Expand Up @@ -551,8 +551,8 @@ private static IDictionary<string, PluralRanges> LoadLocaleIdToPluralRanges()
new string[] {"other", "other", "other"},
};
#pragma warning disable 612, 618
PluralRanges pr = null;
string[] locales = null;
PluralRanges? pr = null;
string[]? locales = null;
IDictionary<string, PluralRanges> tempLocaleIdToPluralRanges = new Dictionary<string, PluralRanges>();
#pragma warning restore 612, 618
foreach (string[] row in pluralRangeData)
Expand Down Expand Up @@ -580,14 +580,14 @@ private static IDictionary<string, PluralRanges> LoadLocaleIdToPluralRanges()
StandardPluralUtil.TryFromString(row[1], out StandardPlural end);
StandardPluralUtil.TryFromString(row[2], out StandardPlural result);
#pragma warning disable 612, 618
pr.Add(start, end, result);
pr!.Add(start, end, result);
#pragma warning restore 612, 618
}
}
// do last one
foreach (string locale in locales!)
{
tempLocaleIdToPluralRanges[locale] = pr;
tempLocaleIdToPluralRanges[locale] = pr!;
}
// now make whole thing immutable
#if FEATURE_IDICTIONARY_ASREADONLY
Expand Down
10 changes: 9 additions & 1 deletion src/ICU4N/Impl/RuleCharacterIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ public enum RuleCharacterIteratorOptions
/// its value. Variables are parsed using the <see cref="SymbolTable"/> API.
/// </summary>
ParseVariables = 1,
#if FEATURE_SPAN
/// <summary>
/// Bitmask option to enable parsing of escape sequences. If (options &amp;
/// <see cref="ParseEscapes"/> != 0, then an embedded escape sequence will be expanded
/// to its value. Escapes are parsed using <see cref="Utility.UnescapeAt(string, int[])"/>.
/// to its value. Escapes are parsed using <see cref="Utility.UnescapeAt(ReadOnlySpan{char}, ref int)"/>.
/// </summary>
#else
/// <summary>
/// Bitmask option to enable parsing of escape sequences. If (options &amp;
/// <see cref="ParseEscapes"/> != 0, then an embedded escape sequence will be expanded
/// to its value. Escapes are parsed using <see cref="Utility.UnescapeAt(string, ref int)"/>.
/// </summary>
#endif
ParseEscapes = 2,
/// <summary>
/// Bitmask option to enable skipping of whitespace. If (options &amp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public Capitalization Capitalization
/// </summary>
/// <draft>ICU 60.1</draft>
public NumberFormatRules SpellOut
=> LazyInitializer.EnsureInitialized(ref spellOut, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.SpellOut));
=> LazyInitializer.EnsureInitialized(ref spellOut, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.SpellOut))!;

/// <summary>
/// Gets the ordinal <see cref="NumberFormatRules"/> instance for the rule-based number formatter
/// that attaches an ordinal suffix from the desired language to the end of the number (e.g. "123rd").
/// </summary>
/// <draft>ICU 60.1</draft>
public NumberFormatRules Ordinal
=> LazyInitializer.EnsureInitialized(ref ordinal, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.Ordinal));
=> LazyInitializer.EnsureInitialized(ref ordinal, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.Ordinal))!;

/// <summary>
/// Gets the duration <see cref="NumberFormatRules"/> instance for the rule-based number formatter
Expand All @@ -61,7 +61,7 @@ public NumberFormatRules Ordinal
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] // ICU4N TODO: Do we need this? We have TimeSpan.ToString() which seems to cover. Need research.
public NumberFormatRules Duration
=> LazyInitializer.EnsureInitialized(ref duration, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.Duration));
=> LazyInitializer.EnsureInitialized(ref duration, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.Duration))!;

/// <summary>
/// Gets the numbering system <see cref="NumberFormatRules"/> instance for the rule-based number formatter
Expand All @@ -70,7 +70,7 @@ public NumberFormatRules Duration
/// </summary>
/// <draft>ICU 60.1</draft>
public NumberFormatRules NumberingSystem
=> LazyInitializer.EnsureInitialized(ref numberingSystem, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.NumberingSystem));
=> LazyInitializer.EnsureInitialized(ref numberingSystem, () => NumberFormatRules.GetInstance(CultureData.name, NumberPresentation.NumberingSystem))!;
#endif

}
Expand Down
2 changes: 1 addition & 1 deletion src/ICU4N/Support/Globalization/UNumberFormatInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public UNumberFormatInfo()
internal UNumberFormatInfo(UCultureData cultureData)
{
Debug.Assert(cultureData != null);
cultureData.GetNFIValues(this);
cultureData!.GetNFIValues(this);
this.cultureData = cultureData;
}

Expand Down