зеркало из https://github.com/dotnet/msbuild.git
Initial code commit. Adding sources from Visual Studio 2015 release branch.
This commit is contained in:
Родитель
1f63d6c0ad
Коммит
82177a50da
|
@ -0,0 +1,80 @@
|
|||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
|
||||
[attr]wintext text eol=crlf
|
||||
|
||||
* text=auto
|
||||
|
||||
# Default
|
||||
*.* wintext
|
||||
|
||||
# Build Specifications
|
||||
*.sln wintext
|
||||
*.props wintext
|
||||
*.proj wintext
|
||||
*.targets wintext
|
||||
*.tasks wintext
|
||||
*.overridetasks wintext
|
||||
*.csproj wintext
|
||||
*.rptproj wintext
|
||||
*.vcxproj wintext
|
||||
*.filters wintext
|
||||
*.cd wintext
|
||||
|
||||
# Sources (Managed)
|
||||
*.cs wintext
|
||||
*.vb wintext
|
||||
*.resx wintext
|
||||
*.xaml wintext
|
||||
*.config wintext
|
||||
*.manifest wintext
|
||||
*.txt wintext
|
||||
*.tst wintext
|
||||
|
||||
# Sources (Web)
|
||||
*.html wintext
|
||||
*.css wintext
|
||||
*.js wintext
|
||||
|
||||
# Sources (Native)
|
||||
*.h wintext
|
||||
*.cpp wintext
|
||||
*.rc wintext
|
||||
|
||||
# Sources (Xml)
|
||||
*.xml wintext
|
||||
*.xsl wintext
|
||||
*.xsd wintext
|
||||
|
||||
# Sources (Script)
|
||||
*.cmd wintext
|
||||
*.bat wintext
|
||||
*.rsp wintext
|
||||
*.sample wintext
|
||||
|
||||
|
||||
# Sources (Binary)
|
||||
*.doc binary
|
||||
*.ico binary
|
||||
*.appx binary
|
||||
|
||||
# Configuration
|
||||
*.gitattributes wintext
|
||||
*.gitignore wintext
|
||||
|
||||
#Binaries
|
||||
*.exe binary
|
||||
*.dll binary
|
||||
*.obj binary
|
||||
*.pdb binary
|
||||
*.zip binary
|
||||
*.chm binary
|
||||
*.nupkg binary
|
||||
*.lex binary
|
||||
*.ocx binary
|
||||
*.mui binary
|
||||
|
||||
#Images (Binary)
|
||||
*.png binary
|
||||
*.jpg binary
|
|
@ -0,0 +1,183 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Roslyn cache directories
|
||||
*.ide/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
#NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding addin-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# If using the old MSBuild-Integrated Package Restore, uncomment this:
|
||||
#!**/packages/repositories.config
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
|
@ -0,0 +1,59 @@
|
|||
:: Usage:
|
||||
:: BuildAndCopy <path> <retail framework>
|
||||
:: <path> - Where to copy the build output
|
||||
:: <retail framework> - true to have MSBuild target Microsoft.Build.Framework
|
||||
::
|
||||
:: Example: BuildAndCopy.cmd bin\MSBuild false
|
||||
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set MSBuild14Path=%ProgramFiles(x86)%\MSBuild\14.0\Bin
|
||||
set DebugBuildOutputPath=%~dp0bin\Windows_NT\Debug
|
||||
set OutputPath=%~dp0bin\MSBuild
|
||||
|
||||
:: Check prerequisites
|
||||
if not defined VS140COMNTOOLS (
|
||||
echo Error: This script should be run from a Visual Studio 2015 Command Prompt.
|
||||
echo Please see https://github.com/Microsoft/msbuild/wiki/Building-Testing-and-Debugging for build instructions.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not "%1"=="" (
|
||||
set OutputPath=%1
|
||||
if "%2"=="true" (
|
||||
set AdditionalBuildCommand= /p:TargetRetailBuildFramework=true
|
||||
)
|
||||
)
|
||||
|
||||
echo ** Creating a build package
|
||||
echo ** Output Path: %OutputPath%
|
||||
echo ** Additional Build Parameters:%AdditionalBuildCommand%
|
||||
echo.
|
||||
:: Build MSBuild
|
||||
call "%~dp0build.cmd" /t:Rebuild %AdditionalBuildCommand%
|
||||
|
||||
:: Make a copy of our build
|
||||
echo ** ROBOCOPY bin\Windows_NT\Debug -^> %OutputPath%
|
||||
robocopy "%DebugBuildOutputPath%" "%OutputPath%" *.* /S /NFL /NDL /NJH /NJS /nc /ns /np
|
||||
echo.
|
||||
|
||||
:: This is a bit hacky, but we need to copy certain dependencies.
|
||||
:: The files needed are defined in MSBuildLocalSystemDependencies.txt (one per line)
|
||||
:: Note: Files may be in use if the compiler is still running (this is generally ok)
|
||||
echo ** Copying required dependencies from MSBuild 14.0
|
||||
for /F "tokens=*" %%A in (MSBuildLocalSystemDependencies.txt) do (
|
||||
robocopy "%MSBuild14Path%" "%OutputPath%" %%A /NFL /NDL /NJH /NJS /nc /ns /np>nul
|
||||
)
|
||||
echo.
|
||||
|
||||
:: Delete the copy of Microsoft.Build.Framework.dll we built so there are no conflicts
|
||||
if "%2"=="true" (
|
||||
echo ** Deleting Microsoft.Build.Framework.dll we built in favor of the Retail version.
|
||||
del %OutputPath%\Microsoft.Build.Framework.*
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ** Packaging complete.
|
||||
set MSBUILDCUSTOMPATH="%OutputPath%\MSBuild.exe"
|
||||
echo ** MSBuild = %MSBUILDCUSTOMPATH%
|
|
@ -0,0 +1,13 @@
|
|||
csc2.exe
|
||||
Microsoft.CodeAnalysis.CSharp.Desktop.dll
|
||||
Microsoft.CodeAnalysis.CSharp.dll
|
||||
Microsoft.CodeAnalysis.dll
|
||||
Microsoft.CodeAnalysis.Desktop.dll
|
||||
Microsoft.CodeAnalysis.VisualBasic.Desktop.dll
|
||||
Microsoft.CodeAnalysis.VisualBasic.dll
|
||||
System.Collections.Immutable.dll
|
||||
System.Reflection.Metadata.dll
|
||||
Tracker.exe
|
||||
vbc2.exe
|
||||
VBCSCompiler.exe
|
||||
VBCSCompiler.exe.config
|
|
@ -0,0 +1,47 @@
|
|||
# Microsoft.Build (MSBuild)
|
||||
The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software. Visual Studio uses MSBuild, but it doesn't depend on Visual Studio. By invoking msbuild.exe on your project or solution file, you can orchestrate and build products in environments where Visual Studio isn't installed.
|
||||
|
||||
For more information on MSBuild, see the [MSDN documentation](https://msdn.microsoft.com/en-us/library/dd393574(v=vs.120).aspx).
|
||||
|
||||
### Source code
|
||||
|
||||
* Clone the sources: `git clone https://github.com/Microsoft/msbuild.git`
|
||||
|
||||
### Building
|
||||
For the full supported experience, you will need to have Visual Studio 2015 Preview or later. You can open the solution in Visual Studio 2013, but you will encounter issues building with the provided scripts.
|
||||
|
||||
To get started on **Visual Studio 2015 Preview**:
|
||||
|
||||
1. Set up a box with Visual Studio 2015 Preview. Either
|
||||
[install Visual Studio 2015 Preview](http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs),
|
||||
or grab a [prebuilt Azure VM image](http://blogs.msdn.com/b/visualstudioalm/archive/2014/06/04/visual-studio-14-ctp-now-available-in-the-virtual-machine-azure-gallery.aspx).
|
||||
2. Clone the source code (see above).
|
||||
3. Open src/MSBuild.sln solution in Visual Studio 2015.
|
||||
|
||||
## How to Engage, Contribute and Provide Feedback
|
||||
Before you contribute, please read through the contributing and developer guides to get an idea of what kinds of pull requsts we will or won't accept.
|
||||
|
||||
* [Contributing Guide](https://github.com/Microsoft/msbuild/wiki/Contributing-Code)
|
||||
* [Developer Guide](https://github.com/Microsoft/msbuild/wiki/Building-Testing-and-Debugging)
|
||||
|
||||
Want to get more familiar with what's going on in the code?
|
||||
* [Pull requests](https://github.com/Microsoft/msbuild/pulls): [Open](https://github.com/Microsoft/msbuild/pulls?q=is%3Aopen+is%3Apr)/[Closed](https://github.com/Microsoft/msbuild/pulls?q=is%3Apr+is%3Aclosed)
|
||||
* [Issue Guide](https://github.com/Microsoft/msbuild/wiki/Issue-Guide)
|
||||
|
||||
You are also encouraged to start a discussion by filing an issue or creating a gist.
|
||||
|
||||
## MSBuild Components
|
||||
|
||||
* **MSBuild**. [Microsoft.Build.CommandLine](https://msdn.microsoft.com/en-us/library/dd393574(v=vs.120).aspx) is the entrypoint for the Microsoft Build Engine (MSBuild.exe).
|
||||
|
||||
* **Microsoft.Build**. The [Microsoft.Build](https://msdn.microsoft.com/en-us/library/gg145008(v=vs.120).aspx) namespaces contain types that provide programmatic access to, and control of, the MSBuild engine.
|
||||
|
||||
* **Microsoft.Build.Framework**. The [Microsoft.Build.Framework](https://msdn.microsoft.com/en-us/library/microsoft.build.framework(v=vs.120).aspx) namespace contains the types that define how tasks and loggers interact with the MSBuild engine. For additional information on this component, see our [Microsoft.Build.Framework wiki page](https://github.com/Microsoft/msbuild/wiki/Microsoft.Build.Framework).
|
||||
|
||||
* **Microsoft.Build.Tasks**. The [Microsoft.Build.Tasks](https://msdn.microsoft.com/en-us/library/microsoft.build.tasks(v=vs.120).aspx) namespace contains the implementation of all tasks shipping with MSBuild.
|
||||
|
||||
* **Microsoft.Build.Utilities**. The [Microsoft.Build.Utilities](https://msdn.microsoft.com/en-us/library/microsoft.build.utilities(v=vs.120).aspx) namespace provides helper classes that you can use to create your own MSBuild loggers and tasks.
|
||||
|
||||
## License
|
||||
|
||||
MSBuild is licensed under the [MIT license](LICENSE).
|
|
@ -0,0 +1,24 @@
|
|||
:: This script will:
|
||||
:: 1) Rebuild MSBuild source tree.
|
||||
:: 2) Create a copy of the build output in bin\MSBuild
|
||||
:: 3) Build the source tree again with the MSBuild.exe in step 2.
|
||||
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set MSBuildTempPath=%~dp0bin\MSBuild
|
||||
|
||||
:: Check prerequisites
|
||||
if not defined VS140COMNTOOLS (
|
||||
echo Error: This script should be run from a Visual Studio 2015 Command Prompt.
|
||||
echo Please see https://github.com/Microsoft/msbuild/wiki/Developer-Guide for build instructions.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Build and copy output to bin\MSBuild
|
||||
:: Set TargetRetailBuildFramework to false so that we can target our own version of Microsoft.Build.Framework
|
||||
call "%~dp0BuildAndCopy.cmd" "%MSBuildTempPath%" false
|
||||
|
||||
:: Rebuild
|
||||
set MSBUILDCUSTOMPATH=%MSBuildTempPath%\MSBuild.exe
|
||||
"%~dp0build.cmd" /t:Rebuild
|
|
@ -0,0 +1,30 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
:: Check prerequisites
|
||||
if not "%VisualStudioVersion%" == "14.0" (
|
||||
echo Error: build.cmd should be run from a Visual Studio 2015 Command Prompt.
|
||||
echo Please see https://github.com/Microsoft/msbuild/wiki/Building-Testing-and-Debugging for build instructions.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Check for a custom MSBuild path. If not defined, default to the one in your path.
|
||||
if not defined MSBUILDCUSTOMPATH (
|
||||
set MSBUILDCUSTOMPATH=MSBuild.exe
|
||||
)
|
||||
|
||||
|
||||
echo ** MSBuild Path: %MSBUILDCUSTOMPATH%
|
||||
echo ** Building all sources
|
||||
|
||||
:: Call MSBuild
|
||||
echo ** "%MSBUILDCUSTOMPATH%" "%~dp0build.proj" /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%~dp0msbuild.log" %*
|
||||
"%MSBUILDCUSTOMPATH%" "%~dp0build.proj" /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%~dp0msbuild.log" %*
|
||||
set BUILDERRORLEVEL=%ERRORLEVEL%
|
||||
echo.
|
||||
|
||||
:: Pull the build summary from the log file
|
||||
findstr /ir /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" "%~dp0msbuild.log"
|
||||
echo ** Build completed. Exit code: %BUILDERRORLEVEL%
|
||||
|
||||
exit /b %BUILDERRORLEVEL%
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="dir.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<Project Include="src\dirs.proj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="dir.traversal.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,69 @@
|
|||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Common repo directories -->
|
||||
<PropertyGroup>
|
||||
<ProjectDir>$(MSBuildThisFileDirectory)</ProjectDir>
|
||||
<SourceDir>$(ProjectDir)src\</SourceDir>
|
||||
<BinDir>$(ProjectDir)bin\</BinDir>
|
||||
<TestWorkingDir>$(BinDir)tests\</TestWorkingDir>
|
||||
<PackagesDir>$(ProjectDir)packages\</PackagesDir>
|
||||
<ToolsDir>$(PackagesDir)Microsoft.DotNet.BuildTools.$(BuildToolsVersion)\lib\</ToolsDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Common nuget properties -->
|
||||
<PropertyGroup>
|
||||
<NuGetToolPath>$(PackagesDir)NuGet.exe</NuGetToolPath>
|
||||
<NuGetConfigFile>$(SourceDir).nuget\NuGet.Config</NuGetConfigFile>
|
||||
<NuGetConfigCommandLine>-ConfigFile "$(NuGetConfigFile)"</NuGetConfigCommandLine>
|
||||
|
||||
<NugetRestoreCommand>"$(NuGetToolPath)"</NugetRestoreCommand>
|
||||
<NugetRestoreCommand>$(NugetRestoreCommand) install</NugetRestoreCommand>
|
||||
<NugetRestoreCommand>$(NugetRestoreCommand) -OutputDirectory "$(PackagesDir.TrimEnd('\'))"</NugetRestoreCommand>
|
||||
<NugetRestoreCommand>$(NugetRestoreCommand) $(NuGetConfigCommandLine)</NugetRestoreCommand>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Set default Configuration and Platform -->
|
||||
<PropertyGroup>
|
||||
<Configuration Condition="'$(Configuration)' ==''">Debug</Configuration>
|
||||
<Platform Condition="'$(Platform)'==''">AnyCPU</Platform>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Setup Default symbol and optimization for Configuration -->
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<DebugSymbols Condition="'$(DebugSymbols)' == ''">true</DebugSymbols>
|
||||
<Optimize Condition="'$(Optimize)' == ''">false</Optimize>
|
||||
<DebugType Condition="'$(DebugType)' == ''">full</DebugType>
|
||||
<DefineConstants>$(DefineConstants);DEBUG;TRACE;STANDALONEBUILD</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<DebugSymbols Condition="'$(DebugSymbols)' == ''">true</DebugSymbols>
|
||||
<Optimize Condition="'$(Optimize)' == ''">true</Optimize>
|
||||
<DebugType Condition="'$(DebugType)' == ''">pdbonly</DebugType>
|
||||
<DefineConstants>$(DefineConstants);TRACE;STANDALONEBUILD</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Setup some common paths -->
|
||||
<PropertyGroup>
|
||||
<CommonPath>$(SourceDir)Common\src</CommonPath>
|
||||
<CommonTestPath>$(SourceDir)Common\tests</CommonTestPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Setup the default output and intermediate paths -->
|
||||
<PropertyGroup>
|
||||
<BaseOutputPath>$(ProjectDir)bin\</BaseOutputPath>
|
||||
<BaseOutputPathWithConfig>$(BaseOutputPath)$(OS)\$(Configuration)\</BaseOutputPathWithConfig>
|
||||
<BaseOutputPathWithConfig Condition="'$(Platform)' != 'AnyCPU'">$(BaseOutputPath)$(Platform)\$(OS)\$(Configuration)\</BaseOutputPathWithConfig>
|
||||
<OutputPath>$(BaseOutputPathWithConfig)\</OutputPath>
|
||||
|
||||
<BaseIntermediateOutputPath>$(BaseOutputPath)obj\</BaseIntermediateOutputPath>
|
||||
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(MSBuildProjectName)\$(OS)\$(Configuration)\</IntermediateOutputPath>
|
||||
<IntermediateOutputPath Condition="'$(Platform)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(MSBuildProjectName)\$(Platform)\$(OS)\$(Configuration)\</IntermediateOutputPath>
|
||||
|
||||
<TestPath>$(TestWorkingDir)$(MSBuildProjectName)\$(OS)\$(Configuration)\</TestPath>
|
||||
<TestPath Condition="'$(Platform)' != 'AnyCPU'">$(TestWorkingDir)$(MSBuildProjectName)\$(Platform)\$(OS)\$(Configuration)\</TestPath>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" InitialTargets="_RestoreBuildToolsWrapper" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<!-- Inline task to bootstrap the build to enable downloading nuget.exe -->
|
||||
<UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
|
||||
<ParameterGroup>
|
||||
<Address ParameterType="System.String" Required="true"/>
|
||||
<FileName ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.IO" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
var directory = System.IO.Path.GetDirectoryName(FileName);
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
var tempFile = Path.Combine(directory, Path.GetRandomFileName());
|
||||
var client = new System.Net.WebClient();
|
||||
client.Proxy = System.Net.WebRequest.DefaultWebProxy;
|
||||
client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
|
||||
client.DownloadFile(Address, tempFile);
|
||||
|
||||
try
|
||||
{
|
||||
if (!File.Exists(FileName))
|
||||
File.Move(tempFile, FileName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(tempFile))
|
||||
File.Delete(tempFile);
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
|
||||
<!--
|
||||
Needed to avoid the IntialTargets from having an Output which ends up getting
|
||||
added to the output references when you have a project to project reference.
|
||||
-->
|
||||
<Target Name="_RestoreBuildToolsWrapper" DependsOnTargets="_RestoreBuildTools" />
|
||||
|
||||
<Target Name="_RestoreBuildTools"
|
||||
Inputs="$(MSBuildThisFileFullPath);$(MSBuildThisFileDirectory)dir.props"
|
||||
Outputs="$(ToolsDir)Microsoft.DotNet.Build.Tasks.dll;$(NugetToolPath)">
|
||||
|
||||
<!-- Download latest nuget.exe -->
|
||||
<DownloadFile FileName="$(NuGetToolPath)"
|
||||
Address="http://nuget.org/nuget.exe"
|
||||
Condition="!Exists($(NuGetToolPath))" />
|
||||
|
||||
<!-- Restore build tools -->
|
||||
<Exec Command="$(NugetRestoreCommand) "$(SourceDir).nuget\packages.config"" StandardOutputImportance="Low" />
|
||||
|
||||
<Error Condition="'$(ErrorIfBuildToolsRestoredFromIndividualProject)'=='true'"
|
||||
Text="The build tools package was just restored and so we cannot continue the build of an individual project because targets from the build tools package were not able to be imported. Please retry the build the individual project again." />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
|
||||
<Target Name="BuildAllProjects">
|
||||
<!-- To Serialize we use msbuild's batching functionality '%' to force it to batch all similar projects with the same identity
|
||||
however since the project names are unique it will essentially force each to run in its own batch -->
|
||||
<MSBuild Targets="Build" Projects="@(Project)" Condition="'$(SerializeProjects)'=='true'" Properties="Dummy=%(Identity)"/>
|
||||
<MSBuild Targets="Build" Projects="@(Project)" Condition="'$(SerializeProjects)'!='true'" BuildInParallel="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CleanAllProjects">
|
||||
<!-- To Serialize we use msbuild's batching functionality '%' to force it to batch all similar projects with the same identity
|
||||
however since the project names are unique it will essentially force each to run in its own batch -->
|
||||
<MSBuild Targets="Clean" Projects="@(Project)" Condition="'$(SerializeProjects)'=='true'" Properties="Dummy=%(Identity)"/>
|
||||
<MSBuild Targets="Clean" Projects="@(Project)" Condition="'$(SerializeProjects)'!='true'" BuildInParallel="true" />
|
||||
</Target>
|
||||
|
||||
<PropertyGroup>
|
||||
<TraversalBuildDependsOn>
|
||||
BuildAllProjects;
|
||||
$(TraversalBuildDependsOn);
|
||||
</TraversalBuildDependsOn>
|
||||
|
||||
<TraversalCleanDependsOn>
|
||||
CleanAllProjects;
|
||||
$(TraversalCleanDependsOn);
|
||||
</TraversalCleanDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="Build" DependsOnTargets="$(TraversalBuildDependsOn)" />
|
||||
|
||||
<Target Name="Clean" DependsOnTargets="$(TraversalCleanDependsOn)" />
|
||||
|
||||
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageRestore>
|
||||
<add key="enabled" value="True" />
|
||||
</packageRestore>
|
||||
<packageSources>
|
||||
</packageSources>
|
||||
<activePackageSource>
|
||||
<add key="All" value="(Aggregate source)" />
|
||||
</activePackageSource>
|
||||
<config>
|
||||
<add key="repositoryPath" value="..\..\packages" />
|
||||
</config>
|
||||
</configuration>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net451" />
|
||||
</packages>
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Assembly info.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Markup;
|
||||
|
||||
// A combination of RequestMinimum and RequestOptional causes the permissions granted to
|
||||
// the assembly to only be the permission requested (like a PermitOnly). More generally
|
||||
// the equation for the PermissionSet granted at load time is:
|
||||
//
|
||||
// Granted = (MaxGrant intersect (ReqMin union ReqOpt)) - ReqRefuse
|
||||
//
|
||||
// Where,
|
||||
// MaxGrant -- the permissions granted by policy.
|
||||
// ReqMin -- the permissions that RequestMinimum is specified for.
|
||||
// ReqOpt -- the permissions that RequestOptional is specified for.
|
||||
// ReqRefuse -- the permissions that Request refuse is specified for.
|
||||
//
|
||||
// Note that if ReqOpt is the empty set, then it is consider to be "FullTrust" and this
|
||||
// equation becomes:
|
||||
//
|
||||
// Granted = MaxGrant - ReqRefuse
|
||||
//
|
||||
// Regardless of whether ReqMin is empty or not.
|
||||
#pragma warning disable 618
|
||||
[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]
|
||||
#pragma warning restore 618
|
||||
[assembly: InternalsVisibleTo("Microsoft.Build.Framework.Unittest, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.Build.Framework.Whidbey.Unittest, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
|
||||
#if STANDALONEBUILD
|
||||
[assembly: AssemblyVersion("14.1.0.0")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.Build.Framework.UnitTests")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.Build.Tasks.UnitTests")]
|
||||
#endif
|
||||
|
||||
// This is the assembly-level GUID, and the GUID for the TypeLib associated with
|
||||
// this assembly. We should specify this explicitly, as opposed to letting
|
||||
// tlbexp just pick whatever it wants.
|
||||
[assembly: GuidAttribute("D8A9BA71-4724-481d-9CA7-0DA23A1D615C")]
|
||||
|
||||
[assembly: XmlnsDefinition("http://schemas.microsoft.com/build/2009/properties", "Microsoft.Build.Framework.XamlTypes")]
|
||||
|
||||
// This will enable passing the SafeDirectories flag to any P/Invoke calls/implementations within the assembly,
|
||||
// so that we don't run into known security issues with loading libraries from unsafe locations
|
||||
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)]
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// <summary>Structure which includes the success or failures of the IBuildEngine build and the target outputs.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This structure is used to return the result of the build and the target outputs.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "Would require a public API change -- currently we're trying to keep our surface area static.")]
|
||||
public struct BuildEngineResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Did the build pass or fail
|
||||
/// </summary>
|
||||
private bool _buildResult;
|
||||
|
||||
/// <summary>
|
||||
/// Target outputs by project
|
||||
/// </summary>
|
||||
private List<IDictionary<string, ITaskItem[]>> _targetOutputsPerProject;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor takes the result of the build and a list of the target outputs per project
|
||||
/// </summary>
|
||||
public BuildEngineResult(bool result, List<IDictionary<string, ITaskItem[]>> targetOutputsPerProject)
|
||||
{
|
||||
_buildResult = result;
|
||||
_targetOutputsPerProject = targetOutputsPerProject;
|
||||
if (_targetOutputsPerProject == null)
|
||||
{
|
||||
_targetOutputsPerProject = new List<IDictionary<string, ITaskItem[]>>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Did the build pass or fail. True means the build succeeded, False means the build failed.
|
||||
/// </summary>
|
||||
public bool Result
|
||||
{
|
||||
get
|
||||
{
|
||||
return _buildResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Outputs of the targets per project.
|
||||
/// </summary>
|
||||
public IList<IDictionary<string, ITaskItem[]>> TargetOutputsPerProject
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetOutputsPerProject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,394 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for any build event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for error events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class BuildErrorEventArgs : LazyFormattedBuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Subcategory of the error
|
||||
/// </summary>
|
||||
private string _subcategory;
|
||||
|
||||
/// <summary>
|
||||
/// Error code
|
||||
/// </summary>
|
||||
private string _code;
|
||||
|
||||
/// <summary>
|
||||
/// File name
|
||||
/// </summary>
|
||||
private string _file;
|
||||
|
||||
/// <summary>
|
||||
/// The project which issued the event
|
||||
/// </summary>
|
||||
private string _projectFile;
|
||||
|
||||
/// <summary>
|
||||
/// Line number
|
||||
/// </summary>
|
||||
private int _lineNumber;
|
||||
|
||||
/// <summary>
|
||||
/// Column number
|
||||
/// </summary>
|
||||
private int _columnNumber;
|
||||
|
||||
/// <summary>
|
||||
/// End line number
|
||||
/// </summary>
|
||||
private int _endLineNumber;
|
||||
|
||||
/// <summary>
|
||||
/// End column number
|
||||
/// </summary>
|
||||
private int _endColumnNumber;
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows all event data to be initialized
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event sub-category</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
public BuildErrorEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor which allows a timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event sub-category</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
public BuildErrorEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor which allows a timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event sub-category</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
/// <param name="messageArgs">message arguments</param>
|
||||
public BuildErrorEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp, messageArgs)
|
||||
{
|
||||
_subcategory = subcategory;
|
||||
_code = code;
|
||||
_file = file;
|
||||
_lineNumber = lineNumber;
|
||||
_columnNumber = columnNumber;
|
||||
_endLineNumber = endLineNumber;
|
||||
_endColumnNumber = endColumnNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected BuildErrorEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The custom sub-type of the event.
|
||||
/// </summary>
|
||||
public string Subcategory
|
||||
{
|
||||
get
|
||||
{
|
||||
return _subcategory;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Code associated with event.
|
||||
/// </summary>
|
||||
public string Code
|
||||
{
|
||||
get
|
||||
{
|
||||
return _code;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File associated with event.
|
||||
/// </summary>
|
||||
public string File
|
||||
{
|
||||
get
|
||||
{
|
||||
return _file;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The project file which issued this event.
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_projectFile = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Line number of interest in associated file.
|
||||
/// </summary>
|
||||
public int LineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Column number of interest in associated file.
|
||||
/// </summary>
|
||||
public int ColumnNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _columnNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ending line number of interest in associated file.
|
||||
/// </summary>
|
||||
public int EndLineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endLineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ending column number of interest in associated file.
|
||||
/// </summary>
|
||||
public int EndColumnNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endColumnNumber;
|
||||
}
|
||||
}
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
#region SubCategory
|
||||
if (_subcategory == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_subcategory);
|
||||
}
|
||||
#endregion
|
||||
#region Code
|
||||
if (_code == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_code);
|
||||
}
|
||||
#endregion
|
||||
#region File
|
||||
if (_file == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_file);
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
writer.Write((Int32)_lineNumber);
|
||||
writer.Write((Int32)_columnNumber);
|
||||
writer.Write((Int32)_endLineNumber);
|
||||
writer.Write((Int32)_endColumnNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which the object will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
#region SubCategory
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_subcategory = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_subcategory = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region Code
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_code = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_code = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region File
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_file = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_file = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (version > 20)
|
||||
{
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
#endregion
|
||||
_lineNumber = reader.ReadInt32();
|
||||
_columnNumber = reader.ReadInt32();
|
||||
_endLineNumber = reader.ReadInt32();
|
||||
_endColumnNumber = reader.ReadInt32();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,354 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for any build event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This class encapsulates the default data associated with build events.
|
||||
/// It is intended to be extended/sub-classed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public abstract class BuildEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Message
|
||||
/// </summary>
|
||||
private string _message;
|
||||
|
||||
/// <summary>
|
||||
/// Help keyword
|
||||
/// </summary>
|
||||
private string _helpKeyword;
|
||||
|
||||
/// <summary>
|
||||
/// Sender name
|
||||
/// </summary>
|
||||
private string _senderName;
|
||||
|
||||
/// <summary>
|
||||
/// Timestamp
|
||||
/// </summary>
|
||||
private DateTime _timestamp;
|
||||
|
||||
/// <summary>
|
||||
/// Thread id
|
||||
/// </summary>
|
||||
private int _threadId;
|
||||
|
||||
/// <summary>
|
||||
/// Build event context
|
||||
/// </summary>
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private BuildEventContext _buildEventContext;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected BuildEventArgs()
|
||||
: this(null, null, null, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows all event data to be initialized
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
protected BuildEventArgs(string message, string helpKeyword, string senderName)
|
||||
: this(message, helpKeyword, senderName, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows all event data to be initialized while providing a custom timestamp.
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimeStamp">TimeStamp of when the event was created</param>
|
||||
protected BuildEventArgs(string message, string helpKeyword, string senderName, DateTime eventTimestamp)
|
||||
{
|
||||
_message = message;
|
||||
_helpKeyword = helpKeyword;
|
||||
_senderName = senderName;
|
||||
_timestamp = eventTimestamp;
|
||||
_threadId = System.Threading.Thread.CurrentThread.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The time when event was raised.
|
||||
/// </summary>
|
||||
public DateTime Timestamp
|
||||
{
|
||||
get
|
||||
{
|
||||
// Rather than storing dates in Local time all the time, we store in UTC type, and only
|
||||
// convert to Local when the user requests access to this field. This lets us avoid the
|
||||
// expensive conversion to Local time unless it's absolutely necessary.
|
||||
if (_timestamp.Kind == DateTimeKind.Utc)
|
||||
{
|
||||
_timestamp = _timestamp.ToLocalTime();
|
||||
}
|
||||
|
||||
return _timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The thread that raised event.
|
||||
/// </summary>
|
||||
public int ThreadId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _threadId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Text of event.
|
||||
/// </summary>
|
||||
public virtual string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
protected set
|
||||
{
|
||||
_message = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom help keyword associated with event.
|
||||
/// </summary>
|
||||
public string HelpKeyword
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helpKeyword;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the object sending this event.
|
||||
/// </summary>
|
||||
public string SenderName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _senderName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event contextual information for the build event argument
|
||||
/// </summary>
|
||||
public BuildEventContext BuildEventContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return _buildEventContext;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_buildEventContext = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal virtual void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
#region Message
|
||||
if (_message == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_message);
|
||||
}
|
||||
#endregion
|
||||
#region HelpKeyword
|
||||
if (_helpKeyword == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_helpKeyword);
|
||||
}
|
||||
#endregion
|
||||
#region SenderName
|
||||
if (_senderName == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_senderName);
|
||||
}
|
||||
#endregion
|
||||
#region TimeStamp
|
||||
writer.Write((Int64)_timestamp.Ticks);
|
||||
writer.Write((Int32)_timestamp.Kind);
|
||||
#endregion
|
||||
writer.Write((Int32)_threadId);
|
||||
#region BuildEventContext
|
||||
if (_buildEventContext == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write((Int32)_buildEventContext.NodeId);
|
||||
writer.Write((Int32)_buildEventContext.ProjectContextId);
|
||||
writer.Write((Int32)_buildEventContext.TargetId);
|
||||
writer.Write((Int32)_buildEventContext.TaskId);
|
||||
writer.Write((Int32)_buildEventContext.SubmissionId);
|
||||
writer.Write((Int32)_buildEventContext.ProjectInstanceId);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal virtual void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
#region Message
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_message = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_message = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region HelpKeyword
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_helpKeyword = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_helpKeyword = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region SenderName
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_senderName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_senderName = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region TimeStamp
|
||||
long timestampTicks = reader.ReadInt64();
|
||||
if (version > 20)
|
||||
{
|
||||
DateTimeKind kind = (DateTimeKind)reader.ReadInt32();
|
||||
_timestamp = new DateTime(timestampTicks, kind);
|
||||
}
|
||||
else
|
||||
{
|
||||
_timestamp = new DateTime(timestampTicks);
|
||||
}
|
||||
#endregion
|
||||
_threadId = reader.ReadInt32();
|
||||
#region BuildEventContext
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_buildEventContext = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nodeId = reader.ReadInt32();
|
||||
int projectContextId = reader.ReadInt32();
|
||||
int targetId = reader.ReadInt32();
|
||||
int taskId = reader.ReadInt32();
|
||||
|
||||
if (version > 20)
|
||||
{
|
||||
int submissionId = reader.ReadInt32();
|
||||
int projectInstanceId = reader.ReadInt32();
|
||||
_buildEventContext = new BuildEventContext(submissionId, nodeId, projectInstanceId, projectContextId, targetId, taskId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_buildEventContext = new BuildEventContext(nodeId, targetId, projectContextId, taskId);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
#region SetSerializationDefaults
|
||||
|
||||
/// <summary>
|
||||
/// Run before the object has been deserialized
|
||||
/// UNDONE (Logging.) Can this and the next function go away, and instead return a BuildEventContext.Invalid from
|
||||
/// the property if the buildEventContext field is null?
|
||||
/// </summary>
|
||||
[OnDeserializing]
|
||||
private void SetBuildEventContextDefaultBeforeSerialization(StreamingContext sc)
|
||||
{
|
||||
// Dont want to create a new one here as default all the time as that would be a lot of
|
||||
// possibly useless allocations
|
||||
_buildEventContext = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run after the object has been deserialized
|
||||
/// </summary>
|
||||
[OnDeserialized]
|
||||
private void SetBuildEventContextDefaultAfterSerialization(StreamingContext sc)
|
||||
{
|
||||
if (_buildEventContext == null)
|
||||
{
|
||||
_buildEventContext = new BuildEventContext
|
||||
(
|
||||
BuildEventContext.InvalidNodeId,
|
||||
BuildEventContext.InvalidTargetId,
|
||||
BuildEventContext.InvalidProjectContextId,
|
||||
BuildEventContext.InvalidTaskId
|
||||
);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,298 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Will provide location information for an event, this is especially
|
||||
/// needed in a multi processor environment
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuildEventContext
|
||||
{
|
||||
#region Data
|
||||
|
||||
/// <summary>
|
||||
/// Node event was in
|
||||
/// </summary>
|
||||
private int _nodeId;
|
||||
|
||||
/// <summary>
|
||||
/// Target event was in
|
||||
/// </summary>
|
||||
private int _targetId;
|
||||
|
||||
/// <summary>
|
||||
///The node-unique project request context the event was in
|
||||
/// </summary>
|
||||
private int _projectContextId;
|
||||
|
||||
/// <summary>
|
||||
/// Id of the task the event was caused from
|
||||
/// </summary>
|
||||
private int _taskId;
|
||||
|
||||
/// <summary>
|
||||
/// The id of the project instance to which this event refers.
|
||||
/// </summary>
|
||||
private int _projectInstanceId;
|
||||
|
||||
/// <summary>
|
||||
/// The id of the submission.
|
||||
/// </summary>
|
||||
private int _submissionId;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// This is the original constructor. No one should ever use this except internally for backward compatibility.
|
||||
/// </summary>
|
||||
public BuildEventContext
|
||||
(
|
||||
int nodeId,
|
||||
int targetId,
|
||||
int projectContextId,
|
||||
int taskId
|
||||
)
|
||||
: this(InvalidSubmissionId, nodeId, InvalidProjectInstanceId, projectContextId, targetId, taskId)
|
||||
{
|
||||
// UNDONE: This is obsolete.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a BuildEventContext with a specified project instance id.
|
||||
/// </summary>
|
||||
public BuildEventContext
|
||||
(
|
||||
int nodeId,
|
||||
int projectInstanceId,
|
||||
int projectContextId,
|
||||
int targetId,
|
||||
int taskId
|
||||
)
|
||||
: this(InvalidSubmissionId, nodeId, projectInstanceId, projectContextId, targetId, taskId)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a BuildEventContext with a specific submission id
|
||||
/// </summary>
|
||||
public BuildEventContext
|
||||
(
|
||||
int submissionId,
|
||||
int nodeId,
|
||||
int projectInstanceId,
|
||||
int projectContextId,
|
||||
int targetId,
|
||||
int taskId
|
||||
)
|
||||
{
|
||||
_submissionId = submissionId;
|
||||
_nodeId = nodeId;
|
||||
_targetId = targetId;
|
||||
_projectContextId = projectContextId;
|
||||
_taskId = taskId;
|
||||
_projectInstanceId = projectInstanceId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns a default invalid BuildEventContext
|
||||
/// </summary>
|
||||
public static BuildEventContext Invalid
|
||||
{
|
||||
get
|
||||
{
|
||||
return new BuildEventContext(BuildEventContext.InvalidNodeId, BuildEventContext.InvalidTargetId, BuildEventContext.InvalidProjectContextId, BuildEventContext.InvalidTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NodeId where event took place
|
||||
/// </summary>
|
||||
public int NodeId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nodeId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Id of the target the event was in when the event was fired
|
||||
/// </summary>
|
||||
public int TargetId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the Project Context id.
|
||||
/// </summary>
|
||||
public int ProjectContextId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectContextId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the task id.
|
||||
/// </summary>
|
||||
public int TaskId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _taskId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the project instance id.
|
||||
/// </summary>
|
||||
public int ProjectInstanceId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectInstanceId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the Submission id.
|
||||
/// </summary>
|
||||
public int SubmissionId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _submissionId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the BuildRequest id. Note that this is not the same as the global request id on a BuildRequest or BuildResult.
|
||||
/// </summary>
|
||||
public long BuildRequestId
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((long)_nodeId << 32) + _projectContextId;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
public const int InvalidProjectContextId = -2;
|
||||
public const int InvalidTaskId = -1;
|
||||
public const int InvalidTargetId = -1;
|
||||
public const int InvalidNodeId = -2;
|
||||
public const int InvalidProjectInstanceId = -1;
|
||||
public const int InvalidSubmissionId = -1;
|
||||
#endregion
|
||||
|
||||
#region Equals
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a hash code for this BuildEventContext.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (ProjectContextId + (NodeId << 24));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare a BuildEventContext with this BuildEventContext.
|
||||
/// A build event context is compared in the following way.
|
||||
///
|
||||
/// 1. If the obect references are the same the contexts are equivilant
|
||||
/// 2. If the object type is the same and the Id values in the context are the same, the contexts are equivilant
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// If the references are the same no need to do any more comparing
|
||||
if (object.ReferenceEquals(this, obj))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (object.ReferenceEquals(obj, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// The types do not match, they cannot be the same
|
||||
if (this.GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return InternalEquals((BuildEventContext)obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// Override == so the equals comparison using this operator will be the same as
|
||||
/// .Equals
|
||||
/// </summary>
|
||||
/// <param name="left">Left hand side operand</param>
|
||||
/// <param name="right">Right hand side operand</param>
|
||||
/// <returns>True if the object values are identical, false if they are not identical</returns>
|
||||
public static bool operator ==(BuildEventContext left, BuildEventContext right)
|
||||
{
|
||||
if (Object.ReferenceEquals(left, right))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Object.ReferenceEquals(left, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override != so the equals comparison using this operator will be the same as
|
||||
/// ! Equals
|
||||
/// </summary>
|
||||
/// <param name="left">Left hand side operand</param>
|
||||
/// <param name="right">Right hand side operand</param>
|
||||
/// <returns>True if the object values are not identical, false if they are identical</returns>
|
||||
public static bool operator !=(BuildEventContext left, BuildEventContext right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the fields are identical
|
||||
/// </summary>
|
||||
/// <param name="buildEventContext">BuildEventContext to compare to this instance</param>
|
||||
/// <returns>True if the value fields are the same, false if otherwise</returns>
|
||||
private bool InternalEquals(BuildEventContext buildEventContext)
|
||||
{
|
||||
return ((_nodeId == buildEventContext.NodeId)
|
||||
&& (_projectContextId == buildEventContext.ProjectContextId)
|
||||
&& (_targetId == buildEventContext.TargetId)
|
||||
&& (_taskId == buildEventContext.TaskId));
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for any build event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This class represents the event arguments for build finished events.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class BuildFinishedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the build succeeded
|
||||
/// </summary>
|
||||
private bool _succeeded;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected BuildFinishedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to initialize all paramterers.
|
||||
/// Sender field cannot be set here and is assumed to be "MSBuild"
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="succeeded">True indicates a successful build</param>
|
||||
public BuildFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
bool succeeded
|
||||
)
|
||||
: this(message, helpKeyword, succeeded, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor which allows the timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="succeeded">True indicates a successful build</param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
public BuildFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(message, helpKeyword, succeeded, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor which allows the timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="succeeded">True indicates a successful build</param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
/// <param name="messageArgs">message arguments</param>
|
||||
public BuildFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp, messageArgs)
|
||||
{
|
||||
_succeeded = succeeded;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
writer.Write(_succeeded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
_succeeded = reader.ReadBoolean();
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Succeeded is true if the build succeeded; false otherwise.
|
||||
/// </summary>
|
||||
public bool Succeeded
|
||||
{
|
||||
get
|
||||
{
|
||||
return _succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,485 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for any build event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This enumeration provides three levels of importance for messages.
|
||||
/// </summary>
|
||||
///
|
||||
///
|
||||
[Serializable]
|
||||
public enum MessageImportance
|
||||
{
|
||||
/// <summary>
|
||||
/// High importance, appears in less verbose logs
|
||||
/// </summary>
|
||||
High,
|
||||
|
||||
/// <summary>
|
||||
/// Normal importance
|
||||
/// </summary>
|
||||
Normal,
|
||||
|
||||
/// <summary>
|
||||
/// Low importance, appears in more verbose logs
|
||||
/// </summary>
|
||||
Low
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arguments for message events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class BuildMessageEventArgs : LazyFormattedBuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected BuildMessageEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constuctor allows all event data to be initialized
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="importance">importance of the message</param>
|
||||
public BuildMessageEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
MessageImportance importance
|
||||
)
|
||||
: this(message, helpKeyword, senderName, importance, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constuctor allows a timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="importance">importance of the message</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
public BuildMessageEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
MessageImportance importance,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(message, helpKeyword, senderName, importance, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constuctor allows a timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="importance">importance of the message</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
/// <param name="messageArgs">message arguments</param>
|
||||
public BuildMessageEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
MessageImportance importance,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: this(null, null, null, 0, 0, 0, 0, message, helpKeyword, senderName, importance, eventTimestamp, messageArgs)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows all event data to be initialized
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="importance">importance of the message</param>
|
||||
public BuildMessageEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
MessageImportance importance
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, importance, DateTime.UtcNow)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="importance">importance of the message</param>
|
||||
/// <param name="eventTimestamp">custom timestamp for the event</param>
|
||||
public BuildMessageEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
MessageImportance importance,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, importance, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="importance">importance of the message</param>
|
||||
/// <param name="eventTimestamp">custom timestamp for the event</param>
|
||||
/// <param name="messageArgs">message arguments</param>
|
||||
public BuildMessageEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
MessageImportance importance,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp, messageArgs)
|
||||
{
|
||||
_importance = importance;
|
||||
_subcategory = subcategory;
|
||||
_code = code;
|
||||
_file = file;
|
||||
_lineNumber = lineNumber;
|
||||
_columnNumber = columnNumber;
|
||||
_endLineNumber = endLineNumber;
|
||||
_endColumnNumber = endColumnNumber;
|
||||
}
|
||||
|
||||
private MessageImportance _importance;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private string _subcategory;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private string _code;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private string _file;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private string _projectFile;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private int _lineNumber;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private int _columnNumber;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private int _endLineNumber;
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private int _endColumnNumber;
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
writer.Write((Int32)_importance);
|
||||
#region SubCategory
|
||||
if (_subcategory == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_subcategory);
|
||||
}
|
||||
#endregion
|
||||
#region Code
|
||||
if (_code == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_code);
|
||||
}
|
||||
#endregion
|
||||
#region File
|
||||
if (_file == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_file);
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
writer.Write((Int32)_lineNumber);
|
||||
writer.Write((Int32)_columnNumber);
|
||||
writer.Write((Int32)_endLineNumber);
|
||||
writer.Write((Int32)_endColumnNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
_importance = (MessageImportance)reader.ReadInt32();
|
||||
|
||||
//The data in the stream beyond this point are new to 4.0
|
||||
if (version > 20)
|
||||
{
|
||||
#region SubCategory
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_subcategory = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_subcategory = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region Code
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_code = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_code = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region File
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_file = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_file = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
_lineNumber = reader.ReadInt32();
|
||||
_columnNumber = reader.ReadInt32();
|
||||
_endLineNumber = reader.ReadInt32();
|
||||
_endColumnNumber = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Importance of the message
|
||||
/// </summary>
|
||||
public MessageImportance Importance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _importance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The custom sub-type of the event.
|
||||
/// </summary>
|
||||
public string Subcategory
|
||||
{
|
||||
get
|
||||
{
|
||||
return _subcategory;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Code associated with event.
|
||||
/// </summary>
|
||||
public string Code
|
||||
{
|
||||
get
|
||||
{
|
||||
return _code;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File associated with event.
|
||||
/// </summary>
|
||||
public string File
|
||||
{
|
||||
get
|
||||
{
|
||||
return _file;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Line number of interest in associated file.
|
||||
/// </summary>
|
||||
public int LineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Column number of interest in associated file.
|
||||
/// </summary>
|
||||
public int ColumnNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _columnNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ending line number of interest in associated file.
|
||||
/// </summary>
|
||||
public int EndLineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endLineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ending column number of interest in associated file.
|
||||
/// </summary>
|
||||
public int EndColumnNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endColumnNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The project which was building when the message was issued.
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_projectFile = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for build started events.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class BuildStartedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
private IDictionary<string, string> _environmentOnBuildStart;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected BuildStartedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to initialize all parameters.
|
||||
/// Sender field cannot be set here and is assumed to be "MSBuild"
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
public BuildStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword
|
||||
)
|
||||
: this(message, helpKeyword, DateTime.UtcNow)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to initialize all parameters.
|
||||
/// Sender field cannot be set here and is assumed to be "MSBuild"
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="environmentOfBuild">A dictionary which lists the environment of the build when the build is started.</param>
|
||||
public BuildStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
IDictionary<string, string> environmentOfBuild
|
||||
)
|
||||
: this(message, helpKeyword, DateTime.UtcNow)
|
||||
{
|
||||
_environmentOnBuildStart = environmentOfBuild;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to allow timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
public BuildStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(message, helpKeyword, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to allow timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
/// <param name="messageArgs">message args</param>
|
||||
public BuildStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp, messageArgs)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The environment which is used at the start of the build
|
||||
/// </summary>
|
||||
public IDictionary<string, string> BuildEnvironment
|
||||
{
|
||||
get { return _environmentOnBuildStart; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for build status events. This class is meant
|
||||
/// to be extended.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public abstract class BuildStatusEventArgs : LazyFormattedBuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected BuildStatusEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
protected BuildStatusEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName
|
||||
)
|
||||
: this(message, helpKeyword, senderName, DateTime.UtcNow)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</pparam>
|
||||
protected BuildStatusEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(message, helpKeyword, senderName, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</pparam>
|
||||
protected BuildStatusEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp, messageArgs)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,354 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for warning events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class BuildWarningEventArgs : LazyFormattedBuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected BuildWarningEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows all event data to be initialized
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
public BuildWarningEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">custom timestamp for the event</param>
|
||||
public BuildWarningEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">custom timestamp for the event</param>
|
||||
/// <param name="messageArgs">message arguments</param>
|
||||
public BuildWarningEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp, messageArgs)
|
||||
{
|
||||
_subcategory = subcategory;
|
||||
_code = code;
|
||||
_file = file;
|
||||
_lineNumber = lineNumber;
|
||||
_columnNumber = columnNumber;
|
||||
_endLineNumber = endLineNumber;
|
||||
_endColumnNumber = endColumnNumber;
|
||||
}
|
||||
|
||||
private string _subcategory;
|
||||
private string _code;
|
||||
private string _file;
|
||||
private string _projectFile;
|
||||
private int _lineNumber;
|
||||
private int _columnNumber;
|
||||
private int _endLineNumber;
|
||||
private int _endColumnNumber;
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes the Errorevent to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
#region SubCategory
|
||||
if (_subcategory == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_subcategory);
|
||||
}
|
||||
#endregion
|
||||
#region Code
|
||||
if (_code == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_code);
|
||||
}
|
||||
#endregion
|
||||
#region File
|
||||
if (_file == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_file);
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
writer.Write((Int32)_lineNumber);
|
||||
writer.Write((Int32)_columnNumber);
|
||||
writer.Write((Int32)_endLineNumber);
|
||||
writer.Write((Int32)_endColumnNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
#region SubCatetory
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_subcategory = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_subcategory = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region Code
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_code = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_code = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region File
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_file = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_file = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (version > 20)
|
||||
{
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
_lineNumber = reader.ReadInt32();
|
||||
_columnNumber = reader.ReadInt32();
|
||||
_endLineNumber = reader.ReadInt32();
|
||||
_endColumnNumber = reader.ReadInt32();
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// The custom sub-type of the event.
|
||||
/// </summary>
|
||||
public string Subcategory
|
||||
{
|
||||
get
|
||||
{
|
||||
return _subcategory;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Code associated with event.
|
||||
/// </summary>
|
||||
public string Code
|
||||
{
|
||||
get
|
||||
{
|
||||
return _code;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File associated with event.
|
||||
/// </summary>
|
||||
public string File
|
||||
{
|
||||
get
|
||||
{
|
||||
return _file;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Line number of interest in associated file.
|
||||
/// </summary>
|
||||
public int LineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Column number of interest in associated file.
|
||||
/// </summary>
|
||||
public int ColumnNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _columnNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ending line number of interest in associated file.
|
||||
/// </summary>
|
||||
public int EndLineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endLineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ending column number of interest in associated file.
|
||||
/// </summary>
|
||||
public int EndColumnNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endColumnNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The project which was building when the message was issued.
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_projectFile = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for critical build message event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for critical message events. These always have High importance.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class CriticalBuildMessageEventArgs : BuildMessageEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// This constructor allows all event data to be initialized
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
public CriticalBuildMessageEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, DateTime.UtcNow)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">custom timestamp for the event</param>
|
||||
public CriticalBuildMessageEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="subcategory">event subcategory</param>
|
||||
/// <param name="code">event code</param>
|
||||
/// <param name="file">file associated with the event</param>
|
||||
/// <param name="lineNumber">line number (0 if not applicable)</param>
|
||||
/// <param name="columnNumber">column number (0 if not applicable)</param>
|
||||
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
|
||||
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimestamp">custom timestamp for the event</param>
|
||||
/// <param name="messageArgs">message arguments</param>
|
||||
public CriticalBuildMessageEventArgs
|
||||
(
|
||||
string subcategory,
|
||||
string code,
|
||||
string file,
|
||||
int lineNumber,
|
||||
int columnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
//// Force importance to High.
|
||||
: base(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, MessageImportance.High, eventTimestamp, messageArgs)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected CriticalBuildMessageEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for custom build events.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public abstract class CustomBuildEventArgs : LazyFormattedBuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected CustomBuildEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of sender</param>
|
||||
protected CustomBuildEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName
|
||||
)
|
||||
: this(message, helpKeyword, senderName, DateTime.UtcNow)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized including timestamp.
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of sender</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
protected CustomBuildEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(message, helpKeyword, senderName, eventTimestamp, null)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized including timestamp.
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of sender</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
/// <param name="messageArgs">Message arguments</param>
|
||||
protected CustomBuildEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp, messageArgs)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Font Name="Tahoma" Size="8.25" />
|
||||
<Class Name="Microsoft.Build.Framework.BuildErrorEventArgs" Collapsed="true">
|
||||
<Position X="6" Y="1.75" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<FileName>BuildErrorEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAAAAgAAAAAAAAAAoAAAArAAEAAgAFAAAABAABAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.BuildEventArgs" Collapsed="true">
|
||||
<Position X="4.75" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<FileName>BuildEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAgAAAAAAAGAAAABgAAAAAAACAAICAgACA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.BuildFinishedEventArgs" Collapsed="true">
|
||||
<Position X="1" Y="4" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>BuildFinishedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.BuildMessageEventArgs" Collapsed="true">
|
||||
<Position X="10.25" Y="1.75" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>BuildMessageEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.BuildStartedEventArgs" Collapsed="true">
|
||||
<Position X="1" Y="3.25" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<FileName>BuildStartedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.BuildStatusEventArgs" Collapsed="true">
|
||||
<Position X="2.5" Y="2" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<FileName>BuildStatusEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.BuildWarningEventArgs" Collapsed="true">
|
||||
<Position X="8" Y="1.75" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>BuildWarningEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAAAAgAAAAAAAAAAoAAAArAAEAAgAFAAAABAABAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.CustomBuildEventArgs" Collapsed="true">
|
||||
<Position X="6.25" Y="2.75" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<FileName>CustomBuildEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.ProjectFinishedEventArgs" Collapsed="true">
|
||||
<Position X="1" Y="5.5" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>ProjectFinishedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAgAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAIA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.ProjectStartedEventArgs" Collapsed="true">
|
||||
<Position X="1" Y="4.75" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>ProjectStartedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAABAAABAAAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.TargetFinishedEventArgs" Collapsed="true">
|
||||
<Position X="3.75" Y="4" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>TargetFinishedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAoAAAADAAAAAQAAAAAAAAAAAAAAAgAAAAIAAAAIA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.TargetStartedEventArgs" Collapsed="true">
|
||||
<Position X="3.75" Y="3.25" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>TargetStartedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAIAAAADAAAAAQAAAAAAAAAAAAAAAgAAAAIAAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.TaskFinishedEventArgs" Collapsed="true">
|
||||
<Position X="3.75" Y="5.5" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<FileName>TaskFinishedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAggAAABIEAAAQBAAAAAAAAAAAAAAAAAAAAAAAAIA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="Microsoft.Build.Framework.TaskStartedEventArgs" Collapsed="true">
|
||||
<Position X="3.75" Y="4.75" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<FileName>TaskStartedEventArgs.cs</FileName>
|
||||
<HashCode>AAAAAgAAABIEAAAQBAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
</ClassDiagram>
|
|
@ -0,0 +1,115 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Will provide location information for an event, this is especially
|
||||
/// needed in a multi processor environment
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuildEventContext
|
||||
{
|
||||
#region Constructor
|
||||
public BuildEventContext
|
||||
(
|
||||
int nodeId,
|
||||
int targetId,
|
||||
int projectContextId,
|
||||
int taskId
|
||||
)
|
||||
{
|
||||
this.nodeId = nodeId;
|
||||
this.targetId = targetId;
|
||||
this.projectContextId = projectContextId;
|
||||
this.taskId = taskId;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// NodeId where event took Place
|
||||
/// </summary>
|
||||
public int NodeId
|
||||
{
|
||||
get
|
||||
{
|
||||
return nodeId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TargetName of the target the event was in when the event was fired
|
||||
/// </summary>
|
||||
public int TargetId
|
||||
{
|
||||
get
|
||||
{
|
||||
return targetId;
|
||||
}
|
||||
}
|
||||
|
||||
public int ProjectContextId
|
||||
{
|
||||
get
|
||||
{
|
||||
return projectContextId;
|
||||
}
|
||||
}
|
||||
|
||||
public int TaskId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.taskId;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
public const int InvalidProjectContextId = -2;
|
||||
public const int InvalidTaskId = -1;
|
||||
public const int InvalidTargetId = -1;
|
||||
public const int InvalidNodeId = -2;
|
||||
#endregion
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (ProjectContextId + (NodeId << 24));
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// If the references are the same no need to do any comparing
|
||||
if (base.Equals(obj))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildEventContext contextToCompare = obj as BuildEventContext;
|
||||
|
||||
if (contextToCompare == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (this.nodeId == contextToCompare.NodeId)
|
||||
&& (this.projectContextId == contextToCompare.ProjectContextId)
|
||||
&& (this.targetId == contextToCompare.TargetId)
|
||||
&& (this.taskId == contextToCompare.TaskId);
|
||||
}
|
||||
|
||||
#region Data
|
||||
// Node event was in
|
||||
private int nodeId;
|
||||
// Target event was in
|
||||
private int targetId;
|
||||
//ProjectContext the event was in
|
||||
private int projectContextId;
|
||||
// Id of the task the event was caused from
|
||||
private int taskId;
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for external project finished events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class ExternalProjectFinishedEventArgs : CustomBuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected ExternalProjectFinishedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// nothing to do here, move along.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Useful constructor
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword</param>
|
||||
/// <param name="senderName">name of the object sending this event</param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="succeeded">true indicates project built successfully</param>
|
||||
public ExternalProjectFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
string projectFile,
|
||||
bool succeeded
|
||||
)
|
||||
: this(message, helpKeyword, senderName, projectFile, succeeded, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Useful constructor including the ability to set the timestamp
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword</param>
|
||||
/// <param name="senderName">name of the object sending this event</param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="succeeded">true indicates project built successfully</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
public ExternalProjectFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
string projectFile,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp)
|
||||
{
|
||||
_projectFile = projectFile;
|
||||
_succeeded = succeeded;
|
||||
}
|
||||
|
||||
private string _projectFile;
|
||||
|
||||
/// <summary>
|
||||
/// Project name
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _succeeded;
|
||||
|
||||
/// <summary>
|
||||
/// True if project built successfully, false otherwise
|
||||
/// </summary>
|
||||
public bool Succeeded
|
||||
{
|
||||
get
|
||||
{
|
||||
return _succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for external project started events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class ExternalProjectStartedEventArgs : CustomBuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected ExternalProjectStartedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// nothing to do here, move along.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Useful constructor
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword</param>
|
||||
/// <param name="senderName">name of the object sending this event</param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="targetNames">targets we are going to build (empty indicates default targets)</param>
|
||||
public ExternalProjectStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
string projectFile,
|
||||
string targetNames
|
||||
)
|
||||
: this(message, helpKeyword, senderName, projectFile, targetNames, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Useful constructor, including the ability to set the timestamp of the event
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword</param>
|
||||
/// <param name="senderName">name of the object sending this event</param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="targetNames">targets we are going to build (empty indicates default targets)</param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
public ExternalProjectStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
string projectFile,
|
||||
string targetNames,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp)
|
||||
{
|
||||
_projectFile = projectFile;
|
||||
_targetNames = targetNames;
|
||||
}
|
||||
|
||||
private string _projectFile;
|
||||
|
||||
/// <summary>
|
||||
/// Project name
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
private string _targetNames;
|
||||
|
||||
/// <summary>
|
||||
/// Targets that we will build in the project. This may mean different things for different project types,
|
||||
/// our tasks will put something like Rebuild, Clean, etc. here. This may be null if the project is being
|
||||
/// built with the default target.
|
||||
/// </summary>
|
||||
public string TargetNames
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// FxCop Suppression file
|
||||
// To Use:
|
||||
// Add add module level suppressions to this file to have them suppressed in the assembly
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
#if CODE_ANALYSIS
|
||||
[module: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]
|
||||
[module: SuppressMessage("Microsoft.MSInternal", "CA905:SystemAndMicrosoftNamespacesRequireApproval", Scope="namespace", Target="Microsoft.Build.CommandLine", Justification="This is an approved namespace.")]
|
||||
[module: SuppressMessage("Microsoft.Naming","CA1709:IdentifiersShouldBeCasedCorrectly", MessageId="STA", Scope="type", Target="Microsoft.Build.Framework.RunInSTAAttribute", Justification="Not worth breaking custormers because of case.")]
|
||||
#endif
|
|
@ -0,0 +1,105 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface exposes functionality on the build engine
|
||||
/// that is required for task authoring.
|
||||
/// </summary>
|
||||
public interface IBuildEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows tasks to raise error events to all registered loggers.
|
||||
/// The build engine may perform some filtering or
|
||||
/// pre-processing on the events, before dispatching them.
|
||||
/// </summary>
|
||||
/// <param name="e">Details of event to raise.</param>
|
||||
void LogErrorEvent(BuildErrorEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Allows tasks to raise warning events to all registered loggers.
|
||||
/// The build engine may perform some filtering or
|
||||
/// pre-processing on the events, before dispatching them.
|
||||
/// </summary>
|
||||
/// <param name="e">Details of event to raise.</param>
|
||||
void LogWarningEvent(BuildWarningEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Allows tasks to raise message events to all registered loggers.
|
||||
/// The build engine may perform some filtering or
|
||||
/// pre-processing on the events, before dispatching them.
|
||||
/// </summary>
|
||||
/// <param name="e">Details of event to raise.</param>
|
||||
void LogMessageEvent(BuildMessageEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Allows tasks to raise custom events to all registered loggers.
|
||||
/// The build engine may perform some filtering or
|
||||
/// pre-processing on the events, before dispatching them.
|
||||
/// </summary>
|
||||
/// <param name="e">Details of event to raise.</param>
|
||||
void LogCustomEvent(CustomBuildEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the ContinueOnError flag was set to true for this particular task
|
||||
/// in the project file.
|
||||
/// </summary>
|
||||
bool ContinueOnError
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the line number of the task node withing the project file that called it.
|
||||
/// </summary>
|
||||
int LineNumberOfTaskNode
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the line number of the task node withing the project file that called it.
|
||||
/// </summary>
|
||||
int ColumnNumberOfTaskNode
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the full path to the project file that contained the call to this task.
|
||||
/// </summary>
|
||||
string ProjectFileOfTaskNode
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method allows tasks to initiate a build on a
|
||||
/// particular project file. If the build is successful, the outputs
|
||||
/// (if any) of the specified targets are returned.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 1) it is acceptable to pass null for both <c>targetNames</c> and <c>targetOutputs</c>
|
||||
/// 2) if no targets are specified, the default targets are built
|
||||
/// 3) target outputs are returned as <c>ITaskItem</c> arrays indexed by target name
|
||||
/// </remarks>
|
||||
/// <param name="projectFileName">The project to build.</param>
|
||||
/// <param name="targetNames">The targets in the project to build (can be null).</param>
|
||||
/// <param name="globalProperties">A hash table of additional global properties to apply
|
||||
/// to the child project (can be null). The key and value should both be strings.</param>
|
||||
/// <param name="targetOutputs">The outputs of each specified target (can be null).</param>
|
||||
/// <returns>true, if build was successful</returns>
|
||||
bool BuildProjectFile
|
||||
(
|
||||
string projectFileName,
|
||||
string[] targetNames,
|
||||
IDictionary globalProperties,
|
||||
IDictionary targetOutputs
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface extends IBuildEngine to provide a method allowing building
|
||||
/// project files in parallel.
|
||||
/// </summary>
|
||||
public interface IBuildEngine2 : IBuildEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// This property allows a task to query whether or not the system is running in single process mode or multi process mode.
|
||||
/// Single process mode (IsRunningMultipleNodes = false) is where the engine is initialized with the number of cpus = 1 and the engine is not a child engine.
|
||||
/// The engine is in multi process mode (IsRunningMultipleNodes = true) when the engine is initialized with a number of cpus > 1 or the engine is a child engine.
|
||||
/// </summary>
|
||||
bool IsRunningMultipleNodes
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method allows tasks to initiate a build on a
|
||||
/// particular project file. If the build is successful, the outputs
|
||||
/// (if any) of the specified targets are returned.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 1) it is acceptable to pass null for both <c>targetNames</c> and <c>targetOutputs</c>
|
||||
/// 2) if no targets are specified, the default targets are built
|
||||
/// 3) target outputs are returned as <c>ITaskItem</c> arrays indexed by target name
|
||||
/// </remarks>
|
||||
/// <param name="projectFileName">The project to build.</param>
|
||||
/// <param name="targetNames">The targets in the project to build (can be null).</param>
|
||||
/// <param name="globalProperties">A hash table of additional global properties to apply
|
||||
/// to the child project (can be null). The key and value should both be strings.</param>
|
||||
/// <param name="targetOutputs">The outputs of each specified target (can be null).</param>
|
||||
/// <param name="toolsVersion">A tools version recognized by the Engine that will be used during this build (can be null).</param>
|
||||
/// <returns>true, if build was successful</returns>
|
||||
bool BuildProjectFile
|
||||
(
|
||||
string projectFileName,
|
||||
string[] targetNames,
|
||||
IDictionary globalProperties,
|
||||
IDictionary targetOutputs,
|
||||
string toolsVersion
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// This method allows tasks to initiate a build on a
|
||||
/// particular project file. If the build is successful, the outputs
|
||||
/// (if any) of the specified targets are returned.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 1) it is acceptable to pass null for both <c>targetNames</c> and <c>targetOutputs</c>
|
||||
/// 2) if no targets are specified, the default targets are built
|
||||
/// 3) target outputs are returned as <c>ITaskItem</c> arrays indexed by target name
|
||||
/// </remarks>
|
||||
/// <param name="projectFileNames">The project to build.</param>
|
||||
/// <param name="targetNames">The targets in the project to build (can be null).</param>
|
||||
/// <param name="globalProperties">An array of hashtables of additional global properties to apply
|
||||
/// to the child project (array entries can be null).
|
||||
/// The key and value in the hashtable should both be strings.</param>
|
||||
/// <param name="targetOutputsPerProject">The outputs of each specified target (can be null).</param>
|
||||
/// <param name="toolsVersion">A tools version recognized by the Engine that will be used during this build (can be null).</param>
|
||||
/// <param name="useResultsCache">If true the operation will only be run if the cache doesn't
|
||||
/// already contain the result. After the operation the result is
|
||||
/// stored in the cache </param>
|
||||
/// <param name="unloadProjectsOnCompletion">If true the project will be unloaded once the
|
||||
/// operation is completed </param>
|
||||
/// <returns>true, if build was successful</returns>
|
||||
bool BuildProjectFilesInParallel
|
||||
(
|
||||
string[] projectFileNames,
|
||||
string[] targetNames,
|
||||
IDictionary[] globalProperties,
|
||||
IDictionary[] targetOutputsPerProject,
|
||||
string[] toolsVersion,
|
||||
bool useResultsCache,
|
||||
bool unloadProjectsOnCompletion
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// <summary>Interface for tasks to communicate with the MSBuild engine.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface extends IBuildEngine to provide a method allowing building
|
||||
/// project files in parallel.
|
||||
/// </summary>
|
||||
public interface IBuildEngine3 : IBuildEngine2
|
||||
{
|
||||
/// <summary>
|
||||
/// This method allows tasks to initiate a build on a
|
||||
/// particular project file. If the build is successful, the outputs
|
||||
/// (if any) of the specified targets are returned.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 1) it is acceptable to pass null for both <c>targetNames</c> and <c>targetOutputs</c>
|
||||
/// 2) if no targets are specified, the default targets are built
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="projectFileNames">The project to build.</param>
|
||||
/// <param name="targetNames">The targets in the project to build (can be null).</param>
|
||||
/// <param name="globalProperties">An array of hashtables of additional global properties to apply
|
||||
/// to the child project (array entries can be null).
|
||||
/// The key and value in the hashtable should both be strings.</param>
|
||||
/// <param name="removeGlobalProperties">A list of global properties which should be removed.</param>
|
||||
/// <param name="toolsVersion">A tools version recognized by the Engine that will be used during this build (can be null).</param>
|
||||
/// <param name="returnTargetOutputs">Should the target outputs be returned in the BuildEngineResult</param>
|
||||
/// <returns>Returns a structure containing the success or failure of the build and the target outputs by project.</returns>
|
||||
BuildEngineResult BuildProjectFilesInParallel
|
||||
(
|
||||
string[] projectFileNames,
|
||||
string[] targetNames,
|
||||
IDictionary[] globalProperties,
|
||||
IList<string>[] removeGlobalProperties,
|
||||
string[] toolsVersion,
|
||||
bool returnTargetOutputs
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Informs the system that this task has a long-running out-of-process component and other work can be done in the
|
||||
/// build while that work completes.
|
||||
/// </summary>
|
||||
void Yield();
|
||||
|
||||
/// <summary>
|
||||
/// Waits to reacquire control after yielding.
|
||||
/// </summary>
|
||||
void Reacquire();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Interface for tasks to communicate with the MSBuild engine.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the lifetime of a registered task object.
|
||||
/// </summary>
|
||||
public enum RegisteredTaskObjectLifetime
|
||||
{
|
||||
/// <summary>
|
||||
/// The registered object will be disposed when the build ends.
|
||||
/// </summary>
|
||||
Build,
|
||||
|
||||
/// <summary>
|
||||
/// The registered object will be disposed when the AppDomain is unloaded.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The AppDomain to which this refers is the one in which MSBuild was launched,
|
||||
/// not the one in which the Task was launched.
|
||||
/// </remarks>
|
||||
AppDomain,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface extends IBuildEngine to provide a mechanism allowing tasks to
|
||||
/// share data between task invocations.
|
||||
/// </summary>
|
||||
public interface IBuildEngine4 : IBuildEngine3
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers an object with the system that will be disposed of at some specified time
|
||||
/// in the future.
|
||||
/// </summary>
|
||||
/// <param name="key">The key used to retrieve the object.</param>
|
||||
/// <param name="obj">The object to be held for later disposal.</param>
|
||||
/// <param name="lifetime">The lifetime of the object.</param>
|
||||
/// <param name="allowEarlyCollection">The object may be disposed earlier that the requested time if
|
||||
/// MSBuild needs to reclaim memory.</param>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method may be called by tasks which need to maintain state across task invocations,
|
||||
/// such as to cache data which may be expensive to generate but which is known not to change during the
|
||||
/// build. It is strongly recommended that <paramref name="allowEarlyCollection"/> be set to true if the
|
||||
/// object will retain any significant amount of data, as this gives MSBuild the most flexibility to
|
||||
/// manage limited process memory resources.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The thread on which the object is disposed may be arbitrary - however it is guaranteed not to
|
||||
/// be disposed while the task is executing, even if <paramref name="allowEarlyCollection"/> is set
|
||||
/// to true.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If the object implements IDisposable, IDisposable.Dispose will be invoked on the object before
|
||||
/// discarding it.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "Shipped this way in Dev11 Beta, which is go-live")]
|
||||
void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a previously registered task object stored with the specified key.
|
||||
/// </summary>
|
||||
/// <param name="key">The key used to retrieve the object.</param>
|
||||
/// <param name="lifetime">The lifetime of the object.</param>
|
||||
/// <returns>
|
||||
/// The registered object, or null is there is no object registered under that key or the object
|
||||
/// has been discarded through early collection.
|
||||
/// </returns>
|
||||
object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime);
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters a previously-registered task object.
|
||||
/// </summary>
|
||||
/// <param name="key">The key used to retrieve the object.</param>
|
||||
/// <param name="lifetime">The lifetime of the object.</param>
|
||||
/// <returns>
|
||||
/// The registered object, or null is there is no object registered under that key or the object
|
||||
/// has been discarded through early collection.
|
||||
/// </returns>
|
||||
object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Interface for tasks which can be cancelled.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for tasks which can be cancelled.
|
||||
/// </summary>
|
||||
public interface ICancelableTask : ITask
|
||||
{
|
||||
/// <summary>
|
||||
/// Instructs the task to exit as soon as possible, or to immediately exit if Execute is invoked after this method.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Cancel() may be called at any time after the task has been instantiated, even before <see cref="ITask.Execute()"/> is called.
|
||||
/// Cancel calls may come in from any thread. The implementation of this method should not block indefinitely.
|
||||
/// </remarks>
|
||||
void Cancel();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface is used to forward events to another loggers
|
||||
/// </summary>
|
||||
public interface IEventRedirector
|
||||
{
|
||||
/// <summary>
|
||||
/// This method is called by the node loggers to forward the events to central logger
|
||||
/// </summary>
|
||||
void ForwardEvent(BuildEventArgs buildEvent);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of handler for MessageRaised events
|
||||
/// </summary>
|
||||
public delegate void BuildMessageEventHandler(object sender, BuildMessageEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for ErrorRaised events
|
||||
/// </summary>
|
||||
public delegate void BuildErrorEventHandler(object sender, BuildErrorEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for WarningRaised events
|
||||
/// </summary>
|
||||
public delegate void BuildWarningEventHandler(object sender, BuildWarningEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for CustomEventRaised events
|
||||
/// </summary>
|
||||
public delegate void CustomBuildEventHandler(object sender, CustomBuildEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for BuildStartedEvent events
|
||||
/// </summary>
|
||||
public delegate void BuildStartedEventHandler(object sender, BuildStartedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for BuildFinishedEvent events
|
||||
/// </summary>
|
||||
public delegate void BuildFinishedEventHandler(object sender, BuildFinishedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for ProjectStarted events
|
||||
/// </summary>
|
||||
public delegate void ProjectStartedEventHandler(object sender, ProjectStartedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for ProjectFinished events
|
||||
/// </summary>
|
||||
public delegate void ProjectFinishedEventHandler(object sender, ProjectFinishedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for TargetStarted events
|
||||
/// </summary>
|
||||
public delegate void TargetStartedEventHandler(object sender, TargetStartedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for TargetFinished events
|
||||
/// </summary>
|
||||
public delegate void TargetFinishedEventHandler(object sender, TargetFinishedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for TaskStarted events
|
||||
/// </summary>
|
||||
public delegate void TaskStartedEventHandler(object sender, TaskStartedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for TaskFinished events
|
||||
/// </summary>
|
||||
public delegate void TaskFinishedEventHandler(object sender, TaskFinishedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for BuildStatus events
|
||||
/// </summary>
|
||||
public delegate void BuildStatusEventHandler(object sender, BuildStatusEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Type of handler for AnyEventRaised events
|
||||
/// </summary>
|
||||
public delegate void AnyEventHandler(object sender, BuildEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// This interface defines the events raised by the build engine.
|
||||
/// Loggers use this interface to subscribe to the events they
|
||||
/// are interested in receiving.
|
||||
/// </summary>
|
||||
public interface IEventSource
|
||||
{
|
||||
/// <summary>
|
||||
/// this event is raised to log a message
|
||||
/// </summary>
|
||||
event BuildMessageEventHandler MessageRaised;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log an error
|
||||
/// </summary>
|
||||
event BuildErrorEventHandler ErrorRaised;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log a warning
|
||||
/// </summary>
|
||||
event BuildWarningEventHandler WarningRaised;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the start of a build
|
||||
/// </summary>
|
||||
event BuildStartedEventHandler BuildStarted;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the end of a build
|
||||
/// </summary>
|
||||
event BuildFinishedEventHandler BuildFinished;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the start of a project build
|
||||
/// </summary>
|
||||
event ProjectStartedEventHandler ProjectStarted;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the end of a project build
|
||||
/// </summary>
|
||||
event ProjectFinishedEventHandler ProjectFinished;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the start of a target build
|
||||
/// </summary>
|
||||
event TargetStartedEventHandler TargetStarted;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the end of a target build
|
||||
/// </summary>
|
||||
event TargetFinishedEventHandler TargetFinished;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the start of task execution
|
||||
/// </summary>
|
||||
event TaskStartedEventHandler TaskStarted;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log the end of task execution
|
||||
/// </summary>
|
||||
event TaskFinishedEventHandler TaskFinished;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log custom events
|
||||
/// </summary>
|
||||
event CustomBuildEventHandler CustomEventRaised;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log any build status event
|
||||
/// </summary>
|
||||
event BuildStatusEventHandler StatusEventRaised;
|
||||
|
||||
/// <summary>
|
||||
/// this event is raised to log any build event
|
||||
/// </summary>
|
||||
event AnyEventHandler AnyEventRaised;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface extends the ILogger interface to provide a property which can be used to forward events
|
||||
/// to a logger running in a different process. It can also be used create filtering loggers.
|
||||
/// </summary>
|
||||
public interface IForwardingLogger : INodeLogger
|
||||
{
|
||||
/// <summary>
|
||||
/// This property is set by the build engine to allow a node loggers to forward messages to the
|
||||
/// central logger
|
||||
/// </summary>
|
||||
IEventRedirector BuildEventRedirector
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This property is set by the build engine or node to inform the forwarding logger which node it is running on
|
||||
/// </summary>
|
||||
int NodeId
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>An interface implemented by tasks that are generated by ITaskFactory instances.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface implemented by tasks that are generated by ITaskFactory instances.
|
||||
/// </summary>
|
||||
public interface IGeneratedTask : ITask
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets a value on a property of this task instance.
|
||||
/// </summary>
|
||||
/// <param name="property">The property to set.</param>
|
||||
/// <param name="value">The value to set. The caller is responsible to type-coerce this value to match the property's <see cref="TaskPropertyInfo.PropertyType"/>.</param>
|
||||
/// <remarks>
|
||||
/// All exceptions from this method will be caught in the taskExecution host and logged as a fatal task error
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Property", Justification = "Public API that has shipped")]
|
||||
void SetPropertyValue(TaskPropertyInfo property, object value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property value.
|
||||
/// </summary>
|
||||
/// <param name="property">The property to get.</param>
|
||||
/// <returns>
|
||||
/// The value of the property, the value's type will match the type given by <see cref="TaskPropertyInfo.PropertyType"/>.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// MSBuild calls this method after executing the task to get output parameters.
|
||||
/// All exceptions from this method will be caught in the taskExecution host and logged as a fatal task error
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Property", Justification = "Public API that has shipped")]
|
||||
object GetPropertyValue(TaskPropertyInfo property);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration of the levels of detail of an event log.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The level of detail (i.e. verbosity) of an event log is entirely controlled by the logger generating the log -- a logger
|
||||
/// will be directed to keep its verbosity at a certain level, based on user preferences, but a logger is free to choose the
|
||||
/// events it logs for each verbosity level.
|
||||
///
|
||||
/// LOGGING GUIDELINES FOR EACH VERBOSITY LEVEL:
|
||||
/// 1) Quiet -- only display a summary at the end of build
|
||||
/// 2) Minimal -- only display errors, warnings, high importance events and a build summary
|
||||
/// 3) Normal -- display all errors, warnings, high importance events, some status events, and a build summary
|
||||
/// 4) Detailed -- display all errors, warnings, high and normal importance events, all status events, and a build summary
|
||||
/// 5) Diagnostic -- display all events, and a build summary
|
||||
///
|
||||
/// WARNING: VS Automation code for the Tools/Options MSBuild build verbosity setting will be broken
|
||||
/// by changes to this enum (not to mention existing MSBuild clients and vsproject code).
|
||||
/// Please make sure to talk to automation devs before changing it.
|
||||
/// </remarks>
|
||||
[ComVisible(true)]
|
||||
public enum LoggerVerbosity
|
||||
{
|
||||
/// <summary>
|
||||
/// The most minimal output
|
||||
/// </summary>
|
||||
Quiet,
|
||||
|
||||
/// <summary>
|
||||
/// Relatively little output
|
||||
/// </summary>
|
||||
Minimal,
|
||||
|
||||
/// <summary>
|
||||
/// Standard output. This should be the default if verbosity level is not set
|
||||
/// </summary>
|
||||
Normal,
|
||||
|
||||
/// <summary>
|
||||
/// Relatively verbose, but not exhaustive
|
||||
/// </summary>
|
||||
Detailed,
|
||||
|
||||
/// <summary>
|
||||
/// The most verbose and informative verbosity
|
||||
/// </summary>
|
||||
Diagnostic
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface defines a "logger" in the build system. A logger subscribes to build system events. All logger classes must
|
||||
/// implement this interface to be recognized by the build engine.
|
||||
/// </summary>
|
||||
[ComVisible(true)]
|
||||
public interface ILogger
|
||||
{
|
||||
/// <summary>
|
||||
/// The verbosity level directs the amount of detail that appears in a logger's event log. Though this is only a
|
||||
/// recommendation based on user preferences, and a logger is free to choose the exact events it logs, it is still
|
||||
/// important that the guidelines for each level be followed, for a good user experience.
|
||||
/// </summary>
|
||||
/// <value>The verbosity level.</value>
|
||||
LoggerVerbosity Verbosity
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This property holds the user-specified parameters to the logger. If parameters are not provided, a logger should revert
|
||||
/// to defaults. If a logger does not take parameters, it can ignore this property.
|
||||
/// </summary>
|
||||
/// <value>The parameter string (can be null).</value>
|
||||
string Parameters
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the build engine to allow loggers to subscribe to the events they desire.
|
||||
/// </summary>
|
||||
/// <param name="eventSource">The events available to loggers.</param>
|
||||
void Initialize(IEventSource eventSource);
|
||||
|
||||
/// <summary>
|
||||
/// Called by the build engine to allow loggers to release any resources they may have allocated at initialization time,
|
||||
/// or during the build.
|
||||
/// </summary>
|
||||
void Shutdown();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface defines a "parallel aware logger" in the build system. A parallel aware logger
|
||||
/// will accept a cpu count and be aware that any cpu count greater than 1 means the events will
|
||||
/// be received from the logger from each cpu as the events are logged.
|
||||
/// </summary>
|
||||
[ComVisible(true)]
|
||||
public interface INodeLogger : ILogger
|
||||
{
|
||||
void Initialize(IEventSource eventSource, int nodeCount);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface defines a "task" in the build system. A task is an atomic unit of build operation. All task classes must
|
||||
/// implement this interface to be recognized by the build engine.
|
||||
/// </summary>
|
||||
public interface ITask
|
||||
{
|
||||
/// <summary>
|
||||
/// This property is set by the build engine to allow a task to call back into it.
|
||||
/// </summary>
|
||||
/// <value>The interface on the build engine available to tasks.</value>
|
||||
IBuildEngine BuildEngine
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The build engine sets this property if the host IDE has associated a host object with this particular task.
|
||||
/// </summary>
|
||||
/// <value>The host object instance (can be null).</value>
|
||||
ITaskHost HostObject
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by the build engine to begin task execution. A task uses the return value to indicate
|
||||
/// whether it was successful. If a task throws an exception out of this method, the engine will automatically
|
||||
/// assume that the task has failed.
|
||||
/// </summary>
|
||||
/// <returns>true, if successful</returns>
|
||||
bool Execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Task factory Instance which will instantiate and execute tasks</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that a task factory Instance should implement
|
||||
/// </summary>
|
||||
public interface ITaskFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the factory.
|
||||
/// </summary>
|
||||
/// <value>The name of the factory.</value>
|
||||
string FactoryName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the task this factory will instantiate.
|
||||
/// </summary>
|
||||
Type TaskType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this factory for instantiating tasks with a particular inline task block.
|
||||
/// </summary>
|
||||
/// <param name="taskName">Name of the task.</param>
|
||||
/// <param name="parameterGroup">The parameter group.</param>
|
||||
/// <param name="taskBody">The task body.</param>
|
||||
/// <param name="taskFactoryLoggingHost">The task factory logging host.</param>
|
||||
/// <returns>A value indicating whether initialization was successful.</returns>
|
||||
/// <remarks>
|
||||
/// <para>MSBuild engine will call this to initialize the factory. This should initialize the factory enough so that the factory can be asked
|
||||
/// whether or not task names can be created by the factory.</para>
|
||||
/// <para>
|
||||
/// The taskFactoryLoggingHost will log messages in the context of the target where the task is first used.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
bool Initialize(string taskName, IDictionary<string, TaskPropertyInfo> parameterGroup, string taskBody, IBuildEngine taskFactoryLoggingHost);
|
||||
|
||||
/// <summary>
|
||||
/// Get the descriptions for all the task's parameters.
|
||||
/// </summary>
|
||||
/// <returns>A non-null array of property descriptions.</returns>
|
||||
TaskPropertyInfo[] GetTaskParameters();
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of the task to be used.
|
||||
/// </summary>
|
||||
/// <param name="taskFactoryLoggingHost">
|
||||
/// The task factory logging host will log messages in the context of the task.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The generated task, or <c>null</c> if the task failed to be created.
|
||||
/// </returns>
|
||||
ITask CreateTask(IBuildEngine taskFactoryLoggingHost);
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up any context or state that may have been built up for a given task.
|
||||
/// </summary>
|
||||
/// <param name="task">The task to clean up.</param>
|
||||
/// <remarks>
|
||||
/// For many factories, this method is a no-op. But some factories may have built up
|
||||
/// an AppDomain as part of an individual task instance, and this is their opportunity
|
||||
/// to shutdown the AppDomain.
|
||||
/// </remarks>
|
||||
void CleanupTask(ITask task);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Task factory Instance which will instantiate and execute tasks</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that a task factory Instance should implement if it wants to be able to
|
||||
/// use new UsingTask parameters such as Runtime and Architecture.
|
||||
/// </summary>
|
||||
public interface ITaskFactory2 : ITaskFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes this factory for instantiating tasks with a particular inline task block and a set of UsingTask parameters. MSBuild
|
||||
/// provides an implementation of this interface, TaskHostFactory, that uses "Runtime", with values "CLR2", "CLR4", "CurrentRuntime",
|
||||
/// and "*" (Any); and "Architecture", with values "x86", "x64", "CurrentArchitecture", and "*" (Any). An implementer of ITaskFactory2
|
||||
/// can choose to use these pre-defined Runtime and Architecture values, or can specify new values for these parameters.
|
||||
/// </summary>
|
||||
/// <param name="taskName">Name of the task.</param>
|
||||
/// <param name="factoryIdentityParameters">Special parameters that the task factory can use to modify how it executes tasks,
|
||||
/// such as Runtime and Architecture. The key is the name of the parameter and the value is the parameter's value. This
|
||||
/// is the set of parameters that was set on the UsingTask using e.g. the UsingTask Runtime and Architecture parameters.</param>
|
||||
/// <param name="parameterGroup">The parameter group.</param>
|
||||
/// <param name="taskBody">The task body.</param>
|
||||
/// <param name="taskFactoryLoggingHost">The task factory logging host.</param>
|
||||
/// <returns>A value indicating whether initialization was successful.</returns>
|
||||
/// <remarks>
|
||||
/// <para>MSBuild engine will call this to initialize the factory. This should initialize the factory enough so that the
|
||||
/// factory can be asked whether or not task names can be created by the factory. If a task factory implements ITaskFactory2,
|
||||
/// this Initialize method will be called in place of ITaskFactory.Initialize.</para>
|
||||
/// <para>
|
||||
/// The taskFactoryLoggingHost will log messages in the context of the target where the task is first used.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
bool Initialize(string taskName, IDictionary<string, string> factoryIdentityParameters, IDictionary<string, TaskPropertyInfo> parameterGroup, string taskBody, IBuildEngine taskFactoryLoggingHost);
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of the task to be used, with an optional set of "special" parameters set on the individual task invocation using
|
||||
/// the MSBuildRuntime and MSBuildArchitecture default task parameters. MSBuild provides an implementation of this interface,
|
||||
/// TaskHostFactory, that uses "MSBuildRuntime", with values "CLR2", "CLR4", "CurrentRuntime", and "*" (Any); and "MSBuildArchitecture",
|
||||
/// with values "x86", "x64", "CurrentArchitecture", and "*" (Any). An implementer of ITaskFactory2 can choose to use these pre-defined
|
||||
/// MSBuildRuntime and MSBuildArchitecture values, or can specify new values for these parameters.
|
||||
/// </summary>
|
||||
/// <param name="taskFactoryLoggingHost">
|
||||
/// The task factory logging host will log messages in the context of the task.
|
||||
/// </param>
|
||||
/// <param name="taskIdentityParameters">
|
||||
/// Special parameters that the task factory can use to modify how it executes tasks, such as Runtime and Architecture.
|
||||
/// The key is the name of the parameter and the value is the parameter's value. This is the set of parameters that was
|
||||
/// set to the task invocation itself, via e.g. the special MSBuildRuntime and MSBuildArchitecture parameters.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// If a task factory implements ITaskFactory2, MSBuild will call this method instead of ITaskFactory.CreateTask.
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// The generated task, or <c>null</c> if the task failed to be created.
|
||||
/// </returns>
|
||||
ITask CreateTask(IBuildEngine taskFactoryLoggingHost, IDictionary<string, string> taskIdentityParameters);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This empty interface is used to pass host objects from an IDE to individual
|
||||
/// tasks. Depending on the task itself and what kinds parameters and functionality
|
||||
/// it exposes, the task should define its own interface that inherits from this one,
|
||||
/// and then use that interface to communicate with the host.
|
||||
/// </summary>
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComVisible(true)]
|
||||
[Guid("9049A481-D0E9-414f-8F92-D4F67A0359A6")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Justification = "This empty interface is used to pass host objects from an IDE to individual")]
|
||||
public interface ITaskHost
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface defines a project item that can be consumed and emitted by tasks.
|
||||
/// </summary>
|
||||
[ComVisible(true)]
|
||||
[Guid("8661674F-2148-4F71-A92A-49875511C528")]
|
||||
public interface ITaskItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the item "specification" e.g. for disk-based items this would be the file path.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should be named "EvaluatedInclude" but that would be a breaking change to this interface.
|
||||
/// </remarks>
|
||||
/// <value>The item-spec string.</value>
|
||||
string ItemSpec
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the names of all the metadata on the item.
|
||||
/// Includes the built-in metadata like "FullPath".
|
||||
/// </summary>
|
||||
/// <value>The list of metadata names.</value>
|
||||
ICollection MetadataNames
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of pieces of metadata on the item. Includes
|
||||
/// both custom and built-in metadata.
|
||||
/// </summary>
|
||||
/// <value>Count of pieces of metadata.</value>
|
||||
int MetadataCount
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the values of metadata on the item to be queried.
|
||||
/// </summary>
|
||||
/// <param name="metadataName">The name of the metadata to retrieve.</param>
|
||||
/// <returns>The value of the specified metadata.</returns>
|
||||
string GetMetadata(string metadataName);
|
||||
|
||||
/// <summary>
|
||||
/// Allows a piece of custom metadata to be set on the item.
|
||||
/// </summary>
|
||||
/// <param name="metadataName">The name of the metadata to set.</param>
|
||||
/// <param name="metadataValue">The metadata value.</param>
|
||||
void SetMetadata(string metadataName, string metadataValue);
|
||||
|
||||
/// <summary>
|
||||
/// Allows the removal of custom metadata set on the item.
|
||||
/// </summary>
|
||||
/// <param name="metadataName">The name of the metadata to remove.</param>
|
||||
void RemoveMetadata(string metadataName);
|
||||
|
||||
/// <summary>
|
||||
/// Allows custom metadata on the item to be copied to another item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// RECOMMENDED GUIDELINES FOR METHOD IMPLEMENTATIONS:
|
||||
/// 1) this method should NOT copy over the item-spec
|
||||
/// 2) if a particular piece of metadata already exists on the destination item, it should NOT be overwritten
|
||||
/// 3) if there are pieces of metadata on the item that make no semantic sense on the destination item, they should NOT be copied
|
||||
/// </remarks>
|
||||
/// <param name="destinationItem">The item to copy metadata to.</param>
|
||||
void CopyMetadataTo(ITaskItem destinationItem);
|
||||
|
||||
/// <summary>
|
||||
/// Get the collection of custom metadata. This does not include built-in metadata.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// RECOMMENDED GUIDELINES FOR METHOD IMPLEMENTATIONS:
|
||||
/// 1) this method should return a clone of the metadata
|
||||
/// 2) writing to this dictionary should not be reflected in the underlying item.
|
||||
/// </remarks>
|
||||
/// <returns>Dictionary of cloned metadata</returns>
|
||||
IDictionary CloneCustomMetadata();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>An improvement to ITaskItem that makes it possible for implementations to avoid losing escaping information.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface adds escaping support to the ITaskItem interface.
|
||||
/// </summary>
|
||||
[ComVisible(true)]
|
||||
[Guid("ac6d5a59-f877-461b-88e3-b2f06fce0cb9")]
|
||||
public interface ITaskItem2 : ITaskItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the item include value e.g. for disk-based items this would be the file path.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Taking the opportunity to fix the property name, although this doesn't
|
||||
/// make it obvious it's an improvement on ItemSpec.
|
||||
/// </remarks>
|
||||
string EvaluatedIncludeEscaped
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the values of metadata on the item to be queried.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Taking the opportunity to fix the property name, although this doesn't
|
||||
/// make it obvious it's an improvement on GetMetadata.
|
||||
/// </remarks>
|
||||
string GetMetadataValueEscaped(string metadataName);
|
||||
|
||||
/// <summary>
|
||||
/// Allows a piece of custom metadata to be set on the item. Assumes that the value passed
|
||||
/// in is unescaped, and escapes the value as necessary in order to maintain its value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Taking the opportunity to fix the property name, although this doesn't
|
||||
/// make it obvious it's an improvement on SetMetadata.
|
||||
/// </remarks>
|
||||
void SetMetadataValueLiteral(string metadataName, string metadataValue);
|
||||
|
||||
/// <summary>
|
||||
/// ITaskItem2 implementation which returns a clone of the metadata on this object.
|
||||
/// Values returned are in their original escaped form.
|
||||
/// </summary>
|
||||
/// <returns>The cloned metadata, with values' escaping preserved.</returns>
|
||||
IDictionary CloneCustomMetadataEscaped();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,296 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for any build event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores strings for parts of a message delaying the formatting until it needs to be shown
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class LazyFormattedBuildEventArgs : BuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores the message arguments.
|
||||
/// </summary>
|
||||
private object[] _arguments;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the original culture for String.Format.
|
||||
/// </summary>
|
||||
private CultureInfo _originalCulture;
|
||||
|
||||
/// <summary>
|
||||
/// Lock object.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
private Object _locker;
|
||||
|
||||
/// <summary>
|
||||
/// This constuctor allows all event data to be initialized.
|
||||
/// </summary>
|
||||
/// <param name="message">text message.</param>
|
||||
/// <param name="helpKeyword">help keyword.</param>
|
||||
/// <param name="senderName">name of event sender.</param>
|
||||
public LazyFormattedBuildEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName
|
||||
)
|
||||
: this(message, helpKeyword, senderName, DateTime.Now, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constuctor that allows message arguments that are lazily formatted.
|
||||
/// </summary>
|
||||
/// <param name="message">text message.</param>
|
||||
/// <param name="helpKeyword">help keyword.</param>
|
||||
/// <param name="senderName">name of event sender.</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created.</param>
|
||||
/// <param name="messageArgs">Message arguments.</param>
|
||||
public LazyFormattedBuildEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp,
|
||||
params object[] messageArgs
|
||||
)
|
||||
: base(message, helpKeyword, senderName, eventTimestamp)
|
||||
{
|
||||
_arguments = messageArgs;
|
||||
_originalCulture = CultureInfo.CurrentCulture;
|
||||
_locker = new Object();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
protected LazyFormattedBuildEventArgs()
|
||||
: base()
|
||||
{
|
||||
_locker = new Object();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the formatted message.
|
||||
/// </summary>
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_arguments != null && _arguments.Length > 0)
|
||||
{
|
||||
base.Message = FormatString(_originalCulture, base.Message, _arguments);
|
||||
_arguments = null;
|
||||
}
|
||||
}
|
||||
|
||||
return base.Message;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer.
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into.</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
// Locking is needed here as this is invoked on the serialization thread,
|
||||
// whereas a local logger (a distributed logger) may concurrently invoke this.Message
|
||||
// which will trigger formatting and thus the exception below
|
||||
lock (_locker)
|
||||
{
|
||||
bool hasArguments = _arguments != null;
|
||||
base.WriteToStream(writer);
|
||||
|
||||
if (hasArguments && _arguments == null)
|
||||
{
|
||||
throw new InvalidOperationException("BuildEventArgs has formatted message while serializing!");
|
||||
}
|
||||
|
||||
if (_arguments != null)
|
||||
{
|
||||
writer.Write(_arguments.Length);
|
||||
|
||||
foreach (object argument in _arguments)
|
||||
{
|
||||
// Arguments may be ints, etc, so explicitly convert
|
||||
// Convert.ToString returns String.Empty when it cannot convert, rather than throwing
|
||||
writer.Write(Convert.ToString(argument, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((Int32)(-1));
|
||||
}
|
||||
|
||||
writer.Write(_originalCulture != null ? _originalCulture.LCID : 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader.
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from.</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, Int32 version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
|
||||
if (version > 20)
|
||||
{
|
||||
string[] messageArgs = null;
|
||||
int numArguments = reader.ReadInt32();
|
||||
|
||||
if (numArguments >= 0)
|
||||
{
|
||||
messageArgs = new string[numArguments];
|
||||
|
||||
for (int numRead = 0; numRead < numArguments; numRead++)
|
||||
{
|
||||
messageArgs[numRead] = reader.ReadString();
|
||||
}
|
||||
}
|
||||
|
||||
_arguments = messageArgs;
|
||||
|
||||
int originalCultureId = reader.ReadInt32();
|
||||
if (originalCultureId != 0)
|
||||
{
|
||||
if (originalCultureId == CultureInfo.CurrentCulture.LCID)
|
||||
{
|
||||
_originalCulture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
else
|
||||
{
|
||||
_originalCulture = new CultureInfo(originalCultureId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats the given string using the variable arguments passed in.
|
||||
///
|
||||
/// PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
|
||||
/// the array of arguments -- do not call this method repeatedly in performance-critical scenarios
|
||||
/// </summary>
|
||||
/// <remarks>This method is thread-safe.</remarks>
|
||||
/// <param name="culture">The culture info for formatting the message.</param>
|
||||
/// <param name="unformatted">The string to format.</param>
|
||||
/// <param name="args">Optional arguments for formatting the given string.</param>
|
||||
/// <returns>The formatted string.</returns>
|
||||
private static string FormatString(CultureInfo culture, string unformatted, params object[] args)
|
||||
{
|
||||
// Based on the one in Shared/ResourceUtilities.
|
||||
string formatted = unformatted;
|
||||
|
||||
// NOTE: String.Format() does not allow a null arguments array
|
||||
if ((args != null) && (args.Length > 0))
|
||||
{
|
||||
#if DEBUG && !BUILDING_DF_LKG
|
||||
|
||||
#if VALIDATERESOURCESTRINGS
|
||||
// The code below reveals many places in our codebase where
|
||||
// we're not using all of the data given to us to format
|
||||
// strings -- but there are too many to presently fix.
|
||||
// Rather than toss away the code, we should later build it
|
||||
// and fix each offending resource (or the code processing
|
||||
// the resource).
|
||||
|
||||
// String.Format() will throw a FormatException if args does
|
||||
// not have enough elements to match each format parameter.
|
||||
// However, it provides no feedback in the case when args contains
|
||||
// more elements than necessary to replace each format
|
||||
// parameter. We'd like to know if we're providing too much
|
||||
// data in cases like these, so we'll fail if this code runs.
|
||||
|
||||
// We create an array with one fewer element
|
||||
object[] trimmedArgs = new object[args.Length - 1];
|
||||
Array.Copy(args, 0, trimmedArgs, 0, args.Length - 1);
|
||||
|
||||
bool caughtFormatException = false;
|
||||
try
|
||||
{
|
||||
// This will throw if there aren't enough elements in trimmedArgs...
|
||||
String.Format(CultureInfo.CurrentCulture, unformatted, trimmedArgs);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
caughtFormatException = true;
|
||||
}
|
||||
|
||||
// If we didn't catch an exception above, then some of the elements
|
||||
// of args were unnecessary when formatting unformatted...
|
||||
Debug.Assert
|
||||
(
|
||||
caughtFormatException,
|
||||
String.Format("The provided format string '{0}' had fewer format parameters than the number of format args, '{1}'.", unformatted, args.Length)
|
||||
);
|
||||
#endif
|
||||
// If you accidentally pass some random type in that can't be converted to a string,
|
||||
// FormatResourceString calls ToString() which returns the full name of the type!
|
||||
foreach (object param in args)
|
||||
{
|
||||
// Check against a list of types that we know have
|
||||
// overridden ToString() usefully. If you want to pass
|
||||
// another one, add it here.
|
||||
if (param != null && param.ToString() == param.GetType().FullName)
|
||||
{
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "Invalid type for message formatting argument, was {0}", param.GetType().FullName));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Format the string, using the variable arguments passed in.
|
||||
// NOTE: all String methods are thread-safe
|
||||
try
|
||||
{
|
||||
formatted = String.Format(culture, unformatted, args);
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
// User task may have logged something with too many format parameters
|
||||
// We don't have resources in this assembly, and we generally log stack for task failures so they can be fixed by the owner
|
||||
// However, we don't want to crash the logger and stop the build.
|
||||
// Error will look like this (it's OK to not localize subcategory). It's not too bad, although there's no file.
|
||||
//
|
||||
// Task "Crash"
|
||||
// (16,14): error : "This message logged from a task {1} has too few formatting parameters."
|
||||
// at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
|
||||
// at System.String.Format(IFormatProvider provider, String format, Object[] args)
|
||||
// at Microsoft.Build.Framework.LazyFormattedBuildEventArgs.FormatString(CultureInfo culture, String unformatted, Object[] args) in d:\W8T_Refactor\src\vsproject\xmake\Framework\LazyFormattedBuildEventArgs.cs:line 263
|
||||
// Done executing task "Crash".
|
||||
//
|
||||
// T
|
||||
formatted = String.Format(CultureInfo.CurrentCulture, "\"{0}\"\n{1}", unformatted, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialization does not call any constructors, not even
|
||||
/// the parameterless constructor. Therefore since we do not serialize
|
||||
/// this field, we must populate it here.
|
||||
/// </summary>
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
_locker = new Object();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This attribute is used to mark tasks that need to be run in their own app domains. The build engine will create a new app
|
||||
/// domain each time it needs to run such a task, and immediately unload it when the task is finished.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class LoadInSeparateAppDomainAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public LoadInSeparateAppDomainAttribute()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions; // for SecurityPermissionAttribute
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception that should be thrown by a logger when it cannot continue.
|
||||
/// Allows a logger to force the build to stop in an explicit way, when, for example, it
|
||||
/// receives invalid parameters, or cannot write to disk.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class LoggerException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This constructor only exists to satisfy .NET coding guidelines. Use the rich constructor instead.
|
||||
/// </remarks>
|
||||
public LoggerException()
|
||||
{
|
||||
// do nothing
|
||||
// if message is null, the base class provides a default string.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of this exception using the specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">Message string</param>
|
||||
public LoggerException(string message)
|
||||
: base(message, null)
|
||||
{
|
||||
// We do no verification of these parameters.
|
||||
// if message is null, the base class provides a default string.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of this exception using the specified error message and inner exception.
|
||||
/// </summary>
|
||||
/// <param name="message">Message string</param>
|
||||
/// <param name="innerException">Inner exception. Can be null</param>
|
||||
public LoggerException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
// We do no verification of these parameters. Any can be null;
|
||||
// if message is null, the base class provides a default string.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of this exception using rich error information.
|
||||
/// </summary>
|
||||
/// <param name="message">Message string</param>
|
||||
/// <param name="innerException">Inner exception. Can be null</param>
|
||||
/// <param name="errorCode">Error code</param>
|
||||
/// <param name="helpKeyword">Help keyword for host IDE. Can be null</param>
|
||||
public LoggerException(string message, Exception innerException, string errorCode, string helpKeyword)
|
||||
: this(message, innerException)
|
||||
{
|
||||
// We do no verification of these parameters. Any can be null.
|
||||
_errorCode = errorCode;
|
||||
_helpKeyword = helpKeyword;
|
||||
}
|
||||
|
||||
#region Serialization (update when adding new class members)
|
||||
|
||||
/// <summary>
|
||||
/// Protected constructor used for (de)serialization.
|
||||
/// If we ever add new members to this class, we'll need to update this.
|
||||
/// </summary>
|
||||
/// <param name="info">Serialization info</param>
|
||||
/// <param name="context">Streaming context</param>
|
||||
protected LoggerException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
_errorCode = info.GetString("errorCode");
|
||||
_helpKeyword = info.GetString("helpKeyword");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ISerializable method which we must override since Exception implements this interface
|
||||
/// If we ever add new members to this class, we'll need to update this.
|
||||
/// </summary>
|
||||
/// <param name="info">Serialization info</param>
|
||||
/// <param name="context">Streaming context</param>
|
||||
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
|
||||
override public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData(info, context);
|
||||
|
||||
info.AddValue("errorCode", _errorCode);
|
||||
info.AddValue("helpKeyword", _helpKeyword);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error code associated with this exception's message (not the inner exception).
|
||||
/// </summary>
|
||||
/// <value>The error code string.</value>
|
||||
public string ErrorCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the F1-help keyword associated with this error, for the host IDE.
|
||||
/// </summary>
|
||||
/// <value>The keyword string.</value>
|
||||
public string HelpKeyword
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helpKeyword;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// the error code for this exception's message (not the inner exception)
|
||||
private string _errorCode;
|
||||
// the F1-help keyword for the host IDE
|
||||
private string _helpKeyword;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{571F09DB-A81A-4444-945C-6F7B530054CD}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Build.Framework</RootNamespace>
|
||||
<AssemblyName>Microsoft.Build.Framework</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildEngineResult.cs" />
|
||||
<Compile Include="BuildErrorEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildFinishedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildMessageEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildStartedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildStatusEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildWarningEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="CriticalBuildMessageEventArgs.cs" />
|
||||
<Compile Include="CustomBuildEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ExternalProjectFinishedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ExternalProjectStartedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="FxCopExclusions\Microsoft.Build.Framework.Suppressions.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="IBuildEngine3.cs" />
|
||||
<Compile Include="IBuildEngine4.cs" />
|
||||
<Compile Include="IGeneratedTask.cs" />
|
||||
<Compile Include="LazyFormattedBuildEventArgs.cs" />
|
||||
<Compile Include="IBuildEngine.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="IBuildEngine2.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="IEventRedirector.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="IEventSource.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="IForwardingLogger.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ILogger.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="INodeLogger.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ITask.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ICancelableTask.cs" />
|
||||
<Compile Include="ITaskFactory.cs" />
|
||||
<Compile Include="ITaskFactory2.cs" />
|
||||
<Compile Include="ITaskHost.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ITaskItem.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ITaskItem2.cs" />
|
||||
<Compile Include="LoadInSeparateAppDomainAttribute.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="LoggerException.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="BuildEventContext.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="OutputAttribute.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ProjectFinishedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="ProjectStartedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="RequiredAttribute.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="RequiredRuntimeAttribute.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="RunInMTAAttribute.cs" />
|
||||
<Compile Include="RunInSTAAttribute.cs" />
|
||||
<Compile Include="TargetFinishedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="TargetStartedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="TaskCommandLineEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="TaskFinishedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="TaskPropertyInfo.cs" />
|
||||
<Compile Include="TaskStartedEventArgs.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="XamlTypes\Argument.cs" />
|
||||
<Compile Include="XamlTypes\BaseProperty.cs" />
|
||||
<Compile Include="XamlTypes\BoolProperty.cs" />
|
||||
<Compile Include="XamlTypes\Category.cs" />
|
||||
<Compile Include="XamlTypes\CategorySchema.cs" />
|
||||
<Compile Include="XamlTypes\ContentType.cs" />
|
||||
<Compile Include="XamlTypes\DataSource.cs" />
|
||||
<Compile Include="XamlTypes\DynamicEnumProperty.cs" />
|
||||
<Compile Include="XamlTypes\EnumProperty.cs" />
|
||||
<Compile Include="XamlTypes\EnumValue.cs" />
|
||||
<Compile Include="XamlTypes\FileExtension.cs" />
|
||||
<Compile Include="XamlTypes\IntProperty.cs" />
|
||||
<Compile Include="XamlTypes\IProjectSchemaNode.cs" />
|
||||
<Compile Include="XamlTypes\ItemType.cs" />
|
||||
<Compile Include="XamlTypes\NameValuePair.cs" />
|
||||
<Compile Include="XamlTypes\ProjectSchemaDefinitions.cs" />
|
||||
<Compile Include="XamlTypes\Rule.cs" />
|
||||
<Compile Include="XamlTypes\RuleBag.cs" />
|
||||
<Compile Include="XamlTypes\RuleSchema.cs" />
|
||||
<Compile Include="XamlTypes\StringListProperty.cs" />
|
||||
<Compile Include="XamlTypes\StringProperty.cs" />
|
||||
<Compile Include="XamlTypes\ValueEditor.cs" />
|
||||
<None Include="Event args classes.cd" />
|
||||
<!-- Win32 RC Files -->
|
||||
<RCResourceFile Include="native.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This attribute is used by task writers to designate certain task parameters as "outputs". The build engine will only allow
|
||||
/// task parameters (i.e. the task class' .NET properties) that are marked with this attribute to output data from a task. Project
|
||||
/// authors can only use parameters marked with this attribute in a task's <Output> tag. All task parameters, including those
|
||||
/// marked with this attribute, may be treated as inputs to a task by the build engine.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class OutputAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public OutputAttribute()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for project finished events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class ProjectFinishedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected ProjectFinishedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">name of the project</param>
|
||||
/// <param name="succeeded">true indicates project built successfully</param>
|
||||
public ProjectFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
bool succeeded
|
||||
)
|
||||
: this(message, helpKeyword, projectFile, succeeded, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild". This constructor allows the timestamp to be set as well
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">name of the project</param>
|
||||
/// <param name="succeeded">true indicates project built successfully</param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
public ProjectFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp)
|
||||
{
|
||||
_projectFile = projectFile;
|
||||
_succeeded = succeeded;
|
||||
}
|
||||
|
||||
private string _projectFile;
|
||||
private bool _succeeded;
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
|
||||
writer.Write(_succeeded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
|
||||
_succeeded = reader.ReadBoolean();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Project name
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if project built successfully, false otherwise
|
||||
/// </summary>
|
||||
public bool Succeeded
|
||||
{
|
||||
get
|
||||
{
|
||||
return _succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,551 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguements for project started events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class ProjectStartedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
#region Constants
|
||||
public const int InvalidProjectId = -1;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected ProjectStartedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="targetNames">targets we are going to build (empty indicates default targets)</param>
|
||||
/// <param name="properties">list of properties</param>
|
||||
/// <param name="items">list of items</param>
|
||||
public ProjectStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string targetNames,
|
||||
IEnumerable properties,
|
||||
IEnumerable items
|
||||
)
|
||||
: this(message, helpKeyword, projectFile, targetNames, properties, items, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="projectId">project id</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="targetNames">targets we are going to build (empty indicates default targets)</param>
|
||||
/// <param name="properties">list of properties</param>
|
||||
/// <param name="items">list of items</param>
|
||||
/// <param name="parentBuildEventContext">event context info for the parent project</param>
|
||||
public ProjectStartedEventArgs
|
||||
(
|
||||
int projectId,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string targetNames,
|
||||
IEnumerable properties,
|
||||
IEnumerable items,
|
||||
BuildEventContext parentBuildEventContext
|
||||
)
|
||||
: this(projectId, message, helpKeyword, projectFile, targetNames, properties, items, parentBuildEventContext, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="projectId">project id</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="targetNames">targets we are going to build (empty indicates default targets)</param>
|
||||
/// <param name="properties">list of properties</param>
|
||||
/// <param name="items">list of items</param>
|
||||
/// <param name="parentBuildEventContext">event context info for the parent project</param>
|
||||
public ProjectStartedEventArgs
|
||||
(
|
||||
int projectId,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string targetNames,
|
||||
IEnumerable properties,
|
||||
IEnumerable items,
|
||||
BuildEventContext parentBuildEventContext,
|
||||
IDictionary<string, string> globalProperties,
|
||||
string toolsVersion
|
||||
)
|
||||
: this(projectId, message, helpKeyword, projectFile, targetNames, properties, items, parentBuildEventContext)
|
||||
{
|
||||
this.GlobalProperties = globalProperties;
|
||||
this.ToolsVersion = toolsVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized. Also the timestamp can be set
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="targetNames">targets we are going to build (empty indicates default targets)</param>
|
||||
/// <param name="properties">list of properties</param>
|
||||
/// <param name="items">list of items</param>
|
||||
public ProjectStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string targetNames,
|
||||
IEnumerable properties,
|
||||
IEnumerable items,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp)
|
||||
{
|
||||
_projectFile = projectFile;
|
||||
|
||||
if (targetNames == null)
|
||||
{
|
||||
_targetNames = String.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetNames = targetNames;
|
||||
}
|
||||
|
||||
_properties = properties;
|
||||
_items = items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="projectId">project id</param>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project name</param>
|
||||
/// <param name="targetNames">targets we are going to build (empty indicates default targets)</param>
|
||||
/// <param name="properties">list of properties</param>
|
||||
/// <param name="items">list of items</param>
|
||||
/// <param name="parentBuildEventContext">event context info for the parent project</param>
|
||||
public ProjectStartedEventArgs
|
||||
(
|
||||
int projectId,
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string targetNames,
|
||||
IEnumerable properties,
|
||||
IEnumerable items,
|
||||
BuildEventContext parentBuildEventContext,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: this(message, helpKeyword, projectFile, targetNames, properties, items, eventTimestamp)
|
||||
{
|
||||
_parentProjectBuildEventContext = parentBuildEventContext;
|
||||
_projectId = projectId;
|
||||
}
|
||||
|
||||
// ProjectId is only contained in the project started event.
|
||||
// This number indicated the instance id of the project and can be
|
||||
// used when debugging to determine if two projects with the same name
|
||||
// are the same project instance or different instances
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private int _projectId;
|
||||
|
||||
public int ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectId;
|
||||
}
|
||||
}
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private BuildEventContext _parentProjectBuildEventContext;
|
||||
|
||||
/// <summary>
|
||||
/// Event context information, where the event was fired from in terms of the build location
|
||||
/// </summary>
|
||||
public BuildEventContext ParentProjectBuildEventContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parentProjectBuildEventContext;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the project file
|
||||
/// </summary>
|
||||
private string _projectFile;
|
||||
|
||||
/// <summary>
|
||||
/// Project name
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Targets that we will build in the project
|
||||
/// </summary>
|
||||
private string _targetNames;
|
||||
|
||||
/// <summary>
|
||||
/// Targets that we will build in the project
|
||||
/// </summary>
|
||||
public string TargetNames
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetNames;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the set of global properties used to evaluate this project.
|
||||
/// </summary>
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private IDictionary<string, string> _globalProperties;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the set of global properties used to evaluate this project.
|
||||
/// </summary>
|
||||
public IDictionary<string, string> GlobalProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
return _globalProperties;
|
||||
}
|
||||
|
||||
internal set
|
||||
{
|
||||
_globalProperties = value;
|
||||
}
|
||||
}
|
||||
|
||||
[OptionalField(VersionAdded = 2)]
|
||||
private string _toolsVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tools version used to evaluate this project.
|
||||
/// </summary>
|
||||
public string ToolsVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return _toolsVersion;
|
||||
}
|
||||
|
||||
internal set
|
||||
{
|
||||
_toolsVersion = value;
|
||||
}
|
||||
}
|
||||
|
||||
// IEnumerable is not a serializable type. That is okay because
|
||||
// (a) this event will not be thrown by tasks, so it should not generally cross AppDomain boundaries
|
||||
// (b) this event still makes sense when this field is "null"
|
||||
[NonSerialized]
|
||||
private IEnumerable _properties;
|
||||
|
||||
/// <summary>
|
||||
/// List of properties in this project. This is a live, read-only list.
|
||||
/// </summary>
|
||||
public IEnumerable Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
// UNDONE: (Serialization.) Rather than storing the properties directly in this class, we could
|
||||
// grab them from the BuildRequestConfiguration associated with this projectId (which is now poorly
|
||||
// named because it is actually the BuildRequestConfigurationId.) For central loggers in the
|
||||
// multi-proc case, this could pull up just the global properties used to start the project. For
|
||||
// distributed loggers in the multi-proc case and all loggers in the single-proc case, this could pull
|
||||
// up the live list of properties from the loaded project, which is stored in the configuration as well.
|
||||
// By doing this, we no longer need to transmit properties using this message because they've already
|
||||
// been transmitted as part of the BuildRequestConfiguration.
|
||||
return _properties;
|
||||
}
|
||||
}
|
||||
|
||||
// IEnumerable is not a serializable type. That is okay because
|
||||
// (a) this event will not be thrown by tasks, so it should not generally cross AppFomain boundaries
|
||||
// (b) this event still makes sense when this field is "null"
|
||||
[NonSerialized]
|
||||
private IEnumerable _items;
|
||||
|
||||
/// <summary>
|
||||
/// List of items in this project. This is a live, read-only list.
|
||||
/// </summary>
|
||||
public IEnumerable Items
|
||||
{
|
||||
get
|
||||
{
|
||||
// UNDONE: (Serialization.) Currently there is a "bug" in the old OM in that items are not transported to
|
||||
// the central logger in the multi-proc case. No one uses this though, so it's probably no big deal. In
|
||||
// the new OM, this list of items could come directly from the BuildRequestConfiguration, which has access
|
||||
// to the loaded project. For distributed loggers in the multi-proc case and all loggers in the single-proc
|
||||
// case, this access is to the live list. For the central logger in the multi-proc case, the main node
|
||||
// has likely not loaded this project, and therefore the live items would not be available to them, which is
|
||||
// the same as the current functionality.
|
||||
return _items;
|
||||
}
|
||||
}
|
||||
|
||||
#region CustomSerializationToStream
|
||||
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
writer.Write((Int32)_projectId);
|
||||
#region ParentProjectBuildEventContext
|
||||
if (_parentProjectBuildEventContext == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write((Int32)_parentProjectBuildEventContext.NodeId);
|
||||
writer.Write((Int32)_parentProjectBuildEventContext.ProjectContextId);
|
||||
writer.Write((Int32)_parentProjectBuildEventContext.TargetId);
|
||||
writer.Write((Int32)_parentProjectBuildEventContext.TaskId);
|
||||
writer.Write((Int32)_parentProjectBuildEventContext.SubmissionId);
|
||||
writer.Write((Int32)_parentProjectBuildEventContext.ProjectInstanceId);
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TargetNames
|
||||
// TargetNames cannot be null as per line 61 in the constructor
|
||||
writer.Write(_targetNames);
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
Dictionary<string, string> propertyList = GeneratePropertyList();
|
||||
|
||||
// If no properties were added to the property list
|
||||
// then we have nothing to create when it is deserialized
|
||||
// This can happen if properties is null or if none of the
|
||||
// five properties were found in the property object.
|
||||
if ((propertyList == null || propertyList.Count == 0))
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
|
||||
// Write how many properties we are going to write into the stream
|
||||
writer.Write((Int32)propertyList.Count);
|
||||
|
||||
// Write the actual property name value pairs into the stream
|
||||
foreach (KeyValuePair<string, string> propertyPair in propertyList)
|
||||
{
|
||||
writer.Write(propertyPair.Key);
|
||||
writer.Write(propertyPair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a list of KeyValuePairs from the properties enumerator.
|
||||
/// For each of these properties add them to a list to return to the caller.
|
||||
/// </summary>
|
||||
/// <returns>Null if properties is null, or a list containing one or more of the properties in the properties enumerator</returns>
|
||||
private Dictionary<string, string> GeneratePropertyList()
|
||||
{
|
||||
if (_properties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Dictionary<string, string> propertyList = new Dictionary<string, string>();
|
||||
|
||||
// Loop through the properties and add them to the keyvalue pair list
|
||||
foreach (DictionaryEntry property in _properties)
|
||||
{
|
||||
object propertyKey = property.Key;
|
||||
object propertyValue = property.Value;
|
||||
|
||||
// Make sure property keys and values are not null before casting.
|
||||
// property key and value will always be a string, if this is not the case
|
||||
// the a cast exception is the correct course of action.
|
||||
if (property.Key != null && property.Value != null)
|
||||
{
|
||||
propertyList.Add((string)property.Key, (string)property.Value);
|
||||
}
|
||||
}
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
_projectId = reader.ReadInt32();
|
||||
#region ParentProjectBuildEventContext
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_parentProjectBuildEventContext = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nodeId = reader.ReadInt32();
|
||||
int projectContextId = reader.ReadInt32();
|
||||
int targetId = reader.ReadInt32();
|
||||
int taskId = reader.ReadInt32();
|
||||
|
||||
if (version > 20)
|
||||
{
|
||||
int submissionId = reader.ReadInt32();
|
||||
int projectInstanceId = reader.ReadInt32();
|
||||
_parentProjectBuildEventContext = new BuildEventContext(submissionId, nodeId, projectInstanceId, projectContextId, targetId, taskId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_parentProjectBuildEventContext = new BuildEventContext(nodeId, targetId, projectContextId, taskId);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region TargetNames
|
||||
// TargetNames cannot be null as per line 61 in the constructor
|
||||
_targetNames = reader.ReadString();
|
||||
#endregion
|
||||
#region Properties
|
||||
|
||||
// Check to see if properties was null
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_properties = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get number of properties put on the stream
|
||||
int numberOfProperties = reader.ReadInt32();
|
||||
|
||||
// We need to use a dictionaryEntry as that is what the old behavior was
|
||||
ArrayList dictionaryList = new ArrayList(numberOfProperties);
|
||||
|
||||
// Read off each of the key value pairs and put them into the dictionaryList
|
||||
for (int i = 0; i < numberOfProperties; i++)
|
||||
{
|
||||
string key = reader.ReadString();
|
||||
string value = reader.ReadString();
|
||||
|
||||
if (key != null && value != null)
|
||||
{
|
||||
DictionaryEntry entry = new DictionaryEntry(key, value);
|
||||
dictionaryList.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
_properties = dictionaryList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SerializationSection
|
||||
[OnDeserializing] // Will happen before the object is deserialized
|
||||
private void SetDefaultsBeforeSerialization(StreamingContext sc)
|
||||
{
|
||||
_projectId = InvalidProjectId;
|
||||
// Dont want to set the default before deserialization is completed to a new event context because
|
||||
// that would most likely be a lot of wasted allocations
|
||||
_parentProjectBuildEventContext = null;
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void SetDefaultsAfterSerialization(StreamingContext sc)
|
||||
{
|
||||
if (_parentProjectBuildEventContext == null)
|
||||
{
|
||||
_parentProjectBuildEventContext = new BuildEventContext
|
||||
(
|
||||
BuildEventContext.InvalidNodeId,
|
||||
BuildEventContext.InvalidTargetId,
|
||||
BuildEventContext.InvalidProjectContextId,
|
||||
BuildEventContext.InvalidTaskId
|
||||
);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This class defines the attribute that a task writer can apply to a task's property to declare the property to be a
|
||||
/// required property.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class RequiredAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public RequiredAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// When marked with the RequiredRuntimeAttribute, a task indicates that it has stricter
|
||||
/// runtime requirements than a regular task - this tells MSBuild that it will need to potentially
|
||||
/// launch a separate process for that task if the current runtime does not match the version requirement.
|
||||
/// This attribute is currently non-functional since there is only one version of the CLR that is
|
||||
/// capable of running MSBuild v2.0 or v3.5 - the runtime v2.0
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class RequiredRuntimeAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor taking a version, such as "v2.0".
|
||||
/// </summary>
|
||||
public RequiredRuntimeAttribute(string runtimeVersion)
|
||||
{
|
||||
_runtimeVersion = runtimeVersion;
|
||||
}
|
||||
|
||||
private string _runtimeVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the runtime version the attribute was constructed with,
|
||||
/// e.g., "v2.0"
|
||||
/// </summary>
|
||||
public string RuntimeVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return _runtimeVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Attribute which tells MSBuild the task may run in any thread.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This attribute is used to mark a task class as explicitly not being required to run in the STA for COM.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
||||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "MTA", Justification = "It is cased correctly.")]
|
||||
public sealed class RunInMTAAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public RunInMTAAttribute()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Attribute which tells MSBuild the task must run in an STA thread.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This attribute is used to mark a task class as being required to run in a Single Threaded Apartment for COM.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
||||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "STA", Justification = "It is cased correctly.")]
|
||||
public sealed class RunInSTAAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public RunInSTAAttribute()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,265 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for target finished events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class TargetFinishedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected TargetFinishedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="targetName">target name</param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="targetFile">file in which the target is defined</param>
|
||||
/// <param name="succeeded">true if target built successfully</param>
|
||||
public TargetFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string targetName,
|
||||
string projectFile,
|
||||
string targetFile,
|
||||
bool succeeded
|
||||
)
|
||||
: this(message, helpKeyword, targetName, projectFile, targetFile, succeeded, DateTime.UtcNow, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="targetName">target name</param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="targetFile">file in which the target is defined</param>
|
||||
/// <param name="succeeded">true if target built successfully</param>
|
||||
/// <param name="targetOutputs">Target output items for the target. If batching will be null for everything except for the last target in the batch</param>
|
||||
public TargetFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string targetName,
|
||||
string projectFile,
|
||||
string targetFile,
|
||||
bool succeeded,
|
||||
IEnumerable targetOutputs
|
||||
)
|
||||
: this(message, helpKeyword, targetName, projectFile, targetFile, succeeded, DateTime.UtcNow, targetOutputs)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized including the timestamp when the event was created.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="targetName">target name</param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="targetFile">file in which the target is defined</param>
|
||||
/// <param name="succeeded">true if target built successfully</param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
public TargetFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string targetName,
|
||||
string projectFile,
|
||||
string targetFile,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp,
|
||||
IEnumerable targetOutputs
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp)
|
||||
{
|
||||
_targetName = targetName;
|
||||
_succeeded = succeeded;
|
||||
_projectFile = projectFile;
|
||||
_targetFile = targetFile;
|
||||
_targetOutputs = targetOutputs;
|
||||
}
|
||||
|
||||
private string _projectFile;
|
||||
private string _targetFile;
|
||||
private string _targetName;
|
||||
private bool _succeeded;
|
||||
private IEnumerable _targetOutputs;
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
#region TargetFile
|
||||
if (_targetFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_targetFile);
|
||||
}
|
||||
#endregion TargetFile
|
||||
#region TargetName
|
||||
if (_targetName == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_targetName);
|
||||
}
|
||||
#endregion
|
||||
writer.Write(_succeeded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
#region ProjectFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region TargetFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_targetFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region TargetName
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_targetName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetName = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
_succeeded = reader.ReadBoolean();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Target name
|
||||
/// </summary>
|
||||
public string TargetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if target built successfully, false otherwise
|
||||
/// </summary>
|
||||
public bool Succeeded
|
||||
{
|
||||
get
|
||||
{
|
||||
return _succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project file associated with event.
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File where this target was declared.
|
||||
/// </summary>
|
||||
public string TargetFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetFile;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Target outputs
|
||||
/// </summary>
|
||||
public IEnumerable TargetOutputs
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetOutputs;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_targetOutputs = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,238 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for target started events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class TargetStartedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected TargetStartedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="targetName">target name</param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="targetFile">file in which the target is defined</param>
|
||||
public TargetStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string targetName,
|
||||
string projectFile,
|
||||
string targetFile
|
||||
)
|
||||
: this(message, helpKeyword, targetName, projectFile, targetFile, String.Empty, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized including the timestamp when the event was created.
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="targetName">target name</param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="targetFile">file in which the target is defined</param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
public TargetStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string targetName,
|
||||
string projectFile,
|
||||
string targetFile,
|
||||
string parentTarget,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp)
|
||||
{
|
||||
_targetName = targetName;
|
||||
_projectFile = projectFile;
|
||||
_targetFile = targetFile;
|
||||
_parentTarget = parentTarget;
|
||||
}
|
||||
|
||||
private string _targetName;
|
||||
private string _projectFile;
|
||||
private string _targetFile;
|
||||
private string _parentTarget;
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
#region TargetName
|
||||
if (_targetName == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_targetName);
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
#region TargetFile
|
||||
if (_targetFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_targetFile);
|
||||
}
|
||||
#endregion
|
||||
#region ParentTarget
|
||||
if (_parentTarget == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_parentTarget);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
#region TargetName
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_targetName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetName = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region TargetFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_targetFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region ParentTarget
|
||||
if (version > 20)
|
||||
{
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_parentTarget = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_parentTarget = reader.ReadString();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// target name
|
||||
/// </summary>
|
||||
public string TargetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Target which caused this target to build
|
||||
/// </summary>
|
||||
public string ParentTarget
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parentTarget;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project file associated with event.
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File where this target was declared.
|
||||
/// </summary>
|
||||
public string TargetFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is used by tasks to log their command lines. This class extends
|
||||
/// <see cref="BuildMessageEventArgs"/> so that command lines can be logged as
|
||||
/// messages. Logging a command line is only relevant for tasks that wrap an
|
||||
/// underlying executable/tool, or emulate a shell command. Tasks that have
|
||||
/// no command line equivalent should not raise this extended message event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing ISerializable
|
||||
/// imposes a serialization contract -- it is a promise to never change the
|
||||
/// type's fields i.e. the type is immutable; adding new fields in the next
|
||||
/// version of the type without following certain special FX guidelines, can
|
||||
/// break both forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class TaskCommandLineEventArgs : BuildMessageEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default (family) constructor.
|
||||
/// </summary>
|
||||
protected TaskCommandLineEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of this class for the given task command line.
|
||||
/// </summary>
|
||||
/// <param name="commandLine">The command line used by a task to launch
|
||||
/// its underlying tool/executable.</param>
|
||||
/// <param name="taskName">The name of the task raising this event.</param>
|
||||
/// <param name="importance">Importance of command line -- controls whether
|
||||
/// the command line will be displayed by less verbose loggers.</param>
|
||||
public TaskCommandLineEventArgs
|
||||
(
|
||||
string commandLine,
|
||||
string taskName,
|
||||
MessageImportance importance
|
||||
)
|
||||
: this(commandLine, taskName, importance, DateTime.UtcNow)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of this class for the given task command line. This constructor allows the timestamp to be set
|
||||
/// </summary>
|
||||
/// <param name="commandLine">The command line used by a task to launch
|
||||
/// its underlying tool/executable.</param>
|
||||
/// <param name="taskName">The name of the task raising this event.</param>
|
||||
/// <param name="importance">Importance of command line -- controls whether
|
||||
/// the command line will be displayed by less verbose loggers.</param>
|
||||
/// <param name="eventTimestamp">Timestamp when the event was created</param>
|
||||
public TaskCommandLineEventArgs
|
||||
(
|
||||
string commandLine,
|
||||
string taskName,
|
||||
MessageImportance importance,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(commandLine, null, taskName, importance, eventTimestamp)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the task command line associated with this event.
|
||||
/// </summary>
|
||||
public string CommandLine
|
||||
{
|
||||
get
|
||||
{
|
||||
return Message;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the task that raised this event.
|
||||
/// </summary>
|
||||
public string TaskName
|
||||
{
|
||||
get
|
||||
{
|
||||
return SenderName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,224 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for target finished event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for task finished events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class TaskFinishedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected TaskFinishedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="taskFile">file in which the task is defined</param>
|
||||
/// <param name="taskName">task name</param>
|
||||
/// <param name="succeeded">true indicates task succeed</param>
|
||||
public TaskFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string taskFile,
|
||||
string taskName,
|
||||
bool succeeded
|
||||
)
|
||||
: this(message, helpKeyword, projectFile, taskFile, taskName, succeeded, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized and the timestamp to be set
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="taskFile">file in which the task is defined</param>
|
||||
/// <param name="taskName">task name</param>
|
||||
/// <param name="succeeded">true indicates task succeed</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
public TaskFinishedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string taskFile,
|
||||
string taskName,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp)
|
||||
{
|
||||
_taskName = taskName;
|
||||
_taskFile = taskFile;
|
||||
_succeeded = succeeded;
|
||||
_projectFile = projectFile;
|
||||
}
|
||||
|
||||
private string _taskName;
|
||||
private string _projectFile;
|
||||
private string _taskFile;
|
||||
private bool _succeeded;
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
#region TaskName
|
||||
if (_taskName == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_taskName);
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
#region TaskFile
|
||||
if (_taskFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_taskFile);
|
||||
}
|
||||
#endregion
|
||||
writer.Write(_succeeded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the Errorevent from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
#region TaskName
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_taskName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskName = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region TaskFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_taskFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
_succeeded = reader.ReadBoolean();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Task Name
|
||||
/// </summary>
|
||||
public string TaskName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _taskName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if target built successfully, false otherwise
|
||||
/// </summary>
|
||||
public bool Succeeded
|
||||
{
|
||||
get
|
||||
{
|
||||
return _succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project file associated with event.
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MSBuild file where this task was defined.
|
||||
/// </summary>
|
||||
public string TaskFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _taskFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Stores the parameter information which will be passed to inline tasks to use as a set of parameters to create</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Class which represents the parameter information from the using task as a strongly typed class.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TaskPropertyInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates a list of parameters declared in the UsingTask
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the parameter</param>
|
||||
/// <param name="typeOfParameter">The actual type of the parameter</param>
|
||||
/// <param name="output">True if the parameter is both an output and and input parameter. False if the parameter is only an input parameter</param>
|
||||
/// <param name="required">True if the parameter must be supplied to each invocation of the task.</param>
|
||||
public TaskPropertyInfo(string name, Type typeOfParameter, bool output, bool required)
|
||||
{
|
||||
Name = name;
|
||||
PropertyType = typeOfParameter;
|
||||
Output = output;
|
||||
Required = required;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The type of the property
|
||||
/// </summary>
|
||||
public Type PropertyType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the property
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// This task parameter is an output parameter (analogous to [Output] attribute)
|
||||
/// </summary>
|
||||
public bool Output { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// This task parameter is required (analogous to the [Required] attribute)
|
||||
/// </summary>
|
||||
public bool Required { get; private set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Event args for task started event.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Arguments for task started events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING: marking a type [Serializable] without implementing
|
||||
/// ISerializable imposes a serialization contract -- it is a
|
||||
/// promise to never change the type's fields i.e. the type is
|
||||
/// immutable; adding new fields in the next version of the type
|
||||
/// without following certain special FX guidelines, can break both
|
||||
/// forward and backward compatibility
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class TaskStartedEventArgs : BuildStatusEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
protected TaskStartedEventArgs()
|
||||
: base()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="taskFile">file in which the task is defined</param>
|
||||
/// <param name="taskName">task name</param>
|
||||
public TaskStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string taskFile,
|
||||
string taskName
|
||||
)
|
||||
: this(message, helpKeyword, projectFile, taskFile, taskName, DateTime.UtcNow)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows event data to be initialized.
|
||||
/// Sender is assumed to be "MSBuild".
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="projectFile">project file</param>
|
||||
/// <param name="taskFile">file in which the task is defined</param>
|
||||
/// <param name="taskName">task name</param>
|
||||
/// <param name="eventTimestamp">Timestamp when event was created</param>
|
||||
public TaskStartedEventArgs
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string projectFile,
|
||||
string taskFile,
|
||||
string taskName,
|
||||
DateTime eventTimestamp
|
||||
)
|
||||
: base(message, helpKeyword, "MSBuild", eventTimestamp)
|
||||
{
|
||||
_taskName = taskName;
|
||||
_projectFile = projectFile;
|
||||
_taskFile = taskFile;
|
||||
}
|
||||
|
||||
private string _taskName;
|
||||
private string _projectFile;
|
||||
private string _taskFile;
|
||||
|
||||
#region CustomSerializationToStream
|
||||
/// <summary>
|
||||
/// Serializes to a stream through a binary writer
|
||||
/// </summary>
|
||||
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
|
||||
internal override void WriteToStream(BinaryWriter writer)
|
||||
{
|
||||
base.WriteToStream(writer);
|
||||
#region TaskName
|
||||
if (_taskName == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_taskName);
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (_projectFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_projectFile);
|
||||
}
|
||||
#endregion
|
||||
#region TaskFile
|
||||
if (_taskFile == null)
|
||||
{
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((byte)1);
|
||||
writer.Write(_taskFile);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the Errorevent from a stream through a binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">Binary reader which is attached to the stream the event will be deserialized from</param>
|
||||
/// <param name="version">The version of the runtime the message packet was created from</param>
|
||||
internal override void CreateFromStream(BinaryReader reader, int version)
|
||||
{
|
||||
base.CreateFromStream(reader, version);
|
||||
#region TaskName
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_taskName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskName = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region ProjectFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_projectFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
#region TaskFile
|
||||
if (reader.ReadByte() == 0)
|
||||
{
|
||||
_taskFile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskFile = reader.ReadString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Task name.
|
||||
/// </summary>
|
||||
public string TaskName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _taskName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project file associated with event.
|
||||
/// </summary>
|
||||
public string ProjectFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectFile;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MSBuild file where this task was defined.
|
||||
/// </summary>
|
||||
public string TaskFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return _taskFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class AttributeTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Test RequiredRuntimeAttribute
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void RequiredRuntimeAttribute()
|
||||
{
|
||||
RequiredRuntimeAttribute attribute =
|
||||
(RequiredRuntimeAttribute)Attribute.GetCustomAttribute(typeof(X), typeof(RequiredRuntimeAttribute));
|
||||
|
||||
Assert.AreEqual("v5", attribute.RuntimeVersion);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OutputAttribute()
|
||||
{
|
||||
OutputAttribute attribute =
|
||||
(OutputAttribute)Attribute.GetCustomAttribute(typeof(X).GetMember("TestValue2", BindingFlags.NonPublic | BindingFlags.Static)[0], typeof(OutputAttribute));
|
||||
Assert.IsNotNull(attribute);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RequiredAttribute()
|
||||
{
|
||||
RequiredAttribute attribute =
|
||||
(RequiredAttribute)Attribute.GetCustomAttribute(typeof(X).GetMember("TestValue", BindingFlags.NonPublic | BindingFlags.Static)[0], typeof(RequiredAttribute));
|
||||
Assert.IsNotNull(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sample class with RequiredRuntimeAttribute on it
|
||||
/// </summary>
|
||||
[RequiredRuntime("v5")]
|
||||
internal static class X
|
||||
{
|
||||
[Required]
|
||||
internal static bool TestValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[Output]
|
||||
internal static bool TestValue2
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for BuildErrorEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the BuildErrorEventArg class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class BuildErrorEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private BuildErrorEventArgs _baseErrorEvent = new BuildErrorEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender");
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
BuildErrorEventArgs beea = new BuildErrorEventArgs2();
|
||||
beea = new BuildErrorEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender");
|
||||
beea = new BuildErrorEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender", DateTime.Now);
|
||||
beea = new BuildErrorEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "{0}", "HelpKeyword", "sender", DateTime.Now, "Messsage");
|
||||
beea = new BuildErrorEventArgs(null, null, null, 1, 2, 3, 4, null, null, null);
|
||||
beea = new BuildErrorEventArgs(null, null, null, 1, 2, 3, 4, null, null, null, DateTime.Now);
|
||||
beea = new BuildErrorEventArgs(null, null, null, 1, 2, 3, 4, null, null, null, DateTime.Now, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path.
|
||||
/// </summary>
|
||||
private class BuildErrorEventArgs2 : BuildErrorEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Test Constructor
|
||||
/// </summary>
|
||||
public BuildErrorEventArgs2() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for BuildFinishedEventArgs_Tests</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the BuildFinishedEventArg class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class BuildFinishedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default buildFinished event to use in tests.
|
||||
/// </summary>
|
||||
private BuildFinishedEventArgs _baseFinishedEvent = new BuildFinishedEventArgs("Message", "HelpKeyword", true);
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
BuildFinishedEventArgs buildFinishedEvent = new BuildFinishedEventArgs2();
|
||||
buildFinishedEvent = new BuildFinishedEventArgs("Message", "HelpKeyword", true);
|
||||
buildFinishedEvent = new BuildFinishedEventArgs("Message", "HelpKeyword", true, new DateTime());
|
||||
buildFinishedEvent = new BuildFinishedEventArgs("{0}", "HelpKeyword", true, new DateTime(), "Message");
|
||||
buildFinishedEvent = new BuildFinishedEventArgs(null, null, true);
|
||||
buildFinishedEvent = new BuildFinishedEventArgs(null, null, true, new DateTime());
|
||||
buildFinishedEvent = new BuildFinishedEventArgs(null, null, true, new DateTime(), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class BuildFinishedEventArgs2 : BuildFinishedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Test constructor
|
||||
/// </summary>
|
||||
public BuildFinishedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for BuildMessageEventArgs_Tests</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the BuildMessageEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class BuildMessageEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private BuildMessageEventArgs _baseMessageEvent = new BuildMessageEventArgs("Message", "HelpKeyword", "Sender", MessageImportance.Low);
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
BuildMessageEventArgs bmea = new BuildMessageEventArgs2();
|
||||
bmea = new BuildMessageEventArgs("Message", "HelpKeyword", "Sender", MessageImportance.Low);
|
||||
bmea = new BuildMessageEventArgs("Message", "HelpKeyword", "Sender", MessageImportance.Low, DateTime.Now);
|
||||
bmea = new BuildMessageEventArgs("{0}", "HelpKeyword", "Sender", MessageImportance.Low, DateTime.Now, "Message");
|
||||
bmea = new BuildMessageEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "Sender", MessageImportance.Low);
|
||||
bmea = new BuildMessageEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "Sender", MessageImportance.Low, DateTime.Now);
|
||||
bmea = new BuildMessageEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "{0}", "HelpKeyword", "Sender", MessageImportance.Low, DateTime.Now, "Message");
|
||||
bmea = new BuildMessageEventArgs(null, null, null, MessageImportance.Low);
|
||||
bmea = new BuildMessageEventArgs(null, null, null, MessageImportance.Low, DateTime.Now);
|
||||
bmea = new BuildMessageEventArgs(null, null, null, MessageImportance.Low, DateTime.Now, null);
|
||||
bmea = new BuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null, MessageImportance.Low);
|
||||
bmea = new BuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null, MessageImportance.Low, DateTime.Now);
|
||||
bmea = new BuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null, MessageImportance.Low, DateTime.Now, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class BuildMessageEventArgs2 : BuildMessageEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public BuildMessageEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for BuildStartedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the BuildStartedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class BuildStartedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private BuildStartedEventArgs _baseStartedEvent = new BuildStartedEventArgs("Message", "HelpKeyword");
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
BuildStartedEventArgs bsea = new BuildStartedEventArgs2();
|
||||
bsea = new BuildStartedEventArgs("Message", "HelpKeyword");
|
||||
bsea = new BuildStartedEventArgs("Message", "HelpKeyword", DateTime.Now);
|
||||
bsea = new BuildStartedEventArgs("{0}", "HelpKeyword", DateTime.Now, "Message");
|
||||
bsea = new BuildStartedEventArgs(null, null);
|
||||
bsea = new BuildStartedEventArgs(null, null, DateTime.Now);
|
||||
bsea = new BuildStartedEventArgs(null, null, DateTime.Now, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise getHashCode.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestGetHashCode()
|
||||
{
|
||||
_baseStartedEvent.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class BuildStartedEventArgs2 : BuildStartedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public BuildStartedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for BuildWarningEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the BuildWarningEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class BuildWarningEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private BuildWarningEventArgs _baseWarningEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender");
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
BuildWarningEventArgs buildWarningEvent = new BuildWarningEventArgs2();
|
||||
buildWarningEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender");
|
||||
buildWarningEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender", DateTime.Now);
|
||||
buildWarningEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "{0}", "HelpKeyword", "sender", DateTime.Now, "Message");
|
||||
buildWarningEvent = new BuildWarningEventArgs(null, null, null, 1, 2, 3, 4, null, null, null);
|
||||
buildWarningEvent = new BuildWarningEventArgs(null, null, null, 1, 2, 3, 4, null, null, null, DateTime.Now);
|
||||
buildWarningEvent = new BuildWarningEventArgs(null, null, null, 1, 2, 3, 4, null, null, null, DateTime.Now, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise getHashCode.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestGetHashCode()
|
||||
{
|
||||
_baseWarningEvent.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class BuildWarningEventArgs2 : BuildWarningEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public BuildWarningEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for CriticalBuildMessageEventArgs_Tests</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the CriticalBuildMessageEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class CriticalBuildMessageEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
CriticalBuildMessageEventArgs cbmea = new CriticalBuildMessageEventArgs2();
|
||||
cbmea = new CriticalBuildMessageEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "Sender");
|
||||
cbmea = new CriticalBuildMessageEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "Sender", DateTime.Now);
|
||||
cbmea = new CriticalBuildMessageEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "{0}", "HelpKeyword", "Sender", DateTime.Now, "Message");
|
||||
cbmea = new CriticalBuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null);
|
||||
cbmea = new CriticalBuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null, DateTime.Now);
|
||||
cbmea = new CriticalBuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null, DateTime.Now, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class CriticalBuildMessageEventArgs2 : CriticalBuildMessageEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public CriticalBuildMessageEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,981 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class CustomEventArgSerialization_Tests
|
||||
{
|
||||
// Generic build class to test custom serialization of abstract class BuildEventArgs
|
||||
internal class GenericBuildEventArg : BuildEventArgs
|
||||
{
|
||||
internal GenericBuildEventArg
|
||||
(
|
||||
string message,
|
||||
string helpKeyword,
|
||||
string senderName
|
||||
)
|
||||
: base(message, helpKeyword, senderName)
|
||||
{
|
||||
//Do Nothing
|
||||
}
|
||||
}
|
||||
|
||||
// Stream, writer and reader where the events will be serialized and deserialized from
|
||||
private MemoryStream _stream;
|
||||
private BinaryWriter _writer;
|
||||
private BinaryReader _reader;
|
||||
|
||||
private int _eventArgVersion = (Environment.Version.Major * 10) + Environment.Version.Minor;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUp()
|
||||
{
|
||||
_stream = new MemoryStream();
|
||||
_writer = new BinaryWriter(_stream);
|
||||
_reader = new BinaryReader(_stream);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TearDown()
|
||||
{
|
||||
// Close will close the writer/reader and the underlying stream
|
||||
_writer.Close();
|
||||
_reader.Close();
|
||||
_reader = null;
|
||||
_stream = null;
|
||||
_writer = null;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGenericBuildEventArgs()
|
||||
{
|
||||
// Test using reasonable messages
|
||||
GenericBuildEventArg genericEvent = new GenericBuildEventArg("Message", "HelpKeyword", "SenderName");
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
// Get position of stream after write so it can be compared to the position after read
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
GenericBuildEventArg newGenericEvent = new GenericBuildEventArg(null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using empty strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new GenericBuildEventArg(string.Empty, string.Empty, string.Empty);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new GenericBuildEventArg(null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using null strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new GenericBuildEventArg(null, null, null);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new GenericBuildEventArg(null, null, null);
|
||||
newGenericEvent.BuildEventContext = new BuildEventContext(1, 3, 4, 5);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two BuildEventArgs
|
||||
/// </summary>
|
||||
private static void VerifyGenericEventArg(BuildEventArgs genericEvent, BuildEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.AreEqual(genericEvent.BuildEventContext, newGenericEvent.BuildEventContext, "Expected Event Context to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.HelpKeyword, newGenericEvent.HelpKeyword, StringComparison.OrdinalIgnoreCase) == 0, "Expected Help Keywords to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.Message, newGenericEvent.Message, StringComparison.OrdinalIgnoreCase) == 0, "Expected Message to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.SenderName, newGenericEvent.SenderName, StringComparison.OrdinalIgnoreCase) == 0, "Expected Sender Name to Match");
|
||||
Assert.AreEqual(genericEvent.ThreadId, newGenericEvent.ThreadId, "Expected ThreadId to Match");
|
||||
Assert.AreEqual(genericEvent.Timestamp, newGenericEvent.Timestamp, "Expected TimeStamp to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBuildErrorEventArgs()
|
||||
{
|
||||
// Test using reasonable messages
|
||||
BuildErrorEventArgs genericEvent = new BuildErrorEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "SenderName");
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
BuildErrorEventArgs newGenericEvent = new BuildErrorEventArgs(null, null, null, -1, -1, -1, -1, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyBuildErrorEventArgs(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using empty strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 1, 2, 3, 4, string.Empty, string.Empty, string.Empty);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildErrorEventArgs(null, null, null, -1, -1, -1, -1, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyBuildErrorEventArgs(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using null strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new BuildErrorEventArgs(null, null, null, 1, 2, 3, 4, null, null, null);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildErrorEventArgs("Something", "SomeThing", "SomeThing", -1, -1, -1, -1, "Something", "SomeThing", "Something");
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyBuildErrorEventArgs(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two BuildEventArgs
|
||||
/// </summary>
|
||||
private static void VerifyBuildErrorEventArgs(BuildErrorEventArgs genericEvent, BuildErrorEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.IsTrue(string.Compare(genericEvent.Code, newGenericEvent.Code, StringComparison.OrdinalIgnoreCase) == 0, "Expected Code to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.File, newGenericEvent.File, StringComparison.OrdinalIgnoreCase) == 0, "Expected File to Match");
|
||||
Assert.AreEqual(genericEvent.ColumnNumber, newGenericEvent.ColumnNumber, "Expected ColumnNumber to Match");
|
||||
Assert.AreEqual(genericEvent.EndColumnNumber, newGenericEvent.EndColumnNumber, "Expected EndColumnNumber to Match");
|
||||
Assert.AreEqual(genericEvent.EndLineNumber, newGenericEvent.EndLineNumber, "Expected EndLineNumber to Match");
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void TestBuildFinishedEventArgs()
|
||||
{
|
||||
// Test using reasonable messages
|
||||
BuildFinishedEventArgs genericEvent = new BuildFinishedEventArgs("Message", "HelpKeyword", true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
BuildFinishedEventArgs newGenericEvent = new BuildFinishedEventArgs(null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeeded to Match");
|
||||
|
||||
// Test using empty strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new BuildFinishedEventArgs(string.Empty, string.Empty, true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildFinishedEventArgs(null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeded to Match");
|
||||
|
||||
// Test using null strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new BuildFinishedEventArgs(null, null, true);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildFinishedEventArgs("Something", "Something", false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeded to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBuildMessageEventArgs()
|
||||
{
|
||||
// Test using reasonable messages
|
||||
BuildMessageEventArgs genericEvent = new BuildMessageEventArgs("Message", "HelpKeyword", "SenderName", MessageImportance.High);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
BuildMessageEventArgs newGenericEvent = new BuildMessageEventArgs(null, null, null, MessageImportance.Low);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.AreEqual(genericEvent.Importance, newGenericEvent.Importance, "Expected Message Importance to Match");
|
||||
|
||||
// Test empty strings
|
||||
_stream.Position = 0;
|
||||
// Make sure empty strings are passed correctly
|
||||
genericEvent = new BuildMessageEventArgs(string.Empty, string.Empty, string.Empty, MessageImportance.Low);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildMessageEventArgs(null, null, null, MessageImportance.Low);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.AreEqual(genericEvent.Importance, newGenericEvent.Importance, "Expected Message Importance to Match");
|
||||
|
||||
// Test null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
genericEvent = new BuildMessageEventArgs(null, null, null, MessageImportance.Low);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildMessageEventArgs("Something", "Something", "Something", MessageImportance.Low);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.AreEqual(genericEvent.Importance, newGenericEvent.Importance, "Expected Message Importance to Match");
|
||||
}
|
||||
|
||||
private void VerifyMessageEventArg(BuildMessageEventArgs messageEvent, BuildMessageEventArgs newMessageEvent)
|
||||
{
|
||||
VerifyGenericEventArg(messageEvent, newMessageEvent);
|
||||
|
||||
Assert.AreEqual(messageEvent.Importance, newMessageEvent.Importance, "Expected Message Importance to Match");
|
||||
Assert.AreEqual(messageEvent.Subcategory, newMessageEvent.Subcategory, "Expected message Subcategory to match");
|
||||
Assert.AreEqual(messageEvent.Code, newMessageEvent.Code, "Expected message Code to match");
|
||||
Assert.AreEqual(messageEvent.File, newMessageEvent.File, "Expected message File to match");
|
||||
Assert.AreEqual(messageEvent.LineNumber, newMessageEvent.LineNumber, "Expected message LineNumber to match");
|
||||
Assert.AreEqual(messageEvent.ColumnNumber, newMessageEvent.ColumnNumber, "Expected message ColumnNumber to match");
|
||||
Assert.AreEqual(messageEvent.EndLineNumber, newMessageEvent.EndLineNumber, "Expected message EndLineNumber to match");
|
||||
Assert.AreEqual(messageEvent.EndColumnNumber, newMessageEvent.EndColumnNumber, "Expected message EndColumnNumber to match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBuildMessageEventArgsWithFileInfo()
|
||||
{
|
||||
// Test using reasonable messages
|
||||
BuildMessageEventArgs messageEvent = new BuildMessageEventArgs("SubCategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "SenderName", MessageImportance.High);
|
||||
messageEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
messageEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
BuildMessageEventArgs newMessageEvent = new BuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null, MessageImportance.Low);
|
||||
newMessageEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyMessageEventArg(messageEvent, newMessageEvent);
|
||||
|
||||
// Test empty strings
|
||||
_stream.Position = 0;
|
||||
// Make sure empty strings are passed correctly
|
||||
messageEvent = new BuildMessageEventArgs(string.Empty, string.Empty, string.Empty, 1, 2, 3, 4, string.Empty, string.Empty, string.Empty, MessageImportance.Low);
|
||||
messageEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
messageEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newMessageEvent = new BuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null, MessageImportance.Low);
|
||||
newMessageEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyMessageEventArg(messageEvent, newMessageEvent);
|
||||
|
||||
// Test null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
messageEvent = new BuildMessageEventArgs(null, null, null, 1, 2, 3, 4, null, null, null, MessageImportance.Low);
|
||||
messageEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
messageEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newMessageEvent = new BuildMessageEventArgs("Something", "Something", "Something", 0, 0, 0, 0, "Something", "Something", "Something", MessageImportance.Low);
|
||||
newMessageEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyMessageEventArg(messageEvent, newMessageEvent);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCriticalBuildMessageEventArgs()
|
||||
{
|
||||
// Test using reasonable messages
|
||||
CriticalBuildMessageEventArgs criticalMessageEvent = new CriticalBuildMessageEventArgs("SubCategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "SenderName");
|
||||
criticalMessageEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
criticalMessageEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
CriticalBuildMessageEventArgs newCriticalMessageEvent = new CriticalBuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null);
|
||||
newCriticalMessageEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyMessageEventArg(criticalMessageEvent, newCriticalMessageEvent);
|
||||
|
||||
// Test empty strings
|
||||
_stream.Position = 0;
|
||||
// Make sure empty strings are passed correctly
|
||||
criticalMessageEvent = new CriticalBuildMessageEventArgs(string.Empty, string.Empty, string.Empty, 1, 2, 3, 4, string.Empty, string.Empty, string.Empty);
|
||||
criticalMessageEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
criticalMessageEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newCriticalMessageEvent = new CriticalBuildMessageEventArgs(null, null, null, 0, 0, 0, 0, null, null, null);
|
||||
newCriticalMessageEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyMessageEventArg(criticalMessageEvent, newCriticalMessageEvent);
|
||||
|
||||
// Test null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
criticalMessageEvent = new CriticalBuildMessageEventArgs(null, null, null, 1, 2, 3, 4, null, null, null);
|
||||
criticalMessageEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
criticalMessageEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newCriticalMessageEvent = new CriticalBuildMessageEventArgs("Something", "Something", "Something", 0, 0, 0, 0, "Something", "Something", "Something");
|
||||
newCriticalMessageEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyMessageEventArg(criticalMessageEvent, newCriticalMessageEvent);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBuildWarningEventArgs()
|
||||
{
|
||||
// Test with reasonable messages
|
||||
BuildWarningEventArgs genericEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "SenderName");
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
//Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
BuildWarningEventArgs newGenericEvent = new BuildWarningEventArgs(null, null, null, -1, -1, -1, -1, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyBuildWarningEventArgs(genericEvent, newGenericEvent);
|
||||
|
||||
// Test with empty strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new BuildWarningEventArgs(string.Empty, string.Empty, string.Empty, 1, 2, 3, 4, string.Empty, string.Empty, string.Empty);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
//Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildWarningEventArgs(null, null, null, -1, -1, -1, -1, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyBuildWarningEventArgs(genericEvent, newGenericEvent);
|
||||
|
||||
// Test with null strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new BuildWarningEventArgs(null, null, null, 1, 2, 3, 4, null, null, null);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
//Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
//Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new BuildWarningEventArgs("Something", "SomeThing", "SomeThing", -1, -1, -1, -1, "Something", "SomeThing", "Something");
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyBuildWarningEventArgs(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two build warning events
|
||||
/// </summary>
|
||||
private static void VerifyBuildWarningEventArgs(BuildWarningEventArgs genericEvent, BuildWarningEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.IsTrue(string.Compare(genericEvent.Subcategory, newGenericEvent.Subcategory, StringComparison.OrdinalIgnoreCase) == 0, "Expected SubCategory to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.Code, newGenericEvent.Code, StringComparison.OrdinalIgnoreCase) == 0, "Expected Code to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.File, newGenericEvent.File, StringComparison.OrdinalIgnoreCase) == 0, "Expected File to Match");
|
||||
Assert.AreEqual(genericEvent.ColumnNumber, newGenericEvent.ColumnNumber, "Expected ColumnNumber to Match");
|
||||
Assert.AreEqual(genericEvent.EndColumnNumber, newGenericEvent.EndColumnNumber, "Expected EndColumnNumber to Match");
|
||||
Assert.AreEqual(genericEvent.EndLineNumber, newGenericEvent.EndLineNumber, "Expected EndLineNumber to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestProjectFinishedEventArgs()
|
||||
{
|
||||
// Test with reasonable values
|
||||
ProjectFinishedEventArgs genericEvent = new ProjectFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
ProjectFinishedEventArgs newGenericEvent = new ProjectFinishedEventArgs(null, null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeded to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
|
||||
// Test with empty strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new ProjectFinishedEventArgs(string.Empty, string.Empty, string.Empty, true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new ProjectFinishedEventArgs(null, null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeded to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
|
||||
// Test with null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
genericEvent = new ProjectFinishedEventArgs(null, null, null, true);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new ProjectFinishedEventArgs("Something", "Something", "Something", false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeded to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestProjectStartedPropertySerialization()
|
||||
{
|
||||
// Create a list of test properties which should make it through serialization
|
||||
List<DictionaryEntry> propertyList = new List<DictionaryEntry>();
|
||||
propertyList.Add(new DictionaryEntry("TeamBuildOutDir", "c:\\outdir"));
|
||||
propertyList.Add(new DictionaryEntry("Configuration", "BuildConfiguration"));
|
||||
propertyList.Add(new DictionaryEntry("Platform", "System Platform"));
|
||||
propertyList.Add(new DictionaryEntry("OutDir", "myOutDir"));
|
||||
propertyList.Add(new DictionaryEntry("WorkSpaceName", " MyWorkspace"));
|
||||
propertyList.Add(new DictionaryEntry("WorkSpaceOwner", "The workspace owner"));
|
||||
propertyList.Add(new DictionaryEntry("IAmBlank", string.Empty));
|
||||
|
||||
ProjectStartedEventArgs genericEvent = new ProjectStartedEventArgs(8, "Message", "HelpKeyword", "ProjectFile", null, propertyList, null, new BuildEventContext(7, 8, 9, 10));
|
||||
genericEvent.BuildEventContext = new BuildEventContext(7, 8, 9, 10);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
ProjectStartedEventArgs newGenericEvent = new ProjectStartedEventArgs(-1, null, null, null, null, null, null, null);
|
||||
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
Assert.IsNotNull(newGenericEvent.Properties, "Expected Properties to not be null");
|
||||
|
||||
// Create a list of all of the dictionaryEntries which were deserialized
|
||||
List<DictionaryEntry> entryList = new List<DictionaryEntry>();
|
||||
foreach (DictionaryEntry entry in newGenericEvent.Properties)
|
||||
{
|
||||
entryList.Add(entry);
|
||||
}
|
||||
|
||||
// Verify that each of the items in propertyList is inside of the deserialized entryList.
|
||||
AssertDictionaryEntry(entryList, propertyList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare the BuildProperties in propertyList with the Name Value pairs in the entryList.
|
||||
/// We need to make sure that each of the BuildProperties passed into the serializer come out correctly
|
||||
/// </summary>
|
||||
/// <param name="entryList">List of DictionaryEntries which were deserialized</param>
|
||||
/// <param name="propertyList">List of BuildProperties which were serialized</param>
|
||||
private void AssertDictionaryEntry(List<DictionaryEntry> entryList, List<DictionaryEntry> propertyList)
|
||||
{
|
||||
// make sure that there are the same number of elements in both lists as a quick initial check
|
||||
Assert.AreEqual(propertyList.Count, entryList.Count);
|
||||
|
||||
// Go through each of the properties which were serialized and make sure we find the exact same
|
||||
// name and value in the deserialized version.
|
||||
foreach (DictionaryEntry property in propertyList)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (DictionaryEntry entry in entryList)
|
||||
{
|
||||
string key = (string)entry.Key;
|
||||
string value = (string)entry.Value;
|
||||
if (key.Equals((string)property.Key, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (value.Equals((string)property.Value, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsTrue(found, "Expected to find Key:" + property.Key + " Value:" + property.Value);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestProjectStartedEventArgs()
|
||||
{
|
||||
// Test with reasonable values
|
||||
ProjectStartedEventArgs genericEvent = new ProjectStartedEventArgs(8, "Message", "HelpKeyword", "ProjectFile", null, null, null, new BuildEventContext(7, 8, 9, 10));
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
ProjectStartedEventArgs newGenericEvent = new ProjectStartedEventArgs(-1, null, null, null, null, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyProjectStartedEvent(genericEvent, newGenericEvent);
|
||||
|
||||
// Test with empty strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new ProjectStartedEventArgs(-1, string.Empty, string.Empty, string.Empty, string.Empty, null, null, null);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new ProjectStartedEventArgs(-1, null, null, null, null, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream end positions should be equal");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyProjectStartedEvent(genericEvent, newGenericEvent);
|
||||
|
||||
// Test with null strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new ProjectStartedEventArgs(-1, null, null, null, null, null, null, null);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new ProjectStartedEventArgs(4, "Something", "Something", "Something", null, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyProjectStartedEvent(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two project started events
|
||||
/// </summary>
|
||||
private static void VerifyProjectStartedEvent(ProjectStartedEventArgs genericEvent, ProjectStartedEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.AreEqual(genericEvent.Items, newGenericEvent.Items, "Expected Properties to match");
|
||||
Assert.AreEqual(genericEvent.Properties, newGenericEvent.Properties, "Expected Properties to match");
|
||||
Assert.AreEqual(genericEvent.ParentProjectBuildEventContext, newGenericEvent.ParentProjectBuildEventContext, "Expected ParentEvent Contextes to match");
|
||||
Assert.AreEqual(genericEvent.ProjectId, newGenericEvent.ProjectId, "Expected ProjectId to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.TargetNames, newGenericEvent.TargetNames, StringComparison.OrdinalIgnoreCase) == 0, "Expected TargetNames to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestTargetStartedEventArgs()
|
||||
{
|
||||
// Test using reasonable values
|
||||
TargetStartedEventArgs genericEvent = new TargetStartedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile", "ParentTargetStartedEvent", DateTime.UtcNow);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
TargetStartedEventArgs newGenericEvent = new TargetStartedEventArgs(null, null, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTargetStarted(genericEvent, newGenericEvent);
|
||||
|
||||
//Test using Empty strings
|
||||
_stream.Position = 0;
|
||||
// Make sure empty strings are passed correctly
|
||||
genericEvent = new TargetStartedEventArgs(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, DateTime.Now);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TargetStartedEventArgs(null, null, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTargetStarted(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
genericEvent = new TargetStartedEventArgs(null, null, null, null, null, null, DateTime.Now);
|
||||
genericEvent.BuildEventContext = null;
|
||||
//Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
//Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TargetStartedEventArgs("Something", "Something", "Something", "Something", "Something", "Something", DateTime.Now);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTargetStarted(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two targetStarted events
|
||||
/// </summary>
|
||||
private static void VerifyTargetStarted(TargetStartedEventArgs genericEvent, TargetStartedEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.IsTrue(string.Compare(genericEvent.TargetFile, newGenericEvent.TargetFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected TargetFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.TargetName, newGenericEvent.TargetName, StringComparison.OrdinalIgnoreCase) == 0, "Expected TargetName to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ParentTarget, newGenericEvent.ParentTarget, StringComparison.OrdinalIgnoreCase) == 0, "Expected ParentTarget to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestTargetFinishedEventArgs()
|
||||
{
|
||||
// Test using reasonable values
|
||||
TargetFinishedEventArgs genericEvent = new TargetFinishedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile", true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
TargetFinishedEventArgs newGenericEvent = new TargetFinishedEventArgs(null, null, null, null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTargetFinished(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using empty strings
|
||||
_stream.Position = 0;
|
||||
genericEvent = new TargetFinishedEventArgs(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TargetFinishedEventArgs(null, null, null, null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTargetFinished(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
genericEvent = new TargetFinishedEventArgs(null, null, null, null, null, true);
|
||||
genericEvent.BuildEventContext = null;
|
||||
//Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
//Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TargetFinishedEventArgs("Something", "Something", "Something", "Something", "Something", false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTargetFinished(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two TargetFinished events
|
||||
/// </summary>
|
||||
private static void VerifyTargetFinished(TargetFinishedEventArgs genericEvent, TargetFinishedEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeded to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.TargetFile, newGenericEvent.TargetFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected TargetFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.TargetName, newGenericEvent.TargetName, StringComparison.OrdinalIgnoreCase) == 0, "Expected TargetName to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestTaskStartedEventArgs()
|
||||
{
|
||||
// Test using reasonable values
|
||||
TaskStartedEventArgs genericEvent = new TaskStartedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName");
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
TaskStartedEventArgs newGenericEvent = new TaskStartedEventArgs(null, null, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTaskStarted(genericEvent, newGenericEvent);
|
||||
|
||||
_stream.Position = 0;
|
||||
// Make sure empty strings are passed correctly
|
||||
genericEvent = new TaskStartedEventArgs(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TaskStartedEventArgs(null, null, null, null, null);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTaskStarted(genericEvent, newGenericEvent);
|
||||
|
||||
// Test using null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
genericEvent = new TaskStartedEventArgs(null, null, null, null, null);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TaskStartedEventArgs("Something", "Something", "Something", "Something", "Something");
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTaskStarted(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two TaskStarted events
|
||||
/// </summary>
|
||||
private static void VerifyTaskStarted(TaskStartedEventArgs genericEvent, TaskStartedEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.IsTrue(string.Compare(genericEvent.TaskFile, newGenericEvent.TaskFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected TaskFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.TaskName, newGenericEvent.TaskName, StringComparison.OrdinalIgnoreCase) == 0, "Expected TaskName to Match");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestTaskFinishedEventArgs()
|
||||
{
|
||||
// Test using reasonable values
|
||||
TaskFinishedEventArgs genericEvent = new TaskFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName", true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
long streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
TaskFinishedEventArgs newGenericEvent = new TaskFinishedEventArgs(null, null, null, null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
long streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTaskFinished(genericEvent, newGenericEvent);
|
||||
|
||||
//Test using empty strings
|
||||
_stream.Position = 0;
|
||||
// Make sure empty strings are passed correctly
|
||||
genericEvent = new TaskFinishedEventArgs(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, true);
|
||||
genericEvent.BuildEventContext = new BuildEventContext(5, 4, 3, 2);
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TaskFinishedEventArgs(null, null, null, null, null, false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTaskFinished(genericEvent, newGenericEvent);
|
||||
|
||||
//Test using null strings
|
||||
_stream.Position = 0;
|
||||
// Make sure null string are passed correctly
|
||||
genericEvent = new TaskFinishedEventArgs(null, null, null, null, null, true);
|
||||
genericEvent.BuildEventContext = null;
|
||||
|
||||
// Serialize
|
||||
genericEvent.WriteToStream(_writer);
|
||||
streamWriteEndPosition = _stream.Position;
|
||||
|
||||
// Deserialize and Verify
|
||||
_stream.Position = 0;
|
||||
newGenericEvent = new TaskFinishedEventArgs("Something", "Something", "Something", "Something", "Something", false);
|
||||
newGenericEvent.CreateFromStream(_reader, _eventArgVersion);
|
||||
streamReadEndPosition = _stream.Position;
|
||||
Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream End Positions Should Match");
|
||||
VerifyGenericEventArg(genericEvent, newGenericEvent);
|
||||
VerifyTaskFinished(genericEvent, newGenericEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two task finished events
|
||||
/// </summary>
|
||||
private static void VerifyTaskFinished(TaskFinishedEventArgs genericEvent, TaskFinishedEventArgs newGenericEvent)
|
||||
{
|
||||
Assert.IsTrue(genericEvent.Succeeded == newGenericEvent.Succeeded, "Expected Succeded to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.ProjectFile, newGenericEvent.ProjectFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.TaskFile, newGenericEvent.TaskFile, StringComparison.OrdinalIgnoreCase) == 0, "Expected TaskFile to Match");
|
||||
Assert.IsTrue(string.Compare(genericEvent.TaskName, newGenericEvent.TaskName, StringComparison.OrdinalIgnoreCase) == 0, "Expected TaskName to Match");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for EventArgsTests</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Unit test the base class BuildEventArgs
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class EventArgs_Tests
|
||||
{
|
||||
#region BaseClass Equals Tests
|
||||
|
||||
/// <summary>
|
||||
/// Base instance of a BuildEventArgs some default data, this is used during the tests
|
||||
/// to verify the equals operators.
|
||||
/// </summary>
|
||||
private static GenericBuildEventArgs s_baseGenericEvent = null;
|
||||
|
||||
/// <summary>
|
||||
/// Setup the text, this method is run ONCE for the entire text fixture
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void Setup(TestContext context)
|
||||
{
|
||||
s_baseGenericEvent = new GenericBuildEventArgs("Message", "HelpKeyword", "senderName");
|
||||
s_baseGenericEvent.BuildEventContext = new BuildEventContext(9, 8, 7, 6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise getHashCode.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestGetHashCode()
|
||||
{
|
||||
s_baseGenericEvent.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
GenericBuildEventArgs genericEventTest = new GenericBuildEventArgs();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Verify a whidby project started event can be deserialized, the whidby event is stored in a serialized base64 string.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[Ignore]
|
||||
// Ignore: Type in serialized string targets MSBuild retail public key, will not de-serialize
|
||||
public void TestDeserialization()
|
||||
{
|
||||
string base64OldProjectStarted = "AAEAAAD/////AQAAAAAAAAAMAgAAAFxNaWNyb3NvZnQuQnVpbGQuRnJhbWV3b3JrLCBWZXJzaW9uPTIuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49YjAzZjVmN2YxMWQ1MGEzYQUBAAAAMU1pY3Jvc29mdC5CdWlsZC5GcmFtZXdvcmsuUHJvamVjdFN0YXJ0ZWRFdmVudEFyZ3MHAAAAC3Byb2plY3RGaWxlC3RhcmdldE5hbWVzFkJ1aWxkRXZlbnRBcmdzK21lc3NhZ2UaQnVpbGRFdmVudEFyZ3MraGVscEtleXdvcmQZQnVpbGRFdmVudEFyZ3Mrc2VuZGVyTmFtZRhCdWlsZEV2ZW50QXJncyt0aW1lc3RhbXAXQnVpbGRFdmVudEFyZ3MrdGhyZWFkSWQBAQEBAQAADQgCAAAABgMAAAALcHJvamVjdEZpbGUGBAAAAAt0YXJnZXROYW1lcwYFAAAAB21lc3NhZ2UGBgAAAAtoZWxwS2V5d29yZAYHAAAAB01TQnVpbGQBl5vjTYvIiAsAAAAL";
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
MemoryStream ms = new MemoryStream();
|
||||
byte[] binaryObject = Convert.FromBase64String(base64OldProjectStarted);
|
||||
ms.Write(binaryObject, 0, binaryObject.Length);
|
||||
ms.Position = 0;
|
||||
ProjectStartedEventArgs pse = (ProjectStartedEventArgs)bf.Deserialize(ms);
|
||||
Assert.IsTrue(string.Compare(pse.Message, "message", StringComparison.OrdinalIgnoreCase) == 0);
|
||||
Assert.IsTrue(string.Compare(pse.ProjectFile, "projectFile", StringComparison.OrdinalIgnoreCase) == 0);
|
||||
Assert.AreEqual(pse.ProjectId, -1);
|
||||
Assert.IsTrue(string.Compare(pse.TargetNames, "targetNames", StringComparison.OrdinalIgnoreCase) == 0);
|
||||
Assert.AreEqual(pse.BuildEventContext, BuildEventContext.Invalid);
|
||||
Assert.AreEqual(pse.ParentProjectBuildEventContext, BuildEventContext.Invalid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the BuildEventContext is exercised
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void ExerciseBuildEventContext()
|
||||
{
|
||||
BuildEventContext parentBuildEventContext = new BuildEventContext(0, 0, 0, 0);
|
||||
BuildEventContext currentBuildEventContext = new BuildEventContext(0, 2, 1, 1);
|
||||
|
||||
BuildEventContext currentBuildEventContextNode = new BuildEventContext(1, 0, 0, 0);
|
||||
BuildEventContext currentBuildEventContextTarget = new BuildEventContext(0, 1, 0, 0);
|
||||
BuildEventContext currentBuildEventContextPci = new BuildEventContext(0, 0, 1, 0);
|
||||
BuildEventContext currentBuildEventContextTask = new BuildEventContext(0, 0, 0, 1);
|
||||
BuildEventContext allDifferent = new BuildEventContext(1, 1, 1, 1);
|
||||
BuildEventContext allSame = new BuildEventContext(0, 0, 0, 0);
|
||||
|
||||
ProjectStartedEventArgs startedEvent = new ProjectStartedEventArgs(-1, "Message", "HELP", "File", "Targets", null, null, parentBuildEventContext);
|
||||
startedEvent.BuildEventContext = currentBuildEventContext;
|
||||
Assert.IsTrue(parentBuildEventContext.GetHashCode() == 0);
|
||||
|
||||
// Node is different
|
||||
Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextNode));
|
||||
|
||||
// Target is different
|
||||
Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextTarget));
|
||||
|
||||
// PCI is different
|
||||
Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextPci));
|
||||
|
||||
// Task is different
|
||||
Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextTask));
|
||||
|
||||
// All fields are different
|
||||
Assert.IsFalse(parentBuildEventContext.Equals(allDifferent));
|
||||
|
||||
// All fields are same
|
||||
Assert.IsTrue(parentBuildEventContext.Equals(allSame));
|
||||
|
||||
// Compare with null
|
||||
Assert.IsFalse(parentBuildEventContext.Equals(null));
|
||||
|
||||
// Compare with self
|
||||
Assert.IsTrue(currentBuildEventContext.Equals(currentBuildEventContext));
|
||||
Assert.IsFalse(currentBuildEventContext.Equals(new object()));
|
||||
Assert.IsNotNull(startedEvent.BuildEventContext);
|
||||
|
||||
Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.NodeId);
|
||||
Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.TargetId);
|
||||
Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.ProjectContextId);
|
||||
Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.TaskId);
|
||||
Assert.AreEqual(0, startedEvent.BuildEventContext.NodeId);
|
||||
Assert.AreEqual(2, startedEvent.BuildEventContext.TargetId);
|
||||
Assert.AreEqual(1, startedEvent.BuildEventContext.ProjectContextId);
|
||||
Assert.AreEqual(1, startedEvent.BuildEventContext.TaskId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A generic buildEvent arg to test the equals method
|
||||
/// </summary>
|
||||
internal class GenericBuildEventArgs : BuildEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public GenericBuildEventArgs()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows all event data to be initialized
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
public GenericBuildEventArgs(string message, string helpKeyword, string senderName)
|
||||
: base(message, helpKeyword, senderName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor allows all data including timeStamps to be initialized
|
||||
/// </summary>
|
||||
/// <param name="message">text message</param>
|
||||
/// <param name="helpKeyword">help keyword </param>
|
||||
/// <param name="senderName">name of event sender</param>
|
||||
/// <param name="eventTimeStamp">TimeStamp of when the event was created</param>
|
||||
public GenericBuildEventArgs(string message, string helpKeyword, string senderName, DateTime eventTimeStamp)
|
||||
: base(message, helpKeyword, senderName, eventTimeStamp)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for ExternalProjectFinishedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the ExternalProjectFinishedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ExternalProjectFinishedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private ExternalProjectFinishedEventArgs _baseExternalProjectFinishedEvent = new ExternalProjectFinishedEventArgs("Message", "HelpKeyword", "Sender", "ProjectFile", true);
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
ExternalProjectFinishedEventArgs externalProjectFinishedEvent = new ExternalProjectFinishedEventArgs2();
|
||||
externalProjectFinishedEvent = new ExternalProjectFinishedEventArgs("Message", "HelpKeyword", "Sender", "ProjectFile", true);
|
||||
externalProjectFinishedEvent = new ExternalProjectFinishedEventArgs("Message", "HelpKeyword", "Sender", "ProjectFile", true, DateTime.Now);
|
||||
externalProjectFinishedEvent = new ExternalProjectFinishedEventArgs(null, null, null, null, true);
|
||||
externalProjectFinishedEvent = new ExternalProjectFinishedEventArgs(null, null, null, null, true, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class ExternalProjectFinishedEventArgs2 : ExternalProjectFinishedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public ExternalProjectFinishedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for ExternalProjectStartedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the ExternalProjectStartedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ExternalProjectStartedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private ExternalProjectStartedEventArgs _baseExternalProjectStartedEvent = new ExternalProjectStartedEventArgs("Message", "HelpKeyword", "Sender", "ProjectFile", "TargetNames");
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
ExternalProjectStartedEventArgs externalProjectStartedEvent = new ExternalProjectStartedEventArgs2();
|
||||
externalProjectStartedEvent = new ExternalProjectStartedEventArgs("Message", "HelpKeyword", "Sender", "ProjectFile", "TargetNames");
|
||||
externalProjectStartedEvent = new ExternalProjectStartedEventArgs("Message", "HelpKeyword", "Sender", "ProjectFile", "TargetNames", DateTime.Now);
|
||||
externalProjectStartedEvent = new ExternalProjectStartedEventArgs(null, null, null, null, null);
|
||||
externalProjectStartedEvent = new ExternalProjectStartedEventArgs(null, null, null, null, null, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class ExternalProjectStartedEventArgs2 : ExternalProjectStartedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public ExternalProjectStartedEventArgs2() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class LoggerExceptionTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify I implemented ISerializable correctly
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void SerializeDeserialize()
|
||||
{
|
||||
LoggerException e = new LoggerException("message",
|
||||
new Exception("innerException"),
|
||||
"errorCode",
|
||||
"helpKeyword");
|
||||
|
||||
using (MemoryStream memstr = new MemoryStream())
|
||||
{
|
||||
BinaryFormatter frm = new BinaryFormatter();
|
||||
|
||||
frm.Serialize(memstr, e);
|
||||
memstr.Position = 0;
|
||||
|
||||
LoggerException e2 = (LoggerException)frm.Deserialize(memstr);
|
||||
|
||||
Assert.AreEqual(e.ErrorCode, e2.ErrorCode);
|
||||
Assert.AreEqual(e.HelpKeyword, e2.HelpKeyword);
|
||||
Assert.AreEqual(e.Message, e2.Message);
|
||||
Assert.AreEqual(e.InnerException.Message, e2.InnerException.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify I implemented ISerializable correctly, using other ctor
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void SerializeDeserialize2()
|
||||
{
|
||||
LoggerException e = new LoggerException("message");
|
||||
|
||||
using (MemoryStream memstr = new MemoryStream())
|
||||
{
|
||||
BinaryFormatter frm = new BinaryFormatter();
|
||||
|
||||
frm.Serialize(memstr, e);
|
||||
memstr.Position = 0;
|
||||
|
||||
LoggerException e2 = (LoggerException)frm.Deserialize(memstr);
|
||||
|
||||
Assert.AreEqual(null, e2.ErrorCode);
|
||||
Assert.AreEqual(null, e2.HelpKeyword);
|
||||
Assert.AreEqual(e.Message, e2.Message);
|
||||
Assert.AreEqual(null, e2.InnerException);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{BE53C18D-7E4E-4C57-A359-1D662C384511}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Microsoft.Build.Framework.UnitTests</RootNamespace>
|
||||
<AssemblyName>Microsoft.Build.Framework.UnitTests</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Shared\FxCopExclusions\Microsoft.Build.Shared.Suppressions.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="Attribute_Tests.cs" />
|
||||
<Compile Include="BuildErrorEventArgs_Tests.cs" />
|
||||
<Compile Include="BuildFinishedEventArgs_Tests.cs" />
|
||||
<Compile Include="BuildMessageEventArgs_Tests.cs" />
|
||||
<Compile Include="BuildStartedEventArgs_Tests.cs" />
|
||||
<Compile Include="BuildWarningEventArgs_Tests.cs" />
|
||||
<Compile Include="CriticalBuildMessageEventArgs_Tests.cs" />
|
||||
<Compile Include="CustomEventArgSerialization_Tests.cs" />
|
||||
<Compile Include="EventArgs_Tests.cs" />
|
||||
<Compile Include="ExternalProjectFinishedEventArgs_Tests.cs" />
|
||||
<Compile Include="ExternalProjectStartedEventArgs_Tests.cs" />
|
||||
<Compile Include="LoggerException_Tests.cs" />
|
||||
<Compile Include="ProjectFinishedEventArgs_Tests.cs" />
|
||||
<Compile Include="ProjectStartedEventArgs_Tests.cs" />
|
||||
<Compile Include="TargetFinishedEventArgs_Tests.cs" />
|
||||
<Compile Include="TargetStartedEventArgs_Tests.cs" />
|
||||
<Compile Include="TaskCommandLineEventArgs_Tests.cs" />
|
||||
<Compile Include="TaskFinishedEventArgs_Tests.cs" />
|
||||
<Compile Include="TaskStartedEventArgs_Tests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||
<Reference Include="System" />
|
||||
<ProjectReference Include="..\Microsoft.Build.Framework.csproj">
|
||||
<Project>{571f09db-a81a-4444-945c-6f7b530054cd}</Project>
|
||||
<Name>Microsoft.Build.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\Shared\UnitTests\App.config">
|
||||
<Link>App.config</Link>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for ProjectFinishedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the ProjectFinishedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ProjectFinishedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private ProjectFinishedEventArgs _baseProjectFinishedEvent = new ProjectFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", true);
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
ProjectFinishedEventArgs projectFinishedEvent = new ProjectFinishedEventArgs2();
|
||||
projectFinishedEvent = new ProjectFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", true);
|
||||
projectFinishedEvent = new ProjectFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", true, DateTime.Now);
|
||||
projectFinishedEvent = new ProjectFinishedEventArgs(null, null, null, true);
|
||||
projectFinishedEvent = new ProjectFinishedEventArgs(null, null, null, true, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class ProjectFinishedEventArgs2 : ProjectFinishedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public ProjectFinishedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for ProjectStartedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the ProjectStartedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ProjectStartedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private static ProjectStartedEventArgs s_baseProjectStartedEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Setup for text fixture, this is run ONCE for the entire test fixture
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void FixtureSetup(TestContext context)
|
||||
{
|
||||
BuildEventContext parentBuildEventContext = new BuildEventContext(2, 3, 4, 5);
|
||||
s_baseProjectStartedEvent = new ProjectStartedEventArgs(1, "Message", "HelpKeyword", "ProjecFile", "TargetNames", null, null, parentBuildEventContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
ProjectStartedEventArgs projectStartedEvent = new ProjectStartedEventArgs2();
|
||||
Assert.IsNotNull(projectStartedEvent);
|
||||
|
||||
projectStartedEvent = new ProjectStartedEventArgs("Message", "HelpKeyword", "ProjecFile", "TargetNames", null, null);
|
||||
projectStartedEvent = new ProjectStartedEventArgs("Message", "HelpKeyword", "ProjecFile", "TargetNames", null, null, DateTime.Now);
|
||||
projectStartedEvent = new ProjectStartedEventArgs(1, "Message", "HelpKeyword", "ProjecFile", "TargetNames", null, null, null);
|
||||
projectStartedEvent = new ProjectStartedEventArgs(1, "Message", "HelpKeyword", "ProjecFile", "TargetNames", null, null, null, DateTime.Now);
|
||||
projectStartedEvent = new ProjectStartedEventArgs(null, null, null, null, null, null);
|
||||
projectStartedEvent = new ProjectStartedEventArgs(null, null, null, null, null, null, DateTime.Now);
|
||||
projectStartedEvent = new ProjectStartedEventArgs(1, null, null, null, null, null, null, null);
|
||||
projectStartedEvent = new ProjectStartedEventArgs(1, null, null, null, null, null, null, null, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify different Items and properties are not taken into account in the equals comparison. They should
|
||||
/// not be considered as part of the equals evaluation
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void ItemsAndPropertiesDifferentEquals()
|
||||
{
|
||||
ArrayList itemsList = new ArrayList();
|
||||
ArrayList propertiesList = new ArrayList();
|
||||
ProjectStartedEventArgs differentItemsAndProperties = new ProjectStartedEventArgs
|
||||
(
|
||||
s_baseProjectStartedEvent.ProjectId,
|
||||
s_baseProjectStartedEvent.Message,
|
||||
s_baseProjectStartedEvent.HelpKeyword,
|
||||
s_baseProjectStartedEvent.ProjectFile,
|
||||
s_baseProjectStartedEvent.TargetNames,
|
||||
propertiesList,
|
||||
itemsList,
|
||||
s_baseProjectStartedEvent.ParentProjectBuildEventContext,
|
||||
s_baseProjectStartedEvent.Timestamp
|
||||
);
|
||||
|
||||
Assert.IsFalse(propertiesList == s_baseProjectStartedEvent.Properties);
|
||||
Assert.IsFalse(itemsList == s_baseProjectStartedEvent.Items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class ProjectStartedEventArgs2 : ProjectStartedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public ProjectStartedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for TargetFinishedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the TargetFinishedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TargetFinishedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private TargetFinishedEventArgs _baseTargetFinishedEvent = new TargetFinishedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile", true);
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
List<ITaskItem> outputs = new List<ITaskItem>();
|
||||
TargetFinishedEventArgs targetFinishedEvent = new TargetFinishedEventArgs2();
|
||||
targetFinishedEvent = new TargetFinishedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile", true);
|
||||
targetFinishedEvent = new TargetFinishedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile", true, DateTime.Now, outputs);
|
||||
targetFinishedEvent = new TargetFinishedEventArgs(null, null, null, null, null, true);
|
||||
targetFinishedEvent = new TargetFinishedEventArgs(null, null, null, null, null, true, DateTime.Now, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class TargetFinishedEventArgs2 : TargetFinishedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public TargetFinishedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>NodePackets which are used for node communication</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the TargetStartedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TargetStartedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private TargetStartedEventArgs _baseTargetStartedEvent = new TargetStartedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile");
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
TargetStartedEventArgs targetStartedEvent = new TargetStartedEventArgs2();
|
||||
targetStartedEvent = new TargetStartedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile");
|
||||
targetStartedEvent = new TargetStartedEventArgs("Message", "HelpKeyword", "TargetName", "ProjectFile", "TargetFile", "ParentTarget", DateTime.Now);
|
||||
targetStartedEvent = new TargetStartedEventArgs(null, null, null, null, null);
|
||||
targetStartedEvent = new TargetStartedEventArgs(null, null, null, null, null, null, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class TargetStartedEventArgs2 : TargetStartedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public TargetStartedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for TaskCommandLineEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the TaskCommandLineEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TaskCommandLineEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
TaskCommandLineEventArgs taskCommandLineEvent = new TaskCommandLineEventArgs2();
|
||||
taskCommandLineEvent = new TaskCommandLineEventArgs("Commandline", "taskName", MessageImportance.High);
|
||||
taskCommandLineEvent = new TaskCommandLineEventArgs("Commandline", "taskName", MessageImportance.High, DateTime.Now);
|
||||
taskCommandLineEvent = new TaskCommandLineEventArgs(null, null, MessageImportance.High);
|
||||
taskCommandLineEvent = new TaskCommandLineEventArgs(null, null, MessageImportance.High, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class TaskCommandLineEventArgs2 : TaskCommandLineEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public TaskCommandLineEventArgs2() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for TaskFinishedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the TaskFinishedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TaskFinishedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private TaskFinishedEventArgs _baseTaskFinishedEvent = new TaskFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName", true);
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
TaskFinishedEventArgs targetFinishedEvent = new TaskFinishedEventArgs2();
|
||||
targetFinishedEvent = new TaskFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName", true);
|
||||
targetFinishedEvent = new TaskFinishedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName", true, DateTime.Now);
|
||||
targetFinishedEvent = new TaskFinishedEventArgs(null, null, null, null, null, true);
|
||||
targetFinishedEvent = new TaskFinishedEventArgs(null, null, null, null, null, true, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class TaskFinishedEventArgs2 : TaskFinishedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public TaskFinishedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Unit tests for TaskStartedEventArgs</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Build.UnitTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verify the functioning of the TaskStartedEventArgs class.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TaskStartedEventArgs_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Default event to use in tests.
|
||||
/// </summary>
|
||||
private TaskStartedEventArgs _baseTaskStartedEvent = new TaskStartedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName");
|
||||
|
||||
/// <summary>
|
||||
/// Trivially exercise event args default ctors to boost Frameworks code coverage
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void EventArgsCtors()
|
||||
{
|
||||
TaskStartedEventArgs taskStartedEvent = new TaskStartedEventArgs2();
|
||||
taskStartedEvent = new TaskStartedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName");
|
||||
taskStartedEvent = new TaskStartedEventArgs("Message", "HelpKeyword", "ProjectFile", "TaskFile", "TaskName", DateTime.Now);
|
||||
taskStartedEvent = new TaskStartedEventArgs(null, null, null, null, null);
|
||||
taskStartedEvent = new TaskStartedEventArgs(null, null, null, null, null, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a derrived class so that we can test the default constructor in order to increase code coverage and
|
||||
/// verify this code path does not cause any exceptions.
|
||||
/// </summary>
|
||||
private class TaskStartedEventArgs2 : TaskStartedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public TaskStartedEventArgs2()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents an argument to a property. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an argument to a <see cref="BaseProperty"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Functionally, it is simply a reference to another <see cref="BaseProperty"/>. Those who manually
|
||||
/// instantiate this class should remember to call <see cref="BeginInit"/> before setting the first
|
||||
/// property and <see cref="EndInit"/> after setting the last property of the object.
|
||||
/// </remarks>
|
||||
public sealed class Argument : ISupportInitialize
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor needed for XAML deserialization.
|
||||
/// </summary>
|
||||
public Argument()
|
||||
{
|
||||
Separator = String.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Name of the <see cref="BaseProperty"/> this argument refers to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Its value must point to a valid <see cref="BaseProperty"/>. This field is mandatory and culture invariant.
|
||||
/// </remarks>
|
||||
public string Property
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells if the <see cref="BaseProperty"/> pointed to by <see cref="Property"/> must be defined for the definition
|
||||
/// of the <see cref="BaseProperty"/> owning this argument to make sense.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and is set to <c>false</c> by default.
|
||||
/// </remarks>
|
||||
public bool IsRequired
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The string used to separate this argument value from the parent <see cref="BaseProperty"/> switch in the command line.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and culture invariant.
|
||||
/// </remarks>
|
||||
public string Separator
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISupportInitialize Members
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void BeginInit()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void EndInit()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,447 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents a Rule property. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Markup;
|
||||
using System.Xml;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Rule"/> property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>This represents schema information (name, allowed values, etc) of a <see cref="Rule"/> property.
|
||||
/// Since this is just schema information, there is no field like "Value" used to get/set the value of this
|
||||
/// property.</para>
|
||||
/// <para> Those who manually instantiate this class should remember to call <see cref="BeginInit"/> before
|
||||
/// setting the first property and <see cref="EndInit"/> after setting the last property of the object.</para>
|
||||
/// </remarks>
|
||||
/// <comment>
|
||||
/// This partial class contains all properties which are public and hence settable in XAML. Those properties that
|
||||
/// are internal are defined in another partial class below.
|
||||
/// </comment>
|
||||
[ContentProperty("Arguments")]
|
||||
public abstract partial class BaseProperty : ISupportInitialize
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// See DisplayName property.
|
||||
/// </summary>
|
||||
private string _displayName;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor. Needed for deserializtion from a persisted format.
|
||||
/// </summary>
|
||||
protected BaseProperty()
|
||||
{
|
||||
// Initialize collection properties in this class. This is required for
|
||||
// proper deserialization.
|
||||
Metadata = new List<NameValuePair>();
|
||||
Arguments = new List<Argument>();
|
||||
ValueEditors = new List<ValueEditor>();
|
||||
|
||||
// The default value of Visible.
|
||||
Visible = true;
|
||||
|
||||
// The default value of IncludeInCommandLine.
|
||||
IncludeInCommandLine = true;
|
||||
|
||||
SwitchPrefix = String.Empty;
|
||||
Separator = String.Empty;
|
||||
Category = "General";
|
||||
Subcategory = String.Empty;
|
||||
|
||||
HelpContext = -1;
|
||||
HelpFile = String.Empty;
|
||||
HelpUrl = String.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The name of this <see cref="BaseProperty"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is mandatory and culture invariant. The value of this field cannot be set to the empty string.
|
||||
/// </remarks>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name that could be used by a prospective UI client to display this <see cref="BaseProperty"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and is culture sensitive. When this property is not set, it is assigned the same
|
||||
/// value as the <see cref="Name"/> property (and hence, would not be localized).
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _displayName ?? Name;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_displayName = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Description of this <see cref="BaseProperty"/> for use by a prospective UI client.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and is culture sensitive.
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string Description
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The keyword that is used to open the help page for this property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This form of specifying help takes precedence over <see cref="HelpUrl"/>
|
||||
/// and <see cref="HelpFile"/> + <see cref="HelpContext"/>.
|
||||
/// This field is optional and is culture insensitive.
|
||||
/// </remarks>
|
||||
[Localizable(false)]
|
||||
public string F1Keyword
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The URL of the help page for this property that will be opened when the user hits F1.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property is higher in priority that <see cref="HelpContext"/> + <see cref="HelpFile"/>
|
||||
/// (i.e., these two properties are ignored if <see cref="HelpUrl"/>
|
||||
/// is specified), but lower in priority than <see cref="F1Keyword"/>.
|
||||
/// This field is optional and is culture insensitive.
|
||||
/// </remarks>
|
||||
/// <example> <c>ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vstoc/html/06ddebea-2c83-4a45-bb48-6264c797ed93.htm</c> </example>
|
||||
[Localizable(false)]
|
||||
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public string HelpUrl
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The help file to use when the user hits F1. Must specify <see cref="HelpContext"/> along with this.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property goes along with <see cref="HelpContext"/>. <seealso cref="HelpContext"/>. This
|
||||
/// form of specifying the help page for a property takes lower precedence than both <see cref="F1Keyword"/>
|
||||
/// and <see cref="HelpUrl"/>.
|
||||
/// This field is optional and is culture insensitive.
|
||||
/// </remarks>
|
||||
[Localizable(false)]
|
||||
public string HelpFile
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The help context to use when the user hits F1. Must specify <see cref="HelpFile"/> along with this.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property uses the <see cref="HelpFile"/> property to display the help context of the specified
|
||||
/// help file. This field is optional. This
|
||||
/// form of specifying the help page for a property takes lower precedence than both <see cref="F1Keyword"/>
|
||||
/// and <see cref="HelpUrl"/>.
|
||||
/// </remarks>
|
||||
public int HelpContext
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the category to which this property belongs to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// If the value of this field does not correspond to the <c>Name</c>
|
||||
/// property of a <see cref="Category"/> element defined in
|
||||
/// the containing <see cref="Rule"/>, a default <see cref="Category"/> with this name
|
||||
/// is auto-generated and added to the containing <see cref="Rule"/> class.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This field is optional and is culture invariant.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// When this field is not specified, this property is added to a
|
||||
/// auto-generated category called <c>General</c> (localized). This field cannot be set to the
|
||||
/// empty string.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public string Category
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sub category to which this property belongs to.
|
||||
/// </summary>
|
||||
public string Subcategory
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells if this property is a read-only property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and its default value is "false".
|
||||
/// </remarks>
|
||||
public bool ReadOnly
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A value indicating whether this property allows multiple values to be supplied/selected simultaneously.
|
||||
/// </summary>
|
||||
public bool MultipleValuesAllowed
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The switch representation of this property for the case when this property represents a tool parameter.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and culture invariant.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// For the VC++ CL task, <c>WholeProgramOptimization</c> is a boolean parameter. It's switch is <c>GL</c>.
|
||||
/// </example>
|
||||
public string Switch
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The prefix for the switch representation of this property for the case when this property represents a tool parameter.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The value specified here overrides the value specified for the parent <see cref="Rule"/>'s <see cref="Rule.SwitchPrefix"/>.
|
||||
/// This field is optional and culture invariant.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// For the VC++ CL task, <c>WholeProgramOptimization</c> is a boolean parameter. It's switch is <c>GL</c> and its
|
||||
/// switch prefix (inherited from the parent <see cref="Rule.SwitchPrefix"/> since it is not overriden by <c>WholeProgramOptimization</c>)
|
||||
/// is <c>/</c>. Thus the complete switch in the command line for this property would be <c>/GL</c>
|
||||
/// </example>
|
||||
public string SwitchPrefix
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The token used to separate a switch from its value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The value specified here overrides the value specified for the parent <see cref="Rule"/>'s <see cref="Rule.Separator"/>.
|
||||
/// This field is optional and culture invariant.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// Example: Consider <c>/D:WIN32</c>. In this switch and value representation, ":" is the separator since its separates the switch <c>D</c>
|
||||
/// from its value <c>WIN32</c>.
|
||||
/// </example>
|
||||
public string Separator
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A hint to the UI client telling it whether to display this property or not.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and has the default value of "true".
|
||||
/// </remarks>
|
||||
public bool Visible
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A hint to the command line constructor whether to include this property in the command line or not.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Some properties are used only by the targets and don't want to be included in the command line.
|
||||
/// Others (like task parameters) are included in the command line in the form of the switch/value they emit.
|
||||
/// This field is optional and has the default value of <c>true</c>.
|
||||
/// </remarks>
|
||||
public bool IncludeInCommandLine
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this property is required to have a value set.
|
||||
/// </summary>
|
||||
public bool IsRequired
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the default value for this property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and whether, for a <see cref="StringProperty"/>,
|
||||
/// it is culture sensitive or not depends on the semantics of it.
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string Default
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data source where the current value of this property is stored.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If defined, it overrides the
|
||||
/// <see cref="Rule.DataSource"/> property on the containing <see cref="Rule"/>. This field is mandatory only if the parent
|
||||
/// <see cref="Rule"/> does not have the data source initialized. The getter for this property returns
|
||||
/// only the <see cref="DataSource"/> set directly on this <see cref="BaseProperty"/> instance.
|
||||
/// </remarks>
|
||||
public DataSource DataSource
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Additional attributes of this <see cref="BaseProperty"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can be used as a grab bag of additional metadata of this property that are not
|
||||
/// captured by the primary fields. You will need a custom UI to interpret the additional
|
||||
/// metadata since the shipped UI formats can't obviously know about it.
|
||||
/// This field is optional.
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<NameValuePair> Metadata
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of arguments for this property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional.
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<Argument> Arguments
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of value editors for this property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional.
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<ValueEditor> ValueEditors
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Rule"/> property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>This represents schema information (name, allowed values, etc) of a <see cref="Rule"/> property.
|
||||
/// Since this is just schema information, there is no field like "Value" used to get/set the value of this
|
||||
/// property.</para>
|
||||
/// <para> Those who manually instantiate this class should remember to call <see cref="BeginInit"/> before
|
||||
/// setting the first property and <see cref="EndInit"/> after setting the last property of the object.</para>
|
||||
/// </remarks>
|
||||
/// <comment>
|
||||
/// This partial class contains members that are auto-generated, internal, etc. Whereas the
|
||||
/// other partial class contains public properties that can be set in XAML.
|
||||
/// </comment>
|
||||
public abstract partial class BaseProperty : ISupportInitialize
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Rule"/> containing this <see cref="BaseProperty"/>.
|
||||
/// </summary>
|
||||
public Rule ContainingRule
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region ISupportInitialize Members
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public virtual void BeginInit()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public virtual void EndInit()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents the schame of a boolean property. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the schame of a boolean property.
|
||||
/// </summary>
|
||||
public sealed class BoolProperty : BaseProperty
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Represents the logical negation of a boolean switch.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// <para>
|
||||
/// For the VC++ CL task, <c>WholeProgramOptimization</c> is a boolean parameter. It's switch is <c>GL</c>. To
|
||||
/// disable whole program optimization, you need to pass the ReverseSwitch, which is <c>GL-</c>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This field is optional.
|
||||
/// </para>
|
||||
/// </example>
|
||||
public string ReverseSwitch
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//--------------------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents a category to which a property can belong to. </summary>
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a category to which a <see cref="BaseProperty"/> can belong to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Those who manually
|
||||
/// instantiate this class should remember to call <see cref="BeginInit"/> before setting the first
|
||||
/// property and <see cref="EndInit"/> after setting the last property of the object.
|
||||
/// </remarks>
|
||||
/// <comment>
|
||||
/// This partial class contains all properties which are public and hence settable in XAML. Those properties that
|
||||
/// are internal are defined in another partial class below.
|
||||
/// </comment>
|
||||
public sealed partial class Category : CategorySchema, ISupportInitialize
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// See DisplayName property.
|
||||
/// </summary>
|
||||
private string _displayName;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The name of this <see cref="Category"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is mandatory and culture invariant.
|
||||
/// This field cannot be set to the empty string.
|
||||
/// </remarks>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name that could be used by a prospective UI client to display this <see cref="Category"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and is culture sensitive. When this property is not set, it is assigned the same
|
||||
/// value as the <see cref="Name"/> property (and hence, would not be localized).
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _displayName ?? Name;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_displayName = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Description of this <see cref="Category"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and is culture sensitive.
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string Description
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtype of this <see cref="Category"/>. Is either <c>Grid</c> (default) or <c>CommandLine</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It helps the UI display this category in an appropriate form. E.g. non command line category
|
||||
/// properties are normally displayed in the form of a property grid.
|
||||
/// </remarks>
|
||||
public string Subtype
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Help information for this <see cref="Category"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Maybe used to specify a help URL. This field
|
||||
/// is optional and is culture sensitive.
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string HelpString
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a category to which a <see cref="BaseProperty"/> can belong to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Those who manually
|
||||
/// instantiate this class should remember to call <see cref="BeginInit"/> before setting the first
|
||||
/// property and <see cref="EndInit"/> after setting the last property of the object.
|
||||
/// </remarks>
|
||||
/// <comment>
|
||||
/// This partial class contains members that are auto-generated, internal, etc. Whereas the
|
||||
/// other partial class contains public properties that can be set in XAML.
|
||||
/// </comment>
|
||||
public sealed partial class Category : CategorySchema, ISupportInitialize
|
||||
{
|
||||
// This partial class contains members that are auto-generated, internal, etc.
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor. Called during deserialization.
|
||||
/// </summary>
|
||||
public Category()
|
||||
{
|
||||
Subtype = "Grid";
|
||||
}
|
||||
|
||||
#endregion // Constructor
|
||||
|
||||
#region ISupportInitialize Members
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void BeginInit()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void EndInit()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary>Base type for categories in the property page schema data model.</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// The CategorySchema provides a strongly typed identity handle to the underlying schema data model.
|
||||
/// </summary>
|
||||
public abstract class CategorySchema
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> serialization class for Content type data. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to deserialize the content type information
|
||||
/// </summary>
|
||||
[ContentProperty("Metadata")]
|
||||
public sealed class ContentType : ISupportInitialize, IProjectSchemaNode
|
||||
{
|
||||
/// <summary>
|
||||
/// metadata hash
|
||||
/// </summary>
|
||||
private Lazy<Dictionary<string, string>> _metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public ContentType()
|
||||
{
|
||||
this.Metadata = new List<NameValuePair>();
|
||||
|
||||
// We must use ExecutionAndPublication thread safety here because the initializer is a destructive operation.
|
||||
_metadata = new Lazy<Dictionary<string, string>>(this.InitializeMetadata, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IContentType.Name
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IContentType.DisplayName
|
||||
/// </summary>
|
||||
[Localizable(true)]
|
||||
public string DisplayName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IContentType.ItemType
|
||||
/// </summary>
|
||||
public string ItemType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IContentType.DefaultContentTypeForItemType
|
||||
/// </summary>
|
||||
public bool DefaultContentTypeForItemType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This property was never used for anything. It should have been removed before we shipped MSBuild 4.0.
|
||||
/// </summary>
|
||||
[Obsolete("Unused. Use ItemType property instead.", true)]
|
||||
public string ItemGroupName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes content type's metadata. Accessable via IContentType.GetMetadata()
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<NameValuePair> Metadata
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Access metadata in convenient way
|
||||
/// </summary>
|
||||
public string GetMetadata(string metadataName)
|
||||
{
|
||||
if (String.IsNullOrEmpty(metadataName))
|
||||
{
|
||||
throw new ArgumentNullException("metadataName");
|
||||
}
|
||||
|
||||
string value;
|
||||
_metadata.Value.TryGetValue(metadataName, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
#region ISupportInitialize Members
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void BeginInit()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void EndInit()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IProjectSchemaNode Members
|
||||
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
public IEnumerable<Type> GetSchemaObjectTypes()
|
||||
{
|
||||
yield return typeof(ContentType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
public IEnumerable<object> GetSchemaObjects(Type type)
|
||||
{
|
||||
if (type == typeof(ContentType))
|
||||
{
|
||||
yield return this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Lazily initializes the metadata dictionary.
|
||||
/// </summary>
|
||||
/// <returns>The new dictionary.</returns>
|
||||
/// <remarks>
|
||||
/// This is a destructive operation. It clears the NameValuePair list field.
|
||||
/// </remarks>
|
||||
private Dictionary<string, string> InitializeMetadata()
|
||||
{
|
||||
var metadata = new Dictionary<string, string>(this.Metadata.Count, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (NameValuePair pair in this.Metadata)
|
||||
{
|
||||
metadata.Add(pair.Name, pair.Value);
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents the data source for a Rule property. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates where the default value for some property may be found.
|
||||
/// </summary>
|
||||
public enum DefaultValueSourceLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// The default value for a property is set at the top of the project file (usually via an import of a .props file).
|
||||
/// </summary>
|
||||
BeforeContext,
|
||||
|
||||
/// <summary>
|
||||
/// The default value for a property is set at the bottom of the project file (usually via an import of a .targets file,
|
||||
/// where the property definition is conditional on whether the property has not already been defined.)
|
||||
/// </summary>
|
||||
AfterContext,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the location and grouping for a <see cref="BaseProperty"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Those who manually
|
||||
/// instantiate this class should remember to call <see cref="BeginInit"/> before setting the first
|
||||
/// property and <see cref="EndInit"/> after setting the last property of the object.
|
||||
/// </remarks>
|
||||
public sealed class DataSource : ISupportInitialize
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor. Needed for proper XAML deserialization.
|
||||
/// </summary>
|
||||
public DataSource()
|
||||
{
|
||||
// Set the default value for this property.
|
||||
HasConfigurationCondition = true;
|
||||
Label = String.Empty;
|
||||
SourceOfDefaultValue = DefaultValueSourceLocation.BeforeContext;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The storage location for this data source.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is mandatory and is culture invariant. Current accepted values are <c>ProjectFile</c>
|
||||
/// and <c>UserFile</c>. <c>ProjectFile</c> causes the property value to be writted to and read from
|
||||
/// the project manifest file or the property sheet (depending on which node in the solution explorer/property manager
|
||||
/// window is used to spawn the property pages UI). <c>UserFile</c> causes the property value to be written to and
|
||||
/// read from the .user file.
|
||||
/// </remarks>
|
||||
public string Persistence
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the actual MSBuild property name used to read/write the value of this property.
|
||||
/// Applicable only to <see cref="DataSource"/> objects attached to properties.
|
||||
/// </summary>
|
||||
/// <value>The MSBuild property name to use; or <c>null</c> to use the <see cref="BaseProperty.Name"/> as the MSBuild property name.</value>
|
||||
/// <remarks>
|
||||
/// <para>The persisted name will usually be the same as the property name as it appears in the <see cref="Rule"/>
|
||||
/// and the value of this property can therefore be left at is default of <c>null</c>.
|
||||
/// Since property names must be unique but need not be unique in the persisted store (due to other differences
|
||||
/// in the data source such as item type) there may be times when Rule property names must be changed to be
|
||||
/// unique in the XAML file, but without changing how the property is persisted in the MSBuild file.
|
||||
/// It is in those cases where this property becomes useful.</para>
|
||||
/// <para>It may also be useful in specialized build environments where property names must differ from the
|
||||
/// normally used name in order to maintain compatibility with the project system.</para>
|
||||
/// </remarks>
|
||||
public string PersistedName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The label of the MSBuild property group/item definition group to which
|
||||
/// a property/item definition metadata belongs to. Default value is the
|
||||
/// empty string.
|
||||
/// </summary>
|
||||
/// <example> A VC++ property that exists in the project manifest
|
||||
/// in the MSBuild property group with label <c>Globals</c> would have this
|
||||
/// same value for this field. </example>
|
||||
public string Label
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If a <see cref="BaseProperty"/> is an item definition metadata or item metadata, this field
|
||||
/// specified the item type of the item definition or the item, respectively. For common properties
|
||||
/// this field must not be set.
|
||||
/// </summary>
|
||||
public string ItemType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if a property is configuration-dependent as indicated by the presence of a configuration
|
||||
/// condition attached to the property definition at its persistence location.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and has the default value of <c>true</c>.
|
||||
/// </remarks>
|
||||
public bool HasConfigurationCondition
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data type of the source. Generally one of <c>Item</c>, <c>ItemDefinition</c>, <c>Property</c>,
|
||||
/// or <c>TargetResults</c> (when <see cref="MSBuildTarget"/> is non-empty).
|
||||
/// Among other things this governs how the data is treated during build.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// A value of <c>Item</c> for this property indicates that this property is actually
|
||||
/// an item array - the list of all items with the item type specified by <see cref="ItemType"/>.
|
||||
/// </example>
|
||||
public string SourceType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the semicolon-delimited list of MSBuild targets that must be executed before reading
|
||||
/// the read-only properties or items described by this <see cref="DataSource"/>.
|
||||
/// </summary>
|
||||
public string MSBuildTarget
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating where the default value for this property can be found.
|
||||
/// </summary>
|
||||
public DefaultValueSourceLocation SourceOfDefaultValue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region ISupportInitialize Members
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void BeginInit()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void EndInit()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents the schema of a dynamic enumeration property. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the schema of an enumeration property.
|
||||
/// </summary>
|
||||
/// <remarks> This class inherits the <see cref="BaseProperty.Default"/> property from the <see cref="BaseProperty"/> class.
|
||||
/// That property does not make sense for this property. Use the <see cref="EnumValue.IsDefault"/> property on the
|
||||
/// <see cref="EnumValue"/> instead to mark the default value for this property. </remarks>
|
||||
public sealed class DynamicEnumProperty : BaseProperty
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public DynamicEnumProperty()
|
||||
{
|
||||
// Initialize collection properties in this class. This is required for
|
||||
// proper deserialization.
|
||||
ProviderSettings = new List<NameValuePair>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The provider that produces the list of possible values for this property. Must be set.
|
||||
/// </summary>
|
||||
public string EnumProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A provider-specific set of options to pass to the provider.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Concrete collection types required for XAML deserialization")]
|
||||
public List<NameValuePair> ProviderSettings { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents the schema of an enumeration property. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the schema of an enumeration property.
|
||||
/// </summary>
|
||||
/// <remarks> This class inherits the <see cref="BaseProperty.Default"/> property from the <see cref="BaseProperty"/> class.
|
||||
/// That property does not make sense for this property. Use the <see cref="EnumValue.IsDefault"/> property on the
|
||||
/// <see cref="EnumValue"/> instead to mark the default value for this property. </remarks>
|
||||
[ContentProperty("AdmissibleValues")]
|
||||
public sealed class EnumProperty : BaseProperty
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public EnumProperty()
|
||||
{
|
||||
AdmissibleValues = new List<EnumValue>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The list of possible values for this property. Must have at least one value.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<EnumValue> AdmissibleValues
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISupportInitialize Methods
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public override void EndInit()
|
||||
{
|
||||
base.EndInit();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents an admissible value of an EnumProperty. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an admissible value of an <see cref="EnumProperty"/>.
|
||||
/// </summary>
|
||||
[ContentProperty("Arguments")]
|
||||
public sealed class EnumValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// See DisplayName property.
|
||||
/// </summary>
|
||||
private string _displayName;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor needed for XAML deserialization.
|
||||
/// </summary>
|
||||
public EnumValue()
|
||||
{
|
||||
Arguments = new List<Argument>();
|
||||
Metadata = new List<NameValuePair>();
|
||||
|
||||
SwitchPrefix = String.Empty;
|
||||
}
|
||||
|
||||
#endregion // Constructor
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The name of this <see cref="EnumValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is mandatory and culture invariant.
|
||||
/// </remarks>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name that could be used by a prospective UI client to display this <see cref="EnumValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and is culture sensitive. When this property is not set, it is assigned the same
|
||||
/// value as the <see cref="Name"/> property (and hence, would not be localized).
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _displayName ?? Name;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_displayName = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Description of this <see cref="BaseProperty"/> for use by a prospective UI client.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and is culture sensitive.
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string Description
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Help information for this <see cref="EnumValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Maybe used to specify a help URL. This field
|
||||
/// is optional and is culture sensitive.
|
||||
/// </remarks>
|
||||
[Localizable(true)]
|
||||
public string HelpString
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The switch representation of this property for the case when the parent <see cref="EnumProperty"/> represents a tool parameter.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and culture invariant.
|
||||
/// </remarks>
|
||||
/// <example> The VC compiler has an <see cref="EnumProperty"/> named <c>Optimization</c>used to specify the desired optimization type. All the
|
||||
/// admissible values for this property have switches, e.g. <c>Disabled</c> (switch = <c>Od</c>), "MinimumSize" (switch = <c>O1</c>),
|
||||
/// etc. </example>
|
||||
public string Switch
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The prefix for the switch representation of this value for the case when the parent <see cref="EnumProperty"/> represents a tool parameter.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and culture invariant.
|
||||
/// </remarks>
|
||||
public string SwitchPrefix
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells if this <see cref="EnumValue"/> is the default value for the associated
|
||||
/// <see cref="EnumProperty"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional and the default value for this
|
||||
/// field is "false".
|
||||
/// </remarks>
|
||||
public bool IsDefault
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Additional attributes of this <see cref="EnumValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can be used as a grab bag of additional metadata of this value that are not
|
||||
/// captured by the primary fields. You will need a custom UI to interpret the additional
|
||||
/// metadata since the shipped UI formats can't obviously know about it.
|
||||
/// This field is optional.
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<NameValuePair> Metadata
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of arguments for this <see cref="EnumValue"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional.
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<Argument> Arguments
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> serialization class for FileExtension type data. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// simple class that deserialize extension to content type data
|
||||
/// </summary>
|
||||
public sealed class FileExtension : IProjectSchemaNode
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public FileExtension()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// file extension
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// coresponding content type
|
||||
/// </summary>
|
||||
public string ContentType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#region IProjectSchemaNode Members
|
||||
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
public IEnumerable<Type> GetSchemaObjectTypes()
|
||||
{
|
||||
yield return typeof(FileExtension);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
public IEnumerable<object> GetSchemaObjects(Type type)
|
||||
{
|
||||
if (type == typeof(FileExtension))
|
||||
{
|
||||
yield return this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> IProjectSchemaNode. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that we expect all root classes from project schema XAML files to implement
|
||||
/// </summary>
|
||||
public interface IProjectSchemaNode
|
||||
{
|
||||
/// <summary>
|
||||
/// Return all types of static data for data driven features this node contains
|
||||
/// </summary>
|
||||
IEnumerable<Type> GetSchemaObjectTypes();
|
||||
|
||||
/// <summary>
|
||||
/// Returns all instances of static data with Type "type". Null or Empty list if there is no objects from asked type provided by this node
|
||||
/// </summary>
|
||||
IEnumerable<object> GetSchemaObjects(Type type);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents the schema of an integer property. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represent the schema of an integer property.
|
||||
/// </summary>
|
||||
public sealed class IntProperty : BaseProperty
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Minimum allowed value for this property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional.
|
||||
/// It returns null when this property is not set. The value of this
|
||||
/// property must be less than or equal to the <see cref="MaxValue"/>
|
||||
/// property (assuming that the latter is defined).
|
||||
/// </remarks>
|
||||
public int? MinValue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximum allowed value for this property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field is optional.
|
||||
/// It returns null when this property is not set. The value of this
|
||||
/// property must be greater than or equal to the <see cref="MinValue"/>
|
||||
/// property (assuming that the latter is defined).
|
||||
/// </remarks>
|
||||
public int? MaxValue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISupportInitialize Methods
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public override void EndInit()
|
||||
{
|
||||
base.EndInit();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> serialization class for Content type data. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to deserialize the item type information
|
||||
/// </summary>
|
||||
public sealed class ItemType : ISupportInitialize, IProjectSchemaNode
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public ItemType()
|
||||
{
|
||||
// by default it is included in up-to-date check
|
||||
UpToDateCheckInput = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IItemType.Name
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IItemType.DisplayName
|
||||
/// </summary>
|
||||
[Localizable(true)]
|
||||
public string DisplayName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IItemType.ItemType
|
||||
/// </summary>
|
||||
public string DefaultContentType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serializes IItemType.UpToDateCheckInput
|
||||
/// </summary>
|
||||
public bool UpToDateCheckInput
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#region ISupportInitialize Members
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void BeginInit()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See ISupportInitialize.
|
||||
/// </summary>
|
||||
public void EndInit()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IProjectSchemaNode Members
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
public IEnumerable<Type> GetSchemaObjectTypes()
|
||||
{
|
||||
yield return typeof(ItemType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
public IEnumerable<object> GetSchemaObjects(Type type)
|
||||
{
|
||||
if (type == typeof(ItemType))
|
||||
{
|
||||
yield return this;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Represents a name-value pair. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a name-value pair. The name cannot be null or empty.
|
||||
/// </summary>
|
||||
public class NameValuePair
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor needed for
|
||||
/// </summary>
|
||||
public NameValuePair()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructor
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The name.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value.
|
||||
/// </summary>
|
||||
[Localizable(true)]
|
||||
public string Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//-----------------------------------------------------------------------
|
||||
// </copyright>
|
||||
// <summary> Universal Root node for the Data driven project schema XAML. </summary>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Microsoft.Build.Framework.XamlTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializatrion class for node for the Data driven project schema XAML
|
||||
/// </summary>
|
||||
[ContentProperty("Nodes")]
|
||||
public sealed class ProjectSchemaDefinitions : IProjectSchemaNode
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public ProjectSchemaDefinitions()
|
||||
{
|
||||
Nodes = new List<IProjectSchemaNode>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collection of any schema node
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This has shipped in Framework, which is especially important to keep binary compatible, so we can't change it now")]
|
||||
public List<IProjectSchemaNode> Nodes
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#region IProjectSchemaNode Members
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2301:EmbeddableTypesInContainersRule", MessageId = "allTypes", Justification = "All object types come from within this assembly, so there will not be any type equivalence problems")]
|
||||
public IEnumerable<Type> GetSchemaObjectTypes()
|
||||
{
|
||||
Dictionary<Type, bool> allTypes = new Dictionary<Type, bool>();
|
||||
foreach (IProjectSchemaNode node in Nodes)
|
||||
{
|
||||
foreach (Type t in node.GetSchemaObjectTypes())
|
||||
{
|
||||
allTypes[t] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return allTypes.Keys;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// see IProjectSchemaNode
|
||||
/// </summary>
|
||||
public IEnumerable<object> GetSchemaObjects(Type type)
|
||||
{
|
||||
foreach (IProjectSchemaNode node in Nodes)
|
||||
{
|
||||
foreach (object o in node.GetSchemaObjects(type))
|
||||
{
|
||||
yield return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче