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

Commit

Permalink
Check for empty location in ViewsFeatureProvider
Browse files Browse the repository at this point in the history
Fixes #5675
  • Loading branch information
pranavkm committed Jan 17, 2017
1 parent ce53675 commit e749a80
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;
}
}
}

0 comments on commit e749a80

Please sign in to comment.