mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 10:35:27 +08:00 
			
		
		
		
	Fallback to using GetConverter if GetIntrinsicConverter doesn't find one.
This commit is contained in:
		
				
					committed by
					
						
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						parent
						
							2be8e8da4e
						
					
				
				
					commit
					8f2a859087
				
			@@ -82,12 +82,17 @@ internal static class TypeConverterHelper
 | 
				
			|||||||
        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = "Feature switches are not currently supported in the analyzer")]
 | 
					        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = "Feature switches are not currently supported in the analyzer")]
 | 
				
			||||||
        static TypeConverter? GetConverter()
 | 
					        static TypeConverter? GetConverter()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!IsGetConverterSupported)
 | 
					            if (IsGetConverterSupported)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return GetIntrinsicConverter(typeof(T));
 | 
					                // Spectre.Console.TypeConverterHelper.IsGetConverterSupported has been set so
 | 
				
			||||||
 | 
					                // fallback to original behavior
 | 
				
			||||||
 | 
					                return TypeDescriptor.GetConverter(typeof(T));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return TypeDescriptor.GetConverter(typeof(T));
 | 
					            // otherwise try and use the intrinsic converter. if we can't find one, then
 | 
				
			||||||
 | 
					            // try and use GetConverter.
 | 
				
			||||||
 | 
					            var intrinsicConverter = GetIntrinsicConverter(typeof(T));
 | 
				
			||||||
 | 
					            return intrinsicConverter ?? TypeDescriptor.GetConverter(typeof(T));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user