Remove Project Model Server
This commit is contained in:
parent
58fa0bf344
commit
5ed1371cd9
85 changed files with 0 additions and 4344 deletions
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"projects": ["src"]
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": "1.0.0",
|
||||
"EmptyLibrary": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {}
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Misc.DthTestProjects.EmptyConsoleApp
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, world.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": "1.0.0"
|
||||
}
|
||||
},
|
||||
"dnx451": {}
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Misc.DthTestProjects.EmptyLibrary
|
||||
{
|
||||
public class Class
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"dependencies": { },
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"dependencies":{
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Console": "4.0.0-beta-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netstandard1.3": {
|
||||
"imports": "dnxcore50",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.6.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Misc.DthTestProjects.SimpleConsoleApp
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, world.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": "dnxcore50",
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"Newtonsoft.Json": "8.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
namespace FailReleaseProject
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public int Main(string[] args)
|
||||
{
|
||||
#if RELEASE
|
||||
// fail the compilation under Release configuration
|
||||
i
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": "dnxcore50",
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": "1.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": "1.0.0",
|
||||
"Microsoft.Web.Administration": "7.0.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {}
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"NoSuchPackage": "1.0.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { }
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"EmptyLibrary": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { }
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"version": "9.0.1",
|
||||
"dependencies": {
|
||||
},
|
||||
"frameworks": {
|
||||
"netstandard1.5": { }
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"projects": [
|
||||
"src",
|
||||
"../ext"
|
||||
]
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "9.0.1"
|
||||
},
|
||||
"frameworks": {
|
||||
"netstandard1.5": {}
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"projects": ["src"]]
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||
<clear />
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": "1.0.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"
|
||||
},
|
||||
"frameworks": {
|
||||
[]
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
# Negates the lock file
|
||||
# MSBuiild references' project model server tests requires these lock files, since they can't be created without VS tooling.
|
||||
!project.lock.json
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClassLibrary1
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{FD073258-550B-4E57-86AE-DC4874015EB1}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ClassLibrary1</RootNamespace>
|
||||
<AssemblyName>ClassLibrary1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -1,36 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ClassLibrary1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ClassLibrary1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("fd073258-550b-4e57-86ae-dc4874015eb1")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
|
||||
</packages>
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClassLibrary2
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>0f2d2a48-e867-496c-85a7-e97b64cfeda4</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ClassLibrary2</RootNamespace>
|
||||
<AssemblyName>ClassLibrary2</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System"/>
|
||||
|
||||
<Reference Include="System.Core"/>
|
||||
<Reference Include="System.Xml.Linq"/>
|
||||
<Reference Include="System.Data.DataSetExtensions"/>
|
||||
|
||||
|
||||
<Reference Include="Microsoft.CSharp"/>
|
||||
|
||||
<Reference Include="System.Data"/>
|
||||
|
||||
<Reference Include="System.Net.Http"/>
|
||||
|
||||
<Reference Include="System.Xml"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
|
@ -1,36 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ClassLibrary2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ClassLibrary2")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0f2d2a48-e867-496c-85a7-e97b64cfeda4")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClassLibrary3
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>428e95cb-8435-414b-a313-9d734c633b3e</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ClassLibrary3</RootNamespace>
|
||||
<AssemblyName>ClassLibrary3</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System"/>
|
||||
|
||||
<Reference Include="System.Core"/>
|
||||
<Reference Include="System.Xml.Linq"/>
|
||||
<Reference Include="System.Data.DataSetExtensions"/>
|
||||
|
||||
|
||||
<Reference Include="Microsoft.CSharp"/>
|
||||
|
||||
<Reference Include="System.Data"/>
|
||||
|
||||
<Reference Include="System.Net.Http"/>
|
||||
|
||||
<Reference Include="System.Xml"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
|
@ -1,36 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ClassLibrary3")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ClassLibrary3")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("428e95cb-8435-414b-a313-9d734c633b3e")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -1,53 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25029.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1443ACE0-3065-4C20-AD59-D561798AE0A5}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0AE82780-22C8-4DC8-8F1E-86977FDD092F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
global.json = global.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ConsoleApp13", "src\ConsoleApp13\ConsoleApp13.xproj", "{767D3038-AC3A-4722-B21F-F85F2CBC3AA3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{FD073258-550B-4E57-86AE-DC4874015EB1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary2", "ClassLibrary2\ClassLibrary2.csproj", "{0F2D2A48-E867-496C-85A7-E97B64CFEDA4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary3", "ClassLibrary3\ClassLibrary3.csproj", "{428E95CB-8435-414B-A313-9D734C633B3E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{767D3038-AC3A-4722-B21F-F85F2CBC3AA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{767D3038-AC3A-4722-B21F-F85F2CBC3AA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{767D3038-AC3A-4722-B21F-F85F2CBC3AA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{767D3038-AC3A-4722-B21F-F85F2CBC3AA3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FD073258-550B-4E57-86AE-DC4874015EB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FD073258-550B-4E57-86AE-DC4874015EB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FD073258-550B-4E57-86AE-DC4874015EB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FD073258-550B-4E57-86AE-DC4874015EB1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0F2D2A48-E867-496C-85A7-E97B64CFEDA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0F2D2A48-E867-496C-85A7-E97B64CFEDA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0F2D2A48-E867-496C-85A7-E97B64CFEDA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0F2D2A48-E867-496C-85A7-E97B64CFEDA4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{428E95CB-8435-414B-A313-9D734C633B3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{428E95CB-8435-414B-A313-9D734C633B3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{428E95CB-8435-414B-A313-9D734C633B3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{428E95CB-8435-414B-A313-9D734C633B3E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{767D3038-AC3A-4722-B21F-F85F2CBC3AA3} = {1443ACE0-3065-4C20-AD59-D561798AE0A5}
|
||||
{FD073258-550B-4E57-86AE-DC4874015EB1} = {1443ACE0-3065-4C20-AD59-D561798AE0A5}
|
||||
{0F2D2A48-E867-496C-85A7-E97B64CFEDA4} = {1443ACE0-3065-4C20-AD59-D561798AE0A5}
|
||||
{428E95CB-8435-414B-A313-9D734C633B3E} = {1443ACE0-3065-4C20-AD59-D561798AE0A5}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"projects": [ "src", "test" ]
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>767d3038-ac3a-4722-b21f-f85f2cbc3aa3</ProjectGuid>
|
||||
<RootNamespace>ConsoleApp13</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ClassLibrary1\ClassLibrary1.csproj" />
|
||||
<ProjectReference Include="..\..\ClassLibrary2\ClassLibrary2.csproj" />
|
||||
<ProjectReference Include="..\..\ClassLibrary3\ClassLibrary3.csproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConsoleApp13
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var q = new ClassLibrary1.Class1();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ConsoleApp13")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("767d3038-ac3a-4722-b21f-f85f2cbc3aa3")]
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"version": 2,
|
||||
"exports": {
|
||||
"ClassLibrary1/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETFramework,Version=v4.5.2",
|
||||
"compile": {
|
||||
"bin/Debug/ClassLibrary1.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"../packages/Newtonsoft.Json.8.0.3/lib/net45/Newtonsoft.Json.dll": {},
|
||||
"bin/Debug/ClassLibrary1.dll": {}
|
||||
}
|
||||
},
|
||||
"ClassLibrary2/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETFramework,Version=v4.6",
|
||||
"compile": {
|
||||
"bin/Debug/ClassLibrary2.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/Debug/ClassLibrary2.dll": {}
|
||||
}
|
||||
},
|
||||
"ClassLibrary3/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETFramework,Version=v4.6",
|
||||
"compile": {
|
||||
"bin/Debug/ClassLibrary3.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/Debug/ClassLibrary3.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"frameworks": {
|
||||
"net46": {
|
||||
"dependencies": {
|
||||
"ClassLibrary1": {
|
||||
"target": "project"
|
||||
},
|
||||
"ClassLibrary2": {
|
||||
"target": "project"
|
||||
},
|
||||
"ClassLibrary3": {
|
||||
"target": "project"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
{
|
||||
"locked": false,
|
||||
"version": 2,
|
||||
"targets": {
|
||||
".NETFramework,Version=v4.6": {
|
||||
"ClassLibrary1/1.0.0": {
|
||||
"type": "project"
|
||||
},
|
||||
"ClassLibrary2/1.0.0": {
|
||||
"type": "project"
|
||||
},
|
||||
"ClassLibrary3/1.0.0": {
|
||||
"type": "project"
|
||||
}
|
||||
},
|
||||
".NETFramework,Version=v4.6/win7-x64": {
|
||||
"ClassLibrary1/1.0.0": {
|
||||
"type": "project"
|
||||
},
|
||||
"ClassLibrary2/1.0.0": {
|
||||
"type": "project"
|
||||
},
|
||||
"ClassLibrary3/1.0.0": {
|
||||
"type": "project"
|
||||
}
|
||||
},
|
||||
".NETFramework,Version=v4.6/win7-x86": {
|
||||
"ClassLibrary1/1.0.0": {
|
||||
"type": "project"
|
||||
},
|
||||
"ClassLibrary2/1.0.0": {
|
||||
"type": "project"
|
||||
},
|
||||
"ClassLibrary3/1.0.0": {
|
||||
"type": "project"
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"ClassLibrary1/1.0.0": {
|
||||
"type": "project",
|
||||
"msbuildProject": "../../ClassLibrary1/ClassLibrary1.csproj"
|
||||
},
|
||||
"ClassLibrary2/1.0.0": {
|
||||
"type": "project",
|
||||
"msbuildProject": "../../ClassLibrary2/ClassLibrary2.csproj"
|
||||
},
|
||||
"ClassLibrary3/1.0.0": {
|
||||
"type": "project",
|
||||
"msbuildProject": "../../ClassLibrary3/ClassLibrary3.csproj"
|
||||
}
|
||||
},
|
||||
"projectFileDependencyGroups": {
|
||||
"": [],
|
||||
".NETFramework,Version=v4.6": [
|
||||
"ClassLibrary1",
|
||||
"ClassLibrary2",
|
||||
"ClassLibrary3"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
},
|
||||
"frameworks": {
|
||||
"net45": {
|
||||
"frameworkAssemblies": {
|
||||
"mscorlib": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,8 +30,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
// "dotnet-compile-fsc.Tests",
|
||||
"dotnet-new.Tests",
|
||||
"dotnet-pack.Tests",
|
||||
// TODO: https://github.com/dotnet/cli/issues/3734
|
||||
//"dotnet-projectmodel-server.Tests",
|
||||
"dotnet-publish.Tests",
|
||||
"dotnet-resgen.Tests",
|
||||
"dotnet-run.Tests",
|
||||
|
@ -137,19 +135,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
// The 'ProjectModelServer' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output
|
||||
dotnet.Restore(
|
||||
"--verbosity", "verbose",
|
||||
"--infer-runtimes")
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthTestProjects"))
|
||||
.Execute();
|
||||
|
||||
dotnet.Restore(
|
||||
"--verbosity", "verbose",
|
||||
"--infer-runtimes")
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthUpdateSearchPathSample"))
|
||||
.Execute();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ using System.Text;
|
|||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Configurer;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.DotNet.ProjectModel.Server;
|
||||
using Microsoft.DotNet.Tools.Build;
|
||||
using Microsoft.DotNet.Tools.Compiler;
|
||||
using Microsoft.DotNet.Tools.Compiler.Csc;
|
||||
|
@ -33,7 +32,6 @@ namespace Microsoft.DotNet.Cli
|
|||
["help"] = HelpCommand.Run,
|
||||
["new"] = NewCommand.Run,
|
||||
["pack"] = PackCommand.Run,
|
||||
["projectmodel-server"] = ProjectModelServerCommand.Run,
|
||||
["publish"] = PublishCommand.Run,
|
||||
["restore"] = RestoreCommand.Run,
|
||||
["run"] = RunCommand.Run,
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
internal class ConnectionContext
|
||||
{
|
||||
private readonly string _hostName;
|
||||
private readonly ProcessingQueue _queue;
|
||||
private readonly IDictionary<int, ProjectManager> _projects;
|
||||
|
||||
public ConnectionContext(Socket acceptedSocket,
|
||||
string hostName,
|
||||
ProtocolManager protocolManager,
|
||||
DesignTimeWorkspace workspaceContext,
|
||||
IDictionary<int, ProjectManager> projects)
|
||||
{
|
||||
_hostName = hostName;
|
||||
_projects = projects;
|
||||
|
||||
_queue = new ProcessingQueue(new NetworkStream(acceptedSocket));
|
||||
_queue.OnReceive += message =>
|
||||
{
|
||||
if (protocolManager.IsProtocolNegotiation(message))
|
||||
{
|
||||
message.Sender = this;
|
||||
protocolManager.Negotiate(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message.Sender = this;
|
||||
ProjectManager projectManager;
|
||||
if (!_projects.TryGetValue(message.ContextId, out projectManager))
|
||||
{
|
||||
projectManager = new ProjectManager(message.ContextId,
|
||||
workspaceContext,
|
||||
protocolManager);
|
||||
|
||||
_projects[message.ContextId] = projectManager;
|
||||
}
|
||||
|
||||
projectManager.OnReceive(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void QueueStart()
|
||||
{
|
||||
_queue.Start();
|
||||
}
|
||||
|
||||
public bool Transmit(Message message)
|
||||
{
|
||||
message.HostId = _hostName;
|
||||
return _queue.Send(message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Helpers
|
||||
{
|
||||
internal class DependencyTypeChangeFinder
|
||||
{
|
||||
public static IEnumerable<DiagnosticMessage> Diagnose(
|
||||
ProjectContext context,
|
||||
IEnumerable<string> previousSearchPaths)
|
||||
{
|
||||
var result = new List<DiagnosticMessage>();
|
||||
var project = context.ProjectFile;
|
||||
var libraries = context.LibraryManager.GetLibraries();
|
||||
|
||||
var updatedSearchPath = GetUpdatedSearchPaths(previousSearchPaths, project.ResolveSearchPaths());
|
||||
var projectCandiates = GetProjectCandidates(updatedSearchPath);
|
||||
var rootDependencies = libraries.FirstOrDefault(library => string.Equals(library.Identity.Name, project.Name))
|
||||
?.Dependencies
|
||||
?.ToDictionary(libraryRange => libraryRange.Name);
|
||||
|
||||
foreach (var library in libraries)
|
||||
{
|
||||
var diagnostic = Validate(library, projectCandiates, rootDependencies);
|
||||
if (diagnostic != null)
|
||||
{
|
||||
result.Add(diagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static DiagnosticMessage Validate(LibraryDescription library,
|
||||
HashSet<string> projectCandidates,
|
||||
Dictionary<string, LibraryRange> rootDependencies)
|
||||
{
|
||||
if (!library.Resolved || projectCandidates == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var foundCandidate = projectCandidates.Contains(library.Identity.Name);
|
||||
|
||||
if ((library.Identity.Type == LibraryType.Project && !foundCandidate) ||
|
||||
(library.Identity.Type == LibraryType.Package && foundCandidate))
|
||||
{
|
||||
library.Resolved = false;
|
||||
|
||||
var libraryRange = rootDependencies[library.Identity.Name];
|
||||
|
||||
return new DiagnosticMessage(
|
||||
ErrorCodes.NU1010,
|
||||
$"The type of dependency {library.Identity.Name} was changed.",
|
||||
libraryRange.SourceFilePath,
|
||||
DiagnosticMessageSeverity.Error,
|
||||
libraryRange.SourceLine,
|
||||
libraryRange.SourceColumn,
|
||||
library);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static HashSet<string> GetProjectCandidates(IEnumerable<string> searchPaths)
|
||||
{
|
||||
if (searchPaths == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new HashSet<string>(searchPaths.Where(path => Directory.Exists(path))
|
||||
.SelectMany(path => Directory.GetDirectories(path))
|
||||
.Where(path => File.Exists(Path.Combine(path, Project.FileName)))
|
||||
.Select(path => Path.GetFileName(path)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the search paths if they're updated. Otherwise returns null.
|
||||
/// </summary>
|
||||
private static IEnumerable<string> GetUpdatedSearchPaths(IEnumerable<string> oldSearchPaths,
|
||||
IEnumerable<string> newSearchPaths)
|
||||
{
|
||||
// The oldSearchPaths is null when the current project is not initialized. It is not necessary to
|
||||
// validate the dependency in this case.
|
||||
if (oldSearchPaths == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Enumerable.SequenceEqual(oldSearchPaths, newSearchPaths))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return newSearchPaths;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Helpers
|
||||
{
|
||||
public static class JTokenExtensions
|
||||
{
|
||||
public static string GetValue(this JToken token, string name)
|
||||
{
|
||||
return GetValue<string>(token, name);
|
||||
}
|
||||
|
||||
public static TVal GetValue<TVal>(this JToken token, string name)
|
||||
{
|
||||
var value = token?[name];
|
||||
if (value != null)
|
||||
{
|
||||
return value.Value<TVal>();
|
||||
}
|
||||
|
||||
return default(TVal);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Helpers
|
||||
{
|
||||
public static class LibraryExtensions
|
||||
{
|
||||
public static string GetUniqueName(this LibraryDescription library)
|
||||
{
|
||||
var identity = library.Identity;
|
||||
return identity.Type != LibraryType.ReferenceAssembly ? identity.Name : $"fx/{identity.Name}";
|
||||
}
|
||||
|
||||
public static string GetUniqueName(this LibraryRange range)
|
||||
{
|
||||
return range.Target != LibraryType.ReferenceAssembly ? range.Name : $"fx/{range.Name}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.DotNet.ProjectModel.Resolution;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public static class NuGetFrameworkExtensions
|
||||
{
|
||||
public static FrameworkData ToPayload(this NuGetFramework framework)
|
||||
{
|
||||
return new FrameworkData
|
||||
{
|
||||
ShortName = framework.GetShortFolderName(),
|
||||
FrameworkName = framework.DotNetFrameworkName,
|
||||
FriendlyName = FrameworkReferenceResolver.Default.GetFriendlyFrameworkName(framework),
|
||||
RedistListPath = FrameworkReferenceResolver.Default.GetFrameworkRedistListPath(framework)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.IO;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Helpers
|
||||
{
|
||||
public static class ProjectExtensions
|
||||
{
|
||||
public static IEnumerable<string> ResolveSearchPaths(this Project project)
|
||||
{
|
||||
GlobalSettings settings;
|
||||
return project.ResolveSearchPaths(out settings);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> ResolveSearchPaths(this Project project, out GlobalSettings globalSettings)
|
||||
{
|
||||
if (project == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(project));
|
||||
}
|
||||
|
||||
var searchPaths = new HashSet<string> { Directory.GetParent(project.ProjectDirectory).FullName };
|
||||
|
||||
globalSettings = project.ResolveGlobalSettings();
|
||||
if (globalSettings != null)
|
||||
{
|
||||
foreach (var searchPath in globalSettings.ProjectSearchPaths)
|
||||
{
|
||||
var path = Path.Combine(globalSettings.DirectoryPath, searchPath);
|
||||
searchPaths.Add(Path.GetFullPath(path));
|
||||
}
|
||||
}
|
||||
|
||||
return searchPaths;
|
||||
}
|
||||
|
||||
public static GlobalSettings ResolveGlobalSettings(this Project project)
|
||||
{
|
||||
if (project == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(project));
|
||||
}
|
||||
|
||||
GlobalSettings settings;
|
||||
var root = ProjectRootResolver.ResolveRootDirectory(project.ProjectDirectory);
|
||||
if (GlobalSettings.TryGetGlobalSettings(root, out settings))
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using Microsoft.DotNet.Cli.Compiler.Common;
|
||||
using Microsoft.DotNet.ProjectModel.Files;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Helpers;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
internal class ProjectContextSnapshot
|
||||
{
|
||||
public string RootDependency { get; set; }
|
||||
public NuGetFramework TargetFramework { get; set; }
|
||||
public IReadOnlyList<string> SourceFiles { get; set; }
|
||||
public CommonCompilerOptions CompilerOptions { get; set; }
|
||||
public IReadOnlyList<ProjectReferenceDescription> ProjectReferences { get; set; }
|
||||
public IReadOnlyList<string> FileReferences { get; set; }
|
||||
public IReadOnlyList<DiagnosticMessage> DependencyDiagnostics { get; set; }
|
||||
public IDictionary<string, DependencyDescription> Dependencies { get; set; }
|
||||
|
||||
public static ProjectContextSnapshot Create(ProjectContext context, string configuration, IEnumerable<string> previousSearchPaths)
|
||||
{
|
||||
var snapshot = new ProjectContextSnapshot();
|
||||
|
||||
var allDependencyDiagnostics = new List<DiagnosticMessage>();
|
||||
allDependencyDiagnostics.AddRange(context.LibraryManager.GetAllDiagnostics());
|
||||
allDependencyDiagnostics.AddRange(DependencyTypeChangeFinder.Diagnose(context, previousSearchPaths));
|
||||
|
||||
var diagnosticsLookup = allDependencyDiagnostics.ToLookup(d => d.Source);
|
||||
|
||||
var allExports = context.CreateExporter(configuration)
|
||||
.GetAllExports()
|
||||
.ToDictionary(export => export.Library.Identity.Name);
|
||||
|
||||
var allSourceFiles = new List<string>(GetSourceFiles(context, configuration));
|
||||
var allFileReferences = new List<string>();
|
||||
var allProjectReferences = new List<ProjectReferenceDescription>();
|
||||
var allDependencies = new Dictionary<string, DependencyDescription>();
|
||||
|
||||
// All exports are returned. When the same library name have a ReferenceAssembly type export and a Package type export
|
||||
// both will be listed as dependencies. Prefix "fx/" will be added to ReferenceAssembly type dependency.
|
||||
foreach (var export in allExports.Values)
|
||||
{
|
||||
allSourceFiles.AddRange(export.SourceReferences.Select(f => f.ResolvedPath));
|
||||
var diagnostics = diagnosticsLookup[export.Library].ToList();
|
||||
var description = DependencyDescription.Create(export.Library, diagnostics, allExports);
|
||||
allDependencies[description.Name] = description;
|
||||
|
||||
var projectReferene = ProjectReferenceDescription.Create(export.Library);
|
||||
if (projectReferene != null && export.Library.Identity.Name != context.ProjectFile.Name)
|
||||
{
|
||||
allProjectReferences.Add(projectReferene);
|
||||
}
|
||||
|
||||
if (export.Library.Identity.Type != LibraryType.Project)
|
||||
{
|
||||
allFileReferences.AddRange(export.CompilationAssemblies.Select(asset => asset.ResolvedPath));
|
||||
}
|
||||
}
|
||||
|
||||
snapshot.RootDependency = context.ProjectFile.Name;
|
||||
snapshot.TargetFramework = context.TargetFramework;
|
||||
snapshot.SourceFiles = allSourceFiles.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList();
|
||||
snapshot.CompilerOptions = context.GetLanguageSpecificCompilerOptions(context.TargetFramework, configuration);
|
||||
snapshot.ProjectReferences = allProjectReferences.OrderBy(reference => reference.Name).ToList();
|
||||
snapshot.FileReferences = allFileReferences.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList();
|
||||
snapshot.DependencyDiagnostics = allDependencyDiagnostics;
|
||||
snapshot.Dependencies = allDependencies;
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetSourceFiles(ProjectContext context, string configuration)
|
||||
{
|
||||
var compilerOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration);
|
||||
|
||||
if (compilerOptions.CompileInclude == null)
|
||||
{
|
||||
return context.ProjectFile.Files.SourceFiles;
|
||||
}
|
||||
|
||||
var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null);
|
||||
|
||||
return includeFiles.Select(f => f.SourcePath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Helpers;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
internal class ProjectSnapshot
|
||||
{
|
||||
public Project Project { get; set; }
|
||||
public string GlobalJsonPath { get; set; }
|
||||
public IReadOnlyList<string> ProjectSearchPaths { get; set; }
|
||||
public IReadOnlyList<DiagnosticMessage> ProjectDiagnostics { get; set; }
|
||||
public ErrorMessage GlobalErrorMessage { get; set; }
|
||||
public Dictionary<NuGetFramework, ProjectContextSnapshot> ProjectContexts { get; } = new Dictionary<NuGetFramework, ProjectContextSnapshot>();
|
||||
|
||||
public static ProjectSnapshot Create(string projectDirectory,
|
||||
string configuration,
|
||||
DesignTimeWorkspace workspaceContext,
|
||||
IReadOnlyList<string> previousSearchPaths,
|
||||
bool clearWorkspaceContextCache)
|
||||
{
|
||||
var projectContextsCollection = workspaceContext.GetProjectContextCollection(projectDirectory, clearWorkspaceContextCache);
|
||||
if (!projectContextsCollection.ProjectContexts.Any())
|
||||
{
|
||||
throw new InvalidOperationException($"Unable to find project.json in '{projectDirectory}'");
|
||||
}
|
||||
GlobalSettings globalSettings;
|
||||
var currentSearchPaths = projectContextsCollection.Project.ResolveSearchPaths(out globalSettings);
|
||||
|
||||
var snapshot = new ProjectSnapshot();
|
||||
snapshot.Project = projectContextsCollection.Project;
|
||||
snapshot.ProjectDiagnostics = new List<DiagnosticMessage>(projectContextsCollection.ProjectDiagnostics);
|
||||
snapshot.ProjectSearchPaths = currentSearchPaths.ToList();
|
||||
snapshot.GlobalJsonPath = globalSettings?.FilePath;
|
||||
|
||||
foreach (var projectContext in projectContextsCollection.FrameworkOnlyContexts)
|
||||
{
|
||||
snapshot.ProjectContexts[projectContext.TargetFramework] =
|
||||
ProjectContextSnapshot.Create(projectContext, configuration, previousSearchPaths);
|
||||
}
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
public class MessageTypes
|
||||
{
|
||||
// Incoming
|
||||
public const string Initialize = nameof(Initialize);
|
||||
public const string ChangeConfiguration = nameof(ChangeConfiguration);
|
||||
public const string RefreshDependencies = nameof(RefreshDependencies);
|
||||
public const string RestoreComplete = nameof(RestoreComplete);
|
||||
public const string FilesChanged = nameof(FilesChanged);
|
||||
public const string GetDiagnostics = nameof(GetDiagnostics);
|
||||
public const string ProtocolVersion = nameof(ProtocolVersion);
|
||||
|
||||
// Outgoing
|
||||
public const string Error = nameof(Error);
|
||||
public const string ProjectInformation = nameof(ProjectInformation);
|
||||
public const string Diagnostics = nameof(Diagnostics);
|
||||
public const string DependencyDiagnostics = nameof(DependencyDiagnostics);
|
||||
public const string Dependencies = nameof(Dependencies);
|
||||
public const string CompilerOptions = nameof(CompilerOptions);
|
||||
public const string References = nameof(References);
|
||||
public const string Sources = nameof(Sources);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class CompilerOptionsMessenger : Messenger<ProjectContextSnapshot>
|
||||
{
|
||||
public CompilerOptionsMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.CompilerOptions, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
return remote.CompilerOptions != null &&
|
||||
Equals(local.CompilerOptions, remote.CompilerOptions);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectContextSnapshot local, Action<object> send)
|
||||
{
|
||||
send(new CompilationOptionsMessage
|
||||
{
|
||||
Framework = local.TargetFramework.ToPayload(),
|
||||
Options = local.CompilerOptions
|
||||
});
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
remote.CompilerOptions = local.CompilerOptions;
|
||||
}
|
||||
|
||||
private class CompilationOptionsMessage
|
||||
{
|
||||
public FrameworkData Framework { get; set; }
|
||||
|
||||
public CommonCompilerOptions Options { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class DependenciesMessenger : Messenger<ProjectContextSnapshot>
|
||||
{
|
||||
public DependenciesMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.Dependencies, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
return remote.Dependencies != null &&
|
||||
string.Equals(local.RootDependency, remote.RootDependency) &&
|
||||
Equals(local.TargetFramework, remote.TargetFramework) &&
|
||||
Enumerable.SequenceEqual(local.Dependencies, remote.Dependencies);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectContextSnapshot local, Action<object> send)
|
||||
{
|
||||
send(new DependenciesMessage
|
||||
{
|
||||
Framework = local.TargetFramework.ToPayload(),
|
||||
RootDependency = local.RootDependency,
|
||||
Dependencies = local.Dependencies
|
||||
});
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
remote.Dependencies = local.Dependencies;
|
||||
}
|
||||
|
||||
private class DependenciesMessage
|
||||
{
|
||||
public FrameworkData Framework { get; set; }
|
||||
public string RootDependency { get; set; }
|
||||
public IDictionary<string, DependencyDescription> Dependencies { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class DependencyDiagnosticsMessenger : Messenger<ProjectContextSnapshot>
|
||||
{
|
||||
public DependencyDiagnosticsMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.DependencyDiagnostics, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
return remote.DependencyDiagnostics != null &&
|
||||
Enumerable.SequenceEqual(local.DependencyDiagnostics, remote.DependencyDiagnostics);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectContextSnapshot local, Action<object> send)
|
||||
{
|
||||
send(new DiagnosticsListMessage(
|
||||
local.DependencyDiagnostics,
|
||||
local.TargetFramework?.ToPayload()));
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
remote.DependencyDiagnostics = local.DependencyDiagnostics;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class GlobalErrorMessenger : Messenger<ProjectSnapshot>
|
||||
{
|
||||
public GlobalErrorMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.Error, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectSnapshot local, ProjectSnapshot remote)
|
||||
{
|
||||
return remote != null && Equals(local.GlobalErrorMessage, remote.GlobalErrorMessage);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectSnapshot local, Action<object> send)
|
||||
{
|
||||
if (local.GlobalErrorMessage != null)
|
||||
{
|
||||
send(local.GlobalErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
send(new ErrorMessage
|
||||
{
|
||||
Message = null,
|
||||
Path = null,
|
||||
Line = -1,
|
||||
Column = -1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote)
|
||||
{
|
||||
remote.GlobalErrorMessage = local.GlobalErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal abstract class Messenger<T> where T : class
|
||||
{
|
||||
protected readonly Action<string, object> _transmit;
|
||||
|
||||
public Messenger(string messageType, Action<string, object> transmit)
|
||||
{
|
||||
_transmit = transmit;
|
||||
|
||||
MessageType = messageType;
|
||||
}
|
||||
|
||||
public string MessageType { get; }
|
||||
|
||||
public void UpdateRemote(T local, T remote)
|
||||
{
|
||||
if (!CheckDifference(local, remote))
|
||||
{
|
||||
SendPayload(local, payload => _transmit(MessageType, payload));
|
||||
SetValue(local, remote);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void SetValue(T local, T remote);
|
||||
protected abstract void SendPayload(T local, Action<object> send);
|
||||
protected abstract bool CheckDifference(T local, T remote);
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class ProjectDiagnosticsMessenger : Messenger<ProjectSnapshot>
|
||||
{
|
||||
public ProjectDiagnosticsMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.Diagnostics, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectSnapshot local, ProjectSnapshot remote)
|
||||
{
|
||||
return remote.ProjectDiagnostics != null &&
|
||||
Enumerable.SequenceEqual(local.ProjectDiagnostics, remote.ProjectDiagnostics);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectSnapshot local, Action<object> send)
|
||||
{
|
||||
send(new DiagnosticsListMessage(local.ProjectDiagnostics));
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote)
|
||||
{
|
||||
remote.ProjectDiagnostics = local.ProjectDiagnostics;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class ProjectInformationMessenger : Messenger<ProjectSnapshot>
|
||||
{
|
||||
public ProjectInformationMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.ProjectInformation, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectSnapshot local, ProjectSnapshot remote)
|
||||
{
|
||||
return remote.Project != null &&
|
||||
string.Equals(local.Project.Name, remote.Project.Name) &&
|
||||
string.Equals(local.GlobalJsonPath, remote.GlobalJsonPath) &&
|
||||
Enumerable.SequenceEqual(local.Project.GetTargetFrameworks().Select(f => f.FrameworkName),
|
||||
remote.Project.GetTargetFrameworks().Select(f => f.FrameworkName)) &&
|
||||
Enumerable.SequenceEqual(local.Project.GetConfigurations(), remote.Project.GetConfigurations()) &&
|
||||
Enumerable.SequenceEqual(local.Project.Commands, remote.Project.Commands) &&
|
||||
Enumerable.SequenceEqual(local.ProjectSearchPaths, remote.ProjectSearchPaths);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectSnapshot local, Action<object> send)
|
||||
{
|
||||
send(new ProjectInformationMessage(local.Project, local.GlobalJsonPath, local.ProjectSearchPaths));
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote)
|
||||
{
|
||||
remote.Project = local.Project;
|
||||
remote.GlobalJsonPath = local.GlobalJsonPath;
|
||||
remote.ProjectSearchPaths = local.ProjectSearchPaths;
|
||||
}
|
||||
|
||||
private class ProjectInformationMessage
|
||||
{
|
||||
public ProjectInformationMessage(Project project,
|
||||
string gloablJsonPath,
|
||||
IReadOnlyList<string> projectSearchPaths)
|
||||
{
|
||||
Name = project.Name;
|
||||
Frameworks = project.GetTargetFrameworks().Select(f => f.FrameworkName.ToPayload()).ToList();
|
||||
Configurations = project.GetConfigurations().ToList();
|
||||
Commands = project.Commands;
|
||||
ProjectSearchPaths = projectSearchPaths;
|
||||
GlobalJsonPath = gloablJsonPath;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public IReadOnlyList<FrameworkData> Frameworks { get; }
|
||||
|
||||
public IReadOnlyList<string> Configurations { get; }
|
||||
|
||||
public IDictionary<string, string> Commands { get; }
|
||||
|
||||
public IReadOnlyList<string> ProjectSearchPaths { get; }
|
||||
|
||||
public string GlobalJsonPath { get; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class ReferencesMessenger : Messenger<ProjectContextSnapshot>
|
||||
{
|
||||
public ReferencesMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.References, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
return remote.FileReferences != null &&
|
||||
remote.ProjectReferences != null &&
|
||||
Enumerable.SequenceEqual(local.FileReferences, remote.FileReferences) &&
|
||||
Enumerable.SequenceEqual(local.ProjectReferences, remote.ProjectReferences);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectContextSnapshot local, Action<object> send)
|
||||
{
|
||||
send(new ReferencesMessage
|
||||
{
|
||||
Framework = local.TargetFramework.ToPayload(),
|
||||
ProjectReferences = local.ProjectReferences,
|
||||
FileReferences = local.FileReferences
|
||||
});
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
remote.FileReferences = local.FileReferences;
|
||||
remote.ProjectReferences = local.ProjectReferences;
|
||||
}
|
||||
|
||||
private class ReferencesMessage
|
||||
{
|
||||
public FrameworkData Framework { get; set; }
|
||||
public IReadOnlyList<string> FileReferences { get; set; }
|
||||
public IReadOnlyList<ProjectReferenceDescription> ProjectReferences { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
internal class SourcesMessenger : Messenger<ProjectContextSnapshot>
|
||||
{
|
||||
public SourcesMessenger(Action<string, object> transmit)
|
||||
: base(MessageTypes.Sources, transmit)
|
||||
{ }
|
||||
|
||||
protected override bool CheckDifference(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
return remote.SourceFiles != null &&
|
||||
Enumerable.SequenceEqual(local.SourceFiles, remote.SourceFiles);
|
||||
}
|
||||
|
||||
protected override void SendPayload(ProjectContextSnapshot local, Action<object> send)
|
||||
{
|
||||
send(new SourcesMessage
|
||||
{
|
||||
Framework = local.TargetFramework.ToPayload(),
|
||||
Files = local.SourceFiles,
|
||||
GeneratedFiles = new Dictionary<string, string>()
|
||||
});
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectContextSnapshot local, ProjectContextSnapshot remote)
|
||||
{
|
||||
remote.SourceFiles = local.SourceFiles;
|
||||
}
|
||||
|
||||
private class SourcesMessage
|
||||
{
|
||||
public FrameworkData Framework { get; set; }
|
||||
public IReadOnlyList<string> Files { get; set; }
|
||||
public IDictionary<string, string> GeneratedFiles { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class DependencyDescription
|
||||
{
|
||||
private DependencyDescription() { }
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public string DisplayName { get; private set; }
|
||||
|
||||
public string Version { get; private set; }
|
||||
|
||||
public string Path { get; private set; }
|
||||
|
||||
public string Type { get; private set; }
|
||||
|
||||
public bool Resolved { get; private set; }
|
||||
|
||||
public IEnumerable<DependencyItem> Dependencies { get; private set; }
|
||||
|
||||
public IEnumerable<DiagnosticMessageView> Errors { get; private set; }
|
||||
|
||||
public IEnumerable<DiagnosticMessageView> Warnings { get; private set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as DependencyDescription;
|
||||
|
||||
return other != null &&
|
||||
Resolved == other.Resolved &&
|
||||
string.Equals(Name, other.Name) &&
|
||||
object.Equals(Version, other.Version) &&
|
||||
string.Equals(Path, other.Path) &&
|
||||
string.Equals(Type, other.Type) &&
|
||||
Enumerable.SequenceEqual(Dependencies, other.Dependencies) &&
|
||||
Enumerable.SequenceEqual(Errors, other.Errors) &&
|
||||
Enumerable.SequenceEqual(Warnings, other.Warnings);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// These objects are currently POCOs and we're overriding equals
|
||||
// so that things like Enumerable.SequenceEqual just work.
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public static DependencyDescription Create(LibraryDescription library,
|
||||
List<DiagnosticMessage> diagnostics,
|
||||
IDictionary<string, LibraryExport> exportsLookup)
|
||||
{
|
||||
var result = new DependencyDescription
|
||||
{
|
||||
Name = library.Identity.Name,
|
||||
DisplayName = library.Identity.Name,
|
||||
Version = (library.Identity.Version ?? new NuGetVersion("1.0.0")).ToNormalizedString(),
|
||||
Type = library.Identity.Type.Value,
|
||||
Resolved = library.Resolved,
|
||||
Path = library.Path,
|
||||
Dependencies = library.Dependencies.Select(dependency => GetDependencyItem(dependency, exportsLookup)),
|
||||
Errors = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Error)
|
||||
.Select(d => new DiagnosticMessageView(d)),
|
||||
Warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning)
|
||||
.Select(d => new DiagnosticMessageView(d))
|
||||
};
|
||||
|
||||
var msbuildLibrary = library as MSBuildProjectDescription;
|
||||
if (msbuildLibrary != null)
|
||||
{
|
||||
result.Path = msbuildLibrary.MSBuildProjectPath;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static DependencyItem GetDependencyItem(LibraryRange dependency,
|
||||
IDictionary<string, LibraryExport> exportsLookup)
|
||||
{
|
||||
return new DependencyItem
|
||||
{
|
||||
Name = dependency.Name,
|
||||
Version = exportsLookup[dependency.Name].Library.Identity.Version?.ToNormalizedString()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class DependencyItem
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as DependencyItem;
|
||||
return other != null &&
|
||||
string.Equals(Name, other.Name) &&
|
||||
object.Equals(Version, other.Version);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// These objects are currently POCOs and we're overriding equals
|
||||
// so that things like Enumerable.SequenceEqual just work.
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class DiagnosticMessageGroup
|
||||
{
|
||||
public DiagnosticMessageGroup(IEnumerable<DiagnosticMessage> diagnostics)
|
||||
: this(framework: null, diagnostics: diagnostics)
|
||||
{ }
|
||||
|
||||
public DiagnosticMessageGroup(NuGetFramework framework, IEnumerable<DiagnosticMessage> diagnostics)
|
||||
{
|
||||
Framework = framework;
|
||||
Diagnostics = diagnostics;
|
||||
}
|
||||
|
||||
public IEnumerable<DiagnosticMessage> Diagnostics { get; }
|
||||
|
||||
public NuGetFramework Framework { get; }
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class DiagnosticMessageView
|
||||
{
|
||||
public DiagnosticMessageView(DiagnosticMessage data)
|
||||
{
|
||||
ErrorCode = data.ErrorCode;
|
||||
SourceFilePath = data.SourceFilePath;
|
||||
Message = data.Message;
|
||||
Severity = data.Severity;
|
||||
StartLine = data.StartLine;
|
||||
StartColumn = data.StartColumn;
|
||||
EndLine = data.EndLine;
|
||||
EndColumn = data.EndColumn;
|
||||
FormattedMessage = data.FormattedMessage;
|
||||
|
||||
var description = data.Source as LibraryDescription;
|
||||
if (description != null)
|
||||
{
|
||||
Source = new
|
||||
{
|
||||
Name = description.Identity.Name,
|
||||
Version = description.Identity.Version?.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public string ErrorCode { get; }
|
||||
|
||||
public string SourceFilePath { get; }
|
||||
|
||||
public string Message { get; }
|
||||
|
||||
public DiagnosticMessageSeverity Severity { get; }
|
||||
|
||||
public int StartLine { get; }
|
||||
|
||||
public int StartColumn { get; }
|
||||
|
||||
public int EndLine { get; }
|
||||
|
||||
public int EndColumn { get; }
|
||||
|
||||
public string FormattedMessage { get; }
|
||||
|
||||
public object Source { get; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as DiagnosticMessageView;
|
||||
|
||||
return other != null &&
|
||||
Severity == other.Severity &&
|
||||
StartLine == other.StartLine &&
|
||||
StartColumn == other.StartColumn &&
|
||||
EndLine == other.EndLine &&
|
||||
EndColumn == other.EndColumn &&
|
||||
string.Equals(ErrorCode, other.ErrorCode, StringComparison.Ordinal) &&
|
||||
string.Equals(SourceFilePath, other.SourceFilePath, StringComparison.Ordinal) &&
|
||||
string.Equals(Message, other.Message, StringComparison.Ordinal) &&
|
||||
object.Equals(Source, other.Source);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class DiagnosticsListMessage
|
||||
{
|
||||
public DiagnosticsListMessage(IEnumerable<DiagnosticMessage> diagnostics) :
|
||||
this(diagnostics, frameworkData: null)
|
||||
{
|
||||
}
|
||||
|
||||
public DiagnosticsListMessage(IEnumerable<DiagnosticMessage> diagnostics, FrameworkData frameworkData) :
|
||||
this(diagnostics.Select(msg => new DiagnosticMessageView(msg)).ToList(), frameworkData)
|
||||
{
|
||||
if (diagnostics == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(diagnostics));
|
||||
}
|
||||
}
|
||||
|
||||
public DiagnosticsListMessage(IEnumerable<DiagnosticMessageView> diagnostics) :
|
||||
this(diagnostics, frameworkData: null)
|
||||
{
|
||||
}
|
||||
|
||||
public DiagnosticsListMessage(IEnumerable<DiagnosticMessageView> diagnostics, FrameworkData frameworkData)
|
||||
{
|
||||
if (diagnostics == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(diagnostics));
|
||||
}
|
||||
|
||||
Diagnostics = diagnostics;
|
||||
Errors = diagnostics.Where(msg => msg.Severity == DiagnosticMessageSeverity.Error).ToList();
|
||||
Warnings = diagnostics.Where(msg => msg.Severity == DiagnosticMessageSeverity.Warning).ToList();
|
||||
Framework = frameworkData;
|
||||
}
|
||||
|
||||
public FrameworkData Framework { get; }
|
||||
|
||||
[JsonIgnore]
|
||||
public IEnumerable<DiagnosticMessageView> Diagnostics { get; }
|
||||
|
||||
public IList<DiagnosticMessageView> Errors { get; }
|
||||
|
||||
public IList<DiagnosticMessageView> Warnings { get; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as DiagnosticsListMessage;
|
||||
|
||||
return other != null &&
|
||||
Enumerable.SequenceEqual(Errors, other.Errors) &&
|
||||
Enumerable.SequenceEqual(Warnings, other.Warnings) &&
|
||||
object.Equals(Framework, other.Framework);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class ErrorMessage
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public string Path { get; set; }
|
||||
public int Line { get; set; }
|
||||
public int Column { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var payload = obj as ErrorMessage;
|
||||
return payload != null &&
|
||||
string.Equals(Message, payload.Message, StringComparison.Ordinal) &&
|
||||
string.Equals(Path, payload.Path, StringComparison.OrdinalIgnoreCase) &&
|
||||
Line == payload.Line &&
|
||||
Column == payload.Column;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
public class FrameworkData
|
||||
{
|
||||
public string FrameworkName { get; set; }
|
||||
public string FriendlyName { get; set; }
|
||||
public string ShortName { get; set; }
|
||||
public string RedistListPath { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as FrameworkData;
|
||||
|
||||
return other != null &&
|
||||
string.Equals(FrameworkName, other.FrameworkName);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// These objects are currently POCOs and we're overriding equals
|
||||
// so that things like Enumerable.SequenceEqual just work.
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
internal class Message
|
||||
{
|
||||
public static Message FromPayload(string messageType, int contextId, object payload)
|
||||
{
|
||||
return new Message
|
||||
{
|
||||
MessageType = messageType,
|
||||
ContextId = contextId,
|
||||
Payload = payload is JToken ? (JToken)payload : JToken.FromObject(payload)
|
||||
};
|
||||
}
|
||||
|
||||
private Message() { }
|
||||
|
||||
public string MessageType { get; set; }
|
||||
|
||||
public string HostId { get; set; }
|
||||
|
||||
public int ContextId { get; set; } = -1;
|
||||
|
||||
public JToken Payload { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public ConnectionContext Sender { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({HostId}, {MessageType}, {ContextId}) -> {Payload?.ToString(Formatting.Indented)}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Models
|
||||
{
|
||||
internal class ProjectReferenceDescription
|
||||
{
|
||||
private ProjectReferenceDescription() { }
|
||||
|
||||
public FrameworkData Framework { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as ProjectReferenceDescription;
|
||||
return other != null &&
|
||||
string.Equals(Name, other.Name) &&
|
||||
string.Equals(Path, other.Path);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a ProjectReferenceDescription from given LibraryDescription. If the library doesn't
|
||||
/// represent a project reference returns null.
|
||||
/// </summary>
|
||||
public static ProjectReferenceDescription Create(LibraryDescription library)
|
||||
{
|
||||
if (library is ProjectDescription)
|
||||
{
|
||||
return new ProjectReferenceDescription
|
||||
{
|
||||
Framework = library.Framework.ToPayload(),
|
||||
Name = library.Identity.Name,
|
||||
Path = library.Path
|
||||
};
|
||||
}
|
||||
else if (library is MSBuildProjectDescription)
|
||||
{
|
||||
return new ProjectReferenceDescription
|
||||
{
|
||||
Framework = library.Framework.ToPayload(),
|
||||
Name = library.Identity.Name,
|
||||
Path = ((MSBuildProjectDescription)library).MSBuildProjectPath,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
internal class ProcessingQueue
|
||||
{
|
||||
private readonly BinaryReader _reader;
|
||||
private readonly BinaryWriter _writer;
|
||||
|
||||
public ProcessingQueue(Stream stream)
|
||||
{
|
||||
_reader = new BinaryReader(stream);
|
||||
_writer = new BinaryWriter(stream);
|
||||
}
|
||||
|
||||
public event Action<Message> OnReceive;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Reporter.Output.WriteLine("Start");
|
||||
new Thread(ReceiveMessages).Start();
|
||||
}
|
||||
|
||||
public bool Send(Action<BinaryWriter> writeAction)
|
||||
{
|
||||
lock (_writer)
|
||||
{
|
||||
try
|
||||
{
|
||||
writeAction(_writer);
|
||||
return true;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
// swallow
|
||||
Reporter.Output.WriteLine($"Ignore {nameof(IOException)} during sending message: \"{ex.Message}\".");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Reporter.Output.WriteLine($"Unexpected exception {ex.GetType().Name} during sending message: \"{ex.Message}\".");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Send(Message message)
|
||||
{
|
||||
return Send(_writer =>
|
||||
{
|
||||
Reporter.Output.WriteLine($"OnSend ({message})");
|
||||
_writer.Write(JsonConvert.SerializeObject(message));
|
||||
});
|
||||
}
|
||||
|
||||
private void ReceiveMessages()
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var content = _reader.ReadString();
|
||||
var message = JsonConvert.DeserializeObject<Message>(content);
|
||||
|
||||
Reporter.Output.WriteLine($"OnReceive ({message})");
|
||||
OnReceive(message);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Reporter.Output.WriteLine($"Ignore {nameof(IOException)} during receiving messages: \"{ex}\".");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Reporter.Error.WriteLine($"Unexpected exception {ex.GetType().Name} during receiving messages: \"{ex}\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
public class ProjectModelServerCommand
|
||||
{
|
||||
private readonly Dictionary<int, ProjectManager> _projects;
|
||||
private readonly DesignTimeWorkspace _workspaceContext;
|
||||
private readonly ProtocolManager _protocolManager;
|
||||
private readonly string _hostName;
|
||||
private readonly int _port;
|
||||
private Socket _listenSocket;
|
||||
|
||||
public ProjectModelServerCommand(int port, string hostName)
|
||||
{
|
||||
_port = port;
|
||||
_hostName = hostName;
|
||||
_protocolManager = new ProtocolManager(maxVersion: 4);
|
||||
_workspaceContext = new DesignTimeWorkspace(ProjectReaderSettings.ReadFromEnvironment());
|
||||
_projects = new Dictionary<int, ProjectManager>();
|
||||
}
|
||||
|
||||
public static int Run(string[] args)
|
||||
{
|
||||
var app = new CommandLineApplication();
|
||||
app.Name = "dotnet-projectmodel-server";
|
||||
app.Description = ".NET Project Model Server";
|
||||
app.FullName = ".NET Design Time Server";
|
||||
app.Description = ".NET Design Time Server";
|
||||
app.HelpOption("-?|-h|--help");
|
||||
|
||||
var verbose = app.Option("--verbose", "Verbose ouput", CommandOptionType.NoValue);
|
||||
var hostpid = app.Option("--host-pid", "The process id of the host", CommandOptionType.SingleValue);
|
||||
var hostname = app.Option("--host-name", "The name of the host", CommandOptionType.SingleValue);
|
||||
var port = app.Option("--port", "The TCP port used for communication", CommandOptionType.SingleValue);
|
||||
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!MonitorHostProcess(hostpid))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var intPort = CheckPort(port);
|
||||
if (intPort == -1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!hostname.HasValue())
|
||||
{
|
||||
Reporter.Error.WriteLine($"Option \"{hostname.LongName}\" is missing.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var program = new ProjectModelServerCommand(intPort, hostname.Value());
|
||||
program.OpenChannel();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Reporter.Error.WriteLine($"Unhandled exception in server main: {ex}");
|
||||
throw;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
return app.Execute(args);
|
||||
}
|
||||
|
||||
public void OpenChannel()
|
||||
{
|
||||
_listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
_listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, _port));
|
||||
_listenSocket.Listen(10);
|
||||
|
||||
Reporter.Output.WriteLine($"Process ID {Process.GetCurrentProcess().Id}");
|
||||
Reporter.Output.WriteLine($"Listening on port {_port}");
|
||||
|
||||
while (true)
|
||||
{
|
||||
var acceptSocket = _listenSocket.Accept();
|
||||
Reporter.Output.WriteLine($"Client accepted {acceptSocket.LocalEndPoint}");
|
||||
|
||||
var connection = new ConnectionContext(acceptSocket,
|
||||
_hostName,
|
||||
_protocolManager,
|
||||
_workspaceContext,
|
||||
_projects);
|
||||
|
||||
connection.QueueStart();
|
||||
}
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
if (_listenSocket.Connected)
|
||||
{
|
||||
_listenSocket.Shutdown(SocketShutdown.Both);
|
||||
}
|
||||
}
|
||||
|
||||
private static int CheckPort(CommandOption port)
|
||||
{
|
||||
if (!port.HasValue())
|
||||
{
|
||||
Reporter.Error.WriteLine($"Option \"{port.LongName}\" is missing.");
|
||||
}
|
||||
|
||||
int result;
|
||||
if (int.TryParse(port.Value(), out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
Reporter.Error.WriteLine($"Option \"{port.LongName}\" is not a valid Int32 value.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool MonitorHostProcess(CommandOption host)
|
||||
{
|
||||
if (!host.HasValue())
|
||||
{
|
||||
Console.Error.WriteLine($"Option \"{host.LongName}\" is missing.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int hostPID;
|
||||
if (int.TryParse(host.Value(), out hostPID))
|
||||
{
|
||||
var hostProcess = Process.GetProcessById(hostPID);
|
||||
hostProcess.EnableRaisingEvents = true;
|
||||
hostProcess.Exited += (s, e) =>
|
||||
{
|
||||
Process.GetCurrentProcess().Kill();
|
||||
};
|
||||
|
||||
Reporter.Output.WriteLine($"Server will exit when process {hostPID} exits.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Reporter.Error.WriteLine($"Option \"{host.LongName}\" is not a valid Int32 value.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,327 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Helpers;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Messengers;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
internal class ProjectManager
|
||||
{
|
||||
private readonly object _processingLock = new object();
|
||||
private readonly Queue<Message> _inbox = new Queue<Message>();
|
||||
private readonly ProtocolManager _protocolManager;
|
||||
|
||||
private ConnectionContext _initializedContext;
|
||||
|
||||
// triggers
|
||||
private readonly Trigger<string> _appPath = new Trigger<string>();
|
||||
private readonly Trigger<string> _configure = new Trigger<string>();
|
||||
private readonly Trigger<bool> _refreshDependencies = new Trigger<bool>();
|
||||
private readonly Trigger<int> _filesChanged = new Trigger<int>();
|
||||
|
||||
private ProjectSnapshot _local = new ProjectSnapshot();
|
||||
private ProjectSnapshot _remote = new ProjectSnapshot();
|
||||
|
||||
private readonly DesignTimeWorkspace _workspaceContext;
|
||||
private int? _contextProtocolVersion;
|
||||
|
||||
private readonly List<Messenger<ProjectContextSnapshot>> _messengers;
|
||||
|
||||
private ProjectDiagnosticsMessenger _projectDiagnosticsMessenger;
|
||||
private GlobalErrorMessenger _globalErrorMessenger;
|
||||
private ProjectInformationMessenger _projectInforamtionMessenger;
|
||||
|
||||
public ProjectManager(
|
||||
int contextId,
|
||||
DesignTimeWorkspace workspaceContext,
|
||||
ProtocolManager protocolManager)
|
||||
{
|
||||
Id = contextId;
|
||||
_workspaceContext = workspaceContext;
|
||||
_protocolManager = protocolManager;
|
||||
|
||||
_messengers = new List<Messenger<ProjectContextSnapshot>>
|
||||
{
|
||||
new ReferencesMessenger(Transmit),
|
||||
new DependenciesMessenger(Transmit),
|
||||
new DependencyDiagnosticsMessenger(Transmit),
|
||||
new CompilerOptionsMessenger(Transmit),
|
||||
new SourcesMessenger(Transmit)
|
||||
};
|
||||
|
||||
_projectDiagnosticsMessenger = new ProjectDiagnosticsMessenger(Transmit);
|
||||
_globalErrorMessenger = new GlobalErrorMessenger(Transmit);
|
||||
_projectInforamtionMessenger = new ProjectInformationMessenger(Transmit);
|
||||
}
|
||||
|
||||
public int Id { get; }
|
||||
|
||||
public string ProjectPath { get { return _appPath.Value; } }
|
||||
|
||||
public int ProtocolVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_contextProtocolVersion.HasValue)
|
||||
{
|
||||
return _contextProtocolVersion.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _protocolManager.CurrentVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReceive(Message message)
|
||||
{
|
||||
lock (_inbox)
|
||||
{
|
||||
_inbox.Enqueue(message);
|
||||
}
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state => ((ProjectManager)state).ProcessLoop(), this);
|
||||
}
|
||||
|
||||
private void Transmit(string messageType, object payload)
|
||||
{
|
||||
var message = Message.FromPayload(messageType, Id, payload);
|
||||
_initializedContext.Transmit(message);
|
||||
}
|
||||
|
||||
private void ProcessLoop()
|
||||
{
|
||||
if (!Monitor.TryEnter(_processingLock))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lock (_inbox)
|
||||
{
|
||||
if (!_inbox.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DoProcessLoop();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Reporter.Error.WriteLine($"A unexpected exception occurred: {ex}");
|
||||
|
||||
var error = new ErrorMessage
|
||||
{
|
||||
Message = ex.Message
|
||||
};
|
||||
|
||||
var fileFormatException = ex as FileFormatException;
|
||||
if (fileFormatException != null)
|
||||
{
|
||||
error.Path = fileFormatException.Path;
|
||||
error.Line = fileFormatException.Line;
|
||||
error.Column = fileFormatException.Column;
|
||||
}
|
||||
|
||||
var message = Message.FromPayload(MessageTypes.Error, Id, error);
|
||||
|
||||
_initializedContext.Transmit(message);
|
||||
_remote.GlobalErrorMessage = error;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Monitor.Exit(_processingLock);
|
||||
}
|
||||
}
|
||||
|
||||
private void DoProcessLoop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
DrainInbox();
|
||||
|
||||
UpdateProject();
|
||||
SendOutgingMessages();
|
||||
|
||||
lock (_inbox)
|
||||
{
|
||||
if (_inbox.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrainInbox()
|
||||
{
|
||||
Reporter.Output.WriteLine("Begin draining inbox.");
|
||||
|
||||
while (ProcessMessage()) { }
|
||||
|
||||
Reporter.Output.WriteLine("Finish draining inbox.");
|
||||
}
|
||||
|
||||
private bool ProcessMessage()
|
||||
{
|
||||
Message message;
|
||||
|
||||
lock (_inbox)
|
||||
{
|
||||
if (!_inbox.Any())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
message = _inbox.Dequeue();
|
||||
Debug.Assert(message != null);
|
||||
}
|
||||
|
||||
Reporter.Output.WriteLine($"Received {message.MessageType}");
|
||||
|
||||
switch (message.MessageType)
|
||||
{
|
||||
case MessageTypes.Initialize:
|
||||
Initialize(message);
|
||||
break;
|
||||
case MessageTypes.ChangeConfiguration:
|
||||
// TODO: what if the payload is null or represent empty string?
|
||||
_configure.Value = message.Payload.GetValue("Configuration");
|
||||
break;
|
||||
case MessageTypes.RefreshDependencies:
|
||||
// In the case of RefreshDependencies request, the cache will not be reset in any case. The value
|
||||
// is set so as to trigger refresh action in later loop.
|
||||
_refreshDependencies.Value = false;
|
||||
break;
|
||||
case MessageTypes.RestoreComplete:
|
||||
// In the case of RestoreComplete request, the value of the 'Reset' property in payload will determine
|
||||
// if the cache should be reset. If the property doesn't exist, cache will be reset.
|
||||
_refreshDependencies.Value = message.Payload.HasValues ? message.Payload.Value<bool>("Reset") : true;
|
||||
break;
|
||||
case MessageTypes.FilesChanged:
|
||||
_filesChanged.Value = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Initialize(Message message)
|
||||
{
|
||||
if (_initializedContext != null)
|
||||
{
|
||||
Reporter.Output.WriteLine($"Received {message.MessageType} message more than once for {_appPath.Value}");
|
||||
return;
|
||||
}
|
||||
|
||||
_initializedContext = message.Sender;
|
||||
_appPath.Value = message.Payload.GetValue("ProjectFolder");
|
||||
_configure.Value = message.Payload.GetValue("Configuration") ?? "Debug";
|
||||
|
||||
var version = message.Payload.GetValue<int>("Version");
|
||||
if (version != 0 && !_protocolManager.EnvironmentOverridden)
|
||||
{
|
||||
_contextProtocolVersion = Math.Min(version, _protocolManager.MaxVersion);
|
||||
Reporter.Output.WriteLine($"Set context protocol version to {_contextProtocolVersion.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdateProject()
|
||||
{
|
||||
ProjectSnapshot newSnapshot = null;
|
||||
|
||||
if (_appPath.WasAssigned || _configure.WasAssigned || _filesChanged.WasAssigned || _refreshDependencies.WasAssigned)
|
||||
{
|
||||
_appPath.ClearAssigned();
|
||||
_configure.ClearAssigned();
|
||||
_filesChanged.ClearAssigned();
|
||||
|
||||
bool resetCache = _refreshDependencies.WasAssigned ? _refreshDependencies.Value : false;
|
||||
_refreshDependencies.ClearAssigned();
|
||||
|
||||
newSnapshot = ProjectSnapshot.Create(_appPath.Value,
|
||||
_configure.Value,
|
||||
_workspaceContext,
|
||||
_remote.ProjectSearchPaths,
|
||||
clearWorkspaceContextCache: resetCache);
|
||||
}
|
||||
|
||||
if (newSnapshot == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_local = newSnapshot;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SendOutgingMessages()
|
||||
{
|
||||
_projectInforamtionMessenger.UpdateRemote(_local, _remote);
|
||||
_projectDiagnosticsMessenger.UpdateRemote(_local, _remote);
|
||||
|
||||
var unprocessedFrameworks = new HashSet<NuGetFramework>(_remote.ProjectContexts.Keys);
|
||||
foreach (var pair in _local.ProjectContexts)
|
||||
{
|
||||
ProjectContextSnapshot localProjectSnapshot = pair.Value;
|
||||
ProjectContextSnapshot remoteProjectSnapshot;
|
||||
|
||||
if (!_remote.ProjectContexts.TryGetValue(pair.Key, out remoteProjectSnapshot))
|
||||
{
|
||||
remoteProjectSnapshot = new ProjectContextSnapshot();
|
||||
_remote.ProjectContexts[pair.Key] = remoteProjectSnapshot;
|
||||
}
|
||||
|
||||
unprocessedFrameworks.Remove(pair.Key);
|
||||
|
||||
foreach (var messenger in _messengers)
|
||||
{
|
||||
messenger.UpdateRemote(localProjectSnapshot,
|
||||
remoteProjectSnapshot);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all processed frameworks from the remote view
|
||||
foreach (var framework in unprocessedFrameworks)
|
||||
{
|
||||
_remote.ProjectContexts.Remove(framework);
|
||||
}
|
||||
|
||||
_globalErrorMessenger.UpdateRemote(_local, _remote);
|
||||
}
|
||||
|
||||
private class Trigger<TValue>
|
||||
{
|
||||
private TValue _value;
|
||||
|
||||
public bool WasAssigned { get; private set; }
|
||||
|
||||
public void ClearAssigned()
|
||||
{
|
||||
WasAssigned = false;
|
||||
}
|
||||
|
||||
public TValue Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
WasAssigned = true;
|
||||
_value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server
|
||||
{
|
||||
internal class ProtocolManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Environment variable for overriding protocol.
|
||||
/// </summary>
|
||||
public const string EnvDthProtocol = "DTH_PROTOCOL";
|
||||
|
||||
public ProtocolManager(int maxVersion)
|
||||
{
|
||||
MaxVersion = maxVersion;
|
||||
|
||||
// initialized to the highest supported version or environment overridden value
|
||||
int? protocol = GetProtocolVersionFromEnvironment();
|
||||
|
||||
if (protocol.HasValue)
|
||||
{
|
||||
CurrentVersion = protocol.Value;
|
||||
EnvironmentOverridden = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentVersion = 4;
|
||||
}
|
||||
}
|
||||
|
||||
public int MaxVersion { get; }
|
||||
|
||||
public int CurrentVersion { get; private set; }
|
||||
|
||||
public bool EnvironmentOverridden { get; }
|
||||
|
||||
public bool IsProtocolNegotiation(Message message)
|
||||
{
|
||||
return message?.MessageType == MessageTypes.ProtocolVersion;
|
||||
}
|
||||
|
||||
public void Negotiate(Message message)
|
||||
{
|
||||
if (!IsProtocolNegotiation(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reporter.Output.WriteLine("Initializing the protocol negotiation.");
|
||||
|
||||
if (EnvironmentOverridden)
|
||||
{
|
||||
Reporter.Output.WriteLine($"DTH protocol negotiation is override by environment variable {EnvDthProtocol} and set to {CurrentVersion}.");
|
||||
return;
|
||||
}
|
||||
|
||||
var tokenValue = message.Payload?["Version"];
|
||||
if (tokenValue == null)
|
||||
{
|
||||
Reporter.Output.WriteLine("Protocol negotiation failed. Version property is missing in payload.");
|
||||
return;
|
||||
}
|
||||
|
||||
var preferredVersion = tokenValue.ToObject<int>();
|
||||
if (preferredVersion == 0)
|
||||
{
|
||||
// the preferred version can't be zero. either property is missing or the the payload is corrupted.
|
||||
Reporter.Output.WriteLine("Protocol negotiation failed. Protocol version 0 is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentVersion = Math.Min(preferredVersion, MaxVersion);
|
||||
Reporter.Output.WriteLine($"Protocol negotiation successed. Use protocol {CurrentVersion}");
|
||||
|
||||
if (message.Sender != null)
|
||||
{
|
||||
Reporter.Output.WriteLine("Respond to protocol negotiation.");
|
||||
message.Sender.Transmit(Message.FromPayload(
|
||||
MessageTypes.ProtocolVersion,
|
||||
0,
|
||||
new { Version = CurrentVersion }));
|
||||
}
|
||||
else
|
||||
{
|
||||
Reporter.Output.WriteLine($"{nameof(Message.Sender)} is null.");
|
||||
}
|
||||
}
|
||||
|
||||
private static int? GetProtocolVersionFromEnvironment()
|
||||
{
|
||||
// look for the environment variable DTH_PROTOCOL, if it is set override the protocol version.
|
||||
// this is for debugging.
|
||||
var strProtocol = Environment.GetEnvironmentVariable(EnvDthProtocol);
|
||||
int intProtocol = -1;
|
||||
if (!string.IsNullOrEmpty(strProtocol) && Int32.TryParse(strProtocol, out intProtocol))
|
||||
{
|
||||
return intProtocol;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,294 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public class DthTestClient : IDisposable
|
||||
{
|
||||
private readonly string _hostId;
|
||||
private readonly BinaryReader _reader;
|
||||
private readonly BinaryWriter _writer;
|
||||
private readonly NetworkStream _networkStream;
|
||||
private readonly BlockingCollection<DthMessage> _messageQueue;
|
||||
private readonly CancellationTokenSource _readCancellationToken;
|
||||
private readonly TimeSpan _defaultTimeout = TimeSpan.FromSeconds(20);
|
||||
|
||||
// Keeps track of initialized project contexts
|
||||
// REVIEW: This needs to be exposed if we ever create 2 clients in order to simulate how build
|
||||
// works in visual studio
|
||||
private readonly Dictionary<string, int> _projectContexts = new Dictionary<string, int>();
|
||||
private int _nextContextId;
|
||||
private readonly Socket _socket;
|
||||
|
||||
public DthTestClient(DthTestServer server)
|
||||
{
|
||||
// Avoid Socket exception 10006 on Linux
|
||||
Thread.Sleep(100);
|
||||
|
||||
_socket = new Socket(AddressFamily.InterNetwork,
|
||||
SocketType.Stream,
|
||||
ProtocolType.Tcp);
|
||||
|
||||
_socket.Connect(new IPEndPoint(IPAddress.Loopback, server.Port));
|
||||
|
||||
_hostId = server.HostId;
|
||||
|
||||
_networkStream = new NetworkStream(_socket);
|
||||
_reader = new BinaryReader(_networkStream);
|
||||
_writer = new BinaryWriter(_networkStream);
|
||||
|
||||
_messageQueue = new BlockingCollection<DthMessage>();
|
||||
|
||||
_readCancellationToken = new CancellationTokenSource();
|
||||
Task.Run(() => ReadMessage(_readCancellationToken.Token), _readCancellationToken.Token);
|
||||
}
|
||||
|
||||
public void SendPayload(Project project, string messageType)
|
||||
{
|
||||
SendPayload(project.ProjectDirectory, messageType);
|
||||
}
|
||||
|
||||
public void SendPayload(string projectPath, string messageType)
|
||||
{
|
||||
SendPayload(projectPath, messageType, new { });
|
||||
}
|
||||
|
||||
public void SendPayload(string projectPath, string messageType, object payload)
|
||||
{
|
||||
int contextId;
|
||||
if (!_projectContexts.TryGetValue(projectPath, out contextId))
|
||||
{
|
||||
Assert.True(false, $"Unable to resolve context for {projectPath}");
|
||||
}
|
||||
|
||||
SendPayload(contextId, messageType, payload);
|
||||
}
|
||||
|
||||
public void SendPayload(int contextId, string messageType)
|
||||
{
|
||||
SendPayload(contextId, messageType, new { });
|
||||
}
|
||||
|
||||
public void SendPayload(int contextId, string messageType, object payload)
|
||||
{
|
||||
lock (_writer)
|
||||
{
|
||||
var message = new
|
||||
{
|
||||
ContextId = contextId,
|
||||
HostId = _hostId,
|
||||
MessageType = messageType,
|
||||
Payload = payload
|
||||
};
|
||||
_writer.Write(JsonConvert.SerializeObject(message));
|
||||
}
|
||||
}
|
||||
|
||||
public int Initialize(string projectPath)
|
||||
{
|
||||
var contextId = _nextContextId++;
|
||||
|
||||
_projectContexts[projectPath] = contextId;
|
||||
SendPayload(contextId, MessageTypes.Initialize, new { ProjectFolder = projectPath });
|
||||
|
||||
return contextId;
|
||||
}
|
||||
|
||||
public int Initialize(string projectPath, int protocolVersion)
|
||||
{
|
||||
var contextId = _nextContextId++;
|
||||
|
||||
_projectContexts[projectPath] = contextId;
|
||||
SendPayload(contextId, MessageTypes.Initialize, new { ProjectFolder = projectPath, Version = protocolVersion });
|
||||
|
||||
return contextId;
|
||||
}
|
||||
|
||||
public int Initialize(string projectPath, int protocolVersion, string configuration)
|
||||
{
|
||||
var contextId = _nextContextId++;
|
||||
|
||||
_projectContexts[projectPath] = contextId;
|
||||
SendPayload(contextId, MessageTypes.Initialize, new { ProjectFolder = projectPath, Version = protocolVersion, Configuration = configuration });
|
||||
|
||||
return contextId;
|
||||
}
|
||||
|
||||
public void SetProtocolVersion(int version)
|
||||
{
|
||||
SendPayload(0, MessageTypes.ProtocolVersion, new { Version = version });
|
||||
}
|
||||
|
||||
public List<DthMessage> DrainMessage(int count)
|
||||
{
|
||||
var result = new List<DthMessage>();
|
||||
while (count > 0)
|
||||
{
|
||||
result.Add(GetResponse(timeout: _defaultTimeout));
|
||||
count--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DthMessage> DrainAllMessages()
|
||||
{
|
||||
return DrainAllMessages(_defaultTimeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read all messages from pipeline till timeout
|
||||
/// </summary>
|
||||
/// <param name="timeout">The timeout</param>
|
||||
/// <returns>All the messages in a list</returns>
|
||||
public List<DthMessage> DrainAllMessages(TimeSpan timeout)
|
||||
{
|
||||
var result = new List<DthMessage>();
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
result.Add(GetResponse(timeout));
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read messages from pipeline until the first match
|
||||
/// </summary>]
|
||||
/// <param name="type">A message type</param>
|
||||
/// <returns>The first match message</returns>
|
||||
public DthMessage DrainTillFirst(string type)
|
||||
{
|
||||
return DrainTillFirst(type, _defaultTimeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read messages from pipeline until the first match
|
||||
/// </summary>
|
||||
/// <param name="type">A message type</param>
|
||||
/// <param name="timeout">Timeout for each read</param>
|
||||
/// <returns>The first match message</returns>
|
||||
public DthMessage DrainTillFirst(string type, TimeSpan timeout)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var next = GetResponse(timeout);
|
||||
if (next.MessageType == type)
|
||||
{
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read messages from pipeline until the first match
|
||||
/// </summary>
|
||||
/// <param name="type">A message type</param>
|
||||
/// <param name="timeout">Timeout</param>
|
||||
/// <param name="leadingMessages">All the messages read before the first match</param>
|
||||
/// <returns>The first match</returns>
|
||||
public DthMessage DrainTillFirst(string type, TimeSpan timeout, out List<DthMessage> leadingMessages)
|
||||
{
|
||||
leadingMessages = new List<DthMessage>();
|
||||
while (true)
|
||||
{
|
||||
var next = GetResponse(timeout);
|
||||
if (next.MessageType == type)
|
||||
{
|
||||
return next;
|
||||
}
|
||||
else
|
||||
{
|
||||
leadingMessages.Add(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_reader.Dispose();
|
||||
_writer.Dispose();
|
||||
_networkStream.Dispose();
|
||||
_readCancellationToken.Cancel();
|
||||
|
||||
try
|
||||
{
|
||||
_socket.Shutdown(SocketShutdown.Both);
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
// Swallow this error for now.
|
||||
// This is a temporary fix for a random failure on CI. The issue happens on Windowx x86
|
||||
// only.
|
||||
Console.Error.WriteLine($"Exception thrown durning socket shutting down: {ex.SocketErrorCode}.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadMessage(CancellationToken cancellationToken)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var content = _reader.ReadString();
|
||||
var message = JsonConvert.DeserializeObject<DthMessage>(content);
|
||||
|
||||
_messageQueue.Add(message);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// swallow
|
||||
}
|
||||
catch (JsonSerializationException deserializException)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Fail to deserailze data into {nameof(DthMessage)}.",
|
||||
deserializException);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DthMessage GetResponse(TimeSpan timeout)
|
||||
{
|
||||
DthMessage message;
|
||||
|
||||
if (_messageQueue.TryTake(out message, timeout))
|
||||
{
|
||||
return message;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TimeoutException($"Response time out after {timeout.TotalSeconds} seconds.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public class DthTestServer : IDisposable
|
||||
{
|
||||
private readonly ProjectModelServerCommand _program;
|
||||
private readonly Thread _thread;
|
||||
|
||||
public DthTestServer()
|
||||
{
|
||||
Port = FindFreePort();
|
||||
HostId = Guid.NewGuid().ToString();
|
||||
|
||||
_program = new ProjectModelServerCommand(Port, HostId);
|
||||
|
||||
_thread = new Thread(() => { _program.OpenChannel(); }) { IsBackground = true };
|
||||
_thread.Start();
|
||||
}
|
||||
|
||||
public string HostId { get; }
|
||||
|
||||
public int Port { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
_program.Shutdown();
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// swallow the exception if the process had been terminated.
|
||||
}
|
||||
}
|
||||
|
||||
private static int FindFreePort()
|
||||
{
|
||||
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
socket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
|
||||
return ((IPEndPoint)socket.LocalEndPoint).Port;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,789 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public class DthTests : TestBase
|
||||
{
|
||||
private readonly TestAssetsManager _testAssetsManager;
|
||||
|
||||
public DthTests()
|
||||
{
|
||||
_testAssetsManager = new TestAssetsManager(
|
||||
Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "DthTestProjects", "src"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DthStartup_GetProjectInformation()
|
||||
{
|
||||
var projectPath = Path.Combine(_testAssetsManager.AssetsRoot, "EmptyConsoleApp");
|
||||
Assert.NotNull(projectPath);
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
|
||||
var projectInformation = client.DrainTillFirst(MessageTypes.ProjectInformation)
|
||||
.EnsureSource(server, client)
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.AssertProperty("Name", "EmptyConsoleApp");
|
||||
|
||||
projectInformation.RetrievePropertyAs<JArray>("Configurations")
|
||||
.AssertJArrayCount(2)
|
||||
.AssertJArrayContains("Debug")
|
||||
.AssertJArrayContains("Release");
|
||||
|
||||
var frameworkShortNames = projectInformation.RetrievePropertyAs<JArray>("Frameworks")
|
||||
.AssertJArrayCount(2)
|
||||
.Select(f => f["ShortName"].Value<string>());
|
||||
|
||||
Assert.Contains("netcoreapp1.0", frameworkShortNames);
|
||||
Assert.Contains("dnx451", frameworkShortNames);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(MessageTypes.RefreshDependencies, null)]
|
||||
[InlineData(MessageTypes.RestoreComplete, null)]
|
||||
[InlineData(MessageTypes.RestoreComplete, true)]
|
||||
[InlineData(MessageTypes.RestoreComplete, false)]
|
||||
public void RefreshDependenciesResultsAreConsistent(string messageType, bool? clearCache)
|
||||
{
|
||||
var projectPath = Path.Combine(_testAssetsManager.AssetsRoot, "EmptyNetCoreApp");
|
||||
Assert.True(Directory.Exists(projectPath));
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
var originalDependencies = client.DrainMessage(7).Single(m => m.MessageType == MessageTypes.Dependencies)
|
||||
.RetrievePayloadAs<JObject>();
|
||||
|
||||
if (clearCache.HasValue)
|
||||
{
|
||||
client.SendPayload(projectPath, messageType, new { Reset = clearCache.Value });
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SendPayload(projectPath, messageType);
|
||||
}
|
||||
|
||||
var refreshedDependencies = client.DrainTillFirst(MessageTypes.Dependencies).Payload.ToString();
|
||||
|
||||
Assert.Equal(originalDependencies.ToString(), refreshedDependencies.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DependencyDiagnsoticsAfterDependencies()
|
||||
{
|
||||
var projectPath = Path.Combine(_testAssetsManager.AssetsRoot, "EmptyConsoleApp");
|
||||
Assert.NotNull(projectPath);
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
var messages = client.DrainMessage(12)
|
||||
.Select(message => message.MessageType)
|
||||
.ToArray();
|
||||
|
||||
var expectDependencies = true;
|
||||
var expectDependencyDiagnostics = false;
|
||||
for (var i = 0; i < messages.Length; ++i)
|
||||
{
|
||||
if (messages[i] == MessageTypes.Dependencies)
|
||||
{
|
||||
Assert.True(expectDependencies);
|
||||
expectDependencies = false;
|
||||
expectDependencyDiagnostics = true;
|
||||
}
|
||||
else if (messages[i] == MessageTypes.DependencyDiagnostics)
|
||||
{
|
||||
Assert.True(expectDependencyDiagnostics);
|
||||
expectDependencyDiagnostics = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.False(expectDependencies);
|
||||
Assert.False(expectDependencyDiagnostics);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(4, 4)]
|
||||
[InlineData(5, 4)]
|
||||
[InlineData(3, 3)]
|
||||
public void DthStartup_ProtocolNegotiation(int requestVersion, int expectVersion)
|
||||
{
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.SetProtocolVersion(requestVersion);
|
||||
|
||||
var response = client.DrainTillFirst(MessageTypes.ProtocolVersion, TimeSpan.FromDays(1));
|
||||
response.EnsureSource(server, client);
|
||||
|
||||
Assert.Equal(expectVersion, response.Payload["Version"]?.Value<int>());
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DthStartup_ProtocolNegotiation_ZeroIsNoAllowed()
|
||||
{
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.SetProtocolVersion(0);
|
||||
|
||||
Assert.Throws<TimeoutException>(() =>
|
||||
{
|
||||
client.DrainTillFirst(MessageTypes.ProtocolVersion, timeout: TimeSpan.FromSeconds(1));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Project", "UnresolvedProjectSample", "EmptyLibrary", "Project")]
|
||||
[InlineData("Package", "UnresolvedPackageSample", "NoSuchPackage", null)]
|
||||
[InlineData("Package", "IncompatiblePackageSample", "Microsoft.Web.Administration", "Package")]
|
||||
public void DthCompilation_Initialize_UnresolvedDependency(string referenceType,
|
||||
string testProjectName,
|
||||
string expectedUnresolvedDependency,
|
||||
string expectedUnresolvedType)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
Console.WriteLine("Test is skipped on Linux");
|
||||
return;
|
||||
}
|
||||
|
||||
var projectPath = Path.Combine(_testAssetsManager.AssetsRoot, testProjectName);
|
||||
Assert.NotNull(projectPath);
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
|
||||
var referencesMessage = client.DrainTillFirst(MessageTypes.References, TimeSpan.FromDays(1))
|
||||
.EnsureSource(server, client);
|
||||
|
||||
if (referenceType == "Project")
|
||||
{
|
||||
var expectedUnresolvedProjectPath = Path.Combine(Path.GetDirectoryName(projectPath),
|
||||
expectedUnresolvedDependency,
|
||||
Project.FileName);
|
||||
|
||||
referencesMessage.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("ProjectReferences")
|
||||
.AssertJArrayCount(1)
|
||||
.RetrieveArraryElementAs<JObject>(0)
|
||||
.AssertProperty("Name", expectedUnresolvedDependency)
|
||||
.AssertProperty("Path", expectedUnresolvedProjectPath);
|
||||
}
|
||||
else if (referenceType == "Package")
|
||||
{
|
||||
referencesMessage.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("ProjectReferences")
|
||||
.AssertJArrayCount(0);
|
||||
}
|
||||
|
||||
var unresolveDependency = client.DrainTillFirst(MessageTypes.Dependencies)
|
||||
.EnsureSource(server, client)
|
||||
.RetrieveDependency(expectedUnresolvedDependency);
|
||||
|
||||
unresolveDependency.AssertProperty("Name", expectedUnresolvedDependency)
|
||||
.AssertProperty("DisplayName", expectedUnresolvedDependency)
|
||||
.AssertProperty("Resolved", false)
|
||||
.AssertProperty("Type", expectedUnresolvedType);
|
||||
|
||||
if (expectedUnresolvedType == "Project")
|
||||
{
|
||||
unresolveDependency.AssertProperty("Path", Path.Combine(Path.GetDirectoryName(projectPath),
|
||||
expectedUnresolvedDependency,
|
||||
Project.FileName));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.False(unresolveDependency["Path"].HasValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DthNegative_BrokenProjectPathInLockFile()
|
||||
{
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
// After restore the project is copied to another place so that
|
||||
// the relative path in project lock file is invalid.
|
||||
var movedProjectPath = _testAssetsManager.CreateTestInstance("BrokenProjectPathSample")
|
||||
.WithLockFiles()
|
||||
.TestRoot;
|
||||
|
||||
client.Initialize(movedProjectPath);
|
||||
|
||||
client.DrainTillFirst("Dependencies")
|
||||
.RetrieveDependency("EmptyLibrary")
|
||||
.AssertProperty<JArray>("Errors", errorsArray => errorsArray.Count == 1)
|
||||
.AssertProperty<JArray>("Warnings", warningsArray => warningsArray.Count == 0)
|
||||
.AssertProperty("Name", "EmptyLibrary")
|
||||
.AssertProperty("Resolved", false);
|
||||
|
||||
client.DrainTillFirst("DependencyDiagnostics")
|
||||
.RetrieveDependencyDiagnosticsCollection()
|
||||
.RetrieveDependencyDiagnosticsErrorAt(0)
|
||||
.AssertProperty<string>("FormattedMessage", message => message.Contains("error NU1002"))
|
||||
.RetrievePropertyAs<JObject>("Source")
|
||||
.AssertProperty("Name", "EmptyLibrary");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DthDependencies_UpdateGlobalJson_RefreshDependencies()
|
||||
{
|
||||
var assetsManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer"));
|
||||
var projectPath = assetsManager.CreateTestInstance("DthUpdateSearchPathSample").WithLockFiles().TestRoot;
|
||||
Assert.True(Directory.Exists(projectPath));
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
var testProject = Path.Combine(projectPath, "home", "src", "MainProject");
|
||||
|
||||
client.Initialize(testProject);
|
||||
|
||||
client.DrainTillFirst("ProjectInformation")
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("ProjectSearchPaths")
|
||||
.AssertJArrayCount(2);
|
||||
|
||||
client.DrainTillFirst("Dependencies")
|
||||
.RetrieveDependency("Newtonsoft.Json")
|
||||
.AssertProperty("Type", "Project")
|
||||
.AssertProperty("Resolved", true)
|
||||
.AssertProperty<JArray>("Errors", array => array.Count == 0, _ => "Dependency shouldn't contain any error.");
|
||||
|
||||
client.DrainTillFirst("DependencyDiagnostics")
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.AssertProperty<JArray>("Errors", array => array.Count == 0)
|
||||
.AssertProperty<JArray>("Warnings", array => array.Count == 0);
|
||||
|
||||
// Overwrite the global.json to remove search path to ext
|
||||
File.WriteAllText(
|
||||
Path.Combine(projectPath, "home", GlobalSettings.FileName),
|
||||
JsonConvert.SerializeObject(new { projects = new string[] { "src" } }));
|
||||
|
||||
client.SendPayload(testProject, "RefreshDependencies");
|
||||
|
||||
client.DrainTillFirst("ProjectInformation")
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("ProjectSearchPaths")
|
||||
.AssertJArrayCount(1)
|
||||
.AssertJArrayElement(0, Path.Combine(projectPath, "home", "src"));
|
||||
|
||||
client.DrainTillFirst("Dependencies")
|
||||
.RetrieveDependency("Newtonsoft.Json")
|
||||
.AssertProperty("Resolved", false)
|
||||
.AssertProperty("Type", "Project")
|
||||
.RetrievePropertyAs<JArray>("Errors")
|
||||
.AssertJArrayCount(1)
|
||||
.RetrieveArraryElementAs<JObject>(0)
|
||||
.AssertProperty("ErrorCode", ErrorCodes.NU1010);
|
||||
|
||||
client.DrainTillFirst("DependencyDiagnostics")
|
||||
.RetrieveDependencyDiagnosticsCollection()
|
||||
.RetrieveDependencyDiagnosticsErrorAt<JObject>(0)
|
||||
.AssertProperty("ErrorCode", ErrorCodes.NU1010);
|
||||
|
||||
var restoreCommand = new RestoreCommand();
|
||||
restoreCommand.WorkingDirectory = projectPath;
|
||||
restoreCommand.Execute().Should().Pass();
|
||||
|
||||
client.SendPayload(testProject, "RefreshDependencies");
|
||||
|
||||
client.DrainTillFirst("Dependencies")
|
||||
.RetrieveDependency("Newtonsoft.Json")
|
||||
.AssertProperty("Resolved", true)
|
||||
.AssertProperty("Type", "Package")
|
||||
.RetrievePropertyAs<JArray>("Errors")
|
||||
.AssertJArrayCount(0);
|
||||
|
||||
client.DrainTillFirst("DependencyDiagnostics")
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.AssertProperty<JArray>("Errors", array => array.Count == 0)
|
||||
.AssertProperty<JArray>("Warnings", array => array.Count == 0);
|
||||
|
||||
// Overwrite the global.json to add search path to ext back
|
||||
File.WriteAllText(
|
||||
Path.Combine(projectPath, "home", GlobalSettings.FileName),
|
||||
JsonConvert.SerializeObject(new { projects = new string[] { "src", "../ext" } }));
|
||||
|
||||
client.SendPayload(testProject, "RefreshDependencies");
|
||||
|
||||
client.DrainTillFirst("ProjectInformation")
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("ProjectSearchPaths")
|
||||
.AssertJArrayCount(2)
|
||||
.AssertJArrayElement(0, Path.Combine(projectPath, "home", "src"))
|
||||
.AssertJArrayElement(1, Path.Combine(projectPath, "ext"));
|
||||
|
||||
client.DrainTillFirst("Dependencies")
|
||||
.RetrieveDependency("Newtonsoft.Json")
|
||||
.AssertProperty("Resolved", false)
|
||||
.AssertProperty("Type", "Package")
|
||||
.RetrievePropertyAs<JArray>("Errors")
|
||||
.AssertJArrayCount(1)
|
||||
.RetrieveArraryElementAs<JObject>(0)
|
||||
.AssertProperty("ErrorCode", ErrorCodes.NU1010);
|
||||
|
||||
client.DrainTillFirst("DependencyDiagnostics")
|
||||
.RetrieveDependencyDiagnosticsCollection()
|
||||
.RetrieveDependencyDiagnosticsErrorAt<JObject>(0)
|
||||
.AssertProperty("ErrorCode", ErrorCodes.NU1010);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DthStartup_OpenProjectBeforeRestore()
|
||||
{
|
||||
var projectPath = _testAssetsManager.CreateTestInstance("EmptyConsoleApp").TestRoot;
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
var messages = client.DrainMessage(12);
|
||||
Assert.False(messages.Any(msg => msg.MessageType == MessageTypes.Error));
|
||||
|
||||
var dependencyDiagnostics = messages.Where(msg => msg.MessageType == MessageTypes.DependencyDiagnostics);
|
||||
Assert.Equal(2, dependencyDiagnostics.Count());
|
||||
|
||||
foreach (var message in dependencyDiagnostics)
|
||||
{
|
||||
message.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("Errors")
|
||||
.AssertJArrayContains<JObject>(error => error["ErrorCode"].Value<string>() == ErrorCodes.NU1009);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidProjectJson()
|
||||
{
|
||||
var testAssetsPath = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer");
|
||||
var assetsManager = new TestAssetsManager(testAssetsPath);
|
||||
var testSource = assetsManager.CreateTestInstance("IncorrectProjectJson").TestRoot;
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "EmptyLibrary"));
|
||||
client.Initialize(testSource);
|
||||
|
||||
// Error for invalid project.json
|
||||
var messages = client.DrainMessage(8);
|
||||
messages.Single(msg => msg.MessageType == MessageTypes.Error)
|
||||
.Payload.AsJObject()
|
||||
.AssertProperty<string>("Path", v => v.Contains("IncorrectProjectJson"));
|
||||
|
||||
// Successfully initialize the other project
|
||||
messages.Single(msg => msg.MessageType == MessageTypes.ProjectInformation)
|
||||
.Payload.AsJObject()
|
||||
.AssertProperty<string>("Name", v => string.Equals(v, "EmptyLibrary", StringComparison.Ordinal));
|
||||
|
||||
// Successfully initialize another project afterwards
|
||||
client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "EmptyConsoleApp"));
|
||||
client.DrainTillFirst(MessageTypes.ProjectInformation)
|
||||
.Payload.AsJObject()
|
||||
.AssertProperty<string>("Name", v => string.Equals(v, "EmptyConsoleApp", StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidGlobalJson()
|
||||
{
|
||||
var testAssetsPath = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer");
|
||||
var assetsManager = new TestAssetsManager(testAssetsPath);
|
||||
var testSource = assetsManager.CreateTestInstance("IncorrectGlobalJson");
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(Path.Combine(testSource.TestRoot, "src", "Project1"));
|
||||
|
||||
client.DrainTillFirst(MessageTypes.Error)
|
||||
.Payload.AsJObject()
|
||||
.AssertProperty<string>("Path", v => v.Contains("InvalidGlobalJson"));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RecoverFromGlobalError()
|
||||
{
|
||||
var testProject = _testAssetsManager.CreateTestInstance("EmptyConsoleApp")
|
||||
.WithLockFiles()
|
||||
.TestRoot;
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
var projectFile = Path.Combine(testProject, Project.FileName);
|
||||
var content = File.ReadAllText(projectFile);
|
||||
File.WriteAllText(projectFile, content + "}");
|
||||
|
||||
client.Initialize(testProject);
|
||||
client.DrainTillFirst(MessageTypes.Error);
|
||||
|
||||
File.WriteAllText(projectFile, content);
|
||||
client.SendPayload(testProject, MessageTypes.FilesChanged);
|
||||
client.DrainTillFirst(MessageTypes.Error)
|
||||
.Payload.AsJObject()
|
||||
.AssertProperty("Message", null as string);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(500, true)]
|
||||
[InlineData(3000, false)]
|
||||
public void WaitForLockFileReleased(int occupyFileFor, bool expectSuccess)
|
||||
{
|
||||
var testProject = _testAssetsManager.CreateTestInstance("EmptyConsoleApp")
|
||||
.WithLockFiles()
|
||||
.TestRoot;
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
var lockFilePath = Path.Combine(testProject, LockFile.FileName);
|
||||
var lockFileContent = File.ReadAllText(lockFilePath);
|
||||
var fs = new FileStream(lockFilePath, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
|
||||
// Test the platform
|
||||
// A sharing violation is expected in following code. Otherwise the FileSteam is not implemented correctly.
|
||||
Assert.ThrowsAny<IOException>(() =>
|
||||
{
|
||||
new FileStream(lockFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
});
|
||||
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
// WorkspaceContext will try to open the lock file for 3 times with 500 ms interval in between.
|
||||
Thread.Sleep(occupyFileFor);
|
||||
fs.Dispose();
|
||||
});
|
||||
|
||||
client.Initialize(testProject);
|
||||
if (expectSuccess)
|
||||
{
|
||||
client.DrainMessage(12).AssertDoesNotContain(MessageTypes.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.DrainTillFirst(MessageTypes.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddMSBuildReferenceBeforeRestore()
|
||||
{
|
||||
var tam = new TestAssetsManager(
|
||||
Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MSBuildReferencesProjects"));
|
||||
|
||||
// var appName = "EmptyNetCoreApp";
|
||||
var projectPath = tam.CreateTestInstance("ValidCase01").WithLockFiles().TestRoot;
|
||||
projectPath = Path.Combine(projectPath, "src", "MainApp");
|
||||
|
||||
var projectFilePath = Path.Combine(projectPath, Project.FileName);
|
||||
var projectJson = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(projectFilePath));
|
||||
|
||||
((JObject)projectJson["frameworks"]["net46"]["dependencies"])
|
||||
.Add("ClassLibrary4", JToken.FromObject(new { target = "project" }));
|
||||
|
||||
File.WriteAllText(projectFilePath, JsonConvert.SerializeObject(projectJson));
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
var messages = client.DrainMessage(7);
|
||||
messages.AssertDoesNotContain(MessageTypes.Error);
|
||||
messages.RetrieveSingleMessage(MessageTypes.Dependencies)
|
||||
.RetrieveDependency("ClassLibrary4")
|
||||
.AssertProperty<object>(
|
||||
"Version",
|
||||
v => !string.IsNullOrEmpty(v.ToString()),
|
||||
v => $"Version string shouldn't be empty. Value [{v.ToString()}]");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MSBuildReferenceTest()
|
||||
{
|
||||
var testProject = Path.Combine(RepoRoot, "TestAssets",
|
||||
"ProjectModelServer",
|
||||
"MSBuildReferencesProjects",
|
||||
"ValidCase01",
|
||||
"src",
|
||||
"MainApp");
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(testProject);
|
||||
var messages = client.DrainMessage(7);
|
||||
|
||||
var classLibraries = new HashSet<string>(new string[] { "ClassLibrary1", "ClassLibrary2", "ClassLibrary3" });
|
||||
var dependencies = messages.RetrieveSingleMessage(MessageTypes.Dependencies);
|
||||
var testProjectRoot = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MSBuildReferencesProjects", "ValidCase01");
|
||||
foreach (var classLibrary in classLibraries)
|
||||
{
|
||||
var dependency = dependencies.RetrieveDependency(classLibrary);
|
||||
dependency.AssertProperty("Type", LibraryType.MSBuildProject.ToString());
|
||||
dependency.AssertProperty("Path", NormalizePathString(Path.Combine(testProjectRoot, classLibrary, $"{classLibrary}.csproj")));
|
||||
dependency.AssertProperty<bool>("Resolved", true);
|
||||
dependency.AssertProperty("Name", classLibrary);
|
||||
dependency.AssertProperty<JArray>("Errors", array => array.Count == 0);
|
||||
dependency.AssertProperty<JArray>("Warnings", array => array.Count == 0);
|
||||
}
|
||||
|
||||
var references = messages.RetrieveSingleMessage(MessageTypes.References)
|
||||
.RetrievePayloadAs<JObject>();
|
||||
|
||||
var projectReferences = references.RetrievePropertyAs<JArray>("ProjectReferences");
|
||||
Assert.Equal(3, projectReferences.Count);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
var projectRef = projectReferences.RetrieveArraryElementAs<JObject>(i);
|
||||
var name = projectRef["Name"].Value<string>();
|
||||
|
||||
Assert.True(classLibraries.Contains(name));
|
||||
projectRef.AssertProperty("Path", NormalizePathString(Path.Combine(testProjectRoot, name, $"{name}.csproj")));
|
||||
}
|
||||
|
||||
var fileReferences = references.RetrievePropertyAs<JArray>("FileReferences")
|
||||
.Select(each => each.Value<string>())
|
||||
.ToArray();
|
||||
foreach (var each in classLibraries)
|
||||
{
|
||||
fileReferences.Contains(Path.Combine("ValidCase01", "ClassLibrary1", "bin", "Debug", $"{each}.dll"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemovePackageDependencyFromProjectJson()
|
||||
{
|
||||
// Remove a package dependency from project.json and then request refreshing dependency before
|
||||
// restore.
|
||||
|
||||
var appName = "EmptyNetCoreApp";
|
||||
var projectPath = _testAssetsManager.CreateTestInstance(appName)
|
||||
.WithLockFiles()
|
||||
.TestRoot;
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
|
||||
client.DrainMessage(7)
|
||||
.AssertDoesNotContain(MessageTypes.Error)
|
||||
.RetrieveSingleMessage(MessageTypes.Dependencies)
|
||||
.RetrieveDependency(appName)
|
||||
.RetrievePropertyAs<JArray>("Dependencies")
|
||||
.AssertJArrayCount(2);
|
||||
|
||||
var projectFilePath = Path.Combine(projectPath, Project.FileName);
|
||||
var projectJson = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(projectFilePath));
|
||||
|
||||
// Remove newtonsoft.json dependency
|
||||
var dependencies = projectJson["frameworks"]["netcoreapp1.0"]["dependencies"] as JObject;
|
||||
dependencies.Remove("Newtonsoft.Json");
|
||||
|
||||
File.WriteAllText(projectFilePath, JsonConvert.SerializeObject(projectJson));
|
||||
|
||||
client.SendPayload(projectPath, MessageTypes.RefreshDependencies);
|
||||
|
||||
var afterDependencies = client.DrainTillFirst(MessageTypes.Dependencies);
|
||||
afterDependencies.RetrieveDependency(appName)
|
||||
.RetrievePropertyAs<JArray>("Dependencies")
|
||||
.AssertJArrayCount(1)
|
||||
.RetrieveArraryElementAs<JObject>(0)
|
||||
.AssertProperty("Name", "Microsoft.NETCore.App");
|
||||
afterDependencies.RetrieveDependency("Newtonsoft.Json");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveMSBuildDependencyFromProjectJson()
|
||||
{
|
||||
// Remove a msbuild project dependency from project.json and then request refreshing dependency before
|
||||
// restore.
|
||||
|
||||
var tam = new TestAssetsManager(
|
||||
Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MSBuildReferencesProjects"));
|
||||
|
||||
// var appName = "EmptyNetCoreApp";
|
||||
var projectPath = tam.CreateTestInstance("ValidCase01").WithLockFiles().TestRoot;
|
||||
projectPath = Path.Combine(projectPath, "src", "MainApp");
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
|
||||
client.DrainMessage(7)
|
||||
.AssertDoesNotContain(MessageTypes.Error)
|
||||
.RetrieveSingleMessage(MessageTypes.Dependencies)
|
||||
.RetrieveDependency("MainApp")
|
||||
.RetrievePropertyAs<JArray>("Dependencies")
|
||||
.AssertJArrayContains<JObject>(dep => dep["Name"].Value<string>() == "ClassLibrary1")
|
||||
.AssertJArrayContains<JObject>(dep => dep["Name"].Value<string>() == "ClassLibrary2")
|
||||
.AssertJArrayContains<JObject>(dep => dep["Name"].Value<string>() == "ClassLibrary3");
|
||||
|
||||
var projectFilePath = Path.Combine(projectPath, Project.FileName);
|
||||
var projectJson = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(projectFilePath));
|
||||
|
||||
// Remove ClassLibrary2 and ClassLibrary3 dependency
|
||||
var dependencies = projectJson["frameworks"]["net46"]["dependencies"] as JObject;
|
||||
dependencies.Remove("ClassLibrary2");
|
||||
dependencies.Remove("ClassLibrary3");
|
||||
|
||||
File.WriteAllText(projectFilePath, JsonConvert.SerializeObject(projectJson));
|
||||
|
||||
client.SendPayload(projectPath, MessageTypes.RefreshDependencies);
|
||||
|
||||
var afterDependencies = client.DrainTillFirst(MessageTypes.Dependencies);
|
||||
afterDependencies.RetrieveDependency("MainApp")
|
||||
.RetrievePropertyAs<JArray>("Dependencies")
|
||||
.AssertJArrayNotContains<JObject>(dep => dep["Name"].Value<string>() == "ClassLibrary2")
|
||||
.AssertJArrayNotContains<JObject>(dep => dep["Name"].Value<string>() == "ClassLibrary3");
|
||||
|
||||
afterDependencies.RetrieveDependency("ClassLibrary2");
|
||||
afterDependencies.RetrieveDependency("ClassLibrary3");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMscorlibLibraryDuplication()
|
||||
{
|
||||
var projectPath = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MscorlibLibraryDuplication");
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
client.DrainMessage(7).AssertDoesNotContain(MessageTypes.Error);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTargetFrameworkChange()
|
||||
{
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
var testProject = _testAssetsManager.CreateTestInstance("EmptyLibrary")
|
||||
.WithLockFiles()
|
||||
.TestRoot;
|
||||
|
||||
// initialize the project and drain all messages (7 message for project with one framework)
|
||||
client.Initialize(testProject);
|
||||
client.DrainMessage(7);
|
||||
|
||||
// update the target framework from netstandard1.3 to netstandard 1.5 so as to invalidate all
|
||||
// dependencies
|
||||
var projectJsonPath = Path.Combine(testProject, "project.json");
|
||||
File.WriteAllText(projectJsonPath,
|
||||
File.ReadAllText(projectJsonPath).Replace("netstandard1.3", "netstandard1.5"));
|
||||
|
||||
// send files change request to server to prompt update
|
||||
client.SendPayload(testProject, MessageTypes.FilesChanged);
|
||||
|
||||
// assert project information is updated
|
||||
client.DrainTillFirst(MessageTypes.ProjectInformation)
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("Frameworks")
|
||||
.AssertJArrayCount(1)
|
||||
.RetrieveArraryElementAs<JObject>(0)
|
||||
.AssertProperty("ShortName", "netstandard1.5");
|
||||
|
||||
// the NETStandard.Library dependency should turn unresolved
|
||||
var dependencies = client.DrainTillFirst(MessageTypes.Dependencies);
|
||||
|
||||
dependencies.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JObject>("Framework")
|
||||
.AssertProperty("ShortName", "netstandard1.5");
|
||||
|
||||
dependencies.RetrieveDependency("NETStandard.Library")
|
||||
.RetrievePropertyAs<JArray>("Errors")
|
||||
.AssertJArrayCount(1)
|
||||
.RetrieveArraryElementAs<JObject>(0)
|
||||
.AssertProperty("ErrorCode", "NU1001");
|
||||
|
||||
// warning for project.json and project.lock.json out of sync
|
||||
var diagnostics = client.DrainTillFirst(MessageTypes.DependencyDiagnostics);
|
||||
|
||||
diagnostics.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JObject>("Framework")
|
||||
.AssertProperty("ShortName", "netstandard1.5");
|
||||
|
||||
diagnostics.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("Warnings")
|
||||
.AssertJArrayCount(1)
|
||||
.RetrieveArraryElementAs<JObject>(0)
|
||||
.AssertProperty("ErrorCode", "NU1006");
|
||||
|
||||
// restore again
|
||||
var restoreCommand = new RestoreCommand();
|
||||
restoreCommand.WorkingDirectory = testProject;
|
||||
restoreCommand.Execute().Should().Pass();
|
||||
|
||||
client.SendPayload(testProject, MessageTypes.RefreshDependencies);
|
||||
|
||||
client.DrainTillFirst(MessageTypes.Dependencies)
|
||||
.RetrieveDependency("NETStandard.Library")
|
||||
.RetrievePropertyAs<JArray>("Errors")
|
||||
.AssertJArrayCount(0);
|
||||
|
||||
client.DrainTillFirst(MessageTypes.DependencyDiagnostics)
|
||||
.RetrievePayloadAs<JObject>()
|
||||
.RetrievePropertyAs<JArray>("Warnings")
|
||||
.AssertJArrayCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
private static string NormalizePathString(string original)
|
||||
{
|
||||
return original.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
private static void PrintAllMessages(IEnumerable<DthMessage> messages)
|
||||
{
|
||||
foreach (var message in messages)
|
||||
{
|
||||
Console.WriteLine($"{message.MessageType} => {message.Payload.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public class DthMessage
|
||||
{
|
||||
public string HostId { get; set; }
|
||||
|
||||
public string MessageType { get; set; }
|
||||
|
||||
public int ContextId { get; set; }
|
||||
|
||||
public int Version { get; set; }
|
||||
|
||||
public JToken Payload { get; set; }
|
||||
|
||||
// for ProjectContexts message only
|
||||
public Dictionary<string, int> Projects { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. 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.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public static class DthMessageCollectionExtension
|
||||
{
|
||||
public static IList<DthMessage> GetMessagesByFramework(this IEnumerable<DthMessage> messages, FrameworkName targetFramework)
|
||||
{
|
||||
return messages.Where(msg => MatchesFramework(targetFramework, msg)).ToList();
|
||||
}
|
||||
|
||||
public static IList<DthMessage> GetMessagesByType(this IEnumerable<DthMessage> messages, string typename)
|
||||
{
|
||||
return messages.Where(msg => string.Equals(msg.MessageType, typename)).ToList();
|
||||
}
|
||||
|
||||
public static DthMessage RetrieveSingleMessage(this IEnumerable<DthMessage> messages,
|
||||
string typename)
|
||||
{
|
||||
var result = messages.SingleOrDefault(msg => string.Equals(msg.MessageType, typename, StringComparison.Ordinal));
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
if (messages.FirstOrDefault(msg => string.Equals(msg.MessageType, typename, StringComparison.Ordinal)) != null)
|
||||
{
|
||||
Assert.False(true, $"More than one {typename} messages exist.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.False(true, $"{typename} message doesn't exists.");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IEnumerable<DthMessage> ContainsMessage(this IEnumerable<DthMessage> messages,
|
||||
string typename)
|
||||
{
|
||||
var contain = messages.FirstOrDefault(msg => string.Equals(msg.MessageType, typename, StringComparison.Ordinal)) != null;
|
||||
|
||||
Assert.True(contain, $"Messages collection doesn't contain message of type {typename}.");
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public static IEnumerable<DthMessage> AssertDoesNotContain(this IEnumerable<DthMessage> messages, string typename)
|
||||
{
|
||||
var notContain = messages.FirstOrDefault(msg => string.Equals(msg.MessageType, typename, StringComparison.Ordinal)) == null;
|
||||
|
||||
Assert.True(notContain, $"Message collection contains message of type {typename}.");
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
private static bool MatchesFramework(FrameworkName targetFramework, DthMessage msg)
|
||||
{
|
||||
if (msg.Payload.Type != JTokenType.Object)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var frameworkObj = msg.Payload["Framework"];
|
||||
|
||||
if (frameworkObj == null || !frameworkObj.HasValues)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return string.Equals(frameworkObj.Value<string>("FrameworkName"), targetFramework.FullName, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public static class DthMessageExtension
|
||||
{
|
||||
public static JObject RetrieveDependency(this DthMessage message, string dependencyName)
|
||||
{
|
||||
Assert.NotNull(message);
|
||||
Assert.Equal(MessageTypes.Dependencies, message.MessageType);
|
||||
|
||||
var payload = message.Payload as JObject;
|
||||
Assert.NotNull(payload);
|
||||
|
||||
var dependency = payload[MessageTypes.Dependencies][dependencyName] as JObject;
|
||||
Assert.NotNull(dependency);
|
||||
Assert.Equal(dependencyName, dependency["Name"].Value<string>());
|
||||
|
||||
return dependency;
|
||||
}
|
||||
|
||||
public static DthMessage EnsureNotContainDependency(this DthMessage message, string dependencyName)
|
||||
{
|
||||
Assert.NotNull(message);
|
||||
Assert.Equal(MessageTypes.Dependencies, message.MessageType);
|
||||
|
||||
var payload = message.Payload as JObject;
|
||||
Assert.NotNull(payload);
|
||||
|
||||
Assert.True(payload[MessageTypes.Dependencies][dependencyName] == null, $"Unexpected dependency {dependencyName} exists.");
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static JObject RetrieveDependencyDiagnosticsCollection(this DthMessage message)
|
||||
{
|
||||
Assert.NotNull(message);
|
||||
Assert.Equal(MessageTypes.DependencyDiagnostics, message.MessageType);
|
||||
|
||||
var payload = message.Payload as JObject;
|
||||
Assert.NotNull(payload);
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
public static T RetrievePayloadAs<T>(this DthMessage message)
|
||||
where T : JToken
|
||||
{
|
||||
Assert.NotNull(message);
|
||||
AssertType<T>(message.Payload, "Payload");
|
||||
|
||||
return (T)message.Payload;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws if the message is not generated in communication between given server and client
|
||||
/// </summary>
|
||||
public static DthMessage EnsureSource(this DthMessage message, DthTestServer server, DthTestClient client)
|
||||
{
|
||||
if (message.HostId != server.HostId)
|
||||
{
|
||||
throw new Exception($"{nameof(message.HostId)} doesn't match the one of server. Expected {server.HostId} but actually {message.HostId}.");
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void AssertType<T>(object obj, string name)
|
||||
{
|
||||
Assert.True(obj is T, $"{name} is not of type {typeof(T).Name}.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public static class JArrayExtensions
|
||||
{
|
||||
public static JArray AssertJArrayEmpty(this JArray array)
|
||||
{
|
||||
Assert.NotNull(array);
|
||||
Assert.Empty(array);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JArray AssertJArrayNotEmpty(this JArray array)
|
||||
{
|
||||
Assert.NotNull(array);
|
||||
Assert.NotEmpty(array);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JArray AssertJArrayCount(this JArray array, int expectedCount)
|
||||
{
|
||||
Assert.NotNull(array);
|
||||
Assert.Equal(expectedCount, array.Count);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JArray AssertJArrayElement<T>(this JArray array, int index, T expectedElementValue)
|
||||
{
|
||||
Assert.NotNull(array);
|
||||
|
||||
var element = array[index];
|
||||
Assert.NotNull(element);
|
||||
Assert.Equal(expectedElementValue, element.Value<T>());
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JArray AssertJArrayContains<T>(this JArray array, T value)
|
||||
{
|
||||
AssertJArrayContains<T>(array, element => object.Equals(element, value));
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JArray AssertJArrayContains<T>(this JArray array, Func<T, bool> critiera)
|
||||
{
|
||||
bool contains = false;
|
||||
foreach (var element in array)
|
||||
{
|
||||
var value = element.Value<T>();
|
||||
|
||||
contains = critiera(value);
|
||||
if (contains)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(contains, "JArray doesn't contains the specified element.");
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JArray AssertJArrayNotContains<T>(this JArray array, Func<T, bool> critiera)
|
||||
{
|
||||
foreach (var element in array)
|
||||
{
|
||||
var value = element.Value<T>();
|
||||
|
||||
if (critiera(value))
|
||||
{
|
||||
Assert.True(false, "JArray contains unexpected element.");
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static T RetrieveArraryElementAs<T>(this JArray json, int index)
|
||||
where T : JToken
|
||||
{
|
||||
Assert.NotNull(json);
|
||||
Assert.True(index >= 0 && index < json.Count, "Index out of range");
|
||||
|
||||
var element = json[index];
|
||||
DthMessageExtension.AssertType<T>(element, $"Element at {index}");
|
||||
|
||||
return (T)element;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||
{
|
||||
public static class JObjectExtensions
|
||||
{
|
||||
public static JObject AsJObject(this JToken token)
|
||||
{
|
||||
DthMessageExtension.AssertType<JObject>(token, nameof(JToken));
|
||||
|
||||
return (JObject)token;
|
||||
}
|
||||
|
||||
public static JObject RetrieveDependencyDiagnosticsErrorAt(this JObject payload, int index)
|
||||
{
|
||||
Assert.NotNull(payload);
|
||||
|
||||
return payload.RetrievePropertyAs<JArray>("Errors")
|
||||
.RetrieveArraryElementAs<JObject>(index);
|
||||
}
|
||||
|
||||
public static T RetrieveDependencyDiagnosticsErrorAt<T>(this JObject payload, int index)
|
||||
where T : JToken
|
||||
{
|
||||
Assert.NotNull(payload);
|
||||
|
||||
return payload.RetrievePropertyAs<JArray>("Errors")
|
||||
.RetrieveArraryElementAs<T>(index);
|
||||
}
|
||||
|
||||
public static T RetrievePropertyAs<T>(this JObject json, string propertyName)
|
||||
where T : JToken
|
||||
{
|
||||
Assert.NotNull(json);
|
||||
|
||||
var property = json[propertyName];
|
||||
Assert.NotNull(property);
|
||||
DthMessageExtension.AssertType<T>(property, $"Property {propertyName}");
|
||||
|
||||
return (T)property;
|
||||
}
|
||||
|
||||
public static JObject AssertProperty<T>(this JObject json, string propertyName, T expectedPropertyValue)
|
||||
{
|
||||
Assert.NotNull(json);
|
||||
|
||||
var property = json[propertyName];
|
||||
Assert.NotNull(property);
|
||||
Assert.Equal(expectedPropertyValue, property.Value<T>());
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JObject AssertProperty<T>(this JObject json, string propertyName, Func<T, bool> assertion)
|
||||
{
|
||||
return AssertProperty<T>(json,
|
||||
propertyName,
|
||||
assertion,
|
||||
value => $"Assert failed on {propertyName}.");
|
||||
}
|
||||
|
||||
public static JObject AssertProperty<T>(this JObject json, string propertyName, Func<T, bool> assertion, Func<T, string> errorMessage)
|
||||
{
|
||||
Assert.NotNull(json);
|
||||
|
||||
var property = json[propertyName];
|
||||
Assert.False(property == null, $"Property {propertyName} doesn't exist.");
|
||||
|
||||
var propertyValue = property.Value<T>();
|
||||
Assert.False(propertyValue == null, $"Property {propertyName} of type {typeof(T).Name} doesn't exist.");
|
||||
|
||||
Assert.True(assertion(propertyValue),
|
||||
errorMessage(propertyValue));
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>11c77123-e4da-499f-8900-80c88c2c69f2</ProjectGuid>
|
||||
<RootNamespace>Microsoft.DotNet.ProjectModel.Server.Tests</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"dotnet": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.Win32.Registry": {
|
||||
"version": "4.0.0",
|
||||
"exclude": "Compile"
|
||||
},
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.DotNet.ProjectModel": {
|
||||
"target": "project"
|
||||
},
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "1.0.0-rc2-192208-24",
|
||||
"System.Net.NameResolution": "4.0.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": [
|
||||
"netstandardapp1.5",
|
||||
"dotnet5.4",
|
||||
"portable-net451+win8"
|
||||
]
|
||||
}
|
||||
},
|
||||
"testRunner": "xunit"
|
||||
}
|
Loading…
Add table
Reference in a new issue