Skip to content

Commit 0dd3152

Browse files
Remove unused
1 parent d5b62f8 commit 0dd3152

1 file changed

Lines changed: 1 addition & 41 deletions

File tree

CodeConverter/CSharp/ExpressionNodeVisitor.cs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
using System.Collections.Immutable;
2-
using System.Data;
3-
using System.Globalization;
4-
using ICSharpCode.CodeConverter.CSharp.Replacements;
5-
using ICSharpCode.CodeConverter.Util.FromRoslyn;
6-
using Microsoft.CodeAnalysis;
1+
using ICSharpCode.CodeConverter.Util.FromRoslyn;
72
using Microsoft.CodeAnalysis.CSharp;
83
using Microsoft.CodeAnalysis.CSharp.Syntax;
94
using Microsoft.CodeAnalysis.Operations;
10-
using Microsoft.CodeAnalysis.Simplification;
11-
using Microsoft.VisualBasic;
125
using Microsoft.VisualBasic.CompilerServices;
13-
using ComparisonKind = ICSharpCode.CodeConverter.CSharp.VisualBasicEqualityComparison.ComparisonKind;
146

157
namespace ICSharpCode.CodeConverter.CSharp;
168

@@ -31,7 +23,6 @@ internal partial class ExpressionNodeVisitor : VBasic.VisualBasicSyntaxVisitor<T
3123
private readonly Stack<ExpressionSyntax> _withBlockLhs = new();
3224
private readonly ITypeContext _typeContext;
3325
private readonly QueryConverter _queryConverter;
34-
private readonly Lazy<IReadOnlyDictionary<ITypeSymbol, string>> _convertMethodsLookupByReturnType;
3526
private readonly LambdaConverter _lambdaConverter;
3627
private readonly Dictionary<string, Stack<(SyntaxNode Scope, string TempName)>> _tempNameForAnonymousScope = new();
3728
private readonly HashSet<string> _generatedNames = new(StringComparer.OrdinalIgnoreCase);
@@ -55,40 +46,9 @@ public ExpressionNodeVisitor(SemanticModel semanticModel,
5546
_argumentConverter = new ArgumentConverter(visualBasicEqualityComparison, typeContext, semanticModel, commonConversions);
5647
_xmlExpressionConverter = new XmlExpressionConverter(xmlImportContext, extraUsingDirectives, TriviaConvertingExpressionVisitor);
5748
_nameExpressionNodeVisitor = new NameExpressionNodeVisitor(semanticModel, _generatedNames, typeContext, extraUsingDirectives, _tempNameForAnonymousScope, _withBlockLhs, commonConversions, _argumentConverter, TriviaConvertingExpressionVisitor);
58-
_visualBasicNullableTypesConverter = visualBasicNullableTypesConverter;
5949
_operatorConverter = VbOperatorConversion.Create(TriviaConvertingExpressionVisitor, semanticModel, visualBasicEqualityComparison, commonConversions.TypeConversionAnalyzer);
6050
_binaryExpressionConverter = new BinaryExpressionConverter(semanticModel, _operatorConverter, visualBasicEqualityComparison, visualBasicNullableTypesConverter, commonConversions);
61-
// If this isn't needed, the assembly with Conversions may not be referenced, so this must be done lazily
62-
_convertMethodsLookupByReturnType =
63-
new Lazy<IReadOnlyDictionary<ITypeSymbol, string>>(() => CreateConvertMethodsLookupByReturnType(semanticModel));
6451
}
65-
66-
private static IReadOnlyDictionary<ITypeSymbol, string> CreateConvertMethodsLookupByReturnType(
67-
SemanticModel semanticModel)
68-
{
69-
// In some projects there's a source declaration as well as the referenced one, which causes the first of these methods to fail
70-
var symbolsWithName = semanticModel.Compilation
71-
.GetSymbolsWithName(n => n.Equals(ConvertType.Name, StringComparison.Ordinal), SymbolFilter.Type).ToList();
72-
73-
var convertType =
74-
semanticModel.Compilation.GetTypeByMetadataName(ConvertType.FullName) ??
75-
(ITypeSymbol)symbolsWithName.FirstOrDefault(s =>
76-
s.ContainingNamespace.ToDisplayString().Equals(ConvertType.Namespace, StringComparison.Ordinal));
77-
78-
if (convertType is null) return ImmutableDictionary<ITypeSymbol, string>.Empty;
79-
80-
var convertMethods = convertType.GetMembers().Where(m =>
81-
m.Name.StartsWith("To", StringComparison.Ordinal) && m.GetParameters().Length == 1);
82-
83-
#pragma warning disable RS1024 // Compare symbols correctly - GroupBy and ToDictionary use the same logic to dedupe as to lookup, so it doesn't matter which equality is used
84-
var methodsByType = convertMethods
85-
.GroupBy(m => new { ReturnType = m.GetReturnType(), Name = $"{ConvertType.FullName}.{m.Name}" })
86-
.ToDictionary(m => m.Key.ReturnType, m => m.Key.Name);
87-
#pragma warning restore RS1024 // Compare symbols correctly
88-
89-
return methodsByType;
90-
}
91-
9252
public CommonConversions CommonConversions { get; }
9353

9454
public override async Task<CSharpSyntaxNode> DefaultVisit(SyntaxNode node)

0 commit comments

Comments
 (0)