Skip to content

[CP #2179 > support/v6.0] [lang] Configuration for CSharp API and folder structure alignment #2186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
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
3 changes: 2 additions & 1 deletion lang/csharp/Eclipse.eCAL.Core.Samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2024 Continental Corporation
# Copyright (C) 2016 - 2025 Continental Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,3 +18,4 @@

add_subdirectory(pubsub)
add_subdirectory(service)
add_subdirectory(testexec)
31 changes: 31 additions & 0 deletions lang/csharp/Eclipse.eCAL.Core.Samples/testexec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2025 Continental Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ========================= eCAL LICENSE =================================

include(CSharpUtilities)
project(Eclipse.eCAL.Core.Samples LANGUAGES CSharp)

find_package(eCAL REQUIRED)

macro(ecal_add_csharp_core_sample sample_name)
ecal_add_sample(${sample_name} ${sample_name}.cs)
target_link_libraries(${sample_name} PRIVATE Eclipse.eCAL.Core)
set_property(TARGET ${sample_name} PROPERTY FOLDER samples/csharp/binary/testexec)
add_dependencies(${sample_name} Eclipse.eCAL.Core.Test)
endmacro()

ecal_add_csharp_core_sample(testexec_csharp)
90 changes: 90 additions & 0 deletions lang/csharp/Eclipse.eCAL.Core.Samples/testexec/testexec_csharp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

using System;
using System.Collections.Generic;
using System.Reflection;

public class TestExec
{
static void Main()
{
var testCases = new Dictionary<string, List<string>>
{
{ "ConfigTest", new List<string> { "TestConfigPassing", "TestPubSubConfig", "TestConfigConvenienceGetter" } },
// Add more test classes and methods here
// { "AnotherTestClass", new List<string> { "Test1", "Test2" } }
};

string assemblyPath = "Eclipse.Ecal.Core.Testd.dll";
var assembly = Assembly.LoadFrom(assemblyPath);

var failedTests = new List<string>();

foreach (var kvp in testCases)
{
string className = kvp.Key;
var testClass = assembly.GetType(className);
if (testClass == null)
{
Console.WriteLine($"[ERROR] Test class '{className}' not found.");
failedTests.Add($"{className} (class not found)");
continue;
}

object instance = Activator.CreateInstance(testClass);

foreach (var methodName in kvp.Value)
{
var method = testClass.GetMethod(methodName);
if (method == null)
{
Console.WriteLine($"[ERROR] Method '{methodName}' not found in '{className}'.");
failedTests.Add($"{className}.{methodName} (method not found)");
continue;
}

try
{
Console.WriteLine($"Running {className}.{methodName}... ");
object result = method.Invoke(instance, null);
Console.WriteLine("SUCCESS");
}
catch (Exception ex)
{
Console.WriteLine("FAILED");
Console.WriteLine($" Exception: {ex.InnerException?.Message ?? ex.Message}");
failedTests.Add($"{className}.{methodName}");
}
}
}

Console.WriteLine("\nTest run complete.");
if (failedTests.Count > 0)
{
Console.WriteLine("Failed tests:");
foreach (var fail in failedTests)
Console.WriteLine($" {fail}");
}
else
{
Console.WriteLine("All tests passed!");
}
}
}
1 change: 1 addition & 0 deletions lang/csharp/Eclipse.eCAL.Core.Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ target_sources(${PROJECT_NAME}
PRIVATE
PubSubReceiveTest.cs
PubSubEventHandlingTest.cs
ConfigTest.cs
)

target_link_libraries(${PROJECT_NAME} Eclipse.eCAL.Core)
Expand Down
Loading
Loading