1
- // Copyright (c) .NET Foundation. All rights reserved.
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System ;
@@ -39,7 +39,7 @@ public HtmlFormattableString(string format, params object[] args)
39
39
/// <param name="formatProvider">An object that provides culture-specific formatting information.</param>
40
40
/// <param name="format">A composite format string.</param>
41
41
/// <param name="args">An array that contains objects to format.</param>
42
- public HtmlFormattableString ( IFormatProvider formatProvider , string format , params object [ ] args )
42
+ public HtmlFormattableString ( IFormatProvider ? formatProvider , string format , params object [ ] args )
43
43
{
44
44
if ( format == null )
45
45
{
@@ -94,7 +94,7 @@ private class EncodingFormatProvider : IFormatProvider, ICustomFormatter
94
94
private readonly HtmlEncoder _encoder ;
95
95
private readonly IFormatProvider _formatProvider ;
96
96
97
- private StringWriter _writer ;
97
+ private StringWriter ? _writer ;
98
98
99
99
public EncodingFormatProvider ( IFormatProvider formatProvider , HtmlEncoder encoder )
100
100
{
@@ -105,7 +105,7 @@ public EncodingFormatProvider(IFormatProvider formatProvider, HtmlEncoder encode
105
105
_encoder = encoder ;
106
106
}
107
107
108
- public string Format ( string format , object arg , IFormatProvider formatProvider )
108
+ public string Format ( string ? format , object ? arg , IFormatProvider ? formatProvider )
109
109
{
110
110
// These are the cases we need to special case. We trust the HtmlString or IHtmlContent instance
111
111
// to do the right thing with encoding.
@@ -118,7 +118,7 @@ public string Format(string format, object arg, IFormatProvider formatProvider)
118
118
var htmlContent = arg as IHtmlContent ;
119
119
if ( htmlContent != null )
120
120
{
121
- _writer = _writer ?? new StringWriter ( ) ;
121
+ _writer ??= new StringWriter ( ) ;
122
122
123
123
htmlContent . WriteTo ( _writer , _encoder ) ;
124
124
@@ -133,7 +133,7 @@ public string Format(string format, object arg, IFormatProvider formatProvider)
133
133
//
134
134
// First check for an ICustomFormatter - if the IFormatProvider is a CultureInfo, then it's likely
135
135
// that ICustomFormatter will be null.
136
- var customFormatter = ( ICustomFormatter ) _formatProvider . GetFormat ( typeof ( ICustomFormatter ) ) ;
136
+ var customFormatter = ( ICustomFormatter ? ) _formatProvider . GetFormat ( typeof ( ICustomFormatter ) ) ;
137
137
if ( customFormatter != null )
138
138
{
139
139
var result = customFormatter . Format ( format , arg , _formatProvider ) ;
@@ -170,7 +170,7 @@ public string Format(string format, object arg, IFormatProvider formatProvider)
170
170
return string . Empty ;
171
171
}
172
172
173
- public object GetFormat ( Type formatType )
173
+ public object ? GetFormat ( Type ? formatType )
174
174
{
175
175
if ( formatType == typeof ( ICustomFormatter ) )
176
176
{
0 commit comments