Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Check for empty location in ViewsFeatureProvider #5685

Merged
merged 1 commit into from Jan 17, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -58,7 +58,7 @@ public void PopulateFeature(IEnumerable<ApplicationPart> parts, ViewsFeature fea
protected virtual Type GetViewInfoContainerType(AssemblyPart assemblyPart)
{
#if NETSTANDARD1_6
if (!assemblyPart.Assembly.IsDynamic && assemblyPart.Assembly.Location != null)
if (!assemblyPart.Assembly.IsDynamic && !string.IsNullOrEmpty(assemblyPart.Assembly.Location))
{
var precompiledAssemblyFileName = assemblyPart.Assembly.GetName().Name
+ PrecompiledViewsAssemblySuffix
Expand Down
Expand Up @@ -90,6 +90,23 @@ public void PopulateFeature_ReturnsEmptySequenceIfNoDynamicAssemblyPartHasViewAs
Assert.Empty(feature.Views);
}

[Fact]
public void PopulateFeature_DoesNotFail_IfAssemblyHasEmptyLocation()
{
// Arrange
var assembly = new AssemblyWithEmptyLocation();
var applicationPartManager = new ApplicationPartManager();
applicationPartManager.ApplicationParts.Add(new AssemblyPart(assembly));
applicationPartManager.FeatureProviders.Add(new ViewsFeatureProvider());
var feature = new ViewsFeature();

// Act
applicationPartManager.PopulateFeature(feature);

// Assert
Assert.Empty(feature.Views);
}

private class TestableViewsFeatureProvider : ViewsFeatureProvider
{
private readonly Dictionary<AssemblyPart, Type> _containerLookup;
Expand Down Expand Up @@ -125,5 +142,12 @@ public ViewInfoContainer2()
{
}
}

private class AssemblyWithEmptyLocation : Assembly
{
public override string Location => string.Empty;

public override string FullName => typeof(ViewsFeatureProviderTest).GetTypeInfo().Assembly.FullName;
}
}
}