diff --git a/src/Microsoft.AspNet.Routing/RouteValueDictionary.cs b/src/Microsoft.AspNet.Routing/RouteValueDictionary.cs
index 8f6457cce0..e528c1ecdc 100644
--- a/src/Microsoft.AspNet.Routing/RouteValueDictionary.cs
+++ b/src/Microsoft.AspNet.Routing/RouteValueDictionary.cs
@@ -31,23 +31,24 @@ namespace Microsoft.AspNet.Routing
}
///
- /// Creates a initialized with the provided input value.
+ /// Creates a initialized with the specified .
///
- /// An object to initialize the dictionary. The value can be of type
- /// or or
- /// any other object.
+ /// An object to initialize the dictionary. The value can be of type
+ /// or
+ /// or an object with public properties as key-value pairs.
///
///
- /// If the value is a dictionary, then its entries are copied. Otherwise the object is interpreted as a set
- /// of key-value-pairs where the property names are keys, and property values are the values, and copied
- /// into the dictionary. Only public instance non-index properties are considered.
+ /// If the value is a dictionary or other ,
+ /// then its entries are copied. Otherwise the object is interpreted as a set of key-value pairs where the
+ /// property names are keys, and property values are the values, and copied into the dictionary.
+ /// Only public instance non-index properties are considered.
///
- public RouteValueDictionary(object obj)
+ public RouteValueDictionary(object values)
: this()
{
- if (obj != null)
+ if (values != null)
{
- var keyValuePairCollection = obj as IEnumerable>;
+ var keyValuePairCollection = values as IEnumerable>;
if (keyValuePairCollection != null)
{
foreach (var kvp in keyValuePairCollection)
@@ -57,7 +58,7 @@ namespace Microsoft.AspNet.Routing
return;
}
- var type = obj.GetType();
+ var type = values.GetType();
var allProperties = type.GetRuntimeProperties();
// This is done to support 'new' properties that hide a property on a base class
@@ -69,7 +70,7 @@ namespace Microsoft.AspNet.Routing
!property.GetMethod.IsStatic &&
property.GetIndexParameters().Length == 0)
{
- var value = property.GetValue(obj);
+ var value = property.GetValue(values);
if (ContainsKey(property.Name) && property.DeclaringType != type)
{
// This is a hidden property, ignore it.
diff --git a/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs b/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs
index 30ada5cf37..779496f9a2 100644
--- a/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs
+++ b/src/Microsoft.AspNet.Routing/Template/TemplateBinder.cs
@@ -414,7 +414,7 @@ namespace Microsoft.AspNet.Routing.Template
return string.Format(
"{{Accepted: '{0}' Filters: '{1}'}}",
string.Join(", ", _acceptedValues.Keys),
- string.Join(", ", _filters.Keys));
+ string.Join(", ", _filters?.Keys));
}
}
diff --git a/test/Microsoft.AspNet.Routing.Tests/RouteValueDictionaryTests.cs b/test/Microsoft.AspNet.Routing.Tests/RouteValueDictionaryTests.cs
index 4015158aa8..88dd3ac4f0 100644
--- a/test/Microsoft.AspNet.Routing.Tests/RouteValueDictionaryTests.cs
+++ b/test/Microsoft.AspNet.Routing.Tests/RouteValueDictionaryTests.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNet.Testing;
using Xunit;
@@ -168,36 +169,47 @@ namespace Microsoft.AspNet.Routing.Tests
expected);
}
- [Fact]
- public void CreateFromReadOnlyDictionary_CopiesValues()
+ public static IEnumerable