From 805bc843a48b073f4de25be27ddc1c49d1ffb74a Mon Sep 17 00:00:00 2001 From: "KEYSIGHT\\alexwang" Date: Thu, 22 Jan 2026 17:28:34 -0500 Subject: [PATCH 1/2] upgrade to .net9 and remove all the compiling warnings due to upgrade --- .gitversion | 2 +- OpenTap.Plugins.PNAX/Acquisition/StoreSnp.cs | 4 +--- .../BaseSteps/SingleTraceBaseStep.cs | 1 - OpenTap.Plugins.PNAX/Calibration/CalAll.cs | 3 +-- .../MODSaveDistortionTable.cs | 4 +--- .../General/Spectrum Analyzer/SASource.cs | 2 +- OpenTap.Plugins.PNAX/Instrument/PNACal.cs | 2 +- .../Instrument/PNALoadMeasStore.cs | 4 ++-- OpenTap.Plugins.PNAX/Instrument/PNAMath.cs | 1 - .../Instrument/PNAModulationDistortion.cs | 1 - .../Instrument/PNAReceiverLeveling.cs | 1 - .../Instrument/PNAStandard.cs | 1 - OpenTap.Plugins.PNAX/LMS/LoadFile.cs | 8 ++++---- OpenTap.Plugins.PNAX/LMS/Measure.cs | 8 ++++---- OpenTap.Plugins.PNAX/LMS/SaveState.cs | 8 ++++---- OpenTap.Plugins.PNAX/LMS/StoreData.cs | 12 ++++-------- .../LMS/StoreDispTraceData.cs | 4 +--- OpenTap.Plugins.PNAX/LMS/StoreScreenShot.cs | 6 ++---- OpenTap.Plugins.PNAX/LMS/StoreSnp.cs | 6 ++---- .../Network Analyzer Steps/AutoScale.cs | 8 ++++---- .../OpenTap.Plugins.PNAX.csproj | 6 +++--- TestPlanGenerator/OpenTapTestGenMenu.cs | 15 ++++++++++++--- TestPlanGenerator/TestGen.xaml.cs | 19 ++++++++++++++++++- TestPlanGenerator/TestGenModel.cs | 10 +++++----- TestPlanGenerator/TestPlanGenerator.csproj | 10 +++------- 25 files changed, 74 insertions(+), 72 deletions(-) diff --git a/.gitversion b/.gitversion index ac325d1..cee33e0 100644 --- a/.gitversion +++ b/.gitversion @@ -3,7 +3,7 @@ # This is the version number that will be used. Prerelease numbers are calculated by # counting git commits since the last change in this value. -version = 0.7.5 +version = 0.8.0 # A version is determined to be a "beta" prerelease if it originates from the default branch # The default branch is the first branch that matches the following regular expession. diff --git a/OpenTap.Plugins.PNAX/Acquisition/StoreSnp.cs b/OpenTap.Plugins.PNAX/Acquisition/StoreSnp.cs index 8a19d39..8230e3e 100644 --- a/OpenTap.Plugins.PNAX/Acquisition/StoreSnp.cs +++ b/OpenTap.Plugins.PNAX/Acquisition/StoreSnp.cs @@ -91,9 +91,7 @@ public override void Run() public string AssemblyDirectory() { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); + string path = Assembly.GetExecutingAssembly().Location; return Path.GetDirectoryName(path); } } diff --git a/OpenTap.Plugins.PNAX/BaseSteps/SingleTraceBaseStep.cs b/OpenTap.Plugins.PNAX/BaseSteps/SingleTraceBaseStep.cs index 8135fa5..08ab5dd 100644 --- a/OpenTap.Plugins.PNAX/BaseSteps/SingleTraceBaseStep.cs +++ b/OpenTap.Plugins.PNAX/BaseSteps/SingleTraceBaseStep.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Runtime.Remoting.Channels; using System.Text; namespace OpenTap.Plugins.PNAX diff --git a/OpenTap.Plugins.PNAX/Calibration/CalAll.cs b/OpenTap.Plugins.PNAX/Calibration/CalAll.cs index b8c9667..b2b4f8e 100644 --- a/OpenTap.Plugins.PNAX/Calibration/CalAll.cs +++ b/OpenTap.Plugins.PNAX/Calibration/CalAll.cs @@ -510,7 +510,7 @@ private void QueryChannels() PNAX.Close(); } - catch (Exception ex) + catch (Exception) { if (PNAX.IsConnected) { @@ -519,7 +519,6 @@ private void QueryChannels() Log.Error("Cannot query channels!"); return; } - } public CalAll() diff --git a/OpenTap.Plugins.PNAX/General/Modulation Distortion/MODSaveDistortionTable.cs b/OpenTap.Plugins.PNAX/General/Modulation Distortion/MODSaveDistortionTable.cs index d8535db..1d3cd50 100644 --- a/OpenTap.Plugins.PNAX/General/Modulation Distortion/MODSaveDistortionTable.cs +++ b/OpenTap.Plugins.PNAX/General/Modulation Distortion/MODSaveDistortionTable.cs @@ -63,9 +63,7 @@ public override void Run() public string AssemblyDirectory() { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); + string path = Assembly.GetExecutingAssembly().Location; return Path.GetDirectoryName(path); } } diff --git a/OpenTap.Plugins.PNAX/General/Spectrum Analyzer/SASource.cs b/OpenTap.Plugins.PNAX/General/Spectrum Analyzer/SASource.cs index 82a5267..ebca688 100644 --- a/OpenTap.Plugins.PNAX/General/Spectrum Analyzer/SASource.cs +++ b/OpenTap.Plugins.PNAX/General/Spectrum Analyzer/SASource.cs @@ -46,7 +46,7 @@ public bool PortPowersCoupled [Output] [Browsable(true)] [Display("MetaData", Groups: new[] { "MetaData" }, Order: 1000.0)] - public List<(string, object)> MetaData { get; private set; } + public new List<(string, object)> MetaData { get; private set; } #endregion public SASource() diff --git a/OpenTap.Plugins.PNAX/Instrument/PNACal.cs b/OpenTap.Plugins.PNAX/Instrument/PNACal.cs index d5f9e4f..e9d1ada 100644 --- a/OpenTap.Plugins.PNAX/Instrument/PNACal.cs +++ b/OpenTap.Plugins.PNAX/Instrument/PNACal.cs @@ -407,7 +407,7 @@ public void CalAllSetProperty(string prop, string value) // Error 342, may need error 341 also if (!ex.Message.StartsWith("Error: 342")) { - throw ex; + throw; } } diff --git a/OpenTap.Plugins.PNAX/Instrument/PNALoadMeasStore.cs b/OpenTap.Plugins.PNAX/Instrument/PNALoadMeasStore.cs index 99cab23..c2fe676 100644 --- a/OpenTap.Plugins.PNAX/Instrument/PNALoadMeasStore.cs +++ b/OpenTap.Plugins.PNAX/Instrument/PNALoadMeasStore.cs @@ -706,9 +706,9 @@ private void ChangeFolder(string folder) // We now have switched to the folder } - catch (Exception ex) + catch (Exception) { - throw ex; + throw; } } diff --git a/OpenTap.Plugins.PNAX/Instrument/PNAMath.cs b/OpenTap.Plugins.PNAX/Instrument/PNAMath.cs index 3b025d9..1364de5 100644 --- a/OpenTap.Plugins.PNAX/Instrument/PNAMath.cs +++ b/OpenTap.Plugins.PNAX/Instrument/PNAMath.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Runtime.Remoting.Channels; using System.Text; //Note this template assumes that you have a SCPI based instrument, and accordingly diff --git a/OpenTap.Plugins.PNAX/Instrument/PNAModulationDistortion.cs b/OpenTap.Plugins.PNAX/Instrument/PNAModulationDistortion.cs index d636863..ab95b9e 100644 --- a/OpenTap.Plugins.PNAX/Instrument/PNAModulationDistortion.cs +++ b/OpenTap.Plugins.PNAX/Instrument/PNAModulationDistortion.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using System.IO; using System.Linq; -using System.Runtime.Remoting.Channels; using System.Text; //Note this template assumes that you have a SCPI based instrument, and accordingly diff --git a/OpenTap.Plugins.PNAX/Instrument/PNAReceiverLeveling.cs b/OpenTap.Plugins.PNAX/Instrument/PNAReceiverLeveling.cs index 9ad6aa1..6fffd6f 100644 --- a/OpenTap.Plugins.PNAX/Instrument/PNAReceiverLeveling.cs +++ b/OpenTap.Plugins.PNAX/Instrument/PNAReceiverLeveling.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Runtime.Remoting.Channels; using System.Text; //Note this template assumes that you have a SCPI based instrument, and accordingly diff --git a/OpenTap.Plugins.PNAX/Instrument/PNAStandard.cs b/OpenTap.Plugins.PNAX/Instrument/PNAStandard.cs index 57f0b31..5767ced 100644 --- a/OpenTap.Plugins.PNAX/Instrument/PNAStandard.cs +++ b/OpenTap.Plugins.PNAX/Instrument/PNAStandard.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Runtime.Remoting.Channels; using System.Text; //Note this template assumes that you have a SCPI based instrument, and accordingly diff --git a/OpenTap.Plugins.PNAX/LMS/LoadFile.cs b/OpenTap.Plugins.PNAX/LMS/LoadFile.cs index aa6892f..0525aad 100644 --- a/OpenTap.Plugins.PNAX/LMS/LoadFile.cs +++ b/OpenTap.Plugins.PNAX/LMS/LoadFile.cs @@ -42,13 +42,13 @@ public override void Run() PNAX.LoadState(absolutePath, overwrite); PNAX.WaitForOperationComplete(); } - catch(FileNotFoundException ex) + catch (FileNotFoundException) { - throw ex; + throw; } - catch(Exception ex) + catch (Exception) { - throw ex; + throw; } UpgradeVerdict(Verdict.Pass); diff --git a/OpenTap.Plugins.PNAX/LMS/Measure.cs b/OpenTap.Plugins.PNAX/LMS/Measure.cs index 6d750d5..9fcd239 100644 --- a/OpenTap.Plugins.PNAX/LMS/Measure.cs +++ b/OpenTap.Plugins.PNAX/LMS/Measure.cs @@ -64,13 +64,13 @@ public override void Run() } PNAX.WaitForOperationComplete(); } - catch (IndexOutOfRangeException ex) + catch (IndexOutOfRangeException) { - throw ex; + throw; } - catch (Exception ex) + catch (Exception) { - throw ex; + throw; } UpgradeVerdict(Verdict.Pass); diff --git a/OpenTap.Plugins.PNAX/LMS/SaveState.cs b/OpenTap.Plugins.PNAX/LMS/SaveState.cs index 2c1c5f6..9788d7b 100644 --- a/OpenTap.Plugins.PNAX/LMS/SaveState.cs +++ b/OpenTap.Plugins.PNAX/LMS/SaveState.cs @@ -47,13 +47,13 @@ public override void Run() Log.Info("---Save State Completed---"); PNAX.WaitForOperationComplete(); } - catch (FileNotFoundException ex) + catch (FileNotFoundException) { - throw ex; + throw; } - catch (Exception ex) + catch (Exception) { - throw ex; + throw; } UpgradeVerdict(Verdict.Pass); diff --git a/OpenTap.Plugins.PNAX/LMS/StoreData.cs b/OpenTap.Plugins.PNAX/LMS/StoreData.cs index 8c0b109..f36312a 100644 --- a/OpenTap.Plugins.PNAX/LMS/StoreData.cs +++ b/OpenTap.Plugins.PNAX/LMS/StoreData.cs @@ -190,10 +190,6 @@ public override void Run() // append xaxisvalues resultColumn = new ResultColumn($"{TraceName}_XAxis", x1[i].Select(double.Parse).Select(x => Math.Round(x, 2)).ToArray()); - if (false) - { - resultColumns.Add(resultColumn); - } // append pf List pfByRow = new List(); @@ -376,13 +372,13 @@ public override void Run() } } - catch (IndexOutOfRangeException ex) + catch (IndexOutOfRangeException) { - throw ex; + throw; } - catch(Exception ex) + catch(Exception) { - throw ex; + throw; } UpgradeVerdict(Verdict.Pass); diff --git a/OpenTap.Plugins.PNAX/LMS/StoreDispTraceData.cs b/OpenTap.Plugins.PNAX/LMS/StoreDispTraceData.cs index 26d9641..42cdcef 100644 --- a/OpenTap.Plugins.PNAX/LMS/StoreDispTraceData.cs +++ b/OpenTap.Plugins.PNAX/LMS/StoreDispTraceData.cs @@ -66,9 +66,7 @@ public override void Run() public string AssemblyDirectory() { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); + string path = Assembly.GetExecutingAssembly().Location; return Path.GetDirectoryName(path); } } diff --git a/OpenTap.Plugins.PNAX/LMS/StoreScreenShot.cs b/OpenTap.Plugins.PNAX/LMS/StoreScreenShot.cs index 2e20853..35b54cb 100644 --- a/OpenTap.Plugins.PNAX/LMS/StoreScreenShot.cs +++ b/OpenTap.Plugins.PNAX/LMS/StoreScreenShot.cs @@ -64,10 +64,8 @@ public override void Run() public string AssemblyDirectory() { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); - return Path.GetDirectoryName(path); + string location = Assembly.GetExecutingAssembly().Location; + return Path.GetDirectoryName(location); } } } diff --git a/OpenTap.Plugins.PNAX/LMS/StoreSnp.cs b/OpenTap.Plugins.PNAX/LMS/StoreSnp.cs index 31b4c39..b67ba79 100644 --- a/OpenTap.Plugins.PNAX/LMS/StoreSnp.cs +++ b/OpenTap.Plugins.PNAX/LMS/StoreSnp.cs @@ -98,10 +98,8 @@ public override void Run() public string AssemblyDirectory() { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); - return Path.GetDirectoryName(path); + string location = Assembly.GetExecutingAssembly().Location; + return Path.GetDirectoryName(location); } } } diff --git a/OpenTap.Plugins.PNAX/Network Analyzer Steps/AutoScale.cs b/OpenTap.Plugins.PNAX/Network Analyzer Steps/AutoScale.cs index bcd5582..b74c887 100644 --- a/OpenTap.Plugins.PNAX/Network Analyzer Steps/AutoScale.cs +++ b/OpenTap.Plugins.PNAX/Network Analyzer Steps/AutoScale.cs @@ -48,13 +48,13 @@ public override void Run() PNAX.AutoScaleWindow(window); } } - catch (IndexOutOfRangeException ex) + catch (IndexOutOfRangeException) { - throw ex; + throw; // Preserve the original stack trace } - catch (Exception ex) + catch (Exception) { - throw ex; + throw; // Preserve the original stack trace } UpgradeVerdict(Verdict.Pass); diff --git a/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj b/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj index b107bdb..e0b48a0 100644 --- a/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj +++ b/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj @@ -5,7 +5,7 @@ - net472 + net9.0 false false package.xml @@ -13,7 +13,7 @@ - net472 + net9.0 false @@ -36,7 +36,7 @@ - + diff --git a/TestPlanGenerator/OpenTapTestGenMenu.cs b/TestPlanGenerator/OpenTapTestGenMenu.cs index 5d3833e..345ae59 100644 --- a/TestPlanGenerator/OpenTapTestGenMenu.cs +++ b/TestPlanGenerator/OpenTapTestGenMenu.cs @@ -71,13 +71,22 @@ public void Initialize(GuiContext context) protected string GetTheme() { - if (Keysight.OpenTap.Wpf.EditorSettings.Current.ColorTheme == Keysight.OpenTap.Wpf.Themes.TapSkins.Theme.Light) + // Check if the platform supports the EditorSettings API + if (OperatingSystem.IsWindowsVersionAtLeast(7)) { - return "Light"; + if (Keysight.OpenTap.Wpf.EditorSettings.Current.ColorTheme == Keysight.OpenTap.Wpf.Themes.TapSkins.Theme.Light) + { + return "Light"; + } + else + { + return "Dark"; + } } else { - return "Dark"; + // Default to "Light" theme for unsupported platforms + return "Light"; } } diff --git a/TestPlanGenerator/TestGen.xaml.cs b/TestPlanGenerator/TestGen.xaml.cs index 5149b0a..cc0aca0 100644 --- a/TestPlanGenerator/TestGen.xaml.cs +++ b/TestPlanGenerator/TestGen.xaml.cs @@ -16,6 +16,7 @@ using OpenTap; using System.IO; using Microsoft.Win32; +using System.Runtime.Versioning; namespace TestPlanGenerator { @@ -119,13 +120,23 @@ private void BrowseDialogInputFileButton_Click(object sender, RoutedEventArgs e) } + // ... + private void SetTestPlan(TestPlan testPlan) { Application.Current.Dispatcher.Invoke(() => { try { - this.uiContext.Plan = testPlan; + if (OperatingSystem.IsWindowsVersionAtLeast(7)) + { + // Marking the following line with the SupportedOSPlatform attribute to suppress CA1416 warning + SetPlanForWindows(testPlan); + } + else + { + throw new PlatformNotSupportedException("This functionality is only supported on Windows 7.0 and later."); + } } catch (Exception e) { @@ -134,6 +145,12 @@ private void SetTestPlan(TestPlan testPlan) }); } + [SupportedOSPlatform("windows7.0")] + private void SetPlanForWindows(TestPlan testPlan) + { + this.uiContext.Plan = testPlan; + } + private void BrowseInputFileButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); diff --git a/TestPlanGenerator/TestGenModel.cs b/TestPlanGenerator/TestGenModel.cs index 10e38df..8cd5379 100644 --- a/TestPlanGenerator/TestGenModel.cs +++ b/TestPlanGenerator/TestGenModel.cs @@ -222,8 +222,8 @@ public void ParseExcelFile(String filename) // Parse Channels int sheetIndex = 1; Worksheet sheet = (Worksheet)wb.Sheets.Item[sheetIndex]; - Range excelRange = sheet.UsedRange; - foreach (Range row in excelRange.Rows) + Microsoft.Office.Interop.Excel.Range excelRange = sheet.UsedRange; + foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows) { int rowNumber = row.Row; @@ -291,7 +291,7 @@ public void ParseExcelFile(String filename) sheetIndex = 2; sheet = (Worksheet)wb.Sheets.Item[sheetIndex]; excelRange = sheet.UsedRange; - foreach (Range row in excelRange.Rows) + foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows) { int rowNumber = row.Row; @@ -526,8 +526,8 @@ public void ParseDialogExcelFile(String filename) // Parse Channels int sheetIndex = 1; Worksheet sheet = (Worksheet)wb.Sheets.Item[sheetIndex]; - Range excelRange = sheet.UsedRange; - foreach (Range row in excelRange.Rows) + Microsoft.Office.Interop.Excel.Range excelRange = sheet.UsedRange; + foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows) { int rowNumber = row.Row; diff --git a/TestPlanGenerator/TestPlanGenerator.csproj b/TestPlanGenerator/TestPlanGenerator.csproj index 0e335f5..f6cdb93 100644 --- a/TestPlanGenerator/TestPlanGenerator.csproj +++ b/TestPlanGenerator/TestPlanGenerator.csproj @@ -5,7 +5,7 @@ - net472 + net9.0-windows7.0 false false package.xml @@ -14,7 +14,7 @@ - net472 + net9.0-windows7.0 @@ -34,7 +34,7 @@ - + @@ -48,10 +48,6 @@ $(OutDir)Packages\OpenTap\OpenTap.Plugins.BasicSteps.dll - - - - From 16af403e76d5b9d2ed57f8cf2602a1e6a0791f99 Mon Sep 17 00:00:00 2001 From: "KEYSIGHT\\alexwang" Date: Thu, 19 Feb 2026 17:57:01 -0500 Subject: [PATCH 2/2] upgrade to 9.32.1 and bump to 1.0 version --- .github/workflows/build.yml | 2 +- .gitversion | 2 +- OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj | 2 +- TestPlanGenerator/TestPlanGenerator.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9cdab3d..2401bd4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: 9.0.x - name: Build id: build diff --git a/.gitversion b/.gitversion index cee33e0..7085ac8 100644 --- a/.gitversion +++ b/.gitversion @@ -3,7 +3,7 @@ # This is the version number that will be used. Prerelease numbers are calculated by # counting git commits since the last change in this value. -version = 0.8.0 +version = 1.0.0 # A version is determined to be a "beta" prerelease if it originates from the default branch # The default branch is the first branch that matches the following regular expession. diff --git a/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj b/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj index e0b48a0..ec66143 100644 --- a/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj +++ b/OpenTap.Plugins.PNAX/OpenTap.Plugins.PNAX.csproj @@ -36,7 +36,7 @@ - + diff --git a/TestPlanGenerator/TestPlanGenerator.csproj b/TestPlanGenerator/TestPlanGenerator.csproj index f6cdb93..4625779 100644 --- a/TestPlanGenerator/TestPlanGenerator.csproj +++ b/TestPlanGenerator/TestPlanGenerator.csproj @@ -34,7 +34,7 @@ - +