@@ -23,7 +23,7 @@ internal void AddInput(int ioId, IAsyncMemorySource source)
23
23
{
24
24
if ( _inputs . ContainsKey ( ioId ) || _outputs . ContainsKey ( ioId ) )
25
25
{
26
- throw new ArgumentException ( "ioId" , $ "ioId { ioId } has already been assigned") ;
26
+ throw new ArgumentException ( $ "ioId { ioId } has already been assigned", nameof ( ioId ) ) ;
27
27
}
28
28
29
29
_inputs . Add ( ioId , source ) ;
@@ -32,7 +32,7 @@ internal void AddOutput(int ioId, IOutputDestination destination)
32
32
{
33
33
if ( _inputs . ContainsKey ( ioId ) || _outputs . ContainsKey ( ioId ) )
34
34
{
35
- throw new ArgumentException ( "ioId" , $ "ioId { ioId } has already been assigned") ;
35
+ throw new ArgumentException ( $ "ioId { ioId } has already been assigned", nameof ( ioId ) ) ;
36
36
}
37
37
38
38
_outputs . Add ( ioId , destination ) ;
@@ -148,7 +148,7 @@ public BuildEndpoint BuildCommandString(IBytesSource source, int? sourceIoId, IO
148
148
public BuildEndpoint BuildCommandString ( byte [ ] source , IOutputDestination dest , string commandString ) => BuildCommandString ( new MemorySource ( source ) , dest , commandString ) ;
149
149
150
150
/// <summary>
151
- /// Modify the input image (source) with the given command string and watermarks and encode to the (dest)
151
+ /// Modify the input image (source) with the given command string and watermarks and encode to the (dest)
152
152
/// </summary>
153
153
/// <param name="source"></param>
154
154
/// <param name="dest"></param>
@@ -265,7 +265,7 @@ internal string ToJsonDebug(SecurityOptions? securityOptions = default)
265
265
internal async Task < BuildJobResult > FinishAsync ( JobExecutionOptions executionOptions , SecurityOptions ? securityOptions , CancellationToken cancellationToken )
266
266
{
267
267
var inputByteArrays = await Task . WhenAll (
268
- _inputs . Select ( async pair => new KeyValuePair < int , ReadOnlyMemory < byte > > ( pair . Key , await pair . Value . BorrowReadOnlyMemoryAsync ( cancellationToken ) ) ) ) ;
268
+ _inputs . Select ( async pair => new KeyValuePair < int , ReadOnlyMemory < byte > > ( pair . Key , await pair . Value . BorrowReadOnlyMemoryAsync ( cancellationToken ) . ConfigureAwait ( false ) ) ) ) . ConfigureAwait ( false ) ;
269
269
using ( var ctx = new JobContext ( ) )
270
270
{
271
271
foreach ( var pair in inputByteArrays )
@@ -282,7 +282,7 @@ internal async Task<BuildJobResult> FinishAsync(JobExecutionOptions executionOpt
282
282
var message = CreateJsonNodeForFramewiseWithSecurityOptions ( securityOptions ) ;
283
283
284
284
var response = executionOptions . OffloadCpuToThreadPool
285
- ? await Task . Run ( ( ) => ctx . InvokeExecute ( message ) , cancellationToken )
285
+ ? await Task . Run ( ( ) => ctx . InvokeExecute ( message ) , cancellationToken ) . ConfigureAwait ( false )
286
286
: ctx . InvokeExecute ( message ) ;
287
287
288
288
// TODO: Should we handle failure before copying out the buffers??
@@ -292,7 +292,7 @@ internal async Task<BuildJobResult> FinishAsync(JobExecutionOptions executionOpt
292
292
foreach ( var pair in _outputs )
293
293
{
294
294
using var memOwner = ctx . BorrowOutputBufferMemoryAndAddReference ( pair . Key ) ;
295
- await pair . Value . AdaptiveWriteAllAsync ( memOwner . Memory , cancellationToken ) ;
295
+ await pair . Value . AdaptiveWriteAllAsync ( memOwner . Memory , cancellationToken ) . ConfigureAwait ( false ) ;
296
296
}
297
297
return BuildJobResult . From ( response , _outputs ) ;
298
298
}
@@ -377,7 +377,7 @@ internal async Task CopyOutputsToDestinations(CancellationToken token)
377
377
{
378
378
using ( var stream = pair . Key . ReadFromBeginning ( ) )
379
379
{
380
- await pair . Value . CopyFromStreamAsyncInternal ( stream , token ) ;
380
+ await pair . Value . CopyFromStreamAsyncInternal ( stream , token ) . ConfigureAwait ( false ) ;
381
381
}
382
382
}
383
383
}
@@ -404,15 +404,15 @@ private async Task<SubprocessFilesystemJob> PrepareForSubprocessAsync(Cancellati
404
404
405
405
var inputFiles = ( await Task . WhenAll ( _inputs . Select ( async pair =>
406
406
{
407
- var bytes = await pair . Value . BorrowReadOnlyMemoryAsync ( cancellationToken ) ;
407
+ var bytes = await pair . Value . BorrowReadOnlyMemoryAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
408
408
409
409
var file = job . Provider . Create ( cleanupFiles , bytes . Length ) ;
410
410
job . Cleanup . Add ( file ) ;
411
411
return ( io_id : pair . Key , direction : "in" ,
412
412
io : new JsonObject { { "file" , file . Path } } ,
413
413
bytes , bytes . Length , File : file ) ;
414
414
415
- } ) ) ) . ToArray ( ) ;
415
+ } ) ) . ConfigureAwait ( false ) ) . ToArray ( ) ;
416
416
417
417
var outputCapacity = outputBufferCapacity ?? inputFiles . Max ( v => v . Length ) * 2 ;
418
418
var outputFiles = _outputs . Select ( pair =>
@@ -427,7 +427,7 @@ private async Task<SubprocessFilesystemJob> PrepareForSubprocessAsync(Cancellati
427
427
foreach ( var f in inputFiles )
428
428
{
429
429
using var accessor = f . File . WriteFromBeginning ( ) ;
430
- await accessor . WriteMemoryAsync ( f . bytes , cancellationToken ) ;
430
+ await accessor . WriteMemoryAsync ( f . bytes , cancellationToken ) . ConfigureAwait ( false ) ;
431
431
}
432
432
433
433
// job.JobMessage = new
@@ -505,7 +505,7 @@ internal async Task<BuildJobResult> FinishInSubprocessAsync(SecurityOptions? sec
505
505
throw new FileNotFoundException ( "Cannot find imageflow_tool using path \" " + imageflowToolPath + "\" and currect folder \" " + Directory . GetCurrentDirectory ( ) + "\" " ) ;
506
506
}
507
507
508
- using ( var job = await PrepareForSubprocessAsync ( cancellationToken , securityOptions , true , outputBufferCapacity ) )
508
+ using ( var job = await PrepareForSubprocessAsync ( cancellationToken , securityOptions , true , outputBufferCapacity ) . ConfigureAwait ( false ) )
509
509
{
510
510
511
511
var startInfo = new ProcessStartInfo
@@ -517,7 +517,7 @@ internal async Task<BuildJobResult> FinishInSubprocessAsync(SecurityOptions? sec
517
517
FileName = imageflowToolPath
518
518
} ;
519
519
520
- var results = await ProcessEx . RunAsync ( startInfo , cancellationToken ) ;
520
+ var results = await ProcessEx . RunAsync ( startInfo , cancellationToken ) . ConfigureAwait ( false ) ;
521
521
522
522
var output = results . GetBufferedOutputStream ( ) ;
523
523
var errors = results . GetStandardErrorString ( ) ;
@@ -535,7 +535,7 @@ internal async Task<BuildJobResult> FinishInSubprocessAsync(SecurityOptions? sec
535
535
}
536
536
}
537
537
538
- await job . CopyOutputsToDestinations ( cancellationToken ) ;
538
+ await job . CopyOutputsToDestinations ( cancellationToken ) . ConfigureAwait ( false ) ;
539
539
540
540
var outputMemory = output . GetWrittenMemory ( ) ;
541
541
return BuildJobResult . From ( new MemoryJsonResponse ( results . ExitCode , outputMemory ) , _outputs ) ;
@@ -544,7 +544,7 @@ internal async Task<BuildJobResult> FinishInSubprocessAsync(SecurityOptions? sec
544
544
545
545
internal async Task < IPreparedFilesystemJob > WriteJsonJobAndInputs ( CancellationToken cancellationToken , SecurityOptions ? securityOptions , bool deleteFilesOnDispose )
546
546
{
547
- return await PrepareForSubprocessAsync ( cancellationToken , securityOptions , deleteFilesOnDispose ) ;
547
+ return await PrepareForSubprocessAsync ( cancellationToken , securityOptions , deleteFilesOnDispose ) . ConfigureAwait ( false ) ;
548
548
}
549
549
550
550
private readonly List < BuildItemBase > _nodesCreated = new List < BuildItemBase > ( 10 ) ;
@@ -598,10 +598,10 @@ private static IEnumerable<Tuple<long, long, EdgeKind>> CollectEdges(ICollection
598
598
internal JsonNode ToFramewise ( )
599
599
{
600
600
var nodes = CollectUnique ( ) ;
601
- return ToFramewiseGraph ( nodes ) ;
601
+ return ImageJob . ToFramewiseGraph ( nodes ) ;
602
602
}
603
603
604
- private JsonNode ToFramewiseGraph ( ICollection < BuildItemBase > uniqueNodes )
604
+ private static JsonNode ToFramewiseGraph ( ICollection < BuildItemBase > uniqueNodes )
605
605
{
606
606
var lowestUid = LowestUid ( uniqueNodes ) ?? 0 ;
607
607
var edges = CollectEdges ( uniqueNodes )
@@ -707,7 +707,7 @@ public static async Task<ImageInfo> GetImageInfo(IBytesSource image, Cancellatio
707
707
{
708
708
try
709
709
{
710
- var inputByteArray = await image . GetBytesAsync ( cancellationToken ) ;
710
+ var inputByteArray = await image . GetBytesAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
711
711
using ( var ctx = new JobContext ( ) )
712
712
{
713
713
ctx . AddInputBytesPinned ( 0 , inputByteArray ) ;
@@ -758,7 +758,7 @@ public static async ValueTask<ImageInfo> GetImageInfoAsync(IAsyncMemorySource im
758
758
{
759
759
try
760
760
{
761
- var inputMemory = await image . BorrowReadOnlyMemoryAsync ( cancellationToken ) ;
761
+ var inputMemory = await image . BorrowReadOnlyMemoryAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
762
762
if ( inputMemory . Length == 0 )
763
763
{
764
764
throw new ArgumentException ( "Input image is empty" ) ;
@@ -782,7 +782,7 @@ public static async ValueTask<ImageInfo> GetImageInfoAsync(IAsyncMemorySource im
782
782
}
783
783
}
784
784
/// <summary>
785
- /// Returns true if it is likely that Imageflow can decode the given image based on the first 12 bytes of the file.
785
+ /// Returns true if it is likely that Imageflow can decode the given image based on the first 12 bytes of the file.
786
786
/// </summary>
787
787
/// <param name="first12Bytes">The first 12 or more bytes of the file</param>
788
788
/// <returns></returns>
@@ -795,7 +795,7 @@ public static bool CanDecodeBytes(byte[] first12Bytes)
795
795
/// <summary>
796
796
/// Returns a MIME type string such as "image/jpeg" based on the provided first 12 bytes of the file.
797
797
/// Only guaranteed to work for image types Imageflow supports, but support for more file types may be added
798
- /// later.
798
+ /// later.
799
799
/// </summary>
800
800
/// <param name="first12Bytes">The first 12 or more bytes of the file</param>
801
801
/// <returns></returns>
0 commit comments