Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Unknown Assembly Experience/Messaging #559

Merged
merged 4 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/ExtendedXmlSerializer/ReflectionModel/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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);
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue558Tests.cs
Original file line number Diff line number Diff line change
@@ -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 =
@"<?xml version=""1.0"" encoding=""utf-8""?><Issue558Tests-Subject xmlns=""clr-namespace:ExtendedXmlSerializer.Tests.ReportedIssues;assembly=ExtendedXmlSerializer.Tests.ReportedIssues.DoesNotExist"" />";

subject.Invoking(x => x.Deserialize<Subject>(document))
.Should()
.ThrowExactly<InvalidOperationException>()
.WithMessage("Could not load assembly 'ExtendedXmlSerializer.Tests.ReportedIssues.DoesNotExist'. Are you sure it exists?");
}

sealed class Subject {}
}
}