From 4154e90fc6c76df16a615d786ff4367dd300360f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 12:42:46 +0200 Subject: [PATCH] Bump Newtonsoft.json from 9.0.1 to 13.0.1 (#30) * Bump Newtonsoft.json from 9.0.1 to 13.0.1 Bumps [Newtonsoft.json](https://github.com/JamesNK/Newtonsoft.Json) from 9.0.1 to 13.0.1. - [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases) - [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/9.0.1...13.0.1) --- updated-dependencies: - dependency-name: Newtonsoft.json dependency-type: direct:production ... Signed-off-by: dependabot[bot] * fix: add assembly redirect for Newtonsoft.Json NJsonSchema depends on Newtonsoft.Json 9.x, which we are upgrading to 13. Adding an assembly resolver so that the NJsonSchema library references the updated Newtonsoft.Json assembly. Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrea Spadaccini Co-authored-by: Andrea Spadaccini --- FeatureFlags.psm1 | 18 ++++++++++++++++++ PowerShell-FeatureFlags.csproj | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/FeatureFlags.psm1 b/FeatureFlags.psm1 index d31bb8d..0a164a8 100644 --- a/FeatureFlags.psm1 +++ b/FeatureFlags.psm1 @@ -32,6 +32,20 @@ if (-not (Test-Path -Path $jsonLibPath -PathType Leaf)) { } Write-Verbose "Found JSON.Net assembly at $jsonLibPath" +Write-Verbose "Adding assembly resolver." +$onAssemblyResolve = [System.ResolveEventHandler] { + param($sender, $e) + + if ($e.Name -like 'Newtonsoft.Json, *') { + Write-Verbose "Resolving '$($e.Name)'" + return [System.Reflection.Assembly]::LoadFrom($jsonLibPath) + } + + Write-Verbose "Unable to resolve assembly name '$($e.Name)'" + return $null +} +[System.AppDomain]::CurrentDomain.add_AssemblyResolve($onAssemblyResolve) + try { $jsonType = Add-Type -Path $jsonLibPath -PassThru $jsonSchemaType = Add-Type -Path $schemaLibPath -PassThru @@ -42,6 +56,10 @@ try { throw } +# Unregister the assembly resolver. +Write-Verbose "Removing assemlby resolver." +[System.AppDomain]::CurrentDomain.remove_AssemblyResolve($onAssemblyResolve) + $script:schema = $null try { Write-Verbose "Reading JSON schema..." diff --git a/PowerShell-FeatureFlags.csproj b/PowerShell-FeatureFlags.csproj index 35a59ea..7266346 100644 --- a/PowerShell-FeatureFlags.csproj +++ b/PowerShell-FeatureFlags.csproj @@ -9,7 +9,7 @@ - +