Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Oct 2, 2024
1 parent f95b1a2 commit 75d2f8b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion csharp/src/Ice/Internal/MetricsAdminI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ public static void validateProperties(string prefix, Ice.Properties properties)
message.Append("\n ");
message.Append(p);
}
throw new InvalidOperationException(message.ToString());
throw new UnknownPropertyException(message.ToString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion csharp/src/Ice/Internal/ReferenceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ Dictionary<string, string> props
message.Append("\n ");
message.Append(s);
}
throw new InitializationException(message.ToString());
throw new UnknownPropertyException(message.ToString());
}
}

Expand Down
19 changes: 19 additions & 0 deletions csharp/src/Ice/LocalExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,3 +855,22 @@ public TwowayOnlyException(string operation)

public override string ice_id() => "::Ice::TwowayOnlyException";
}

/// <summary>
/// An unknown property was used in the configuration of an object adapter or a proxy.
/// </summary>
public sealed class UnknownPropertyException : LocalException
{
/// <summary>
/// Initializes a new instance of the <see cref="UnknownPropertyException" /> class.
/// </summary>
/// <param name="message">The exception message.</param>
/// <param name="innerException">The inner exception.</param>
public UnknownPropertyException(string message, System.Exception? innerException = null)
: base(message, innerException)
{
}

/// <inheritdoc/>
public override string ice_id() => "::Ice::UnknownPropertyException";
}
2 changes: 1 addition & 1 deletion csharp/src/Ice/ObjectAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ internal ObjectAdapter(
message.Append("\n ");
message.Append(s);
}
throw new InitializationException(message.ToString());
throw new UnknownPropertyException(message.ToString());
}

//
Expand Down
11 changes: 4 additions & 7 deletions csharp/test/Ice/unknownProperties/AllTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// Copyright (c) ZeroC, Inc.

using System.Collections;
using System.Diagnostics;

namespace Ice.unknownProperties;

public class AllTests : global::Test.AllTests
public class AllTests : Test.AllTests
{
public static int allTests(global::Test.TestHelper helper)
public static int allTests(Test.TestHelper helper)
{
var communicator = helper.communicator();
var output = helper.getWriter();
Expand All @@ -20,7 +17,7 @@ public static int allTests(global::Test.TestHelper helper)
communicator.createObjectAdapter("Foo");
test(false);
}
catch (InitializationException)
catch (UnknownPropertyException)
{
}
output.WriteLine("ok");
Expand All @@ -34,7 +31,7 @@ public static int allTests(global::Test.TestHelper helper)
communicator.propertyToProxy("Greeter");
test(false);
}
catch (InitializationException)
catch (UnknownPropertyException)
{
}
output.WriteLine("ok");
Expand Down
10 changes: 4 additions & 6 deletions csharp/test/Ice/unknownProperties/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

namespace Ice.unknownProperties;

public class Client : global::Test.TestHelper
public class Client : Test.TestHelper
{
public override void run(string[] args)
{
var initData = new InitializationData();
initData.properties = createTestProperties(ref args);
using (var communicator = initialize(initData))
{
AllTests.allTests(this);
}
using Communicator communicator = initialize(initData);
AllTests.allTests(this);
}

public static Task<int> Main(string[] args) =>
global::Test.TestDriver.runTestAsync<Client>(args);
Test.TestDriver.runTestAsync<Client>(args);
}

0 comments on commit 75d2f8b

Please sign in to comment.