Skip to content

Commit 457b571

Browse files
committed
Add MediaTypeMappings support in NetCore assembly
1 parent 7842d08 commit 457b571

File tree

4 files changed

+0
-18
lines changed

4 files changed

+0
-18
lines changed

src/System.Net.Http.Formatting/Formatting/JsonMediaTypeFormatter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ public JsonMediaTypeFormatter()
3535
SupportedMediaTypes.Add(MediaTypeConstants.ApplicationJsonMediaType);
3636
SupportedMediaTypes.Add(MediaTypeConstants.TextJsonMediaType);
3737

38-
#if !NETFX_CORE // MediaTypeMappings are not supported in portable library
3938
_requestHeaderMapping = new XmlHttpRequestHeaderMapping();
4039
MediaTypeMappings.Add(_requestHeaderMapping);
41-
#endif
4240
}
4341

4442
/// <summary>

src/System.Net.Http.Formatting/Formatting/MediaTypeFormatter.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ public abstract class MediaTypeFormatter
3333

3434
private readonly List<MediaTypeHeaderValue> _supportedMediaTypes;
3535
private readonly List<Encoding> _supportedEncodings;
36-
#if !NETFX_CORE // No MediaTypeMappings in portable library or IRequiredMemberSelector (no model state on client)
3736
private readonly List<MediaTypeMapping> _mediaTypeMappings;
3837
private IRequiredMemberSelector _requiredMemberSelector;
39-
#endif
4038

4139
/// <summary>
4240
/// Initializes a new instance of the <see cref="MediaTypeFormatter"/> class.
@@ -47,10 +45,8 @@ protected MediaTypeFormatter()
4745
SupportedMediaTypes = new MediaTypeHeaderValueCollection(_supportedMediaTypes);
4846
_supportedEncodings = new List<Encoding>();
4947
SupportedEncodings = new Collection<Encoding>(_supportedEncodings);
50-
#if !NETFX_CORE // No MediaTypeMappings in portable library
5148
_mediaTypeMappings = new List<MediaTypeMapping>();
5249
MediaTypeMappings = new Collection<MediaTypeMapping>(_mediaTypeMappings);
53-
#endif
5450
}
5551

5652
/// <summary>
@@ -68,11 +64,9 @@ protected MediaTypeFormatter(MediaTypeFormatter formatter)
6864
SupportedMediaTypes = formatter.SupportedMediaTypes;
6965
_supportedEncodings = formatter._supportedEncodings;
7066
SupportedEncodings = formatter.SupportedEncodings;
71-
#if !NETFX_CORE // No MediaTypeMappings in portable library or IRequiredMemberSelector (no model state on client)
7267
_mediaTypeMappings = formatter._mediaTypeMappings;
7368
MediaTypeMappings = formatter.MediaTypeMappings;
7469
_requiredMemberSelector = formatter._requiredMemberSelector;
75-
#endif
7670
}
7771

7872
/// <summary>
@@ -123,7 +117,6 @@ internal List<Encoding> SupportedEncodingsInternal
123117
get { return _supportedEncodings; }
124118
}
125119

126-
#if !NETFX_CORE // No MediaTypeMappings in portable library
127120
/// <summary>
128121
/// Gets the mutable collection of <see cref="MediaTypeMapping"/> elements used
129122
/// by this <see cref="MediaTypeFormatter"/> instance to determine the
@@ -135,7 +128,6 @@ internal List<MediaTypeMapping> MediaTypeMappingsInternal
135128
{
136129
get { return _mediaTypeMappings; }
137130
}
138-
#endif
139131

140132
#if !NETFX_CORE // IRequiredMemberSelector is not in portable libraries because there is no model state on the client.
141133
/// <summary>

test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ public static TestData<HttpContent> StandardHttpContents
356356

357357
//// TODO: make this list compose from other data?
358358
// Collection of legal instances of all standard MediaTypeMapping types
359-
#if !NETFX_CORE // not present in portable library version
360359
public static TestData<MediaTypeMapping> StandardMediaTypeMappings
361360
{
362361
get
@@ -375,7 +374,6 @@ public static TestData<QueryStringMapping> QueryStringMappings
375374
});
376375
}
377376
}
378-
#endif
379377

380378
public static TestData<string> LegalUriPathExtensions
381379
{

test/System.Net.Http.Formatting.Test/Formatting/MediaTypeFormatterTests.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@ public void Constructor()
5151
Collection<MediaTypeHeaderValue> supportedMediaTypes = formatter.SupportedMediaTypes;
5252
Assert.NotNull(supportedMediaTypes);
5353
Assert.Empty(supportedMediaTypes);
54-
#if !NETFX_CORE // No MediaTypeMapping support in portable libraries
5554
Collection<MediaTypeMapping> mappings = formatter.MediaTypeMappings;
5655

5756
Assert.NotNull(mappings);
5857
Assert.Empty(mappings);
59-
#endif
6058
}
6159

6260
[Fact]
@@ -65,11 +63,9 @@ void CopyConstructor()
6563
TestMediaTypeFormatter formatter = new TestMediaTypeFormatter();
6664
TestMediaTypeFormatter derivedFormatter = new TestMediaTypeFormatter(formatter);
6765

68-
#if !NETFX_CORE // No MediaTypeMapping or RequiredMemberSelector in client libraries
6966
Assert.Same(formatter.MediaTypeMappings, derivedFormatter.MediaTypeMappings);
7067
Assert.Same(formatter.MediaTypeMappingsInternal, derivedFormatter.MediaTypeMappingsInternal);
7168
Assert.Equal(formatter.RequiredMemberSelector, derivedFormatter.RequiredMemberSelector);
72-
#endif
7369

7470
Assert.Same(formatter.SupportedMediaTypes, derivedFormatter.SupportedMediaTypes);
7571
Assert.Same(formatter.SupportedMediaTypesInternal, derivedFormatter.SupportedMediaTypesInternal);
@@ -151,7 +147,6 @@ public void SupportedMediaTypes_InsertThrowsWithMediaRange(MediaTypeHeaderValue
151147
Assert.ThrowsArgument(() => supportedMediaTypes.Insert(0, mediaType), "item", Error.Format(Properties.Resources.CannotUseMediaRangeForSupportedMediaType, typeof(MediaTypeHeaderValue).Name, mediaType.MediaType));
152148
}
153149

154-
#if !NETFX_CORE // No MediaTypeMapping support in portable libraries
155150
[Fact]
156151
public void MediaTypeMappings_IsMutable()
157152
{
@@ -165,7 +160,6 @@ public void MediaTypeMappings_IsMutable()
165160

166161
Assert.True(standardMappings.SequenceEqual(formatter.MediaTypeMappings));
167162
}
168-
#endif
169163

170164
[Fact]
171165
public void SelectCharacterEncoding_ThrowsIfNoSupportedEncodings()

0 commit comments

Comments
 (0)