Skip to content

Commit 51ae923

Browse files
taking shape
1 parent 8e0b232 commit 51ae923

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

src/CoreIpc.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UiPath.CoreIpc.Tests", "UiP
1313
EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{676A208A-2F08-4749-A833-F8D2BCB1B147}"
1515
ProjectSection(SolutionItems) = preProject
16+
Directory.Build.targets = Directory.Build.targets
1617
NuGet.Config = NuGet.Config
1718
EndProjectSection
1819
EndProject

src/Directory.Build.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<ItemGroup>
3+
<PackageReference Update="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" />
4+
</ItemGroup>
5+
</Project>

src/UiPath.CoreIpc/Dtos.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text;
1+
using System.Diagnostics.CodeAnalysis;
2+
using System.Text;
23
using Newtonsoft.Json;
34
namespace UiPath.CoreIpc;
45
public class Message
@@ -45,7 +46,18 @@ public TResult Deserialize<TResult>(ISerializer serializer, bool objectParameter
4546
[Serializable]
4647
public record Error(string Message, string StackTrace, string Type, Error InnerError)
4748
{
49+
[return: NotNullIfNotNull(nameof(exception))]
50+
public static Error? FromException(Exception? exception)
51+
=> exception is null
52+
? null
53+
: new(
54+
Message: exception.Message,
55+
StackTrace: exception.StackTrace ?? exception.GetBaseException().StackTrace,
56+
Type: GetExceptionType(exception),
57+
InnerError: FromException(exception.InnerException));
4858
public override string ToString() => new RemoteException(this).ToString();
59+
60+
private static string GetExceptionType(Exception exception) => (exception as RemoteException)?.Type ?? exception.GetType().FullName;
4961
}
5062
[Serializable]
5163
public class RemoteException : Exception

src/UiPath.CoreIpc/Polyfills.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#if NETFRAMEWORK
2+
3+
namespace System.Diagnostics.CodeAnalysis;
4+
5+
using static AttributeTargets;
6+
7+
[ExcludeFromCodeCoverage]
8+
[DebuggerNonUserCode]
9+
[AttributeUsage(Parameter | Property | ReturnValue, AllowMultiple = true)]
10+
internal sealed class NotNullIfNotNullAttribute : Attribute
11+
{
12+
/// <summary>
13+
/// Gets the associated parameter name.
14+
/// The output will be non-<see langword="null"/> if the argument to the
15+
/// parameter specified is non-<see langword="null"/>.
16+
/// </summary>
17+
public string ParameterName { get; }
18+
19+
/// <summary>
20+
/// Initializes the attribute with the associated parameter name.
21+
/// </summary>
22+
/// <param name="parameterName">
23+
/// The associated parameter name.
24+
/// The output will be non-<see langword="null"/> if the argument to the
25+
/// parameter specified is non-<see langword="null"/>.
26+
/// </param>
27+
public NotNullIfNotNullAttribute(string parameterName) =>
28+
ParameterName = parameterName;
29+
}
30+
#endif

src/UiPath.CoreIpc/UiPath.CoreIpc.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<NoWarn>CA1416</NoWarn>
1717
<LangVersion>latest</LangVersion>
1818
<ImplicitUsings>true</ImplicitUsings>
19+
<Nullable>annotations</Nullable>
1920
</PropertyGroup>
2021
<ItemGroup Condition="$(TargetFramework) == 'net461'">
2122
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
@@ -25,7 +26,7 @@
2526
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
2627
<_Parameter1>UiPath.CoreIpc.Tests</_Parameter1>
2728
</AssemblyAttribute>
28-
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.1" />
29+
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
2930
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
3031
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
3132
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />

0 commit comments

Comments
 (0)