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
14 changes: 11 additions & 3 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0'

- name: Build Release
run: msbuild JavaToCSharp.csproj /p:Configuration=Release /p:Platform="Any CPU"
run: dotnet build -c Release

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: JavaToCSharp-Release
path: bin/Release/net8.0/JavaToCSharp.dll

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
75 changes: 9 additions & 66 deletions JavaToCSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,72 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{766E09AF-B872-444D-BD76-C8BB17E38DAC}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>JavaToCSharp</RootNamespace>
<AssemblyName>JavaToCSharp</AssemblyName>
<TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\RuleSection.cs" />
<Compile Include="Configuration\RuleSectionCollection.cs" />
<Compile Include="Configuration\J2CSSection.cs" />
<Compile Include="IRule.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RuleEngine.cs" />
<Compile Include="Rules\CapitalizeRule.cs" />
<Compile Include="Rules\DeleteRule.cs" />
<Compile Include="Rules\EquivalentRule.cs" />
<Compile Include="Rules\foreachRule.cs" />
<Compile Include="Rules\getIndexerRule.cs" />
<Compile Include="Rules\OtherRule.cs" />
<Compile Include="Rules\RemoveGetRule.cs" />
<Compile Include="Rules\skiplineRule.cs" />
</ItemGroup>

<ItemGroup>
<None Include="App.config" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
6 changes: 3 additions & 3 deletions RuleEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using System.Text;
using System.IO;
using System.Reflection;
using JavaToCSharp.Configuration;
using System.Configuration;
using JavaToCSharp.Configuration;
using JavaToCSharp.Rules;

namespace JavaToCSharp
Expand All @@ -30,8 +30,8 @@ public void LoadRules()
foreach (RuleSection rs in config.Rules)
{
EquivalentRule r = new EquivalentRule(rs.Name);
r.Pattern = rs.Pattern;
r.Replacement = rs.Replacement;
r.PatternValue = rs.Pattern;
r.ReplacementValue = rs.Replacement;
//Console.WriteLine(r.ToString());
AddRule(r);
}
Expand Down
16 changes: 8 additions & 8 deletions Rules/EquivalentExceptionRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace JavaToCSharp.Rules
{
public abstract class EquivalentExceptionRule : EquivalentRule
{
protected override sealed string Replacement
protected override string Replacement
{
get { return this.Pattern; }
}
Expand All @@ -21,7 +21,7 @@ protected override string Pattern
get { return @"RuntimeException"; }
}

public override string ReplaceString(Match match)
protected override string ReplaceString(Match match)
{
return "Exception";
}
Expand All @@ -35,7 +35,7 @@ protected override string Pattern
get { return @"ClassCastException"; }
}

public override string ReplaceString(Match match)
protected override string ReplaceString(Match match)
{
return "InvalidCastException";
}
Expand All @@ -49,7 +49,7 @@ protected override string Pattern
get { return @"UnsupportedEncodingException"; }
}

public override string ReplaceString(Match match)
protected override string ReplaceString(Match match)
{
return "EncoderFallbackException";
}
Expand All @@ -63,7 +63,7 @@ protected override string Pattern
get { return @"AssertionFailedError"; }
}

public override string ReplaceString(Match match)
protected override string ReplaceString(Match match)
{
return "AssertFailedException";
}
Expand All @@ -77,7 +77,7 @@ protected override string Pattern
get { return @"IllegalArgumentException"; }
}

public override string ReplaceString(Match match)
protected override string ReplaceString(Match match)
{
return "ArgumentException";
}
Expand All @@ -90,7 +90,7 @@ protected override string Pattern
get { return @"NumberFormatException"; }
}

public override string ReplaceString(Match match)
protected override string ReplaceString(Match match)
{
return "FormatException";
}
Expand All @@ -103,7 +103,7 @@ protected override string Pattern
get { return @"IllegalAccessError|IllegalStateException"; }
}

public override string ReplaceString(Match match)
protected override string ReplaceString(Match match)
{
return "InvalidOperationException";
}
Expand Down
14 changes: 12 additions & 2 deletions Rules/EquivalentRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
{
public class EquivalentRule : Rule
{
public EquivalentRule()

Check warning on line 10 in Rules/EquivalentRule.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Replacement' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 10 in Rules/EquivalentRule.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Pattern' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 10 in Rules/EquivalentRule.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{

}
public EquivalentRule(string name)

Check warning on line 14 in Rules/EquivalentRule.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Replacement' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 14 in Rules/EquivalentRule.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Pattern' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
{
this._name = name;
}
Expand All @@ -22,18 +22,28 @@
get { return _name; }
}

public virtual string Replacement
protected virtual string Pattern
{
get;
set;
}

public string PatternValue
{
set { this.Pattern = value; }
}

public virtual string Pattern
protected virtual string Replacement
{
get;
set;
}

public string ReplacementValue
{
set { this.Replacement = value; }
}

protected virtual string ReplaceString(Match match)
{
return this.Replacement;
Expand Down
Loading
Loading