Skip to content

Commit 1ea0262

Browse files
[fix] fix build failure from package vulnerability (#149)
Package 'Tmds.DBus.Protocol' explicitly added as build fails from transient package usage. `Warning As Error: Package 'Tmds.DBus.Protocol' 0.21.2 has a known high severity vulnerability, [https://github.com/advisories/GHSA-xrw6-gwf8-vvr9](https://github.com/advisories/GHSA-xrw6-gwf8-vvr9) File [JavaToCSharpGui\ViewModels\MainWindowViewModel.cs](https://github.com/paulirwin/JavaToCSharp/blob/master/JavaToCSharpGui/ViewModels/MainWindowViewModel.cs) Line187 has been changed from `int subStartIndex = dir.FullName.Length;` to `int subStartIndex = dir.FullName.Length - 1;` - Fixes exception `'startIndex cannot be larger than length of string. (Parameter 'startIndex')'` thrown on line193, `string jOutPath = $"{outDirFullName}{jPath[subStartIndex..]}";` when sub directories are not present or .java files are directly under chosen directory - Fixes improper directory duplicate creation when sub dirs are present. Previous result takes `maindir/subdir_one/file_one.java` and creates `maindir/maindir_csharp_outputsubdir_one/file_one.java` & `maindir/maindir_csharp_output/subdir_one/file_one.java` current result takes `maindir/subdir_one/file_one.java` and cretes only `maindir/maindir_csharp_output/subdir_one/file_one.java`
1 parent d3ab6db commit 1ea0262

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

JavaToCSharpGui/ViewModels/MainWindowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ await Task.Run(async () =>
184184
outDir.Create();
185185

186186
string outDirFullName = outDir.FullName;
187-
int subStartIndex = dir.FullName.Length;
188187

189188
foreach (var jFile in FolderInputFiles.Where(static x => x.Directory is not null))
190189
{
191190
// ! null checked above
192191
string jPath = jFile.Directory!.FullName;
193-
string jOutPath = $"{outDirFullName}{jPath[subStartIndex..]}";
192+
string relativePath = Path.GetRelativePath(dir.FullName, jPath);
193+
string jOutPath = Path.Combine(outDirFullName, relativePath);
194194
string jOutFileName = Path.GetFileNameWithoutExtension(jFile.Name) + ".cs";
195195
string jOutFileFullName = Path.Combine(jOutPath, jOutFileName);
196196

0 commit comments

Comments
 (0)