Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Nullable: make Object.ToString() return nullable #23510

Merged
merged 1 commit into from
Mar 28, 2019
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
4 changes: 3 additions & 1 deletion src/System.Private.CoreLib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)
safern marked this conversation as resolved.
Show resolved Hide resolved
hijriAdvance = -1;
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/shared/System/Object.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;
safern marked this conversation as resolved.
Show resolved Hide resolved

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