diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d0dace..abb2346 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: runs-on: windows-latest steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Build module - Debug shell: pwsh @@ -38,7 +38,7 @@ jobs: if: ${{ env.BUILD_CONFIGURATION == 'Release' }} - name: Capture PowerShell Module - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: PSModule path: output/*.nupkg @@ -60,10 +60,10 @@ jobs: os: windows-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Restore Built PowerShell Module - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: PSModule path: output @@ -100,21 +100,21 @@ jobs: - name: Upload Test Results if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: Unit Test Results (${{ matrix.info.name }}) path: ./output/TestResults/Pester.xml - name: Upload Coverage Results if: always() && !startsWith(github.ref, 'refs/tags/v') - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: Coverage Results (${{ matrix.info.name }}) path: ./output/TestResults/Coverage.xml - name: Upload Coverage to codecov if: always() && !startsWith(github.ref, 'refs/tags/v') - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v6 with: files: ./output/TestResults/Coverage.xml flags: ${{ matrix.info.name }} @@ -128,7 +128,7 @@ jobs: runs-on: windows-latest steps: - name: Restore Built PowerShell Module - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: PSModule path: ./ diff --git a/src/PSADTree/Internal/_FormattingInternals.cs b/src/PSADTree/Internal/_FormattingInternals.cs index 75af3b5..9a11246 100644 --- a/src/PSADTree/Internal/_FormattingInternals.cs +++ b/src/PSADTree/Internal/_FormattingInternals.cs @@ -9,7 +9,7 @@ namespace PSADTree.Internal; [EditorBrowsable(EditorBrowsableState.Never)] public static class _FormattingInternals { - private static Regex s_getDomain = new( + private static readonly Regex s_getDomain = new( @"^DC=|(? + type.GetMethod(name) + ?? throw new InvalidOperationException( + $"Method '{name}' not found on type '{type.FullName}'."); + private static ActiveDirectorySecurity GetBaseObject(PSObject target) => (ActiveDirectorySecurity)target.BaseObject; public static IdentityReference? GetOwner(PSObject target) - => GetBaseObject(target).GetOwner(_target); + => GetBaseObject(target).GetOwner(s_target); public static IdentityReference? GetGroup(PSObject target) - => GetBaseObject(target).GetGroup(_target); + => GetBaseObject(target).GetGroup(s_target); public static string GetSddlForm(PSObject target) => GetBaseObject(target).GetSecurityDescriptorSddlForm(AccessControlSections.All); public static AuthorizationRuleCollection GetAccessRules(PSObject target) - => GetBaseObject(target).GetAccessRules(true, true, _target); + => GetBaseObject(target).GetAccessRules(true, true, s_target); public static string GetAccessToString(PSObject target) { @@ -56,13 +61,14 @@ public static string GetAccessToString(PSObject target) } internal static PSObject GetSecurityDescriptorAsPSObject(this DirectoryEntry entry) - => PSObject.AsPSObject(entry.ObjectSecurity) - .AddProperty("Path", entry.Path) - .AddCodeProperty("Owner", _getOwner) - .AddCodeProperty("Group", _getGroup) - .AddCodeProperty("Sddl", _getSddlForm) - .AddCodeProperty("Access", _getAccessRules) - .AddCodeProperty("AccessToString", _getAccessToString); + => PSObject + .AsPSObject(entry.ObjectSecurity) + .AddProperty("Path", entry.Path) + .AddCodeProperty("Owner", s_getOwner) + .AddCodeProperty("Group", s_getGroup) + .AddCodeProperty("Sddl", s_getSddlForm) + .AddCodeProperty("Access", s_getAccessRules) + .AddCodeProperty("AccessToString", s_getAccessToString); private static PSObject AddProperty( this PSObject psObject, diff --git a/tools/InvokeBuild.ps1 b/tools/InvokeBuild.ps1 index 4ece54d..daed5ee 100644 --- a/tools/InvokeBuild.ps1 +++ b/tools/InvokeBuild.ps1 @@ -83,7 +83,10 @@ task PesterTests { if (-not (dotnet tool list --global | Select-String coverlet.console -SimpleMatch)) { Write-Host 'Installing dotnet tool coverlet.console' -ForegroundColor Yellow - dotnet tool install --global coverlet.console + dotnet @( + 'tool', 'install' + '--global', 'coverlet.console' + if (-not $IsCoreCLR) { '--version', '6.0.4' }) } coverlet $ProjectInfo.Pester.GetTestArgs($PSVersionTable.PSVersion)