From c341ecfc46dbbd6eb2deebbb1cad9e0305c8b385 Mon Sep 17 00:00:00 2001
From: Mike-E <2931376+Mike-E-angelo@users.noreply.github.com>
Date: Tue, 26 Oct 2021 04:33:49 -0400
Subject: [PATCH] Improved Unknown Assembly Experience/Messaging (#559)
---
.../ReflectionModel/AssemblyLoader.cs | 6 ++---
.../Issue558Tests.cs | 27 +++++++++++++++++++
2 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue558Tests.cs
diff --git a/src/ExtendedXmlSerializer/ReflectionModel/AssemblyLoader.cs b/src/ExtendedXmlSerializer/ReflectionModel/AssemblyLoader.cs
index f1bf37c2..eb784c83 100644
--- a/src/ExtendedXmlSerializer/ReflectionModel/AssemblyLoader.cs
+++ b/src/ExtendedXmlSerializer/ReflectionModel/AssemblyLoader.cs
@@ -32,7 +32,7 @@ public Assembly Get(string parameter)
{
return Assembly.LoadFile(_path(parameter));
}
- catch
+ catch (Exception error)
{
var length = _loaded.Length;
for (var i = 0; i < length; i++)
@@ -44,9 +44,7 @@ public Assembly Get(string parameter)
}
}
-#pragma warning disable CS0618
- return Assembly.LoadWithPartialName(parameter);
-#pragma warning restore CS0618
+ throw new InvalidOperationException($"Could not load assembly '{parameter}'. Are you sure it exists?", error);
}
}
}
diff --git a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue558Tests.cs b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue558Tests.cs
new file mode 100644
index 00000000..e7624062
--- /dev/null
+++ b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue558Tests.cs
@@ -0,0 +1,27 @@
+using ExtendedXmlSerializer.Configuration;
+using ExtendedXmlSerializer.Tests.ReportedIssues.Support;
+using FluentAssertions;
+using System;
+using Xunit;
+
+namespace ExtendedXmlSerializer.Tests.ReportedIssues
+{
+ public sealed class Issue558Tests
+ {
+ [Fact]
+ public void Verify()
+ {
+ var subject = new ConfigurationContainer().Create().ForTesting();
+
+ const string document =
+ @"";
+
+ subject.Invoking(x => x.Deserialize(document))
+ .Should()
+ .ThrowExactly()
+ .WithMessage("Could not load assembly 'ExtendedXmlSerializer.Tests.ReportedIssues.DoesNotExist'. Are you sure it exists?");
+ }
+
+ sealed class Subject {}
+ }
+}
\ No newline at end of file