// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
usingSystem;
usingSystem.Collections.Immutable;
usingSystem.Diagnostics;
usingSystem.IO;
usingSystem.Text;
usingSystem.Threading;
usingRoslyn.Utilities;
namespaceMicrosoft.CodeAnalysis.Text
{
internalsealedclassEncodedStringText:SourceText
internalstaticclassEncodedStringText
{
/// <summary>
/// Underlying string on which this SourceText instance is based
/// Specifies an encoding to be used if the actual encoding can't be determined from the stream content (the stream doesn't start with Byte Order Mark).
/// If not specified auto-detect heuristics are used to determine the encoding. If these heuristics fail the decoding is assumed to be <see cref="Encoding.Default"/>.
/// Decode the given stream using the given encoding. Does not
/// close the stream afterwards.
/// </summary>
/// <param name="data">Data stream</param>
/// <param name="encoding">Default encoding to use for decoding.</param>
/// <param name="actualEncoding">Actual encoding used to read the text.</param>
/// <exception cref="DecoderFallbackException">If the given encoding is set to use <see cref="DecoderExceptionFallback"/> as its fallback decoder.</exception>
/// <returns>Decoded stream as a text string</returns>
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
static Microsoft.CodeAnalysis.Text.SourceText.CalculateChecksum(byte[] buffer, int offset, int count, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm algorithmId)
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
usingSystem;
usingSystem.Collections.Immutable;
usingSystem.IO;
usingSystem.Text;
...
...
@@ -123,21 +125,9 @@ private int GetIndexFromPosition(int position)
/// Hash algorithm to use to calculate checksum of the text that's saved to PDB.
/// </param>
/// <param name="throwIfBinaryDetected">If the decoded text contains at least two consecutive NUL
/// characters, then an <see cref="InvalidDataException"/> is thrown.</param>
/// <exception cref="ArgumentNullException"><paramref name="stream"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="stream"/> doesn't support reading or seeking.
/// <paramref name="checksumAlgorithm"/> is not supported.
/// </exception>
/// <exception cref="DecoderFallbackException">If the given encoding is set to use a throwing decoder as a fallback</exception>
/// <exception cref="InvalidDataException">Two consecutive NUL characters were detected in the decoded text and <paramref name="throwIfBinaryDetected"/> was true.</exception>
/// <param name="length">The number of bytes to read from the buffer.</param>
/// <param name="encoding">
/// Data encoding to use if the encoded buffer doesn't start with Byte Order Mark.
/// <see cref="Encoding.UTF8"/> if not specified.
/// </param>
/// <param name="checksumAlgorithm">
/// Hash algorithm to use to calculate checksum of the text that's saved to PDB.
/// </param>
/// <param name="throwIfBinaryDetected">If the decoded text contains at least two consecutive NUL
/// characters, then an <see cref="InvalidDataException"/> is thrown.</param>
/// <returns>The decoded text.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="buffer"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="length"/> is negative or longer than the <paramref name="buffer"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="checksumAlgorithm"/> is not supported.</exception>
/// <exception cref="DecoderFallbackException">If the given encoding is set to use a throwing decoder as a fallback</exception>
/// <exception cref="InvalidDataException">Two consecutive NUL characters were detected in the decoded text and <paramref name="throwIfBinaryDetected"/> was true.</exception>
@@ -3048,7 +3048,7 @@ Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.AddSyntaxTrees(trees A
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.ClassifyConversion(source As Microsoft.CodeAnalysis.ITypeSymbol, destination As Microsoft.CodeAnalysis.ITypeSymbol)
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.ContainsSyntaxTree(syntaxTree As Microsoft.CodeAnalysis.SyntaxTree)
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.GetSemanticModel(syntaxTree As Microsoft.CodeAnalysis.SyntaxTree, suppressAccessChecks As Boolean = False)
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.GetSemanticModel(syntaxTree As Microsoft.CodeAnalysis.SyntaxTree, ignoreAccessibility As Boolean = False)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetCompilationNamespace(namespaceSymbol As Microsoft.CodeAnalysis.INamespaceSymbol)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetEntryPoint(cancellationToken As System.Threading.CancellationToken)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetMetadataReference(_assemblySymbol As Microsoft.CodeAnalysis.IAssemblySymbol)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetSemanticModel(syntaxTree As Microsoft.CodeAnalysis.SyntaxTree, suppressAccessChecks As Boolean)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetSemanticModel(syntaxTree As Microsoft.CodeAnalysis.SyntaxTree, ignoreAccessibility As Boolean)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetSpecialType(specialType As Microsoft.CodeAnalysis.SpecialType)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetSubmissionResultType(ByRef hasValue As Boolean)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.CommonGetTypeByMetadataName(metadataName As String)
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// this cache logic is completely broken. cache can't be used in this way. if we didn't have an issue before that is just purely by luck.
// the reason it is broken is that, this method can be called from any place (no central call path so, can't figure out all the possible paths, but I confirmed that there
// are at least more than one path) from any workspace snapshot from any thread but the cache doesn't have any versioning or snapshot check,
// but regardless, this code updates the cache. which introduce a race where if code uses the cache in 2 different places in the same method, the return value might be different.
// and that is causing us to crash since one gets two completely different state.
//
// I tried to figure out how to fix this but, eventually gave up since it is so deeply spread in the code, I don't see any way to properly fix this.
// my conculusion is ripping out this code and re-write this state management code.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.