Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### VB -> C#

* Xor operator overloads now converted [#1182](htts://github.com/icsharpcode/CodeConverter/issues/1182)

### C# -> VB

Expand Down
2 changes: 2 additions & 0 deletions CodeConverter/CSharp/SyntaxKindExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ public static SyntaxKind ConvertToken(this Microsoft.CodeAnalysis.VisualBasic.Sy
return SyntaxKind.AmpersandToken;
case Microsoft.CodeAnalysis.VisualBasic.SyntaxKind.OrKeyword:
return SyntaxKind.BarToken;
case Microsoft.CodeAnalysis.VisualBasic.SyntaxKind.XorKeyword:
return SyntaxKind.CaretToken;
//
case Microsoft.CodeAnalysis.VisualBasic.SyntaxKind.AssemblyKeyword:
return SyntaxKind.AssemblyKeyword;
Expand Down
27 changes: 27 additions & 0 deletions Tests/CSharp/MemberTests/OperatorMemberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,32 @@ End Operator
Assert.Contains("Public Shared Operator ^(i As Integer,", convertedCode);
Assert.Contains("_failedMemberConversionMarker2", convertedCode);
Assert.Contains("Public Shared Operator Like(s As String,", convertedCode);
}

[Fact]

public async Task XorOperatorOverloadConversionAsync()

{

await TestConversionVisualBasicToCSharpAsync(

@"
Public Class MyType
Public Shared Operator Xor(left As MyType, right As MyType) As MyType
Throw New Global.System.NotSupportedException(""Not supported"")
End Operator
End Class",

@"using System;

public partial class MyType
{
public static MyType operator ^(MyType left, MyType right)
{
throw new NotSupportedException(""Not supported"");
}
}");

}
}
Loading