diff --git a/src/System.Net.Http.Formatting.NetCore/System.Net.Http.Formatting.NetCore.csproj b/src/System.Net.Http.Formatting.NetCore/System.Net.Http.Formatting.NetCore.csproj
index c3d0a0827..e6b73a996 100644
--- a/src/System.Net.Http.Formatting.NetCore/System.Net.Http.Formatting.NetCore.csproj
+++ b/src/System.Net.Http.Formatting.NetCore/System.Net.Http.Formatting.NetCore.csproj
@@ -60,6 +60,9 @@
Formatting\FormUrlEncodedJson.cs
+
+ Formatting\FormUrlEncodedMediaTypeFormatter.cs
+
Formatting\IFormatterLogger.cs
@@ -117,6 +120,9 @@
Formatting\XmlMediaTypeFormatter.cs
+
+ HttpContentFormDataExtensions.cs
+
HttpValueCollection.cs
diff --git a/src/System.Net.Http.Formatting.NetStandard/System.Net.Http.Formatting.NetStandard.csproj b/src/System.Net.Http.Formatting.NetStandard/System.Net.Http.Formatting.NetStandard.csproj
index 49eb0f3a9..4824d77cd 100644
--- a/src/System.Net.Http.Formatting.NetStandard/System.Net.Http.Formatting.NetStandard.csproj
+++ b/src/System.Net.Http.Formatting.NetStandard/System.Net.Http.Formatting.NetStandard.csproj
@@ -59,6 +59,9 @@
Formatting\FormUrlEncodedJson.cs
+
+ Formatting\FormUrlEncodedMediaTypeFormatter.cs
+
Formatting\IFormatterLogger.cs
@@ -116,6 +119,9 @@
Formatting\XmlMediaTypeFormatter.cs
+
+ HttpContentFormDataExtensions.cs
+
Internal\HttpValueCollection.cs
diff --git a/src/System.Net.Http.Formatting/Formatting/MediaTypeFormatterCollection.cs b/src/System.Net.Http.Formatting/Formatting/MediaTypeFormatterCollection.cs
index 2a54f050a..17a4959ba 100644
--- a/src/System.Net.Http.Formatting/Formatting/MediaTypeFormatterCollection.cs
+++ b/src/System.Net.Http.Formatting/Formatting/MediaTypeFormatterCollection.cs
@@ -59,7 +59,6 @@ public JsonMediaTypeFormatter JsonFormatter
get { return Items.OfType().FirstOrDefault(); }
}
-#if !NETFX_CORE // FormUrlEncodedMediaTypeFormatter is not supported in portable library.
///
/// Gets the to use for application/x-www-form-urlencoded data.
///
@@ -67,7 +66,6 @@ public FormUrlEncodedMediaTypeFormatter FormUrlEncodedFormatter
{
get { return Items.OfType().FirstOrDefault(); }
}
-#endif
internal MediaTypeFormatter[] WritingFormatters
{
@@ -202,8 +200,8 @@ public static bool IsTypeExcludedFromValidation(Type type)
return
#if !NETFX_CORE
typeof(XmlNode).IsAssignableFrom(type) ||
- typeof(FormDataCollection).IsAssignableFrom(type) ||
#endif
+ typeof(FormDataCollection).IsAssignableFrom(type) ||
FormattingUtilities.IsJTokenType(type) ||
typeof(XObject).IsAssignableFrom(type) ||
typeof(Type).IsAssignableFrom(type) ||
@@ -260,9 +258,7 @@ private static IEnumerable CreateDefaultFormatters()
{
new JsonMediaTypeFormatter(),
new XmlMediaTypeFormatter(),
-#if !NETFX_CORE
new FormUrlEncodedMediaTypeFormatter()
-#endif
};
}
diff --git a/src/System.Net.Http.Formatting/HttpContentFormDataExtensions.cs b/src/System.Net.Http.Formatting/HttpContentFormDataExtensions.cs
index 3ef7afc6a..19f5b9bc3 100644
--- a/src/System.Net.Http.Formatting/HttpContentFormDataExtensions.cs
+++ b/src/System.Net.Http.Formatting/HttpContentFormDataExtensions.cs
@@ -8,6 +8,9 @@
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
+#if NETFX_CORE
+using NameValueCollection = System.Net.Http.Formatting.HttpValueCollection;
+#endif
namespace System.Net.Http
{
diff --git a/test/System.Net.Http.Formatting.NetCore.Test/System.Net.Http.Formatting.NetCore.Test.csproj b/test/System.Net.Http.Formatting.NetCore.Test/System.Net.Http.Formatting.NetCore.Test.csproj
index f8051e292..f0bad92d4 100644
--- a/test/System.Net.Http.Formatting.NetCore.Test/System.Net.Http.Formatting.NetCore.Test.csproj
+++ b/test/System.Net.Http.Formatting.NetCore.Test/System.Net.Http.Formatting.NetCore.Test.csproj
@@ -60,15 +60,27 @@
+
+ DataSets\Types\DerivedFormUrlEncodedMediaTypeFormatter.cs
+
Formatting\BsonMediaTypeFormatterTests.cs
Internal\FormDataCollectionTests.cs
+
+ Formatting\FormUrlEncodedFromContentTests.cs
+
+
+ Formatting\FormUrlEncodedFromUriQueryTests.cs
+
Internal\FormUrlEncodedJsonTests.cs
+
+ Formatting\FormUrlEncodedMediaTypeFormatterTests.cs
+
Formatting\JsonNetSerializationTest.cs
@@ -78,6 +90,9 @@
Internal\FormUrlEncodedParserTests.cs
+
+ HttpContentFormDataExtensionsTest.cs
+
HttpValueCollectionTest.cs
diff --git a/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj b/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj
index d442f4ca0..c8b514a1a 100644
--- a/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj
+++ b/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj
@@ -53,15 +53,27 @@
+
+ DataSets\Types\DerivedFormUrlEncodedMediaTypeFormatter.cs
+
Formatting\BsonMediaTypeFormatterTests.cs
Internal\FormDataCollectionTests.cs
+
+ Formatting\FormUrlEncodedFromContentTests.cs
+
+
+ Formatting\FormUrlEncodedFromUriQueryTests.cs
+
Internal\FormUrlEncodedJsonTests.cs
+
+ Formatting\FormUrlEncodedMediaTypeFormatterTests.cs
+
Formatting\JsonNetSerializationTest.cs
@@ -71,6 +83,9 @@
Internal\FormUrlEncodedParserTests.cs
+
+ HttpContentFormDataExtensionsTest.cs
+
HttpValueCollectionTest.cs
diff --git a/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs b/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs
index 94cc7782b..50911b2f9 100644
--- a/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs
+++ b/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs
@@ -498,9 +498,7 @@ public static TestData StandardFormatters
{
new XmlMediaTypeFormatter(),
new JsonMediaTypeFormatter(),
-#if !NETFX_CORE // not present in portable library version
new FormUrlEncodedMediaTypeFormatter()
-#endif
});
}
}
@@ -521,9 +519,7 @@ public static TestData DerivedFormatters
{
new DerivedXmlMediaTypeFormatter(),
new DerivedJsonMediaTypeFormatter(),
-#if !NETFX_CORE // not present in portable library version
new DerivedFormUrlEncodedMediaTypeFormatter(),
-#endif
});
}
}
diff --git a/test/System.Net.Http.Formatting.Test/Formatting/MediaTypeFormatterCollectionTests.cs b/test/System.Net.Http.Formatting.Test/Formatting/MediaTypeFormatterCollectionTests.cs
index 2e551072a..4a06f3def 100644
--- a/test/System.Net.Http.Formatting.Test/Formatting/MediaTypeFormatterCollectionTests.cs
+++ b/test/System.Net.Http.Formatting.Test/Formatting/MediaTypeFormatterCollectionTests.cs
@@ -27,16 +27,11 @@ public void TypeIsCorrect()
public void Constructor()
{
MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection();
-#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
+
Assert.Equal(3, collection.Count);
-#else
- Assert.Equal(2, collection.Count);
-#endif
Assert.NotNull(collection.XmlFormatter);
Assert.NotNull(collection.JsonFormatter);
-#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
Assert.NotNull(collection.FormUrlEncodedFormatter);
-#endif
}
[Fact]
@@ -101,14 +96,11 @@ public void Constructor1_AcceptsDuplicateFormatterTypes()
{
new XmlMediaTypeFormatter(),
new JsonMediaTypeFormatter(),
-#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
new FormUrlEncodedMediaTypeFormatter(),
-#endif
+
new XmlMediaTypeFormatter(),
new JsonMediaTypeFormatter(),
-#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
new FormUrlEncodedMediaTypeFormatter(),
-#endif
};
MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection(formatters);
@@ -185,7 +177,6 @@ public void JsonFormatter_ClearedByCtor()
Assert.Null(collection.JsonFormatter);
}
-#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
[Fact]
public void FormUrlEncodedFormatter_SetByCtor()
{
@@ -200,8 +191,7 @@ public void FormUrlEncodedFormatter_ClearedByCtor()
MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection(new MediaTypeFormatter[0]);
Assert.Null(collection.FormUrlEncodedFormatter);
}
-#endif
-
+
[Fact]
public void Remove_SetsXmlFormatter()
{
@@ -371,8 +361,8 @@ public void FindWriter_ReturnsFormatterOnMatch(Type variationType, object testDa
[InlineData(typeof(byte[]))]
#if !NETFX_CORE
[InlineData(typeof(XmlElement))]
- [InlineData(typeof(FormDataCollection))]
#endif
+ [InlineData(typeof(FormDataCollection))]
public void IsTypeExcludedFromValidation_ReturnsTrueForExcludedTypes(Type type)
{
Assert.True(MediaTypeFormatterCollection.IsTypeExcludedFromValidation(type));
diff --git a/test/System.Net.Http.Formatting.Test/HttpContentFormDataExtensionsTest.cs b/test/System.Net.Http.Formatting.Test/HttpContentFormDataExtensionsTest.cs
index ea2ca2ef4..06326ecc3 100644
--- a/test/System.Net.Http.Formatting.Test/HttpContentFormDataExtensionsTest.cs
+++ b/test/System.Net.Http.Formatting.Test/HttpContentFormDataExtensionsTest.cs
@@ -5,9 +5,13 @@
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Text;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.TestCommon;
+#if NETFX_CORE
+using NameValueCollection = System.Net.Http.Formatting.HttpValueCollection;
+#endif
namespace System.Net.Http
{
@@ -150,7 +154,11 @@ public async Task ReadAsFormDataAsync_HandlesIrregularFormData(string irregularF
// Assert
Assert.Equal(1, data.Count);
+#if NETFX_CORE
+ Assert.Equal(irregularFormData, data.First().Key);
+#else
Assert.Equal(irregularFormData, data.AllKeys[0]);
+#endif
}
[Fact]