11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
4- #nullable disable warnings
5-
64using System ;
75using System . Collections . Generic ;
86using System . Diagnostics ;
9- using System . Threading . Tasks ;
107using Microsoft . AspNetCore . Components . RenderTree ;
118
129namespace Microsoft . AspNetCore . Components . Rendering
@@ -29,7 +26,7 @@ public sealed class RenderTreeBuilder : IDisposable
2926 private readonly Stack < int > _openElementIndices = new Stack < int > ( ) ;
3027 private RenderTreeFrameType ? _lastNonAttributeFrameType ;
3128 private bool _hasSeenAddMultipleAttributes ;
32- private Dictionary < string , int > _seenAttributeNames ;
29+ private Dictionary < string , int > ? _seenAttributeNames ;
3330
3431 /// <summary>
3532 /// The reserved parameter name used for supplying child content.
@@ -82,23 +79,23 @@ public void CloseElement()
8279 /// </summary>
8380 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
8481 /// <param name="markupContent">Content for the new markup frame.</param>
85- public void AddMarkupContent ( int sequence , string markupContent )
82+ public void AddMarkupContent ( int sequence , string ? markupContent )
8683 => Append ( RenderTreeFrame . Markup ( sequence , markupContent ?? string . Empty ) ) ;
8784
8885 /// <summary>
8986 /// Appends a frame representing text content.
9087 /// </summary>
9188 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
9289 /// <param name="textContent">Content for the new text frame.</param>
93- public void AddContent ( int sequence , string textContent )
90+ public void AddContent ( int sequence , string ? textContent )
9491 => Append ( RenderTreeFrame . Text ( sequence , textContent ?? string . Empty ) ) ;
9592
9693 /// <summary>
9794 /// Appends frames representing an arbitrary fragment of content.
9895 /// </summary>
9996 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
10097 /// <param name="fragment">Content to append.</param>
101- public void AddContent ( int sequence , RenderFragment fragment )
98+ public void AddContent ( int sequence , RenderFragment ? fragment )
10299 {
103100 if ( fragment != null )
104101 {
@@ -118,7 +115,7 @@ public void AddContent(int sequence, RenderFragment fragment)
118115 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
119116 /// <param name="fragment">Content to append.</param>
120117 /// <param name="value">The value used by <paramref name="fragment"/>.</param>
121- public void AddContent < TValue > ( int sequence , RenderFragment < TValue > fragment , TValue value )
118+ public void AddContent < TValue > ( int sequence , RenderFragment < TValue > ? fragment , TValue value )
122119 {
123120 if ( fragment != null )
124121 {
@@ -139,7 +136,7 @@ public void AddContent(int sequence, MarkupString markupContent)
139136 /// </summary>
140137 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
141138 /// <param name="textContent">Content for the new text frame.</param>
142- public void AddContent ( int sequence , object textContent )
139+ public void AddContent ( int sequence , object ? textContent )
143140 => AddContent ( sequence , textContent ? . ToString ( ) ) ;
144141
145142 /// <summary>
@@ -185,7 +182,7 @@ public void AddAttribute(int sequence, string name, bool value)
185182 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
186183 /// <param name="name">The name of the attribute.</param>
187184 /// <param name="value">The value of the attribute.</param>
188- public void AddAttribute ( int sequence , string name , string value )
185+ public void AddAttribute ( int sequence , string name , string ? value )
189186 {
190187 AssertCanAddAttribute ( ) ;
191188 if ( value != null || _lastNonAttributeFrameType == RenderTreeFrameType . Component )
@@ -210,7 +207,7 @@ public void AddAttribute(int sequence, string name, string value)
210207 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
211208 /// <param name="name">The name of the attribute.</param>
212209 /// <param name="value">The value of the attribute.</param>
213- public void AddAttribute ( int sequence , string name , MulticastDelegate value )
210+ public void AddAttribute ( int sequence , string name , MulticastDelegate ? value )
214211 {
215212 AssertCanAddAttribute ( ) ;
216213 if ( value != null || _lastNonAttributeFrameType == RenderTreeFrameType . Component )
@@ -320,7 +317,7 @@ public void AddAttribute<TArgument>(int sequence, string name, EventCallback<TAr
320317 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
321318 /// <param name="name">The name of the attribute.</param>
322319 /// <param name="value">The value of the attribute.</param>
323- public void AddAttribute ( int sequence , string name , object value )
320+ public void AddAttribute ( int sequence , string name , object ? value )
324321 {
325322 // This looks a bit daunting because we need to handle the boxed/object version of all of the
326323 // types that AddAttribute special cases.
@@ -402,7 +399,7 @@ public void AddAttribute(int sequence, in RenderTreeFrame frame)
402399 /// </summary>
403400 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
404401 /// <param name="attributes">A collection of key-value pairs representing attributes.</param>
405- public void AddMultipleAttributes ( int sequence , IEnumerable < KeyValuePair < string , object > > attributes )
402+ public void AddMultipleAttributes ( int sequence , IEnumerable < KeyValuePair < string , object > > ? attributes )
406403 {
407404 // Calling this up-front just to make sure we validate before mutating anything.
408405 AssertCanAddAttribute ( ) ;
@@ -455,7 +452,7 @@ public void SetUpdatesAttributeName(string updatesAttributeName)
455452 /// </summary>
456453 /// <typeparam name="TComponent">The type of the child component.</typeparam>
457454 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
458- public void OpenComponent < TComponent > ( int sequence ) where TComponent : IComponent
455+ public void OpenComponent < TComponent > ( int sequence ) where TComponent : notnull , IComponent
459456 => OpenComponentUnchecked ( sequence , typeof ( TComponent ) ) ;
460457
461458 /// <summary>
@@ -477,7 +474,7 @@ public void OpenComponent(int sequence, Type componentType)
477474 /// Assigns the specified key value to the current element or component.
478475 /// </summary>
479476 /// <param name="value">The value for the key.</param>
480- public void SetKey ( object value )
477+ public void SetKey ( object ? value )
481478 {
482479 if ( value == null )
483480 {
@@ -560,7 +557,7 @@ public void AddElementReferenceCapture(int sequence, Action<ElementReference> el
560557 /// </summary>
561558 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
562559 /// <param name="componentReferenceCaptureAction">An action to be invoked whenever the reference value changes.</param>
563- public void AddComponentReferenceCapture ( int sequence , Action < object > componentReferenceCaptureAction )
560+ public void AddComponentReferenceCapture ( int sequence , Action < object ? > componentReferenceCaptureAction )
564561 {
565562 var parentFrameIndex = GetCurrentParentFrameIndex ( ) ;
566563 if ( ! parentFrameIndex . HasValue )
@@ -640,7 +637,7 @@ public void Clear()
640637
641638 // internal because this should only be used during the post-event tree patching logic
642639 // It's expensive because it involves copying all the subsequent memory in the array
643- internal void InsertAttributeExpensive ( int insertAtIndex , int sequence , string attributeName , object attributeValue )
640+ internal void InsertAttributeExpensive ( int insertAtIndex , int sequence , string attributeName , object ? attributeValue )
644641 {
645642 // Replicate the same attribute omission logic as used elsewhere
646643 if ( ( attributeValue == null ) || ( attributeValue is bool boolValue && ! boolValue ) )
0 commit comments