From ef4a4094bda37fffd364fa54aee99180aa99101b Mon Sep 17 00:00:00 2001 From: Alex Perovich Date: Wed, 12 Oct 2016 17:28:39 -0700 Subject: [PATCH] Bring S.Resources.ResourceManager up to ns20 (dotnet/corefx#12468) * Bring S.Resources.ResourceManager up to ns20 Fixes dotnet/corefx#11769 * Remove unneeded references * Fix naming,formatting and remove binary formatter * Move UMS up to S.Runtime.InteropServices * Update Dependencies * Update Dependencies Again * Add ToDo comments * Fix type * Remove protected fields no longer in netstandard * Move UMA down * Fix build break * Add ActiveIssue to failing tests * Replace dummy implementations in S.CM.TypeConverter * Uncomment type converter stuff * Reference new ResourceManager in TypeConverter tests Commit migrated from https://github.com/dotnet/corefx/commit/90e2de3727ee429a54055d7e88a78cc8ec1282f4 --- ...System.ComponentModel.TypeConverter.csproj | 4 + .../ref/System.ComponentModel.cs | 20 +- ...System.ComponentModel.TypeConverter.csproj | 5 + .../ComponentResourceManager.cs | 5 +- .../src/System/misc.cs | 39 -- ....ComponentModel.TypeConverter.Tests.csproj | 6 +- .../ref/System.IO.FileSystem.Primitives.cs | 8 +- .../System.IO.FileSystem.Primitives.csproj | 4 + .../ref/project.json | 2 +- ...stem.IO.FileSystem.Primitives.Tests.csproj | 4 +- .../ref/System.IO.UnmanagedMemoryStream.cs | 92 +--- .../System.IO.UnmanagedMemoryStream.csproj | 4 + .../ref/project.json | 7 +- ...stem.IO.UnmanagedMemoryStream.Tests.csproj | 9 +- .../System.Resources.Reader/dir.props | 2 +- .../pkg/System.Resources.Reader.pkgproj | 4 +- .../ref/System.Resources.Reader.cs | 12 +- .../ref/System.Resources.Reader.csproj | 8 +- .../System.Resources.Reader/ref/project.json | 10 +- .../src/System.Resources.Reader.csproj | 9 +- .../src/System/Resources/ResourceReader.cs | 435 ---------------- .../src/System/Resources/StreamExtensions.cs | 118 ----- .../System.Resources.Reader/src/project.json | 14 +- .../tests/ResourceReaderUnitTest.cs | 21 +- .../System.Resources.Reader.Tests.builds | 6 +- .../System.Resources.Reader.Tests.csproj | 8 +- .../tests/project.json | 4 +- .../System.Resources.ResourceManager.sln | 28 +- .../dir.props | 2 +- .../System.Resources.ResourceManager.pkgproj | 12 +- .../ref/System.Resources.ResourceManager.cs | 84 +++- .../System.Resources.ResourceManager.csproj | 9 +- .../ref/project.json | 13 +- .../src/ApiCompatBaseline.uap101aot.txt | 35 ++ .../System.Resources.ResourceManager.builds | 3 + .../System.Resources.ResourceManager.csproj | 20 +- .../src/project.json | 12 +- .../MissingManifestResourceExceptionTests.cs | 2 +- ...estResourceExceptionTests.netstandard17.cs | 20 + .../MissingSatelliteAssemblyException.cs | 56 +++ .../tests/ResourceManagerTests.cs | 2 +- .../ResourceManagerTests.netstandard17.cs | 118 +++++ .../tests/ResourceSetTests.cs | 121 +++++ .../TestResx.netstandard17.Designer.cs | 102 ++++ .../Resources/TestResx.netstandard17.resx} | 61 +-- ...tem.Resources.ResourceManager.Tests.builds | 6 +- ...tem.Resources.ResourceManager.Tests.csproj | 31 +- .../tests/project.json | 8 +- .../System.Resources.Writer/dir.props | 4 +- .../pkg/System.Resources.Writer.pkgproj | 4 +- .../ref/System.Resources.Writer.cs | 18 +- .../ref/System.Resources.Writer.csproj | 4 +- .../System.Resources.Writer/ref/project.json | 10 +- .../src/Resources/Strings.resx | 9 + .../src/System.Resources.Writer.csproj | 9 +- .../src/System/Resources/IResourceWriter.cs | 15 + .../src/System/Resources/ResourceWriter.cs | 473 ++++++++++++++++-- .../Resources/__FastResourceComparer.cs | 14 +- .../Versioning/MultitargetingHelpers.cs | 60 +++ .../System.Resources.Writer/src/project.json | 29 +- .../tests/ResourceWriterUnitTest.cs | 9 +- .../System.Resources.Writer.Tests.builds | 6 +- .../System.Resources.Writer.Tests.csproj | 7 +- .../tests/project.json | 3 +- .../ref/System.Runtime.InteropServices.cs | 89 ++++ .../ref/project.json | 2 +- .../src/System.Runtime.WindowsRuntime.csproj | 2 +- .../System.Runtime/ref/System.Runtime.cs | 7 + .../src/ApiCompatBaseline.uap101aot.txt | 1 + .../packageIndex.json | 6 +- 70 files changed, 1417 insertions(+), 969 deletions(-) delete mode 100644 src/libraries/System.Resources.Reader/src/System/Resources/ResourceReader.cs delete mode 100644 src/libraries/System.Resources.Reader/src/System/Resources/StreamExtensions.cs create mode 100644 src/libraries/System.Resources.ResourceManager/src/ApiCompatBaseline.uap101aot.txt create mode 100644 src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.netstandard17.cs create mode 100644 src/libraries/System.Resources.ResourceManager/tests/MissingSatelliteAssemblyException.cs create mode 100644 src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.netstandard17.cs create mode 100644 src/libraries/System.Resources.ResourceManager/tests/ResourceSetTests.cs create mode 100644 src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.Designer.cs rename src/libraries/{System.Resources.Reader/src/Resources/Strings.resx => System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.resx} (67%) create mode 100644 src/libraries/System.Resources.Writer/src/System/Resources/IResourceWriter.cs create mode 100644 src/libraries/System.Resources.Writer/src/System/Runtime/Versioning/MultitargetingHelpers.cs diff --git a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj index 0972efe7f12..bde0c6219a8 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj +++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj @@ -8,6 +8,10 @@ + + + + diff --git a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs index 7fa27b0359c..841716490e4 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs @@ -161,8 +161,7 @@ namespace System.ComponentModel } public partial class ComponentResourceManager : System.Resources.ResourceManager { - //public ComponentResourceManager() { } - //TODO NETSTANDARD2.0: I had to update the ctor to call the base ctor for this type + public ComponentResourceManager() { } public ComponentResourceManager(System.Type t) : base(t) { } public void ApplyResources(object value, string objectName) { } public virtual void ApplyResources(object value, string objectName, System.Globalization.CultureInfo culture) { } @@ -1497,20 +1496,3 @@ namespace System.ComponentModel.Design.Serialization void System.IDisposable.Dispose() { } } } - -namespace System.Resources -{ - public partial interface IResourceReader : System.Collections.IEnumerable, System.IDisposable - { - void Close(); - new System.Collections.IDictionaryEnumerator GetEnumerator(); - } - public partial interface IResourceWriter : System.IDisposable - { - void AddResource(string name, byte[] value); - void AddResource(string name, object value); - void AddResource(string name, string value); - void Close(); - void Generate(); - } -} \ No newline at end of file diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj index 05bc2617098..f14247fe2a8 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj @@ -244,6 +244,11 @@ + + + + + diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs index 535b4b0252c..09aae398455 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs @@ -22,9 +22,8 @@ namespace System.ComponentModel private Hashtable _resourceSets; private CultureInfo _neutralResourcesCulture; - //TODO: NETSTANDARD2.0 - // public ComponentResourceManager() : base() { - // } + public ComponentResourceManager() : base() { + } public ComponentResourceManager(Type t) : base(t) { diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/misc.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/misc.cs index c396ac57b0a..3fbd0d55e49 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/misc.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/misc.cs @@ -116,42 +116,3 @@ namespace System internal const int License = unchecked((int)0x80131901); } } - -namespace System.Resources -{ - public partial interface IResourceReader : System.Collections.IEnumerable, System.IDisposable - { - void Close(); - new System.Collections.IDictionaryEnumerator GetEnumerator(); - } - public partial interface IResourceWriter : System.IDisposable - { - void AddResource(string name, byte[] value); - void AddResource(string name, object value); - void AddResource(string name, string value); - void Close(); - void Generate(); - } - - public partial class ResourceSet : System.Collections.IEnumerable, System.IDisposable - { - protected System.Resources.IResourceReader Reader; - protected System.Collections.Hashtable Table; - protected ResourceSet() { } - public ResourceSet(System.IO.Stream stream) { } - public ResourceSet(System.Resources.IResourceReader reader) { } - public ResourceSet(string fileName) { } - public virtual void Close() { } - public void Dispose() { } - protected virtual void Dispose(bool disposing) { } - public virtual System.Type GetDefaultReader() { throw null; } - public virtual System.Type GetDefaultWriter() { throw null; } - public virtual System.Collections.IDictionaryEnumerator GetEnumerator() { throw null; } - public virtual object GetObject(string name) { throw null; } - public virtual object GetObject(string name, bool ignoreCase) { throw null; } - public virtual string GetString(string name) { throw null; } - public virtual string GetString(string name, bool ignoreCase) { throw null; } - protected virtual void ReadResources() { } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } -} \ No newline at end of file diff --git a/src/libraries/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj b/src/libraries/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj index f7487d4f4d4..5852d7de133 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj +++ b/src/libraries/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj @@ -90,9 +90,13 @@ + + + + - \ No newline at end of file + diff --git a/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.cs b/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.cs index bf7ce09dd88..55b5b9826f1 100644 --- a/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.cs +++ b/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.cs @@ -5,16 +5,10 @@ // Changes to this file must follow the http://aka.ms/api-review process. // ------------------------------------------------------------------------------ +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.FileAccess))] namespace System.IO { - [System.FlagsAttribute] - public enum FileAccess - { - Read = 1, - ReadWrite = 3, - Write = 2, - } [System.FlagsAttribute] public enum FileAttributes { diff --git a/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.csproj b/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.csproj index 6a888fa15b8..a6295976eaa 100644 --- a/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.csproj +++ b/src/libraries/System.IO.FileSystem.Primitives/ref/System.IO.FileSystem.Primitives.csproj @@ -8,6 +8,10 @@ + + + + diff --git a/src/libraries/System.IO.FileSystem.Primitives/ref/project.json b/src/libraries/System.IO.FileSystem.Primitives/ref/project.json index f4f76903216..2cd0509ee9c 100644 --- a/src/libraries/System.IO.FileSystem.Primitives/ref/project.json +++ b/src/libraries/System.IO.FileSystem.Primitives/ref/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "System.Runtime": "4.1.0" + "System.Runtime": "4.4.0-beta-24612-03" }, "frameworks": { "netstandard1.7": {} diff --git a/src/libraries/System.IO.FileSystem.Primitives/tests/System.IO.FileSystem.Primitives.Tests.csproj b/src/libraries/System.IO.FileSystem.Primitives/tests/System.IO.FileSystem.Primitives.Tests.csproj index 33b36f58b4c..e0a2d49f579 100644 --- a/src/libraries/System.IO.FileSystem.Primitives/tests/System.IO.FileSystem.Primitives.Tests.csproj +++ b/src/libraries/System.IO.FileSystem.Primitives/tests/System.IO.FileSystem.Primitives.Tests.csproj @@ -23,7 +23,9 @@ - + + + {6c05678e-394c-4cff-b453-a18e28c8f2c3} System.IO.FileSystem.Primitives diff --git a/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.cs b/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.cs index 9c2042a2132..0340e6b4c5f 100644 --- a/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.cs +++ b/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.cs @@ -5,93 +5,5 @@ // Changes to this file must follow the http://aka.ms/api-review process. // ------------------------------------------------------------------------------ - -namespace System.IO -{ - public partial class UnmanagedMemoryAccessor : System.IDisposable - { - protected UnmanagedMemoryAccessor() { } - public UnmanagedMemoryAccessor(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long capacity) { } - public UnmanagedMemoryAccessor(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long capacity, System.IO.FileAccess access) { } - public bool CanRead { get { return default(bool); } } - public bool CanWrite { get { return default(bool); } } - public long Capacity { get { return default(long); } } - protected bool IsOpen { get { return default(bool); } } - public void Dispose() { } - protected virtual void Dispose(bool disposing) { } - protected void Initialize(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long capacity, System.IO.FileAccess access) { } - public bool ReadBoolean(long position) { return default(bool); } - public byte ReadByte(long position) { return default(byte); } - public char ReadChar(long position) { return default(char); } - public decimal ReadDecimal(long position) { return default(decimal); } - public double ReadDouble(long position) { return default(double); } - public short ReadInt16(long position) { return default(short); } - public int ReadInt32(long position) { return default(int); } - public long ReadInt64(long position) { return default(long); } - [System.CLSCompliantAttribute(false)] - public sbyte ReadSByte(long position) { return default(sbyte); } - public float ReadSingle(long position) { return default(float); } - [System.CLSCompliantAttribute(false)] - public ushort ReadUInt16(long position) { return default(ushort); } - [System.CLSCompliantAttribute(false)] - public uint ReadUInt32(long position) { return default(uint); } - [System.CLSCompliantAttribute(false)] - public ulong ReadUInt64(long position) { return default(ulong); } - public void Read(long position, out T structure) where T : struct { throw null; } - public int ReadArray(long position, T[] array, int offset, int count) where T : struct { throw null; } - public void Write(long position, bool value) { } - public void Write(long position, byte value) { } - public void Write(long position, char value) { } - public void Write(long position, decimal value) { } - public void Write(long position, double value) { } - public void Write(long position, short value) { } - public void Write(long position, int value) { } - public void Write(long position, long value) { } - [System.CLSCompliantAttribute(false)] - public void Write(long position, sbyte value) { } - public void Write(long position, float value) { } - [System.CLSCompliantAttribute(false)] - public void Write(long position, ushort value) { } - [System.CLSCompliantAttribute(false)] - public void Write(long position, uint value) { } - [System.CLSCompliantAttribute(false)] - public void Write(long position, ulong value) { } - public void Write(long position, ref T structure) where T : struct { throw null; } - public void WriteArray(long position, T[] array, int offset, int count) where T : struct { throw null; } - } - public partial class UnmanagedMemoryStream : System.IO.Stream - { - protected UnmanagedMemoryStream() { } - [System.CLSCompliantAttribute(false)] - [System.Security.SecurityCriticalAttribute] - public unsafe UnmanagedMemoryStream(byte* pointer, long length) { } - [System.CLSCompliantAttribute(false)] - [System.Security.SecurityCriticalAttribute] - public unsafe UnmanagedMemoryStream(byte* pointer, long length, long capacity, System.IO.FileAccess access) { } - public UnmanagedMemoryStream(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length) { } - public UnmanagedMemoryStream(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length, System.IO.FileAccess access) { } - public override bool CanRead { get { return default(bool); } } - public override bool CanSeek { get { return default(bool); } } - public override bool CanWrite { get { return default(bool); } } - public long Capacity { get { return default(long); } } - public override long Length { get { return default(long); } } - public override long Position { get { return default(long); } set { } } - [System.CLSCompliantAttribute(false)] - public unsafe byte* PositionPointer {[System.Security.SecurityCriticalAttribute]get { return default(byte*); }[System.Security.SecurityCriticalAttribute]set { } } - protected override void Dispose(bool disposing) { } - public override void Flush() { } - public override System.Threading.Tasks.Task FlushAsync(System.Threading.CancellationToken cancellationToken) { return default(System.Threading.Tasks.Task); } - [System.CLSCompliantAttribute(false)] - [System.Security.SecurityCriticalAttribute] - protected unsafe void Initialize(byte* pointer, long length, long capacity, System.IO.FileAccess access) { } - protected void Initialize(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length, System.IO.FileAccess access) { } - public override int Read(byte[] buffer, int offset, int count) { buffer = default(byte[]); return default(int); } - public override System.Threading.Tasks.Task ReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { return default(System.Threading.Tasks.Task); } - public override int ReadByte() { return default(int); } - public override long Seek(long offset, System.IO.SeekOrigin loc) { return default(long); } - public override void SetLength(long value) { } - public override void Write(byte[] buffer, int offset, int count) { } - public override System.Threading.Tasks.Task WriteAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { return default(System.Threading.Tasks.Task); } - public override void WriteByte(byte value) { } - } -} +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.UnmanagedMemoryStream))] +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.UnmanagedMemoryAccessor))] diff --git a/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.csproj b/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.csproj index f9b6793f9ea..ba016722029 100644 --- a/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.csproj +++ b/src/libraries/System.IO.UnmanagedMemoryStream/ref/System.IO.UnmanagedMemoryStream.csproj @@ -9,6 +9,10 @@ + + + + diff --git a/src/libraries/System.IO.UnmanagedMemoryStream/ref/project.json b/src/libraries/System.IO.UnmanagedMemoryStream/ref/project.json index e8a1c54d0e6..38f6efbf34b 100644 --- a/src/libraries/System.IO.UnmanagedMemoryStream/ref/project.json +++ b/src/libraries/System.IO.UnmanagedMemoryStream/ref/project.json @@ -1,10 +1,7 @@ { "dependencies": { - "System.IO.FileSystem.Primitives": "4.0.1", - "System.IO": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime": "4.1.0", - "System.Threading.Tasks": "4.0.11" + "System.Runtime.InteropServices": "4.4.0-beta-24612-03", + "System.Runtime": "4.4.0-beta-24612-03" }, "frameworks": { "netstandard1.7": {} diff --git a/src/libraries/System.IO.UnmanagedMemoryStream/tests/System.IO.UnmanagedMemoryStream.Tests.csproj b/src/libraries/System.IO.UnmanagedMemoryStream/tests/System.IO.UnmanagedMemoryStream.Tests.csproj index c92d059ad95..13123c0b029 100644 --- a/src/libraries/System.IO.UnmanagedMemoryStream/tests/System.IO.UnmanagedMemoryStream.Tests.csproj +++ b/src/libraries/System.IO.UnmanagedMemoryStream/tests/System.IO.UnmanagedMemoryStream.Tests.csproj @@ -44,9 +44,12 @@ - - System.IO.FileSystem.Primitives - + + + + + + {bcf9255a-4321-4277-ad7d-f5094092c554} System.IO.UnmanagedMemoryStream diff --git a/src/libraries/System.Resources.Reader/dir.props b/src/libraries/System.Resources.Reader/dir.props index ba7c08a94cd..fcc1a7ca5a1 100644 --- a/src/libraries/System.Resources.Reader/dir.props +++ b/src/libraries/System.Resources.Reader/dir.props @@ -2,6 +2,6 @@ - 4.0.2.0 + 4.1.0.0 \ No newline at end of file diff --git a/src/libraries/System.Resources.Reader/pkg/System.Resources.Reader.pkgproj b/src/libraries/System.Resources.Reader/pkg/System.Resources.Reader.pkgproj index 45f495e7da2..9e20290dd24 100644 --- a/src/libraries/System.Resources.Reader/pkg/System.Resources.Reader.pkgproj +++ b/src/libraries/System.Resources.Reader/pkg/System.Resources.Reader.pkgproj @@ -4,9 +4,9 @@ - net45;netcore45;netcoreapp1.0;wp8;wpa81;$(AllXamarinFrameworks) + net463;netcoreapp1.1;$(AllXamarinFrameworks) - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.cs b/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.cs index ba0f13f08ad..cea0ccc59ab 100644 --- a/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.cs +++ b/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.cs @@ -5,14 +5,4 @@ // Changes to this file must follow the http://aka.ms/api-review process. // ------------------------------------------------------------------------------ - -namespace System.Resources -{ - public sealed partial class ResourceReader : System.IDisposable - { - [System.Security.SecurityCriticalAttribute] - public ResourceReader(System.IO.Stream stream) { } - public void Dispose() { } - public System.Collections.IDictionaryEnumerator GetEnumerator() { return default(System.Collections.IDictionaryEnumerator); } - } -} +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Resources.ResourceReader))] diff --git a/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.csproj b/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.csproj index 72e25bfd500..bcf7de07f3f 100644 --- a/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.csproj +++ b/src/libraries/System.Resources.Reader/ref/System.Resources.Reader.csproj @@ -3,7 +3,7 @@ Library - .NETStandard,Version=v1.3 + .NETStandard,Version=v1.7 @@ -11,5 +11,9 @@ + + + + - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Reader/ref/project.json b/src/libraries/System.Resources.Reader/ref/project.json index 453136a72b5..25bc277e768 100644 --- a/src/libraries/System.Resources.Reader/ref/project.json +++ b/src/libraries/System.Resources.Reader/ref/project.json @@ -1,13 +1,9 @@ { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0" + "System.Runtime": "4.4.0-beta-24612-03", + "System.IO": "4.4.0-beta-24612-03" }, "frameworks": { - "netstandard1.3": { - "imports": [ - "dotnet5.4" - ] - } + "netstandard1.7": {} } } diff --git a/src/libraries/System.Resources.Reader/src/System.Resources.Reader.csproj b/src/libraries/System.Resources.Reader/src/System.Resources.Reader.csproj index 3d73e09fc80..f7d36de913d 100644 --- a/src/libraries/System.Resources.Reader/src/System.Resources.Reader.csproj +++ b/src/libraries/System.Resources.Reader/src/System.Resources.Reader.csproj @@ -6,7 +6,8 @@ System.Resources.Reader System.Resources {16EE5522-F387-4C9E-9EF2-B5134B043F37} - .NETStandard,Version=v1.0 + true + .NETStandard,Version=v1.7 @@ -14,11 +15,11 @@ - - + + - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Reader/src/System/Resources/ResourceReader.cs b/src/libraries/System.Resources.Reader/src/System/Resources/ResourceReader.cs deleted file mode 100644 index ab89d076220..00000000000 --- a/src/libraries/System.Resources.Reader/src/System/Resources/ResourceReader.cs +++ /dev/null @@ -1,435 +0,0 @@ -// 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.Collections; -using System.Diagnostics; -using System.IO; -using System.Text; - -namespace System.Resources -{ - public sealed class ResourceReader : IDisposable - { - private const int ResSetVersion = 2; - private const int ResourceTypeCodeString = 1; - private const int ResourceManagerMagicNumber = unchecked((int)0xBEEFCACE); - private const int ResourceManagerHeaderVersionNumber = 1; - - private Stream _stream; // backing store we're reading from. - private long _nameSectionOffset; // Offset to name section of file. - private long _dataSectionOffset; // Offset to Data section of file. - private long _resourceStreamStart; // beginning of the resource stream, which could be part of a longer file stream - - private int[] _namePositions; // relative locations of names - private int _stringTypeIndex; - private int _numOfTypes; - private int _numResources; // Num of resources files, in case arrays aren't allocated. - private int _version; - - // "System.String, mscorlib" representation in resources stream - private readonly static byte[] s_SystemStringName = EncodeStringName(); - - public ResourceReader(Stream stream) - { - if (stream == null) - throw new ArgumentNullException(nameof(stream)); - if (!stream.CanRead) - throw new ArgumentException(SR.Argument_StreamNotReadable); - if (!stream.CanSeek) - throw new ArgumentException(SR.Argument_StreamNotSeekable); - - _stream = stream; - - ReadResources(); - } - - public void Dispose() - { - Dispose(true); - } - - [System.Security.SecuritySafeCritical] // auto-generated - private unsafe void Dispose(bool disposing) - { - if (_stream != null) { - if (disposing) { - Stream stream = _stream; - _stream = null; - if (stream != null) { - stream.Dispose(); - } - _namePositions = null; - } - } - } - - private void SkipString() - { - int stringLength; - if (!_stream.TryReadInt327BitEncoded(out stringLength) || stringLength < 0) - { - throw new BadImageFormatException(SR.BadImageFormat_NegativeStringLength); - } - _stream.Seek(stringLength, SeekOrigin.Current); - } - - private unsafe int GetNamePosition(int index) - { - Debug.Assert(index >= 0 && index < _numResources, "Bad index into name position array. index: " + index); - - int r; - - r = _namePositions[index]; - if (r < 0 || r > _dataSectionOffset - _nameSectionOffset) - { - throw new FormatException(SR.BadImageFormat_ResourcesNameInvalidOffset + ":" + r); - } - return r; - } - public IDictionaryEnumerator GetEnumerator() - { - if (_stream == null) - throw new InvalidOperationException(SR.ResourceReaderIsClosed); - return new ResourceEnumerator(this); - } - - private void SuccessElseEosException(bool condition) - { - if (!condition) { - throw new EndOfStreamException(); - } - } - - private string GetKeyForNameIndex(int index) - { - Debug.Assert(_stream != null, "ResourceReader is closed!"); - long nameVA = GetNamePosition(index); - lock (this) - { - _stream.Seek(_resourceStreamStart + nameVA + _nameSectionOffset, SeekOrigin.Begin); - var result = _stream.ReadString(utf16: true); - - int dataOffset; - SuccessElseEosException(_stream.TryReadInt32(out dataOffset)); - if (dataOffset < 0 || dataOffset >= _stream.Length - _dataSectionOffset) - { - throw new FormatException(SR.BadImageFormat_ResourcesDataInvalidOffset + " offset :" + dataOffset); - } - return result; - } - } - - private string GetValueForNameIndex(int index) - { - Debug.Assert(_stream != null, "ResourceReader is closed!"); - long nameVA = GetNamePosition(index); - lock (this) - { - _stream.Seek(_resourceStreamStart + nameVA + _nameSectionOffset, SeekOrigin.Begin); - SkipString(); - - int dataPos; - SuccessElseEosException(_stream.TryReadInt32(out dataPos)); - if (dataPos < 0 || dataPos >= _stream.Length - _dataSectionOffset) - { - throw new FormatException(SR.BadImageFormat_ResourcesDataInvalidOffset + dataPos); - } - - try - { - return ReadStringElseNull(dataPos); - } - catch (EndOfStreamException eof) - { - throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch, eof); - } - catch (ArgumentOutOfRangeException e) - { - throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch, e); - } - } - } - - //returns null if the resource is not a string - private string ReadStringElseNull(int pos) - { - _stream.Seek(_dataSectionOffset + pos, SeekOrigin.Begin); - - int typeIndex; - if(!_stream.TryReadInt327BitEncoded(out typeIndex)) { - throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch); - } - - if (_version == 1) { - if (typeIndex == -1 || !IsString(typeIndex)) { - return null; - } - } - else - { - if (ResourceTypeCodeString != typeIndex) { - return null; - } - } - - return _stream.ReadString(utf16 : false); - } - - private void ReadResources() - { - Debug.Assert(_stream != null, "ResourceReader is closed!"); - - try - { - // mega try-catch performs exceptionally bad on x64; factored out body into - // _ReadResources and wrap here. - _ReadResources(); - } - catch (EndOfStreamException eof) - { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted, eof); - } - catch (IndexOutOfRangeException e) - { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted, e); - } - } - - private void _ReadResources() - { - _resourceStreamStart = _stream.Position; - - // Read out the ResourceManager header - // Read out magic number - int magicNum; - SuccessElseEosException(_stream.TryReadInt32(out magicNum)); - - if (magicNum != ResourceManagerMagicNumber) - throw new ArgumentException(SR.Resources_StreamNotValid); - - // Assuming this is ResourceManager header V1 or greater, hopefully - // after the version number there is a number of bytes to skip - // to bypass the rest of the ResMgr header. For V2 or greater, we - // use this to skip to the end of the header - - int resMgrHeaderVersion; - SuccessElseEosException(_stream.TryReadInt32(out resMgrHeaderVersion)); - - //number of bytes to skip over to get past ResMgr header - int numBytesToSkip; - SuccessElseEosException(_stream.TryReadInt32(out numBytesToSkip)); - - if (numBytesToSkip < 0 || resMgrHeaderVersion < 0) { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); - } - - if (resMgrHeaderVersion > 1) { - _stream.Seek(numBytesToSkip, SeekOrigin.Current); - } - else { - // We don't care about numBytesToSkip; read the rest of the header - //Due to legacy : this field is always a variant of System.Resources.ResourceReader, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; - //So we Skip the type name for resourcereader unlike Desktop - SkipString(); - - // Skip over type name for a suitable ResourceSet - SkipString(); - } - - // Read RuntimeResourceSet header - // Do file version check - SuccessElseEosException(_stream.TryReadInt32(out _version)); - if (_version != ResSetVersion && _version != 1) { - throw new ArgumentException(SR.Arg_ResourceFileUnsupportedVersion + "Expected:" + ResSetVersion + "but got:" + _version); - } - - // number of resources - SuccessElseEosException(_stream.TryReadInt32(out _numResources)); - if (_numResources < 0) { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); - } - - SuccessElseEosException(_stream.TryReadInt32(out _numOfTypes)); - if (_numOfTypes < 0) { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); - } - - // find index of System.String - for (int i = 0; i < _numOfTypes; i++) - { - if(_stream.StartsWith(s_SystemStringName, advance : true)){ - _stringTypeIndex = i; - } - } - - // Prepare to read in the array of name hashes - // Note that the name hashes array is aligned to 8 bytes so - // we can use pointers into it on 64 bit machines. (4 bytes - // may be sufficient, but let's plan for the future) - // Skip over alignment stuff. All public .resources files - // should be aligned No need to verify the byte values. - long pos = _stream.Position; - int alignBytes = ((int)pos) & 7; - if (alignBytes != 0) - { - for (int i = 0; i < 8 - alignBytes; i++) - { - _stream.ReadByte(); - } - } - - //Skip over the array of name hashes - - for (int i = 0; i < _numResources; i++) - { - int hash; - SuccessElseEosException(_stream.TryReadInt32(out hash)); - } - - // Read in the array of relative positions for all the names. - _namePositions = new int[_numResources]; - for (int i = 0; i < _numResources; i++) - { - int namePosition; - SuccessElseEosException(_stream.TryReadInt32(out namePosition)); - if (namePosition < 0) - { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); - } - - _namePositions[i] = namePosition; - } - - // Read location of data section. - int dataSectionOffset; - SuccessElseEosException(_stream.TryReadInt32(out dataSectionOffset)); - if (dataSectionOffset < 0) - { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); - } - _dataSectionOffset = dataSectionOffset; - - // Store current location as start of name section - _nameSectionOffset = _stream.Position - _resourceStreamStart; - - // _nameSectionOffset should be <= _dataSectionOffset; if not, it's corrupt - if (_dataSectionOffset < _nameSectionOffset) - { - throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); - } - } - - private bool IsString(int typeIndex) - { - if (typeIndex < 0 || typeIndex >= _numOfTypes) - { - throw new BadImageFormatException(SR.BadImageFormat_InvalidType); - } - - return typeIndex == _stringTypeIndex; - } - - private static byte[] EncodeStringName() - { - // ResourceWriter always write the resources with legacy core library name (i.e. mscorlib). - // Ensure that when we read the type name, we update the library name to be the same. - var name = "System.String, mscorlib"; - int length = name.Length; - - var buffer = new byte[length + 1]; - var encoded = Encoding.UTF8.GetBytes(name, 0, length, buffer, 1); - - // all characters should be single byte encoded and the type name shorter than 128 bytes - // this restriction is needed to encode without multiple allocations of the buffer - if (encoded > 127 || encoded != length) - { - throw new NotSupportedException(); - } - - checked { buffer[0] = (byte)encoded; } - return buffer; - } - - internal sealed class ResourceEnumerator : IDictionaryEnumerator - { - private const int ENUM_DONE = int.MinValue; - private const int ENUM_NOT_STARTED = -1; - - private ResourceReader _reader; - private bool _currentIsValid; - private int _currentName; - - internal ResourceEnumerator(ResourceReader reader) - { - _currentName = ENUM_NOT_STARTED; - _reader = reader; - - } - - public bool MoveNext() - { - if (_currentName == _reader._numResources - 1 || _currentName == ENUM_DONE) - { - _currentIsValid = false; - _currentName = ENUM_DONE; - return false; - } - _currentIsValid = true; - _currentName++; - return true; - } - - public Object Key - { - [System.Security.SecuritySafeCritical] // auto-generated - get - { - if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.InvalidOperation_EnumEnded); - if (!_currentIsValid) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); - return _reader.GetKeyForNameIndex(_currentName); - } - } - - public Object Current - { - get - { - return Entry; - } - } - - public DictionaryEntry Entry - { - [System.Security.SecuritySafeCritical] // auto-generated - get - { - if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.InvalidOperation_EnumEnded); - if (!_currentIsValid) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); - - string key = _reader.GetKeyForNameIndex(_currentName); - string value = _reader.GetValueForNameIndex(_currentName); - - return new DictionaryEntry(key, value); - } - } - - public Object Value - { - get - { - if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.InvalidOperation_EnumEnded); - if (!_currentIsValid) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); - - return _reader.GetValueForNameIndex(_currentName); - } - } - - public void Reset() - { - if (_reader._stream == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed); - _currentIsValid = false; - _currentName = ENUM_NOT_STARTED; - } - } - } -} diff --git a/src/libraries/System.Resources.Reader/src/System/Resources/StreamExtensions.cs b/src/libraries/System.Resources.Reader/src/System/Resources/StreamExtensions.cs deleted file mode 100644 index 00af57ea4f1..00000000000 --- a/src/libraries/System.Resources.Reader/src/System/Resources/StreamExtensions.cs +++ /dev/null @@ -1,118 +0,0 @@ -// 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.Diagnostics; -using System.IO; -using System.Text; - -namespace System.Resources -{ - internal static class BinaryStreamExtensions - { - public static bool TryReadInt32(this Stream stream, out int result) - { - result = 0; - var b0 = stream.ReadByte(); - if (b0 < 0) return false; - var b1 = stream.ReadByte(); - if (b1 < 0) return false; - var b2 = stream.ReadByte(); - if (b2 < 0) return false; - var b3 = stream.ReadByte(); - if (b3 < 0) return false; - - result = b3; - result <<= 8; - result |= b2; - result <<= 8; - result |= b1; - result <<= 8; - result |= b0; - - return true; - } - - //blatantly copied over from BinaryReader - public static bool TryReadInt327BitEncoded(this Stream stream, out int result) - { - // Read out an int 7 bits at a time. The high bit - // of the byte when on means to continue reading more bytes. - result = 0; - int shift = 0; - byte b; - do - { - // Check for a corrupted stream. Read a max of 5 bytes. - // In a future version, add a DataFormatException. - if (shift == 5 * 7) // 5 bytes max per int, shift += 7 - throw new FormatException(SR.Format_Bad7BitInt32); - - // ReadByte handles end of stream cases for us. - int readByte = stream.ReadByte(); - if (readByte < 0) - { - result = default(int); - return false; - } - b = (byte)readByte; - result |= (b & 0x7F) << shift; - shift += 7; - } while ((b & 0x80) != 0); - - return true; - } - - // reads length (7-bit encoded int) + UTF8 buffer - public static string ReadString(this Stream stream, bool utf16 = false) - { - var position = stream.Position; - int stringLength; - if (!stream.TryReadInt327BitEncoded(out stringLength)) - { - throw new BadImageFormatException(SR.Resources_StreamNotValid); - } - - if(stringLength == 0) { return string.Empty; } - - byte[] buffer = new byte[stringLength]; - int totalRead = 0; - - do - { - int justRead = stream.Read(buffer, totalRead, stringLength - totalRead); - if(justRead == 0) - { - throw new EndOfStreamException(SR.BadImageFormat_ResourceNameCorrupted_NameIndex + position); - } - totalRead += justRead; - } - while (totalRead != stringLength); - - if (utf16) { - return Encoding.Unicode.GetString(buffer, 0, buffer.Length); - } - else { - return Encoding.UTF8.GetString(buffer, 0, buffer.Length); - } - } - - internal static bool StartsWith(this Stream stream, byte[] value, bool advance = false) - { - long originalPosition = stream.Position; - foreach(var b in value) - { - int read = stream.ReadByte(); - if(b != read) { - if (!advance) { - stream.Position = originalPosition; - } - return false; - } - } - if (!advance) { - stream.Position = originalPosition; - } - return true; - } - } -} diff --git a/src/libraries/System.Resources.Reader/src/project.json b/src/libraries/System.Resources.Reader/src/project.json index b2fdd3a7ba1..2cd0509ee9c 100644 --- a/src/libraries/System.Resources.Reader/src/project.json +++ b/src/libraries/System.Resources.Reader/src/project.json @@ -1,18 +1,8 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1", - "System.Diagnostics.Debug": "4.0.0", - "System.IO": "4.0.0", - "System.Resources.ResourceManager": "4.0.0", - "System.Runtime": "4.0.0", - "System.Text.Encoding": "4.0.0", - "System.Threading": "4.0.0" + "System.Runtime": "4.4.0-beta-24612-03" }, "frameworks": { - "netstandard1.0": { - "imports": [ - "dotnet5.1" - ] - } + "netstandard1.7": {} } } diff --git a/src/libraries/System.Resources.Reader/tests/ResourceReaderUnitTest.cs b/src/libraries/System.Resources.Reader/tests/ResourceReaderUnitTest.cs index 04b6e7b9e5b..c38a27578f6 100644 --- a/src/libraries/System.Resources.Reader/tests/ResourceReaderUnitTest.cs +++ b/src/libraries/System.Resources.Reader/tests/ResourceReaderUnitTest.cs @@ -403,11 +403,14 @@ namespace System.Resources.ResourceWriterTests byte[] _RefBuffer12 = new byte[] { 206, 202, 239, 190, 1, 0, 0, 0, 145, 0, 0, 0, 108, 83, 121, 115, 116, 101, 109, 46, 82, 101, 115, 111, 117, 114, 99, 101, 115, 46, 82, 101, 115, 111, 117, 114, 99, 101, 82, 101, 97, 100, 101, 114, 44, 32, 109, 115, 99, 111, 114, 108, 105, 98, 44, 32, 86, 101, 114, 115, 105, 111, 110, 61, 52, 46, 48, 46, 48, 46, 48, 44, 32, 67, 117, 108, 116, 117, 114, 101, 61, 110, 101, 117, 116, 114, 97, 108, 44, 32, 80, 117, 98, 108, 105, 99, 75, 101, 121, 84, 111, 107, 101, 110, 61, 98, 55, 55, 97, 53, 99, 53, 54, 49, 57, 51, 52, 101, 48, 56, 57, 35, 83, 121, 115, 116, 101, 109, 46, 82, 101, 115, 111, 117, 114, 99, 101, 115, 46, 82, 117, 110, 116, 105, 109, 101, 82, 101, 115, 111, 117, 114, 99, 101, 83, 101, 116, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 80, 65, 68, 80, 65, 68, 80, 208, 41, 193, 10, 209, 41, 193, 10, 211, 41, 193, 10, 15, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 249, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 49, 0, 0, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 50, 0, 8, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 51, 0, 30, 1, 0, 0, 1, 6, 118, 97, 108, 117, 101, 49, 32, 17, 1, 0, 0, 206, 202, 239, 190, 1, 0, 0, 0, 145, 0, 0, 0, 108, 83, 121, 115, 116, 101, 109, 46, 82, 101, 115, 111, 117, 114, 99, 101, 115, 46, 82, 101, 115, 111, 117, 114, 99, 101, 82, 101, 97, 100, 101, 114, 44, 32, 109, 115, 99, 111, 114, 108, 105, 98, 44, 32, 86, 101, 114, 115, 105, 111, 110, 61, 52, 46, 48, 46, 48, 46, 48, 44, 32, 67, 117, 108, 116, 117, 114, 101, 61, 110, 101, 117, 116, 114, 97, 108, 44, 32, 80, 117, 98, 108, 105, 99, 75, 101, 121, 84, 111, 107, 101, 110, 61, 98, 55, 55, 97, 53, 99, 53, 54, 49, 57, 51, 52, 101, 48, 56, 57, 35, 83, 121, 115, 116, 101, 109, 46, 82, 101, 115, 111, 117, 114, 99, 101, 115, 46, 82, 117, 110, 116, 105, 109, 101, 82, 101, 115, 111, 117, 114, 99, 101, 83, 101, 116, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 80, 65, 68, 80, 65, 68, 80, 208, 41, 193, 10, 209, 41, 193, 10, 211, 41, 193, 10, 15, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 249, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 49, 0, 0, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 50, 0, 8, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 51, 0, 16, 0, 0, 0, 1, 6, 118, 97, 108, 117, 101, 49, 1, 6, 118, 97, 108, 117, 101, 50, 1, 6, 118, 97, 108, 117, 101, 51, 1, 6, 118, 97, 108, 117, 101, 51 }; - Dictionary s_dict_expected = new Dictionary{ - { "name1", "value1"}, - { "name2", null}, - { "name3", "value3"} - }; + Dictionary s_dict_expected = new Dictionary + { + { "name1", "value1"}, + { "name2", new byte[]{ + 206, 202, 239, 190, 1, 0, 0, 0, 145, 0, 0, 0, 108, 83, 121, 115, 116, 101, 109, 46, 82, 101, 115, 111, 117, 114, 99, 101, 115, 46, 82, 101, 115, 111, 117, 114, 99, 101, 82, 101, 97, 100, 101, 114, 44, 32, 109, 115, 99, 111, 114, 108, 105, 98, 44, 32, 86, 101, 114, 115, 105, 111, 110, 61, 52, 46, 48, 46, 48, 46, 48, 44, 32, 67, 117, 108, 116, 117, 114, 101, 61, 110, 101, 117, 116, 114, 97, 108, 44, 32, 80, 117, 98, 108, 105, 99, 75, 101, 121, 84, 111, 107, 101, 110, 61, 98, 55, 55, 97, 53, 99, 53, 54, 49, 57, 51, 52, 101, 48, 56, 57, 35, 83, 121, 115, 116, 101, 109, 46, 82, 101, 115, 111, 117, 114, 99, 101, 115, 46, 82, 117, 110, 116, 105, 109, 101, 82, 101, 115, 111, 117, 114, 99, 101, 83, 101, 116, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 80, 65, 68, 80, 65, 68, 80, 208, 41, 193, 10, 209, 41, 193, 10, 211, 41, 193, 10, 15, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 249, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 49, 0, 0, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 50, 0, 8, 0, 0, 0, 10, 110, 0, 97, 0, 109, 0, 101, 0, 51, 0, 16, 0, 0, 0, 1, 6, 118, 97, 108, 117, 101, 49, 1, 6, 118, 97, 108, 117, 101, 50, 1, 6, 118, 97, 108, 117, 101, 51 + }}, + { "name3", "value3"} + }; using (var ms2 = new MemoryStream(_RefBuffer12)) { using (var rw = new ResourceReader(ms2)) @@ -422,13 +425,11 @@ namespace System.Resources.ResourceWriterTests foreach (DictionaryEntry entry in reader) { string key = (string)entry.Key; - string found = (string)entry.Value; - string value = s_dict_expected[key]; - Assert.True(string.Compare(value, found) == 0, "expected: " + value + ", but got : " + found); + object actual = entry.Value; + object expected = s_dict_expected[key]; + Assert.Equal(expected, actual); s_found_list.Add(key); } - - } } } diff --git a/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.builds b/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.builds index 7adbf47466f..eff35d58291 100644 --- a/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.builds +++ b/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.builds @@ -3,10 +3,14 @@ + + netstandard1.3 + netcoreapp1.0 + Windows_NT netcore50;net46 - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.csproj b/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.csproj index 63d16f2e4d9..f9f9480e41d 100644 --- a/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.csproj +++ b/src/libraries/System.Resources.Reader/tests/System.Resources.Reader.Tests.csproj @@ -9,7 +9,7 @@ System.Resources.Reader.Tests System.Resources.Reader.Tests {8D7202E8-084A-4C20-AB93-3BF70D2E0651} - .NETStandard,Version=v1.3 + .NETStandard,Version=v1.7 @@ -22,8 +22,10 @@ - System.Resources.Reder + System.Resources.Reader + + - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Reader/tests/project.json b/src/libraries/System.Resources.Reader/tests/project.json index 232055e5a73..035f16d376a 100644 --- a/src/libraries/System.Resources.Reader/tests/project.json +++ b/src/libraries/System.Resources.Reader/tests/project.json @@ -18,11 +18,13 @@ "Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00830-02" }, "frameworks": { - "netstandard1.3": {} + "netstandard1.3": {}, + "netstandard1.7": {} }, "supports": { "coreFx.Test.netcore50": {}, "coreFx.Test.netcoreapp1.0": {}, + "coreFx.Test.netcoreapp1.1": {}, "coreFx.Test.net46": {}, "coreFx.Test.net461": {}, "coreFx.Test.net462": {}, diff --git a/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln b/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln index e8b453c2e92..db0e7d3bca1 100644 --- a/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln +++ b/src/libraries/System.Resources.ResourceManager/System.Resources.ResourceManager.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Resources.ResourceManager", "src\System.Resources.ResourceManager.csproj", "{01F82B23-B433-4926-9E58-F87A25287EE9}" EndProject @@ -18,49 +18,49 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU net46_Debug|Any CPU = net46_Debug|Any CPU net46_Release|Any CPU = net46_Release|Any CPU + Release|Any CPU = Release|Any CPU uap101aot_Debug|Any CPU = uap101aot_Debug|Any CPU uap101aot_Release|Any CPU = uap101aot_Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {01F82B23-B433-4926-9E58-F87A25287EE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {01F82B23-B433-4926-9E58-F87A25287EE9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Debug|Any CPU.ActiveCfg = net46_Debug|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Debug|Any CPU.Build.0 = net46_Debug|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Release|Any CPU.ActiveCfg = net46_Release|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Release|Any CPU.Build.0 = net46_Release|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Debug|Any CPU.ActiveCfg = uap101aot_Debug|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Debug|Any CPU.Build.0 = uap101aot_Debug|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Release|Any CPU.ActiveCfg = uap101aot_Release|Any CPU - {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Release|Any CPU.Build.0 = uap101aot_Release|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Debug|Any CPU.Build.0 = Debug|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Release|Any CPU.ActiveCfg = Release|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.net46_Release|Any CPU.Build.0 = Release|Any CPU {01F82B23-B433-4926-9E58-F87A25287EE9}.Release|Any CPU.ActiveCfg = Release|Any CPU {01F82B23-B433-4926-9E58-F87A25287EE9}.Release|Any CPU.Build.0 = Release|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Debug|Any CPU.Build.0 = Debug|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Release|Any CPU.ActiveCfg = Release|Any CPU + {01F82B23-B433-4926-9E58-F87A25287EE9}.uap101aot_Release|Any CPU.Build.0 = Release|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.net46_Debug|Any CPU.ActiveCfg = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.net46_Debug|Any CPU.Build.0 = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.net46_Release|Any CPU.ActiveCfg = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.net46_Release|Any CPU.Build.0 = Debug|Any CPU + {E5D665D5-443B-45DC-8C36-74932FAB3848}.Release|Any CPU.ActiveCfg = Debug|Any CPU + {E5D665D5-443B-45DC-8C36-74932FAB3848}.Release|Any CPU.Build.0 = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.uap101aot_Debug|Any CPU.ActiveCfg = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.uap101aot_Debug|Any CPU.Build.0 = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.uap101aot_Release|Any CPU.ActiveCfg = Debug|Any CPU {E5D665D5-443B-45DC-8C36-74932FAB3848}.uap101aot_Release|Any CPU.Build.0 = Debug|Any CPU - {E5D665D5-443B-45DC-8C36-74932FAB3848}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {E5D665D5-443B-45DC-8C36-74932FAB3848}.Release|Any CPU.Build.0 = Debug|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.net46_Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.net46_Debug|Any CPU.Build.0 = Debug|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.net46_Release|Any CPU.ActiveCfg = Release|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.net46_Release|Any CPU.Build.0 = Release|Any CPU + {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.Release|Any CPU.Build.0 = Release|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.uap101aot_Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.uap101aot_Debug|Any CPU.Build.0 = Debug|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.uap101aot_Release|Any CPU.ActiveCfg = Release|Any CPU {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.uap101aot_Release|Any CPU.Build.0 = Release|Any CPU - {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/libraries/System.Resources.ResourceManager/dir.props b/src/libraries/System.Resources.ResourceManager/dir.props index 16a766f83bb..fcc1a7ca5a1 100644 --- a/src/libraries/System.Resources.ResourceManager/dir.props +++ b/src/libraries/System.Resources.ResourceManager/dir.props @@ -2,6 +2,6 @@ - 4.0.3.0 + 4.1.0.0 \ No newline at end of file diff --git a/src/libraries/System.Resources.ResourceManager/pkg/System.Resources.ResourceManager.pkgproj b/src/libraries/System.Resources.ResourceManager/pkg/System.Resources.ResourceManager.pkgproj index dca79f7ae00..dfbd9dcde94 100644 --- a/src/libraries/System.Resources.ResourceManager/pkg/System.Resources.ResourceManager.pkgproj +++ b/src/libraries/System.Resources.ResourceManager/pkg/System.Resources.ResourceManager.pkgproj @@ -3,21 +3,19 @@ - net45;netcore45;netcoreapp1.0;wp8;wpa81;uap10.1;$(AllXamarinFrameworks) + net463;netcoreapp1.1;uap10.1;$(AllXamarinFrameworks) - - + + net463 + + - - - - diff --git a/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.cs b/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.cs index 25cb52b7db5..a2f84f75995 100644 --- a/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.cs +++ b/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.cs @@ -8,33 +8,107 @@ namespace System.Resources { + public interface IResourceReader : System.Collections.IEnumerable, System.IDisposable + { + void Close(); + new System.Collections.IDictionaryEnumerator GetEnumerator(); + } + public sealed partial class ResourceReader : IResourceReader + { + public ResourceReader(System.IO.Stream stream) { } + public ResourceReader(string fileName) { } + public void Close() { } + public void Dispose() { } + public void GetResourceData(string resourceName, out string resourceType, out byte[] resourceData) { throw null; } + public System.Collections.IDictionaryEnumerator GetEnumerator() { return default(System.Collections.IDictionaryEnumerator); } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))] - public partial class MissingManifestResourceException : System.Exception + public partial class MissingManifestResourceException : System.SystemException { public MissingManifestResourceException() { } public MissingManifestResourceException(string message) { } public MissingManifestResourceException(string message, System.Exception inner) { } + protected MissingManifestResourceException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + } + [System.Serializable] + public class MissingSatelliteAssemblyException : System.SystemException + { + public MissingSatelliteAssemblyException(): base() { } + public MissingSatelliteAssemblyException(String message): base() { } + public MissingSatelliteAssemblyException(String message, String cultureName): base() { } + public MissingSatelliteAssemblyException(String message, Exception inner): base() { } + protected MissingSatelliteAssemblyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context): base() { } + public String CultureName { get { throw null; } } } [System.AttributeUsageAttribute((System.AttributeTargets)(1), AllowMultiple = false)] [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))] - public sealed partial class NeutralResourcesLanguageAttribute : System.Attribute + public sealed class NeutralResourcesLanguageAttribute : System.Attribute { public NeutralResourcesLanguageAttribute(string cultureName) { } public string CultureName { get { return default(string); } } + public NeutralResourcesLanguageAttribute(string cultureName, UltimateResourceFallbackLocation location) { } + public UltimateResourceFallbackLocation Location { get { throw null; } } } [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))] - public partial class ResourceManager + public class ResourceManager { + public static readonly int HeaderVersionNumber; + public static readonly int MagicNumber; + protected ResourceManager() { } public ResourceManager(string baseName, System.Reflection.Assembly assembly) { } + public ResourceManager(string baseName, System.Reflection.Assembly assembly, System.Type usingResourceSet) { } public ResourceManager(System.Type resourceSource) { } - public string GetString(string name) { return default(string); } + public virtual string BaseName { get { throw null; } } + public virtual bool IgnoreCase { get { throw null; } set { } } + public virtual System.Type ResourceSetType { get { throw null; } } + protected static System.Globalization.CultureInfo GetNeutralResourcesLanguage(System.Reflection.Assembly a) { throw null; } + public virtual object GetObject(string name) { throw null; } + public virtual object GetObject(string name, System.Globalization.CultureInfo culture) { throw null; } + protected virtual string GetResourceFileName(System.Globalization.CultureInfo culture) { throw null; } + public virtual ResourceSet GetResourceSet(System.Globalization.CultureInfo culture, bool createIfNotExists, bool tryParents) { throw null; } + protected static System.Version GetSatelliteContractVersion(System.Reflection.Assembly a) { throw null; } + public System.IO.UnmanagedMemoryStream GetStream(string name) { throw null; } + public System.IO.UnmanagedMemoryStream GetStream(string name, System.Globalization.CultureInfo culture) { throw null; } + public virtual string GetString(string name) { return default(string); } public virtual string GetString(string name, System.Globalization.CultureInfo culture) { return default(string); } + protected virtual ResourceSet InternalGetResourceSet(System.Globalization.CultureInfo culture, bool createIfNotExists, bool tryParents) { throw null; } + public virtual void ReleaseAllResources() { } + protected UltimateResourceFallbackLocation FallbackLocation { get { throw null; } set { } } + public static ResourceManager CreateFileBasedResourceManager(string baseName, string resourceDir, System.Type usingResourceSet) { throw null; } + + } + [System.Serializable] + public class ResourceSet : System.IDisposable, System.Collections.IEnumerable + { + protected ResourceSet() { } + public ResourceSet(System.IO.Stream stream) { } + public ResourceSet(string fileName) { } + public ResourceSet(IResourceReader reader) { } + public virtual void Close() { } + public void Dispose() { } + protected virtual void Dispose(bool disposing) { } + public virtual Type GetDefaultReader() { throw null; } + public virtual Type GetDefaultWriter() { throw null; } + public virtual System.Collections.IDictionaryEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + public virtual object GetObject(string name) { throw null; } + public virtual object GetObject(string name, bool ignoreCase) { throw null; } + public virtual string GetString(string name) { throw null; } + public virtual string GetString(string name, bool ignoreCase) { throw null; } + protected virtual void ReadResources() { } } [System.AttributeUsageAttribute((System.AttributeTargets)(1), AllowMultiple = false)] [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))] - public sealed partial class SatelliteContractVersionAttribute : System.Attribute + public sealed class SatelliteContractVersionAttribute : System.Attribute { public SatelliteContractVersionAttribute(string version) { } public string Version { get { return default(string); } } } + [System.Serializable] + public enum UltimateResourceFallbackLocation + { + MainAssembly, + Satellite + } } diff --git a/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.csproj b/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.csproj index b3ebaa2cdad..44311b6634b 100644 --- a/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.csproj +++ b/src/libraries/System.Resources.ResourceManager/ref/System.Resources.ResourceManager.csproj @@ -2,14 +2,17 @@ - 4.0.0.0 Library - .NETStandard,Version=v1.0 - netstandard1.0;uap10.1 + .NETStandard,Version=v1.7 + netstandard1.7;uap10.1 + + + + diff --git a/src/libraries/System.Resources.ResourceManager/ref/project.json b/src/libraries/System.Resources.ResourceManager/ref/project.json index b4351db2686..f3dbb9cfcb7 100644 --- a/src/libraries/System.Resources.ResourceManager/ref/project.json +++ b/src/libraries/System.Resources.ResourceManager/ref/project.json @@ -1,14 +1,11 @@ { "dependencies": { - "System.Runtime": "4.0.0", - "System.Reflection": "4.0.0", - "System.Globalization": "4.0.0" + "System.Runtime": "4.4.0-beta-24612-03", + "System.Runtime.InteropServices": "4.4.0-beta-24612-03", + "System.Reflection": "4.4.0-beta-24612-03", + "System.Globalization": "4.4.0-beta-24612-03" }, "frameworks": { - "netstandard1.0": { - "imports": [ - "dotnet5.1" - ] - } + "netstandard1.7": {} } } diff --git a/src/libraries/System.Resources.ResourceManager/src/ApiCompatBaseline.uap101aot.txt b/src/libraries/System.Resources.ResourceManager/src/ApiCompatBaseline.uap101aot.txt new file mode 100644 index 00000000000..ca1f05abc69 --- /dev/null +++ b/src/libraries/System.Resources.ResourceManager/src/ApiCompatBaseline.uap101aot.txt @@ -0,0 +1,35 @@ +Compat issues with assembly System.Resources.ResourceManager: +TypesMustExist : Type 'System.Resources.IResourceReader' does not exist in the implementation but it does exist in the contract. +CannotRemoveBaseTypeOrInterface : Type 'System.Resources.MissingManifestResourceException' does not inherit from base type 'System.SystemException' in the implementation but it does in the contract. +MembersMustExist : Member 'System.Resources.MissingManifestResourceException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract. +TypesMustExist : Type 'System.Resources.MissingSatelliteAssemblyException' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.NeutralResourcesLanguageAttribute..ctor(System.String, System.Resources.UltimateResourceFallbackLocation)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.NeutralResourcesLanguageAttribute.Location.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Int32 System.Resources.ResourceManager.HeaderVersionNumber' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Int32 System.Resources.ResourceManager.MagicNumber' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Reflection.Assembly System.Resources.ResourceManager.MainAssembly' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.String System.Resources.ResourceManager.BaseNameField' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager..ctor()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager..ctor(System.String, System.Reflection.Assembly, System.Type)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.BaseName.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.CreateFileBasedResourceManager(System.String, System.String, System.Type)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.FallbackLocation.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.FallbackLocation.set(System.Resources.UltimateResourceFallbackLocation)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetNeutralResourcesLanguage(System.Reflection.Assembly)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetObject(System.String)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetObject(System.String, System.Globalization.CultureInfo)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetResourceFileName(System.Globalization.CultureInfo)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo, System.Boolean, System.Boolean)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetSatelliteContractVersion(System.Reflection.Assembly)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetStream(System.String)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.GetStream(System.String, System.Globalization.CultureInfo)' does not exist in the implementation but it does exist in the contract. +CannotMakeMemberNonVirtual : Member 'System.Resources.ResourceManager.GetString(System.String)' is non-virtual in the implementation but is virtual in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.IgnoreCase.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.IgnoreCase.set(System.Boolean)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, System.Boolean, System.Boolean)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.ReleaseAllResources()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'System.Resources.ResourceManager.ResourceSetType.get()' does not exist in the implementation but it does exist in the contract. +TypesMustExist : Type 'System.Resources.ResourceReader' does not exist in the implementation but it does exist in the contract. +TypesMustExist : Type 'System.Resources.ResourceSet' does not exist in the implementation but it does exist in the contract. +TypesMustExist : Type 'System.Resources.UltimateResourceFallbackLocation' does not exist in the implementation but it does exist in the contract. +Total Issues: 33 diff --git a/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.builds b/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.builds index 17aa77ae8cb..d60b2d1d370 100644 --- a/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.builds +++ b/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.builds @@ -3,6 +3,9 @@ + + net463 + uap101aot diff --git a/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.csproj b/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.csproj index b4f69ca2de9..80e8d652c32 100644 --- a/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.csproj +++ b/src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.csproj @@ -6,21 +6,13 @@ true None true - .NETStandard,Version=v1.3 - netstandard1.3;uap10.1 + .NETStandard,Version=v1.7 + true + netstandard1.7;uap10.1 - - - - true - - - - - @@ -35,6 +27,12 @@ + + + + + + diff --git a/src/libraries/System.Resources.ResourceManager/src/project.json b/src/libraries/System.Resources.ResourceManager/src/project.json index ae327a9d49f..126c1b577c7 100644 --- a/src/libraries/System.Resources.ResourceManager/src/project.json +++ b/src/libraries/System.Resources.ResourceManager/src/project.json @@ -1,12 +1,14 @@ { "frameworks": { - "netstandard1.3": { + "netstandard1.7": { "dependencies": { "Microsoft.TargetingPack.Private.CoreCLR": "1.2.0-beta-24612-03" - }, - "imports": [ - "dotnet5.4" - ] + } + }, + "net463": { + "dependencies": { + "Microsoft.TargetingPack.NETFramework.v4.6": "1.0.1" + } }, "uap10.1": { "dependencies": { diff --git a/src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.cs b/src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.cs index cf4c56c13c8..8e0767d3b5f 100644 --- a/src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.cs +++ b/src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.cs @@ -6,7 +6,7 @@ using Xunit; namespace System.Resources.Tests { - public class MissingManifestResourceExceptionTests + public partial class MissingManifestResourceExceptionTests { [Fact] public static void ConstructorSimple() diff --git a/src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.netstandard17.cs b/src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.netstandard17.cs new file mode 100644 index 00000000000..299ae31e69b --- /dev/null +++ b/src/libraries/System.Resources.ResourceManager/tests/MissingManifestResourceExceptionTests.netstandard17.cs @@ -0,0 +1,20 @@ +// 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.Runtime.Serialization.Formatters.Tests; +using Xunit; + +namespace System.Resources.Tests +{ + public partial class MissingManifestResourceExceptionTests + { + [Fact] + public void Serialization() + { + const string message = "FATAL ERROR: The pizza could not be found."; + var ex = new MissingManifestResourceException(message); + BinaryFormatterHelpers.AssertRoundtrips(ex); + } + } +} diff --git a/src/libraries/System.Resources.ResourceManager/tests/MissingSatelliteAssemblyException.cs b/src/libraries/System.Resources.ResourceManager/tests/MissingSatelliteAssemblyException.cs new file mode 100644 index 00000000000..cf8894a0b7a --- /dev/null +++ b/src/libraries/System.Resources.ResourceManager/tests/MissingSatelliteAssemblyException.cs @@ -0,0 +1,56 @@ +// 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.Runtime.Serialization.Formatters.Tests; +using Xunit; + +namespace System.Resources.Tests +{ + public partial class MissingSatelliteAssemblyExceptionTests + { + [Fact] + public void ConstructorSimple() + { + MissingSatelliteAssemblyException msae = new MissingSatelliteAssemblyException(); + Assert.NotNull(msae.Message); + } + + [Fact] + public void ConstructorWithMessage() + { + const string message = "message"; + MissingSatelliteAssemblyException msae = new MissingSatelliteAssemblyException(message); + Assert.Equal(message, msae.Message); + } + + [Fact] + public void ConstructorWithMessageAndCultureName() + { + const string message = "message"; + const string cultureName = "fr-FR"; + MissingSatelliteAssemblyException msae = new MissingSatelliteAssemblyException(message, cultureName); + Assert.Equal(message, msae.Message); + Assert.Equal(cultureName, msae.CultureName); + } + + [Fact] + public void ConstructorWithMessageAndInnerException() + { + string message = "message"; + Exception innerException = new Exception(); + MissingSatelliteAssemblyException msae = new MissingSatelliteAssemblyException(message, innerException); + Assert.Equal(message, msae.Message); + Assert.Same(innerException, msae.InnerException); + } + + [Fact] + [ActiveIssue(12467)] + public void Serialization() + { + const string cultureName = "fr-FR"; + MissingSatelliteAssemblyException msae = new MissingSatelliteAssemblyException("message", cultureName); + BinaryFormatterHelpers.AssertRoundtrips(msae); + } + } +} diff --git a/src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.cs b/src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.cs index aba43af5d04..d0baac66dd3 100644 --- a/src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.cs +++ b/src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace System.Resources.Tests { - public static class ResourceManagerTests + public static partial class ResourceManagerTests { public static IEnumerable EnglishResourceData() { diff --git a/src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.netstandard17.cs b/src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.netstandard17.cs new file mode 100644 index 00000000000..3442e2fc75a --- /dev/null +++ b/src/libraries/System.Resources.ResourceManager/tests/ResourceManagerTests.netstandard17.cs @@ -0,0 +1,118 @@ +// 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.IO; +using System.Reflection; +using System.Globalization; +using System.Collections.Generic; +using Xunit; + +namespace System.Resources.Tests +{ + public static partial class ResourceManagerTests + { + [Fact] + public static void HeaderVersionNumber() + { + Assert.Equal(1, ResourceManager.HeaderVersionNumber); + } + + [Fact] + public static void MagicNumber() + { + Assert.Equal(unchecked((int)0xBEEFCACE), ResourceManager.MagicNumber); + } + + [Fact] + public static void UsingResourceSet() + { + var resourceManager = new ResourceManager("System.Resources.Tests.Resources.TestResx", typeof(ResourceManagerTests).GetTypeInfo().Assembly, typeof(ResourceSet)); + Assert.Equal(typeof(ResourceSet), resourceManager.ResourceSetType); + } + + [Fact] + public static void BaseName() + { + var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx", typeof(ResourceManagerTests).GetTypeInfo().Assembly); + Assert.Equal("System.Resources.Tests.Resources.TestResx", manager.BaseName); + } + + [Theory] + [MemberData(nameof(EnglishResourceData))] + public static void IgnoreCase(string key, string expectedValue) + { + var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx", typeof(ResourceManagerTests).GetTypeInfo().Assembly); + var culture = new CultureInfo("en-US"); + Assert.False(manager.IgnoreCase); + Assert.Equal(expectedValue, manager.GetString(key, culture)); + Assert.Null(manager.GetString(key.ToLower(), culture)); + manager.IgnoreCase = true; + Assert.Equal(expectedValue, manager.GetString(key, culture)); + Assert.Equal(expectedValue, manager.GetString(key.ToLower(), culture)); + } + + public static IEnumerable EnglishNonStringResourceData() + { + yield return new object[] { "Int", 42 }; + yield return new object[] { "Float", 3.14159 }; + yield return new object[] { "Bytes", new byte[] { 41, 42, 43, 44, 192, 168, 1, 1 } }; + yield return new object[] { "InvalidKeyName", null }; + } + + [Theory] + [MemberData(nameof(EnglishNonStringResourceData))] + [ActiveIssue(12565, TestPlatforms.AnyUnix)] + public static void GetObject(string key, object expectedValue) + { + var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(ResourceManagerTests).GetTypeInfo().Assembly); + Assert.Equal(expectedValue, manager.GetObject(key)); + Assert.Equal(expectedValue, manager.GetObject(key, new CultureInfo("en-US"))); + } + + [Theory] + [MemberData(nameof(EnglishResourceData))] + public static void GetResourceSet_Strings(string key, string expectedValue) + { + var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx", typeof(ResourceManagerTests).GetTypeInfo().Assembly); + var culture = new CultureInfo("en-US"); + ResourceSet set = manager.GetResourceSet(culture, true, true); + Assert.Equal(expectedValue, set.GetString(key)); + } + + [Theory] + [MemberData(nameof(EnglishNonStringResourceData))] + [ActiveIssue(12565, TestPlatforms.AnyUnix)] + public static void GetResourceSet_NonStrings(string key, object expectedValue) + { + var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(ResourceManagerTests).GetTypeInfo().Assembly); + var culture = new CultureInfo("en-US"); + ResourceSet set = manager.GetResourceSet(culture, true, true); + Assert.Equal(expectedValue, set.GetObject(key)); + } + + [Fact] + [ActiveIssue(12565, TestPlatforms.AnyUnix)] + public static void GetStream() + { + var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(ResourceManagerTests).GetTypeInfo().Assembly); + var culture = new CultureInfo("en-US"); + var expectedBytes = new byte[] { 41, 42, 43, 44, 192, 168, 1, 1 }; + using (Stream stream = manager.GetStream("ByteStream")) + { + foreach (byte b in expectedBytes) + { + Assert.Equal(b, stream.ReadByte()); + } + } + using (Stream stream = manager.GetStream("ByteStream", culture)) + { + foreach (byte b in expectedBytes) + { + Assert.Equal(b, stream.ReadByte()); + } + } + } + } +} diff --git a/src/libraries/System.Resources.ResourceManager/tests/ResourceSetTests.cs b/src/libraries/System.Resources.ResourceManager/tests/ResourceSetTests.cs new file mode 100644 index 00000000000..5a9ab6ea39e --- /dev/null +++ b/src/libraries/System.Resources.ResourceManager/tests/ResourceSetTests.cs @@ -0,0 +1,121 @@ + +// 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 Xunit; +using System.IO; +using System.Reflection; +using System.Globalization; +using System.Collections.Generic; + +namespace System.Resources.Tests +{ + public static class StaticResources + { + /// + /// An empty .resources file in base64 created with ResourceWriter on full .NET framework + /// + public const string Empty = "zsrvvgEAAACRAAAAbFN5c3RlbS5SZXNvdXJjZXMuUmVzb3VyY2VSZWFkZXIsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OSNTeXN0ZW0uUmVzb3VyY2VzLlJ1bnRpbWVSZXNvdXJjZVNldAIAAAAAAAAAAAAAAFBBRFBBRFC0AAAA"; + + /// + /// A .resources file in base64 with the following keys: + /// String: "message" + /// Int: (object)42 + /// Float: (object)3.14159 + /// Bytes: new byte[]{ 41, 42, 43, 44, 192, 168, 1, 1 } + /// ByteStream: new UnmanagedMemoryStream(new byte[]{ 41, 42, 43, 44, 192, 168, 1, 1 }) + /// + public const string WithData = "zsrvvgEAAACRAAAAbFN5c3RlbS5SZXNvdXJjZXMuUmVzb3VyY2VSZWFkZXIsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OSNTeXN0ZW0uUmVzb3VyY2VzLlJ1bnRpbWVSZXNvdXJjZVNldAIAAAAFAAAAAAAAAFBBRFBBRFCTxNurUOnkxTbThwtVRFcMfHGiDAAAAABCAAAANwAAACgAAAAZAAAALwEAABRCAHkAdABlAFMAdAByAGUAYQBtAAAAAAAKQgB5AHQAZQBzAA0AAAAKRgBsAG8AYQB0ABoAAAAGSQBuAHQAIwAAAAxTAHQAcgBpAG4AZwAoAAAAIQgAAAApKisswKgBASAIAAAAKSorLMCoAQENboYb8PkhCUAIKgAAAAEHbWVzc2FnZQ=="; + } + + public abstract class ResourceSetTests + { + public abstract ResourceSet GetSet(string base64Data); + + [Fact] + public void GetDefaultReader() + { + var set = GetSet(StaticResources.Empty); + Assert.Equal(typeof(ResourceReader), set.GetDefaultReader()); + } + + [Fact] + public void GetDefaultWriter() + { + var set = GetSet(StaticResources.Empty); + Assert.Equal(typeof(ResourceWriter), set.GetDefaultWriter()); + } + + [Fact] + public void EnumerateEmpty() + { + var set = GetSet(StaticResources.Empty); + var enumerator = set.GetEnumerator(); + Assert.False(enumerator.MoveNext()); + } + + [Fact] + public void Enumerate() + { + var set = GetSet(StaticResources.WithData); + var keys = new List + { + "String", + "Int", + "Float", + "Bytes", + "ByteStream" + }; + var enumerator = set.GetEnumerator(); + var idx = 0; + while (enumerator.MoveNext()) + { + Assert.Contains((string)enumerator.Key, keys); + idx++; + } + Assert.Equal(keys.Count, idx); + } + + public static IEnumerable EnglishResourceData() + { + yield return new object[] { "String", "message" }; + yield return new object[] { "Int", 42 }; + yield return new object[] { "Float", 3.14159 }; + yield return new object[] { "Bytes", new byte[] { 41, 42, 43, 44, 192, 168, 1, 1 } }; + } + + [Theory] + [MemberData(nameof(EnglishResourceData))] + public void GetObject(string key, object expectedValue) + { + var set = GetSet(StaticResources.WithData); + Assert.Equal(expectedValue, set.GetObject(key)); + Assert.Equal(expectedValue, set.GetObject(key.ToLower(), true)); + } + + [Fact] + public void GetString() + { + var set = GetSet(StaticResources.WithData); + Assert.Equal("message", set.GetString("String")); + Assert.Equal("message", set.GetString("string", true)); + } + } + + public class ResourceSetTests_StreamCtor : ResourceSetTests + { + public override ResourceSet GetSet(string base64Data) + { + return new ResourceSet(new MemoryStream(Convert.FromBase64String(base64Data))); + } + } + + public class ResourceSetTests_ResourceReaderCtor : ResourceSetTests + { + public override ResourceSet GetSet(string base64Data) + { + return new ResourceSet(new ResourceReader(new MemoryStream(Convert.FromBase64String(base64Data)))); + } + } +} diff --git a/src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.Designer.cs b/src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.Designer.cs new file mode 100644 index 00000000000..9ba27a3a4dc --- /dev/null +++ b/src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.Designer.cs @@ -0,0 +1,102 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace System.Resources.Tests.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class TestResx_netstandard17 { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal TestResx_netstandard17() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(TestResx_netstandard17).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Bytes { + get { + object obj = ResourceManager.GetObject("Bytes", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. + /// + internal static System.IO.UnmanagedMemoryStream ByteStream { + get { + return ResourceManager.GetStream("ByteStream", resourceCulture); + } + } + + /// + /// Looks up a localized resource of type System.Double similar to 3.14159. + /// + internal static double Float { + get { + object obj = ResourceManager.GetObject("Float", resourceCulture); + return ((double)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Int32 similar to 42. + /// + internal static int Int { + get { + object obj = ResourceManager.GetObject("Int", resourceCulture); + return ((int)(obj)); + } + } + } +} diff --git a/src/libraries/System.Resources.Reader/src/Resources/Strings.resx b/src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.resx similarity index 67% rename from src/libraries/System.Resources.Reader/src/Resources/Strings.resx rename to src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.resx index 015b9bf11d7..d3cb050091c 100644 --- a/src/libraries/System.Resources.Reader/src/Resources/Strings.resx +++ b/src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.netstandard17.resx @@ -117,55 +117,22 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - The resource writer has already been closed and cannot be edited. + + + 42 - - Stream was not seekable. + + 3.14159 - - The ResourceReader class does not know how to read this version of .resources files. + + KSorLMCoAQE= - - Stream is not a valid resource file. - - - Corrupt .resources file. Unable to read resources from this file because of invalid header information. Try regenerating the .resources file. - - - Stream was not readable. - - - Corrupt .resources file. String length must be non-negative. - - - Corrupt .resources file. The Invalid offset into name section is . - - - This .resources file should not be read with this reader. The resource reader type is - - - Corrupt .resources file. The specified type doesn't match the available data in the stream. - - - Corrupt .resources file. The resource name for name index that extends past the end of the stream is - - - Corrupt .resources file. Invalid offset into data section is - - - Too many bytes in what should have been a 7 bit encoded Int32. - - - Corrupt .resources file. The specified type doesn't exist. - - - Enumeration has not started. Call MoveNext - - - Enumeration already finished. - - - ResourceReader is closed. + + + AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v + cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw + b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB + AQEBCQIAAAAAAAAAAAAAAAgAAAAIAAAAAAEAAQoPAgAAAAgAAAACKSorLMCoAQEL + \ No newline at end of file diff --git a/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.builds b/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.builds index d9162d30206..f0f367ded08 100644 --- a/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.builds +++ b/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.builds @@ -3,10 +3,14 @@ + + netstandard1.3 + netcoreapp1.0 + Windows_NT netcore50;net46 - \ No newline at end of file + diff --git a/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.csproj b/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.csproj index 8fa0b58f46b..ddcd659cc89 100644 --- a/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.csproj +++ b/src/libraries/System.Resources.ResourceManager/tests/System.Resources.ResourceManager.Tests.csproj @@ -6,7 +6,7 @@ System.Resources.ResourceManager.Tests System.Resources.Tests {1D51A16C-B6D8-4E8F-98DE-21AD9A7062A1} - .NETStandard,Version=v1.3 + .NETStandard,Version=v1.7 @@ -25,6 +25,33 @@ + + + System/Runtime/Serialization/Formatters/BinaryFormatterHelpers.cs + + + + + + + ResXFileCodeGenerator + TestResx.netstandard17.Designer.cs + + + True + True + TestResx.netstandard17.resx + + + + + + + + + + + ResXFileCodeGenerator @@ -32,4 +59,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Resources.ResourceManager/tests/project.json b/src/libraries/System.Resources.ResourceManager/tests/project.json index 75d63d4aa51..c0e94139264 100644 --- a/src/libraries/System.Resources.ResourceManager/tests/project.json +++ b/src/libraries/System.Resources.ResourceManager/tests/project.json @@ -5,7 +5,6 @@ "System.Globalization": "4.4.0-beta-24612-03", "System.Linq.Expressions": "4.4.0-beta-24612-03", "System.ObjectModel": "4.4.0-beta-24612-03", - "System.Resources.ResourceManager": "4.4.0-beta-24612-03", "System.Text.RegularExpressions": "4.4.0-beta-24612-03", "test-runtime": { "target": "project", @@ -15,7 +14,12 @@ "Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00830-02" }, "frameworks": { - "netstandard1.3": {} + "netstandard1.3": {}, + "netstandard1.7": { + "dependencies": { + "System.Runtime.Serialization.Formatters": "4.4.0-beta-24612-03" + } + } }, "supports": { "coreFx.Test.netcore50": {}, diff --git a/src/libraries/System.Resources.Writer/dir.props b/src/libraries/System.Resources.Writer/dir.props index ba7c08a94cd..041b9b1160d 100644 --- a/src/libraries/System.Resources.Writer/dir.props +++ b/src/libraries/System.Resources.Writer/dir.props @@ -2,6 +2,6 @@ - 4.0.2.0 + 4.1.0.0 - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Writer/pkg/System.Resources.Writer.pkgproj b/src/libraries/System.Resources.Writer/pkg/System.Resources.Writer.pkgproj index f238ad54ccd..d299e340161 100644 --- a/src/libraries/System.Resources.Writer/pkg/System.Resources.Writer.pkgproj +++ b/src/libraries/System.Resources.Writer/pkg/System.Resources.Writer.pkgproj @@ -4,9 +4,9 @@ - net46;netcore50;netcoreapp1.0;$(AllXamarinFrameworks) + net463;netcoreapp1.1;$(AllXamarinFrameworks) - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.cs b/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.cs index f7601733c69..26700a38c1b 100644 --- a/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.cs +++ b/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.cs @@ -8,11 +8,27 @@ namespace System.Resources { - public sealed partial class ResourceWriter : System.IDisposable + public interface IResourceWriter : IDisposable { + void AddResource(string name, string value); + void AddResource(string name, object value); + void AddResource(string name, byte[] value); + void Close(); + void Generate(); + } + public sealed class ResourceWriter : IResourceWriter + { + public ResourceWriter(string fileName) { } public ResourceWriter(System.IO.Stream stream) { } public void AddResource(string name, string value) { } + public void AddResource(string name, object value) { } + public void AddResource(string name, byte[] value) { } + public void AddResource(string name, System.IO.Stream value) { } + public void AddResource(string name, System.IO.Stream value, bool closeAfterWrite) { } + public void AddResourceData(string name, string typeName, byte[] serializedData) { } + public void Close() { } public void Dispose() { } public void Generate() { } + public System.Func TypeNameConverter { get { throw null; } set { } } } } diff --git a/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.csproj b/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.csproj index c59301b1cf8..cf6628a5226 100644 --- a/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.csproj +++ b/src/libraries/System.Resources.Writer/ref/System.Resources.Writer.csproj @@ -3,7 +3,7 @@ Library - .NETStandard,Version=v1.3 + .NETStandard,Version=v1.7 @@ -12,4 +12,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Writer/ref/project.json b/src/libraries/System.Resources.Writer/ref/project.json index 453136a72b5..25bc277e768 100644 --- a/src/libraries/System.Resources.Writer/ref/project.json +++ b/src/libraries/System.Resources.Writer/ref/project.json @@ -1,13 +1,9 @@ { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0" + "System.Runtime": "4.4.0-beta-24612-03", + "System.IO": "4.4.0-beta-24612-03" }, "frameworks": { - "netstandard1.3": { - "imports": [ - "dotnet5.4" - ] - } + "netstandard1.7": {} } } diff --git a/src/libraries/System.Resources.Writer/src/Resources/Strings.resx b/src/libraries/System.Resources.Writer/src/Resources/Strings.resx index 41aa5cd1760..25b7164292e 100644 --- a/src/libraries/System.Resources.Writer/src/Resources/Strings.resx +++ b/src/libraries/System.Resources.Writer/src/Resources/Strings.resx @@ -168,4 +168,13 @@ ResourceReader is closed. + + Stream does not support seeking. + + + This platform does not support binary serialized resources. + + + Stream length must be non-negative and less than 2^31 - 1 - origin. + diff --git a/src/libraries/System.Resources.Writer/src/System.Resources.Writer.csproj b/src/libraries/System.Resources.Writer/src/System.Resources.Writer.csproj index 43d19adc1bb..d71560dce76 100644 --- a/src/libraries/System.Resources.Writer/src/System.Resources.Writer.csproj +++ b/src/libraries/System.Resources.Writer/src/System.Resources.Writer.csproj @@ -5,7 +5,7 @@ true System.Resources.Writer System.Resources - .NETStandard,Version=v1.3 + .NETStandard,Version=v1.7 @@ -14,10 +14,15 @@ + + + + + - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Writer/src/System/Resources/IResourceWriter.cs b/src/libraries/System.Resources.Writer/src/System/Resources/IResourceWriter.cs new file mode 100644 index 00000000000..24706f57b34 --- /dev/null +++ b/src/libraries/System.Resources.Writer/src/System/Resources/IResourceWriter.cs @@ -0,0 +1,15 @@ +// 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.Resources +{ + public interface IResourceWriter : IDisposable + { + void AddResource(string name, string value); + void AddResource(string name, object value); + void AddResource(string name, byte[] value); + void Close(); + void Generate(); + } +} diff --git a/src/libraries/System.Resources.Writer/src/System/Resources/ResourceWriter.cs b/src/libraries/System.Resources.Writer/src/System/Resources/ResourceWriter.cs index 24bde4f341a..b15ce246d4c 100644 --- a/src/libraries/System.Resources.Writer/src/System/Resources/ResourceWriter.cs +++ b/src/libraries/System.Resources.Writer/src/System/Resources/ResourceWriter.cs @@ -21,6 +21,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Runtime.Versioning; +using System.Runtime.Serialization; using System.Diagnostics; using System.Diagnostics.Contracts; @@ -37,7 +38,7 @@ namespace System.Resources // See the RuntimeResourceSet overview for details on the system // default file format. // - public sealed class ResourceWriter : System.IDisposable + public sealed class ResourceWriter : IResourceWriter { // An initial size for our internal sorted list, to avoid extra resizes. private const int AverageNameSize = 20 * 2; // chars in little endian Unicode @@ -45,13 +46,24 @@ namespace System.Resources private const string ResourceReaderFullyQualifiedName = "System.Resources.ResourceReader, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; private const string ResSetTypeName = "System.Resources.RuntimeResourceSet"; private const int ResSetVersion = 2; - private const int ResourceTypeCodeString = 1; - private const int ResourceManagerMagicNumber = unchecked((int)0xBEEFCACE); - private const int ResourceManagerHeaderVersionNumber = 1; - private SortedDictionary _resourceList; + private SortedDictionary _resourceList; private Stream _output; - private Dictionary _caseInsensitiveDups; + private Dictionary _caseInsensitiveDups; + private Dictionary _preserializedData; + + // Set this delegate to allow multi-targeting for .resources files. + public Func TypeNameConverter { get; set; } + + public ResourceWriter(string fileName) + { + if (fileName == null) + throw new ArgumentNullException(nameof(fileName)); + Contract.EndContractBlock(); + _output = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None); + _resourceList = new SortedDictionary(FastResourceComparer.Default); + _caseInsensitiveDups = new Dictionary(StringComparer.OrdinalIgnoreCase); + } public ResourceWriter(Stream stream) { @@ -61,14 +73,14 @@ namespace System.Resources throw new ArgumentException(SR.Argument_StreamNotWritable); Contract.EndContractBlock(); _output = stream; - _resourceList = new SortedDictionary(FastResourceComparer.Default); - _caseInsensitiveDups = new Dictionary(StringComparer.OrdinalIgnoreCase); + _resourceList = new SortedDictionary(FastResourceComparer.Default); + _caseInsensitiveDups = new Dictionary(StringComparer.OrdinalIgnoreCase); } // Adds a string resource to the list of resources to be written to a file. // They aren't written until Generate() is called. // - public void AddResource(String name, String value) + public void AddResource(string name, string value) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -81,22 +93,171 @@ namespace System.Resources _resourceList.Add(name, value); } - public void Dispose() + // Adds a resource of type Object to the list of resources to be + // written to a file. They aren't written until Generate() is called. + // + public void AddResource(string name, object value) { - if (_resourceList != null) + if (name == null) + throw new ArgumentNullException(nameof(name)); + Contract.EndContractBlock(); + if (_resourceList == null) + throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved); + + // needed for binary compat + if (value != null && value is Stream) { - Generate(); + AddResourceInternal(name, (Stream)value, false); } - if (_output != null) + else { - _output.Dispose(); - GC.SuppressFinalize((object)_output); + // Check for duplicate resources whose names vary only by case. + _caseInsensitiveDups.Add(name, null); + _resourceList.Add(name, value); + } + } + + // Adds a resource of type Stream to the list of resources to be + // written to a file. They aren't written until Generate() is called. + // Doesn't close the Stream when done. + // + public void AddResource(string name, Stream value) + { + if (name == null) + throw new ArgumentNullException(nameof(name)); + Contract.EndContractBlock(); + if (_resourceList == null) + throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved); + + AddResourceInternal(name, value, false); + } + + // Adds a resource of type Stream to the list of resources to be + // written to a file. They aren't written until Generate() is called. + // closeAfterWrite parameter indicates whether to close the stream when done. + // + public void AddResource(string name, Stream value, bool closeAfterWrite) + { + if (name == null) + throw new ArgumentNullException(nameof(name)); + Contract.EndContractBlock(); + if (_resourceList == null) + throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved); + + AddResourceInternal(name, value, closeAfterWrite); + } + + private void AddResourceInternal(string name, Stream value, bool closeAfterWrite) + { + if (value == null) + { + // Check for duplicate resources whose names vary only by case. + _caseInsensitiveDups.Add(name, null); + _resourceList.Add(name, value); + } + else + { + // make sure the Stream is seekable + if (!value.CanSeek) + throw new ArgumentException(SR.NotSupported_UnseekableStream); + + // Check for duplicate resources whose names vary only by case. + _caseInsensitiveDups.Add(name, null); + _resourceList.Add(name, new StreamWrapper(value, closeAfterWrite)); + } + } + + // Adds a named byte array as a resource to the list of resources to + // be written to a file. They aren't written until Generate() is called. + // + public void AddResource(string name, byte[] value) + { + if (name == null) + throw new ArgumentNullException(nameof(name)); + Contract.EndContractBlock(); + if (_resourceList == null) + throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved); + + // Check for duplicate resources whose names vary only by case. + _caseInsensitiveDups.Add(name, null); + _resourceList.Add(name, value); + } + + public void AddResourceData(string name, string typeName, byte[] serializedData) + { + if (name == null) + throw new ArgumentNullException(nameof(name)); + if (typeName == null) + throw new ArgumentNullException(nameof(typeName)); + if (serializedData == null) + throw new ArgumentNullException(nameof(serializedData)); + Contract.EndContractBlock(); + if (_resourceList == null) + throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved); + + // Check for duplicate resources whose names vary only by case. + _caseInsensitiveDups.Add(name, null); + if (_preserializedData == null) + _preserializedData = new Dictionary(FastResourceComparer.Default); + + _preserializedData.Add(name, new PrecannedResource(typeName, serializedData)); + } + + // For cases where users can't create an instance of the deserialized + // type in memory, and need to pass us serialized blobs instead. + // LocStudio's managed code parser will do this in some cases. + private class PrecannedResource + { + internal readonly string TypeName; + internal readonly byte[] Data; + + internal PrecannedResource(string typeName, byte[] data) + { + TypeName = typeName; + Data = data; + } + } + + private class StreamWrapper + { + internal readonly Stream Stream; + internal readonly bool CloseAfterWrite; + + internal StreamWrapper(Stream s, bool closeAfterWrite) + { + Stream = s; + CloseAfterWrite = closeAfterWrite; + } + } + + public void Close() + { + Dispose(true); + } + + private void Dispose(bool disposing) + { + if (disposing) + { + if (_resourceList != null) + { + Generate(); + } + if (_output != null) + { + _output.Dispose(); + } } _output = null; _caseInsensitiveDups = null; } + public void Dispose() + { + Dispose(true); + } + // After calling AddResource, Generate() writes out all resources to the // output stream in the system default format. // If an exception occurs during object serialization or during IO, @@ -108,13 +269,14 @@ namespace System.Resources throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved); BinaryWriter bw = new BinaryWriter(_output, Encoding.UTF8); + List typeNames = new List(); // Write out the ResourceManager header // Write out magic number - bw.Write(ResourceManagerMagicNumber); + bw.Write(ResourceManager.MagicNumber); // Write out ResourceManager header version number - bw.Write(ResourceManagerHeaderVersionNumber); + bw.Write(ResourceManager.HeaderVersionNumber); MemoryStream resMgrHeaderBlob = new MemoryStream(240); BinaryWriter resMgrHeaderPart = new BinaryWriter(resMgrHeaderBlob); @@ -145,6 +307,8 @@ namespace System.Resources // number of resources int numResources = _resourceList.Count; + if (_preserializedData != null) + numResources += _preserializedData.Count; bw.Write(numResources); // Store values in temporary streams to write at end of file. @@ -160,31 +324,38 @@ namespace System.Resources { BinaryWriter data = new BinaryWriter(dataSection, Encoding.UTF8); - // We've stored our resources internally in a Hashtable, which - // makes no guarantees about the ordering while enumerating. - // While we do our own sorting of the resource names based on their - // hash values, that's only sorting the nameHashes and namePositions - // arrays. That's all that is strictly required for correctness, - // but for ease of generating a patch in the future that - // modifies just .resources files, we should re-sort them. - + if (_preserializedData != null) + { + foreach (KeyValuePair entry in _preserializedData) + { + _resourceList.Add(entry.Key, entry.Value); + } + } // Write resource name and position to the file, and the value // to our temporary buffer. Save Type as well. - foreach (var items in _resourceList) + foreach (var item in _resourceList) { - nameHashes[curNameNumber] = FastResourceComparer.HashFunction((String)items.Key); + nameHashes[curNameNumber] = FastResourceComparer.HashFunction(item.Key); namePositions[curNameNumber++] = (int)names.Seek(0, SeekOrigin.Current); - names.Write((String)items.Key); // key + names.Write(item.Key); // key names.Write((int)data.Seek(0, SeekOrigin.Current)); // virtual offset of value. - String value = items.Value; + object value = item.Value; + ResourceTypeCode typeCode = FindTypeCode(value, typeNames); // Write out type code - Write7BitEncodedInt(data, ResourceTypeCodeString); + Write7BitEncodedInt(data, (int)typeCode); - // Write out value - data.Write(value); + var userProvidedResource = value as PrecannedResource; + if (userProvidedResource != null) + { + data.Write(userProvidedResource.Data); + } + else + { + WriteValue(typeCode, value, data); + } } // At this point, the ResourceManager header has been written. @@ -192,7 +363,11 @@ namespace System.Resources // The reader expects a list of user defined type names // following the size of the list, write 0 for this // writer implementation - bw.Write((int)0); + bw.Write(typeNames.Count); + foreach (var typeName in typeNames) + { + bw.Write(typeName); + } // Write out the name-related items for lookup. // Note that the hash array and the namePositions array must @@ -217,7 +392,9 @@ namespace System.Resources Debug.Assert((bw.BaseStream.Position & 7) == 0, "ResourceWriter: Name hashes array won't be 8 byte aligned! Ack!"); foreach (int hash in nameHashes) + { bw.Write(hash); + } // Write relative positions of all the names in the file. // Note: this data is 4 byte aligned, occurring immediately @@ -226,7 +403,9 @@ namespace System.Resources Debug.Assert((bw.BaseStream.Position & 3) == 0, "ResourceWriter: Name positions array won't be 4 byte aligned! Ack!"); foreach (int pos in namePositions) + { bw.Write(pos); + } // Flush all BinaryWriters to their underlying streams. bw.Flush(); @@ -268,6 +447,234 @@ namespace System.Resources } store.Write((byte)v); } + + // Finds the ResourceTypeCode for a type, or adds this type to the + // types list. + private ResourceTypeCode FindTypeCode(object value, List types) + { + if (value == null) + return ResourceTypeCode.Null; + + Type type = value.GetType(); + if (type == typeof(string)) + return ResourceTypeCode.String; + else if (type == typeof(int)) + return ResourceTypeCode.Int32; + else if (type == typeof(bool)) + return ResourceTypeCode.Boolean; + else if (type == typeof(char)) + return ResourceTypeCode.Char; + else if (type == typeof(byte)) + return ResourceTypeCode.Byte; + else if (type == typeof(sbyte)) + return ResourceTypeCode.SByte; + else if (type == typeof(short)) + return ResourceTypeCode.Int16; + else if (type == typeof(long)) + return ResourceTypeCode.Int64; + else if (type == typeof(ushort)) + return ResourceTypeCode.UInt16; + else if (type == typeof(uint)) + return ResourceTypeCode.UInt32; + else if (type == typeof(ulong)) + return ResourceTypeCode.UInt64; + else if (type == typeof(float)) + return ResourceTypeCode.Single; + else if (type == typeof(double)) + return ResourceTypeCode.Double; + else if (type == typeof(decimal)) + return ResourceTypeCode.Decimal; + else if (type == typeof(DateTime)) + return ResourceTypeCode.DateTime; + else if (type == typeof(TimeSpan)) + return ResourceTypeCode.TimeSpan; + else if (type == typeof(byte[])) + return ResourceTypeCode.ByteArray; + else if (type == typeof(StreamWrapper)) + return ResourceTypeCode.Stream; + + + // This is a user type, or a precanned resource. Find type + // table index. If not there, add new element. + string typeName; + if (type == typeof(PrecannedResource)) { + typeName = ((PrecannedResource)value).TypeName; + if (typeName.StartsWith("ResourceTypeCode.", StringComparison.Ordinal)) { + typeName = typeName.Substring(17); // Remove through '.' + ResourceTypeCode typeCode = (ResourceTypeCode)Enum.Parse(typeof(ResourceTypeCode), typeName); + return typeCode; + } + } + else + { + typeName = MultitargetingHelpers.GetAssemblyQualifiedName(type, TypeNameConverter); + } + + int typeIndex = types.IndexOf(typeName); + if (typeIndex == -1) { + typeIndex = types.Count; + types.Add(typeName); + } + + return (ResourceTypeCode)(typeIndex + ResourceTypeCode.StartOfUserTypes); + } + + private void WriteValue(ResourceTypeCode typeCode, object value, BinaryWriter writer) + { + Contract.Requires(writer != null); + + switch (typeCode) + { + case ResourceTypeCode.Null: + break; + + case ResourceTypeCode.String: + writer.Write((string)value); + break; + + case ResourceTypeCode.Boolean: + writer.Write((bool)value); + break; + + case ResourceTypeCode.Char: + writer.Write((ushort)(char)value); + break; + + case ResourceTypeCode.Byte: + writer.Write((byte)value); + break; + + case ResourceTypeCode.SByte: + writer.Write((sbyte)value); + break; + + case ResourceTypeCode.Int16: + writer.Write((short)value); + break; + + case ResourceTypeCode.UInt16: + writer.Write((ushort)value); + break; + + case ResourceTypeCode.Int32: + writer.Write((int)value); + break; + + case ResourceTypeCode.UInt32: + writer.Write((uint)value); + break; + + case ResourceTypeCode.Int64: + writer.Write((long)value); + break; + + case ResourceTypeCode.UInt64: + writer.Write((ulong)value); + break; + + case ResourceTypeCode.Single: + writer.Write((float)value); + break; + + case ResourceTypeCode.Double: + writer.Write((double)value); + break; + + case ResourceTypeCode.Decimal: + writer.Write((decimal)value); + break; + + case ResourceTypeCode.DateTime: + // Use DateTime's ToBinary & FromBinary. + long data = ((DateTime)value).ToBinary(); + writer.Write(data); + break; + + case ResourceTypeCode.TimeSpan: + writer.Write(((TimeSpan)value).Ticks); + break; + + // Special Types + case ResourceTypeCode.ByteArray: + { + byte[] bytes = (byte[])value; + writer.Write(bytes.Length); + writer.Write(bytes, 0, bytes.Length); + break; + } + + case ResourceTypeCode.Stream: + { + StreamWrapper sw = (StreamWrapper)value; + if (sw.Stream.GetType() == typeof(MemoryStream)) + { + MemoryStream ms = (MemoryStream)sw.Stream; + if (ms.Length > int.MaxValue) + throw new ArgumentException(SR.ArgumentOutOfRange_StreamLength); + byte[] arr = ms.ToArray(); + writer.Write(arr.Length); + writer.Write(arr, 0, arr.Length); + } + else + { + Stream s = sw.Stream; + // we've already verified that the Stream is seekable + if (s.Length > int.MaxValue) + throw new ArgumentException(SR.ArgumentOutOfRange_StreamLength); + + s.Position = 0; + writer.Write((int)s.Length); + byte[] buffer = new byte[4096]; + int read = 0; + while ((read = s.Read(buffer, 0, buffer.Length)) != 0) + { + writer.Write(buffer, 0, read); + } + if (sw.CloseAfterWrite) + { + s.Close(); + } + } + break; + } + + default: + Contract.Assert(typeCode >= ResourceTypeCode.StartOfUserTypes, string.Format(CultureInfo.InvariantCulture, "ResourceReader: Unsupported ResourceTypeCode in .resources file! {0}", typeCode)); + throw new PlatformNotSupportedException(SR.NotSupported_BinarySerializedResources); + } + } + } + + [Serializable] + internal enum ResourceTypeCode { + // Primitives + Null = 0, + String = 1, + Boolean = 2, + Char = 3, + Byte = 4, + SByte = 5, + Int16 = 6, + UInt16 = 7, + Int32 = 8, + UInt32 = 9, + Int64 = 0xa, + UInt64 = 0xb, + Single = 0xc, + Double = 0xd, + Decimal = 0xe, + DateTime = 0xf, + TimeSpan = 0x10, + + // A meta-value - change this if you add new primitives + LastPrimitive = TimeSpan, + + // Types with a special representation, like byte[] and Stream + ByteArray = 0x20, + Stream = 0x21, + + // User types - serialized using the binary formatter. + StartOfUserTypes = 0x40 } } diff --git a/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs b/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs index 8fa59d799d4..5e4a21e13b3 100644 --- a/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs +++ b/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs @@ -10,12 +10,12 @@ using System.Diagnostics; namespace System.Resources { //internal sealed class FastResourceComparer : IComparer, IEqualityComparer, IComparer, IEqualityComparer - internal sealed class FastResourceComparer :IComparer, IEqualityComparer + internal sealed class FastResourceComparer :IComparer, IEqualityComparer { internal static readonly FastResourceComparer Default = new FastResourceComparer(); - public int GetHashCode(String key) + public int GetHashCode(string key) { return FastResourceComparer.HashFunction(key); } @@ -23,7 +23,7 @@ namespace System.Resources // This hash function MUST be publicly documented with the resource // file format, AND we may NEVER change this hash function's return // value (without changing the file format). - internal static int HashFunction(String key) + internal static int HashFunction(string key) { // Never change this hash function. We must standardize it so that // others can read & write our .resources files. Additionally, we @@ -34,14 +34,14 @@ namespace System.Resources return (int)hash; } - public int Compare(String a, String b) + public int Compare(string a, string b) { - return String.CompareOrdinal(a, b); + return string.CompareOrdinal(a, b); } - public bool Equals(String a, String b) + public bool Equals(string a, string b) { - return String.Equals(a, b); + return string.Equals(a, b); } diff --git a/src/libraries/System.Resources.Writer/src/System/Runtime/Versioning/MultitargetingHelpers.cs b/src/libraries/System.Resources.Writer/src/System/Runtime/Versioning/MultitargetingHelpers.cs new file mode 100644 index 00000000000..362cc413127 --- /dev/null +++ b/src/libraries/System.Resources.Writer/src/System/Runtime/Versioning/MultitargetingHelpers.cs @@ -0,0 +1,60 @@ +using System; +using System.IO; +using System.Text; +using System.Diagnostics.Contracts; + +namespace System.Runtime.Versioning +{ + + internal static class MultitargetingHelpers + { + // This method gets assembly info for the corresponding type. If the typeConverter + // is provided it is used to get this information. + internal static string GetAssemblyQualifiedName(Type type, Func converter) + { + string assemblyFullName = null; + + if (type != null) + { + if (converter != null) + { + try + { + assemblyFullName = converter(type); + // TODO: validate that type and assembly names are well constructed - throw if not. + } + catch (Exception e) + { + if (IsSecurityOrCriticalException(e)) + { + throw; + } + } + } + + if (assemblyFullName == null) + { + assemblyFullName = type.AssemblyQualifiedName; + } + } + + return assemblyFullName; + } + + private static bool IsCriticalException(Exception ex) + { + return ex is NullReferenceException + || ex is StackOverflowException + || ex is OutOfMemoryException + //|| ex is System.Threading.ThreadAbortException + || ex is IndexOutOfRangeException + || ex is AccessViolationException; + } + + private static bool IsSecurityOrCriticalException(Exception ex) + { + return (ex is System.Security.SecurityException) || IsCriticalException(ex); + } + + } +} diff --git a/src/libraries/System.Resources.Writer/src/project.json b/src/libraries/System.Resources.Writer/src/project.json index 12f7a82691b..b0ca91352e2 100644 --- a/src/libraries/System.Resources.Writer/src/project.json +++ b/src/libraries/System.Resources.Writer/src/project.json @@ -1,22 +1,21 @@ { "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", - "System.Collections": "4.0.0", - "System.Diagnostics.Contracts": "4.0.0", - "System.Diagnostics.Debug": "4.0.0", - "System.Diagnostics.Tools": "4.0.0", - "System.IO": "4.0.0", - "System.Resources.ResourceManager": "4.0.0", - "System.Runtime": "4.0.20", - "System.Runtime.Extensions": "4.0.0", - "System.Text.Encoding": "4.0.0", - "System.Threading": "4.0.0" + "System.Collections": "4.4.0-beta-24612-03", + "System.Diagnostics.Contracts": "4.4.0-beta-24612-03", + "System.Diagnostics.Debug": "4.4.0-beta-24612-03", + "System.Diagnostics.Tools": "4.4.0-beta-24612-03", + "System.Globalization": "4.4.0-beta-24612-03", + "System.IO": "4.4.0-beta-24612-03", + "System.IO.FileSystem": "4.4.0-beta-24612-03", + "System.IO.FileSystem.Primitives": "4.4.0-beta-24612-03", + "System.Runtime": "4.4.0-beta-24612-03", + "System.Runtime.Extensions": "4.4.0-beta-24612-03", + "System.Text.Encoding": "4.4.0-beta-24612-03", + "System.Threading": "4.4.0-beta-24612-03", + "System.Threading.Tasks": "4.4.0-beta-24612-03" }, "frameworks": { - "netstandard1.3": { - "imports": [ - "dotnet5.4" - ] - } + "netstandard1.7": {} } } diff --git a/src/libraries/System.Resources.Writer/tests/ResourceWriterUnitTest.cs b/src/libraries/System.Resources.Writer/tests/ResourceWriterUnitTest.cs index 53b7f5cf941..5f7e382a4da 100644 --- a/src/libraries/System.Resources.Writer/tests/ResourceWriterUnitTest.cs +++ b/src/libraries/System.Resources.Writer/tests/ResourceWriterUnitTest.cs @@ -129,8 +129,8 @@ namespace System.Resources.ResourceWriterTests [Fact] public static void GenerateResources() { - byte[] buffer = new byte[_RefBuffer.Length]; - using (var ms2 = new MemoryStream(buffer, true)) + byte[] buffer; + using (var ms2 = new MemoryStream()) { using (var rw = new ResourceWriter(ms2)) { @@ -144,10 +144,9 @@ namespace System.Resources.ResourceWriterTests rw.Generate(); } + buffer = ms2.ToArray(); } - - bool hError = buffer.SequenceEqual(_RefBuffer); - Assert.True(hError, "The generated Resource does not match the reference"); + Assert.Equal(_RefBuffer, buffer); } } diff --git a/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.builds b/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.builds index 0daa76a6158..dafb05519d9 100644 --- a/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.builds +++ b/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.builds @@ -3,10 +3,14 @@ + + netstandard1.3 + netcoreapp1.0 + Windows_NT netcore50;net46 - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.csproj b/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.csproj index a4843450670..695a8e8dc18 100644 --- a/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.csproj +++ b/src/libraries/System.Resources.Writer/tests/System.Resources.Writer.Tests.csproj @@ -8,7 +8,7 @@ Library System.Resources.Writer.Tests System.Resources.Writer.Tests - .NETStandard,Version=v1.3 + .NETStandard,Version=v1.7 @@ -20,10 +20,13 @@ + + System.Resources.ResourceManager + {16EE5522-F387-4C9E-9EF2-B5134B043F37} System.Resources.Writer - \ No newline at end of file + diff --git a/src/libraries/System.Resources.Writer/tests/project.json b/src/libraries/System.Resources.Writer/tests/project.json index 092fa73ad6f..d18a6b6bddb 100644 --- a/src/libraries/System.Resources.Writer/tests/project.json +++ b/src/libraries/System.Resources.Writer/tests/project.json @@ -17,7 +17,8 @@ "Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00830-02" }, "frameworks": { - "netstandard1.3": {} + "netstandard1.3": {}, + "netstandard1.7": {} }, "supports": { "coreFx.Test.netcore50": {}, diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index 0d86951b0dd..c11bcf4eb00 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -25,6 +25,95 @@ namespace System public DllNotFoundException(string message, System.Exception inner) { } } } +namespace System.IO +{ + public partial class UnmanagedMemoryAccessor : System.IDisposable + { + protected UnmanagedMemoryAccessor() { } + public UnmanagedMemoryAccessor(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long capacity) { } + public UnmanagedMemoryAccessor(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long capacity, System.IO.FileAccess access) { } + public bool CanRead { get { return default(bool); } } + public bool CanWrite { get { return default(bool); } } + public long Capacity { get { return default(long); } } + protected bool IsOpen { get { return default(bool); } } + public void Dispose() { } + protected virtual void Dispose(bool disposing) { } + protected void Initialize(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long capacity, System.IO.FileAccess access) { } + public bool ReadBoolean(long position) { return default(bool); } + public byte ReadByte(long position) { return default(byte); } + public char ReadChar(long position) { return default(char); } + public decimal ReadDecimal(long position) { return default(decimal); } + public double ReadDouble(long position) { return default(double); } + public short ReadInt16(long position) { return default(short); } + public int ReadInt32(long position) { return default(int); } + public long ReadInt64(long position) { return default(long); } + [System.CLSCompliantAttribute(false)] + public sbyte ReadSByte(long position) { return default(sbyte); } + public float ReadSingle(long position) { return default(float); } + [System.CLSCompliantAttribute(false)] + public ushort ReadUInt16(long position) { return default(ushort); } + [System.CLSCompliantAttribute(false)] + public uint ReadUInt32(long position) { return default(uint); } + [System.CLSCompliantAttribute(false)] + public ulong ReadUInt64(long position) { return default(ulong); } + public void Read(long position, out T structure) where T : struct { throw null; } + public int ReadArray(long position, T[] array, int offset, int count) where T : struct { throw null; } + public void Write(long position, bool value) { } + public void Write(long position, byte value) { } + public void Write(long position, char value) { } + public void Write(long position, decimal value) { } + public void Write(long position, double value) { } + public void Write(long position, short value) { } + public void Write(long position, int value) { } + public void Write(long position, long value) { } + [System.CLSCompliantAttribute(false)] + public void Write(long position, sbyte value) { } + public void Write(long position, float value) { } + [System.CLSCompliantAttribute(false)] + public void Write(long position, ushort value) { } + [System.CLSCompliantAttribute(false)] + public void Write(long position, uint value) { } + [System.CLSCompliantAttribute(false)] + public void Write(long position, ulong value) { } + public void Write(long position, ref T structure) where T : struct { throw null; } + public void WriteArray(long position, T[] array, int offset, int count) where T : struct { throw null; } + } + public partial class UnmanagedMemoryStream : System.IO.Stream + { + protected UnmanagedMemoryStream() { } + [System.CLSCompliantAttribute(false)] + [System.Security.SecurityCriticalAttribute] + public unsafe UnmanagedMemoryStream(byte* pointer, long length) { } + [System.CLSCompliantAttribute(false)] + [System.Security.SecurityCriticalAttribute] + public unsafe UnmanagedMemoryStream(byte* pointer, long length, long capacity, System.IO.FileAccess access) { } + public UnmanagedMemoryStream(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length) { } + public UnmanagedMemoryStream(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length, System.IO.FileAccess access) { } + public override bool CanRead { get { return default(bool); } } + public override bool CanSeek { get { return default(bool); } } + public override bool CanWrite { get { return default(bool); } } + public long Capacity { get { return default(long); } } + public override long Length { get { return default(long); } } + public override long Position { get { return default(long); } set { } } + [System.CLSCompliantAttribute(false)] + public unsafe byte* PositionPointer {[System.Security.SecurityCriticalAttribute]get { return default(byte*); }[System.Security.SecurityCriticalAttribute]set { } } + protected override void Dispose(bool disposing) { } + public override void Flush() { } + public override System.Threading.Tasks.Task FlushAsync(System.Threading.CancellationToken cancellationToken) { return default(System.Threading.Tasks.Task); } + [System.CLSCompliantAttribute(false)] + [System.Security.SecurityCriticalAttribute] + protected unsafe void Initialize(byte* pointer, long length, long capacity, System.IO.FileAccess access) { } + protected void Initialize(System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length, System.IO.FileAccess access) { } + public override int Read(byte[] buffer, int offset, int count) { buffer = default(byte[]); return default(int); } + public override System.Threading.Tasks.Task ReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { return default(System.Threading.Tasks.Task); } + public override int ReadByte() { return default(int); } + public override long Seek(long offset, System.IO.SeekOrigin loc) { return default(long); } + public override void SetLength(long value) { } + public override void Write(byte[] buffer, int offset, int count) { } + public override System.Threading.Tasks.Task WriteAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { return default(System.Threading.Tasks.Task); } + public override void WriteByte(byte value) { } + } +} namespace System.Runtime.CompilerServices { [System.AttributeUsageAttribute((System.AttributeTargets)(2304), Inherited=false)] diff --git a/src/libraries/System.Runtime.InteropServices/ref/project.json b/src/libraries/System.Runtime.InteropServices/ref/project.json index b08635f2944..18c50952c68 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/project.json +++ b/src/libraries/System.Runtime.InteropServices/ref/project.json @@ -3,7 +3,7 @@ "System.Reflection": "4.4.0-beta-24612-03", "System.Reflection.Primitives": "4.4.0-beta-24612-03", "System.Runtime": "4.4.0-beta-24612-03", - "System.Runtime.Handles": "4.0.0" + "System.Runtime.Handles": "4.4.0-beta-24612-03" }, "frameworks": { "netstandard1.7": { diff --git a/src/libraries/System.Runtime.WindowsRuntime/src/System.Runtime.WindowsRuntime.csproj b/src/libraries/System.Runtime.WindowsRuntime/src/System.Runtime.WindowsRuntime.csproj index 4ac15d8f32d..7f6a1c28d2e 100644 --- a/src/libraries/System.Runtime.WindowsRuntime/src/System.Runtime.WindowsRuntime.csproj +++ b/src/libraries/System.Runtime.WindowsRuntime/src/System.Runtime.WindowsRuntime.csproj @@ -67,7 +67,7 @@ uap101aot - + uap101aot diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 49d17d61920..c3b36aa32cd 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4340,6 +4340,13 @@ namespace System.IO public DirectoryNotFoundException(string message, System.Exception innerException) { } protected DirectoryNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } } + [Flags] + public enum FileAccess + { + Read = 1, + ReadWrite = 3, + Write = 2, + } public partial class FileLoadException : System.IO.IOException { public FileLoadException() { } diff --git a/src/libraries/System.Runtime/src/ApiCompatBaseline.uap101aot.txt b/src/libraries/System.Runtime/src/ApiCompatBaseline.uap101aot.txt index ddd01830140..f64da4f74a6 100644 --- a/src/libraries/System.Runtime/src/ApiCompatBaseline.uap101aot.txt +++ b/src/libraries/System.Runtime/src/ApiCompatBaseline.uap101aot.txt @@ -389,6 +389,7 @@ MembersMustExist : Member 'System.Globalization.TextInfo.ToTitleCase(System.Stri MembersMustExist : Member 'System.Globalization.ThaiBuddhistCalendar.AlgorithmType.get()' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'System.Globalization.UmAlQuraCalendar.AlgorithmType.get()' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'System.IO.DirectoryNotFoundException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract. +TypesMustExist : Type 'System.IO.FileAccess' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'System.IO.FileLoadException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'System.IO.FileLoadException.FusionLog.get()' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'System.IO.FileNotFoundException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract. diff --git a/src/libraries/pkg/Microsoft.Private.PackageBaseline/packageIndex.json b/src/libraries/pkg/Microsoft.Private.PackageBaseline/packageIndex.json index f65eda17837..9948ffbde6e 100644 --- a/src/libraries/pkg/Microsoft.Private.PackageBaseline/packageIndex.json +++ b/src/libraries/pkg/Microsoft.Private.PackageBaseline/packageIndex.json @@ -1856,7 +1856,7 @@ "AssemblyVersionInPackageVersion": { "4.0.0.0": "4.0.0", "4.0.1.0": "4.3.0", - "4.0.2.0": "4.4.0" + "4.1.0.0": "4.4.0" } }, "System.Resources.ResourceManager": { @@ -1869,7 +1869,7 @@ "4.0.0.0": "4.0.0", "4.0.1.0": "4.0.1", "4.0.2.0": "4.3.0", - "4.0.3.0": "4.4.0" + "4.1.0.0": "4.4.0" } }, "System.Resources.Writer": { @@ -1880,7 +1880,7 @@ "AssemblyVersionInPackageVersion": { "4.0.0.0": "4.0.0", "4.0.1.0": "4.3.0", - "4.0.2.0": "4.4.0" + "4.1.0.0": "4.4.0" } }, "System.Runtime": {