From be73838f49df6715342d9bad6a9b601d311e7841 Mon Sep 17 00:00:00 2001 From: BalajiKris Date: Thu, 8 Jan 2015 12:38:01 -0800 Subject: [PATCH] Better name generation while extracting nullables. In ConditionalAccess Expression ?. if we have a member binding expression, we now use that to get a smart name. If nothing else works and if the original definition is a nullable, we give back the default parameter name (v) we use in for built in types. (changeset 1394509) --- .../Portable/Extensions/ISemanticModelExtensions.cs | 8 ++++++++ .../Portable/Shared/Extensions/ITypeSymbolExtensions.cs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Src/Workspaces/CSharp/Portable/Extensions/ISemanticModelExtensions.cs b/Src/Workspaces/CSharp/Portable/Extensions/ISemanticModelExtensions.cs index 3816b16ee55..928c853e9f2 100644 --- a/Src/Workspaces/CSharp/Portable/Extensions/ISemanticModelExtensions.cs +++ b/Src/Workspaces/CSharp/Portable/Extensions/ISemanticModelExtensions.cs @@ -222,6 +222,14 @@ private static bool CanBindToken(SyntaxToken token) { return ((MemberAccessExpressionSyntax)current).Name.Identifier.ValueText.ToCamelCase(); } + else if (current is MemberBindingExpressionSyntax) + { + return ((MemberBindingExpressionSyntax)current).Name.Identifier.ValueText.ToCamelCase(); + } + else if (current is ConditionalAccessExpressionSyntax) + { + current = ((ConditionalAccessExpressionSyntax)current).WhenNotNull; + } else if (current is CastExpressionSyntax) { current = ((CastExpressionSyntax)current).Expression; diff --git a/Src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs b/Src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs index 8e37a360681..b792e1efd8d 100644 --- a/Src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs +++ b/Src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs @@ -559,7 +559,7 @@ private static string GetParameterName(ITypeSymbol type) return DefaultParameterName; } - if (type.IsSpecialType()) + if (type.IsSpecialType() || type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T) { return DefaultBuiltInParameterName; } -- GitLab