Skip to content
Draft
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
1 change: 1 addition & 0 deletions Engine/Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.8.14" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 13 additions & 10 deletions Engine/ScriptAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Collections;
using System.Diagnostics;
using System.Text;
using Microsoft.VisualStudio.Threading;
using Microsoft.Windows.PowerShell.ScriptAnalyzer.Extensions;

namespace Microsoft.Windows.PowerShell.ScriptAnalyzer
Expand Down Expand Up @@ -2172,18 +2173,20 @@ public IEnumerable<DiagnosticRecord> AnalyzeSyntaxTree(
result.Add(new ErrorRecord(scriptRuleException, Strings.RuleErrorMessage, ErrorCategory.InvalidOperation, scriptAst.Extent.File));
}

verboseOrErrors.Add(result);
}));
Task.Factory.ContinueWhenAll(tasks.ToArray(), t => verboseOrErrors.CompleteAdding());
while (!verboseOrErrors.IsCompleted)
return result;
}).WithTimeout(TimeSpan.FromSeconds(10))).ToList();
while (tasks.Count > 0)
{
List<object> data = null;
try
var data = new JoinableTaskContext().Factory.Run(async () =>
{
data = verboseOrErrors.Take();
}
catch (InvalidOperationException) { }

var task = await Task.WhenAny(tasks.ToArray());
tasks.Remove(task);
if (task.IsCanceled || task.IsFaulted)
{
return null;
}
return await task;
});
if (data != null)
{
this.outputWriter.WriteVerbose(data[0] as string);
Expand Down