Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 04a2e39

Browse files
authored
Move New Syndication APIs to NetCore Specific Ref (#25611)
* Move New Syndication APIs to NetCore Specific Ref Move New Syndication APIs to NetCore Specific Ref Assembly. Fix #25585 * Fixed Syndication Netfx Ref * Merged Test Projects.
1 parent eb0d438 commit 04a2e39

8 files changed

+161
-120
lines changed

src/System.ServiceModel.Syndication/ref/Configurations.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<BuildConfigurations>
55
netfx;
6+
netcoreapp;
67
netstandard;
78
</BuildConfigurations>
89
</PropertyGroup>

src/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ public abstract partial class SyndicationFeedFormatter
391391
{
392392
protected SyndicationFeedFormatter() { }
393393
protected SyndicationFeedFormatter(System.ServiceModel.Syndication.SyndicationFeed feedToWrite) { }
394-
public System.Func<string, string, string, System.DateTimeOffset> DateTimeParser { get { throw null; } set { } }
395394
public System.ServiceModel.Syndication.SyndicationFeed Feed { get { throw null; } }
396-
public System.Func<string, System.UriKind, string, string, System.Uri> UriParser { get { throw null; } set { } }
397395
public abstract string Version { get; }
398396
public abstract bool CanRead(System.Xml.XmlReader reader);
399397
protected internal static System.ServiceModel.Syndication.SyndicationCategory CreateCategory(System.ServiceModel.Syndication.SyndicationFeed feed) { throw null; }

src/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.csproj

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,31 @@
33
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
44
<PropertyGroup>
55
<ProjectGuid>{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}</ProjectGuid>
6-
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
76
</PropertyGroup>
87
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
98
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
10+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
1011
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
1112
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
1213
<ItemGroup>
1314
<Compile Include="System.ServiceModel.Syndication.cs" />
1415
</ItemGroup>
16+
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
17+
<Compile Include="System.ServiceModel.Syndication.netcoreapp.cs" />
18+
</ItemGroup>
19+
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
20+
<ProjectReference Include="..\..\System.Collections\ref\System.Collections.csproj" />
21+
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
22+
<ProjectReference Include="..\..\System.Runtime.Serialization.Primitives\ref\System.Runtime.Serialization.Primitives.csproj" />
23+
<ProjectReference Include="..\..\System.Runtime.Serialization.Xml\ref\System.Runtime.Serialization.Xml.csproj" />
24+
<ProjectReference Include="..\..\System.Xml.ReaderWriter\ref\System.Xml.ReaderWriter.csproj" />
25+
<ProjectReference Include="..\..\System.Xml.XmlSerializer\ref\System.Xml.XmlSerializer.csproj" />
26+
</ItemGroup>
1527
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
1628
<Reference Include="mscorlib" />
1729
<Reference Include="System" />
1830
<Reference Include="System.Runtime.Serialization" />
19-
<Reference Include="System.ServiceModel" />
2031
<Reference Include="System.Xml" />
2132
</ItemGroup>
2233
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// ------------------------------------------------------------------------------
5+
// Changes to this file must follow the http://aka.ms/api-review process.
6+
// ------------------------------------------------------------------------------
7+
8+
namespace System.ServiceModel.Syndication
9+
{
10+
public abstract partial class SyndicationFeedFormatter
11+
{
12+
public System.Func<string, string, string, System.DateTimeOffset> DateTimeParser { get { throw null; } set { } }
13+
public System.Func<string, System.UriKind, string, string, System.Uri> UriParser { get { throw null; } set { } }
14+
}
15+
}

src/System.ServiceModel.Syndication/tests/BasicScenarioTests.cs

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace System.ServiceModel.Syndication.Tests
1515
{
16-
public static class BasicScenarioTests
16+
public static partial class BasicScenarioTests
1717
{
1818
[Fact]
1919
public static void SyndicationFeed_CreateNewFeed()
@@ -304,110 +304,6 @@ public static void SyndicationFeed_Rss_WrongDateFormat()
304304
Assert.Throws<XmlException>(() => dateTimeOffset = items[2].PublishDate);
305305
}
306306

307-
[Fact]
308-
public static void SyndicationFeed_Rss_DateTimeParser()
309-
{
310-
// *** SETUP *** \\
311-
// *** EXECUTE *** \\
312-
SyndicationFeed feed;
313-
DateTimeOffset dto = new DateTimeOffset(2017, 1, 2, 3, 4, 5, new TimeSpan(0));
314-
using (XmlReader reader = XmlReader.Create(@"RssSpecCustomParser.xml"))
315-
{
316-
var formatter = new Rss20FeedFormatter();
317-
formatter.DateTimeParser = (value, localName, ns) => dto;
318-
formatter.ReadFrom(reader);
319-
feed = formatter.Feed;
320-
}
321-
322-
// *** ASSERT *** \\
323-
Assert.True(feed != null, "res was null.");
324-
Assert.Equal(dto, feed.LastUpdatedTime);
325-
}
326-
327-
[Fact]
328-
public static void SyndicationFeed_Rss_UriParser()
329-
{
330-
// *** SETUP *** \\
331-
// *** EXECUTE *** \\
332-
SyndicationFeed feed;
333-
using (XmlReader reader = XmlReader.Create(@"RssSpecCustomParser.xml"))
334-
{
335-
var formatter = new Rss20FeedFormatter
336-
{
337-
UriParser = (value, kind, localName, ns) => new Uri($"http://value-{value}-kind-{kind}-localName-{localName}-ns-{ns}-end")
338-
};
339-
formatter.ReadFrom(reader);
340-
feed = formatter.Feed;
341-
}
342-
343-
// *** ASSERT *** \\
344-
Assert.True(feed != null, "res was null.");
345-
Assert.Equal(new Uri("http://value-ChannelBase-kind-relativeorabsolute-localName-channel-ns--end"), feed.BaseUri);
346-
Assert.Equal(new Uri("http://value-ImageUrl-kind-relativeorabsolute-localName-url-ns--end"), feed.ImageUrl);
347-
Assert.NotNull(feed.Links);
348-
Assert.Equal(1, feed.Links.Count);
349-
Assert.Equal(new Uri("http://value-FeedLink-kind-relativeorabsolute-localName-link-ns--end"), feed.Links.First().Uri);
350-
351-
Assert.True(feed.Items != null, "res.Items was null.");
352-
Assert.Equal(1, feed.Items.Count());
353-
Assert.Equal(1, feed.Items.First().Links.Count);
354-
Assert.Equal(new Uri("http://value-itemlink-kind-relativeorabsolute-localName-link-ns--end"), feed.Items.First().Links.First().Uri);
355-
}
356-
357-
[Fact]
358-
public static void SyndicationFeed_Atom_DateTimeParser()
359-
{
360-
// *** SETUP *** \\
361-
// *** EXECUTE *** \\
362-
SyndicationFeed feed;
363-
DateTimeOffset dto = new DateTimeOffset(2017, 1, 2, 3, 4, 5, new TimeSpan(0));
364-
using (XmlReader reader = XmlReader.Create(@"SimpleAtomFeedCustomParser.xml"))
365-
{
366-
var formatter = new Atom10FeedFormatter
367-
{
368-
DateTimeParser = (value, localName, ns) => dto
369-
};
370-
formatter.ReadFrom(reader);
371-
feed = formatter.Feed;
372-
}
373-
374-
// *** ASSERT *** \\
375-
Assert.True(feed != null, "res was null.");
376-
Assert.Equal(dto, feed.LastUpdatedTime);
377-
378-
Assert.True(feed.Items != null, "res.Items was null.");
379-
Assert.Equal(1, feed.Items.Count());
380-
Assert.Equal(dto, feed.Items.First().LastUpdatedTime);
381-
}
382-
383-
[Fact]
384-
public static void SyndicationFeed_Atom_UriParser()
385-
{
386-
// *** SETUP *** \\
387-
// *** EXECUTE *** \\
388-
SyndicationFeed feed;
389-
using (XmlReader reader = XmlReader.Create(@"SimpleAtomFeedCustomParser.xml"))
390-
{
391-
var formatter = new Atom10FeedFormatter
392-
{
393-
UriParser = (value, kind, localName, ns) => new Uri($"http://value-{value}-kind-{kind}-localName-{localName}-ns-{ns}-end")
394-
};
395-
formatter.ReadFrom(reader);
396-
feed = formatter.Feed;
397-
}
398-
399-
// *** ASSERT *** \\
400-
Assert.True(feed != null, "res was null.");
401-
Assert.Equal(new Uri("http://value-FeedLogo-kind-relativeorabsolute-localName-logo-ns-http//www.w3.org/2005/Atom-end"), feed.ImageUrl);
402-
403-
Assert.True(feed.Items != null, "res.Items was null.");
404-
Assert.Equal(1, feed.Items.Count());
405-
Assert.NotNull(feed.Items.First().Links);
406-
Assert.Equal(1, feed.Items.First().Links.Count);
407-
Assert.Equal(new Uri("http://value-EntryLinkHref-kind-relativeorabsolute-localName-link-ns-http//www.w3.org/2005/Atom-end"), feed.Items.First().Links.First().Uri);
408-
Assert.Equal(new Uri("http://value-EntryContentSrc-kind-relativeorabsolute-localName-content-ns-http://www.w3.org/2005/Atom-end"), ((UrlSyndicationContent)feed.Items.First().Content).Url);
409-
}
410-
411307
[Fact]
412308
public static void AtomEntryPositiveTest()
413309
{

src/System.ServiceModel.Syndication/tests/Configurations.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<BuildConfigurations>
5+
netcoreapp;
56
netstandard;
67
</BuildConfigurations>
78
</PropertyGroup>

src/System.ServiceModel.Syndication/tests/System.ServiceModel.Syndication.Tests.csproj

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,18 @@
44
<PropertyGroup>
55
<ProjectGuid>{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}</ProjectGuid>
66
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Debug|AnyCPU'" />
8+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Release|AnyCPU'" />
79
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
810
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
911
<ItemGroup>
10-
<Compile Include="$(MsBuildThisFileDirectory)**\*.cs" Exclude="$(MsBuildThisFileDirectory)async\**\*.cs" />
12+
<Compile Include="$(MsBuildThisFileDirectory)**\*.cs" Exclude="$(MsBuildThisFileDirectory)netcoreapp\**\*.cs" />
13+
</ItemGroup>
14+
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
15+
<Compile Include="$(MsBuildThisFileDirectory)netcoreapp\**\*.cs" />
1116
</ItemGroup>
1217
<ItemGroup>
13-
<Content Include="$(MsBuildThisFileDirectory)\TestFeeds\*.xml">
14-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15-
</Content>
16-
<Content Include="$(MsBuildThisFileDirectory)\TestFeeds\AtomFeeds\*.xml">
17-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18-
</Content>
19-
<Content Include="$(MsBuildThisFileDirectory)\TestFeeds\RssFeeds\*.xml">
20-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
21-
</Content>
22-
<Content Include="$(MsBuildThisFileDirectory)\TestFeeds\FailureFeeds\*.xml">
18+
<Content Include="$(MsBuildThisFileDirectory)\TestFeeds\**\*.xml">
2319
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2420
</Content>
2521
</ItemGroup>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+

2+
// Licensed to the .NET Foundation under one or more agreements.
3+
// The .NET Foundation licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for more information.
5+
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Text;
9+
using System.ServiceModel.Syndication;
10+
using System.Xml;
11+
using System.IO;
12+
using Xunit;
13+
using System.Linq;
14+
15+
namespace System.ServiceModel.Syndication.Tests
16+
{
17+
public static partial class BasicScenarioTests
18+
{
19+
[Fact]
20+
public static void SyndicationFeed_Rss_DateTimeParser()
21+
{
22+
// *** SETUP *** \\
23+
// *** EXECUTE *** \\
24+
SyndicationFeed feed;
25+
DateTimeOffset dto = new DateTimeOffset(2017, 1, 2, 3, 4, 5, new TimeSpan(0));
26+
using (XmlReader reader = XmlReader.Create(@"RssSpecCustomParser.xml"))
27+
{
28+
var formatter = new Rss20FeedFormatter();
29+
formatter.DateTimeParser = (value, localName, ns) => dto;
30+
formatter.ReadFrom(reader);
31+
feed = formatter.Feed;
32+
}
33+
34+
// *** ASSERT *** \\
35+
Assert.True(feed != null, "res was null.");
36+
Assert.Equal(dto, feed.LastUpdatedTime);
37+
}
38+
39+
[Fact]
40+
public static void SyndicationFeed_Rss_UriParser()
41+
{
42+
// *** SETUP *** \\
43+
// *** EXECUTE *** \\
44+
SyndicationFeed feed;
45+
using (XmlReader reader = XmlReader.Create(@"RssSpecCustomParser.xml"))
46+
{
47+
var formatter = new Rss20FeedFormatter
48+
{
49+
UriParser = (value, kind, localName, ns) => new Uri($"http://value-{value}-kind-{kind}-localName-{localName}-ns-{ns}-end")
50+
};
51+
formatter.ReadFrom(reader);
52+
feed = formatter.Feed;
53+
}
54+
55+
// *** ASSERT *** \\
56+
Assert.True(feed != null, "res was null.");
57+
Assert.Equal(new Uri("http://value-ChannelBase-kind-relativeorabsolute-localName-channel-ns--end"), feed.BaseUri);
58+
Assert.Equal(new Uri("http://value-ImageUrl-kind-relativeorabsolute-localName-url-ns--end"), feed.ImageUrl);
59+
Assert.NotNull(feed.Links);
60+
Assert.Equal(1, feed.Links.Count);
61+
Assert.Equal(new Uri("http://value-FeedLink-kind-relativeorabsolute-localName-link-ns--end"), feed.Links.First().Uri);
62+
63+
Assert.True(feed.Items != null, "res.Items was null.");
64+
Assert.Equal(1, feed.Items.Count());
65+
Assert.Equal(1, feed.Items.First().Links.Count);
66+
Assert.Equal(new Uri("http://value-itemlink-kind-relativeorabsolute-localName-link-ns--end"), feed.Items.First().Links.First().Uri);
67+
}
68+
69+
[Fact]
70+
public static void SyndicationFeed_Atom_DateTimeParser()
71+
{
72+
// *** SETUP *** \\
73+
// *** EXECUTE *** \\
74+
SyndicationFeed feed;
75+
DateTimeOffset dto = new DateTimeOffset(2017, 1, 2, 3, 4, 5, new TimeSpan(0));
76+
using (XmlReader reader = XmlReader.Create(@"SimpleAtomFeedCustomParser.xml"))
77+
{
78+
var formatter = new Atom10FeedFormatter
79+
{
80+
DateTimeParser = (value, localName, ns) => dto
81+
};
82+
formatter.ReadFrom(reader);
83+
feed = formatter.Feed;
84+
}
85+
86+
// *** ASSERT *** \\
87+
Assert.True(feed != null, "res was null.");
88+
Assert.Equal(dto, feed.LastUpdatedTime);
89+
90+
Assert.True(feed.Items != null, "res.Items was null.");
91+
Assert.Equal(1, feed.Items.Count());
92+
Assert.Equal(dto, feed.Items.First().LastUpdatedTime);
93+
}
94+
95+
[Fact]
96+
public static void SyndicationFeed_Atom_UriParser()
97+
{
98+
// *** SETUP *** \\
99+
// *** EXECUTE *** \\
100+
SyndicationFeed feed;
101+
using (XmlReader reader = XmlReader.Create(@"SimpleAtomFeedCustomParser.xml"))
102+
{
103+
var formatter = new Atom10FeedFormatter
104+
{
105+
UriParser = (value, kind, localName, ns) => new Uri($"http://value-{value}-kind-{kind}-localName-{localName}-ns-{ns}-end")
106+
};
107+
formatter.ReadFrom(reader);
108+
feed = formatter.Feed;
109+
}
110+
111+
// *** ASSERT *** \\
112+
Assert.True(feed != null, "res was null.");
113+
Assert.Equal(new Uri("http://value-FeedLogo-kind-relativeorabsolute-localName-logo-ns-http//www.w3.org/2005/Atom-end"), feed.ImageUrl);
114+
115+
Assert.True(feed.Items != null, "res.Items was null.");
116+
Assert.Equal(1, feed.Items.Count());
117+
Assert.NotNull(feed.Items.First().Links);
118+
Assert.Equal(1, feed.Items.First().Links.Count);
119+
Assert.Equal(new Uri("http://value-EntryLinkHref-kind-relativeorabsolute-localName-link-ns-http//www.w3.org/2005/Atom-end"), feed.Items.First().Links.First().Uri);
120+
Assert.Equal(new Uri("http://value-EntryContentSrc-kind-relativeorabsolute-localName-content-ns-http://www.w3.org/2005/Atom-end"), ((UrlSyndicationContent)feed.Items.First().Content).Url);
121+
}
122+
}
123+
}

0 commit comments

Comments
 (0)