Skip to content

Commit

Permalink
Span compat (#757)
Browse files Browse the repository at this point in the history
* Start using hashing and span

* Skip some tests for now

* Working version

* Cleanup

* More span

* Cleanup

* Cleanup response

* More Span

* Fix hash

* More span

* Add netstandard compat back in

* Fix null checks

* Format

* Fix all span for netstandard

* Update package

* Add net48 compat in tests

* Fix warnings

* Fix test

* Completes changes to support 4.7.2 & 4.8 releases

* Changes to support 4.x releases

* Fix tags

* Fix file name

* turn the escaping off

* Format

* Update format

* Fix tests

* Update nuget

* Fix warnings

* More span

* Format

* Fix test

* More span

* Optimize streams

* Format again

* More memory

* Format

* Performance

* Fix test

* Progress

* More stream

* Format

* Fix response

* More span

* Use memory

* fixes the lint errors

* Fix merge

* Fixes

(cherry picked from commit 3363b25)

* More fixes

(cherry picked from commit 869fc5f)

* more lint changes

---------

Co-authored-by: Ersan <ersan.bozduman@gmail.com>
  • Loading branch information
martijn00 and ebozduman authored Apr 13, 2023
1 parent bc8104f commit c43ef12
Show file tree
Hide file tree
Showing 61 changed files with 959 additions and 742 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2022.3.2",
"version": "2023.1.0",
"commands": [
"jb"
]
},
"regitlint": {
"version": "6.3.10",
"version": "6.3.11",
"commands": [
"regitlint"
]
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="IDisposableAnalyzers" Version="4.0.2">
<PackageReference Include="IDisposableAnalyzers" Version="4.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ReflectionAnalyzers" Version="0.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.14">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions FileUploader/FileUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static bool IsWindows()
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
}

private static void Main(string[] args)
private static async Task Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
| SecurityProtocolType.Tls11
Expand All @@ -50,7 +50,7 @@ private static void Main(string[] args)
.WithCredentials(accessKey, secretKey)
.WithSSL()
.Build();
Run(minio).Wait();
await Run(minio).ConfigureAwait(false);
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/CustomRequestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static async Task Run(IMinioClient minio)
}
}

internal class MyRequestLogger : IRequestLogger
internal sealed class MyRequestLogger : IRequestLogger
{
public void LogRequest(RequestToLog requestToLog, ResponseToLog responseToLog, double durationMs)
{
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/GetBucketTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public static async Task Run(IMinioClient minio,
new GetBucketTagsArgs()
.WithBucket(bucketName)
).ConfigureAwait(false);
if (tags != null && tags.GetTags()?.Count > 0)
if (tags != null && tags.Tags?.Count > 0)
{
Console.WriteLine($"Got Bucket Tags set for bucket {bucketName}.");
foreach (var tag in tags.GetTags()) Console.WriteLine(tag.Key + " : " + tag.Value);
foreach (var tag in tags.Tags) Console.WriteLine(tag.Key + " : " + tag.Value);
Console.WriteLine();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/GetObjectTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public static async Task Run(IMinioClient minio,
.WithObject(objectName)
.WithVersionId(versionId)
).ConfigureAwait(false);
if (tags != null && tags.GetTags()?.Count > 0)
if (tags != null && tags.Tags?.Count > 0)
{
Console.WriteLine($"Got tags set for object {bucketName}/{objectName}.");
foreach (var tag in tags.GetTags()) Console.WriteLine(tag.Key + " : " + tag.Value);
foreach (var tag in tags.Tags) Console.WriteLine(tag.Key + " : " + tag.Value);
Console.WriteLine();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/GetPartialObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static async Task Run(IMinioClient minio,
{
var fileStream = File.Create(fileName);
await stream.CopyToAsync(fileStream).ConfigureAwait(false);
await fileStream.DisposeAsync();
await fileStream.DisposeAsync().ConfigureAwait(false);
var writtenInfo = new FileInfo(fileName);
var file_read_size = writtenInfo.Length;
// Uncomment to print the file on output console
Expand Down
34 changes: 17 additions & 17 deletions Minio.Examples/Cases/PutObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using CommunityToolkit.HighPerformance;
using Minio.DataModel;

namespace Minio.Examples.Cases;
Expand All @@ -31,25 +32,24 @@ public static async Task Run(IMinioClient minio,
{
try
{
var bs = await File.ReadAllBytesAsync(fileName).ConfigureAwait(false);
ReadOnlyMemory<byte> bs = await File.ReadAllBytesAsync(fileName).ConfigureAwait(false);
Console.WriteLine("Running example for API: PutObjectAsync");
using (var filestream = new MemoryStream(bs))
var filestream = bs.AsStream();

var fileInfo = new FileInfo(fileName);
var metaData = new Dictionary<string, string>
{
var fileInfo = new FileInfo(fileName);
var metaData = new Dictionary<string, string>
{
{ "Test-Metadata", "Test Test" }
};
var args = new PutObjectArgs()
.WithBucket(bucketName)
.WithObject(objectName)
.WithStreamData(filestream)
.WithObjectSize(filestream.Length)
.WithContentType("application/octet-stream")
.WithHeaders(metaData)
.WithServerSideEncryption(sse);
await minio.PutObjectAsync(args).ConfigureAwait(false);
}
{ "Test-Metadata", "Test Test" }
};
var args = new PutObjectArgs()
.WithBucket(bucketName)
.WithObject(objectName)
.WithStreamData(filestream)
.WithObjectSize(filestream.Length)
.WithContentType("application/octet-stream")
.WithHeaders(metaData)
.WithServerSideEncryption(sse);
await minio.PutObjectAsync(args).ConfigureAwait(false);

Console.WriteLine($"Uploaded object {objectName} to bucket {bucketName}");
Console.WriteLine();
Expand Down
19 changes: 9 additions & 10 deletions Minio.Examples/Cases/SelectObjectContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

using System.Text;
using CommunityToolkit.HighPerformance;
using Minio.DataModel;

namespace Minio.Examples.Cases;
Expand All @@ -39,16 +40,14 @@ public static async Task Run(IMinioClient minio,
csvString.AppendLine("Employee1,,1000");
csvString.AppendLine("Employee5,Employee1,500");
csvString.AppendLine("Employee2,Employee1,800");
var csvBytes = Encoding.UTF8.GetBytes(csvString.ToString());
using (var stream = new MemoryStream(csvBytes))
{
var putObjectArgs = new PutObjectArgs()
.WithBucket(bucketName)
.WithObject(newObjectName)
.WithStreamData(stream)
.WithObjectSize(stream.Length);
await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false);
}
ReadOnlyMemory<byte> csvBytes = Encoding.UTF8.GetBytes(csvString.ToString());
var stream = csvBytes.AsStream();
var putObjectArgs = new PutObjectArgs()
.WithBucket(bucketName)
.WithObject(newObjectName)
.WithStreamData(stream)
.WithObjectSize(stream.Length);
await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false);

var queryType = QueryExpressionType.SQL;
var queryExpr = "select count(*) from s3object";
Expand Down
Loading

0 comments on commit c43ef12

Please sign in to comment.