Skip to content

Commit 4cb9a8f

Browse files
Timur KelmanTimur Kelman
authored andcommitted
add tests
* WithByRef test commented out because of a Roslyn bug (need newer version) * A bunch of unrelated changes was necessary to fix tests * `ConvertWholeSolutionAsync` (to VB) doesn't work because it writes stack including file names
1 parent ccbd778 commit 4cb9a8f

49 files changed

Lines changed: 3486 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Tests/CSharp/MultiFileSolutionAndProjectTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ public async Task ConvertVbLibraryOnlyAsync()
3030
{
3131
await _multiFileTestFixture.ConvertProjectsWhereAsync(p => p.Name == "VbLibrary", Language.CS);
3232
}
33+
34+
[Fact]
35+
public async Task ConvertVbUsingCSharpRefReturnOnlyAsync()
36+
{
37+
await _multiFileTestFixture.ConvertProjectsWhereAsync(p => p.Name == "VisualBasicUsingCSharpRefReturn", Language.CS);
38+
}
3339
}

Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertCSharpConsoleAppOnly/CharacterizationTestSolution.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Prefix.VbLibrary", "Prefix.
2626
EndProject
2727
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualBasicConsoleApp", "ConsoleApp1\VisualBasicConsoleApp.vbproj", "{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}"
2828
EndProject
29+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpRefReturn", "CSharpRefReturn\CSharpRefReturn.csproj", "{8B843547-F49D-40A2-8C4E-1B81D8C5D589}"
30+
EndProject
31+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualBasicUsingCSharpRefReturn", "VisualBasicUsesCSharpRefReturn\VisualBasicUsingCSharpRefReturn.vbproj", "{6266982D-4807-4619-A71D-1440D0B6B6F4}"
32+
EndProject
2933
Global
3034
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3135
Debug|Any CPU = Debug|Any CPU
@@ -68,6 +72,14 @@ Global
6872
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Debug|Any CPU.Build.0 = Debug|Any CPU
6973
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Release|Any CPU.ActiveCfg = Release|Any CPU
7074
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Release|Any CPU.Build.0 = Release|Any CPU
75+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Debug|Any CPU.Build.0 = Debug|Any CPU
77+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Release|Any CPU.ActiveCfg = Release|Any CPU
78+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Release|Any CPU.Build.0 = Release|Any CPU
79+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
81+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
82+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Release|Any CPU.Build.0 = Release|Any CPU
7183
EndGlobalSection
7284
GlobalSection(SolutionProperties) = preSolution
7385
HideSolutionNode = FALSE
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<OptionInfer>On</OptionInfer>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{39A0B42C-38C5-0F53-0E16-D1FFBA52E129}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace></RootNamespace>
12+
<AssemblyName>CSharpRefReturn</AssemblyName>
13+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<Deterministic>true</Deterministic>
16+
<DefaultItemExcludes>$(DefaultItemExcludes);$(ProjectDir)**\*.cs</DefaultItemExcludes>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG,TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="RefReturnList.vb" />
47+
<Compile Include="Properties\AssemblyInfo.vb" />
48+
</ItemGroup>
49+
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
50+
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Imports System.Reflection
2+
Imports System.Runtime.InteropServices
3+
4+
' General Information about an assembly is controlled through the following
5+
' set of attributes. Change these attribute values to modify the information
6+
' associated with an assembly.
7+
<Assembly: AssemblyTitle("CSharpRefReturn")>
8+
<Assembly: AssemblyDescription("")>
9+
<Assembly: AssemblyConfiguration("")>
10+
<Assembly: AssemblyCompany("")>
11+
<Assembly: AssemblyProduct("CSharpRefReturn")>
12+
<Assembly: AssemblyCopyright("Copyright © 2024")>
13+
<Assembly: AssemblyTrademark("")>
14+
<Assembly: AssemblyCulture("")>
15+
16+
' Setting ComVisible to false makes the types in this assembly not visible
17+
' to COM components. If you need to access a type in this assembly from
18+
' COM, set the ComVisible attribute to true on that type.
19+
<Assembly: ComVisible(False)>
20+
21+
' The following GUID is for the ID of the typelib if this project is exposed to COM
22+
<Assembly: Guid("8b843547-f49d-40a2-8c4e-1b81d8c5d589")>
23+
24+
' Version information for an assembly consists of the following four values:
25+
'
26+
' Major Version
27+
' Minor Version
28+
' Build Number
29+
' Revision
30+
'
31+
' You can specify all the values or you can default the Build and Revision Numbers
32+
' by using the '*' as shown below:
33+
' [assembly: AssemblyVersion("1.0.*")]
34+
<Assembly: AssemblyVersion("1.0.0.0")>
35+
<Assembly: AssemblyFileVersion("1.0.0.0")>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
Namespace CSharpRefReturn
3+
Public Class RefReturnList(Of T)
4+
Private dummy As T
5+
''' Cannot convert IndexerDeclarationSyntax, System.InvalidCastException: Unable to cast object of type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.EmptyStatementSyntax' to type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.TypeSyntax'.
6+
''' at ICSharpCode.CodeConverter.VB.NodesVisitor.<>c__DisplayClass53_0.<ConvertPropertyBlock>b__1()
7+
''' at ICSharpCode.CodeConverter.VB.NodesVisitor.ConvertPropertyBlock(BasePropertyDeclarationSyntax node, SyntaxToken id, SyntaxTokenList modifiers, ParameterListSyntax parameterListSyntax, ArrowExpressionClauseSyntax arrowExpressionClauseSyntax, EqualsValueSyntax initializerOrNull)
8+
''' at ICSharpCode.CodeConverter.VB.NodesVisitor.VisitIndexerDeclaration(IndexerDeclarationSyntax node)
9+
''' at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.Visit(SyntaxNode node)
10+
''' at ICSharpCode.CodeConverter.VB.CommentConvertingVisitorWrapper`1.Accept(SyntaxNode csNode, Boolean addSourceMapping)
11+
'''
12+
''' Input:
13+
''' public ref T this[int i] {
14+
''' get {
15+
''' return ref this.dummy;
16+
''' }
17+
''' }
18+
'''
19+
'''
20+
End Class
21+
End Namespace

Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertWholeSolution/CharacterizationTestSolution.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Prefix.VbLibrary", "Prefix.
2626
EndProject
2727
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualBasicConsoleApp", "ConsoleApp1\VisualBasicConsoleApp.vbproj", "{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}"
2828
EndProject
29+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CSharpRefReturn", "CSharpRefReturn\CSharpRefReturn.vbproj", "{39A0B42C-38C5-0F53-0E16-D1FFBA52E129}"
30+
EndProject
31+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualBasicUsingCSharpRefReturn", "VisualBasicUsesCSharpRefReturn\VisualBasicUsingCSharpRefReturn.vbproj", "{6266982D-4807-4619-A71D-1440D0B6B6F4}"
32+
EndProject
2933
Global
3034
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3135
Debug|Any CPU = Debug|Any CPU
@@ -68,6 +72,14 @@ Global
6872
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Debug|Any CPU.Build.0 = Debug|Any CPU
6973
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Release|Any CPU.ActiveCfg = Release|Any CPU
7074
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Release|Any CPU.Build.0 = Release|Any CPU
75+
{39A0B42C-38C5-0F53-0E16-D1FFBA52E129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76+
{39A0B42C-38C5-0F53-0E16-D1FFBA52E129}.Debug|Any CPU.Build.0 = Debug|Any CPU
77+
{39A0B42C-38C5-0F53-0E16-D1FFBA52E129}.Release|Any CPU.ActiveCfg = Release|Any CPU
78+
{39A0B42C-38C5-0F53-0E16-D1FFBA52E129}.Release|Any CPU.Build.0 = Release|Any CPU
79+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
81+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
82+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Release|Any CPU.Build.0 = Release|Any CPU
7183
EndGlobalSection
7284
GlobalSection(SolutionProperties) = preSolution
7385
HideSolutionNode = FALSE
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{8B843547-F49D-40A2-8C4E-1B81D8C5D589}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CSharpRefReturn</RootNamespace>
11+
<AssemblyName>CSharpRefReturn</AssemblyName>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="System" />
35+
<Reference Include="System.Core" />
36+
<Reference Include="System.Xml.Linq" />
37+
<Reference Include="System.Data.DataSetExtensions" />
38+
<Reference Include="Microsoft.CSharp" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Net.Http" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="RefReturnList.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
48+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CSharpRefReturn")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CSharpRefReturn")]
13+
[assembly: AssemblyCopyright("Copyright © 2024")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("8b843547-f49d-40a2-8c4e-1b81d8c5d589")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CSharpRefReturn
8+
{
9+
public class RefReturnList<T>
10+
{
11+
private T dummy;
12+
public ref T this[int i] {
13+
get {
14+
return ref dummy;
15+
}
16+
}
17+
}
18+
}

Tests/TestData/MultiFileCharacterization/SourceFiles/CharacterizationTestSolution.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Prefix.VbLibrary", "Prefix.
2626
EndProject
2727
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualBasicConsoleApp", "ConsoleApp1\VisualBasicConsoleApp.vbproj", "{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}"
2828
EndProject
29+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpRefReturn", "CSharpRefReturn\CSharpRefReturn.csproj", "{8B843547-F49D-40A2-8C4E-1B81D8C5D589}"
30+
EndProject
31+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualBasicUsingCSharpRefReturn", "VisualBasicUsesCSharpRefReturn\VisualBasicUsingCSharpRefReturn.vbproj", "{6266982D-4807-4619-A71D-1440D0B6B6F4}"
32+
EndProject
2933
Global
3034
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3135
Debug|Any CPU = Debug|Any CPU
@@ -68,6 +72,14 @@ Global
6872
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Debug|Any CPU.Build.0 = Debug|Any CPU
6973
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Release|Any CPU.ActiveCfg = Release|Any CPU
7074
{C69D27C1-FF4E-43CB-BB0F-9BF811BF0F81}.Release|Any CPU.Build.0 = Release|Any CPU
75+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Debug|Any CPU.Build.0 = Debug|Any CPU
77+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Release|Any CPU.ActiveCfg = Release|Any CPU
78+
{8B843547-F49D-40A2-8C4E-1B81D8C5D589}.Release|Any CPU.Build.0 = Release|Any CPU
79+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
81+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
82+
{6266982D-4807-4619-A71D-1440D0B6B6F4}.Release|Any CPU.Build.0 = Release|Any CPU
7183
EndGlobalSection
7284
GlobalSection(SolutionProperties) = preSolution
7385
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)