Skip to content

Commit 8f213b0

Browse files
Automated dotnet-format update
1 parent 76a2d76 commit 8f213b0

File tree

12 files changed

+59
-37
lines changed

12 files changed

+59
-37
lines changed

demo/dotnetCampus.Ipc.WpfDemo/MainWindow.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
using System.Windows.Media.Imaging;
1616
using System.Windows.Navigation;
1717
using System.Windows.Shapes;
18-
using DotNetCampus.Cli;
1918
using dotnetCampus.Ipc.Context;
2019
using dotnetCampus.Ipc.Pipes;
2120
using dotnetCampus.Ipc.WpfDemo.View;
22-
21+
using DotNetCampus.Cli;
2322
using Walterlv.ThreadSwitchingTasks;
2423

2524
namespace dotnetCampus.Ipc.WpfDemo

src/dotnetCampus.Ipc.Analyzers/Generators/IpcPublicGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
1717
(syntaxNode, ct) => syntaxNode is InterfaceDeclarationSyntax { AttributeLists.Count: > 0 },
1818
// 语义解析:确定是否真的是感兴趣的 IPC 接口。
1919
(generatorSyntaxContext, ct) => IpcPublicCompilation.TryCreateIpcPublicCompilation(
20-
(InterfaceDeclarationSyntax)generatorSyntaxContext.Node,
20+
(InterfaceDeclarationSyntax) generatorSyntaxContext.Node,
2121
generatorSyntaxContext.SemanticModel,
2222
out var ipcPublicCompilation)
2323
? ipcPublicCompilation
@@ -30,7 +30,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3030
(syntaxNode, ct) => syntaxNode is ClassDeclarationSyntax { AttributeLists.Count: > 0 },
3131
// 语义解析:确定是否真的是感兴趣的 IPC 接口。
3232
(generatorSyntaxContext, ct) => IpcShapeCompilation.TryCreateIpcShapeCompilation(
33-
(ClassDeclarationSyntax)generatorSyntaxContext.Node,
33+
(ClassDeclarationSyntax) generatorSyntaxContext.Node,
3434
generatorSyntaxContext.SemanticModel,
3535
out var ipcPublicCompilation)
3636
? ipcPublicCompilation

src/dotnetCampus.Ipc.Analyzers/Generators/Utils/GeneratorHelper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using dotnetCampus.Ipc.Generators.Compiling;
2-
using dotnetCampus.Ipc.Generators.Builders;
1+
using dotnetCampus.Ipc.Generators.Builders;
2+
using dotnetCampus.Ipc.Generators.Compiling;
33

44
namespace dotnetCampus.Ipc.Generators.Utils;
55

@@ -53,10 +53,10 @@ internal static string GenerateProxySource(IpcShapeCompilation ipc)
5353
internal static string GenerateShapeSource(IpcPublicCompilation ipc, string? typeName, string? @namespace)
5454
{
5555
using var builder = new SourceTextBuilder(@namespace ?? ipc.IpcType.ContainingNamespace.ToString())
56-
{
57-
SimplifyTypeNamesByUsingNamespace = true,
58-
ShouldPrependGlobal = false,
59-
}
56+
{
57+
SimplifyTypeNamesByUsingNamespace = true,
58+
ShouldPrependGlobal = false,
59+
}
6060
.Using("dotnetCampus.Ipc.CompilerServices.Attributes")
6161
.Using("dotnetCampus.Ipc.CompilerServices.GeneratedProxies")
6262
.AddTypeDeclaration($"internal sealed class {typeName ?? $"{ipc.IpcType.Name}IpcShape"}", t => t

src/dotnetCampus.Ipc/CompilerServices/GeneratedProxies/Contexts/GeneratedIpcJointResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal static async Task<GeneratedIpcJointResponse> FromAsyncReturnModel(
2727
var returnModel = await asyncReturnModel.ConfigureAwait(false);
2828
var message = returnModel is null
2929
? new IpcMessage()
30-
: serializer.SerializeToIpcMessage((ulong)KnownMessageHeaders.RemoteObjectMessageHeader, returnModel, "Return");
30+
: serializer.SerializeToIpcMessage((ulong) KnownMessageHeaders.RemoteObjectMessageHeader, returnModel, "Return");
3131
return new GeneratedIpcJointResponse(message);
3232
}
3333
}

src/dotnetCampus.Ipc/CompilerServices/GeneratedProxies/GeneratedIpcFactory.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public static TPublic CreateIpcProxy<TPublic>(this IIpcProvider ipcProvider, IPe
7474
nameof(TPublic));
7575
}
7676

77-
var proxy = (GeneratedIpcProxy<TPublic>)proxyFactory();
77+
var proxy = (GeneratedIpcProxy<TPublic>) proxyFactory();
7878
proxy.Context = ipcProvider.GetGeneratedContext();
7979
proxy.PeerProxy = peer;
8080
proxy.ObjectId = ipcObjectId;
81-
return (TPublic)(object)proxy;
81+
return (TPublic) (object) proxy;
8282
}
8383

8484
/// <summary>
@@ -101,12 +101,12 @@ public static TPublic CreateIpcProxy<TPublic>(this IIpcProvider ipcProvider, IPe
101101
nameof(TPublic));
102102
}
103103

104-
var proxy = (GeneratedIpcProxy<TPublic>)proxyFactory();
104+
var proxy = (GeneratedIpcProxy<TPublic>) proxyFactory();
105105
proxy.Context = ipcProvider.GetGeneratedContext();
106106
proxy.PeerProxy = peer;
107107
proxy.ObjectId = ipcObjectId;
108108
proxy.RuntimeConfigs = ipcProxyConfigs;
109-
return (TPublic)(object)proxy;
109+
return (TPublic) (object) proxy;
110110
}
111111

112112
/// <summary>
@@ -128,11 +128,11 @@ public static TPublic CreateIpcProxy<TPublic, TShape>(this IIpcProvider ipcProvi
128128
nameof(TShape));
129129
}
130130

131-
var proxy = (GeneratedIpcProxy<TPublic>)proxyFactory();
131+
var proxy = (GeneratedIpcProxy<TPublic>) proxyFactory();
132132
proxy.Context = ipcProvider.GetGeneratedContext();
133133
proxy.PeerProxy = peer;
134134
proxy.ObjectId = ipcObjectId;
135-
return (TPublic)(object)proxy;
135+
return (TPublic) (object) proxy;
136136
}
137137

138138
/// <summary>
@@ -154,7 +154,7 @@ public static TPublic CreateIpcJoint<TPublic>(this IIpcProvider ipcProvider, TPu
154154
}
155155

156156
var context = ipcProvider.GetGeneratedContext();
157-
var joint = (GeneratedIpcJoint<TPublic>)jointFactory();
157+
var joint = (GeneratedIpcJoint<TPublic>) jointFactory();
158158
joint.Context = context;
159159
joint.SetInstance(realInstance);
160160
context.JointManager.AddPublicIpcObject(joint, ipcObjectId);

src/dotnetCampus.Ipc/CompilerServices/GeneratedProxies/GeneratedIpcJoint.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public abstract partial class GeneratedIpcJoint<TContract> : GeneratedIpcJoint w
7272
/// 设置此对接对象的真实实例。
7373
/// </summary>
7474
/// <param name="realInstance">真实实例。</param>
75-
internal sealed override void SetInstance(object realInstance) => SetInstance((TContract)realInstance);
75+
internal sealed override void SetInstance(object realInstance) => SetInstance((TContract) realInstance);
7676

7777
/// <summary>
7878
/// 设置此对接对象的真实实例。
@@ -107,7 +107,7 @@ protected void MatchMethod(ulong memberId, Action methodInvoker)
107107
methodInvoker();
108108
return DefaultGarm;
109109
}
110-
));
110+
));
111111
}
112112

113113
/// <summary>
@@ -132,7 +132,7 @@ protected void MatchMethod(ulong memberId, Func<Task> methodInvoker)
132132
await methodInvoker().ConfigureAwait(false);
133133
return DefaultGarm;
134134
}
135-
));
135+
));
136136
}
137137

138138
/// <summary>
@@ -157,7 +157,7 @@ protected void MatchMethod<T>(ulong memberId, Action<T> methodInvoker)
157157
methodInvoker(CastArg<T>(args[0])!);
158158
return DefaultGarm;
159159
}
160-
));
160+
));
161161
}
162162

163163
/// <summary>
@@ -172,7 +172,7 @@ protected void MatchMethod<T>(ulong memberId, Func<T, Task> methodInvoker)
172172
await methodInvoker(CastArg<T>(args[0])!).ConfigureAwait(false);
173173
return DefaultGarm;
174174
}
175-
));
175+
));
176176
}
177177

178178
/// <summary>

src/dotnetCampus.Ipc/CompilerServices/GeneratedProxies/GeneratedIpcProxy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected async Task<T> GetValueAsync<T>(ulong memberId, IpcMemberInfo info, [Ca
9393
if (_readonlyPropertyValues.TryGetValue(propertyName, out var cachedValue))
9494
{
9595
// 当只读字典中存在此属性的缓存时,直接取缓存。
96-
return (T)cachedValue!;
96+
return (T) cachedValue!;
9797
}
9898
// 否则,通过 IPC 访问获取此属性的值后设入缓存。(这里可能存在并发情况,会导致浪费的 IPC 访问,但能确保数据一致性)。
9999
var value = await IpcInvokeAsync<T>(MemberInvokingType.GetProperty, memberId, propertyName, null, info).ConfigureAwait(false);
@@ -206,15 +206,15 @@ private async Task<T> IpcInvokeAsync<T>(MemberInvokingType callType, ulong membe
206206
catch (IpcRemoteException) when (ignoresIpcException)
207207
{
208208
// 如果目标要求忽略异常,则返回指定值或默认值。
209-
return info.DefaultReturn is { } defaultReturn ? (T)defaultReturn : default!;
209+
return info.DefaultReturn is { } defaultReturn ? (T) defaultReturn : default!;
210210
}
211211
catch (AggregateException ex) when (ex.InnerExceptions.Count >= 1)
212212
{
213213
var innerException = ex.Flatten().InnerExceptions[0];
214214
if (innerException is IpcRemoteException)
215215
{
216216
// 如果目标要求忽略异常,则返回指定值或默认值。
217-
return info.DefaultReturn is { } defaultReturn ? (T)defaultReturn : default!;
217+
return info.DefaultReturn is { } defaultReturn ? (T) defaultReturn : default!;
218218
}
219219
else
220220
{
@@ -240,7 +240,7 @@ private async Task<T> InvokeWithTimeoutAsync<T>(MemberInvokingType callType, ulo
240240
{
241241
// 任务超时(不抛异常)。
242242
IgnoreTaskExceptionsAsync(ipcTask);
243-
return defaultReturn is null ? default! : (T)defaultReturn;
243+
return defaultReturn is null ? default! : (T) defaultReturn;
244244
}
245245
// 任务超时(抛异常)。
246246
IgnoreTaskExceptionsAsync(ipcTask);

src/dotnetCampus.Ipc/CompilerServices/GeneratedProxies/PublicIpcJointManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void AddPublicIpcObject(Type contractType, GeneratedIpcJoint joint, strin
6969
public bool TryJoint(IIpcRequestContext request, out Task<IIpcResponseMessage> responseTask)
7070
{
7171
if (Context.ObjectSerializer.TryDeserializeFromIpcMessage<GeneratedProxyMemberInvokeModel>(
72-
request.IpcBufferMessage, (ulong)KnownMessageHeaders.RemoteObjectMessageHeader, out var requestModel)
72+
request.IpcBufferMessage, (ulong) KnownMessageHeaders.RemoteObjectMessageHeader, out var requestModel)
7373
&& TryFindJoint(requestModel, out var joint)
7474
&& requestModel.MemberName is not null)
7575
{

src/dotnetCampus.Ipc/CompilerServices/GeneratedProxies/Utils/IpcProxyInvokingHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ internal string TypeName
9393
return null;
9494
}
9595

96-
var header = (ulong)KnownMessageHeaders.RemoteObjectMessageHeader;
96+
var header = (ulong) KnownMessageHeaders.RemoteObjectMessageHeader;
9797
var requestMessage = Context.ObjectSerializer.SerializeToIpcMessage(header, model, model.ToString());
9898
//requestMessage = new IpcMessage(requestMessage.Tag, requestMessage.Body, CoreMessageType.JsonObject);
9999
var responseMessage = await PeerProxy.GetResponseAsync(requestMessage).ConfigureAwait(false);

src/dotnetCampus.Ipc/Serialization/SystemTextJsonIpcObjectSerializer.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if NET6_0_OR_GREATER
22

3+
using System.Diagnostics.CodeAnalysis;
34
using System.Text;
45
using System.Text.Json;
56
using System.Text.Json.Serialization;
@@ -35,6 +36,15 @@ public SystemTextJsonIpcObjectSerializer(JsonSerializerContext jsonSerializerCon
3536
public JsonSerializerContext? JsonSerializerContext { get; }
3637

3738
/// <inheritdoc />
39+
40+
<<<<<<< TODO: Unmerged change from project 'dotnetCampus.Ipc(net6.0)', Before:
41+
public byte[] Serialize(object? value)
42+
=======
43+
[RequiresUnreferencedCode()]
44+
public byte[] Serialize(object? value)
45+
>>>>>>> After
46+
[RequiresDynamicCode()]
47+
[RequiresUnreferencedCode()]
3848
public byte[] Serialize(object? value)
3949
{
4050
if (value is null)
@@ -56,6 +66,15 @@ public byte[] Serialize(object? value)
5666
}
5767

5868
/// <inheritdoc />
69+
70+
<<<<<<< TODO: Unmerged change from project 'dotnetCampus.Ipc(net6.0)', Before:
71+
public void Serialize(Stream stream, object? value)
72+
=======
73+
[RequiresUnreferencedCode()]
74+
public void Serialize(Stream stream, object? value)
75+
>>>>>>> After
76+
[RequiresDynamicCode()]
77+
[RequiresUnreferencedCode()]
5978
public void Serialize(Stream stream, object? value)
6079
{
6180
if (value is null)
@@ -75,6 +94,7 @@ public void Serialize(Stream stream, object? value)
7594
}
7695

7796
/// <inheritdoc />
97+
[RequiresUnreferencedCode()]
7898
public IpcJsonElement SerializeToElement(object? value)
7999
{
80100
if (value is null)
@@ -96,6 +116,7 @@ public IpcJsonElement SerializeToElement(object? value)
96116
}
97117

98118
/// <inheritdoc />
119+
[RequiresUnreferencedCode()]
99120
public T? Deserialize<T>(byte[] data, int start, int length)
100121
{
101122
var span = data.AsSpan(start, length);
@@ -111,6 +132,7 @@ public IpcJsonElement SerializeToElement(object? value)
111132
}
112133

113134
/// <inheritdoc />
135+
[RequiresUnreferencedCode()]
114136
public T? Deserialize<T>(Stream stream)
115137
{
116138
if (JsonSerializerContext is null)
@@ -124,6 +146,7 @@ public IpcJsonElement SerializeToElement(object? value)
124146
}
125147

126148
/// <inheritdoc />
149+
[RequiresUnreferencedCode()]
127150
public T? Deserialize<T>(IpcJsonElement jsonElement)
128151
{
129152
if (jsonElement.RawValueOnSystemTextJson is not { } element)

0 commit comments

Comments
 (0)