Skip to content

Commit fe6e0c2

Browse files
authored
Merge pull request #9 from clement-lucas/C#fix
Fix issue with C# conversion
2 parents bfb4e63 + 8c0f0d2 commit fe6e0c2

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

CobolToQuarkusMigration.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@
2626
<Content Remove="McpChatWeb.Tests\**\*" />
2727
</ItemGroup>
2828

29+
<ItemGroup>
30+
<Compile Remove="output\**" />
31+
</ItemGroup>
32+
2933
</Project>

Models/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System.IO;
2+
using System.Text.Json.Serialization;
23

34
namespace CobolToQuarkusMigration.Models;
45

56
/// <summary>
67
/// Represents the target language for code conversion.
78
/// </summary>
9+
[JsonConverter(typeof(JsonStringEnumConverter))]
810
public enum TargetLanguage
911
{
1012
/// <summary>

Processes/MigrationProcess.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@ public async Task RunAsync(
119119
string javaOutputFolder,
120120
Action<string, int, int>? progressCallback = null)
121121
{
122-
_enhancedLogger.ShowSectionHeader("COBOL TO JAVA QUARKUS MIGRATION", "AI-Powered Legacy Code Modernization");
122+
var migrationTargetLang = _settings.ApplicationSettings.TargetLanguage;
123+
var targetName = migrationTargetLang == TargetLanguage.CSharp ? "C# .NET" : "JAVA QUARKUS";
124+
_enhancedLogger.ShowSectionHeader($"COBOL TO {targetName} MIGRATION", "AI-Powered Legacy Code Modernization");
123125

124126
_logger.LogInformation("COBOL source folder: {CobolSourceFolder}", cobolSourceFolder);
125-
_logger.LogInformation("Java output folder: {JavaOutputFolder}", javaOutputFolder);
127+
_logger.LogInformation("{TargetLanguage} output folder: {OutputFolder}", targetName, javaOutputFolder);
126128

127129
if (_cobolAnalyzerAgent == null || _codeConverterAgent == null || _dependencyMapperAgent == null)
128130
{

Program.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,7 @@ private static void LoadEnvironmentVariables()
507507
string localConfigFile = Path.Combine(configDir, "ai-config.local.env");
508508
string templateConfigFile = Path.Combine(configDir, "ai-config.env");
509509

510-
if (File.Exists(templateConfigFile))
511-
{
512-
LoadEnvFile(templateConfigFile);
513-
}
514-
510+
// Load local config first (highest priority among config files)
515511
if (File.Exists(localConfigFile))
516512
{
517513
LoadEnvFile(localConfigFile);
@@ -521,6 +517,12 @@ private static void LoadEnvironmentVariables()
521517
Console.WriteLine("💡 Consider creating Config/ai-config.local.env for your personal settings");
522518
Console.WriteLine(" You can copy from Config/ai-config.local.env.template");
523519
}
520+
521+
// Then load template config to fill in any missing values
522+
if (File.Exists(templateConfigFile))
523+
{
524+
LoadEnvFile(templateConfigFile);
525+
}
524526
}
525527
catch (Exception ex)
526528
{
@@ -544,7 +546,12 @@ private static void LoadEnvFile(string filePath)
544546
{
545547
string key = parts[0].Trim();
546548
string value = parts[1].Trim().Trim('"', '\'');
547-
Environment.SetEnvironmentVariable(key, value);
549+
550+
// Only set if not already set (allows shell script to override)
551+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(key)))
552+
{
553+
Environment.SetEnvironmentVariable(key, value);
554+
}
548555
}
549556
}
550557
}

doctor.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,9 @@ generate_migration_report() {
486486
sqlite3 "$db_path" <<SQL
487487
.mode markdown
488488
.headers off
489-
SELECT '- **Total COBOL Files:** ' || COUNT(DISTINCT source_file) FROM cobol_files WHERE run_id = $run_id;
490-
SELECT '- **Programs (.cbl):** ' || COUNT(DISTINCT source_file) FROM cobol_files WHERE run_id = $run_id AND source_file LIKE '%.cbl';
491-
SELECT '- **Copybooks (.cpy):** ' || COUNT(DISTINCT source_file) FROM cobol_files WHERE run_id = $run_id AND source_file LIKE '%.cpy';
489+
SELECT '- **Total COBOL Files:** ' || COUNT(DISTINCT file_name) FROM cobol_files WHERE run_id = $run_id;
490+
SELECT '- **Programs (.cbl):** ' || COUNT(DISTINCT file_name) FROM cobol_files WHERE run_id = $run_id AND file_name LIKE '%.cbl';
491+
SELECT '- **Copybooks (.cpy):** ' || COUNT(DISTINCT file_name) FROM cobol_files WHERE run_id = $run_id AND file_name LIKE '%.cpy';
492492
SQL
493493

494494
echo ""
@@ -517,7 +517,7 @@ SQL
517517
sqlite3 "$db_path" <<SQL
518518
.mode markdown
519519
.headers on
520-
SELECT file_name AS 'File Name', file_path AS 'Path', line_count AS 'Lines'
520+
SELECT file_name AS 'File Name', file_path AS 'Path', is_copybook AS 'Is Copybook'
521521
FROM cobol_files
522522
WHERE run_id = $run_id
523523
ORDER BY file_name;
@@ -895,6 +895,8 @@ run_migration() {
895895
fi
896896

897897
# Run the application with updated folder structure
898+
# Export TARGET_LANGUAGE so it's available to the dotnet process
899+
export TARGET_LANGUAGE
898900
"$DOTNET_CMD" run -- --source ./source $skip_reverse_eng
899901
local migration_exit=$?
900902

0 commit comments

Comments
 (0)