-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/dotnet/roslyn into format…
…perf
- Loading branch information
Showing
30 changed files
with
701 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Compilers/CSharp/Test/Emit/Attributes/EmitTestStrongNameProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.CodeAnalysis.CSharp.Test.Utilities; | ||
using System; | ||
using System.IO; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.UnitTests | ||
{ | ||
public partial class InternalsVisibleToAndStrongNameTests : CSharpTestBase | ||
{ | ||
/// <summary> | ||
/// A strong name provider which throws an IOException while creating | ||
/// the input stream. | ||
/// </summary> | ||
private class StrongNameProviderWithBadInputStream : StrongNameProvider | ||
{ | ||
private StrongNameProvider _underlyingProvider; | ||
public StrongNameProviderWithBadInputStream(StrongNameProvider underlyingProvider) | ||
{ | ||
_underlyingProvider = underlyingProvider; | ||
} | ||
|
||
public override bool Equals(object other) => this == other; | ||
|
||
public override int GetHashCode() => _underlyingProvider.GetHashCode(); | ||
|
||
internal override Stream CreateInputStream() | ||
{ | ||
throw new IOException("This is a test IOException"); | ||
} | ||
|
||
internal override StrongNameKeys CreateKeys(string keyFilePath, string keyContainerName, CommonMessageProvider messageProvider) => | ||
_underlyingProvider.CreateKeys(keyFilePath, keyContainerName, messageProvider); | ||
|
||
internal override void SignAssembly(StrongNameKeys keys, Stream inputStream, Stream outputStream) => | ||
_underlyingProvider.SignAssembly(keys, inputStream, outputStream); | ||
} | ||
|
||
[Fact] | ||
public void BadInputStream() | ||
{ | ||
string src = @" | ||
class C | ||
{ | ||
public static void Main(string[] args) { } | ||
}"; | ||
var testProvider = new StrongNameProviderWithBadInputStream(s_defaultProvider); | ||
var options = TestOptions.DebugExe | ||
.WithStrongNameProvider(testProvider) | ||
.WithCryptoKeyContainer("RoslynTestContainer"); | ||
|
||
var comp = CreateCompilationWithMscorlib(src, | ||
options: options); | ||
|
||
comp.VerifyEmitDiagnostics( | ||
// error CS7028: Error signing output with public key from container 'RoslynTestContainer' -- This is a test IOException | ||
Diagnostic(ErrorCode.ERR_PublicKeyContainerFailure).WithArguments("RoslynTestContainer", "This is a test IOException").WithLocation(1, 1)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/Compilers/VisualBasic/Test/Emit/Attributes/EmitTestStrongNameProvider.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
Imports System.IO | ||
Imports Microsoft.CodeAnalysis | ||
Imports Microsoft.CodeAnalysis.VisualBasic | ||
Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests | ||
|
||
Partial Public Class InternalsVisibleToAndStrongNameTests | ||
Inherits BasicTestBase | ||
|
||
Private Class StrongNameProviderWithBadInputStream | ||
Inherits StrongNameProvider | ||
Private _underlyingProvider As StrongNameProvider | ||
Public Sub New(underlyingProvider As StrongNameProvider) | ||
_underlyingProvider = underlyingProvider | ||
End Sub | ||
|
||
|
||
Public Overrides Function Equals(other As Object) As Boolean | ||
Return Me Is other | ||
End Function | ||
|
||
Public Overrides Function GetHashCode() As Integer | ||
Return _underlyingProvider.GetHashCode() | ||
End Function | ||
|
||
Friend Overrides Function CreateInputStream() As Stream | ||
Throw New IOException("This is a test IOException") | ||
End Function | ||
|
||
Friend Overrides Function CreateKeys(keyFilePath As String, keyContainerName As String, messageProvider As CommonMessageProvider) As StrongNameKeys | ||
Return _underlyingProvider.CreateKeys(keyFilePath, keyContainerName, messageProvider) | ||
End Function | ||
|
||
Friend Overrides Sub SignAssembly(keys As StrongNameKeys, inputStream As Stream, outputStream As Stream) | ||
_underlyingProvider.SignAssembly(keys, inputStream, outputStream) | ||
End Sub | ||
End Class | ||
|
||
<Fact> | ||
Public Sub BadInputStream() | ||
Dim testProvider = New StrongNameProviderWithBadInputStream(s_defaultProvider) | ||
Dim options = TestOptions.DebugDll.WithStrongNameProvider(testProvider).WithCryptoKeyContainer("RoslynTestContainer") | ||
|
||
Dim comp = CreateCompilationWithMscorlib( | ||
<compilation> | ||
<file name="a.vb"><![CDATA[ | ||
Public Class C | ||
Public Sub M() | ||
End Sub | ||
End Class | ||
]]> | ||
</file> | ||
</compilation>, options:=options) | ||
|
||
comp.VerifyEmitDiagnostics( | ||
Diagnostic(ERRID.ERR_PublicKeyContainerFailure).WithArguments("RoslynTestContainer", "This is a test IOException").WithLocation(1, 1)) | ||
End Sub | ||
|
||
End Class |
Oops, something went wrong.