提交 43194716 编写于 作者: J Julien Couvreur 提交者: GitHub

Add commit SHA to version information (#17537)

上级 7a6d4e6a
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Choose>
<When Condition="'$(OfficialBuild)' != 'true'">
<!-- On non-official builds we don't burn in a git sha. In large part because it
hurts our determinism efforts as binaries which should be the same between
builds will not (due to developers building against different HEAD
values -->
<PropertyGroup>
<GitHeadSha>&lt;developer build&gt;</GitHeadSha>
</PropertyGroup>
</When>
<When Condition="'$(BUILD_SOURCEVERSION)' != ''">
<PropertyGroup>
<GitHeadSha>$(BUILD_SOURCEVERSION)</GitHeadSha>
</PropertyGroup>
</When>
<When Condition="'$(BUILD_SOURCEVERSION)' == '' AND '$(GIT_COMMIT)' != ''">
<PropertyGroup>
<GitHeadSha>$(GIT_COMMIT)</GitHeadSha>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<GitHeadSha>Not found</GitHeadSha>
<DotGitDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../../.git'))</DotGitDir>
<HeadFileContent Condition="Exists('$(DotGitDir)/HEAD')">$([System.IO.File]::ReadAllText('$(DotGitDir)/HEAD').Trim())</HeadFileContent>
<RefPath Condition="$(HeadFileContent.StartsWith('ref: '))">$(DotGitDir)/$(HeadFileContent.Substring(5))</RefPath>
<GitHeadSha Condition="'$(RefPath)' != '' AND Exists('$(RefPath)')">$([System.IO.File]::ReadAllText('$(RefPath)').Trim())</GitHeadSha>
<GitHeadSha Condition="'$(HeadFileContent)' != '' AND '$(RefPath)' == ''">$(HeadFileContent)</GitHeadSha>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<GeneratedAssemblyInfoFile>$(IntermediateOutputPath)GeneratedAssemblyInfo_$(BuildVersion)$(DefaultLanguageSourceExtension)</GeneratedAssemblyInfoFile>
</PropertyGroup>
......@@ -114,4 +82,4 @@
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragmentEx>
</Target>
</Project>
\ No newline at end of file
</Project>
......@@ -72,4 +72,36 @@
</PropertyGroup>
</Otherwise>
</Choose>
<Choose>
<When Condition="'$(OfficialBuild)' != 'true'">
<!-- On non-official builds we don't burn in a git sha. In large part because it
hurts our determinism efforts as binaries which should be the same between
builds will not (due to developers building against different HEAD
values). -->
<PropertyGroup>
<GitHeadSha>&lt;developer build&gt;</GitHeadSha>
</PropertyGroup>
</When>
<When Condition="'$(BUILD_SOURCEVERSION)' != ''">
<PropertyGroup>
<GitHeadSha>$(BUILD_SOURCEVERSION)</GitHeadSha>
</PropertyGroup>
</When>
<When Condition="'$(BUILD_SOURCEVERSION)' == '' AND '$(GIT_COMMIT)' != ''">
<PropertyGroup>
<GitHeadSha>$(GIT_COMMIT)</GitHeadSha>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<GitHeadSha>Not found</GitHeadSha>
<DotGitDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../../.git'))</DotGitDir>
<HeadFileContent Condition="Exists('$(DotGitDir)/HEAD')">$([System.IO.File]::ReadAllText('$(DotGitDir)/HEAD').Trim())</HeadFileContent>
<RefPath Condition="$(HeadFileContent.StartsWith('ref: '))">$(DotGitDir)/$(HeadFileContent.Substring(5))</RefPath>
<GitHeadSha Condition="'$(RefPath)' != '' AND Exists('$(RefPath)')">$([System.IO.File]::ReadAllText('$(RefPath)').Trim())</GitHeadSha>
<GitHeadSha Condition="'$(HeadFileContent)' != '' AND '$(RefPath)' == ''">$(HeadFileContent)</GitHeadSha>
</PropertyGroup>
</Otherwise>
</Choose>
</Project>
......@@ -19,6 +19,11 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
<ItemGroup>
<AssemblyVersionAttribute Include="Microsoft.CodeAnalysis.CommitHashAttribute">
<_Parameter1>$(GitHeadSha)</_Parameter1>
</AssemblyVersionAttribute>
</ItemGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Tools\Source\CompilerGeneratorTools\DeployCompilerGeneratorToolsRuntime\DeployCompilerGeneratorToolsRuntime.csproj">
<Project>{6da08f12-32f2-4dd9-bbad-982eb71a2c9b}</Project>
......
......@@ -39,6 +39,8 @@ public class CommandLineTests : CSharpTestBase
private static readonly string s_CSharpCompilerExecutable = typeof(Csc).GetTypeInfo().Assembly.Location;
private static readonly string s_defaultSdkDirectory = RuntimeEnvironment.GetRuntimeDirectory();
private static readonly string s_compilerVersion = typeof(Csc).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
private static readonly string s_compilerShortCommitHash =
CommonCompiler.ExtractShortCommitHash(typeof(CSharpCompiler).GetTypeInfo().Assembly.GetCustomAttribute<CommitHashAttribute>().Hash);
private readonly string _baseDirectory = TempRoot.Root;
......@@ -5277,16 +5279,52 @@ class C
var csc = new MockCSharpCompiler(null, dir.Path, new[] { "/target:library", "/preferreduilang:en", "a.cs" });
int exitCode = csc.Run(outWriter);
Assert.Equal(0, exitCode);
var patched = Regex.Replace(outWriter.ToString().Trim(), "version \\d+\\.\\d+\\.\\d+(\\.\\d+)?", "version A.B.C.D");
patched = ReplaceCommitHash(patched);
Assert.Equal(@"
Microsoft (R) Visual C# Compiler version A.B.C.D
Microsoft (R) Visual C# Compiler version A.B.C.D (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.".Trim(),
Regex.Replace(outWriter.ToString().Trim(), "version \\d+\\.\\d+\\.\\d+(\\.\\d+)?", "version A.B.C.D"));
patched);
// Privately queued builds have 3-part version numbers instead of 4. Since we're throwing away the version number,
// making the last part optional will fix this.
CleanupAllGeneratedFiles(file.Path);
}
[Theory,
InlineData("Microsoft (R) Visual C# Compiler version A.B.C.D (<developer build>)",
"Microsoft (R) Visual C# Compiler version A.B.C.D (HASH)"),
InlineData("Microsoft (R) Visual C# Compiler version A.B.C.D (ABCDEF01)",
"Microsoft (R) Visual C# Compiler version A.B.C.D (HASH)"),
InlineData("Microsoft (R) Visual C# Compiler version A.B.C.D (abcdef90)",
"Microsoft (R) Visual C# Compiler version A.B.C.D (HASH)"),
InlineData("Microsoft (R) Visual C# Compiler version A.B.C.D (12345678)",
"Microsoft (R) Visual C# Compiler version A.B.C.D (HASH)")]
public void TestReplaceCommitHash(string orig, string expected)
{
Assert.Equal(expected, ReplaceCommitHash(orig));
}
private static string ReplaceCommitHash(string s)
{
// open paren, followed by either <developer build> or 8 hex, followed by close paren
return Regex.Replace(s, "(\\((<developer build>|[a-fA-F0-9]{8})\\))", "(HASH)");
}
[Fact]
public void ExtractShortCommitHash()
{
Assert.Null(CommonCompiler.ExtractShortCommitHash(null));
Assert.Equal("", CommonCompiler.ExtractShortCommitHash(""));
Assert.Equal("<", CommonCompiler.ExtractShortCommitHash("<"));
Assert.Equal("<developer build>", CommonCompiler.ExtractShortCommitHash("<developer build>"));
Assert.Equal("1", CommonCompiler.ExtractShortCommitHash("1"));
Assert.Equal("1234567", CommonCompiler.ExtractShortCommitHash("1234567"));
Assert.Equal("12345678", CommonCompiler.ExtractShortCommitHash("12345678"));
Assert.Equal("12345678", CommonCompiler.ExtractShortCommitHash("123456789"));
}
private void CheckOutputFileName(string source1, string source2, string inputName1, string inputName2, string[] commandLineArguments, string expectedOutputName)
{
var dir = Temp.CreateDirectory();
......@@ -6980,7 +7018,7 @@ public void FileShareDeleteCompatibility_Xplat()
var output = ProcessUtilities.RunAndGetOutput(s_CSharpCompilerExecutable, $"/target:library /debug:portable {libSrc.Path}", startFolder: dir.ToString());
AssertEx.AssertEqualToleratingWhitespaceDifferences($@"
Microsoft (R) Visual C# Compiler version {s_compilerVersion}
Microsoft (R) Visual C# Compiler version {s_compilerVersion} ({s_compilerShortCommitHash })
Copyright (C) Microsoft Corporation. All rights reserved.", output);
// reading original content from the memory map:
......@@ -8829,7 +8867,7 @@ public void PathMapParser()
public void Version()
{
var folderName = Temp.CreateDirectory().ToString();
var expected = FileVersionInfo.GetVersionInfo(typeof(CSharpCompiler).Assembly.Location).FileVersion;
var expected = $"{FileVersionInfo.GetVersionInfo(typeof(CSharpCompiler).Assembly.Location).FileVersion} ({s_compilerShortCommitHash})";
var argss = new[]
{
"/version",
......
......@@ -29,6 +29,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Compile Include="CommitHashAttribute.cs" />
<Compile Include="DiagnosticAnalyzer\AnalyzerManager.AnalyzerExecutionContext.cs" />
<Compile Include="InternalUtilities\CommandLineUtilities.cs" />
<Compile Include="InternalUtilities\GeneratedCodeUtilities.cs" />
......
......@@ -130,14 +130,29 @@ internal virtual string GetAssemblyFileVersion()
{
if (_clientDirectory != null)
{
var name = $"{Type.GetTypeInfo().Assembly.GetName().Name}.dll";
Assembly assembly = Type.GetTypeInfo().Assembly;
var name = $"{assembly.GetName().Name}.dll";
var filePath = Path.Combine(_clientDirectory, name);
return FileVersionInfo.GetVersionInfo(filePath).FileVersion;
var fileVersionInfo = FileVersionInfo.GetVersionInfo(filePath);
string hash = ExtractShortCommitHash(assembly.GetCustomAttribute<CommitHashAttribute>()?.Hash);
return $"{fileVersionInfo.FileVersion} ({hash})";
}
return "";
}
internal static string ExtractShortCommitHash(string hash)
{
// leave "<developer build>" alone, but truncate SHA to 8 characters
if (hash != null && hash.Length >= 8 && hash[0] != '<')
{
return hash.Substring(0, 8);
}
return hash;
}
/// <summary>
/// Tool name used, along with assembly version, for error logging.
/// </summary>
......
// 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 System;
namespace Microsoft.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
internal sealed class CommitHashAttribute : Attribute
{
internal readonly string Hash;
public CommitHashAttribute(string hash)
{
Hash = hash;
}
}
}
......@@ -16,6 +16,11 @@
<NoWarn>$(NoWarn);42014</NoWarn>
<CodeAnalysisRuleSet>..\BasicCodeAnalysisRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<AssemblyVersionAttribute Include="Microsoft.CodeAnalysis.CommitHashAttribute">
<_Parameter1>$(GitHeadSha)</_Parameter1>
</AssemblyVersionAttribute>
</ItemGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Tools\Source\CompilerGeneratorTools\DeployCompilerGeneratorToolsRuntime\DeployCompilerGeneratorToolsRuntime.csproj">
<Project>{6da08f12-32f2-4dd9-bbad-982eb71a2c9b}</Project>
......
......@@ -30,6 +30,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests
Private ReadOnly _baseDirectory As String = TempRoot.Root
Private Shared ReadOnly s_basicCompilerExecutable As String = GetType(Vbc).Assembly.Location
Private Shared ReadOnly s_defaultSdkDirectory As String = RuntimeEnvironment.GetRuntimeDirectory()
Private Shared ReadOnly s_compilerVersion As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Private Shared ReadOnly s_compilerShortCommitHash As String =
CommonCompiler.ExtractShortCommitHash(GetType(VisualBasicCompiler).GetTypeInfo().Assembly.GetCustomAttribute(Of CommitHashAttribute).Hash)
Private Shared Function DefaultParse(args As IEnumerable(Of String), baseDirectory As String, Optional sdkDirectory As String = Nothing, Optional additionalReferenceDirectories As String = Nothing) As VisualBasicCommandLineArguments
sdkDirectory = If(sdkDirectory, s_defaultSdkDirectory)
......@@ -228,18 +231,36 @@ End Class
Dim exitCode = cmd.Run(output, Nothing)
Assert.Equal(0, exitCode)
Dim patched As String = Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D")
patched = ReplaceCommitHash(patched)
Assert.Equal(<text>
Microsoft (R) Visual Basic Compiler version A.B.C.D
Microsoft (R) Visual Basic Compiler version A.B.C.D (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
</text>.Value.Replace(vbLf, vbCrLf).Trim,
Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D"))
patched)
' Privately queued builds have 3-part version numbers instead of 4. Since we're throwing away the version number,
' making the last part optional will fix this.
CleanupAllGeneratedFiles(src)
End Sub
<Theory,
InlineData("Microsoft (R) Visual Basic Compiler version A.B.C.D (<developer build>)",
"Microsoft (R) Visual Basic Compiler version A.B.C.D (HASH)"),
InlineData("Microsoft (R) Visual Basic Compiler version A.B.C.D (ABCDEF01)",
"Microsoft (R) Visual Basic Compiler version A.B.C.D (HASH)"),
InlineData("Microsoft (R) Visual Basic Compiler version A.B.C.D (abcdef90)",
"Microsoft (R) Visual Basic Compiler version A.B.C.D (HASH)"),
InlineData("Microsoft (R) Visual Basic Compiler version A.B.C.D (12345678)",
"Microsoft (R) Visual Basic Compiler version A.B.C.D (HASH)")>
Public Sub TestReplaceCommitHash(orig As String, expected As String)
Assert.Equal(expected, ReplaceCommitHash(orig))
End Sub
Private Shared Function ReplaceCommitHash(s As String) As String
Return Regex.Replace(s, "(\((<developer build>|[a-fA-F0-9]{8})\))", "(HASH)")
End Function
<Fact>
Public Sub VbcNologo_2a()
Dim src As String = Temp.CreateFile().WriteAllText(<text>
......@@ -253,15 +274,16 @@ End Class
Dim exitCode = cmd.Run(output, Nothing)
Assert.Equal(0, exitCode)
Dim patched As String = Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D")
patched = ReplaceCommitHash(patched)
Assert.Equal(<text>
Microsoft (R) Visual Basic Compiler version A.B.C.D
Microsoft (R) Visual Basic Compiler version A.B.C.D (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
</text>.Value.Replace(vbLf, vbCrLf).Trim,
Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D"))
patched)
' Privately queued builds have 3-part version numbers instead of 4. Since we're throwing away the version number,
' making the last part optional will fix this.
CleanupAllGeneratedFiles(src)
End Sub
......@@ -4831,7 +4853,7 @@ End Module
</compilation>
Dim result =
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(5) : warning BC42024: Unused local variable: 'x'.
......@@ -4861,12 +4883,10 @@ PATH(11) : warning BC42105: Function 'foo' doesn't return a value on all code pa
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Dim expected = result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf).Trim()
Dim expected = ReplacePathAndVersionAndHash(result, file).Trim()
Dim actual = output.ToString().Trim()
Assert.Equal(expected, actual)
CleanupAllGeneratedFiles(file.Path)
End Sub
......@@ -4898,7 +4918,7 @@ End Module
</compilation>
Dim result =
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(9) : error BC36640: Instance of restricted type 'ArgIterator' cannot be used in a lambda expression.
......@@ -4916,8 +4936,7 @@ PATH(9) : error BC36640: Instance of restricted type 'ArgIterator' cannot be use
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en", "-imports:System"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Assert.Equal(result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf), output.ToString())
Assert.Equal(ReplacePathAndVersionAndHash(result, file), output.ToString())
CleanupAllGeneratedFiles(file.Path)
End Sub
......@@ -4932,7 +4951,7 @@ PATH(9) : error BC36640: Instance of restricted type 'ArgIterator' cannot be use
" End Sub" + vbCrLf +
"End Module" + vbCrLf
Dim result = <file name="output">Microsoft (R) Visual Basic Compiler version VERSION
Dim result = <file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(3) : error BC30201: Expression expected.
......@@ -4954,8 +4973,7 @@ PATH(3) : error BC30004: Character constant must contain exactly one character.
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Dim expected = result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf).Trim()
Dim expected = ReplacePathAndVersionAndHash(result, file).Trim()
Dim actual = output.ToString().Trim()
Assert.Equal(expected, actual)
......@@ -4983,7 +5001,7 @@ End Module
</compilation>
Dim result =
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(5) : error BC36593: Expression of type 'Integer()' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.
......@@ -5005,8 +5023,7 @@ PATH(5) : error BC36593: Expression of type 'Integer()' is not queryable. Make s
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Assert.Equal(result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf), output.ToString())
Assert.Equal(ReplacePathAndVersionAndHash(result, file), output.ToString())
CleanupAllGeneratedFiles(file.Path)
End Sub
......@@ -5030,7 +5047,7 @@ Module _
</compilation>
Dim result =
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(3) : error BC30625: 'Module' statement must end with a matching 'End Module'.
......@@ -5050,8 +5067,7 @@ Module _
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Assert.Equal(result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf), output.ToString())
Assert.Equal(ReplacePathAndVersionAndHash(result, file), output.ToString())
CleanupAllGeneratedFiles(file.Path)
End Sub
......@@ -5081,7 +5097,7 @@ End Module
</compilation>
Dim result =
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(7) : error BC37220: Name 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeEventHandler' exceeds the maximum length allowed in metadata.
......@@ -5099,8 +5115,7 @@ PATH(7) : error BC37220: Name 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Assert.Equal(result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf), output.ToString())
Assert.Equal(ReplacePathAndVersionAndHash(result, file), output.ToString())
CleanupAllGeneratedFiles(file.Path)
End Sub
......@@ -5124,7 +5139,7 @@ End Class]]>
</compilation>
Dim result =
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(4) : error BC30625: 'Module' statement must end with a matching 'End Module'.
......@@ -5146,8 +5161,7 @@ End Class
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Assert.Equal(result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf), output.ToString())
Assert.Equal(ReplacePathAndVersionAndHash(result, file), output.ToString())
CleanupAllGeneratedFiles(file.Path)
End Sub
......@@ -5171,7 +5185,7 @@ End Module
</compilation>
Dim result =
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION
<file name="output">Microsoft (R) Visual Basic Compiler version VERSION (HASH)
Copyright (C) Microsoft Corporation. All rights reserved.
PATH(6) : error BC30203: Identifier expected.
......@@ -5189,12 +5203,15 @@ PATH(6) : error BC30203: Identifier expected.
Dim vbc As New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, "/preferreduilang:en"})
vbc.Run(output, Nothing)
Dim version As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Assert.Equal(result.Value.Replace("PATH", file.Path).Replace("VERSION", version).Replace(vbLf, vbCrLf), output.ToString())
Assert.Equal(ReplacePathAndVersionAndHash(result, file), output.ToString())
CleanupAllGeneratedFiles(file.Path)
End Sub
Private Shared Function ReplacePathAndVersionAndHash(result As XElement, file As TempFile) As String
Return result.Value.Replace("PATH", file.Path).Replace("VERSION", s_compilerVersion).Replace("HASH", s_compilerShortCommitHash).Replace(vbLf, vbCrLf)
End Function
<WorkItem(545247, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545247")>
<Fact()>
Public Sub CompilationWithNonExistingOutPath()
......@@ -7959,7 +7976,7 @@ End Class
<Fact()>
Public Sub Version()
Dim folderName = Temp.CreateDirectory().ToString()
Dim expected As String = FileVersionInfo.GetVersionInfo(GetType(VisualBasicCompiler).Assembly.Location).FileVersion
Dim expected As String = $"{s_compilerVersion} ({s_compilerShortCommitHash})"
Dim argss = {
"/version",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册