Skip to content

Commit 9c19f70

Browse files
authored
lamda fixes and add RunFullSyncAsync method (#23)
LOTS more AI code fixes to come
1 parent c803372 commit 9c19f70

File tree

32 files changed

+264
-526
lines changed

32 files changed

+264
-526
lines changed

src/aspire/AStar.Dev.Web.ServiceDefaults/Extensions.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,18 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder)
5353
});
5454

5555
_ = builder.Services.AddOpenTelemetry()
56-
.WithMetrics(metrics =>
57-
{
58-
_ = metrics.AddAspNetCoreInstrumentation()
56+
.WithMetrics(metrics => _ = metrics.AddAspNetCoreInstrumentation()
5957
.AddHttpClientInstrumentation()
60-
.AddRuntimeInstrumentation();
61-
})
62-
.WithTracing(tracing =>
63-
{
64-
_ = tracing.AddSource(builder.Environment.ApplicationName)
58+
.AddRuntimeInstrumentation())
59+
.WithTracing(tracing => _ = tracing.AddSource(builder.Environment.ApplicationName)
6560
.AddAspNetCoreInstrumentation(tracing =>
6661
// Exclude health check requests from tracing
6762
tracing.Filter = context => !context.Request.Path.StartsWithSegments(HealthEndpointPath)
6863
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
6964
)
7065
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
7166
//.AddGrpcClientInstrumentation()
72-
.AddHttpClientInstrumentation();
73-
});
67+
.AddHttpClientInstrumentation());
7468

7569
_ = builder.AddOpenTelemetryExporters();
7670

@@ -82,7 +76,7 @@ private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builde
8276
{
8377
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
8478

85-
if (useOtlpExporter)
79+
if(useOtlpExporter)
8680
_ = builder.Services.AddOpenTelemetry().UseOtlpExporter();
8781

8882
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
@@ -110,7 +104,7 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
110104
{
111105
// Adding health checks endpoints to applications in non-development environments has security implications.
112106
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
113-
if (app.Environment.IsDevelopment())
107+
if(app.Environment.IsDevelopment())
114108
{
115109
// All health checks must pass for app to be considered ready to accept traffic after starting
116110
_ = app.MapHealthChecks(HealthEndpointPath);

src/modules/apis/AStar.Web.ApiService/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// Configure the HTTP request pipeline.
2828
app.UseExceptionHandler();
2929

30-
if (app.Environment.IsDevelopment()) _ = app.MapOpenApi();
30+
if(app.Environment.IsDevelopment()) _ = app.MapOpenApi();
3131

3232
string[] summaries =
3333
["Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"];

src/nuget-packages/AStar.Dev.Functional.Extensions/CollectionAndStatusExtensions.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Collections.ObjectModel;
4-
using System.Linq;
5-
using System.Threading.Tasks;
62

73
namespace AStar.Dev.Functional.Extensions;
84

@@ -19,14 +15,14 @@ public static class CollectionAndStatusExtensions
1915
public static async Task ApplyToCollectionAsync<T>(this Task<Result<IEnumerable<T>, Exception>> resultTask, ObservableCollection<T> target, Action<Exception>? onError = null)
2016
{
2117
Result<IEnumerable<T>, Exception> result = await resultTask.ConfigureAwait(false);
22-
if (result is Result<IEnumerable<T>, Exception>.Ok ok)
18+
if(result is Result<IEnumerable<T>, Exception>.Ok ok)
2319
{
2420
// Replace items while preserving collection instance
2521
target.Clear();
26-
foreach (T item in ok.Value ?? Enumerable.Empty<T>())
22+
foreach(T item in ok.Value ?? Enumerable.Empty<T>())
2723
target.Add(item);
2824
}
29-
else if (result is Result<IEnumerable<T>, Exception>.Error err)
25+
else if(result is Result<IEnumerable<T>, Exception>.Error err)
3026
{
3127
onError?.Invoke(err.Reason);
3228
}

src/nuget-packages/AStar.Dev.Functional.Extensions/ConvenienceResultExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Threading.Tasks;
3-
41
namespace AStar.Dev.Functional.Extensions;
52

63
/// <summary>

src/nuget-packages/AStar.Dev.Functional.Extensions/OptionExtensions.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static Result<T, TError> ToResult<T, TError>(this Option<T> option, Func<
109109
public static void Deconstruct<T>(this Option<T> option, out bool isSome, out T? value)
110110
{
111111
isSome = option is Option<T>.Some;
112-
value = isSome ? ((Option<T>.Some)option).Value : default;
112+
value = isSome ? ((Option<T>.Some)option).Value : default;
113113
}
114114

115115
/// <summary>
@@ -119,8 +119,8 @@ public static async Task<Option<TResult>> MapAsync<T, TResult>(this Option<T> op
119119
=> option switch
120120
{
121121
Option<T>.Some some => new Option<TResult>.Some(await mapAsync(some.Value)),
122-
Option<T>.None => Option.None<TResult>(),
123-
_ => throw new InvalidOperationException(UnreachableMessage)
122+
Option<T>.None => Option.None<TResult>(),
123+
_ => throw new InvalidOperationException(UnreachableMessage)
124124
};
125125

126126
/// <summary>
@@ -146,8 +146,8 @@ public static async Task<Option<TResult>> BindAsync<T, TResult>(this Option<T> o
146146
=> option switch
147147
{
148148
Option<T>.Some some => await bindAsync(some.Value),
149-
Option<T>.None => Option.None<TResult>(),
150-
_ => throw new InvalidOperationException(UnreachableMessage)
149+
Option<T>.None => Option.None<TResult>(),
150+
_ => throw new InvalidOperationException(UnreachableMessage)
151151
};
152152

153153
/// <summary>
@@ -195,7 +195,8 @@ public static async Task<Result<T, TError>> ToResultAsync<T, TError>(this Task<O
195195
/// </summary>
196196
public static Option<T> Tap<T>(this Option<T> option, Action<T> action)
197197
{
198-
if(option is Option<T>.Some some) action(some.Value);
198+
if(option is Option<T>.Some some)
199+
action(some.Value);
199200

200201
return option;
201202
}
@@ -205,7 +206,8 @@ public static Option<T> Tap<T>(this Option<T> option, Action<T> action)
205206
/// </summary>
206207
public static async Task<Option<T>> TapAsync<T>(this Option<T> option, Func<T, Task> actionAsync)
207208
{
208-
if(option is Option<T>.Some some) await actionAsync(some.Value);
209+
if(option is Option<T>.Some some)
210+
await actionAsync(some.Value);
209211

210212
return option;
211213
}
@@ -239,8 +241,8 @@ public static async Task<TResult> MatchAsync<T, TResult>(this Option<T> option,
239241
=> option switch
240242
{
241243
Option<T>.Some some => await onSomeAsync(some.Value),
242-
Option<T>.None => onNone(),
243-
_ => throw new InvalidOperationException(UnreachableMessage)
244+
Option<T>.None => onNone(),
245+
_ => throw new InvalidOperationException(UnreachableMessage)
244246
};
245247

246248
/// <summary>
@@ -250,8 +252,8 @@ public static async Task<TResult> MatchAsync<T, TResult>(this Option<T> option,
250252
=> option switch
251253
{
252254
Option<T>.Some some => onSome(some.Value),
253-
Option<T>.None => await onNoneAsync(),
254-
_ => throw new InvalidOperationException(UnreachableMessage)
255+
Option<T>.None => await onNoneAsync(),
256+
_ => throw new InvalidOperationException(UnreachableMessage)
255257
};
256258

257259
/// <summary>
@@ -261,8 +263,8 @@ public static async Task<TResult> MatchAsync<T, TResult>(this Option<T> option,
261263
=> option switch
262264
{
263265
Option<T>.Some some => await onSomeAsync(some.Value),
264-
Option<T>.None => await onNoneAsync(),
265-
_ => throw new InvalidOperationException(UnreachableMessage)
266+
Option<T>.None => await onNoneAsync(),
267+
_ => throw new InvalidOperationException(UnreachableMessage)
266268
};
267269

268270
/// <summary>
@@ -320,7 +322,8 @@ public static IEnumerable<TResult> Choose<T, TResult>(this IEnumerable<T> source
320322
{
321323
Option<TResult> option = chooser(item);
322324

323-
if(option is Option<TResult>.Some some) yield return some.Value;
325+
if(option is Option<TResult>.Some some)
326+
yield return some.Value;
324327
}
325328
}
326329

src/nuget-packages/AStar.Dev.Functional.Extensions/Option{T}.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public sealed class Some : Option<T>
9898
/// <exception cref="ArgumentNullException" />
9999
public Some(T value)
100100
{
101-
if(value is null) throw new ArgumentNullException(nameof(value));
101+
if(value is null)
102+
throw new ArgumentNullException(nameof(value));
102103

103104
Value = value;
104105
}

src/nuget-packages/AStar.Dev.Functional.Extensions/ResultExtensions.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ public static async Task<Result<TNew, TError>> BindAsync<TSuccess, TError, TNew>
264264
/// </returns>
265265
public static Result<TSuccess, TError> Tap<TSuccess, TError>(this Result<TSuccess, TError> result, Action<TSuccess> action)
266266
{
267-
if(result is Result<TSuccess, TError>.Ok ok) action(ok.Value);
267+
if(result is Result<TSuccess, TError>.Ok ok)
268+
action(ok.Value);
268269

269270
return result;
270271
}
@@ -282,7 +283,8 @@ public static Result<TSuccess, TError> Tap<TSuccess, TError>(this Result<TSucces
282283
/// </returns>
283284
public static Result<TSuccess, TError> TapError<TSuccess, TError>(this Result<TSuccess, TError> result, Action<TError> action)
284285
{
285-
if(result is Result<TSuccess, TError>.Error err) action(err.Reason);
286+
if(result is Result<TSuccess, TError>.Error err)
287+
action(err.Reason);
286288

287289
return result;
288290
}
@@ -300,7 +302,8 @@ public static Result<TSuccess, TError> TapError<TSuccess, TError>(this Result<TS
300302
/// </returns>
301303
public static async Task<Result<TSuccess, TError>> TapAsync<TSuccess, TError>(this Result<TSuccess, TError> result, Func<TSuccess, Task> actionAsync)
302304
{
303-
if(result is Result<TSuccess, TError>.Ok ok) await actionAsync(ok.Value);
305+
if(result is Result<TSuccess, TError>.Ok ok)
306+
await actionAsync(ok.Value);
304307

305308
return result;
306309
}
@@ -354,7 +357,8 @@ public static async Task<Result<TSuccess, TError>> TapAsync<TSuccess, TError>(th
354357
/// </returns>
355358
public static async Task<Result<TSuccess, TError>> TapErrorAsync<TSuccess, TError>(this Result<TSuccess, TError> result, Func<TError, Task> actionAsync)
356359
{
357-
if(result is Result<TSuccess, TError>.Error err) await actionAsync(err.Reason);
360+
if(result is Result<TSuccess, TError>.Error err)
361+
await actionAsync(err.Reason);
358362

359363
return result;
360364
}

src/nuget-packages/AStar.Dev.Functional.Extensions/ViewModelResultExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Threading.Tasks;
3-
41
namespace AStar.Dev.Functional.Extensions;
52

63
/// <summary>
@@ -13,13 +10,13 @@ public static class ViewModelResultExtensions
1310
/// </summary>
1411
public static void Apply<T>(this Result<T, Exception> result, Action<T> onSuccess, Action<Exception>? onError = null)
1512
{
16-
if (result is Result<T, Exception>.Ok ok)
13+
if(result is Result<T, Exception>.Ok ok)
1714
{
1815
onSuccess(ok.Value);
1916
return;
2017
}
2118

22-
if (result is Result<T, Exception>.Error err)
19+
if(result is Result<T, Exception>.Error err)
2320
{
2421
onError?.Invoke(err.Reason);
2522
}
@@ -40,13 +37,13 @@ public static async Task ApplyAsync<T>(this Task<Result<T, Exception>> resultTas
4037
public static async Task ApplyAsync<T>(this Task<Result<T, Exception>> resultTask, Func<T, Task> onSuccessAsync, Func<Exception, Task>? onErrorAsync = null)
4138
{
4239
Result<T, Exception> result = await resultTask.ConfigureAwait(false);
43-
if (result is Result<T, Exception>.Ok ok)
40+
if(result is Result<T, Exception>.Ok ok)
4441
{
4542
await onSuccessAsync(ok.Value).ConfigureAwait(false);
4643
return;
4744
}
4845

49-
if (result is Result<T, Exception>.Error err && onErrorAsync is not null)
46+
if(result is Result<T, Exception>.Error err && onErrorAsync is not null)
5047
{
5148
await onErrorAsync(err.Reason).ConfigureAwait(false);
5249
}

src/services/AStar.Dev.OneDrive.Client/Services/AppPathHelper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using System.IO;
31
using System.Runtime.InteropServices;
42

53
namespace AStar.Dev.OneDrive.Client.Services;

0 commit comments

Comments
 (0)