Skip to content

Commit

Permalink
Bump System.Drawing.Common from 8.0.4 to 8.0.5 (#1817)
Browse files Browse the repository at this point in the history
* Bump System.Drawing.Common from 8.0.4 to 8.0.5

Bumps [System.Drawing.Common](https://github.com/dotnet/winforms) from 8.0.4 to 8.0.5.
- [Release notes](https://github.com/dotnet/winforms/releases)
- [Changelog](https://github.com/dotnet/winforms/blob/main/docs/release-activity.md)
- [Commits](dotnet/winforms@v8.0.4...v8.0.5)

---
updated-dependencies:
- dependency-name: System.Drawing.Common
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump change log

* Improve stability on git operations

* Clean up

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bernie White <[email protected]>
  • Loading branch information
dependabot[bot] and BernieWhite authored May 17, 2024
1 parent 5e17b24 commit 038f3e3
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"extensions": [
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"ms-vscode.powershell",
"github.vscode-pull-request-github",
"davidanson.vscode-markdownlint",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"ms-vscode.powershell",
"github.vscode-pull-request-github",
"davidanson.vscode-markdownlint",
Expand Down
4 changes: 2 additions & 2 deletions docs/CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers
What's changed since pre-release v3.0.0-B0153:

- Engineering:
- Bump System.Drawing.Common to v8.0.4.
[#1790](https://github.com/microsoft/PSRule/pull/1790)
- Bump System.Drawing.Common to v8.0.5.
[#1817](https://github.com/microsoft/PSRule/pull/1817)
- Bump Bump xunit to v2.8.0.
[#1809](https://github.com/microsoft/PSRule/pull/1809)
- Bump xunit.runner.visualstudio to v2.8.0.
Expand Down
2 changes: 1 addition & 1 deletion src/PSRule.BuildTool/PSRule.BuildTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />
<PackageReference Include="System.Drawing.Common" Version="8.0.4" />
<PackageReference Include="System.Drawing.Common" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/PSRule.BuildTool/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},
"System.Drawing.Common": {
"type": "Direct",
"requested": "[8.0.3, )",
"resolved": "8.0.3",
"contentHash": "oDE9duAtHhxYJM2bsOlZCLBKdorU9DTV1tw7Mlc+VIT7HgwO5ddfOHk/An8C+fAS9oKdmn2PaIA5t1b484uz8g==",
"requested": "[8.0.5, )",
"resolved": "8.0.5",
"contentHash": "n55wb6rL8YG254AG+SfQOSQencrcnpKAAcYyEcvBuO2pob7ltXuZ5skBBdvLJOLVPKd1Ya8+8ColIM5AtBo5ww==",
"dependencies": {
"Microsoft.Win32.SystemEvents": "8.0.0"
}
Expand Down
80 changes: 48 additions & 32 deletions src/PSRule/Common/ExternalToolHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ internal sealed class ExternalTool : IDisposable
private readonly AutoResetEvent _ErrorWait;
private readonly AutoResetEvent _OutputWait;
private readonly int _Interval;
private readonly int _Timeout;
private readonly string _BinaryPath;
private bool _Disposed;

private ExternalTool(string binaryPath, int timeout, string version = null)
private ExternalTool(string binaryPath)
{
_Output = new StringBuilder();
_Error = new StringBuilder();
_Interval = 1000;
_Timeout = timeout;
_BinaryPath = binaryPath;

_ErrorWait = new AutoResetEvent(false);
_OutputWait = new AutoResetEvent(false);
}
Expand All @@ -37,7 +34,7 @@ internal static ExternalTool Get(string defaultPath, string binary)
if (!TryPathFromDefault(defaultPath, binary, out var binaryPath) && !TryPathFromEnvironment(binary, out binaryPath))
return null;

return new ExternalTool(binaryPath, 0, null);
return new ExternalTool(binaryPath);
}

private static bool TryPathFromDefault(string defaultPath, string binary, out string binaryPath)
Expand All @@ -47,58 +44,65 @@ private static bool TryPathFromDefault(string defaultPath, string binary, out st

public bool WaitForExit(string args, out int exitCode)
{
var startInfo = new ProcessStartInfo(_BinaryPath, args)
_Process = new Process
{
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
WorkingDirectory = Environment.GetWorkingPath(),
StartInfo = new ProcessStartInfo(_BinaryPath, args)
{
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
WorkingDirectory = Environment.GetWorkingPath(),
}
};
_Process = Process.Start(startInfo);
_Process.ErrorDataReceived += Bicep_ErrorDataReceived;
_Process.OutputDataReceived += Bicep_OutputDataReceived;

_Process.BeginErrorReadLine();
_Process.BeginOutputReadLine();
_Process.ErrorDataReceived += Tool_ErrorDataReceived;
_Process.OutputDataReceived += Tool_OutputDataReceived;

_ErrorWait.Reset();
_OutputWait.Reset();

if (!_Process.HasExited)
{
var timeoutCount = 0;
while (!_Process.WaitForExit(_Interval) && !_Process.HasExited && timeoutCount < _Timeout)
timeoutCount++;
}
_Process.Start();
_Process.BeginErrorReadLine();
_Process.BeginOutputReadLine();

_Process.WaitForExit();

exitCode = _Process.HasExited ? _Process.ExitCode : -1;
return _Process.HasExited && _ErrorWait.WaitOne(_Interval) && _OutputWait.WaitOne();
}

public string GetOutput()
{
return _Output.ToString();
lock (_Output)
{
return _Output.ToString();
}
}

public string GetError()
{
return _Error.ToString();
lock (_Error)
{
return _Error.ToString();
}
}

private void Bicep_OutputDataReceived(object sender, DataReceivedEventArgs e)
private void Tool_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data == null)
{
_OutputWait.Set();
}
else
{
_Output.AppendLine(e.Data);
lock (_Output)
{
_Output.AppendLine(e.Data);
}
}
}

private void Bicep_ErrorDataReceived(object sender, DataReceivedEventArgs e)
private void Tool_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data == null)
{
Expand All @@ -107,8 +111,14 @@ private void Bicep_ErrorDataReceived(object sender, DataReceivedEventArgs e)
else
{
var errors = GetErrorLine(e.Data);
for (var i = 0; i < errors.Length; i++)
_Error.AppendLine(errors[i]);
if (errors.Length == 0)
return;

lock (_Error)
{
for (var i = 0; i < errors.Length; i++)
_Error.AppendLine(errors[i]);
}
}
}

Expand Down Expand Up @@ -161,8 +171,14 @@ private void Dispose(bool disposing)
_OutputWait.Dispose();
_Process.Dispose();
}
_Error.Clear();
_Output.Clear();
lock (_Error)
{
_Error.Clear();
}
lock (_Output)
{
_Output.Clear();
}
_Disposed = true;
}
}
Expand Down

0 comments on commit 038f3e3

Please sign in to comment.