Skip to content

Commit

Permalink
Merge pull request #1 from dotnet/master
Browse files Browse the repository at this point in the history
updating personal fork to latest commit
  • Loading branch information
mattscheffer committed Mar 9, 2015
2 parents 4f147f5 + 54f1dc5 commit 0d38e54
Show file tree
Hide file tree
Showing 2,291 changed files with 121,578 additions and 42,425 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome:
http://EditorConfig.org

# top-most EditorConfig file
root = true

# Default settings:
# Use 4 spaces as indentation
[*]
indent_style = space
indent_size = 4

# Xml project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# Xml config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
* text=auto encoding=UTF-8

###############################################################################
# Set default behavior for command prompt diff.
Expand All @@ -10,7 +10,8 @@
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
*.cs diff=csharp text
*.vb text

###############################################################################
# Set the merge driver for project and solution files
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ UnitTestResults.html
*.tmp
*.tmp_proj
*.log
*.wrn
*.vspscc
*.vssscc
.builds
Expand Down
48 changes: 16 additions & 32 deletions BuildAndTest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
use a 2013 compatible solution. -->
<PropertyGroup>
<RoslynSolution>$(MSBuildThisFileDirectory)\Src\Roslyn.sln</RoslynSolution>
<RoslynSolution Condition="$(CIBuild) == 'true'">$(MSBuildThisFileDirectory)\Src\Roslyn2013.sln</RoslynSolution>
<RoslynSolution Condition="'$(CIBuild)' == 'true'">$(MSBuildThisFileDirectory)\Src\RoslynLight.sln</RoslynSolution>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<RunTestArgs></RunTestArgs>
<RunTestArgs Condition="'$(Test64)' == 'true'">-test64</RunTestArgs>

<!-- Emit XML in a CIBuild in order to get structured test results -->
<RunTestArgs Condition="'$(CIBuild)' == 'true'">$(RunTestArgs) -xml</RunTestArgs>
</PropertyGroup>

<Target Name="RestorePackages">
Expand All @@ -22,7 +28,7 @@
<Target Name="Build" DependsOnTargets="RestorePackages">
<MSBuild BuildInParallel="true"
Projects="$(RoslynSolution)"
Properties="RestorePackages=false"
Properties="RestorePackages=false;TreatWarningsAsErrors=true"
Targets="Build"/>
</Target>

Expand All @@ -36,7 +42,7 @@
<Target Name="Rebuild">
<MSBuild BuildInParallel="true"
Projects="$(RoslynSolution)"
Properties="RestorePackages=false"
Properties="RestorePackages=false;TreatWarningsAsErrors=true"
Targets="Rebuild"/>
</Target>

Expand All @@ -45,40 +51,18 @@
<ItemGroup Condition="'$(CIBuild)' == ''">
<TestAssemblies
Include="Binaries\$(Configuration)\**\*.UnitTests*.dll"
Exclude="Binaries\Roslyn.Compilers.NativeClient.UnitTests.dll" />
Exclude="Binaries\$(Configuration)\Roslyn.Compilers.NativeClient.UnitTests.dll" />
</ItemGroup>

<!-- The Microsoft.CodeAnalysis.Scripting.UnitTests.dll is disabled due to https://github.com/dotnet/roslyn/issues/860 -->
<ItemGroup Condition="'$(CIBuild)' == 'true'">

<!--
These assemblies currently don't run correctly in Jenkins. Disabling while
we investigate the failures. This is being tracked by issue #79
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CompilerServer.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.NativeClient.UnitTests.dll" />
-->

<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.CommandLine.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Emit.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Semantic.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Syntax.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Symbol.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.VisualBasic.Emit.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.VisualBasic.Semantic.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.VisualBasic.Symbol.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.VisualBasic.Syntax.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.VisualBasic.CommandLine.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Diagnostics.Analyzers.FxCop.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Diagnostics.Analyzers.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Services.CSharp.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Services.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Services.VisualBasic.UnitTests.dll" />
<TestAssemblies
Include="Binaries\$(Configuration)\**\*.UnitTests*.dll"
Exclude="Binaries\$(Configuration)\Roslyn.Compilers.NativeClient.UnitTests.dll;Binaries\$(Configuration)\*ResultProvider*.UnitTests.dll;Binaries\$(Configuration)\Microsoft.CodeAnalysis.Scripting.UnitTests.dll" />
</ItemGroup>

<xunit
Assemblies="@(TestAssemblies)"
Html="UnitTestResults.html"
ShadowCopy="false" />
<Exec Command="Binaries\$(Configuration)\RunTests.exe packages\xunit.runners.2.0.0-alpha-build2576\tools $(RunTestArgs) @(TestAssemblies, ' ')" />

</Target>

<Target Name="BuildAndTest"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Welcome to the .NET Compiler Platform ("Roslyn")

[![Join the chat at https://gitter.im/dotnet/roslyn](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dotnet/roslyn?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](http://dotnet-ci.cloudapp.net/job/dotnet_roslyn/badge/icon)](http://dotnet-ci.cloudapp.net/job/dotnet_roslyn/)

The .NET Compiler Platform ("Roslyn") provides open-source C# and Visual Basic compilers
Expand Down
103 changes: 47 additions & 56 deletions build/VSL.Imports.Closed.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- ====================================================================================
Support for in-place modification of the compiled binary.
Since there may be more than one post compile modification, we must take care not
to break incremental builds. A timestemp file is written out when all modification
targets have completed.
Note that the targets participating in post compile modification must list the
sentinel file as one of their outputs, but they should not modify it.
==================================================================================== -->

<PropertyGroup>
<PostCompileBinaryModificationSentinelFile>$(IntermediateOutputPath)$(TargetFileName).pcbm</PostCompileBinaryModificationSentinelFile>
</PropertyGroup>

<Target Name="PostCompileBinaryModification"
AfterTargets="CoreCompile"
DependsOnTargets="ApplyOptimizations;FakeSign"
Inputs="@(IntermediateAssembly)"
Outputs="@(IntermediateAssembly);$(PostCompileBinaryModificationSentinelFile)">

<!-- Write out a sentinel timestamp file to prevent unnecessary work in incremental builds. -->
<Touch AlwaysCreate="true" Files="$(PostCompileBinaryModificationSentinelFile)" />

<ItemGroup>
<FileWrites Include="$(PostCompileBinaryModificationSentinelFile)" />
</ItemGroup>
</Target>

<!-- ====================================================================================
Support for rolling optimization data into assemblies.
Expand All @@ -13,90 +43,51 @@

<Target Name="ApplyOptimizations"
Condition="'$(Configuration)' == 'Release' AND '$(NonShipping)' != 'true' AND '$(SkipApplyOptimizations)' != 'true' AND Exists('$(OptimizationDataFile)')"
DependsOnTargets="CoreCompile"
Inputs="@(IntermediateAssembly)"
Outputs="@(IntermediateAssembly);@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).ibcmerge.timestamp')">
Outputs="@(IntermediateAssembly);$(PostCompileBinaryModificationSentinelFile)">

<Message Text="Adding optimization data to @(IntermediateAssembly)"/>
<Exec Command="&quot;$(IbcMergePath)&quot; -q -f -partialNGEN -minify -mo &quot;@(IntermediateAssembly)&quot; -incremental &quot;$(OptimizationDataFile)&quot;" />

<Message Text="Re-signing after merging optimization data" Condition="'$(DelaySign)' != 'true' AND '$(SignAssembly)' == 'true'" />
<Exec Command="&quot;$(SnToolPath)&quot; -q -R &quot;@(IntermediateAssembly)&quot; &quot;$(AssemblyOriginatorKeyFile)&quot;" Condition="'$(DelaySign)' != 'true' AND '$(SignAssembly)' == 'true'" />

<!-- Write out a sentinel timestamp file. Since the rewrite happens in-place, this extra output enables incremental build to work. -->
<Touch AlwaysCreate="true" Files="@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).ibcmerge.timestamp')" />

</Target>

<Target Name="CleanApplyOptimizations">
<Delete Files="@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).ibcmerge.timestamp')" />
</Target>

<Target Name="CreateAndSignPhoneCopy"
Condition="'$(NeedsPhoneCopy)' == 'true'"
DependsOnTargets="Compile"
BeforeTargets="SignVsixInputs"
Inputs="@(IntermediateAssembly)"
Outputs="$(OutDir)Phone\%(Filename)%(Extension)">
<Copy SourceFiles="@(IntermediateAssembly)"
DestinationFolder="$(OutDir)Phone" />

<ItemGroup Condition="'$(ShouldSignBuild)' == 'true'">
<PhoneAssembliesToSign Include="$(OutDir)Phone\%(IntermediateAssembly.Filename)%(IntermediateAssembly.Extension)">
<Authenticode>WindowsPhone623</Authenticode>
<StrongName>72</StrongName>
</PhoneAssembliesToSign>
</ItemGroup>

<Message Condition="'$(ShouldSignBuild)' == 'true'"
Text="Signing phone assemblies: using authenticode certificate '%(PhoneAssembliesToSign.Authenticode)' for @(PhoneAssembliesToSign)"/>

<SignFiles Condition="'$(ShouldSignBuild)' == 'true'"
Files="@(PhoneAssembliesToSign)"
IntermediatesDirectory="$(IntermediateOutputPath)"
BinariesDirectory="$(OutDir)Phone"
Type="$(SignType)" />
</Target>

<Target Name="CleanPhoneCopy">
<RemoveDir Directories="$(OutDir)Phone')" />

</Target>

<PropertyGroup>
<CompileDependsOn>$(CompileDependsOn);ApplyOptimizations</CompileDependsOn>
<CleanDependsOn>$(CleanDependsOn);CleanApplyOptimizations;CleanPhoneCopy</CleanDependsOn>
</PropertyGroup>

<!-- ====================================================================================
Support for signing files that are in VSIXes, and also signing the resulting package
Support for signing files that are in VSIXes.
==================================================================================== -->

<PropertyGroup>
<RunningInMicroBuild Condition="Exists('$(TF_BUILD_BUILDDIRECTORY)\MicroBuild\MicroBuild.Signing.dll')">true</RunningInMicroBuild>
<ShouldSignBuild Condition="'$(RealSignBuild)' == 'true' OR ('$(RunningInMicroBuild)' == 'true' AND '$(SignType)' == 'real')">true</ShouldSignBuild>
<CompileDependsOn>$(CompileDependsOn);FakeSignAssembly</CompileDependsOn>
<FakeSignSentinelFile>$(IntermediateOutputPath)$(TargetFileName).fakesign</FakeSignSentinelFile>
</PropertyGroup>

<Target Name="FakeSignAssembly"
<Target Name="FakeSign"
Condition="'$(DelaySign)' == 'true' AND '$(ShouldSignBuild)' != 'true' AND ('$(Language)' == 'C#' OR '$(Language)' == 'VB')"
DependsOnTargets="CoreCompile"
Inputs="$(IntermediateOutputPath)$(TargetFileName)"
Outputs="$(FakeSignSentinelFile)">
<Exec Command="$(VSLOutDir)\FakeSign.exe &quot;$(IntermediateOutputPath)$(TargetFileName)&quot;" />
<Touch Files="$(FakeSignSentinelFile)" AlwaysCreate="true" />
Inputs="@(IntermediateAssembly)"
Outputs="@(IntermediateAssembly);$(PostCompileBinaryModificationSentinelFile)">

<Exec Command="$(VSLOutDir)\FakeSign.exe &quot;@(IntermediateAssembly)&quot;" />

</Target>

<!-- ====================================================================================
Support for signing VSIXes
==================================================================================== -->

<UsingTask TaskName="SignFiles" AssemblyFile="$(TF_BUILD_BUILDDIRECTORY)\MicroBuild\MicroBuild.Signing.dll" Condition="'$(RunningInMicroBuild)' == 'true'" />

<PropertyGroup>
<CreateVsixContainerDependsOn>$(CreateVsixContainerDependsOn);SignVsixInputs</CreateVsixContainerDependsOn>
<PrepareForRunDependsOn>$(PrepareForRunDependsOn);SignVsix</PrepareForRunDependsOn>
<ProducingSignedVsix Condition="'$(ShouldSignBuild)' == 'true' AND '$(NonShipping)' != 'true' AND '$(CreateVsixContainer)' == 'true'">true</ProducingSignedVsix>
</PropertyGroup>

<!-- GetTargetPath returns the path under $(OutDir) for each project.
This target adds the $(AuthenticodeCertificateName) as metadata. -->
<Target Name="GetTargetPathWithAuthenticodeCertificateName" DependsOnTargets="GetTargetPath" Returns="@(TargetPathWithAuthenticodeCertificateName)">
Expand Down
2 changes: 1 addition & 1 deletion build/VSL.Settings.Closed.targets
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</BuildNumberPart2>

<NuGetReleaseVersion>$(RoslynSemanticVersion)</NuGetReleaseVersion>
<NuGetPreReleaseVersion>$(NuGetReleaseVersion)-rc1</NuGetPreReleaseVersion>
<NuGetPreReleaseVersion>$(NuGetReleaseVersion)-rc2</NuGetPreReleaseVersion>
<NuGetPerBuildPreReleaseVersion Condition="'$(BuildNumberSuffix)' != ''">$(NuGetPreReleaseVersion)-$(BuildNumberPart1.Trim())-$(BuildNumberPart2.Trim())</NuGetPerBuildPreReleaseVersion>
</PropertyGroup>

Expand Down
15 changes: 15 additions & 0 deletions cibuild.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
msbuild /v:m /m BuildAndTest.proj /p:CIBuild=true
if ERRORLEVEL 1 (
taskkill /F /IM vbcscompiler.exe
echo Build failed
exit /b 1
)

REM Kill any instances of VBCSCompiler.exe to release locked files;
REM otherwise future CI runs may fail while trying to delete those files.
taskkill /F /IM vbcscompiler.exe

REM It is okay and expected for taskkill to fail (it's a cleanup routine). Ensure
REM caller sees successful exit.
exit /b 0
6 changes: 6 additions & 0 deletions docs/compilers/CSharp/COM Interop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
COM interop
===========

[This is a placeholder. We need some more documentation here]

We have a number of features in the compiler/language to support COM interop, none of which is described in the language specification.
29 changes: 29 additions & 0 deletions docs/compilers/CSharp/Definite Assignment And Partials.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Definite Assignment For Partial And Conditional Methods
=======================================================

The C# language specification for definite assignment of an invocation expression [5.3.2.2] assumes incorrectly that the invocation expression and its arguments will be evaluated at runtime if it is reached. That may not be correct for *partial methods* [10.2.7] and methods marked with a *conditional attribute* [17.4.2].

The C# compiler correctly takes into account that the method invocation (and argument evaluation) may be omitted.

```cs
using System.Diagnostics;

 static partial class A
{
    static void Main()
    {
        int x;
        x.Foo(); // OK
        Bar(x); // OK
        Bar(x = 1);
        x.ToString(); // error CS0165: Use of unassigned local variable 'x'
    }

    static partial void Foo(this int y);

    [Conditional("xxxxxx")]
    static void Bar(int y) { }

}
```
41 changes: 41 additions & 0 deletions docs/compilers/CSharp/Definite Assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Definite Assignment
===================

The definite assignment rules for C# were reimplemented in Roslyn, and we discovered some shortcomings of the specification and native compiler, which we document here.

### Constant boolean expressions

There are two foundations definite assignment rules missing from the C# language specification, and from the implementation of definite assignment in the native compiler. Absence of these two rules causes a large number of cases of nonintuitive behavior of the compiler, and so the native compiler also includes a large number of ad-hoc rules to patch these examples.

The Roslyn compiler implements the C# language specification with two additional foundational rules. With these rules added, the ad-hoc rules implemented by the native compiler are no longer needed. The new rules are more precise than those implemented by the native compiler; for example, the Roslyn C# compiler accepts the following code, but the native compiler rejects it:

```cs
    static void Main(string[] args)
    {
        int x;
        if (false && x == 3)
        {
            x = x + 1; // Dev10 does not consider x definitely assigned
        }
    }
```

The new foundational rules are:

> #### 5.3.3.N Constant Expressions
For a constant expression with value true:
- If *v* is definitely assigned before the expression,
then *v* is definitely assigned after the expression.
- Otherwise *v* is “definitely assigned after false expression”
after the expression.

>For a constant expression with value false:
- If *v* is definitely assigned before the expression,
then *v* is definitely assigned after the expression.
- Otherwise *v* is “definitely assigned after true expression” after the expression.

>For all other constant expressions, the definite assignment state of *v* after the expression is the same as the definite assignment state of *v* before the expression.
### Control transfers and intervening finally blocks

The specification for definite assignment and reachability in the C# language specification do not properly take into account the possibility of "intervening" finally blocks between the origin of the control transfer and the destination. These finally blocks can assign to variables, this changing the definite assignment status, or change the control transfer behavior (e.g. by throwing an exception). Both the native compiler and the Roslyn C# compilers account for them in computing definite assignment and reachability of statements.
Loading

0 comments on commit 0d38e54

Please sign in to comment.