diff --git a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Receive/RhinoHostObjectBuilder.cs b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Receive/RhinoHostObjectBuilder.cs index 0d85d437..4da7a785 100644 --- a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Receive/RhinoHostObjectBuilder.cs @@ -149,7 +149,7 @@ CancellationToken cancellationToken var result = _converter.Convert(obj); if (!result.IsSuccess) { - conversionResults.Add(new(Status.ERROR, obj, result.Message.NotNull())); + conversionResults.Add(new(Status.ERROR, obj, result.Message.NotNull())); convertActivity?.SetStatus(SdkActivityStatusCode.Error); continue; } diff --git a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Send/RhinoRootObjectBuilder.cs b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Send/RhinoRootObjectBuilder.cs index bacc4601..d179b9c8 100644 --- a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Send/RhinoRootObjectBuilder.cs +++ b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Operations/Send/RhinoRootObjectBuilder.cs @@ -160,7 +160,7 @@ string projectId } else { - var result = _rootToSpeckleConverter.Convert(rhinoObject); + var result = _rootToSpeckleConverter.Convert(rhinoObject); if (result.IsSuccess) { converted = result.Base.NotNull(); diff --git a/Converters/Rhino/Speckle.Converters.RhinoShared/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs b/Converters/Rhino/Speckle.Converters.RhinoShared/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs index 0fd342fa..934d98ca 100644 --- a/Converters/Rhino/Speckle.Converters.RhinoShared/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs +++ b/Converters/Rhino/Speckle.Converters.RhinoShared/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs @@ -20,7 +20,7 @@ protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter // POC: IIndex would fix this as I would just request the type from `RhinoObject.Geometry` directly. protected abstract TInRaw GetTypedGeometry(TTopLevelIn input); - public BaseResult Convert(object target) + public BaseResult Convert(object target) { var typedTarget = (TTopLevelIn)target; var typedGeometry = GetTypedGeometry(typedTarget); @@ -34,6 +34,6 @@ public BaseResult Convert(object target) result["name"] = typedTarget.Attributes.Name; } - return BaseResult.Success( result); + return BaseResult.Success(result); } } diff --git a/Sdk/Speckle.Connectors.Common/Conversion/ReportResult.cs b/Sdk/Speckle.Connectors.Common/Conversion/ReportResult.cs index ae5defe4..15aaac03 100644 --- a/Sdk/Speckle.Connectors.Common/Conversion/ReportResult.cs +++ b/Sdk/Speckle.Connectors.Common/Conversion/ReportResult.cs @@ -55,12 +55,8 @@ public ReceiveConversionResult( ResultType = resultType; Error = FormatError(exception); } - - public ReceiveConversionResult( - Status status, - Base source, - string exception - ) + + public ReceiveConversionResult(Status status, Base source, string exception) { Status = status; SourceId = source.id.NotNull(); diff --git a/Sdk/Speckle.Connectors.Common/Extensions/RootObjectBuilderExtensions.cs b/Sdk/Speckle.Connectors.Common/Extensions/RootObjectBuilderExtensions.cs index c018271d..b4fbd499 100644 --- a/Sdk/Speckle.Connectors.Common/Extensions/RootObjectBuilderExtensions.cs +++ b/Sdk/Speckle.Connectors.Common/Extensions/RootObjectBuilderExtensions.cs @@ -20,7 +20,7 @@ string objectType logger.Log(logLevel, ex, "Conversion of object {objectType} was not successful", objectType); } - + public static void LogSendConversionError( this ILogger> logger, string objectType, diff --git a/Sdk/Speckle.Converters.Common/Extensions/ToHostTopLevelConverterExtension.cs b/Sdk/Speckle.Converters.Common/Extensions/ToHostTopLevelConverterExtension.cs index 2e1b3047..d0482c52 100644 --- a/Sdk/Speckle.Converters.Common/Extensions/ToHostTopLevelConverterExtension.cs +++ b/Sdk/Speckle.Converters.Common/Extensions/ToHostTopLevelConverterExtension.cs @@ -9,7 +9,11 @@ namespace Speckle.Converters.Common.Extensions; public static class ToHostTopLevelConverterExtension { - public static HostResult ConvertAndLog(this ConverterResult converter, Base target, ILogger logger) + public static HostResult ConvertAndLog( + this ConverterResult converter, + Base target, + ILogger logger + ) { try { @@ -45,9 +49,12 @@ public static HostResult ConvertAndLog(this ConverterResult(ConcurrentDictionary converterTypes, IServiceProvider serviceProvider) : IConverterManager { @@ -23,7 +22,10 @@ public ConverterResult ResolveConverter(Type type, bool recursive = true) if (currentType == null) { - return new ConverterResult(ConversionStatus.NoConverter, Message: $"No conversion found for {type.Name} or any of its base types"); + return new ConverterResult( + ConversionStatus.NoConverter, + Message: $"No conversion found for {type.Name} or any of its base types" + ); } } else if (converter is null) @@ -32,7 +34,6 @@ public ConverterResult ResolveConverter(Type type, bool recursive = true) } else { - return new ConverterResult(ConversionStatus.Success, converter); } } diff --git a/Sdk/Speckle.Converters.Common/Registration/IConversionResult.cs b/Sdk/Speckle.Converters.Common/Registration/IConversionResult.cs index 5a41f064..0f07704a 100644 --- a/Sdk/Speckle.Converters.Common/Registration/IConversionResult.cs +++ b/Sdk/Speckle.Converters.Common/Registration/IConversionResult.cs @@ -16,24 +16,33 @@ public enum ConversionStatus NoConversion } -public readonly record struct ConverterResult(ConversionStatus ConversionStatus, T? Converter = default, string? Message = null) : IConversionResult +public readonly record struct ConverterResult( + ConversionStatus ConversionStatus, + T? Converter = default, + string? Message = null +) : IConversionResult { public bool IsSuccess => ConversionStatus == ConversionStatus.Success; } -public readonly record struct BaseResult(ConversionStatus ConversionStatus, Base? Base = null, string? Message = null) : IConversionResult +public readonly record struct BaseResult(ConversionStatus ConversionStatus, Base? Base = null, string? Message = null) + : IConversionResult { public bool IsSuccess => ConversionStatus == ConversionStatus.Success; - + public static BaseResult Success(Base baseObject) => new(ConversionStatus.Success, baseObject); + public static BaseResult NoConverter(string? message) => new(ConversionStatus.NoConverter, Message: message); } -public readonly record struct HostResult(ConversionStatus ConversionStatus, object? Host = null, string? Message = null) : IConversionResult +public readonly record struct HostResult(ConversionStatus ConversionStatus, object? Host = null, string? Message = null) + : IConversionResult { public bool IsSuccess => ConversionStatus == ConversionStatus.Success; - + public static HostResult Success(object obj) => new(ConversionStatus.Success, obj); + public static HostResult NoConverter(string? message) => new(ConversionStatus.NoConverter, Message: message); + public static HostResult NoConversion(string? message) => new(ConversionStatus.NoConversion, Message: message); } diff --git a/Sdk/Speckle.Converters.Common/ToHost/ConverterWithFallback.cs b/Sdk/Speckle.Converters.Common/ToHost/ConverterWithFallback.cs index 94ee3dcc..a4ed5b57 100644 --- a/Sdk/Speckle.Converters.Common/ToHost/ConverterWithFallback.cs +++ b/Sdk/Speckle.Converters.Common/ToHost/ConverterWithFallback.cs @@ -7,7 +7,6 @@ namespace Speckle.Converters.Common.ToHost; - public sealed class ConverterWithFallback(ConverterWithoutFallback baseConverter, ILogger logger) : IRootToHostConverter { diff --git a/Sdk/Speckle.Converters.Common/ToHost/ConverterWithoutFallback.cs b/Sdk/Speckle.Converters.Common/ToHost/ConverterWithoutFallback.cs index 318b5e64..9e57b010 100644 --- a/Sdk/Speckle.Converters.Common/ToHost/ConverterWithoutFallback.cs +++ b/Sdk/Speckle.Converters.Common/ToHost/ConverterWithoutFallback.cs @@ -8,8 +8,8 @@ namespace Speckle.Converters.Common.ToHost; public sealed class ConverterWithoutFallback( IConverterManager converterResolver, - ILogger logger) - : IRootToHostConverter + ILogger logger +) : IRootToHostConverter { private readonly ILogger _logger = logger;