Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Resources
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym committed Feb 9, 2018
1 parent dee5c34 commit c3a898a
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 262 deletions.
159 changes: 159 additions & 0 deletions src/System.IO.Pipelines/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AdvanceToInvalidCursor" xml:space="preserve">
<value>Pipe is already advanced past provided cursor.</value>
</data>
<data name="BackpressureDeadlock" xml:space="preserve">
<value>Advancing examined to the end would cause pipe to deadlock because FlushAsync is waiting.</value>
</data>
<data name="CannotAdvancePastCurrentBufferSize" xml:space="preserve">
<value>Can't advance past buffer size.</value>
</data>
<data name="CannotCompleteWhileReading" xml:space="preserve">
<value>Can't complete reader while reading.</value>
</data>
<data name="CannotCompleteWhiteWriting" xml:space="preserve">
<value>Can't complete writer while writing.</value>
</data>
<data name="ConcurrentOperationsNotSupported" xml:space="preserve">
<value>Concurrent reads or writes are not supported.</value>
</data>
<data name="GetResultBeforeCompleted" xml:space="preserve">
<value>Can't GetResult unless awaiter is completed.</value>
</data>
<data name="NoReadingOperationToComplete" xml:space="preserve">
<value>No reading operation to complete.</value>
</data>
<data name="NoWritingOperation" xml:space="preserve">
<value>No writing operation. Make sure GetMemory() was called.</value>
</data>
<data name="ReaderAndWriterHasToBeCompleted" xml:space="preserve">
<value>Both reader and writer has to be completed to be able to reset the pipe.</value>
</data>
<data name="ReadingAfterCompleted" xml:space="preserve">
<value>Reading is not allowed after reader was completed.</value>
</data>
<data name="ReadingIsInProgress" xml:space="preserve">
<value>Reading is already in progress.</value>
</data>
<data name="WritingAfterCompleted" xml:space="preserve">
<value>Writing is not allowed after writer was completed.</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/System.IO.Pipelines/src/System.IO.Pipelines.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="Properties\InternalsVisibleTo.cs" />
<Compile Include="System\IO\Pipelines\BufferSegment.cs" />
<Compile Include="System\IO\Pipelines\FlushResult.cs" />
<Compile Include="System\IO\Pipelines\InlineScheduler.cs" />
Expand All @@ -27,7 +28,6 @@
<Compile Include="System\IO\Pipelines\PipeWriter.cs" />
<Compile Include="System\IO\Pipelines\ReadResult.cs" />
<Compile Include="System\IO\Pipelines\ResultFlags.cs" />
<Compile Include="System\IO\Pipelines\SpanLiteralExtensions.cs" />
<Compile Include="System\IO\Pipelines\ThreadPoolScheduler.cs" />
<Compile Include="System\IO\Pipelines\ThrowHelper.cs" />
</ItemGroup>
Expand Down
23 changes: 4 additions & 19 deletions src/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,7 @@ public Pipe(PipeOptions options)
{
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}

if (options.ResumeWriterThreshold < 0)
{
throw new ArgumentOutOfRangeException(nameof(options.ResumeWriterThreshold));
}

if (options.PauseWriterThreshold < 0)
{
throw new ArgumentOutOfRangeException(nameof(options.PauseWriterThreshold));
}

if (options.ResumeWriterThreshold > options.PauseWriterThreshold)
{
throw new ArgumentException(nameof(options.PauseWriterThreshold) + " should be greater or equal to " + nameof(options.ResumeWriterThreshold), nameof(options.PauseWriterThreshold));
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.options);
}

_bufferSegmentPool = new BufferSegment[SegmentPoolSize];
Expand Down Expand Up @@ -482,7 +467,7 @@ internal void OnWriterCompleted(Action<Exception, object> callback, object state
{
if (callback == null)
{
throw new ArgumentNullException(nameof(callback));
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.callback);
}

PipeCompletionCallbacks completionCallbacks;
Expand Down Expand Up @@ -521,7 +506,7 @@ internal void OnReaderCompleted(Action<Exception, object> callback, object state
{
if (callback == null)
{
throw new ArgumentNullException(nameof(callback));
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.callback);
}

PipeCompletionCallbacks completionCallbacks;
Expand Down Expand Up @@ -763,7 +748,7 @@ public void Reset()
{
if (!_disposed)
{
throw new InvalidOperationException("Both reader and writer need to be completed to be able to reset ");
ThrowHelper.ThrowInvalidOperationException_ResetIncompleteReaderWriter();
}

_disposed = false;
Expand Down
11 changes: 11 additions & 0 deletions src/System.IO.Pipelines/src/System/IO/Pipelines/PipeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public class PipeOptions
long resumeWriterThreshold = 0,
int minimumSegmentSize = 2048)
{

if (resumeWriterThreshold < 0 && resumeWriterThreshold > pauseWriterThreshold)
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.resumeWriterThreshold);
}

if (pauseWriterThreshold < 0)
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.pauseWriterThreshold);
}

Pool = pool ?? MemoryPool<byte>.Shared;
ReaderScheduler = readerScheduler;
WriterScheduler = writerScheduler;
Expand Down
33 changes: 1 addition & 32 deletions src/System.IO.Pipelines/src/System/IO/Pipelines/PipeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,7 @@ public abstract class PipeWriter : IBufferWriter
/// </summary>
public virtual PipeAwaiter<FlushResult> WriteAsync(ReadOnlyMemory<byte> source)
{
Span<byte> destination = GetSpan();
var sourceSpan = source.Span;
// Fast path, try copying to the available memory directly
if (sourceSpan.Length <= destination.Length)
{
sourceSpan.CopyTo(destination);
Advance(sourceSpan.Length);
return FlushAsync();
}

var remaining = sourceSpan.Length;
var offset = 0;

while (remaining > 0)
{
var writable = Math.Min(remaining, destination.Length);

destination = GetSpan(writable);

if (writable == 0)
{
continue;
}

sourceSpan.Slice(offset, writable).CopyTo(destination);

remaining -= writable;
offset += writable;

Advance(writable);
}

this.Write(source.Span);
return FlushAsync();
}
}
Expand Down

This file was deleted.

0 comments on commit c3a898a

Please sign in to comment.