提交 ef547b73 编写于 作者: B beep boop 提交者: RoslynTeam

Move Scripting to Open (changeset 1405186)

上级 146f9246
......@@ -18,7 +18,7 @@
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\..\..\..\Closed\Scripting\Test\CommonScriptingTest.csproj">
<ProjectReference Include="..\..\..\..\Scripting\Test\CommonScriptingTest.csproj">
<Project>{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}</Project>
<Name>CommonScriptingTest</Name>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
......
......@@ -52,7 +52,7 @@
<Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project>
<Name>BasicCodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\Closed\Scripting\Test\CommonScriptingTest.csproj">
<ProjectReference Include="..\..\..\Scripting\Test\CommonScriptingTest.csproj">
<Project>{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}</Project>
<Name>CommonScriptingTest</Name>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
......
......@@ -179,6 +179,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpEditorFeatures", "Edi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorFeatures", "EditorFeatures\Core\EditorFeatures.csproj", "{3CDEEAB7-2256-418A-BEB2-620B5CB16302}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicScripting", "Scripting\VisualBasic\BasicScripting.vbproj", "{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicScriptingTest", "Scripting\VisualBasicTest\BasicScriptingTest.vbproj", "{ABC7262E-1053-49F3-B846-E3091BB92E8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonScripting", "Scripting\Core\CommonScripting.csproj", "{12A68549-4E8C-42D6-8703-A09335F97997}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonScriptingTest", "Scripting\Test\CommonScriptingTest.csproj", "{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpScripting", "Scripting\CSharp\CSharpScripting.csproj", "{066F0DBD-C46C-4C20-AFEC-99829A172625}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpScriptingTest", "Scripting\CSharpTest\CSharpScriptingTest.csproj", "{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Compilers\Core\SharedCollections\SharedCollections.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
......@@ -1137,6 +1149,42 @@ Global
{3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Release|x64.ActiveCfg = Release|Any CPU
{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Debug|x64.ActiveCfg = Debug|Any CPU
{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Release|x64.ActiveCfg = Release|Any CPU
{ABC7262E-1053-49F3-B846-E3091BB92E8C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{ABC7262E-1053-49F3-B846-E3091BB92E8C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{ABC7262E-1053-49F3-B846-E3091BB92E8C}.Debug|x64.ActiveCfg = Debug|Any CPU
{ABC7262E-1053-49F3-B846-E3091BB92E8C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{ABC7262E-1053-49F3-B846-E3091BB92E8C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{ABC7262E-1053-49F3-B846-E3091BB92E8C}.Release|x64.ActiveCfg = Release|Any CPU
{12A68549-4E8C-42D6-8703-A09335F97997}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{12A68549-4E8C-42D6-8703-A09335F97997}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{12A68549-4E8C-42D6-8703-A09335F97997}.Debug|x64.ActiveCfg = Debug|Any CPU
{12A68549-4E8C-42D6-8703-A09335F97997}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{12A68549-4E8C-42D6-8703-A09335F97997}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{12A68549-4E8C-42D6-8703-A09335F97997}.Release|x64.ActiveCfg = Release|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Debug|x64.ActiveCfg = Debug|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Release|x64.ActiveCfg = Release|Any CPU
{066F0DBD-C46C-4C20-AFEC-99829A172625}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{066F0DBD-C46C-4C20-AFEC-99829A172625}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{066F0DBD-C46C-4C20-AFEC-99829A172625}.Debug|x64.ActiveCfg = Debug|Any CPU
{066F0DBD-C46C-4C20-AFEC-99829A172625}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{066F0DBD-C46C-4C20-AFEC-99829A172625}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{066F0DBD-C46C-4C20-AFEC-99829A172625}.Release|x64.ActiveCfg = Release|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Debug|x64.ActiveCfg = Debug|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Release|x64.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Roslyn.Utilities;
namespace Roslyn.Scripting.CSharp
{
public sealed class CSharpObjectFormatter : ObjectFormatter
{
public static readonly CSharpObjectFormatter Instance = new CSharpObjectFormatter();
private CSharpObjectFormatter()
{
}
public override object VoidDisplayString
{
get { return "<void>"; }
}
public override string NullLiteral
{
get { return ObjectDisplay.NullLiteral; }
}
public override string FormatLiteral(bool value)
{
return ObjectDisplay.FormatLiteral(value);
}
public override string FormatLiteral(string value, bool quote, bool useHexadecimalNumbers = false)
{
var options = ObjectDisplayOptions.None;
if (quote)
{
options |= ObjectDisplayOptions.UseQuotes;
}
if (useHexadecimalNumbers)
{
options |= ObjectDisplayOptions.UseHexadecimalNumbers;
}
return ObjectDisplay.FormatLiteral(value, options);
}
public override string FormatLiteral(char c, bool quote, bool includeCodePoints = false, bool useHexadecimalNumbers = false)
{
var options = ObjectDisplayOptions.None;
if (quote)
{
options |= ObjectDisplayOptions.UseQuotes;
}
if (includeCodePoints)
{
options |= ObjectDisplayOptions.IncludeCodePoints;
}
if (useHexadecimalNumbers)
{
options |= ObjectDisplayOptions.UseHexadecimalNumbers;
}
return ObjectDisplay.FormatLiteral(c, options);
}
public override string FormatLiteral(sbyte value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(byte value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(short value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(ushort value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(int value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(uint value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(long value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(ulong value, bool useHexadecimalNumbers = false)
{
return ObjectDisplay.FormatLiteral(value, GetObjectDisplayOptions(useHexadecimalNumbers));
}
public override string FormatLiteral(double value)
{
return ObjectDisplay.FormatLiteral(value, ObjectDisplayOptions.None);
}
public override string FormatLiteral(float value)
{
return ObjectDisplay.FormatLiteral(value, ObjectDisplayOptions.None);
}
public override string FormatLiteral(decimal value)
{
return ObjectDisplay.FormatLiteral(value, ObjectDisplayOptions.None);
}
public override string FormatTypeName(Type type, ObjectFormattingOptions options)
{
return GetPrimitiveTypeName(type) ?? AppendComplexTypeName(new StringBuilder(), type, options).ToString();
}
private static string GetPrimitiveTypeName(Type type)
{
switch (Type.GetTypeCode(type))
{
case TypeCode.Boolean: return "bool";
case TypeCode.Byte: return "byte";
case TypeCode.Char: return "char";
case TypeCode.Decimal: return "decimal";
case TypeCode.Double: return "double";
case TypeCode.Int16: return "short";
case TypeCode.Int32: return "int";
case TypeCode.Int64: return "long";
case TypeCode.SByte: return "sbyte";
case TypeCode.Single: return "float";
case TypeCode.String: return "string";
case TypeCode.UInt16: return "ushort";
case TypeCode.UInt32: return "uint";
case TypeCode.UInt64: return "ulong";
case TypeCode.Object:
case TypeCode.Empty:
case TypeCode.DBNull:
case TypeCode.DateTime:
default:
if (type == typeof(object))
{
return "object";
}
return null;
}
}
private StringBuilder AppendComplexTypeName(StringBuilder builder, Type type, ObjectFormattingOptions options)
{
if (type.IsArray)
{
builder.Append(FormatArrayTypeName(type, arrayOpt: null, options: options));
return builder;
}
// compiler generated (e.g. iterator/async)
string stateMachineName;
if (GeneratedNames.TryParseSourceMethodNameFromGeneratedName(type.Name, GeneratedNameKind.StateMachineType, out stateMachineName))
{
builder.Append(stateMachineName);
return builder;
}
if (type.IsGenericType)
{
// consolidated generic arguments (includes arguments of all declaring types):
Type[] genericArguments = type.GetGenericArguments();
if (type.DeclaringType != null)
{
List<Type> nestedTypes = new List<Type>();
do
{
nestedTypes.Add(type);
type = type.DeclaringType;
}
while (type != null);
int typeArgumentIndex = 0;
for (int i = nestedTypes.Count - 1; i >= 0; i--)
{
AppendTypeInstantiation(builder, nestedTypes[i], genericArguments, ref typeArgumentIndex, options);
if (i > 0)
{
builder.Append('.');
}
}
}
else
{
int typeArgumentIndex = 0;
return AppendTypeInstantiation(builder, type, genericArguments, ref typeArgumentIndex, options);
}
}
else if (type.DeclaringType != null)
{
builder.Append(type.Name.Replace('+', '.'));
}
else
{
builder.Append(type.Name);
}
return builder;
}
private StringBuilder AppendTypeInstantiation(StringBuilder builder, Type type, Type[] genericArguments, ref int genericArgIndex,
ObjectFormattingOptions options)
{
// generic arguments of all the outer types and the current type;
Type[] currentGenericArgs = type.GetGenericArguments();
int currentArgCount = currentGenericArgs.Length - genericArgIndex;
if (currentArgCount > 0)
{
int backtick = type.Name.IndexOf('`');
if (backtick > 0)
{
builder.Append(type.Name.Substring(0, backtick));
}
else
{
builder.Append(type.Name);
}
builder.Append('<');
for (int i = 0; i < currentArgCount; i++)
{
if (i > 0)
{
builder.Append(", ");
}
builder.Append(FormatTypeName(genericArguments[genericArgIndex++], options));
}
builder.Append('>');
}
else
{
builder.Append(type.Name);
}
return builder;
}
public override string FormatArrayTypeName(Array array, ObjectFormattingOptions options)
{
return FormatArrayTypeName(array.GetType(), array, options);
}
private string FormatArrayTypeName(Type arrayType, Array arrayOpt, ObjectFormattingOptions options)
{
StringBuilder sb = new StringBuilder();
// print the inner-most element type first:
Type elementType = arrayType.GetElementType();
while (elementType.IsArray)
{
elementType = elementType.GetElementType();
}
sb.Append(FormatTypeName(elementType, options));
// print all components of a jagged array:
Type type = arrayType;
do
{
if (arrayOpt != null)
{
sb.Append('[');
int rank = type.GetArrayRank();
bool anyNonzeroLowerBound = false;
for (int i = 0; i < rank; i++)
{
if (arrayOpt.GetLowerBound(i) > 0)
{
anyNonzeroLowerBound = true;
break;
}
}
for (int i = 0; i < rank; i++)
{
int lowerBound = arrayOpt.GetLowerBound(i);
long length = arrayOpt.GetLongLength(i);
if (i > 0)
{
sb.Append(", ");
}
if (anyNonzeroLowerBound)
{
AppendArrayBound(sb, lowerBound, options.UseHexadecimalNumbers);
sb.Append("..");
AppendArrayBound(sb, length + lowerBound, options.UseHexadecimalNumbers);
}
else
{
AppendArrayBound(sb, length, options.UseHexadecimalNumbers);
}
}
sb.Append(']');
arrayOpt = null;
}
else
{
AppendArrayRank(sb, type);
}
type = type.GetElementType();
}
while (type.IsArray);
return sb.ToString();
}
private void AppendArrayBound(StringBuilder sb, long bound, bool useHexadecimalNumbers)
{
if (bound <= Int32.MaxValue)
{
sb.Append(FormatLiteral((int)bound, useHexadecimalNumbers));
}
else
{
sb.Append(FormatLiteral(bound, useHexadecimalNumbers));
}
}
private static void AppendArrayRank(StringBuilder sb, Type arrayType)
{
sb.Append('[');
int rank = arrayType.GetArrayRank();
if (rank > 1)
{
sb.Append(',', rank - 1);
}
sb.Append(']');
}
public override string FormatMemberName(System.Reflection.MemberInfo member)
{
return member.Name;
}
public override bool IsHiddenMember(System.Reflection.MemberInfo member)
{
// Generated fields, e.g. "<property_name>k__BackingField"
return GeneratedNames.IsGeneratedMemberName(member.Name);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using System.Globalization;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Text;
namespace Roslyn.Scripting.CSharp
{
/// <summary>
/// A factory for creating and running csharp scripts.
/// </summary>
public sealed class CSharpScript : Script
{
private CSharpScript(string code, string path, ScriptOptions options, Type globalsType, Type returnType, ScriptBuilder builder, Script previous)
: base(code, path, options, globalsType, returnType, builder, previous)
{
}
internal override Script Make(string code, string path, ScriptOptions options, Type globalsType, Type returnType, ScriptBuilder builder, Script previous)
{
return new CSharpScript(code, path, options, globalsType, returnType, builder, previous);
}
/// <summary>
/// Create a new C# script.
/// <param name="code">The source code of the script.</param>
/// <param name="options">The script options.</param>
/// </summary>
public static Script Create(string code, ScriptOptions options)
{
return new CSharpScript(code, null, options, null, typeof(object), null, null);
}
/// <summary>
/// Create a new C# script.
/// <param name="code">The source code of the script.</param>
/// </summary>
public static Script Create(string code)
{
return Create(code, null);
}
/// <summary>
/// Run a C# script.
/// </summary>
/// <param name="code">The source code of the script.</param>
/// <param name="options">The script options.</param>
/// <param name="globals">An object instance whose members can be accessed by the script as global variables,
/// or a <see cref="ScriptState"/> instance that was the output from a previously run script.</param>
public static ScriptState Run(string code, ScriptOptions options, object globals)
{
return Create(code, options).Run(globals);
}
/// <summary>
/// Run a C# script.
/// </summary>
/// <param name="code">The source code of the script.</param>
/// <param name="options">The script options.</param>
public static ScriptState Run(string code, ScriptOptions options)
{
return Run(code, options, globals: null);
}
/// <summary>
/// Run a C# script.
/// </summary>
/// <param name="code">The source code of the script.</param>
/// <param name="globals">An object instance whose members can be accessed by the script as global variables,
/// or a <see cref="ScriptState"/> instance that was the output from a previously run script.</param>
public static ScriptState Run(string code, object globals)
{
return Run(code, options: null, globals: globals);
}
/// <summary>
/// Run a C# script.
/// </summary>
/// <param name="code">The source code of the script.</param>
public static ScriptState Run(string code)
{
return Run(code, null, null);
}
/// <summary>
/// Run a C# script and return its resulting value.
/// </summary>
/// <param name="code">The source code of the script.</param>
/// <param name="options">The script options.</param>
/// <param name="globals">An object instance whose members can be accessed by the script as global variables,
/// or a <see cref="ScriptState"/> instance that was the output from a previously run script.</param>
/// <return>Returns the value returned by running the script.</return>
public static object Eval(string code, ScriptOptions options, object globals)
{
return Run(code, options, globals).ReturnValue;
}
/// <summary>
/// Run a C# script and return its resulting value.
/// </summary>
/// <param name="code">The source code of the script.</param>
/// <param name="options">The script options.</param>
/// <return>Returns the value returned by running the script.</return>
public static object Eval(string code, ScriptOptions options)
{
return Run(code, options).ReturnValue;
}
/// <summary>
/// Run a C# script and return its resulting value.
/// </summary>
/// <param name="code">The source code of the script.</param>
/// <param name="globals">An object instance whose members can be accessed by the script as global variables,
/// or a <see cref="ScriptState"/> instance that was the output from a previously run script.</param>
/// <return>Returns the value returned by running the script.</return>
public static object Eval(string code, object globals)
{
return Run(code, globals).ReturnValue;
}
/// <summary>
/// Run a C# script and return its resulting value.
/// </summary>
/// <param name="code">The source code of the script.</param>
/// <return>Returns the value returned by running the script.</return>
public static object Eval(string code)
{
return Run(code).ReturnValue;
}
#region Compilation
private static readonly CSharpParseOptions s_defaultInteractive = new CSharpParseOptions(languageVersion: LanguageVersion.CSharp6, kind: SourceCodeKind.Interactive);
private static readonly CSharpParseOptions s_defaultScript = new CSharpParseOptions(languageVersion: LanguageVersion.CSharp6, kind: SourceCodeKind.Script);
protected override Compilation CreateCompilation()
{
Compilation previousSubmission = null;
if (this.Previous != null)
{
previousSubmission = this.Previous.GetCompilation();
}
var references = this.GetReferencesForCompilation();
var parseOptions = this.Options.IsInteractive ? s_defaultInteractive : s_defaultScript;
var tree = SyntaxFactory.ParseSyntaxTree(this.Code, parseOptions, path: this.Path);
string assemblyName, submissionTypeName;
this.Builder.GenerateSubmissionId(out assemblyName, out submissionTypeName);
var compilation = CSharpCompilation.CreateSubmission(
assemblyName,
tree,
references,
new CSharpCompilationOptions(
outputKind: OutputKind.DynamicallyLinkedLibrary,
mainTypeName: null,
scriptClassName: submissionTypeName,
usings: this.Options.Namespaces,
optimizationLevel: OptimizationLevel.Debug, // TODO
checkOverflow: false, // TODO
allowUnsafe: true, // TODO
platform: Platform.AnyCpu,
warningLevel: 4,
xmlReferenceResolver: null, // don't support XML file references in interactive (permissions & doc comment includes)
sourceReferenceResolver: SourceFileResolver.Default, // TODO
metadataReferenceResolver: this.Options.ReferenceResolver,
assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default
),
previousSubmission,
this.ReturnType,
this.GlobalsType
);
return compilation;
}
protected override string FormatDiagnostic(Diagnostic diagnostic, CultureInfo culture)
{
return CSharpDiagnosticFormatter.Instance.Format(diagnostic, culture);
}
#endregion
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="Settings">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Settings.targets" />
<Import Project="..\..\..\build\VSL.Settings.Closed.targets" />
</ImportGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{066F0DBD-C46C-4C20-AFEC-99829A172625}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Roslyn.Scripting.CSharp</RootNamespace>
<AssemblyName>Roslyn.Scripting.CSharp</AssemblyName>
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Desktop\CodeAnalysis.Desktop.csproj">
<Project>{dfa21ca1-7f96-47ee-940c-069858e81727}</Project>
<Name>CodeAnalysis.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\Core\Portable\CodeAnalysis.csproj">
<Project>{1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}</Project>
<Name>CodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\CSharp\Portable\CSharpCodeAnalysis.csproj">
<Project>{B501A547-C911-4A05-AC6E-274A50DFF30E}</Project>
<Name>CSharpCodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\Core\CommonScripting.csproj">
<Project>{12A68549-4E8C-42D6-8703-A09335F97997}</Project>
<Name>CommonScripting</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Any CPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Any CPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
<PlatformTarget>ARM</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
<PlatformTarget>ARM</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSharpObjectFormatter.cs" />
<Compile Include="CSharpScript.cs" />
<Compile Include="CSharpScriptingResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>CSharpScriptingResources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Emit.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.Emit.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Scripting.Common.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Scripting.CSharp.UnitTests" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="CSharpScriptingResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>CSharpScriptingResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ImportGroup Label="Targets">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18210
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Roslyn.Scripting.CSharp {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class CSharpScriptingResources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal CSharpScriptingResources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Roslyn.Scripting.CSharp.CSharpScriptingResources", typeof(CSharpScriptingResources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="net45" />
</packages>
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
namespace Roslyn.Scripting.CSharp
{
/// <summary>
/// Represents a runtime execution context for C# scripts.
/// </summary>
internal sealed class CSharpScriptEngine : ScriptEngine
{
public CSharpScriptEngine(MetadataFileReferenceProvider metadataReferenceProvider = null, AssemblyLoader assemblyLoader = null)
: base(metadataReferenceProvider, assemblyLoader)
{
}
internal override Script Create(string code, ScriptOptions options, Type globalsType, Type returnType)
{
return CSharpScript.Create(code, options).WithGlobalsType(globalsType).WithReturnType(returnType).WithBuilder(this.Builder);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="Settings">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Settings.targets" />
<Import Project="..\..\..\build\VSL.Settings.Closed.targets" />
</ImportGroup>
<PropertyGroup>
<Nonshipping>true</Nonshipping>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Roslyn.Scripting.CSharpTest</RootNamespace>
<AssemblyName>Roslyn.Scripting.CSharp.UnitTests</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Desktop\CodeAnalysis.Desktop.csproj">
<Project>{dfa21ca1-7f96-47ee-940c-069858e81727}</Project>
<Name>CodeAnalysis.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\Core\Portable\CodeAnalysis.csproj">
<Project>{1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}</Project>
<Name>CodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\CSharp\Desktop\CSharpCodeAnalysis.Desktop.csproj">
<Project>{079af8ef-1058-48b6-943f-ab02d39e0641}</Project>
<Name>CSharpCodeAnalysis.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\CSharp\Portable\CSharpCodeAnalysis.csproj">
<Project>{B501A547-C911-4A05-AC6E-274A50DFF30E}</Project>
<Name>CSharpCodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\VisualBasic\Desktop\BasicCodeAnalysis.Desktop.vbproj">
<Project>{73f3e2c5-d742-452e-b9e1-20732ddbc75d}</Project>
<Name>BasicCodeAnalysis.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\VisualBasic\Portable\BasicCodeAnalysis.vbproj">
<Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project>
<Name>BasicCodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\Test\Resources\Core\CompilerTestResources.vbproj">
<Project>{7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}</Project>
<Name>CompilerTestResources</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\Test\Utilities\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\Core\CommonScripting.csproj">
<Project>{12A68549-4E8C-42D6-8703-A09335F97997}</Project>
<Name>CommonScripting</Name>
</ProjectReference>
<ProjectReference Include="..\Test\CommonScriptingTest.csproj">
<Project>{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}</Project>
<Name>CommonScriptingTest</Name>
</ProjectReference>
<ProjectReference Include="..\CSharp\CSharpScripting.csproj">
<Project>{066F0DBD-C46C-4C20-AFEC-99829A172625}</Project>
<Name>CSharpScripting</Name>
</ProjectReference>
<ProjectReference Include="..\..\Test\Utilities\TestUtilities.csproj">
<Project>{76C6F005-C89D-4348-BB4A-391898DBEB52}</Project>
<Name>TestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\CSharp\Test\Symbol\CSharpCompilerSymbolTest.csproj">
<Project>{28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}</Project>
<Name>CSharpCompilerSymbolTest</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compilers\Test\Utilities\Core2\CompilerTestUtilities2.csproj">
<Project>{F7712928-1175-47B3-8819-EE086753DEE2}</Project>
<Name>CompilerTestUtilities2</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="xunit">
<HintPath>..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSharpScriptEngine.cs" />
<Compile Include="InteractiveSessionTests.cs" />
<Compile Include="ObjectFormatterTests.cs" />
<Compile Include="ScriptTests.cs" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ImportGroup Label="Targets">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="..\..\..\build\Roslyn.Toolsets.Xunit.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
此差异已折叠。
此差异已折叠。
此差异已折叠。
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="StyleCop.MSBuild" version="4.7.48.2" targetFramework="net45" developmentDependency="true" />
<package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="net45" />
<package id="xunit" version="1.9.2" targetFramework="net45" />
</packages>
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Roslyn.Scripting
{
/// <summary>
/// The result of loading an assembly reference to the interactive session.
/// </summary>
[Serializable]
public struct AssemblyLoadResult
{
private readonly string _path;
private readonly string _originalPath;
private readonly bool _successful;
internal static AssemblyLoadResult CreateSuccessful(string path, string originalPath)
{
return new AssemblyLoadResult(path, originalPath, successful: true);
}
internal static AssemblyLoadResult CreateAlreadyLoaded(string path, string originalPath)
{
return new AssemblyLoadResult(path, originalPath, successful: false);
}
private AssemblyLoadResult(string path, string originalPath, bool successful)
{
_path = path;
_originalPath = originalPath;
_successful = successful;
}
/// <summary>
/// True if the assembly was loaded by the assembly loader, false if has been loaded before.
/// </summary>
public bool IsSuccessful
{
get { return _successful; }
}
/// <summary>
/// Full path to the physical assembly file (might be a shadow-copy of the original assembly file).
/// </summary>
public string Path
{
get { return _path; }
}
/// <summary>
/// Original assembly file path.
/// </summary>
public string OriginalPath
{
get { return _originalPath; }
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis;
using System.Reflection;
namespace Roslyn.Scripting
{
/// <summary>
/// Loads assemblies for Reflection based APIs.
/// </summary>
public abstract class AssemblyLoader
{
private sealed class _Default : AssemblyLoader
{
public override Assembly Load(AssemblyIdentity identity, string location = null)
{
return Assembly.Load(identity.ToAssemblyName());
}
}
internal static readonly AssemblyLoader Default = new _Default();
/// <summary>
/// Loads an assembly given its full name.
/// </summary>
/// <param name="identity">The identity of the assembly to load.</param>
/// <param name="location">Location of the assembly.</param>
/// <returns>The loaded assembly.</returns>
public abstract Assembly Load(AssemblyIdentity identity, string location = null);
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
namespace Roslyn.Scripting
{
/// <summary>
/// An exception thrown when the compilation stage of interactive execution produces compilation errors.
/// </summary>
public class CompilationErrorException : Exception
{
private readonly ImmutableArray<Diagnostic> _diagnostics;
internal CompilationErrorException(string message, ImmutableArray<Diagnostic> diagnostics)
: base(message)
{
_diagnostics = diagnostics;
}
/// <summary>
/// The list of diagnostics produced by compilation.
/// </summary>
public ImmutableArray<Diagnostic> Diagnostics
{
get { return _diagnostics; }
}
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="net45" />
</packages>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册