Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dotnet/roslyn into 4578-wildcard-…
Browse files Browse the repository at this point in the history
…deterministic
  • Loading branch information
TyOverby committed Sep 22, 2015
2 parents 4540068 + f0c1e47 commit ab4f4c4
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/Compilers/Core/Portable/CvtRes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using WCHAR = System.Char;
using WORD = System.UInt16;
using System.Reflection.PortableExecutable;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis
{
Expand Down Expand Up @@ -204,9 +205,9 @@ static internal Microsoft.Cci.ResourceSection ReadWin32ResourcesFromCOFF(Stream
var imageResourceSectionBytes = new byte[checked(rsrc1.SizeOfRawData + rsrc2.SizeOfRawData)];

stream.Seek(rsrc1.PointerToRawData, SeekOrigin.Begin);
stream.Read(imageResourceSectionBytes, 0, rsrc1.SizeOfRawData);
stream.TryReadAll(imageResourceSectionBytes, 0, rsrc1.SizeOfRawData); // ConfirmSectionValues ensured that data are available
stream.Seek(rsrc2.PointerToRawData, SeekOrigin.Begin);
stream.Read(imageResourceSectionBytes, rsrc1.SizeOfRawData, rsrc2.SizeOfRawData);
stream.TryReadAll(imageResourceSectionBytes, rsrc1.SizeOfRawData, rsrc2.SizeOfRawData); // ConfirmSectionValues ensured that data are available

const int SizeOfRelocationEntry = 10;

Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/EncodedStringText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private static bool TryGetByteArrayFromFileStream(Stream stream, out byte[] buff
// than the buffer size. The default buffer size is 4KB, so this will incur a 4KB
// allocation for any files less than 4KB. That's why, for example, the command
// line compiler actually specifies a very small buffer size.
return stream.Read(buffer, 0, length) == length;
return stream.TryReadAll(buffer, 0, length) == length;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ public void Commit(int grfCommitFlags)
_stream.Flush();
}

/// <summary>
/// The actual number of bytes read can be fewer than the number of bytes requested
/// if an error occurs or if the end of the stream is reached during the read operation.
/// </summary>
public unsafe void Read(byte[] pv, int cb, IntPtr pcbRead)
{
int bytesRead = _stream.Read(pv, 0, cb);
int bytesRead = _stream.TryReadAll(pv, 0, cb);

if (pcbRead != IntPtr.Zero)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/PEWriter/BlobWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public int WriteBytes(Stream source, int byteCount)
}

int start = Advance(byteCount);
int bytesRead = source.Read(_buffer, start, byteCount);
int bytesRead = source.TryReadAll(_buffer, start, byteCount);
_position = start + bytesRead;
return bytesRead;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\ComStreamWrapper.cs">
<Link>TestHelpers\ComStreamWrapper.cs</Link>
</Compile>
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\StreamExtensions.cs">
<Link>TestHelpers\StreamExtensions.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="TestHelpers\AssertEx.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ End Module</File>
Test(text, expected)
End Sub

<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
<ConditionalFact(GetType(x86))>
<Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
<WorkItem(5391, "https://github.com/dotnet/roslyn/issues/5391")>
Public Sub SuggestEscapedPredefinedTypes()
Dim text = <File>
Imports System
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public InteractiveAssemblyLoader(MetadataShadowCopyProvider shadowCopyProvider =
internal Assembly Load(Stream peStream, Stream pdbStream)
{
byte[] peImage = new byte[peStream.Length];
peStream.Read(peImage, 0, peImage.Length);
peStream.TryReadAll(peImage, 0, peImage.Length);
var assembly = CorLightup.Desktop.LoadAssembly(peImage);

RegisterDependency(assembly);
Expand Down
3 changes: 3 additions & 0 deletions src/Test/PdbUtilities/PdbUtilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\Hash.cs">
<Link>InternalUtilities\Hash.cs</Link>
</Compile>
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\StreamExtensions.cs">
<Link>InternalUtilities\StreamExtensions.cs</Link>
</Compile>
<Compile Include="..\..\Compilers\Core\Portable\PEWriter\CustomDebugInfoConstants.cs">
<Link>Shared\CustomDebugInfoConstants.cs</Link>
</Compile>
Expand Down
3 changes: 3 additions & 0 deletions src/Workspaces/Core/Desktop/Workspaces.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<Compile Include="..\..\..\Compilers\Core\Portable\EncodedStringText.cs">
<Link>InternalUtilities\EncodedStringText.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\StreamExtensions.cs">
<Link>InternalUtilities\StreamExtensions.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Helpers\CoreClrShim.cs">
<Link>InternalUtilities\CoreClrShim.cs</Link>
</Compile>
Expand Down
14 changes: 10 additions & 4 deletions src/Workspaces/Core/Portable/Workspace/Solution/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public SourceCodeKind SourceCodeKind

/// <summary>
/// Get the current syntax tree for the document if the text is already loaded and the tree is already parsed.
/// Returns true if the syntax tree is already available, or false if getting the syntax tree would have incurred additional work.
/// In almost all cases, you should call <see cref="GetSyntaxTreeAsync"/> to fetch the tree, which will parse the tree
/// if it's not already parsed.
/// </summary>
public bool TryGetSyntaxTree(out SyntaxTree syntaxTree)
{
Expand All @@ -88,7 +89,8 @@ public bool TryGetSyntaxTree(out SyntaxTree syntaxTree)

/// <summary>
/// Get the current syntax tree version for the document if the text is already loaded and the tree is already parsed.
/// Returns true if the syntax tree is already available, or false if getting the syntax tree would have incurred additional work.
/// In almost all cases, you should call <see cref="GetSyntaxVersionAsync"/> to fetch the version, which will load the tree
/// if it's not already available.
/// </summary>
public bool TryGetSyntaxVersion(out VersionStamp version)
{
Expand Down Expand Up @@ -199,7 +201,9 @@ public bool SupportsSemanticModel
}

/// <summary>
/// Gets the root node of the current syntax tree if it is available.
/// Gets the root node of the current syntax tree if the syntax tree has already been parsed and the tree is still cached.
/// In almost all cases, you should call <see cref="GetSyntaxRootAsync"/> to fetch the root node, which will parse
/// the document if necessary.
/// </summary>
public bool TryGetSyntaxRoot(out SyntaxNode root)
{
Expand All @@ -223,7 +227,9 @@ public bool TryGetSyntaxRoot(out SyntaxNode root)
}

/// <summary>
/// Gets the current semantic model for this document if the model is already computed.
/// Gets the current semantic model for this document if the model is already computed and still cached.
/// In almost all cases, you should call <see cref="GetSemanticModelAsync"/>, which will compute the semantic model
/// if necessary.
/// </summary>
public bool TryGetSemanticModel(out SemanticModel semanticModel)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Workspaces/Core/Portable/Workspace/Solution/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ private static TextDocument CreateAdditionalDocument(DocumentId documentId, Proj
}

/// <summary>
/// Get the <see cref="Compilation"/> for this project if it is available.
/// Tries to get the cached <see cref="Compilation"/> for this project if it has already been created and is still cached. In almost all
/// cases you should call <see cref="GetCompilationAsync"/> which will either return the cached <see cref="Compilation"/>
/// or create a new one otherwise.
/// </summary>
public bool TryGetCompilation(out Compilation compilation)
{
Expand Down

0 comments on commit ab4f4c4

Please sign in to comment.