Skip to content

Commit 86eae2b

Browse files
Introduce KnownMethod to save inlining 1000s of lines of hardcoding
1 parent 435506e commit 86eae2b

File tree

8 files changed

+122
-731
lines changed

8 files changed

+122
-731
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1313
* Improve performance of single file conversion - [#546](https://github.com/icsharpcode/CodeConverter/issues/546)
1414
* Add AsEnumerable where needed in linq "in" clause - [#544](https://github.com/icsharpcode/CodeConverter/issues/544)
1515
* Remove redundant empty string coalesce in string comparison - [#500](https://github.com/icsharpcode/CodeConverter/issues/500)
16+
* Convert VB comparison operators - [#396](https://github.com/icsharpcode/CodeConverter/issues/396)
1617

1718
### C# -> VB
1819

CodeConverter/CSharp/BuiltInVisualBasicOperatorSubsitutions.cs

Lines changed: 55 additions & 53 deletions
Large diffs are not rendered by default.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Collections.Generic;
2+
using ICSharpCode.CodeConverter.Util;
3+
using Microsoft.CodeAnalysis.CSharp.Syntax;
4+
using SyntaxFactory = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
5+
6+
namespace ICSharpCode.CodeConverter.CSharp
7+
{
8+
internal struct KnownMethod
9+
{
10+
public string Import;
11+
public string TypeName;
12+
public string MethodName;
13+
14+
public KnownMethod(string import, string typeName, string methodName)
15+
{
16+
this.Import = import;
17+
this.TypeName = typeName;
18+
this.MethodName = methodName;
19+
}
20+
21+
public override bool Equals(object obj) =>
22+
obj is KnownMethod other && Import == other.Import && TypeName == other.TypeName && MethodName == other.MethodName;
23+
24+
public override int GetHashCode() =>
25+
(Import, TypeName, MethodName).GetHashCode();
26+
27+
public static implicit operator KnownMethod((string import, string typeName, string methodName) value) =>
28+
new KnownMethod(value.import, value.typeName, value.methodName);
29+
30+
public ExpressionSyntax Invoke(HashSet<string> extraUsingDirectives, params ExpressionSyntax[] args)
31+
{
32+
extraUsingDirectives.Add(Import);
33+
return SyntaxFactory.InvocationExpression(ValidSyntaxFactory.MemberAccess(TypeName, MethodName), ExpressionSyntaxExtensions.CreateArgList(args));
34+
}
35+
}
36+
}

CodeConverter/Util/FromRoslyn/SpecialMember.cs

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)