mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-01 01:25:27 +08:00 
			
		
		
		
	fix some nullability issues
This commit is contained in:
		 Simon Cropp
					Simon Cropp
				
			
				
					committed by
					
						 Patrik Svensson
						Patrik Svensson
					
				
			
			
				
	
			
			
			 Patrik Svensson
						Patrik Svensson
					
				
			
						parent
						
							79742ce9e3
						
					
				
				
					commit
					e71db7f78c
				
			| @@ -34,11 +34,6 @@ namespace Spectre.Console | |||||||
|  |  | ||||||
|         private static void Render(IAnsiConsole console, RenderContext options, IEnumerable<IRenderable> renderables) |         private static void Render(IAnsiConsole console, RenderContext options, IEnumerable<IRenderable> renderables) | ||||||
|         { |         { | ||||||
|             if (renderables is null) |  | ||||||
|             { |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             var result = new List<Segment>(); |             var result = new List<Segment>(); | ||||||
|             foreach (var renderable in renderables) |             foreach (var renderable in renderables) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ namespace Spectre.Console | |||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="text">The text to escape.</param> |         /// <param name="text">The text to escape.</param> | ||||||
|         /// <returns>A string that is safe to use in markup.</returns> |         /// <returns>A string that is safe to use in markup.</returns> | ||||||
|         public static string EscapeMarkup(this string text) |         public static string EscapeMarkup(this string? text) | ||||||
|         { |         { | ||||||
|             if (text == null) |             if (text == null) | ||||||
|             { |             { | ||||||
| @@ -45,7 +45,7 @@ namespace Spectre.Console | |||||||
|             return Cell.GetCellLength(context, text); |             return Cell.GetCellLength(context, text); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         internal static string Capitalize(this string text, CultureInfo? culture = null) |         internal static string Capitalize(this string? text, CultureInfo? culture = null) | ||||||
|         { |         { | ||||||
|             if (text == null) |             if (text == null) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -96,11 +96,6 @@ namespace Spectre.Console | |||||||
|                 throw new ArgumentNullException(nameof(style)); |                 throw new ArgumentNullException(nameof(style)); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (source is null) |  | ||||||
|             { |  | ||||||
|                 return style; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             var current = style; |             var current = style; | ||||||
|             foreach (var item in source) |             foreach (var item in source) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -53,10 +53,7 @@ namespace Spectre.Console.Internal | |||||||
|             var totalRemaining = total; |             var totalRemaining = total; | ||||||
|             var distributedTotal = new List<int>(); |             var distributedTotal = new List<int>(); | ||||||
|  |  | ||||||
|             if (minimums == null) |             minimums ??= ratios.Select(_ => 0).ToList(); | ||||||
|             { |  | ||||||
|                 minimums = ratios.Select(_ => 0).ToList(); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             foreach (var (ratio, minimum) in ratios.Zip(minimums, (a, b) => (a, b))) |             foreach (var (ratio, minimum) in ratios.Zip(minimums, (a, b) => (a, b))) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -72,10 +72,7 @@ namespace Spectre.Console.Internal | |||||||
|                 var decoration = DecorationTable.GetDecoration(part); |                 var decoration = DecorationTable.GetDecoration(part); | ||||||
|                 if (decoration != null) |                 if (decoration != null) | ||||||
|                 { |                 { | ||||||
|                     if (effectiveDecoration == null) |                     effectiveDecoration ??= Decoration.None; | ||||||
|                     { |  | ||||||
|                         effectiveDecoration = Decoration.None; |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     effectiveDecoration |= decoration.Value; |                     effectiveDecoration |= decoration.Value; | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -469,7 +469,7 @@ namespace Spectre.Console.Rendering | |||||||
|         /// <param name="segment">The segment to truncate.</param> |         /// <param name="segment">The segment to truncate.</param> | ||||||
|         /// <param name="maxWidth">The maximum width that the segment may occupy.</param> |         /// <param name="maxWidth">The maximum width that the segment may occupy.</param> | ||||||
|         /// <returns>A new truncated segment, or <c>null</c>.</returns> |         /// <returns>A new truncated segment, or <c>null</c>.</returns> | ||||||
|         public static Segment? Truncate(RenderContext context, Segment segment, int maxWidth) |         public static Segment? Truncate(RenderContext context, Segment? segment, int maxWidth) | ||||||
|         { |         { | ||||||
|             if (context is null) |             if (context is null) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -127,10 +127,7 @@ namespace Spectre.Console | |||||||
|             lock (_lock) |             lock (_lock) | ||||||
|             { |             { | ||||||
|                 var now = DateTime.Now; |                 var now = DateTime.Now; | ||||||
|                 if (StartTime == null) |                 StartTime ??= now; | ||||||
|                 { |  | ||||||
|                     StartTime = now; |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 StopTime = now; |                 StopTime = now; | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user