Skip to content

Commit

Permalink
add options to AOT supporting. #180
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Jan 22, 2025
1 parent 4a26cc4 commit 03cbf06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/Downloader/ConcurrentStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ public class ConcurrentStream : TaskStateManagement, IDisposable, IAsyncDisposab
private ConcurrentPacketBuffer<Packet> _inputBuffer;
private volatile bool _disposed;
private Stream _stream; // Lazy base stream
public long _position;
private long _position;
private CancellationTokenSource _watcherCancelSource;

/// <summary>
/// Gets the stream for reading and writing.
/// </summary>
protected Stream Stream => _stream ?? GetStream();

/// <summary>
/// keep state of of the stream is disposed or not.
/// </summary>
public bool IsDisposed => _disposed;

/// <summary>
Expand Down Expand Up @@ -170,6 +176,10 @@ private void Initial(long maxMemoryBufferBytes, ILogger logger = null)
task.Unwrap();
}

/// <summary>
/// Gets the stream for reading and writing.
/// </summary>
/// <returns></returns>
protected Stream GetStream()
{
if (_disposed || _stream is not null)
Expand Down
13 changes: 11 additions & 2 deletions src/Downloader/Downloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<LangVersion>latestMajor</LangVersion>
<Version>3.3.3</Version>
<AssemblyVersion>3.2.1</AssemblyVersion>
<FileVersion>3.2.1</FileVersion>
<FileVersion>3.2.1</FileVersion>
<Title>Downloader</Title>
<Authors>Behzad Khosravifar</Authors>
<Company>bezzad</Company>
Expand All @@ -16,7 +16,6 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Downloader.snk</AssemblyOriginatorKeyFile>
<Copyright>Copyright (C) 2019-2023 Behzad Khosravifar</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageIcon>downloader.png</PackageIcon>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand All @@ -31,6 +30,16 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
</PropertyGroup>

<!-- Enable AOT for .NET 8.0 target -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>full</TrimMode>
<PublishAot>true</PublishAot>
<IsAotCompatible>true</IsAotCompatible>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<OptimizationPreference>Speed</OptimizationPreference>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\net8.0\Downloader.xml</DocumentationFile>
</PropertyGroup>
Expand Down

0 comments on commit 03cbf06

Please sign in to comment.