From 11c7b1e5d958d9b119cac9db7fc409ab3f1e0820 Mon Sep 17 00:00:00 2001 From: Stephen Giffin Date: Sun, 17 Aug 2025 13:50:33 -0700 Subject: [PATCH 1/2] Add NuGet package management methods and class This commit introduces new methods in the `IVsProjectActions` interface for managing NuGet packages and project references, including retrieval, addition, and removal functionalities. A new `NuGetPackage` class is also added to encapsulate details about NuGet packages, such as ID, version, installation path, and direct dependency status. Additionally, methods in `VsProject` are updated to return `ImmutableArray` instead of `ImmutableList`, improving performance and memory efficiency. --- .../Models/ProjectSystem/IVsProjectActions.cs | 88 +++++++++++++++++++ .../Models/ProjectSystem/NuGetPackage.cs | 61 +++++++++++++ .../Models/ProjectSystem/VsProject.cs | 87 ++++++++++++++++-- 3 files changed, 231 insertions(+), 5 deletions(-) create mode 100644 Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/NuGetPackage.cs diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/IVsProjectActions.cs b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/IVsProjectActions.cs index e134e26..475d65e 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/IVsProjectActions.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/IVsProjectActions.cs @@ -96,5 +96,93 @@ public interface IVsProjectActions /// cref="VsCSharpSource"/> object. Task LoadFromCsSourceAsync(VsProject source,CsSource csSource); + + /// + /// Asynchronously retrieves a list of NuGet packages from the Visual Studio project. + /// + /// Source project to get the NuGet packages from. + /// The returned list may be empty if no NuGet packages are available. + /// A task that represents the asynchronous operation. The task result contains a read-only list of objects representing the retrieved NuGet packages. + Task> GetNuGetPackagesAsync(VsProject source); + + /// + /// Asynchronously adds a NuGet package to the project. + /// + /// This method attempts to add the specified NuGet package to the project. Ensure that + /// the package ID and version are valid and that the project is in a state that allows modifications. + /// The project to which the NuGet package will be added. This cannot be . + /// The unique identifier of the NuGet package to add. This cannot be null or empty. + /// The version of the NuGet package to add. This cannot be null or empty. + /// Flag that determines if you accept the license notice on a nuget package. + /// A task that represents the asynchronous operation. The task result is if the package + /// was successfully added; otherwise, . + Task AddNuGetPackageAsync(VsProject source, string packageId, string version, bool acceptPackageLicense); + + /// + /// Removes a NuGet package with the specified package ID from the system. + /// + /// This method performs an asynchronous operation to remove a NuGet package. Ensure that + /// the package ID provided is valid and corresponds to an existing package in the system. + /// The project from which the NuGet package will be removed. This cannot be . + /// The unique identifier of the NuGet package to remove. This value cannot be null or empty. + /// A task that represents the asynchronous operation. The task result is if the package + /// was successfully removed; otherwise, . + Task RemoveNuGetPackageAsync(VsProject source, string packageId); + + /// + /// Adds a reference to the specified project asynchronously. + /// + /// This method performs the operation asynchronously and may involve I/O operations. + /// Ensure that the project name provided is valid and corresponds to an existing project. + /// Source project to add the reference to. + /// The name of the project to add as a reference. Cannot be null or empty. + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was added successfully; otherwise, . + Task AddProjectReferenceAsync(VsProject source, string projectName); + + /// + /// Adds a reference to the specified project asynchronously. + /// + /// This method performs the operation asynchronously and may involve file system or + /// project system updates. Ensure that the provided is valid and + /// accessible. + /// Source project to add the reference to. + /// The project to be added as a reference. Cannot be . + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was added successfully; otherwise, . + Task AddProjectReferenceAsync(VsProject source, VsProject project); + + /// + /// Removes a project reference by its name asynchronously. + /// + /// This method performs the removal operation asynchronously. Ensure that the project + /// name provided matches an existing reference to avoid unexpected results. + /// Source project to remove the reference from. + /// The name of the project to remove as a reference. Cannot be null or empty. + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was successfully removed; otherwise, . + Task RemoveProjectReferenceAsync(VsProject source, string projectName); + + /// + /// Removes a project reference from the current project asynchronously. + /// + /// Source project to remove the reference from. + /// The instance representing the project to be removed as a reference. + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was successfully removed; otherwise, . + Task RemoveProjectReferenceAsync(VsProject source, VsProject project); + + /// + /// Removes a project reference from the current project asynchronously. + /// + /// This method performs the removal operation asynchronously. Ensure that the provided + /// reference is valid and exists in the current project before calling this method. + /// Source project to remove the reference from. + /// The project reference to be removed. Must not be . + /// A task that represents the asynchronous operation. The task result is if the + /// reference was successfully removed; otherwise, . + Task RemoveProjectReferenceAsync(VsProject source, VsReference reference); + } } diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/NuGetPackage.cs b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/NuGetPackage.cs new file mode 100644 index 0000000..44063b6 --- /dev/null +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/NuGetPackage.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CodeFactory.WinVs.Models.ProjectSystem +{ + /// + /// Represents a NuGet package, including its identifier, version, installation path, and dependency type. + /// + /// This class provides read-only access to the details of a NuGet package, such as its unique + /// identifier, version, installation path, and whether it is a direct dependency of the project. Instances of this + /// class are immutable once created. + public class NuGetPackage + { + //backing fields for the properties + private readonly string _id; + private readonly string _version; + private readonly string _installPath; + private readonly bool _directDependency; + + /// + /// Initializes a new instance of the class with the specified package details. + /// + /// The unique identifier of the NuGet package. This value cannot be null or empty. + /// The version of the NuGet package. This value cannot be null or empty. + /// The file system path where the NuGet package is installed. + /// A value indicating whether the package is a direct dependency of the project. if the + /// package is a direct dependency; otherwise, . + public NuGetPackage(string id, string version, string installPath, bool directDependency) + { + _id = id; + _version = version; + _installPath = installPath; + _directDependency = directDependency; + } + + + /// + /// Gets the unique identifier associated with the NuGet package. + /// + public string Id => _id; + + /// + /// The version of the NuGet package. + /// + public string Version => _version; + + + /// + /// Gets the installation path of the NuGet package. + /// + public string InstallPath => _installPath; + + /// + /// Gets a value indicating whether this instance of the new Nuget package is a direct dependency. + /// + public bool DirectDependency => _directDependency; + + + } +} diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/VsProject.cs b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/VsProject.cs index e596ca1..6187deb 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/VsProject.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Models/ProjectSystem/VsProject.cs @@ -138,11 +138,11 @@ protected VsProject(bool isLoaded, bool hasErrors, IReadOnlyListReadonly list of the referenced projects or an empty list if there is no referenced projects. public async Task> GetReferencedProjects() { - if (!IsLoaded) return ImmutableList.Empty; + if (!IsLoaded) return ImmutableArray.Empty; var projectReferences = await GetProjectReferencesAsync(); - if(!projectReferences.Any(r => r.Type == ProjectReferenceType.Project)) return ImmutableList.Empty; + if(!projectReferences.Any(r => r.Type == ProjectReferenceType.Project)) return ImmutableArray.Empty; var projects = new List(); foreach (var vsProjectReference in projectReferences) @@ -151,7 +151,7 @@ public async Task> GetReferencedProjects() if(project != null) projects.Add(project); } - return projects.Any() ? projects.ToImmutableList() : ImmutableList.Empty; + return projects.Any() ? projects.ToImmutableArray() : ImmutableArray.Empty; } /// @@ -169,7 +169,6 @@ public async Task> GetReferencedProjects() /// cref="CsSource"/> objects that match the specified search criteria. public abstract Task> FindCSharpSourceCodeAsync(CsSourceSearchCriteria searchCriteria, bool searchSubFolders = true, IEnumerable IgnoreFolderPaths = null); - /// /// Asynchronously loads a object from the specified C# source file within a Visual /// Studio project. @@ -179,7 +178,6 @@ public async Task> GetReferencedProjects() /// cref="VsCSharpSource"/> object. public abstract Task LoadFromCsSourceAsync(CsSource csSource); - /// /// Asynchronously loads a C# source file from the specified container. /// @@ -187,5 +185,84 @@ public async Task> GetReferencedProjects() /// A task that represents the asynchronous operation. The task result contains the loaded object. public abstract Task LoadCSharpSourceFromContainerAsync(CsContainer source); + + /// + /// Asynchronously retrieves a list of NuGet packages from the Visual Studio project. + /// + /// The returned list may be empty if no NuGet packages are available. + /// A task that represents the asynchronous operation. The task result contains a read-only list of objects representing the retrieved NuGet packages. + public abstract Task> GetNuGetPackagesAsync(); + + /// + /// Asynchronously adds a NuGet package to the project. + /// + /// This method attempts to add the specified NuGet package to the project. Ensure that + /// the package ID and version are valid and that the project is in a state that allows modifications. + /// The unique identifier of the NuGet package to add. This cannot be null or empty. + /// The version of the NuGet package to add. This cannot be null or empty. + /// Flag that determines if you accept the license notice on a nuget package. + /// A task that represents the asynchronous operation. The task result is if the package + /// was successfully added; otherwise, . + public abstract Task AddNuGetPackageAsync(string packageId, string version, bool acceptPackageLicense); + + /// + /// Removes a NuGet package with the specified package ID from the system. + /// + /// This method performs an asynchronous operation to remove a NuGet package. Ensure that + /// the package ID provided is valid and corresponds to an existing package in the system. + /// The unique identifier of the NuGet package to remove. This value cannot be null or empty. + /// A task that represents the asynchronous operation. The task result is if the package + /// was successfully removed; otherwise, . + public abstract Task RemoveNuGetPackageAsync(string packageId); + + /// + /// Adds a reference to the specified project asynchronously. + /// + /// This method performs the operation asynchronously and may involve I/O operations. + /// Ensure that the project name provided is valid and corresponds to an existing project. + /// The name of the project to add as a reference. Cannot be null or empty. + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was added successfully; otherwise, . + public abstract Task AddProjectReferenceAsync(string projectName); + + /// + /// Adds a reference to the specified project asynchronously. + /// + /// This method performs the operation asynchronously and may involve file system or + /// project system updates. Ensure that the provided is valid and + /// accessible. + /// The project to be added as a reference. Cannot be . + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was added successfully; otherwise, . + public abstract Task AddProjectReferenceAsync(VsProject project); + + /// + /// Removes a project reference by its name asynchronously. + /// + /// This method performs the removal operation asynchronously. Ensure that the project + /// name provided matches an existing reference to avoid unexpected results. + /// The name of the project to remove as a reference. Cannot be null or empty. + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was successfully removed; otherwise, . + public abstract Task RemoveProjectReferenceAsync(string projectName); + + /// + /// Removes a project reference from the current project asynchronously. + /// + /// The instance representing the project to be removed as a reference. + /// A task that represents the asynchronous operation. The task result is if the project + /// reference was successfully removed; otherwise, . + public abstract Task RemoveProjectReferenceAsync(VsProject project); + + /// + /// Removes a project reference from the current project asynchronously. + /// + /// This method performs the removal operation asynchronously. Ensure that the provided + /// reference is valid and exists in the current project before calling this method. + /// The project reference to be removed. Must not be . + /// A task that represents the asynchronous operation. The task result is if the + /// reference was successfully removed; otherwise, . + public abstract Task RemoveProjectReferenceAsync(VsReference reference); } } From 4da68f4021a135194d03dd961e325bccf8a54e4b Mon Sep 17 00:00:00 2001 From: Stephen Giffin Date: Sun, 17 Aug 2025 17:40:42 -0700 Subject: [PATCH 2/2] Update SDK version to 2.25229.0.1-PreRelease - Bump version numbers in `.nuspec` and `.csproj` files. - Add `LoadErrorSdkLibraryException` for better error handling. - Update `AssemblyFileVersion` in `AssemblyInfo.cs`. - Revise `PackageReleaseNotes` to include recompilation instructions. - Adjust `MaxVersion` and `NuGetSdkVersion` constants in `SdkSupport.cs`. - Change `IncludeSymbols` to `True` in `.csproj` files. --- .../CodeFactoryWinVsSDK.nuspec | 10 +-- .../LibraryManagement.cs | 5 ++ .../CodeFactory.Packager.WinVs/Program.cs | 5 ++ .../Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../CodeFactory.WinVs.Wpf/WinVsWpf.nuspec | 8 +- .../CodeFactory.WinVs.csproj | 8 +- .../Loader/CodeFactoryConfigurationLoader.cs | 4 + .../CodeFactory.WinVs/Loader/SdkSupport.cs | 13 ++-- .../CodeFactory/CodeFactory.csproj | 8 +- .../LoadErrorSdkLibraryException.cs | 74 +++++++++++++++++++ 11 files changed, 114 insertions(+), 25 deletions(-) create mode 100644 Src/CodeFactoryForWindows/CodeFactory/LoadErrorSdkLibraryException.cs diff --git a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/CodeFactoryWinVsSDK.nuspec b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/CodeFactoryWinVsSDK.nuspec index 7028198..c80b469 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/CodeFactoryWinVsSDK.nuspec +++ b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/CodeFactoryWinVsSDK.nuspec @@ -2,7 +2,7 @@ CodeFactory.WinVs.SDK - 2.25220.0.1-PreRelease + 2.25229.0.1-PreRelease CodeFactory Software Development Kit for Visual Studio - Windows CodeFactory, LLC. CodeFactory, LLC. @@ -10,7 +10,7 @@ true Software development kit for building CodeFactory automation in Visual Studio - Windows. - Release Updates for 2.25220.0.1 + Release Updates for 2.25229.0.1 Recompile Release: When you update your automation to this version of the SDK. @@ -40,9 +40,9 @@ Copyright © 2025 CodeFactory, LLC. Factory Automation - - - + + + CFLogo128.png diff --git a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/LibraryManagement.cs b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/LibraryManagement.cs index 2983856..4348add 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/LibraryManagement.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/LibraryManagement.cs @@ -229,6 +229,11 @@ public static List GetExternalDependentLibraries( throw; } + catch (LoadErrorSdkLibraryException) + { + throw; + } + catch (BadImageFormatException badImageError) { _logger.Error("A bad image error occurred while trying to load a dependent assembly.", diff --git a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Program.cs b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Program.cs index a3e4b1f..0456cd5 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Program.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Program.cs @@ -148,6 +148,11 @@ public static void Main(string[] args) Console.WriteLine($"--> {unsupportedSdkLibrary.Message}"); returnCode = PackagerData.ExitCodeUnsupportedLibrarySDKVersion; } + catch (LoadErrorSdkLibraryException loadErrorSdkLibrary) + { + Console.WriteLine($"--> {loadErrorSdkLibrary.Message}"); + returnCode = PackagerData.ExitCodeKnownError; + } catch (CommandParsingException cpe) { Console.WriteLine(cpe.Message); diff --git a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Properties/AssemblyInfo.cs b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Properties/AssemblyInfo.cs index d56aef5..e5e7c35 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Properties/AssemblyInfo.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.Packager.WinVs/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.25220.0.1")] +[assembly: AssemblyFileVersion("2.25229.0.1")] diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/Properties/AssemblyInfo.cs b/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/Properties/AssemblyInfo.cs index edfe56b..ef5d1c6 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/Properties/AssemblyInfo.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.25220.0.1")] +[assembly: AssemblyFileVersion("2.25229.0.1")] diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/WinVsWpf.nuspec b/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/WinVsWpf.nuspec index 1f9f569..b564473 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/WinVsWpf.nuspec +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/WinVsWpf.nuspec @@ -2,7 +2,7 @@ CodeFactory.WinVs.Wpf - 2.25220.0.1-PreRelease + 2.25229.0.1-PreRelease CodeFactory User Interface WPF for Visual Studio - Windows CodeFactory, LLC. CodeFactory, LLC. @@ -10,7 +10,7 @@ true Library that provides custom dialog screens hosted in Visual Studio for Windows, hosted for CodeFactory automation. - Release Updates for 2.25220.0.1 + Release Updates for 2.25229.0.1 Recompile Release: When you update your automation to this version of the SDK. @@ -19,8 +19,8 @@ Copyright © 2025 CodeFactory, LLC. Factory Automation - - + + CFLogo128.png diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs/CodeFactory.WinVs.csproj b/Src/CodeFactoryForWindows/CodeFactory.WinVs/CodeFactory.WinVs.csproj index 851863d..e7e593d 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.WinVs/CodeFactory.WinVs.csproj +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs/CodeFactory.WinVs.csproj @@ -6,7 +6,7 @@ True CFSigner.snk True - 2.25220.0.1-PreRelease + 2.25229.0.1-PreRelease CodeFactory, LLC. CodeFactory, LLC. CodeFactory Base Library @@ -14,13 +14,13 @@ The CodeFactory API that supports Visual Studio - Windows MIT True - False + True CodeFactory API for Visual Studio - Windows 2.0.0.0 - 2.25220.0.1 + 2.25229.0.1 CFLogo128.png - Release Updates for 2.25220.0.1 + Release Updates for 2.25229.0.1 Recompile Release: When you update your automation to this version of the SDK. diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/CodeFactoryConfigurationLoader.cs b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/CodeFactoryConfigurationLoader.cs index 0592dbe..295d727 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/CodeFactoryConfigurationLoader.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/CodeFactoryConfigurationLoader.cs @@ -220,6 +220,10 @@ public static LibraryLoadStatus LoadFactoryLibraries(VsFactoryConfiguration conf //Throwing to the caller to notify which library could not be loaded due to SDK being out of date. throw; } + catch(LoadErrorSdkLibraryException) + { + throw; + } catch (Exception loadFactoryLibrariesError) { _logger.Error("Unhandled exception occurred see exception for details.", loadFactoryLibrariesError); diff --git a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/SdkSupport.cs b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/SdkSupport.cs index 6018f9d..cb2a66f 100644 --- a/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/SdkSupport.cs +++ b/Src/CodeFactoryForWindows/CodeFactory.WinVs/Loader/SdkSupport.cs @@ -23,12 +23,12 @@ public static class SdkSupport /// /// The maximum version of the SDK that can be loaded and used. /// - public const string MaxVersion = "2.25220.0.1"; + public const string MaxVersion = "2.25229.0.1"; /// /// The target version of the NuGet package this SDK is deployed from. /// - public const string NuGetSdkVersion = "2.25220.0.1-PreRelease"; + public const string NuGetSdkVersion = "2.25229.0.1-PreRelease"; /// /// The name of the assembly type for the CodeFactory SDK version attribute. @@ -54,6 +54,8 @@ public static void SupportedAssembly(Assembly sourceAssembly) Assembly workAssembly = sourceAssembly; bool cfAssembly = false; + + string rawVersion = "0.0.0.0"; try { cfAssembly = workAssembly.GetReferencedAssemblies().Any(a => a.Name == CodeFactoryAssemblyName); @@ -62,7 +64,7 @@ public static void SupportedAssembly(Assembly sourceAssembly) var versionSdk = customAttributes.FirstOrDefault(c => c.AttributeType.Name == CodeFactorySdkVersionAttributeName); - var rawVersion = versionSdk?.ConstructorArguments.FirstOrDefault().Value as string; + rawVersion = versionSdk?.ConstructorArguments.FirstOrDefault().Value as string; if (string.IsNullOrEmpty(rawVersion)) return; @@ -80,11 +82,10 @@ public static void SupportedAssembly(Assembly sourceAssembly) { throw; } - catch (Exception) + catch (Exception unhandledException) { if (cfAssembly) - throw new UnsupportedSdkLibraryException(workAssembly.FullName, "0.0.0.0", MinVersion, - MaxVersion); + throw new LoadErrorSdkLibraryException(workAssembly.FullName, rawVersion, MinVersion,MaxVersion, unhandledException); } finally { diff --git a/Src/CodeFactoryForWindows/CodeFactory/CodeFactory.csproj b/Src/CodeFactoryForWindows/CodeFactory/CodeFactory.csproj index ed48617..5bd1a90 100644 --- a/Src/CodeFactoryForWindows/CodeFactory/CodeFactory.csproj +++ b/Src/CodeFactoryForWindows/CodeFactory/CodeFactory.csproj @@ -6,7 +6,7 @@ True CFSigner.snk True - 2.25220.0.1-PreRelease + 2.25229.0.1-PreRelease CodeFactory, LLC. CodeFactory, LLC. CodeFactory Base Library @@ -14,14 +14,14 @@ The base contracts and logic used by CodeFactory automation. MIT True - False + True CodeFactory Base Libraries 2.0.0.0 - 2.25220.0.1 + 2.25229.0.1 CFLogo128.png git - Release Updates for 2.25220.0.1 + Release Updates for 2.25229.0.1 Recompile Release: When you update your automation to this version of the SDK. diff --git a/Src/CodeFactoryForWindows/CodeFactory/LoadErrorSdkLibraryException.cs b/Src/CodeFactoryForWindows/CodeFactory/LoadErrorSdkLibraryException.cs new file mode 100644 index 0000000..6850f1b --- /dev/null +++ b/Src/CodeFactoryForWindows/CodeFactory/LoadErrorSdkLibraryException.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CodeFactory +{ + /// + /// Represents an exception that is thrown when an assembly has been loaded and has an unhandled exception during the loading process due. + /// + /// This exception provides detailed information about the assembly and SDK version mismatch, + /// including the assembly name, the SDK version it was built with, the supported SDK version range, and the + /// message of any unhandled exception that occurred during the loading process. + public class LoadErrorSdkLibraryException:Exception + { + //Backing fields for the properties + private readonly string _assemblyName; + + private readonly string _assemblyVersion; + + private readonly string _sdkMinVersion; + + private readonly string _sdkMaxVersion; + + private readonly string _unhandledExceptionMessage; + + /// + /// Represents an exception that occurs when a library is loaded and has an unhandled exception during the loading process, + /// + /// This exception is thrown when the specified library's SDK version does not fall + /// within the supported range or when an unhandled exception occurs during the library's loading process. The + /// exception message provides details about the library's assembly name, version, supported SDK range, and the + /// underlying error. + /// The name of the assembly that caused the exception. + /// The version of the assembly that caused the exception. + /// The minimum supported SDK version for the library. + /// The maximum supported SDK version for the library. + /// The unhandled exception that occurred during the library's loading process. + public LoadErrorSdkLibraryException(string assemblyName, string assemblyVersion, string sdkMinVersion, string sdkMaxVersion , Exception unhandledException) + : base($"The library '{assemblyName}' was built with SDK version '{assemblyVersion}' the supported range is '{sdkMinVersion} - {sdkMaxVersion}' and has the following error '{unhandledException.Message}'.") + { + _assemblyName = assemblyName; + _assemblyVersion = assemblyVersion; + _sdkMinVersion = sdkMinVersion; + _sdkMaxVersion = sdkMaxVersion; + _unhandledExceptionMessage = unhandledException.Message; + } + + /// + /// The name of the assembly that is was compiled on an unsupported SDK version. + /// + public string AssemblyName => _assemblyName; + + /// + /// The assembly SDK version that was used when building the assembly. + /// + public string AssemblyVersion => _assemblyVersion; + + /// + /// The minimum supported SDK version. + /// + public string SdkMinVersion => _sdkMinVersion; + + /// + /// The maximum supported SDK version. + /// + public string SdkMaxVersion => _sdkMaxVersion; + + /// + /// Unhandled exception message that was thrown when trying to load the assembly. + /// + public string UnhandledExceptionMessage => _unhandledExceptionMessage; + + } +}