Skip to content

Commit

Permalink
Nullable: make Object.ToString() return nullable (dotnet/coreclr#23510)
Browse files Browse the repository at this point in the history
Commit migrated from dotnet/coreclr@1cdbdb0
  • Loading branch information
safern committed Mar 28, 2019
1 parent 6712f22 commit f76a66a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Expand Up @@ -25,7 +25,9 @@
<CLSCompliant>true</CLSCompliant>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>649,1573,1591,0419,BCL0020</NoWarn> <!-- Remove BCL0020 once https://github.com/dotnet/arcade/pull/2158 is available -->
<!-- Remove BCL0020 once https://github.com/dotnet/arcade/pull/2158 is available
Remove CS8608 once https://github.com/dotnet/roslyn/issues/23268 is resolved -->
<NoWarn>649,1573,1591,0419,BCL0020,CS8609</NoWarn>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
Expand Down
Expand Up @@ -55,10 +55,10 @@ private static int GetAdvanceHijriDate()
}

int hijriAdvance = 0;
string str = value.ToString();
string? str = value.ToString();
if (string.Compare(str, 0, HijriAdvanceRegKeyEntry, 0, HijriAdvanceRegKeyEntry.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
if (str.Length == HijriAdvanceRegKeyEntry.Length)
if (str!.Length == HijriAdvanceRegKeyEntry.Length)
hijriAdvance = -1;
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/Object.cs
Expand Up @@ -36,7 +36,7 @@ public Object()

// Returns a String which represents the object instance. The default
// for an object is to return the fully qualified name of the class.
public virtual string ToString()
public virtual string? ToString()
{
return GetType().ToString();
}
Expand Down
Expand Up @@ -34,14 +34,7 @@ private static unsafe void FillStringChecked(string dest, int destPos, string sr
}
}

public static string Concat(object? arg0)
{
if (arg0 == null)
{
return string.Empty;
}
return arg0.ToString();
}
public static string Concat(object? arg0) => arg0?.ToString() ?? string.Empty;

public static string Concat(object? arg0, object? arg1)
{
Expand Down

0 comments on commit f76a66a

Please sign in to comment.