From ee21027224885df2edf54f98401fb8a488a0f8b5 Mon Sep 17 00:00:00 2001 From: GrahamTheCoder Date: Sat, 24 Feb 2024 16:43:38 +0000 Subject: [PATCH] Cater net 45 and non-compiling solutions --- .../CSharp/BuiltInVisualBasicOperatorSubstitutions.cs | 2 +- CodeConverter/CSharp/CommonConversions.cs | 2 +- CodeConverter/CSharp/MethodInfoExtensions.cs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CodeConverter/CSharp/BuiltInVisualBasicOperatorSubstitutions.cs b/CodeConverter/CSharp/BuiltInVisualBasicOperatorSubstitutions.cs index ca69b7ed8..17bae7940 100644 --- a/CodeConverter/CSharp/BuiltInVisualBasicOperatorSubstitutions.cs +++ b/CodeConverter/CSharp/BuiltInVisualBasicOperatorSubstitutions.cs @@ -472,7 +472,7 @@ private static bool IsStringType(this ITypeSymbol @this) private static bool IsObjectType(this ITypeSymbol @this) { - return @this.SpecialType == SpecialType.System_Object; + return @this?.SpecialType == SpecialType.System_Object; } private static bool IsDecimalType(this ITypeSymbol @this) diff --git a/CodeConverter/CSharp/CommonConversions.cs b/CodeConverter/CSharp/CommonConversions.cs index d845a012b..4402d5a05 100644 --- a/CodeConverter/CSharp/CommonConversions.cs +++ b/CodeConverter/CSharp/CommonConversions.cs @@ -756,5 +756,5 @@ public bool IsLinqDelegateExpression(VisualBasicSyntaxNode node) return false; } - private bool IsLinqDelegateExpression(ITypeSymbol convertedType) => System_Linq_Expressions_Expression_T.Equals(convertedType?.OriginalDefinition, SymbolEqualityComparer.Default); + private bool IsLinqDelegateExpression(ITypeSymbol convertedType) => System_Linq_Expressions_Expression_T?.Equals(convertedType?.OriginalDefinition, SymbolEqualityComparer.Default) == true; } \ No newline at end of file diff --git a/CodeConverter/CSharp/MethodInfoExtensions.cs b/CodeConverter/CSharp/MethodInfoExtensions.cs index 8f5481b51..5b74fe61d 100644 --- a/CodeConverter/CSharp/MethodInfoExtensions.cs +++ b/CodeConverter/CSharp/MethodInfoExtensions.cs @@ -42,7 +42,9 @@ private static TDesiredFunc CreateOpenInstanceDelegateForcingType( public static MethodInfo ReflectedPropertyGetter(this TInstance instance, string propertyToAccess) { - var propertyInfo = instance.GetType().GetProperty(propertyToAccess, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); + var type = instance.GetType(); + var propertyInfo = type.GetProperty(propertyToAccess, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); + propertyInfo ??= type.ReflectedType?.GetProperty(propertyToAccess, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); return propertyInfo?.GetMethod.GetRuntimeBaseDefinition(); } } \ No newline at end of file