Aracılığıyla paylaş


SourceText.From Method

Definition

Overloads

From(String, Encoding, SourceHashAlgorithm)

Constructs a SourceText from text in a string.

From(Stream, Encoding, SourceHashAlgorithm, Boolean)
From(TextReader, Int32, Encoding, SourceHashAlgorithm)

Constructs a SourceText from text in a string.

From(Byte[], Int32, Encoding, SourceHashAlgorithm, Boolean)
From(Stream, Encoding, SourceHashAlgorithm, Boolean, Boolean)

Constructs a SourceText from stream content.

From(Byte[], Int32, Encoding, SourceHashAlgorithm, Boolean, Boolean)

Constructs a SourceText from a byte array.

From(String, Encoding, SourceHashAlgorithm)

Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs

Constructs a SourceText from text in a string.

public static Microsoft.CodeAnalysis.Text.SourceText From (string text, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
public static Microsoft.CodeAnalysis.Text.SourceText From (string text, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
static member From : string * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (text As String, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1) As SourceText

Parameters

text
String

Text.

encoding
Encoding

Encoding of the file that the text was read from or is going to be saved to. null if the encoding is unspecified. If the encoding is not specified the resulting SourceText isn't debuggable. If an encoding-less SourceText is written to a file a UTF8 shall be used as a default.

checksumAlgorithm
SourceHashAlgorithm

Hash algorithm to use to calculate checksum of the text that's saved to PDB.

Returns

Exceptions

text is null.

checksumAlgorithm is not supported.

Applies to

From(Stream, Encoding, SourceHashAlgorithm, Boolean)

Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
public:
 static Microsoft::CodeAnalysis::Text::SourceText ^ From(System::IO::Stream ^ stream, System::Text::Encoding ^ encoding, Microsoft::CodeAnalysis::Text::SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding? encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
static member From : System.IO.Stream * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (stream As Stream, encoding As Encoding, checksumAlgorithm As SourceHashAlgorithm, throwIfBinaryDetected As Boolean) As SourceText

Parameters

stream
Stream
encoding
Encoding
checksumAlgorithm
SourceHashAlgorithm
throwIfBinaryDetected
Boolean

Returns

Attributes

Applies to

From(TextReader, Int32, Encoding, SourceHashAlgorithm)

Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs

Constructs a SourceText from text in a string.

public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.TextReader reader, int length, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.TextReader reader, int length, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
static member From : System.IO.TextReader * int * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (reader As TextReader, length As Integer, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1) As SourceText

Parameters

reader
TextReader

TextReader

length
Int32

length of content from reader

encoding
Encoding

Encoding of the file that the reader was read from or is going to be saved to. null if the encoding is unspecified. If the encoding is not specified the resulting SourceText isn't debuggable. If an encoding-less SourceText is written to a file a UTF8 shall be used as a default.

checksumAlgorithm
SourceHashAlgorithm

Hash algorithm to use to calculate checksum of the text that's saved to PDB.

Returns

Exceptions

reader is null.

checksumAlgorithm is not supported.

Applies to

From(Byte[], Int32, Encoding, SourceHashAlgorithm, Boolean)

Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
public:
 static Microsoft::CodeAnalysis::Text::SourceText ^ From(cli::array <System::Byte> ^ buffer, int length, System::Text::Encoding ^ encoding, Microsoft::CodeAnalysis::Text::SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding? encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
static member From : byte[] * int * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (buffer As Byte(), length As Integer, encoding As Encoding, checksumAlgorithm As SourceHashAlgorithm, throwIfBinaryDetected As Boolean) As SourceText

Parameters

buffer
Byte[]
length
Int32
encoding
Encoding
checksumAlgorithm
SourceHashAlgorithm
throwIfBinaryDetected
Boolean

Returns

Attributes

Applies to

From(Stream, Encoding, SourceHashAlgorithm, Boolean, Boolean)

Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs

Constructs a SourceText from stream content.

public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
static member From : System.IO.Stream * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (stream As Stream, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, Optional throwIfBinaryDetected As Boolean = false, Optional canBeEmbedded As Boolean = false) As SourceText

Parameters

stream
Stream

Stream. The stream must be seekable.

encoding
Encoding

Data encoding to use if the stream doesn't start with Byte Order Mark specifying the encoding. UTF8 if not specified.

checksumAlgorithm
SourceHashAlgorithm

Hash algorithm to use to calculate checksum of the text that's saved to PDB.

throwIfBinaryDetected
Boolean

If the decoded text contains at least two consecutive NUL characters, then an InvalidDataException is thrown.

canBeEmbedded
Boolean

True if the text can be passed to FromSource(String, SourceText) and be embedded in a PDB.

Returns

Exceptions

stream is null.

stream doesn't support reading or seeking. checksumAlgorithm is not supported.

If the given encoding is set to use a throwing decoder as a fallback

Two consecutive NUL characters were detected in the decoded text and throwIfBinaryDetected was true.

An I/O error occurs.

Remarks

Reads from the beginning of the stream. Leaves the stream open.

Applies to

From(Byte[], Int32, Encoding, SourceHashAlgorithm, Boolean, Boolean)

Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs
Source:
SourceText.cs

Constructs a SourceText from a byte array.

public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
static member From : byte[] * int * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (buffer As Byte(), length As Integer, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, Optional throwIfBinaryDetected As Boolean = false, Optional canBeEmbedded As Boolean = false) As SourceText

Parameters

buffer
Byte[]

The encoded source buffer.

length
Int32

The number of bytes to read from the buffer.

encoding
Encoding

Data encoding to use if the encoded buffer doesn't start with Byte Order Mark. UTF8 if not specified.

checksumAlgorithm
SourceHashAlgorithm

Hash algorithm to use to calculate checksum of the text that's saved to PDB.

throwIfBinaryDetected
Boolean

If the decoded text contains at least two consecutive NUL characters, then an InvalidDataException is thrown.

canBeEmbedded
Boolean

True if the text can be passed to FromSource(String, SourceText) and be embedded in a PDB.

Returns

The decoded text.

Exceptions

The buffer is null.

The length is negative or longer than the buffer.

checksumAlgorithm is not supported.

If the given encoding is set to use a throwing decoder as a fallback

Two consecutive NUL characters were detected in the decoded text and throwIfBinaryDetected was true.

Applies to