Skip to content

1.0.80 #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.6" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.6" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.6" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.7" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.7" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.7" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.5.25277.114" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0-preview.5.25277.114" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.6.25358.103" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0-preview.6.25358.103" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
Expand All @@ -36,12 +36,12 @@
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="xunit.v3" Version="2.0.3" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="BenchmarkDotNet" Version="0.15.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.15.2" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.6" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="9.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.7" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="9.0.7" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.0.2" />
<PackageVersion Include="Dapper" Version="2.1.66" />
Expand Down
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionPatch>79</VersionPatch>
<VersionPatch>80</VersionPatch>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
</PropertyGroup>
</Project>
17 changes: 17 additions & 0 deletions src/WeihanLi.Common/Helpers/ConsoleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,21 @@ public static CommandResult PrintOutputToConsole(this CommandResult commandResul

return commandResult;
}

public static bool HasStandardInput()
{
return Console.IsInputRedirected && Console.In.Peek() != -1;
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Peek() method can block if input is redirected from a slow source. Consider using Console.KeyAvailable or implementing a timeout mechanism to avoid potential blocking.

Suggested change
return Console.IsInputRedirected && Console.In.Peek() != -1;
if (!Console.IsInputRedirected)
{
return false;
}
try
{
var task = Task.Run(() => Console.In.Peek());
if (task.Wait(TimeSpan.FromMilliseconds(100)))
{
return task.Result != -1;
}
}
catch
{
// Handle exceptions if necessary
}
return false;

Copilot uses AI. Check for mistakes.

}

public static bool TryGetStandardInput([MaybeNullWhen(false)]out string input)
{
if (HasStandardInput())
{
input = Console.In.ReadToEnd();
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadToEnd() loads the entire input into memory at once, which could cause issues with large inputs. Consider using a streaming approach or adding size limits for production scenarios.

Copilot uses AI. Check for mistakes.

return true;
}

input = null;
return false;
}
}
20 changes: 8 additions & 12 deletions src/WeihanLi.Common/Helpers/Hosting/BackgroundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace WeihanLi.Common.Helpers.Hosting;

public abstract class BackgroundService : IHostedService, IDisposable
public abstract class BackgroundService : IHostedLifecycleService, IDisposable
{
private Task? _executeTask;
private CancellationTokenSource? _stoppingCts;
Expand Down Expand Up @@ -51,22 +51,18 @@ public virtual async Task StopAsync(CancellationToken cancellationToken)
await Task.WhenAny(_executeTask, tcs.Task).ConfigureAwait(false);
}
}

protected abstract Task ExecuteAsync(CancellationToken stoppingToken);

public virtual void Dispose()
{
_stoppingCts?.Cancel(false);
}
}

public abstract class BackgroundServiceWithLifecycle : BackgroundService, IHostedLifecycleService
{
public virtual Task StartingAsync(CancellationToken cancellationToken) => Task.CompletedTask;

public virtual Task StartedAsync(CancellationToken cancellationToken) => Task.CompletedTask;

public virtual Task StoppingAsync(CancellationToken cancellationToken) => Task.CompletedTask;

public virtual Task StoppedAsync(CancellationToken cancellationToken) => Task.CompletedTask;

protected abstract Task ExecuteAsync(CancellationToken stoppingToken);

public virtual void Dispose()
{
_stoppingCts?.Cancel(false);
}
}
1 change: 1 addition & 0 deletions src/WeihanLi.Common/Http/NoProxyHttpClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public NoProxyHttpClientHandler()
Proxy = null;
UseProxy = false;
UseCookies = false;
AllowAutoRedirect = false;
}
}
Loading