Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/project-docs/porting.md10
-rw-r--r--config.json8
-rw-r--r--src/Common/test-runtime/project.json1
-rw-r--r--src/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs1
-rw-r--r--src/System.Diagnostics.TraceSource/src/project.json3
-rw-r--r--src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs71
-rw-r--r--src/System.Runtime.Extensions/System.Runtime.Extensions.sln9
-rw-r--r--src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs21
-rw-r--r--src/System.Runtime.Extensions/src/System/AppDomain.cs16
-rw-r--r--src/System.Runtime.Extensions/src/System/LoaderOptimization.cs18
-rw-r--r--src/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs21
-rw-r--r--src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyAttributes.cs5
-rw-r--r--src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyResolveTests.csproj36
-rw-r--r--src/System.Runtime.Extensions/tests/AssemblyResolveTests/Class1.cs13
-rw-r--r--src/System.Runtime.Extensions/tests/AssemblyResolveTests/project.json13
-rw-r--r--src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj12
-rw-r--r--src/System.Runtime.Extensions/tests/System/AppDomainTests.cs64
-rw-r--r--src/System.Runtime.Extensions/tests/TestApp/TestApp.csproj6
-rw-r--r--src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/AssemblyAttributes.cs5
-rw-r--r--src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/Program.cs26
-rw-r--r--src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/TestAppOutsideOfTPA.csproj42
-rw-r--r--src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/project.json13
-rw-r--r--src/System.Runtime.Serialization.Xml/tests/SerializationTypes.cs118
-rw-r--r--src/System.Runtime.Serialization.Xml/tests/XmlDictionaryReaderTests.cs48
-rw-r--r--src/System.Runtime.Serialization.Xml/tests/XmlDictionaryWriterTest.cs94
-rw-r--r--src/System.Runtime/ref/System.Runtime.cs20
-rw-r--r--src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt10
-rw-r--r--src/System.Runtime/tests/System.Runtime.Tests.csproj1
-rw-r--r--src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs19
-rw-r--r--src/System.Runtime/tests/TimeZoneTests.netstandard1.7.cs132
30 files changed, 826 insertions, 30 deletions
diff --git a/Documentation/project-docs/porting.md b/Documentation/project-docs/porting.md
index 7f83c63b9e..25e51c4e36 100644
--- a/Documentation/project-docs/porting.md
+++ b/Documentation/project-docs/porting.md
@@ -74,11 +74,12 @@ Feature owners reserve the right to call out what they don't want to support on
This list, while not complete, is meant as a reference point. We'll add to it as we refine our porting plan. Also, just because something is currently not implemented, doesn't imply it's intentionally unsupported. Feel free to [file an issue](https://github.com/dotnet/corefx/issues/new) to ask for specific APIs and technologies. Porting requests are generally marked as [port-to-core](https://github.com/dotnet/corefx/issues?q=is%3Aopen+is%3Aissue+label%3Aport-to-core).
+Binary Serialization is supported post 1.1, however we do not support cross-platform binary serialization. For new code you may want to consider other serialization approaches such as data contract serialization, XML serialization, JSON.NET, and protobuf-net.
+
Technology | More information
---------------------------|-----------------------------------
AppDomains | [Details](#app_domains)
Remoting | [Details](#remoting)
-Binary Serialization | [Details](#binary-serialization)
Code Access Security (CAS) | [Details](#code-access-security-cas)
Security Transparency | [Details](#security-transparency)
@@ -94,12 +95,6 @@ Security Transparency | [Details](#security-transparency)
**Replacement**. For communication across processes, inter-process communication (IPC) should be used, such as pipes or memory mapped files. Across machines, you should use a network based solution, preferably a low-overhead plain text protocol such as HTTP.
-### Binary Serialization
-
-**Justification**. After a decade of servicing we've learned that serialization is incredibly complicated and a huge compatibility burden for the types supporting it. Thus, we made the decision that serialization should be a protocol implemented on top of the available public APIs. However, binary serialization requires intimate knowledge of the types as it allows to serialize object graphs including private state.
-
-**Replacement**. Choose the serialization technology that fits your goals for formatting and footprint. Popular choices include data contract serialization, XML serialization, JSON.NET, and protobuf-net.
-
### Code Access Security (CAS)
**Justification**. Sand-boxing, i.e. relying on the runtime or the framework to constrain which resources a managed application can run, is considered a non-goal for .NET Core. We've already state previously that relying on sand-boxing for security reasons isn't an approach we're feeling comfortable with; there are simply too many pieces in object oriented framework that can result in elevation of privileges. Thus we don't treat CAS as security boundary anymore. On top of that, it makes the implementation more complicated and often has performance implications for the happy path.
@@ -111,3 +106,4 @@ Security Transparency | [Details](#security-transparency)
**Justification**. Similar to CAS, this feature allows separating sand-boxed code from security critical code in a declarative fashion. This feature was heavily used by Silverlight.
**Replacement**. Use operating system provided security boundaries, such as user accounts for running processes with the least set of privileges.
+
diff --git a/config.json b/config.json
index fea3dd68cd..30320f4322 100644
--- a/config.json
+++ b/config.json
@@ -42,8 +42,8 @@
"values": ["True", "False"],
"defaultValue": true
},
- "Platform": {
- "description": "Sets the value of the platform.",
+ "TestArchitecture": {
+ "description": "Sets the architecture value that will be used for testing.",
"valueType": "property",
"values": ["AnyCPU", "x86", "arm", "x64", "arm64"],
"defaultValue": "x64"
@@ -306,9 +306,9 @@
}
},
"buildArch": {
- "description": "Passes the value of the build architecture to the respective build-native script.",
+ "description": "Passes the value of the test architecture to the respective build-managed script.",
"settings": {
- "Platform": "default"
+ "TestArchitecture": "default"
}
},
"verbose": {
diff --git a/src/Common/test-runtime/project.json b/src/Common/test-runtime/project.json
index 9a47c9aae2..8ce4d1c084 100644
--- a/src/Common/test-runtime/project.json
+++ b/src/Common/test-runtime/project.json
@@ -67,6 +67,7 @@
"System.Linq.Expressions": "4.4.0-beta-24715-03",
"System.Linq.Parallel": "4.4.0-beta-24715-03",
"System.Linq.Queryable": "4.4.0-beta-24715-03",
+ "System.Memory": "4.4.0-beta-24715-03",
"System.Net.Http": "4.4.0-beta-24715-03",
"System.Net.NameResolution": "4.4.0-beta-24715-03",
"System.Net.NetworkInformation": "4.4.0-beta-24715-03",
diff --git a/src/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs b/src/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs
index 7078c042fa..d53339e217 100644
--- a/src/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs
+++ b/src/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs
@@ -7,7 +7,6 @@ using System.Threading;
using System.Text;
using System.Collections;
using System.Globalization;
-using System.Security.Permissions;
namespace System.Diagnostics
{
diff --git a/src/System.Diagnostics.TraceSource/src/project.json b/src/System.Diagnostics.TraceSource/src/project.json
index 38a0dfac59..41782701e6 100644
--- a/src/System.Diagnostics.TraceSource/src/project.json
+++ b/src/System.Diagnostics.TraceSource/src/project.json
@@ -15,8 +15,7 @@
"System.Runtime.Extensions": "4.4.0-beta-24715-03",
"System.Runtime.InteropServices": "4.4.0-beta-24715-03",
"System.Threading": "4.4.0-beta-24715-03",
- "System.Threading.Tasks": "4.4.0-beta-24715-03",
- "System.Security.Permissions": "4.4.0-beta-24715-03"
+ "System.Threading.Tasks": "4.4.0-beta-24715-03"
}
},
"net463": {
diff --git a/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs b/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
index eb4932c436..9695fd657b 100644
--- a/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
+++ b/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
@@ -2538,6 +2538,77 @@ string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
Assert.Equal(original, converted);
}
+ [Fact]
+ public static void XmlReflectionImporterTest()
+ {
+ string membername = "Action";
+ XmlReflectionImporter importer = new XmlReflectionImporter("http://www.contoso.com/");
+ XmlReflectionMember[] members = new XmlReflectionMember[1];
+ XmlReflectionMember member = members[0] = new XmlReflectionMember();
+ member.MemberType = typeof(AttributedURI);
+ member.MemberName = membername;
+ XmlMembersMapping mappings = importer.ImportMembersMapping("root", "", members, true);
+ Assert.Equal(1, mappings.Count);
+ XmlMemberMapping xmp = mappings[0];
+ Assert.Equal(membername, xmp.ElementName);
+ Assert.False(xmp.CheckSpecified);
+ }
+
+ [Fact]
+ public static void XmlSerializerImplementationTest()
+ {
+ Employee emp = new Employee() { EmployeeName = "Allice" };
+ SerializeIm sm = new SerializeIm();
+ Func<XmlSerializer> serializerfunc = () => sm.GetSerializer(typeof(Employee));
+ string expected = "<?xml version=\"1.0\"?>\r\n<Employee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n <EmployeeName>Allice</EmployeeName>\r\n</Employee>";
+ SerializeAndDeserialize(emp, expected, serializerfunc);
+ }
+
+ [Fact]
+ public static void XmlSerializerVersionAttributeTest()
+ {
+ XmlSerializerVersionAttribute attr = new XmlSerializerVersionAttribute();
+ Assert.Null(attr.Type);
+ XmlSerializerVersionAttribute attr2 = new XmlSerializerVersionAttribute(typeof(Employee));
+ Assert.Equal(typeof(Employee), attr2.Type);
+ }
+
+ [Fact]
+ public static void XmlSerializerAssemblyAttributeTest()
+ {
+ object[] attrs = typeof(AssemblyAttrTestClass).GetCustomAttributes(typeof(XmlSerializerAssemblyAttribute), false);
+ XmlSerializerAssemblyAttribute attr = (XmlSerializerAssemblyAttribute)attrs[0];
+ Assert.NotNull(attr);
+ Assert.Equal("AssemblyAttrTestClass", attr.AssemblyName);
+ }
+
+ [Fact]
+ public static void CodeIdentifierTest()
+ {
+ CodeIdentifiers cds = new CodeIdentifiers(true);
+ cds.AddReserved(typeof(Employee).Name);
+ cds.Add("test", new TestData());
+ cds.AddUnique("test2", new TestData());
+ }
+
+ [Fact]
+ public static void IXmlTextParserTest()
+ {
+ string xmlFileContent = @"<root><date>2003-01-08T15:00:00-00:00</date></root>";
+ Stream sm = GenerateStreamFromString(xmlFileContent);
+ XmlTextReader reader = new XmlTextReader(sm);
+ MyXmlTextParser text = new MyXmlTextParser(reader);
+ }
+
+ private static Stream GenerateStreamFromString(string s)
+ {
+ var stream = new MemoryStream();
+ var writer = new StreamWriter(stream);
+ writer.Write(s);
+ writer.Flush();
+ stream.Position = 0;
+ return stream;
+ }
private static T SerializeAndDeserialize<T>(T value, string baseline, Func<XmlSerializer> serializerFactory = null,
bool skipStringCompare = false, XmlSerializerNamespaces xns = null)
{
diff --git a/src/System.Runtime.Extensions/System.Runtime.Extensions.sln b/src/System.Runtime.Extensions/System.Runtime.Extensions.sln
index 3f0d6b5628..54d55b2bb6 100644
--- a/src/System.Runtime.Extensions/System.Runtime.Extensions.sln
+++ b/src/System.Runtime.Extensions/System.Runtime.Extensions.sln
@@ -19,6 +19,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Runtime.Extensions.P
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoidMainWithExitCodeApp", "tests\VoidMainWithExitCodeApp\VoidMainWithExitCodeApp.csproj", "{9F312D76-9AF1-4E90-B3B0-815A1EC6C346}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "tests\TestApp\TestApp.csproj", "{24BCEC6B-B9D2-47BC-9D66-725BD6B526FA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyResolveTests", "tests\AssemblyResolveTests\AssemblyResolveTests.csproj", "{AD83807C-8BE5-4F27-85DF-9793613233E1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAppOutsideOfTPA", "tests\TestAppOutsideOfTPA\TestAppOutsideOfTPA.csproj", "{C44B33E3-F89F-40B9-B353-D380C1524988}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -139,5 +145,8 @@ Global
{6C314C9B-3D28-4B05-9B4C-B57A00A9B3B9} = {4253F45C-FA2F-4743-9FC8-20666C416A68}
{373D255D-4749-4F26-A24A-A083E77B4471} = {4253F45C-FA2F-4743-9FC8-20666C416A68}
{9F312D76-9AF1-4E90-B3B0-815A1EC6C346} = {4253F45C-FA2F-4743-9FC8-20666C416A68}
+ {24BCEC6B-B9D2-47BC-9D66-725BD6B526FA} = {4253F45C-FA2F-4743-9FC8-20666C416A68}
+ {AD83807C-8BE5-4F27-85DF-9793613233E1} = {4253F45C-FA2F-4743-9FC8-20666C416A68}
+ {C44B33E3-F89F-40B9-B353-D380C1524988} = {4253F45C-FA2F-4743-9FC8-20666C416A68}
EndGlobalSection
EndGlobal
diff --git a/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs b/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs
index 585ec44358..80d4cec662 100644
--- a/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs
+++ b/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs
@@ -30,6 +30,7 @@ namespace System
public event System.EventHandler DomainUnload { add { } remove { } }
public event System.EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs> FirstChanceException { add { } remove { } }
public event System.EventHandler ProcessExit { add { } remove { } }
+ public event ResolveEventHandler ReflectionOnlyAssemblyResolve { add { } remove { } }
public event System.ResolveEventHandler ResourceResolve { add { } remove { } }
public event System.ResolveEventHandler TypeResolve { add { } remove { } }
public string ApplyPolicy(string assemblyName) { throw null; }
@@ -53,6 +54,8 @@ namespace System
public System.Reflection.Assembly Load(string assemblyString) { throw null; }
public System.Reflection.Assembly[] ReflectionOnlyGetAssemblies() { throw null; }
public void SetData(string name, object data) { }
+ [ObsoleteAttribute("AppDomain.SetDynamicBase has been deprecated.")]
+ public void SetDynamicBase(string path) { }
public void SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy policy) { }
public void SetThreadPrincipal(System.Security.Principal.IPrincipal principal) { }
public override string ToString() { throw null; }
@@ -697,6 +700,24 @@ namespace System
User = 1,
Machine = 2,
}
+ public enum LoaderOptimization
+ {
+ [System.ObsoleteAttribute("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ DisallowBindings = 4,
+ [System.ObsoleteAttribute("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ DomainMask = 3,
+ MultiDomain = 2,
+ MultiDomainHost = 3,
+ NotSpecified = 0,
+ SingleDomain = 1,
+ }
+ [System.AttributeUsageAttribute(System.AttributeTargets.Method)]
+ public sealed partial class LoaderOptimizationAttribute : System.Attribute
+ {
+ public LoaderOptimizationAttribute(byte value) { }
+ public LoaderOptimizationAttribute(System.LoaderOptimization value) { }
+ public System.LoaderOptimization Value { get { throw null; } }
+ }
public static partial class Math
{
public static decimal Abs(decimal value) { throw null; }
diff --git a/src/System.Runtime.Extensions/src/System/AppDomain.cs b/src/System.Runtime.Extensions/src/System/AppDomain.cs
index b708aaa82b..f6159cfd01 100644
--- a/src/System.Runtime.Extensions/src/System/AppDomain.cs
+++ b/src/System.Runtime.Extensions/src/System/AppDomain.cs
@@ -10,6 +10,7 @@ using System;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Runtime.Loader;
+using System.IO;
namespace System
{
@@ -38,6 +39,8 @@ namespace System
public string DynamicDirectory => null;
+ public void SetDynamicBase(string path) { }
+
public string FriendlyName
{
get
@@ -95,8 +98,8 @@ namespace System
{
throw new ArgumentNullException(nameof(assemblyFile));
}
-
- Assembly assembly = Assembly.LoadFrom(assemblyFile);
+ string fullPath = Path.GetFullPath(assemblyFile);
+ Assembly assembly = Assembly.LoadFile(fullPath);
return ExecuteAssembly(assembly, args);
}
@@ -260,7 +263,12 @@ namespace System
}
}
- // TODO: #9327
- public event ResolveEventHandler AssemblyResolve;
+ public event ResolveEventHandler AssemblyResolve
+ {
+ add { AssemblyLoadContext.AssemblyResolve += value; }
+ remove { AssemblyLoadContext.AssemblyResolve -= value; }
+ }
+
+ public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
}
}
diff --git a/src/System.Runtime.Extensions/src/System/LoaderOptimization.cs b/src/System.Runtime.Extensions/src/System/LoaderOptimization.cs
new file mode 100644
index 0000000000..9bf2960d87
--- /dev/null
+++ b/src/System.Runtime.Extensions/src/System/LoaderOptimization.cs
@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System
+{
+ public enum LoaderOptimization
+ {
+ [System.ObsoleteAttribute("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ DisallowBindings = 4,
+ [System.ObsoleteAttribute("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ DomainMask = 3,
+ MultiDomain = 2,
+ MultiDomainHost = 3,
+ NotSpecified = 0,
+ SingleDomain = 1,
+ }
+}
diff --git a/src/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs b/src/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs
new file mode 100644
index 0000000000..746616a6d8
--- /dev/null
+++ b/src/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs
@@ -0,0 +1,21 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System
+{
+ [AttributeUsage(AttributeTargets.Method)]
+ public sealed class LoaderOptimizationAttribute : Attribute
+ {
+ private readonly byte _val;
+ public LoaderOptimizationAttribute(byte value)
+ {
+ _val = value;
+ }
+ public LoaderOptimizationAttribute(LoaderOptimization value)
+ {
+ _val = (byte) value;
+ }
+ public LoaderOptimization Value => (LoaderOptimization)_val;
+ }
+}
diff --git a/src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyAttributes.cs b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyAttributes.cs
new file mode 100644
index 0000000000..42582dccfb
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyAttributes.cs
@@ -0,0 +1,5 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
diff --git a/src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyResolveTests.csproj b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyResolveTests.csproj
new file mode 100644
index 0000000000..bdc514e94a
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/AssemblyResolveTests.csproj
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <ProjectGuid>ad83807c-8be5-4f27-85df-9793613233e1</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>AssemblyResolveTests</RootNamespace>
+ <AssemblyName>AssemblyResolveTests</AssemblyName>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <CopyNuGetImplementations>false</CopyNuGetImplementations>
+ <NuGetTargetMoniker Condition="'$(TargetGroup)' == ''">.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46_Debug|AnyCPU'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46_Release|AnyCPU'" />
+ <ItemGroup>
+ <Compile Include="Class1.cs" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(TargetGroup)' != 'net46'">
+ <Compile Include="AssemblyAttributes.cs" />
+ <Compile Include="$(CommonPath)\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs">
+ <Link>Common\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs</Link>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup Condition="'$(TargetGroup)' == 'net46'">
+ <TargetingPackReference Include="System" />
+ <TargetingPackReference Include="System.Core" />
+ <TargetingPackReference Include="System.Runtime" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="project.json" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ </Project>
diff --git a/src/System.Runtime.Extensions/tests/AssemblyResolveTests/Class1.cs b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/Class1.cs
new file mode 100644
index 0000000000..693f4c1e64
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/Class1.cs
@@ -0,0 +1,13 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Reflection;
+using System.Threading;
+namespace AssemblyResolveTests
+{
+ public class Class1
+ {
+ }
+}
diff --git a/src/System.Runtime.Extensions/tests/AssemblyResolveTests/project.json b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/project.json
new file mode 100644
index 0000000000..faf68d6e65
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/AssemblyResolveTests/project.json
@@ -0,0 +1,13 @@
+{
+ "dependencies": {
+ "System.Runtime": "4.4.0-beta-24715-03",
+ "System.Runtime.Extensions": "4.4.0-beta-24715-03",
+ "System.Resources.ResourceManager": "4.4.0-beta-24715-03",
+ "System.Resources.Reader": "4.4.0-beta-24715-03",
+ "System.Reflection": "4.4.0-beta-24715-03",
+ "System.Threading.Thread": "4.4.0-beta-24715-03"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
diff --git a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
index bed2ee2de5..908345997f 100644
--- a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
+++ b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Windows_Debug</Configuration>
@@ -134,6 +134,14 @@
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
<Name>RemoteExecutorConsoleApp</Name>
</ProjectReference>
+ <ProjectReference Include="AssemblyResolveTests\AssemblyResolveTests.csproj">
+ <Project>{ad83807c-8be5-4f27-85df-9793613233e1}</Project>
+ <Name>AssemblyResolveTests</Name>
+ </ProjectReference>
+ <ProjectReference Include="TestAppOutsideOfTPA\TestAppOutsideOfTPA.csproj">
+ <Project>{c44b33e3-f89f-40b9-b353-d380c1524988}</Project>
+ <Name>TestAppOutsideOfTPA</Name>
+ </ProjectReference>
<ProjectReference Include="VoidMainWithExitCodeApp\VoidMainWithExitCodeApp.csproj">
<Project>{9F312D76-9AF1-4E90-B3B0-815A1EC6C346}</Project>
<Name>VoidMainWithExitCodeApp</Name>
@@ -148,4 +156,4 @@
<ProjectReference Include="..\..\System.IO\pkg\System.IO.pkgproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/System.Runtime.Extensions/tests/System/AppDomainTests.cs b/src/System.Runtime.Extensions/tests/System/AppDomainTests.cs
index 82e5d21375..ee382d1e4d 100644
--- a/src/System.Runtime.Extensions/tests/System/AppDomainTests.cs
+++ b/src/System.Runtime.Extensions/tests/System/AppDomainTests.cs
@@ -15,6 +15,27 @@ namespace System.Tests
{
public class AppDomainTests : RemoteExecutorTestBase
{
+ public AppDomainTests()
+ {
+ string sourceTestAssemblyPath = Path.Combine(Environment.CurrentDirectory, "AssemblyResolveTests.dll");
+ string destTestAssemblyPath = Path.Combine(Environment.CurrentDirectory, "AssemblyResolveTests", "AssemblyResolveTests.dll");
+ if (File.Exists(sourceTestAssemblyPath))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(destTestAssemblyPath));
+ File.Copy(sourceTestAssemblyPath, destTestAssemblyPath, true);
+ File.Delete(sourceTestAssemblyPath);
+ }
+
+ sourceTestAssemblyPath = Path.Combine(Environment.CurrentDirectory, "TestAppOutsideOfTPA.exe");
+ destTestAssemblyPath = Path.Combine(Environment.CurrentDirectory, "TestAppOutsideOfTPA", "TestAppOutsideOfTPA.exe");
+ if (File.Exists(sourceTestAssemblyPath))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(destTestAssemblyPath));
+ File.Copy(sourceTestAssemblyPath, destTestAssemblyPath, true);
+ File.Delete(sourceTestAssemblyPath);
+ }
+ }
+
[Fact]
public void CurrentDomain_Not_Null()
{
@@ -221,13 +242,12 @@ namespace System.Tests
[Fact]
public void ExecuteAssembly()
{
- string name = "TestApp.exe";
+ string name = Path.Combine(Environment.CurrentDirectory, "TestAppOutsideOfTPA", "TestAppOutsideOfTPA.exe");
Assert.Throws<ArgumentNullException>("assemblyFile", () => AppDomain.CurrentDomain.ExecuteAssembly(null));
Assert.Throws<FileNotFoundException>(() => AppDomain.CurrentDomain.ExecuteAssembly("NonExistentFile.exe"));
Assert.Throws<PlatformNotSupportedException>(() => AppDomain.CurrentDomain.ExecuteAssembly(name, new string[2] {"2", "3"}, null, Configuration.Assemblies.AssemblyHashAlgorithm.SHA1));
- // TODO: Currently below tests fail as LoadFrom does not work for assemblies in TPA
- // Assert.Equal(5, AppDomain.CurrentDomain.ExecuteAssembly(name));
- // Assert.Equal(10, AppDomain.CurrentDomain.ExecuteAssemblyByName(name, new string[2] { "2", "3" }));
+ Assert.Equal(5, AppDomain.CurrentDomain.ExecuteAssembly(name));
+ Assert.Equal(10, AppDomain.CurrentDomain.ExecuteAssembly(name, new string[2] { "2", "3" }));
}
[Fact]
@@ -430,7 +450,41 @@ namespace System.Tests
[Fact]
public void AssemblyResolve()
{
- // TODO
+ RemoteInvoke(() =>
+ {
+ ResolveEventHandler handler = (sender, e) =>
+ {
+ return Assembly.LoadFile(Path.Combine(Environment.CurrentDirectory, "AssemblyResolveTests", "AssemblyResolveTests.dll"));
+ };
+
+ AppDomain.CurrentDomain.AssemblyResolve += handler;
+
+ Type t = Type.GetType("AssemblyResolveTests.Class1, AssemblyResolveTests", true);
+ Assert.NotNull(t);
+ return SuccessExitCode;
+ }).Dispose();
+ }
+
+ [Fact]
+ public void AssemblyResolve_RequestingAssembly()
+ {
+ RemoteInvoke(() =>
+ {
+ Assembly a = Assembly.LoadFile(Path.Combine(Environment.CurrentDirectory, "TestAppOutsideOfTPA", "TestAppOutsideOfTPA.exe"));
+
+ ResolveEventHandler handler = (sender, e) =>
+ {
+ Assert.Equal(e.RequestingAssembly, a);
+ return Assembly.LoadFile(Path.Combine(Environment.CurrentDirectory, "AssemblyResolveTests", "AssemblyResolveTests.dll"));
+ };
+
+ AppDomain.CurrentDomain.AssemblyResolve += handler;
+ Type ptype = a.GetType("Program");
+ MethodInfo myMethodInfo = ptype.GetMethod("foo");
+ object ret = myMethodInfo.Invoke(null, null);
+ Assert.NotNull(ret);
+ return SuccessExitCode;
+ }).Dispose();
}
[Fact]
diff --git a/src/System.Runtime.Extensions/tests/TestApp/TestApp.csproj b/src/System.Runtime.Extensions/tests/TestApp/TestApp.csproj
index c5d2f5255f..4ddc17ac0f 100644
--- a/src/System.Runtime.Extensions/tests/TestApp/TestApp.csproj
+++ b/src/System.Runtime.Extensions/tests/TestApp/TestApp.csproj
@@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
- <ProjectGuid>{9F312D76-9AF1-4E90-B3B0-815A1EC6C346}</ProjectGuid>
+ <ProjectGuid>{24BCEC6B-B9D2-47BC-9D66-725BD6B526FA}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>TestApp</RootNamespace>
<AssemblyName>TestApp</AssemblyName>
@@ -19,7 +19,7 @@
<Compile Include="TestApp.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'net46'">
- <Compile Include="AssemblyAttributes.cs"/>
+ <Compile Include="AssemblyAttributes.cs" />
<Compile Include="$(CommonPath)\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs">
<Link>Common\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs</Link>
</Compile>
@@ -33,4 +33,4 @@
<None Include="project.json" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/AssemblyAttributes.cs b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/AssemblyAttributes.cs
new file mode 100644
index 0000000000..42582dccfb
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/AssemblyAttributes.cs
@@ -0,0 +1,5 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
diff --git a/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/Program.cs b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/Program.cs
new file mode 100644
index 0000000000..da7d1f524b
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/Program.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Reflection;
+using System.Threading;
+
+internal static class Program
+{
+ public static int Main(String[] args)
+ {
+ int sum = 5;
+ for (int i = 0; args != null && i < args.Length; i++)
+ {
+ sum += Int32.Parse(args[i]);
+ }
+ return sum;
+ }
+
+ public static object foo()
+ {
+ AssemblyResolveTests.Class1 c = new AssemblyResolveTests.Class1();
+ return c;
+ }
+}
diff --git a/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/TestAppOutsideOfTPA.csproj b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/TestAppOutsideOfTPA.csproj
new file mode 100644
index 0000000000..081d344bbf
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/TestAppOutsideOfTPA.csproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <ProjectGuid>{C44B33E3-F89F-40B9-B353-D380C1524988}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>TestAppOutsideOfTPA</RootNamespace>
+ <AssemblyName>TestAppOutsideOfTPA</AssemblyName>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <CopyNuGetImplementations>false</CopyNuGetImplementations>
+ <NuGetTargetMoniker Condition="'$(TargetGroup)' == ''">.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46_Debug|AnyCPU'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46_Release|AnyCPU'" />
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(TargetGroup)' != 'net46'">
+ <Compile Include="AssemblyAttributes.cs" />
+ <Compile Include="$(CommonPath)\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs">
+ <Link>Common\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs</Link>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup Condition="'$(TargetGroup)' == 'net46'">
+ <TargetingPackReference Include="System" />
+ <TargetingPackReference Include="System.Core" />
+ <TargetingPackReference Include="System.Runtime" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\AssemblyResolveTests\AssemblyResolveTests.csproj">
+ <Project>{ad83807c-8be5-4f27-85df-9793613233e1}</Project>
+ <Name>AssemblyResolveTests</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project> \ No newline at end of file
diff --git a/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/project.json b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/project.json
new file mode 100644
index 0000000000..faf68d6e65
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/TestAppOutsideOfTPA/project.json
@@ -0,0 +1,13 @@
+{
+ "dependencies": {
+ "System.Runtime": "4.4.0-beta-24715-03",
+ "System.Runtime.Extensions": "4.4.0-beta-24715-03",
+ "System.Resources.ResourceManager": "4.4.0-beta-24715-03",
+ "System.Resources.Reader": "4.4.0-beta-24715-03",
+ "System.Reflection": "4.4.0-beta-24715-03",
+ "System.Threading.Thread": "4.4.0-beta-24715-03"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
diff --git a/src/System.Runtime.Serialization.Xml/tests/SerializationTypes.cs b/src/System.Runtime.Serialization.Xml/tests/SerializationTypes.cs
index 536324fc30..9505f55f04 100644
--- a/src/System.Runtime.Serialization.Xml/tests/SerializationTypes.cs
+++ b/src/System.Runtime.Serialization.Xml/tests/SerializationTypes.cs
@@ -3997,3 +3997,121 @@ public class TypeWithSerializableEnum
{
public SerializableEnumWithNonSerializedValue EnumField;
}
+
+[DataContract]
+public class Poseesions
+{
+ [DataMember]
+ public string ItemName;
+}
+
+public static class ReaderWriterConstants
+{
+ public const string ReaderWriterType = "ReaderWriterType";
+ public const string Encoding = "Encoding";
+ public const string TransferMode = "TransferMode";
+ public const string ReaderMode = "ReaderMode";
+ public const string ReaderMode_Streamed = "Streamed";
+ public const string ReaderMode_Buffered = "Buffered";
+
+ public const string RootElementName = "Root";
+ public const string XmlNamespace = "http://www.w3.org/XML/1998/namespace";
+}
+
+public static class FragmentHelper
+{
+ public static bool CanFragment(XmlDictionaryWriter writer)
+ {
+ IFragmentCapableXmlDictionaryWriter fragmentWriter = writer as IFragmentCapableXmlDictionaryWriter;
+ return fragmentWriter != null && fragmentWriter.CanFragment;
+ }
+
+ public static void Start(XmlDictionaryWriter writer, Stream stream)
+ {
+ Start(writer, stream, false);
+ }
+
+ public static void Start(XmlDictionaryWriter writer, Stream stream, bool generateSelfContainedText)
+ {
+ EnsureWriterCanFragment(writer);
+ ((IFragmentCapableXmlDictionaryWriter)writer).StartFragment(stream, generateSelfContainedText);
+ }
+
+ public static void End(XmlDictionaryWriter writer)
+ {
+ EnsureWriterCanFragment(writer);
+ ((IFragmentCapableXmlDictionaryWriter)writer).EndFragment();
+ }
+
+ public static void Write(XmlDictionaryWriter writer, byte[] buffer, int offset, int count)
+ {
+ EnsureWriterCanFragment(writer);
+ ((IFragmentCapableXmlDictionaryWriter)writer).WriteFragment(buffer, offset, count);
+ }
+
+ static void EnsureWriterCanFragment(XmlDictionaryWriter writer)
+ {
+ if (!CanFragment(writer))
+ {
+ throw new InvalidOperationException("Fragment cannot be done using writer " + writer.GetType());
+ }
+ }
+}
+
+[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://schemas.xmlsoap.org/ws/2003/03/addressing")]
+[System.Xml.Serialization.XmlRootAttribute("Action", Namespace = "http://schemas.xmlsoap.org/ws/2003/03/addressing", IsNullable = false)]
+public class AttributedURI
+{
+ [XmlText]
+ public string Value;
+
+ public bool[] BooleanValues = new bool[] { false, true, false, true, true };
+}
+
+public class SerializeIm : XmlSerializerImplementation
+{
+ public override XmlSerializer GetSerializer(Type type)
+ {
+ return new XmlSerializer(type);
+ }
+}
+
+[XmlSerializerAssembly(AssemblyName = "AssemblyAttrTestClass")]
+public class AssemblyAttrTestClass
+{
+ public string TestString { get; set; }
+}
+
+public class MyXmlTextParser : IXmlTextParser
+{
+ private XmlTextReader _myreader;
+ public MyXmlTextParser(XmlTextReader reader)
+ {
+ _myreader = reader;
+ }
+ bool IXmlTextParser.Normalized
+ {
+ get
+ {
+ return _myreader.Normalization;
+ }
+
+ set
+ {
+ _myreader.Normalization = value;
+ }
+ }
+
+ WhitespaceHandling IXmlTextParser.WhitespaceHandling
+ {
+ get
+ {
+ return _myreader.WhitespaceHandling;
+ }
+
+ set
+ {
+ _myreader.WhitespaceHandling = value;
+ }
+ }
+}
diff --git a/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryReaderTests.cs b/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryReaderTests.cs
index 6f3f3b778f..e0074dd667 100644
--- a/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryReaderTests.cs
+++ b/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryReaderTests.cs
@@ -101,6 +101,54 @@ namespace System.Runtime.Serialization.Xml.Tests
Assert.Equal(new DateTime(2003, 1, 8, 15, 0, 0), dt);
}
+ [Fact]
+ public static void GetNonAtomizedNamesTest()
+ {
+ string localNameTest = "localNameTest";
+ string namespaceUriTest = "http://www.msn.com/";
+ var encoding = Encoding.UTF8;
+ var rndGen = new Random();
+ int byteArrayLength = rndGen.Next(100, 2000);
+ byte[] byteArray = new byte[byteArrayLength];
+ rndGen.NextBytes(byteArray);
+ MemoryStream ms = new MemoryStream();
+ XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(ms, encoding);
+ writer.WriteElementString(localNameTest, namespaceUriTest, "value");
+ writer.Flush();
+ ms.Position = 0;
+ XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(ms, encoding, XmlDictionaryReaderQuotas.Max, null);
+ bool success = reader.ReadToDescendant(localNameTest);
+ Assert.True(success);
+ string localName;
+ string namespaceUriStr;
+ reader.GetNonAtomizedNames(out localName, out namespaceUriStr);
+ Assert.Equal(localNameTest, localName);
+ Assert.Equal(namespaceUriTest, namespaceUriStr);
+ writer.Close();
+ }
+
+ [Fact]
+ public static void ReadStringTest()
+ {
+ MemoryStream stream = new MemoryStream();
+ XmlDictionary dictionary = new XmlDictionary();
+ List<XmlDictionaryString> stringList = new List<XmlDictionaryString>();
+ stringList.Add(dictionary.Add("Name"));
+ stringList.Add(dictionary.Add("urn:Test"));
+
+ using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(stream, dictionary, null))
+ {
+ // write using the dictionary - element name, namespace, value
+ string value = "value";
+ writer.WriteElementString(stringList[0], stringList[1], value);
+ writer.Flush();
+ stream.Position = 0;
+ XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(stream, dictionary, new XmlDictionaryReaderQuotas());
+ reader.Read();
+ string s = reader.ReadString();
+ Assert.Equal(value, s);
+ }
+ }
private static Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
diff --git a/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryWriterTest.cs b/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryWriterTest.cs
index 54a0a45318..9539077991 100644
--- a/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryWriterTest.cs
+++ b/src/System.Runtime.Serialization.Xml/tests/XmlDictionaryWriterTest.cs
@@ -300,6 +300,34 @@ public static class XmlDictionaryWriterTest
textReader.Close();
}
+ [ActiveIssue(13375)]
+ [Fact]
+ public static void FragmentTest()
+ {
+ string rwTypeStr = "Text";
+ ReaderWriterFactory.ReaderWriterType rwType = (ReaderWriterFactory.ReaderWriterType)
+ Enum.Parse(typeof(ReaderWriterFactory.ReaderWriterType), rwTypeStr, true);
+ Encoding encoding = Encoding.GetEncoding("utf-8");
+ int numberOfNestedFragments = 1;
+ MemoryStream ms1 = new MemoryStream();
+ MemoryStream ms2 = new MemoryStream();
+ XmlDictionaryWriter writer1 = (XmlDictionaryWriter)ReaderWriterFactory.CreateXmlWriter(rwType, ms1, encoding);
+ XmlDictionaryWriter writer2 = (XmlDictionaryWriter)ReaderWriterFactory.CreateXmlWriter(rwType, ms2, encoding);
+ Assert.True(FragmentHelper.CanFragment(writer1));
+ Assert.True(FragmentHelper.CanFragment(writer2));
+ writer1.WriteStartDocument(); writer2.WriteStartDocument();
+ writer1.WriteStartElement(ReaderWriterConstants.RootElementName); writer2.WriteStartElement(ReaderWriterConstants.RootElementName);
+ SimulateWriteFragment(writer1, true, numberOfNestedFragments);
+ SimulateWriteFragment(writer2, false, numberOfNestedFragments);
+ writer1.WriteEndElement(); writer2.WriteEndElement();
+ writer1.WriteEndDocument(); writer2.WriteEndDocument();
+ writer1.Flush();
+ writer2.Flush();
+
+ byte[] doc1 = ms1.ToArray();
+ byte[] doc2 = ms2.ToArray();
+ CompareArrays(doc1, 0, doc2, 0, doc1.Length);
+ }
private static bool ReadTest(MemoryStream ms, Encoding encoding, ReaderWriterFactory.ReaderWriterType rwType, byte[] byteArray)
{
ms.Position = 0;
@@ -433,6 +461,72 @@ public static class XmlDictionaryWriterTest
}
+ private static void CompareArrays(byte[] array1, int offset1, byte[] array2, int offset2, int count)
+ {
+ for (int i = 0; i < count; i++)
+ {
+ Assert.Equal(array1[i + offset1], array2[i + offset2]);
+ }
+ }
+
+ private static void SimulateWriteFragment(XmlDictionaryWriter writer, bool useFragmentAPI, int nestedLevelsLeft)
+ {
+ if (nestedLevelsLeft <= 0)
+ {
+ return;
+ }
+
+ Random rndGen = new Random(nestedLevelsLeft);
+ int signatureLen = rndGen.Next(100, 200);
+ byte[] signature = new byte[signatureLen];
+ rndGen.NextBytes(signature);
+
+ MemoryStream fragmentStream = new MemoryStream();
+
+ if (!useFragmentAPI) // simulating in the writer itself
+ {
+ writer.WriteStartElement("SignatureValue_" + nestedLevelsLeft);
+ writer.WriteBase64(signature, 0, signatureLen);
+ writer.WriteEndElement();
+ }
+
+ if (useFragmentAPI)
+ {
+ FragmentHelper.Start(writer, fragmentStream);
+ }
+
+ writer.WriteStartElement("Fragment" + nestedLevelsLeft);
+ for (int i = 0; i < 5; i++)
+ {
+ writer.WriteStartElement(String.Format("Element{0}_{1}", nestedLevelsLeft, i));
+ writer.WriteAttributeString("attr1", "value1");
+ writer.WriteAttributeString("attr2", "value2");
+ }
+ writer.WriteString("This is a text with unicode characters: <>&;\u0301\u2234");
+ for (int i = 0; i < 5; i++)
+ {
+ writer.WriteEndElement();
+ }
+
+ // write other nested fragments...
+ SimulateWriteFragment(writer, useFragmentAPI, nestedLevelsLeft - 1);
+
+ writer.WriteEndElement(); // Fragment{nestedLevelsLeft}
+ writer.Flush();
+
+ if (useFragmentAPI)
+ {
+ FragmentHelper.End(writer);
+ writer.WriteStartElement("SignatureValue_" + nestedLevelsLeft);
+ writer.WriteBase64(signature, 0, signatureLen);
+ writer.WriteEndElement();
+
+ FragmentHelper.Write(writer, fragmentStream.GetBuffer(), 0, (int)fragmentStream.Length);
+
+ writer.Flush();
+ }
+ }
+
public class AsyncMemoryStream : MemoryStream
{
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
diff --git a/src/System.Runtime/ref/System.Runtime.cs b/src/System.Runtime/ref/System.Runtime.cs
index fb9da8ed8c..37512ee7f5 100644
--- a/src/System.Runtime/ref/System.Runtime.cs
+++ b/src/System.Runtime/ref/System.Runtime.cs
@@ -2212,6 +2212,21 @@ namespace System
public static bool TryParseExact(string input, string[] formats, System.IFormatProvider formatProvider, System.Globalization.TimeSpanStyles styles, out System.TimeSpan result) { throw null; }
public static bool TryParseExact(string input, string[] formats, System.IFormatProvider formatProvider, out System.TimeSpan result) { throw null; }
}
+
+ public abstract partial class TimeZone
+ {
+ protected TimeZone() { }
+ public static System.TimeZone CurrentTimeZone { get { throw null; } }
+ public abstract string DaylightName { get; }
+ public abstract string StandardName { get; }
+ public abstract System.Globalization.DaylightTime GetDaylightChanges(int year);
+ public abstract System.TimeSpan GetUtcOffset(System.DateTime time);
+ public virtual bool IsDaylightSavingTime(System.DateTime time) { throw null; }
+ public static bool IsDaylightSavingTime(System.DateTime time, System.Globalization.DaylightTime daylightTimes) { throw null; }
+ public virtual System.DateTime ToLocalTime(System.DateTime time) { throw null; }
+ public virtual System.DateTime ToUniversalTime(System.DateTime time) { throw null; }
+ }
+
public sealed partial class TimeZoneInfo : System.IEquatable<System.TimeZoneInfo>, System.Runtime.Serialization.ISerializable, System.Runtime.Serialization.IDeserializationCallback
{
internal TimeZoneInfo() { }
@@ -2227,6 +2242,9 @@ namespace System
public static System.DateTime ConvertTime(System.DateTime dateTime, System.TimeZoneInfo destinationTimeZone) { throw null; }
public static System.DateTime ConvertTime(System.DateTime dateTime, System.TimeZoneInfo sourceTimeZone, System.TimeZoneInfo destinationTimeZone) { throw null; }
public static System.DateTimeOffset ConvertTime(System.DateTimeOffset dateTimeOffset, System.TimeZoneInfo destinationTimeZone) { throw null; }
+ public static System.DateTime ConvertTimeBySystemTimeZoneId(System.DateTime dateTime, string destinationTimeZoneId) { throw null; }
+ public static System.DateTime ConvertTimeBySystemTimeZoneId(System.DateTime dateTime, string sourceTimeZoneId, string destinationTimeZoneId) { throw null; }
+ public static System.DateTimeOffset ConvertTimeBySystemTimeZoneId(System.DateTimeOffset dateTimeOffset, string destinationTimeZoneId) { throw null; }
public static System.DateTime ConvertTimeFromUtc(System.DateTime dateTime, System.TimeZoneInfo destinationTimeZone) { throw null; }
public static System.DateTime ConvertTimeToUtc(System.DateTime dateTime) { throw null; }
public static System.DateTime ConvertTimeToUtc(System.DateTime dateTime, System.TimeZoneInfo sourceTimeZone) { throw null; }
@@ -6115,7 +6133,7 @@ namespace System.Runtime.ExceptionServices
{
public HandleProcessCorruptedStateExceptionsAttribute() { }
}
- public sealed partial class FirstChanceExceptionEventArgs : EventArgs
+ public partial class FirstChanceExceptionEventArgs : EventArgs
{
public FirstChanceExceptionEventArgs(Exception exception) { }
public Exception Exception { get { throw null; } }
diff --git a/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt b/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt
index 23d04448d8..d713a9818c 100644
--- a/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt
+++ b/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt
@@ -316,6 +316,9 @@ MembersMustExist : Member 'System.TimeZoneInfo.FromSerializedString(System.Strin
MembersMustExist : Member 'System.TimeZoneInfo.GetAdjustmentRules()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.TimeZoneInfo.HasSameRules(System.TimeZoneInfo)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.TimeZoneInfo.ToSerializedString()' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.TimeZoneInfo.ConvertTimeBySystemTimeZoneId(System.DateTime, System.String)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.TimeZoneInfo.ConvertTimeBySystemTimeZoneId(System.DateTime, System.String, System.String)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.TimeZoneInfo.ConvertTimeBySystemTimeZoneId(System.DateTimeOffset, System.String)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.TimeZoneInfo.AdjustmentRule' does not implement interface 'System.Runtime.Serialization.IDeserializationCallback' in the implementation but it does in the contract.
MembersMustExist : Member 'System.TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(System.DateTime, System.DateTime, System.TimeSpan, System.TimeZoneInfo.TransitionTime, System.TimeZoneInfo.TransitionTime)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.TimeZoneInfo.AdjustmentRule.DateEnd.get()' does not exist in the implementation but it does exist in the contract.
@@ -641,4 +644,9 @@ MembersMustExist : Member 'System.Threading.Tasks.Task.Dispose(System.Boolean)'
CannotRemoveBaseTypeOrInterface : Type 'System.Threading.Tasks.Task<TResult>' does not implement interface 'System.IDisposable' in the implementation but it does in the contract.
MembersMustExist : Member 'System.GC.GetAllocatedBytesForCurrentThread()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(System.Type)' does not exist in the implementation but it does exist in the contract.
-Total Issues: 642
+TypesMustExist : Type 'System.TimeZone' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.TimeZone.CurrentTimeZone.get()' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.TimeZone.ToLocalTime(System.DateTime)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.TimeZone.CurrentTimeZone.get()' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.TimeZone.ToLocalTime(System.DateTime)' does not exist in the implementation but it does exist in the contract.
+Total Issues: 650
diff --git a/src/System.Runtime/tests/System.Runtime.Tests.csproj b/src/System.Runtime/tests/System.Runtime.Tests.csproj
index 060aa0a5db..5ecfe905fe 100644
--- a/src/System.Runtime/tests/System.Runtime.Tests.csproj
+++ b/src/System.Runtime/tests/System.Runtime.Tests.csproj
@@ -148,6 +148,7 @@
<Compile Include="System\StringTests.netstandard1.7.cs" />
<Compile Include="System\TimeSpanTests.netstandard1.7.cs" />
<Compile Include="System\TypeUnloadedExceptionTests.cs" />
+ <Compile Include="TimeZoneTests.netstandard1.7.cs" />
<Compile Include="TimeZoneInfoTests.netstandard1.7.cs" />
<Compile Include="TimeZoneNotFoundExceptionTests.netstandard1.7.cs" />
<Compile Include="VersionTests.netstandard1.7.cs" />
diff --git a/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs b/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs
index 2692501dac..de277116ad 100644
--- a/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs
+++ b/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs
@@ -240,6 +240,25 @@ namespace System.Tests
Assert.True(utc.HasSameRules(custom));
}
+ [Fact]
+ public static void ConvertTimeBySystemTimeZoneIdTests()
+ {
+ DateTime now = DateTime.Now;
+ DateTime utcNow = TimeZoneInfo.ConvertTimeToUtc(now);
+
+ Assert.Equal(now, TimeZoneInfo.ConvertTimeBySystemTimeZoneId(utcNow, TimeZoneInfo.Local.Id));
+ Assert.Equal(utcNow, TimeZoneInfo.ConvertTimeBySystemTimeZoneId(now, TimeZoneInfo.Utc.Id));
+
+ Assert.Equal(now, TimeZoneInfo.ConvertTimeBySystemTimeZoneId(utcNow, TimeZoneInfo.Utc.Id, TimeZoneInfo.Local.Id));
+ Assert.Equal(utcNow, TimeZoneInfo.ConvertTimeBySystemTimeZoneId(now, TimeZoneInfo.Local.Id, TimeZoneInfo.Utc.Id));
+
+ DateTimeOffset offsetNow = new DateTimeOffset(now);
+ DateTimeOffset utcOffsetNow = new DateTimeOffset(utcNow);
+
+ Assert.Equal(offsetNow, TimeZoneInfo.ConvertTimeBySystemTimeZoneId(utcOffsetNow, TimeZoneInfo.Local.Id));
+ Assert.Equal(utcOffsetNow, TimeZoneInfo.ConvertTimeBySystemTimeZoneId(offsetNow, TimeZoneInfo.Utc.Id));
+ }
+
private static TimeZoneInfo CreateCustomLondonTimeZone()
{
TimeZoneInfo.TransitionTime start = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 1, 0, 0), 3, 5, DayOfWeek.Sunday);
diff --git a/src/System.Runtime/tests/TimeZoneTests.netstandard1.7.cs b/src/System.Runtime/tests/TimeZoneTests.netstandard1.7.cs
new file mode 100644
index 0000000000..2365b0ebfb
--- /dev/null
+++ b/src/System.Runtime/tests/TimeZoneTests.netstandard1.7.cs
@@ -0,0 +1,132 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using Xunit;
+
+namespace System.Tests
+{
+ public static partial class TimeZoneTests
+ {
+ [Fact]
+ public static void TestBasicTimeZoneProperties()
+ {
+ var currentZone = TimeZone.CurrentTimeZone;
+ Assert.Equal(TimeZoneInfo.Local.StandardName, currentZone.StandardName);
+ Assert.Equal(TimeZoneInfo.Local.DaylightName, currentZone.DaylightName);
+
+ int year = DateTime.Today.Year;
+
+ DaylightTime dt = currentZone.GetDaylightChanges(year);
+
+ TimeZoneInfo.AdjustmentRule currentRule = null;
+ if (TimeZoneInfo.Local.SupportsDaylightSavingTime)
+ {
+ foreach (var rule in TimeZoneInfo.Local.GetAdjustmentRules())
+ {
+ if (rule.DateStart.Year <= year && rule.DateEnd.Year >= year && rule.DaylightDelta != TimeSpan.Zero)
+ {
+ currentRule = rule;
+ break;
+ }
+ }
+ }
+
+ if (currentRule != null)
+ {
+ DateTime startTransition = TransitionTimeToDateTime(year, currentRule.DaylightTransitionStart);
+ DateTime endTransition = TransitionTimeToDateTime(year, currentRule.DaylightTransitionEnd);
+
+ Assert.Equal(startTransition, dt.Start);
+ Assert.Equal(endTransition, dt.End);
+ Assert.Equal(currentRule.DaylightDelta, dt.Delta);
+ }
+ else
+ {
+ Assert.Equal(DateTime.MinValue, dt.Start);
+ Assert.Equal(DateTime.MinValue, dt.End);
+ Assert.Equal(TimeSpan.Zero, dt.Delta);
+ }
+ }
+
+ [Fact]
+ public static void TestOffsetsAndDaylight()
+ {
+ var currentZone = TimeZone.CurrentTimeZone;
+ DateTime now = DateTime.Now;
+
+ Assert.Equal(TimeZoneInfo.Local.GetUtcOffset(now), currentZone.GetUtcOffset(now));
+ Assert.Equal(TimeZoneInfo.Local.IsDaylightSavingTime(now), currentZone.IsDaylightSavingTime(now));
+ Assert.Equal(TimeZoneInfo.Local.IsDaylightSavingTime(now), TimeZone.IsDaylightSavingTime(now, currentZone.GetDaylightChanges(now.Year)));
+ }
+
+ [Fact]
+ public static void TestRoundTripping()
+ {
+ var currentZone = TimeZone.CurrentTimeZone;
+ DateTime now = DateTime.Now;
+
+ if (!TimeZoneInfo.Local.IsAmbiguousTime(now))
+ {
+ var utcTime = currentZone.ToUniversalTime(now);
+ var localTime = currentZone.ToLocalTime(utcTime);
+ Assert.Equal(now, localTime);
+ }
+ }
+
+ private static DateTime TransitionTimeToDateTime(Int32 year, TimeZoneInfo.TransitionTime transitionTime)
+ {
+ DateTime value;
+ DateTime timeOfDay = transitionTime.TimeOfDay;
+
+ if (transitionTime.IsFixedDateRule)
+ {
+ Int32 day = DateTime.DaysInMonth(year, transitionTime.Month);
+ value = new DateTime(year, transitionTime.Month, (day < transitionTime.Day) ? day : transitionTime.Day,
+ timeOfDay.Hour, timeOfDay.Minute, timeOfDay.Second, timeOfDay.Millisecond);
+ }
+ else
+ {
+ if (transitionTime.Week <= 4)
+ {
+ value = new DateTime(year, transitionTime.Month, 1, timeOfDay.Hour, timeOfDay.Minute, timeOfDay.Second, timeOfDay.Millisecond);
+
+ int dayOfWeek = (int)value.DayOfWeek;
+ int delta = (int)transitionTime.DayOfWeek - dayOfWeek;
+ if (delta < 0)
+ {
+ delta += 7;
+ }
+ delta += 7 * (transitionTime.Week - 1);
+
+ if (delta > 0)
+ {
+ value = value.AddDays(delta);
+ }
+ }
+ else
+ {
+ Int32 daysInMonth = DateTime.DaysInMonth(year, transitionTime.Month);
+ value = new DateTime(year, transitionTime.Month, daysInMonth, timeOfDay.Hour, timeOfDay.Minute, timeOfDay.Second, timeOfDay.Millisecond);
+
+ int dayOfWeek = (int) value.DayOfWeek;
+ int delta = dayOfWeek - (int)transitionTime.DayOfWeek;
+ if (delta < 0)
+ {
+ delta += 7;
+ }
+
+ if (delta > 0) {
+ value = value.AddDays(-delta);
+ }
+ }
+ }
+ return value;
+ }
+ }
+} \ No newline at end of file