提交 59b16273 编写于 作者: C Charles Stoner

Merge remote-tracking branch 'upstream/master' into 1115030

Unicode Version Change in C# 6
==============================
The Roslyn compilers depend on the underlying platform for their Unicode behavior. As a practical matter, that means that the new compiler will reflect changes in the Unicode standard.
For example, the Unicode Katakana Middle Dot "・" (U+30FB) no longer works in identifiers in C# 6.
Its Unicode class was Pc (Punctuation, Connector) in Unicode 5.1 or older, but it changed to Po (Punctuation, Other) in Unicode 6.0.
See also https://github.com/ufcpp/UfcppSample/blob/master/BreakingChanges/VS2015_CS6/KatakanaMiddleDot.cs
\ No newline at end of file
......@@ -36,6 +36,7 @@ private CSharpSerializableCompilationOptions(SerializationInfo info, StreamingCo
usings: (string[])info.GetValue(UsingsString, typeof(string[])),
cryptoKeyContainer: info.GetString(CryptoKeyContainerString),
cryptoKeyFile: info.GetString(CryptoKeyFileString),
cryptoPublicKey: ((byte[])info.GetValue(CryptoPublicKeyString, typeof(byte[]))).AsImmutableOrNull(),
delaySign: (bool?)info.GetValue(DelaySignString, typeof(bool?)),
optimizationLevel: (OptimizationLevel)info.GetInt32(OptimizeString),
checkOverflow: info.GetBoolean(CheckOverflowString),
......
......@@ -39,6 +39,7 @@ public sealed class CSharpCompilationOptions : CompilationOptions, IEquatable<CS
bool allowUnsafe = false,
string cryptoKeyContainer = null,
string cryptoKeyFile = null,
ImmutableArray<byte> cryptoPublicKey = default(ImmutableArray<byte>),
bool? delaySign = null,
Platform platform = Platform.AnyCpu,
ReportDiagnostic generalDiagnosticOption = ReportDiagnostic.Default,
......@@ -51,7 +52,7 @@ public sealed class CSharpCompilationOptions : CompilationOptions, IEquatable<CS
AssemblyIdentityComparer assemblyIdentityComparer = null,
StrongNameProvider strongNameProvider = null)
: this(outputKind, moduleName, mainTypeName, scriptClassName, usings, optimizationLevel, checkOverflow, allowUnsafe,
cryptoKeyContainer, cryptoKeyFile, delaySign, platform, generalDiagnosticOption, warningLevel,
cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, platform, generalDiagnosticOption, warningLevel,
specificDiagnosticOptions, concurrentBuild,
extendedCustomDebugInformation: true,
xmlReferenceResolver: xmlReferenceResolver,
......@@ -76,6 +77,7 @@ public sealed class CSharpCompilationOptions : CompilationOptions, IEquatable<CS
bool allowUnsafe,
string cryptoKeyContainer,
string cryptoKeyFile,
ImmutableArray<byte> cryptoPublicKey,
bool? delaySign,
Platform platform,
ReportDiagnostic generalDiagnosticOption,
......@@ -90,7 +92,7 @@ public sealed class CSharpCompilationOptions : CompilationOptions, IEquatable<CS
StrongNameProvider strongNameProvider,
MetadataImportOptions metadataImportOptions,
ImmutableArray<string> features)
: base(outputKind, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, delaySign, optimizationLevel, checkOverflow,
: base(outputKind, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, optimizationLevel, checkOverflow,
platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions.ToImmutableDictionaryOrEmpty(),
concurrentBuild, extendedCustomDebugInformation, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer,
strongNameProvider, metadataImportOptions, features)
......@@ -110,6 +112,7 @@ public sealed class CSharpCompilationOptions : CompilationOptions, IEquatable<CS
allowUnsafe: other.AllowUnsafe,
cryptoKeyContainer: other.CryptoKeyContainer,
cryptoKeyFile: other.CryptoKeyFile,
cryptoPublicKey: other.CryptoPublicKey,
delaySign: other.DelaySign,
platform: other.Platform,
generalDiagnosticOption: other.GeneralDiagnosticOption,
......@@ -187,6 +190,16 @@ public CSharpCompilationOptions WithCryptoKeyFile(string path)
return new CSharpCompilationOptions(this) { CryptoKeyFile = path };
}
public CSharpCompilationOptions WithCryptoPublicKey(ImmutableArray<byte> value)
{
if (value == this.CryptoPublicKey)
{
return this;
}
return new CSharpCompilationOptions(this) { CryptoPublicKey = value };
}
public CSharpCompilationOptions WithDelaySign(bool? value)
{
if (value == this.DelaySign)
......@@ -461,7 +474,7 @@ internal override void ValidateOptions(ArrayBuilder<Diagnostic> builder)
if (!MainTypeName.IsValidClrTypeName())
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "MainTypeName", MainTypeName));
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MainTypeName), MainTypeName));
}
}
......@@ -472,7 +485,7 @@ internal override void ValidateOptions(ArrayBuilder<Diagnostic> builder)
if (ModuleName != null)
{
Exception e = MetadataHelpers.CheckAssemblyOrModuleName(ModuleName, "ModuleName");
Exception e = MetadataHelpers.CheckAssemblyOrModuleName(ModuleName, nameof(ModuleName));
if (e != null)
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOption, e.Message));
......@@ -481,27 +494,27 @@ internal override void ValidateOptions(ArrayBuilder<Diagnostic> builder)
if (!OutputKind.IsValid())
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "OutputKind", OutputKind.ToString()));
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OutputKind), OutputKind.ToString()));
}
if (!OptimizationLevel.IsValid())
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "OptimizationLevel", OptimizationLevel.ToString()));
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OptimizationLevel), OptimizationLevel.ToString()));
}
if (ScriptClassName == null || !ScriptClassName.IsValidClrTypeName())
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "ScriptClassName", ScriptClassName ?? "null"));
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(ScriptClassName), ScriptClassName ?? "null"));
}
if (WarningLevel < 0 || WarningLevel > 4)
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "WarningLevel", WarningLevel));
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(WarningLevel), WarningLevel));
}
if (Usings != null && Usings.Any(u => !u.IsValidClrNamespaceName()))
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "Usings", Usings.Where(u => !u.IsValidClrNamespaceName()).First() ?? "null"));
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(Usings), Usings.Where(u => !u.IsValidClrNamespaceName()).First() ?? "null"));
}
if (Platform == Platform.AnyCpu32BitPreferred && OutputKind.IsValid() && !(OutputKind == OutputKind.ConsoleApplication || OutputKind == OutputKind.WindowsApplication || OutputKind == OutputKind.WindowsRuntimeApplication))
......@@ -512,6 +525,19 @@ internal override void ValidateOptions(ArrayBuilder<Diagnostic> builder)
// TODO: add check for
// (kind == 'arm' || kind == 'appcontainer' || kind == 'winmdobj') &&
// (version >= "6.2")
if (!CryptoPublicKey.IsDefault)
{
if (CryptoKeyFile != null)
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_MutuallyExclusiveOptions, nameof(CryptoPublicKey), nameof(CryptoKeyFile)));
}
if (CryptoKeyContainer != null)
{
builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_MutuallyExclusiveOptions, nameof(CryptoPublicKey), nameof(CryptoKeyContainer)));
}
}
}
public bool Equals(CSharpCompilationOptions other)
......
......@@ -5785,6 +5785,15 @@ internal class CSharpResources {
}
}
/// <summary>
/// Looks up a localized string similar to Compilation options &apos;{0}&apos; and &apos;{1}&apos; can&apos;t both be specified at the same time..
/// </summary>
internal static string ERR_MutuallyExclusiveOptions {
get {
return ResourceManager.GetString("ERR_MutuallyExclusiveOptions", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Named attribute argument expected.
/// </summary>
......
......@@ -4113,6 +4113,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_EncReferenceToAddedMember" xml:space="preserve">
<value>Member '{0}' added during the current debug session can only be accessed from within its declaring assembly '{1}'.</value>
</data>
<data name="ERR_MutuallyExclusiveOptions" xml:space="preserve">
<value>Compilation options '{0}' and '{1}' can't both be specified at the same time.</value>
</data>
<data name="ERR_LinkedNetmoduleMetadataMustProvideFullPEImage" xml:space="preserve">
<value>Linked netmodule metadata must provide a full PE image: '{0}'.</value>
</data>
......
......@@ -14,7 +14,6 @@
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Instrumentation;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
......@@ -78,38 +77,35 @@ internal partial class DocumentationCommentCompiler : CSharpSymbolVisitor
/// <param name="filterSpanWithinTree">If <paramref name="filterTree"/> and filterSpanWithinTree is non-null, report diagnostics within this span in the <paramref name="filterTree"/>.</param>
public static void WriteDocumentationCommentXml(CSharpCompilation compilation, string assemblyName, Stream xmlDocStream, DiagnosticBag diagnostics, CancellationToken cancellationToken, SyntaxTree filterTree = null, TextSpan? filterSpanWithinTree = null)
{
using (Logger.LogBlock(FunctionId.CSharp_DocumentationCommentCompiler_WriteDocumentationCommentXml, message: compilation.AssemblyName, cancellationToken: cancellationToken))
StreamWriter writer = null;
if (xmlDocStream != null && xmlDocStream.CanWrite)
{
StreamWriter writer = null;
if (xmlDocStream != null && xmlDocStream.CanWrite)
{
writer = new StreamWriter(
stream: xmlDocStream,
encoding: new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false),
bufferSize: 0x400, // Default.
leaveOpen: true); // Don't close caller's stream.
}
writer = new StreamWriter(
stream: xmlDocStream,
encoding: new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false),
bufferSize: 0x400, // Default.
leaveOpen: true); // Don't close caller's stream.
}
using (writer)
{
var compiler = new DocumentationCommentCompiler(assemblyName ?? compilation.SourceAssembly.Name, compilation, writer, filterTree, filterSpanWithinTree,
processIncludes: true, isForSingleSymbol: false, diagnostics: diagnostics, cancellationToken: cancellationToken);
compiler.Visit(compilation.SourceAssembly.GlobalNamespace);
Debug.Assert(compiler._indentDepth == 0);
}
using (writer)
{
var compiler = new DocumentationCommentCompiler(assemblyName ?? compilation.SourceAssembly.Name, compilation, writer, filterTree, filterSpanWithinTree,
processIncludes: true, isForSingleSymbol: false, diagnostics: diagnostics, cancellationToken: cancellationToken);
compiler.Visit(compilation.SourceAssembly.GlobalNamespace);
Debug.Assert(compiler._indentDepth == 0);
}
if (filterTree != null)
if (filterTree != null)
{
// Will respect the DocumentationMode.
UnprocessedDocumentationCommentFinder.ReportUnprocessed(filterTree, filterSpanWithinTree, diagnostics, cancellationToken);
}
else
{
foreach (SyntaxTree tree in compilation.SyntaxTrees)
{
// Will respect the DocumentationMode.
UnprocessedDocumentationCommentFinder.ReportUnprocessed(filterTree, filterSpanWithinTree, diagnostics, cancellationToken);
}
else
{
foreach (SyntaxTree tree in compilation.SyntaxTrees)
{
// Will respect the DocumentationMode.
UnprocessedDocumentationCommentFinder.ReportUnprocessed(tree, null, diagnostics, cancellationToken);
}
UnprocessedDocumentationCommentFinder.ReportUnprocessed(tree, null, diagnostics, cancellationToken);
}
}
}
......
......@@ -4,7 +4,6 @@
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Emit;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.Instrumentation;
#if DEBUG
using Roslyn.Utilities;
......@@ -42,11 +41,8 @@ private SynthesizedMetadataCompiler(PEModuleBuilder moduleBeingBuilt, Cancellati
{
Debug.Assert(moduleBeingBuilt != null);
using (Logger.LogBlock(FunctionId.CSharp_Compiler_CompileSynthesizedMethodMetadata, message: compilation.AssemblyName, cancellationToken: cancellationToken))
{
var compiler = new SynthesizedMetadataCompiler(moduleBeingBuilt, cancellationToken);
compiler.Visit(compilation.SourceModule.GlobalNamespace);
}
var compiler = new SynthesizedMetadataCompiler(moduleBeingBuilt, cancellationToken);
compiler.Visit(compilation.SourceModule.GlobalNamespace);
}
public override void VisitNamespace(NamespaceSymbol symbol)
......
......@@ -1230,6 +1230,7 @@ internal enum ErrorCode
ERR_MetadataReferencesNotSupported = 7099,
ERR_InvalidAssemblyCulture = 7100,
ERR_EncReferenceToAddedMember = 7101,
ERR_MutuallyExclusiveOptions = 7102,
// available 7102-8000
......
......@@ -138,6 +138,9 @@ public override ReportDiagnostic GetDiagnosticReport(DiagnosticInfo diagnosticIn
public override int INF_UnableToLoadSomeTypesInAnalyzer { get { return (int)ErrorCode.INF_UnableToLoadSomeTypesInAnalyzer; } }
public override int ERR_CantReadRulesetFile { get { return (int)ErrorCode.ERR_CantReadRulesetFile; } }
// compilation options:
public override int ERR_BadCompilationOptionValue { get { return (int)ErrorCode.ERR_BadCompilationOptionValue; } }
// emit options:
public override int ERR_InvalidDebugInformationFormat { get { return (int)ErrorCode.ERR_InvalidDebugInformationFormat; } }
public override int ERR_InvalidOutputName { get { return (int)ErrorCode.ERR_InvalidOutputName; } }
......
......@@ -28,7 +28,7 @@ Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(System.Collection
Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(params Microsoft.CodeAnalysis.MetadataReference[] references)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.AllowUnsafe.get
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, string moduleName = null, string mainTypeName = null, string scriptClassName = null, System.Collections.Generic.IEnumerable<string> usings = null, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel = Microsoft.CodeAnalysis.OptimizationLevel.Debug, bool checkOverflow = false, bool allowUnsafe = false, string cryptoKeyContainer = null, string cryptoKeyFile = null, bool? delaySign = null, Microsoft.CodeAnalysis.Platform platform = Microsoft.CodeAnalysis.Platform.AnyCpu, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption = Microsoft.CodeAnalysis.ReportDiagnostic.Default, int warningLevel = 4, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.CodeAnalysis.ReportDiagnostic>> specificDiagnosticOptions = null, bool concurrentBuild = true, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver = null, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver = null, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver = null, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer = null, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider = null)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, string moduleName = null, string mainTypeName = null, string scriptClassName = null, System.Collections.Generic.IEnumerable<string> usings = null, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel = Microsoft.CodeAnalysis.OptimizationLevel.Debug, bool checkOverflow = false, bool allowUnsafe = false, string cryptoKeyContainer = null, string cryptoKeyFile = null, System.Collections.Immutable.ImmutableArray<byte> cryptoPublicKey = default(System.Collections.Immutable.ImmutableArray<byte>), bool? delaySign = null, Microsoft.CodeAnalysis.Platform platform = Microsoft.CodeAnalysis.Platform.AnyCpu, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption = Microsoft.CodeAnalysis.ReportDiagnostic.Default, int warningLevel = 4, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.CodeAnalysis.ReportDiagnostic>> specificDiagnosticOptions = null, bool concurrentBuild = true, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver = null, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver = null, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver = null, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer = null, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider = null)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.Equals(Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions other)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.Usings.get
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithAllowUnsafe(bool enabled)
......@@ -36,6 +36,7 @@ Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithAssemblyIdentityCompa
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithConcurrentBuild(bool concurrentBuild)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithCryptoKeyContainer(string name)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithCryptoKeyFile(string path)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithCryptoPublicKey(System.Collections.Immutable.ImmutableArray<byte> value)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithDelaySign(bool? value)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithGeneralDiagnosticOption(Microsoft.CodeAnalysis.ReportDiagnostic value)
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithMainTypeName(string name)
......@@ -2462,7 +2463,6 @@ override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetDiagnostics(System.T
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetMethodBodyDiagnostics(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetParseDiagnostics(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSymbolsWithName(System.Func<string, bool> predicate, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.HasCodeToEmit()
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.IsCaseSensitive.get
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.Language.get
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ReferencedAssemblyNames.get
......@@ -4430,4 +4430,4 @@ virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult>.VisitYieldSta
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitLeadingTrivia(Microsoft.CodeAnalysis.SyntaxToken token)
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitToken(Microsoft.CodeAnalysis.SyntaxToken token)
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitTrailingTrivia(Microsoft.CodeAnalysis.SyntaxToken token)
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitTrivia(Microsoft.CodeAnalysis.SyntaxTrivia trivia)
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitTrivia(Microsoft.CodeAnalysis.SyntaxTrivia trivia)
\ No newline at end of file
......@@ -132,6 +132,11 @@ internal sealed class SourceAssemblySymbol : MetadataOrSourceAssemblySymbol, IAt
}
_modules = moduleBuilder.ToImmutableAndFree();
if (!compilation.Options.CryptoPublicKey.IsDefault)
{
_lazyStrongNameKeys = StrongNameKeys.Create(compilation.Options.CryptoPublicKey, MessageProvider.Instance);
}
}
public override string Name
......@@ -535,20 +540,24 @@ private void ValidateAttributeSemantics(DiagnosticBag diagnostics)
DetectAttributeAndOptionConflicts(diagnostics);
if (IsDelaySign && !Identity.HasPublicKey)
if (IsDelaySigned && !Identity.HasPublicKey)
{
diagnostics.Add(ErrorCode.WRN_DelaySignButNoKey, NoLocation.Singleton);
}
// A container cannot contain just the public key. So if we have the public
// key, no keyPair, and no container, then the public key came from a file
// that contained only that. In that case we cannot sign.
// If the options and attributes applied on the compilation imply real signing,
// but we have no private key to sign it with report an error.
// Note that if public key is set and delay sign is off we do OSS signing, which doesn't require private key.
// Consider: should we allow to OSS sign if the key file only contains public key?
if (DeclaringCompilation.Options.OutputKind != OutputKind.NetModule &&
Identity.HasPublicKey &&
!IsDelaySign &&
!StrongNameKeys.CanSign &&
DeclaringCompilation.Options.CryptoPublicKey.IsDefault&&
Identity.HasPublicKey&&
!IsDelaySigned &&
!StrongNameKeys.CanSign&&
StrongNameKeys.DiagnosticOpt == null)
{
// Since the container always contains both keys, the problem is that the key file didn't contain private key.
diagnostics.Add(ErrorCode.ERR_SignButNoPrivateKey, NoLocation.Singleton, StrongNameKeys.KeyFilePath);
}
......@@ -771,7 +780,7 @@ private void DetectAttributeAndOptionConflicts(DiagnosticBag diagnostics)
}
}
internal bool IsDelaySign
internal bool IsDelaySigned
{
get
{
......
......@@ -23,6 +23,7 @@ public void TestFieldsForEqualsAndGetHashCode()
"ConcurrentBuild",
"CryptoKeyContainer",
"CryptoKeyFile",
"CryptoPublicKey",
"DelaySign",
"EnableEditAndContinue",
"Errors",
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册