Add source code from RefactoringEssentials (old namespaces)
This commit is contained in:
Родитель
d546e02633
Коммит
465df3f77f
|
@ -0,0 +1,112 @@
|
|||
; Top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
|
||||
[*.csproj]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
[*.config]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.vsixmanifest]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.vsct]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.cs]
|
||||
# New line preferences
|
||||
csharp_new_line_before_open_brace = methods, types
|
||||
csharp_new_line_before_else = false
|
||||
csharp_new_line_before_catch = false
|
||||
csharp_new_line_before_finally = false
|
||||
csharp_new_line_before_members_in_object_initializers = false
|
||||
csharp_new_line_before_members_in_anonymous_types = false
|
||||
csharp_new_line_within_query_expression_clauses = false
|
||||
|
||||
# Indentation preferences
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = one_less
|
||||
|
||||
# Avoid 'this.' in generated code unless absolutely necessary, but allow developers to use it
|
||||
dotnet_style_qualification_for_field = false:silent
|
||||
dotnet_style_qualification_for_property = false:silent
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
dotnet_style_qualification_for_event = false:silent
|
||||
|
||||
# Do not use 'var' when generating code, but allow developers to use it
|
||||
csharp_style_var_for_built_in_types = false:silent
|
||||
csharp_style_var_when_type_is_apparent = false:silent
|
||||
csharp_style_var_elsewhere = false:silent
|
||||
|
||||
# Use language keywords instead of BCL types when generating code, but allow developers to use either
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
|
||||
dotnet_style_predefined_type_for_member_access = true:silent
|
||||
|
||||
# Using directives
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# Wrapping
|
||||
csharp_preserve_single_line_blocks = true
|
||||
csharp_preserve_single_line_statements = true
|
||||
|
||||
# Code style
|
||||
csharp_prefer_braces = true:silent
|
||||
|
||||
# Expression-level preferences
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
|
||||
# Expression-bodied members
|
||||
csharp_style_expression_bodied_methods = false:silent
|
||||
csharp_style_expression_bodied_constructors = false:silent
|
||||
csharp_style_expression_bodied_operators = false:silent
|
||||
csharp_style_expression_bodied_properties = true:silent
|
||||
csharp_style_expression_bodied_indexers = true:silent
|
||||
csharp_style_expression_bodied_accessors = true:silent
|
||||
|
||||
# Pattern matching
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||
csharp_style_inlined_variable_declaration = true:suggestion
|
||||
|
||||
# Null checking preferences
|
||||
csharp_style_throw_expression = true:suggestion
|
||||
csharp_style_conditional_delegate_call = true:suggestion
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_around_declaration_statements = do_not_ignore
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<solution>
|
||||
<add key="disableSourceControlIntegration" value="true" />
|
||||
</solution>
|
||||
</configuration>
|
Двоичный файл не отображается.
|
@ -0,0 +1,144 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||
|
||||
<!-- Enable the restore command to run before builds -->
|
||||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||
|
||||
<!-- Property that enables building a package from a project -->
|
||||
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||
|
||||
<!-- Determines if package restore consent is required to restore packages -->
|
||||
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||
|
||||
<!-- Download NuGet.exe if it does not already exist -->
|
||||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
|
||||
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
|
||||
<!--
|
||||
<PackageSource Include="https://www.nuget.org/api/v2/" />
|
||||
<PackageSource Include="https://my-nuget-source/nuget/" />
|
||||
-->
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||
<!-- Windows specific commands -->
|
||||
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
|
||||
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
|
||||
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- NuGet command -->
|
||||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
|
||||
|
||||
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
|
||||
|
||||
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||
|
||||
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
|
||||
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
|
||||
|
||||
<!-- Commands -->
|
||||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||
|
||||
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||
RestorePackages;
|
||||
$(BuildDependsOn);
|
||||
</BuildDependsOn>
|
||||
|
||||
<!-- Make the build depend on restore packages -->
|
||||
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||
$(BuildDependsOn);
|
||||
BuildPackage;
|
||||
</BuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="CheckPrerequisites">
|
||||
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||
<!--
|
||||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||
parallel builds will have to wait for it to complete.
|
||||
-->
|
||||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="_DownloadNuGet">
|
||||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(BuildCommand)"
|
||||
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||
|
||||
<Exec Command="$(BuildCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
</Target>
|
||||
|
||||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<OutputFilename ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.Core" />
|
||||
<Using Namespace="System" />
|
||||
<Using Namespace="System.IO" />
|
||||
<Using Namespace="System.Net" />
|
||||
<Using Namespace="Microsoft.Build.Framework" />
|
||||
<Using Namespace="Microsoft.Build.Utilities" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
try {
|
||||
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||
|
||||
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.LogErrorFromException(ex);
|
||||
return false;
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
</Project>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NuGet.CommandLine" version="3.4.4-rtm-final" />
|
||||
</packages>
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2010
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.CodeConverter", "ICSharpCode.CodeConverter\ICSharpCode.CodeConverter.csproj", "{7EA075C6-6406-445C-AB77-6C47AFF88D58}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeConverterWebApp", "Web\CodeConverterWebApp.csproj", "{D1FF18B5-68A8-439B-9D00-C35258AA7833}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{21DBA1CE-AF55-4159-B04B-B8C621BE8921}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vsix", "Vsix\Vsix.csproj", "{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{40A4828C-D6D2-43C5-A452-36CB06649680}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Mono_Debug|Any CPU = Mono_Debug|Any CPU
|
||||
Mono_Release|Any CPU = Mono_Release|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Mono_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Mono_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Mono_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Mono_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7EA075C6-6406-445C-AB77-6C47AFF88D58}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Mono_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Mono_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Mono_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Mono_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D1FF18B5-68A8-439B-9D00-C35258AA7833}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Mono_Debug|Any CPU.ActiveCfg = Mono_Debug|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Mono_Debug|Any CPU.Build.0 = Mono_Debug|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Mono_Release|Any CPU.ActiveCfg = Mono_Release|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Mono_Release|Any CPU.Build.0 = Mono_Release|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{21DBA1CE-AF55-4159-B04B-B8C621BE8921}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Mono_Debug|Any CPU.ActiveCfg = Mono_Debug|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Mono_Debug|Any CPU.Build.0 = Mono_Debug|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Mono_Release|Any CPU.ActiveCfg = Mono_Release|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Mono_Release|Any CPU.Build.0 = Mono_Release|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B87DD8E0-BF04-46F6-A98F-76F93AFD2988}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,401 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using VBasic = Microsoft.CodeAnalysis.VisualBasic;
|
||||
using VBSyntax = Microsoft.CodeAnalysis.VisualBasic.Syntax;
|
||||
|
||||
namespace RefactoringEssentials.CSharp.Converter
|
||||
{
|
||||
public partial class VisualBasicConverter
|
||||
{
|
||||
class MethodBodyVisitor : VBasic.VisualBasicSyntaxVisitor<SyntaxList<StatementSyntax>>
|
||||
{
|
||||
SemanticModel semanticModel;
|
||||
NodesVisitor nodesVisitor;
|
||||
private readonly Stack<string> withBlockTempVariableNames;
|
||||
|
||||
public bool IsIterator { get; set; }
|
||||
|
||||
public MethodBodyVisitor(SemanticModel semanticModel, NodesVisitor nodesVisitor, Stack<string> withBlockTempVariableNames)
|
||||
{
|
||||
this.semanticModel = semanticModel;
|
||||
this.nodesVisitor = nodesVisitor;
|
||||
this.withBlockTempVariableNames = withBlockTempVariableNames;
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> DefaultVisit(SyntaxNode node)
|
||||
{
|
||||
throw new NotImplementedException(node.GetType() + " not implemented!");
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitStopOrEndStatement(VBSyntax.StopOrEndStatementSyntax node)
|
||||
{
|
||||
return SingleStatement(SyntaxFactory.ParseStatement(GetCSharpEquivalentStatementText(node)));
|
||||
}
|
||||
|
||||
private static string GetCSharpEquivalentStatementText(VBSyntax.StopOrEndStatementSyntax node)
|
||||
{
|
||||
switch (VBasic.VisualBasicExtensions.Kind(node.StopOrEndKeyword)) {
|
||||
case VBasic.SyntaxKind.StopKeyword:
|
||||
return "System.Diagnostics.Debugger.Break();";
|
||||
case VBasic.SyntaxKind.EndKeyword:
|
||||
return "System.Environment.Exit(0);";
|
||||
default:
|
||||
throw new NotImplementedException(node.StopOrEndKeyword.Kind() + " not implemented!");
|
||||
}
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitLocalDeclarationStatement(VBSyntax.LocalDeclarationStatementSyntax node)
|
||||
{
|
||||
var modifiers = ConvertModifiers(node.Modifiers, TokenContext.Local);
|
||||
|
||||
var declarations = new List<LocalDeclarationStatementSyntax>();
|
||||
|
||||
foreach (var declarator in node.Declarators)
|
||||
foreach (var decl in SplitVariableDeclarations(declarator, nodesVisitor, semanticModel))
|
||||
declarations.Add(SyntaxFactory.LocalDeclarationStatement(modifiers, decl.Value));
|
||||
|
||||
return SyntaxFactory.List<StatementSyntax>(declarations);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitAddRemoveHandlerStatement(VBSyntax.AddRemoveHandlerStatementSyntax node)
|
||||
{
|
||||
var syntaxKind = node.Kind() == VBasic.SyntaxKind.AddHandlerStatement ? SyntaxKind.AddAssignmentExpression : SyntaxKind.SubtractAssignmentExpression;
|
||||
return SingleStatement(SyntaxFactory.AssignmentExpression(syntaxKind,
|
||||
(ExpressionSyntax)node.EventExpression.Accept(nodesVisitor),
|
||||
(ExpressionSyntax)node.DelegateExpression.Accept(nodesVisitor)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitExpressionStatement(VBSyntax.ExpressionStatementSyntax node)
|
||||
{
|
||||
return SingleStatement((ExpressionSyntax)node.Expression.Accept(nodesVisitor));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitAssignmentStatement(VBSyntax.AssignmentStatementSyntax node)
|
||||
{
|
||||
var kind = ConvertToken(node.Kind(), TokenContext.Local);
|
||||
return SingleStatement(SyntaxFactory.AssignmentExpression(kind, (ExpressionSyntax)node.Left.Accept(nodesVisitor), (ExpressionSyntax)node.Right.Accept(nodesVisitor)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitThrowStatement(VBSyntax.ThrowStatementSyntax node)
|
||||
{
|
||||
return SingleStatement(SyntaxFactory.ThrowStatement((ExpressionSyntax)node.Expression?.Accept(nodesVisitor)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitReturnStatement(VBSyntax.ReturnStatementSyntax node)
|
||||
{
|
||||
if (IsIterator)
|
||||
return SingleStatement(SyntaxFactory.YieldStatement(SyntaxKind.YieldBreakStatement));
|
||||
return SingleStatement(SyntaxFactory.ReturnStatement((ExpressionSyntax)node.Expression?.Accept(nodesVisitor)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitContinueStatement(VBSyntax.ContinueStatementSyntax node)
|
||||
{
|
||||
return SingleStatement(SyntaxFactory.ContinueStatement());
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitYieldStatement(VBSyntax.YieldStatementSyntax node)
|
||||
{
|
||||
return SingleStatement(SyntaxFactory.YieldStatement(SyntaxKind.YieldReturnStatement, (ExpressionSyntax)node.Expression?.Accept(nodesVisitor)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitExitStatement(VBSyntax.ExitStatementSyntax node)
|
||||
{
|
||||
switch (VBasic.VisualBasicExtensions.Kind(node.BlockKeyword)) {
|
||||
case VBasic.SyntaxKind.SubKeyword:
|
||||
return SingleStatement(SyntaxFactory.ReturnStatement());
|
||||
case VBasic.SyntaxKind.FunctionKeyword:
|
||||
VBasic.VisualBasicSyntaxNode typeContainer = (VBasic.VisualBasicSyntaxNode)node.Ancestors().OfType<VBSyntax.LambdaExpressionSyntax>().FirstOrDefault()
|
||||
?? node.Ancestors().OfType<VBSyntax.MethodBlockSyntax>().FirstOrDefault();
|
||||
var info = typeContainer.TypeSwitch(
|
||||
(VBSyntax.LambdaExpressionSyntax e) => semanticModel.GetTypeInfo(e).Type.GetReturnType(),
|
||||
(VBSyntax.MethodBlockSyntax e) => {
|
||||
var type = (TypeSyntax)e.SubOrFunctionStatement.AsClause?.Type.Accept(nodesVisitor) ?? SyntaxFactory.ParseTypeName("object");
|
||||
return semanticModel.GetSymbolInfo(type).Symbol.GetReturnType();
|
||||
}
|
||||
);
|
||||
ExpressionSyntax expr;
|
||||
if (info.IsReferenceType)
|
||||
expr = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression);
|
||||
else if (info.CanBeReferencedByName)
|
||||
expr = SyntaxFactory.DefaultExpression(SyntaxFactory.ParseTypeName(info.ToMinimalDisplayString(semanticModel, node.SpanStart)));
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
return SingleStatement(SyntaxFactory.ReturnStatement(expr));
|
||||
default:
|
||||
return SingleStatement(SyntaxFactory.BreakStatement());
|
||||
}
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitRaiseEventStatement(VBSyntax.RaiseEventStatementSyntax node)
|
||||
{
|
||||
return SingleStatement(
|
||||
SyntaxFactory.ConditionalAccessExpression(
|
||||
(ExpressionSyntax)node.Name.Accept(nodesVisitor),
|
||||
SyntaxFactory.InvocationExpression(
|
||||
SyntaxFactory.MemberBindingExpression(SyntaxFactory.IdentifierName("Invoke")),
|
||||
(ArgumentListSyntax)node.ArgumentList.Accept(nodesVisitor)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitSingleLineIfStatement(VBSyntax.SingleLineIfStatementSyntax node)
|
||||
{
|
||||
var condition = (ExpressionSyntax)node.Condition.Accept(nodesVisitor);
|
||||
var block = SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this)));
|
||||
ElseClauseSyntax elseClause = null;
|
||||
|
||||
if (node.ElseClause != null) {
|
||||
var elseBlock = SyntaxFactory.Block(node.ElseClause.Statements.SelectMany(s => s.Accept(this)));
|
||||
elseClause = SyntaxFactory.ElseClause(elseBlock.UnpackBlock());
|
||||
}
|
||||
return SingleStatement(SyntaxFactory.IfStatement(condition, block.UnpackBlock(), elseClause));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitMultiLineIfBlock(VBSyntax.MultiLineIfBlockSyntax node)
|
||||
{
|
||||
var condition = (ExpressionSyntax)node.IfStatement.Condition.Accept(nodesVisitor);
|
||||
var block = SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this)));
|
||||
ElseClauseSyntax elseClause = null;
|
||||
|
||||
if (node.ElseBlock != null) {
|
||||
var elseBlock = SyntaxFactory.Block(node.ElseBlock.Statements.SelectMany(s => s.Accept(this)));
|
||||
elseClause = SyntaxFactory.ElseClause(elseBlock.UnpackBlock());
|
||||
}
|
||||
|
||||
foreach (var elseIf in node.ElseIfBlocks.Reverse()) {
|
||||
var elseBlock = SyntaxFactory.Block(elseIf.Statements.SelectMany(s => s.Accept(this)));
|
||||
var ifStmt = SyntaxFactory.IfStatement((ExpressionSyntax)elseIf.ElseIfStatement.Condition.Accept(nodesVisitor), elseBlock.UnpackBlock(), elseClause);
|
||||
elseClause = SyntaxFactory.ElseClause(ifStmt);
|
||||
}
|
||||
|
||||
return SingleStatement(SyntaxFactory.IfStatement(condition, block.UnpackBlock(), elseClause));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitForBlock(VBSyntax.ForBlockSyntax node)
|
||||
{
|
||||
var stmt = node.ForStatement;
|
||||
ExpressionSyntax startValue = (ExpressionSyntax)stmt.FromValue.Accept(nodesVisitor);
|
||||
VariableDeclarationSyntax declaration = null;
|
||||
ExpressionSyntax id;
|
||||
if (stmt.ControlVariable is VBSyntax.VariableDeclaratorSyntax) {
|
||||
var v = (VBSyntax.VariableDeclaratorSyntax)stmt.ControlVariable;
|
||||
declaration = SplitVariableDeclarations(v, nodesVisitor, semanticModel).Values.Single();
|
||||
declaration = declaration.WithVariables(SyntaxFactory.SingletonSeparatedList(declaration.Variables[0].WithInitializer(SyntaxFactory.EqualsValueClause(startValue))));
|
||||
id = SyntaxFactory.IdentifierName(declaration.Variables[0].Identifier);
|
||||
} else {
|
||||
id = (ExpressionSyntax)stmt.ControlVariable.Accept(nodesVisitor);
|
||||
var symbol = semanticModel.GetSymbolInfo(stmt.ControlVariable).Symbol;
|
||||
if (!semanticModel.LookupSymbols(node.FullSpan.Start, name: symbol.Name).Any()) {
|
||||
var variableDeclaratorSyntax = SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier(symbol.Name), null,
|
||||
SyntaxFactory.EqualsValueClause(startValue));
|
||||
declaration = SyntaxFactory.VariableDeclaration(
|
||||
SyntaxFactory.IdentifierName("var"),
|
||||
SyntaxFactory.SingletonSeparatedList(variableDeclaratorSyntax));
|
||||
} else {
|
||||
startValue = SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, id, startValue);
|
||||
}
|
||||
}
|
||||
|
||||
var step = (ExpressionSyntax)stmt.StepClause?.StepValue.Accept(nodesVisitor);
|
||||
PrefixUnaryExpressionSyntax value = step.SkipParens() as PrefixUnaryExpressionSyntax;
|
||||
ExpressionSyntax condition;
|
||||
if (value == null) {
|
||||
condition = SyntaxFactory.BinaryExpression(SyntaxKind.LessThanOrEqualExpression, id, (ExpressionSyntax)stmt.ToValue.Accept(nodesVisitor));
|
||||
} else {
|
||||
condition = SyntaxFactory.BinaryExpression(SyntaxKind.GreaterThanOrEqualExpression, id, (ExpressionSyntax)stmt.ToValue.Accept(nodesVisitor));
|
||||
}
|
||||
if (step == null)
|
||||
step = SyntaxFactory.PostfixUnaryExpression(SyntaxKind.PostIncrementExpression, id);
|
||||
else
|
||||
step = SyntaxFactory.AssignmentExpression(SyntaxKind.AddAssignmentExpression, id, step);
|
||||
var block = SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this)));
|
||||
return SingleStatement(SyntaxFactory.ForStatement(
|
||||
declaration,
|
||||
declaration != null ? SyntaxFactory.SeparatedList<ExpressionSyntax>() : SyntaxFactory.SingletonSeparatedList(startValue),
|
||||
condition,
|
||||
SyntaxFactory.SingletonSeparatedList(step),
|
||||
block.UnpackBlock()));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitForEachBlock(VBSyntax.ForEachBlockSyntax node)
|
||||
{
|
||||
var stmt = node.ForEachStatement;
|
||||
|
||||
TypeSyntax type = null;
|
||||
SyntaxToken id;
|
||||
if (stmt.ControlVariable is VBSyntax.VariableDeclaratorSyntax) {
|
||||
var v = (VBSyntax.VariableDeclaratorSyntax)stmt.ControlVariable;
|
||||
var declaration = SplitVariableDeclarations(v, nodesVisitor, semanticModel).Values.Single();
|
||||
type = declaration.Type;
|
||||
id = declaration.Variables[0].Identifier;
|
||||
} else {
|
||||
var v = (IdentifierNameSyntax)stmt.ControlVariable.Accept(nodesVisitor);
|
||||
id = v.Identifier;
|
||||
type = SyntaxFactory.ParseTypeName("var");
|
||||
}
|
||||
|
||||
var block = SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this)));
|
||||
return SingleStatement(SyntaxFactory.ForEachStatement(
|
||||
type,
|
||||
id,
|
||||
(ExpressionSyntax)stmt.Expression.Accept(nodesVisitor),
|
||||
block.UnpackBlock()
|
||||
));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitSelectBlock(VBSyntax.SelectBlockSyntax node)
|
||||
{
|
||||
var expr = (ExpressionSyntax)node.SelectStatement.Expression.Accept(nodesVisitor);
|
||||
SwitchStatementSyntax switchStatement;
|
||||
if (ConvertToSwitch(expr, node.CaseBlocks, out switchStatement))
|
||||
return SingleStatement(switchStatement);
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitWithBlock(VBSyntax.WithBlockSyntax node)
|
||||
{
|
||||
var withExpression = (ExpressionSyntax)node.WithStatement.Expression.Accept(nodesVisitor);
|
||||
withBlockTempVariableNames.Push(GetUniqueVariableNameInScope(node, "withBlock"));
|
||||
try {
|
||||
var variableDeclaratorSyntax = SyntaxFactory.VariableDeclarator(
|
||||
SyntaxFactory.Identifier(withBlockTempVariableNames.Peek()), null,
|
||||
SyntaxFactory.EqualsValueClause(withExpression));
|
||||
var declaration = SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration(
|
||||
SyntaxFactory.IdentifierName("var"),
|
||||
SyntaxFactory.SingletonSeparatedList(variableDeclaratorSyntax)));
|
||||
var statements = node.Statements.SelectMany(s => s.Accept(this));
|
||||
|
||||
return SingleStatement(SyntaxFactory.Block(new[] { declaration }.Concat(statements).ToArray()));
|
||||
} finally {
|
||||
withBlockTempVariableNames.Pop();
|
||||
}
|
||||
}
|
||||
|
||||
private string GetUniqueVariableNameInScope(SyntaxNode node, string variableNameBase)
|
||||
{
|
||||
var reservedNames = withBlockTempVariableNames.Concat(node.DescendantNodesAndSelf()
|
||||
.SelectMany(syntaxNode => semanticModel.LookupSymbols(syntaxNode.SpanStart).Select(s => s.Name)));
|
||||
return NameGenerator.EnsureUniqueness(variableNameBase, reservedNames, true);
|
||||
}
|
||||
|
||||
private bool ConvertToSwitch(ExpressionSyntax expr, SyntaxList<VBSyntax.CaseBlockSyntax> caseBlocks, out SwitchStatementSyntax switchStatement)
|
||||
{
|
||||
switchStatement = null;
|
||||
|
||||
var sections = new List<SwitchSectionSyntax>();
|
||||
foreach (var block in caseBlocks) {
|
||||
var labels = new List<SwitchLabelSyntax>();
|
||||
foreach (var c in block.CaseStatement.Cases) {
|
||||
if (c is VBSyntax.SimpleCaseClauseSyntax) {
|
||||
var s = (VBSyntax.SimpleCaseClauseSyntax)c;
|
||||
labels.Add(SyntaxFactory.CaseSwitchLabel((ExpressionSyntax)s.Value.Accept(nodesVisitor)));
|
||||
} else if (c is VBSyntax.ElseCaseClauseSyntax) {
|
||||
labels.Add(SyntaxFactory.DefaultSwitchLabel());
|
||||
} else return false;
|
||||
}
|
||||
var list = SingleStatement(SyntaxFactory.Block(block.Statements.SelectMany(s => s.Accept(this)).Concat(SyntaxFactory.BreakStatement())));
|
||||
sections.Add(SyntaxFactory.SwitchSection(SyntaxFactory.List(labels), list));
|
||||
}
|
||||
switchStatement = SyntaxFactory.SwitchStatement(expr, SyntaxFactory.List(sections));
|
||||
return true;
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitTryBlock(VBSyntax.TryBlockSyntax node)
|
||||
{
|
||||
var block = SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this)));
|
||||
return SingleStatement(
|
||||
SyntaxFactory.TryStatement(
|
||||
block,
|
||||
SyntaxFactory.List(node.CatchBlocks.Select(c => (CatchClauseSyntax)c.Accept(nodesVisitor))),
|
||||
(FinallyClauseSyntax)node.FinallyBlock?.Accept(nodesVisitor)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitSyncLockBlock(VBSyntax.SyncLockBlockSyntax node)
|
||||
{
|
||||
return SingleStatement(SyntaxFactory.LockStatement(
|
||||
(ExpressionSyntax)node.SyncLockStatement.Expression.Accept(nodesVisitor),
|
||||
SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this))).UnpackBlock()
|
||||
));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitUsingBlock(VBSyntax.UsingBlockSyntax node)
|
||||
{
|
||||
if (node.UsingStatement.Expression == null) {
|
||||
StatementSyntax stmt = SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this)));
|
||||
foreach (var v in node.UsingStatement.Variables.Reverse())
|
||||
foreach (var declaration in SplitVariableDeclarations(v, nodesVisitor, semanticModel).Values.Reverse())
|
||||
stmt = SyntaxFactory.UsingStatement(declaration, null, stmt);
|
||||
return SingleStatement(stmt);
|
||||
} else {
|
||||
var expr = (ExpressionSyntax)node.UsingStatement.Expression.Accept(nodesVisitor);
|
||||
return SingleStatement(SyntaxFactory.UsingStatement(null, expr, SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this))).UnpackBlock()));
|
||||
}
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitWhileBlock(VBSyntax.WhileBlockSyntax node)
|
||||
{
|
||||
return SingleStatement(SyntaxFactory.WhileStatement(
|
||||
(ExpressionSyntax)node.WhileStatement.Condition.Accept(nodesVisitor),
|
||||
SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this))).UnpackBlock()
|
||||
));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitDoLoopBlock(VBSyntax.DoLoopBlockSyntax node)
|
||||
{
|
||||
if (node.DoStatement.WhileOrUntilClause != null) {
|
||||
var stmt = node.DoStatement.WhileOrUntilClause;
|
||||
if (stmt.WhileOrUntilKeyword.IsKind(VBasic.SyntaxKind.WhileKeyword))
|
||||
return SingleStatement(SyntaxFactory.WhileStatement(
|
||||
(ExpressionSyntax)stmt.Condition.Accept(nodesVisitor),
|
||||
SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this))).UnpackBlock()
|
||||
));
|
||||
else
|
||||
return SingleStatement(SyntaxFactory.WhileStatement(
|
||||
SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, (ExpressionSyntax)stmt.Condition.Accept(nodesVisitor)),
|
||||
SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this))).UnpackBlock()
|
||||
));
|
||||
}
|
||||
if (node.LoopStatement.WhileOrUntilClause != null) {
|
||||
var stmt = node.LoopStatement.WhileOrUntilClause;
|
||||
if (stmt.WhileOrUntilKeyword.IsKind(VBasic.SyntaxKind.WhileKeyword))
|
||||
return SingleStatement(SyntaxFactory.DoStatement(
|
||||
SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this))).UnpackBlock(),
|
||||
(ExpressionSyntax)stmt.Condition.Accept(nodesVisitor)
|
||||
));
|
||||
else
|
||||
return SingleStatement(SyntaxFactory.DoStatement(
|
||||
SyntaxFactory.Block(node.Statements.SelectMany(s => s.Accept(this))).UnpackBlock(),
|
||||
SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, (ExpressionSyntax)stmt.Condition.Accept(nodesVisitor))
|
||||
));
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
SyntaxList<StatementSyntax> SingleStatement(StatementSyntax statement)
|
||||
{
|
||||
return SyntaxFactory.SingletonList(statement);
|
||||
}
|
||||
|
||||
SyntaxList<StatementSyntax> SingleStatement(ExpressionSyntax expression)
|
||||
{
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(SyntaxFactory.ExpressionStatement(expression));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Extensions
|
||||
{
|
||||
public static StatementSyntax UnpackBlock(this BlockSyntax block)
|
||||
{
|
||||
return block.Statements.Count == 1 ? block.Statements[0] : block;
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,417 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using VBasic = Microsoft.CodeAnalysis.VisualBasic;
|
||||
using VBSyntax = Microsoft.CodeAnalysis.VisualBasic.Syntax;
|
||||
using RefactoringEssentials.Converter;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace RefactoringEssentials.CSharp.Converter
|
||||
{
|
||||
public partial class VisualBasicConverter
|
||||
{
|
||||
enum TokenContext
|
||||
{
|
||||
Global,
|
||||
InterfaceOrModule,
|
||||
Local,
|
||||
Member,
|
||||
VariableOrConst,
|
||||
MemberInModule,
|
||||
MemberInClass,
|
||||
MemberInStruct,
|
||||
MemberInInterface
|
||||
}
|
||||
|
||||
public static CSharpSyntaxNode Convert(VBasic.VisualBasicSyntaxNode input, SemanticModel semanticModel, Document targetDocument)
|
||||
{
|
||||
return input.Accept(new NodesVisitor(semanticModel, targetDocument));
|
||||
}
|
||||
|
||||
public static ConversionResult ConvertText(string text, MetadataReference[] references)
|
||||
{
|
||||
if (text == null)
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
if (references == null)
|
||||
throw new ArgumentNullException(nameof(references));
|
||||
var tree = VBasic.SyntaxFactory.ParseSyntaxTree(SourceText.From(text));
|
||||
var compilation = VBasic.VisualBasicCompilation.Create("Conversion", new[] { tree }, references);
|
||||
try {
|
||||
return new ConversionResult(Convert((VBasic.VisualBasicSyntaxNode)tree.GetRoot(), compilation.GetSemanticModel(tree, true), null).NormalizeWhitespace().ToFullString());
|
||||
} catch (Exception ex) {
|
||||
return new ConversionResult(ex);
|
||||
}
|
||||
}
|
||||
|
||||
static Dictionary<string, VariableDeclarationSyntax> SplitVariableDeclarations(VBSyntax.VariableDeclaratorSyntax declarator, NodesVisitor nodesVisitor, SemanticModel semanticModel)
|
||||
{
|
||||
var rawType = (TypeSyntax)declarator.AsClause?.TypeSwitch(
|
||||
(VBSyntax.SimpleAsClauseSyntax c) => c.Type,
|
||||
(VBSyntax.AsNewClauseSyntax c) => VBasic.SyntaxExtensions.Type(c.NewExpression),
|
||||
_ => { throw new NotImplementedException($"{_.GetType().FullName} not implemented!"); }
|
||||
)?.Accept(nodesVisitor) ?? SyntaxFactory.ParseTypeName("var");
|
||||
|
||||
var initializer = (ExpressionSyntax)declarator.AsClause?.TypeSwitch(
|
||||
(VBSyntax.SimpleAsClauseSyntax _) => declarator.Initializer?.Value,
|
||||
(VBSyntax.AsNewClauseSyntax c) => c.NewExpression
|
||||
)?.Accept(nodesVisitor) ?? (ExpressionSyntax)declarator.Initializer?.Value.Accept(nodesVisitor);
|
||||
|
||||
var newDecls = new Dictionary<string, VariableDeclarationSyntax>();
|
||||
|
||||
foreach (var name in declarator.Names) {
|
||||
var type = rawType;
|
||||
if (!name.Nullable.IsKind(VBasic.SyntaxKind.None)) {
|
||||
if (type is ArrayTypeSyntax)
|
||||
type = ((ArrayTypeSyntax)type).WithElementType(SyntaxFactory.NullableType(((ArrayTypeSyntax)type).ElementType));
|
||||
else
|
||||
type = SyntaxFactory.NullableType(type);
|
||||
}
|
||||
if (name.ArrayRankSpecifiers.Count > 0)
|
||||
type = SyntaxFactory.ArrayType(type, SyntaxFactory.List(name.ArrayRankSpecifiers.Select(a => (ArrayRankSpecifierSyntax)a.Accept(nodesVisitor))));
|
||||
VariableDeclarationSyntax decl;
|
||||
var v = SyntaxFactory.VariableDeclarator(ConvertIdentifier(name.Identifier, semanticModel), null, initializer == null ? null : SyntaxFactory.EqualsValueClause(initializer));
|
||||
string k = type.ToString();
|
||||
if (newDecls.TryGetValue(k, out decl))
|
||||
newDecls[k] = decl.AddVariables(v);
|
||||
else
|
||||
newDecls[k] = SyntaxFactory.VariableDeclaration(type, SyntaxFactory.SingletonSeparatedList(v));
|
||||
}
|
||||
|
||||
return newDecls;
|
||||
}
|
||||
|
||||
static ExpressionSyntax Literal(object o) => GetLiteralExpression(o);
|
||||
|
||||
internal static ExpressionSyntax GetLiteralExpression(object value)
|
||||
{
|
||||
if (value is bool)
|
||||
return SyntaxFactory.LiteralExpression((bool)value ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression);
|
||||
if (value is byte)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((byte)value));
|
||||
if (value is sbyte)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((sbyte)value));
|
||||
if (value is short)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((short)value));
|
||||
if (value is ushort)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((ushort)value));
|
||||
if (value is int)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((int)value));
|
||||
if (value is uint)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((uint)value));
|
||||
if (value is long)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((long)value));
|
||||
if (value is ulong)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((ulong)value));
|
||||
|
||||
if (value is float)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((float)value));
|
||||
if (value is double)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((double)value));
|
||||
if (value is decimal)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((decimal)value));
|
||||
|
||||
if (value is char)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.CharacterLiteralExpression, SyntaxFactory.Literal((char)value));
|
||||
|
||||
if (value is string)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal((string)value));
|
||||
|
||||
if (value == null)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static SyntaxToken ConvertIdentifier(SyntaxToken id, SemanticModel semanticModel, bool isAttribute = false)
|
||||
{
|
||||
string text = id.ValueText;
|
||||
var keywordKind = SyntaxFacts.GetKeywordKind(text);
|
||||
if (keywordKind != SyntaxKind.None)
|
||||
return SyntaxFactory.Identifier("@" + text);
|
||||
if (id.SyntaxTree == semanticModel.SyntaxTree) {
|
||||
var symbol = semanticModel.GetSymbolInfo(id.Parent).Symbol;
|
||||
if (symbol != null && !string.IsNullOrWhiteSpace(symbol.Name)) {
|
||||
if (symbol.IsConstructor() && isAttribute) {
|
||||
text = symbol.ContainingType.Name;
|
||||
if (text.EndsWith("Attribute", StringComparison.Ordinal))
|
||||
text = text.Remove(text.Length - "Attribute".Length);
|
||||
} else if (text.StartsWith("_", StringComparison.Ordinal) && symbol is IFieldSymbol fieldSymbol && fieldSymbol.AssociatedSymbol?.IsKind(SymbolKind.Property) == true) {
|
||||
|
||||
text = fieldSymbol.AssociatedSymbol.Name;
|
||||
} else
|
||||
text = symbol.Name;
|
||||
}
|
||||
}
|
||||
return SyntaxFactory.Identifier(text);
|
||||
}
|
||||
|
||||
static SyntaxTokenList ConvertModifiers(IEnumerable<SyntaxToken> modifiers, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
return SyntaxFactory.TokenList(ConvertModifiersCore(modifiers, context));
|
||||
}
|
||||
|
||||
static SyntaxTokenList ConvertModifiers(SyntaxTokenList modifiers, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
return SyntaxFactory.TokenList(ConvertModifiersCore(modifiers, context).Where(t => t.Kind() != SyntaxKind.None));
|
||||
}
|
||||
|
||||
static SyntaxToken? ConvertModifier(SyntaxToken m, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
VBasic.SyntaxKind vbSyntaxKind = VBasic.VisualBasicExtensions.Kind(m);
|
||||
switch (vbSyntaxKind) {
|
||||
case VBasic.SyntaxKind.DateKeyword:
|
||||
return SyntaxFactory.Identifier("System.DateTime");
|
||||
}
|
||||
var token = ConvertToken(vbSyntaxKind, context);
|
||||
return token == SyntaxKind.None ? null : new SyntaxToken?(SyntaxFactory.Token(token));
|
||||
}
|
||||
|
||||
static IEnumerable<SyntaxToken> ConvertModifiersCore(IEnumerable<SyntaxToken> modifiers, TokenContext context)
|
||||
{
|
||||
var contextsWithIdenticalDefaults = new[] { TokenContext.Global, TokenContext.Local, TokenContext.InterfaceOrModule, TokenContext.MemberInInterface };
|
||||
if (!contextsWithIdenticalDefaults.Contains(context)) {
|
||||
bool visibility = false;
|
||||
foreach (var token in modifiers) {
|
||||
if (IsVisibility(token, context)) {
|
||||
visibility = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!visibility)
|
||||
yield return VisualBasicDefaultVisibility(context);
|
||||
}
|
||||
foreach (var token in modifiers.Where(m => !IgnoreInContext(m, context)).OrderBy(m => m.IsKind(VBasic.SyntaxKind.PartialKeyword))) {
|
||||
var m = ConvertModifier(token, context);
|
||||
if (m.HasValue) yield return m.Value;
|
||||
}
|
||||
if (context == TokenContext.MemberInModule)
|
||||
yield return SyntaxFactory.Token(SyntaxKind.StaticKeyword);
|
||||
}
|
||||
|
||||
static bool IgnoreInContext(SyntaxToken m, TokenContext context)
|
||||
{
|
||||
switch (VBasic.VisualBasicExtensions.Kind(m)) {
|
||||
case VBasic.SyntaxKind.OptionalKeyword:
|
||||
case VBasic.SyntaxKind.ByValKeyword:
|
||||
case VBasic.SyntaxKind.IteratorKeyword:
|
||||
case VBasic.SyntaxKind.DimKeyword:
|
||||
return true;
|
||||
case VBasic.SyntaxKind.ReadOnlyKeyword:
|
||||
case VBasic.SyntaxKind.WriteOnlyKeyword:
|
||||
return context == TokenContext.Member;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsVisibility(SyntaxToken token, TokenContext context)
|
||||
{
|
||||
return token.IsKind(VBasic.SyntaxKind.PublicKeyword, VBasic.SyntaxKind.FriendKeyword, VBasic.SyntaxKind.ProtectedKeyword, VBasic.SyntaxKind.PrivateKeyword)
|
||||
|| (context == TokenContext.VariableOrConst && token.IsKind(VBasic.SyntaxKind.ConstKeyword));
|
||||
}
|
||||
|
||||
static SyntaxToken VisualBasicDefaultVisibility(TokenContext context)
|
||||
{
|
||||
switch (context) {
|
||||
case TokenContext.Global:
|
||||
case TokenContext.InterfaceOrModule:
|
||||
return SyntaxFactory.Token(SyntaxKind.InternalKeyword);
|
||||
case TokenContext.Member:
|
||||
case TokenContext.MemberInModule:
|
||||
case TokenContext.MemberInClass:
|
||||
case TokenContext.MemberInInterface:
|
||||
case TokenContext.MemberInStruct:
|
||||
return SyntaxFactory.Token(SyntaxKind.PublicKeyword);
|
||||
case TokenContext.Local:
|
||||
case TokenContext.VariableOrConst:
|
||||
return SyntaxFactory.Token(SyntaxKind.PrivateKeyword);
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(context), context, "Specified argument was out of the range of valid values.");
|
||||
}
|
||||
|
||||
static SyntaxToken ConvertToken(SyntaxToken t, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
VBasic.SyntaxKind vbSyntaxKind = VBasic.VisualBasicExtensions.Kind(t);
|
||||
return SyntaxFactory.Token(ConvertToken(vbSyntaxKind, context));
|
||||
}
|
||||
|
||||
static SyntaxKind ConvertToken(VBasic.SyntaxKind t, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
switch (t) {
|
||||
case VBasic.SyntaxKind.None:
|
||||
return SyntaxKind.None;
|
||||
// built-in types
|
||||
case VBasic.SyntaxKind.BooleanKeyword:
|
||||
return SyntaxKind.BoolKeyword;
|
||||
case VBasic.SyntaxKind.ByteKeyword:
|
||||
return SyntaxKind.ByteKeyword;
|
||||
case VBasic.SyntaxKind.SByteKeyword:
|
||||
return SyntaxKind.SByteKeyword;
|
||||
case VBasic.SyntaxKind.ShortKeyword:
|
||||
return SyntaxKind.ShortKeyword;
|
||||
case VBasic.SyntaxKind.UShortKeyword:
|
||||
return SyntaxKind.UShortKeyword;
|
||||
case VBasic.SyntaxKind.IntegerKeyword:
|
||||
return SyntaxKind.IntKeyword;
|
||||
case VBasic.SyntaxKind.UIntegerKeyword:
|
||||
return SyntaxKind.UIntKeyword;
|
||||
case VBasic.SyntaxKind.LongKeyword:
|
||||
return SyntaxKind.LongKeyword;
|
||||
case VBasic.SyntaxKind.ULongKeyword:
|
||||
return SyntaxKind.ULongKeyword;
|
||||
case VBasic.SyntaxKind.DoubleKeyword:
|
||||
return SyntaxKind.DoubleKeyword;
|
||||
case VBasic.SyntaxKind.SingleKeyword:
|
||||
return SyntaxKind.FloatKeyword;
|
||||
case VBasic.SyntaxKind.DecimalKeyword:
|
||||
return SyntaxKind.DecimalKeyword;
|
||||
case VBasic.SyntaxKind.StringKeyword:
|
||||
return SyntaxKind.StringKeyword;
|
||||
case VBasic.SyntaxKind.CharKeyword:
|
||||
return SyntaxKind.CharKeyword;
|
||||
case VBasic.SyntaxKind.ObjectKeyword:
|
||||
return SyntaxKind.ObjectKeyword;
|
||||
// literals
|
||||
case VBasic.SyntaxKind.NothingKeyword:
|
||||
return SyntaxKind.NullKeyword;
|
||||
case VBasic.SyntaxKind.TrueKeyword:
|
||||
return SyntaxKind.TrueKeyword;
|
||||
case VBasic.SyntaxKind.FalseKeyword:
|
||||
return SyntaxKind.FalseKeyword;
|
||||
case VBasic.SyntaxKind.MeKeyword:
|
||||
return SyntaxKind.ThisKeyword;
|
||||
case VBasic.SyntaxKind.MyBaseKeyword:
|
||||
return SyntaxKind.BaseKeyword;
|
||||
// modifiers
|
||||
case VBasic.SyntaxKind.PublicKeyword:
|
||||
return SyntaxKind.PublicKeyword;
|
||||
case VBasic.SyntaxKind.FriendKeyword:
|
||||
return SyntaxKind.InternalKeyword;
|
||||
case VBasic.SyntaxKind.ProtectedKeyword:
|
||||
return SyntaxKind.ProtectedKeyword;
|
||||
case VBasic.SyntaxKind.PrivateKeyword:
|
||||
return SyntaxKind.PrivateKeyword;
|
||||
case VBasic.SyntaxKind.ByRefKeyword:
|
||||
return SyntaxKind.RefKeyword;
|
||||
case VBasic.SyntaxKind.ParamArrayKeyword:
|
||||
return SyntaxKind.ParamsKeyword;
|
||||
case VBasic.SyntaxKind.ReadOnlyKeyword:
|
||||
return SyntaxKind.ReadOnlyKeyword;
|
||||
case VBasic.SyntaxKind.OverridesKeyword:
|
||||
return SyntaxKind.OverrideKeyword;
|
||||
case VBasic.SyntaxKind.OverloadsKeyword:
|
||||
return SyntaxKind.NewKeyword;
|
||||
case VBasic.SyntaxKind.OverridableKeyword:
|
||||
return SyntaxKind.VirtualKeyword;
|
||||
case VBasic.SyntaxKind.SharedKeyword:
|
||||
return SyntaxKind.StaticKeyword;
|
||||
case VBasic.SyntaxKind.ConstKeyword:
|
||||
return SyntaxKind.ConstKeyword;
|
||||
case VBasic.SyntaxKind.PartialKeyword:
|
||||
return SyntaxKind.PartialKeyword;
|
||||
case VBasic.SyntaxKind.MustInheritKeyword:
|
||||
return SyntaxKind.AbstractKeyword;
|
||||
case VBasic.SyntaxKind.MustOverrideKeyword:
|
||||
return SyntaxKind.AbstractKeyword;
|
||||
case VBasic.SyntaxKind.NotOverridableKeyword:
|
||||
case VBasic.SyntaxKind.NotInheritableKeyword:
|
||||
return SyntaxKind.SealedKeyword;
|
||||
// unary operators
|
||||
case VBasic.SyntaxKind.UnaryMinusExpression:
|
||||
return SyntaxKind.UnaryMinusExpression;
|
||||
case VBasic.SyntaxKind.UnaryPlusExpression:
|
||||
return SyntaxKind.UnaryPlusExpression;
|
||||
case VBasic.SyntaxKind.NotExpression:
|
||||
return SyntaxKind.LogicalNotExpression;
|
||||
// binary operators
|
||||
case VBasic.SyntaxKind.ConcatenateExpression:
|
||||
case VBasic.SyntaxKind.AddExpression:
|
||||
return SyntaxKind.AddExpression;
|
||||
case VBasic.SyntaxKind.SubtractExpression:
|
||||
return SyntaxKind.SubtractExpression;
|
||||
case VBasic.SyntaxKind.MultiplyExpression:
|
||||
return SyntaxKind.MultiplyExpression;
|
||||
case VBasic.SyntaxKind.DivideExpression:
|
||||
return SyntaxKind.DivideExpression;
|
||||
case VBasic.SyntaxKind.ModuloExpression:
|
||||
return SyntaxKind.ModuloExpression;
|
||||
case VBasic.SyntaxKind.AndAlsoExpression:
|
||||
return SyntaxKind.LogicalAndExpression;
|
||||
case VBasic.SyntaxKind.OrElseExpression:
|
||||
return SyntaxKind.LogicalOrExpression;
|
||||
case VBasic.SyntaxKind.OrExpression:
|
||||
return SyntaxKind.BitwiseOrExpression;
|
||||
case VBasic.SyntaxKind.AndExpression:
|
||||
return SyntaxKind.BitwiseAndExpression;
|
||||
case VBasic.SyntaxKind.ExclusiveOrExpression:
|
||||
return SyntaxKind.ExclusiveOrExpression;
|
||||
case VBasic.SyntaxKind.EqualsExpression:
|
||||
return SyntaxKind.EqualsExpression;
|
||||
case VBasic.SyntaxKind.NotEqualsExpression:
|
||||
return SyntaxKind.NotEqualsExpression;
|
||||
case VBasic.SyntaxKind.GreaterThanExpression:
|
||||
return SyntaxKind.GreaterThanExpression;
|
||||
case VBasic.SyntaxKind.GreaterThanOrEqualExpression:
|
||||
return SyntaxKind.GreaterThanOrEqualExpression;
|
||||
case VBasic.SyntaxKind.LessThanExpression:
|
||||
return SyntaxKind.LessThanExpression;
|
||||
case VBasic.SyntaxKind.LessThanOrEqualExpression:
|
||||
return SyntaxKind.LessThanOrEqualExpression;
|
||||
// assignment
|
||||
case VBasic.SyntaxKind.SimpleAssignmentStatement:
|
||||
return SyntaxKind.SimpleAssignmentExpression;
|
||||
case VBasic.SyntaxKind.ConcatenateAssignmentStatement:
|
||||
case VBasic.SyntaxKind.AddAssignmentStatement:
|
||||
return SyntaxKind.AddAssignmentExpression;
|
||||
case VBasic.SyntaxKind.SubtractAssignmentStatement:
|
||||
return SyntaxKind.SubtractAssignmentExpression;
|
||||
case VBasic.SyntaxKind.MultiplyAssignmentStatement:
|
||||
return SyntaxKind.MultiplyAssignmentExpression;
|
||||
case VBasic.SyntaxKind.DivideAssignmentStatement:
|
||||
return SyntaxKind.DivideAssignmentExpression;
|
||||
// Casts
|
||||
case VBasic.SyntaxKind.CObjKeyword:
|
||||
return SyntaxKind.ObjectKeyword;
|
||||
case VBasic.SyntaxKind.CBoolKeyword:
|
||||
return SyntaxKind.BoolKeyword;
|
||||
case VBasic.SyntaxKind.CCharKeyword:
|
||||
return SyntaxKind.CharKeyword;
|
||||
case VBasic.SyntaxKind.CSByteKeyword:
|
||||
return SyntaxKind.SByteKeyword;
|
||||
case VBasic.SyntaxKind.CByteKeyword:
|
||||
return SyntaxKind.ByteKeyword;
|
||||
case VBasic.SyntaxKind.CShortKeyword:
|
||||
return SyntaxKind.ShortKeyword;
|
||||
case VBasic.SyntaxKind.CUShortKeyword:
|
||||
return SyntaxKind.UShortKeyword;
|
||||
case VBasic.SyntaxKind.CIntKeyword:
|
||||
return SyntaxKind.IntKeyword;
|
||||
case VBasic.SyntaxKind.CUIntKeyword:
|
||||
return SyntaxKind.UIntKeyword;
|
||||
case VBasic.SyntaxKind.CLngKeyword:
|
||||
return SyntaxKind.LongKeyword;
|
||||
case VBasic.SyntaxKind.CULngKeyword:
|
||||
return SyntaxKind.ULongKeyword;
|
||||
case VBasic.SyntaxKind.CDecKeyword:
|
||||
return SyntaxKind.DecimalKeyword;
|
||||
case VBasic.SyntaxKind.CSngKeyword:
|
||||
return SyntaxKind.FloatKeyword;
|
||||
case VBasic.SyntaxKind.CDblKeyword:
|
||||
return SyntaxKind.DoubleKeyword;
|
||||
case VBasic.SyntaxKind.CStrKeyword:
|
||||
return SyntaxKind.StringKeyword;
|
||||
//
|
||||
case VBasic.SyntaxKind.AssemblyKeyword:
|
||||
return SyntaxKind.AssemblyKeyword;
|
||||
case VBasic.SyntaxKind.AsyncKeyword:
|
||||
return SyntaxKind.AsyncKeyword;
|
||||
}
|
||||
throw new NotSupportedException(t + " not supported!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using ConvVB = RefactoringEssentials.VB.Converter;
|
||||
using ConvCS = RefactoringEssentials.CSharp.Converter;
|
||||
|
||||
namespace RefactoringEssentials.Converter
|
||||
{
|
||||
public static class CodeConverter
|
||||
{
|
||||
public static ConversionResult Convert(CodeWithOptions code)
|
||||
{
|
||||
if (!IsSupportedSource(code.FromLanguage, code.FromLanguageVersion))
|
||||
return new ConversionResult(new NotSupportedException($"Source language {code.FromLanguage} {code.FromLanguageVersion} is not supported!"));
|
||||
if (!IsSupportedTarget(code.ToLanguage, code.ToLanguageVersion))
|
||||
return new ConversionResult(new NotSupportedException($"Target language {code.ToLanguage} {code.ToLanguageVersion} is not supported!"));
|
||||
if (code.FromLanguage == code.ToLanguage && code.FromLanguageVersion != code.ToLanguageVersion)
|
||||
return new ConversionResult(new NotSupportedException($"Converting from {code.FromLanguage} {code.FromLanguageVersion} to {code.ToLanguage} {code.ToLanguageVersion} is not supported!"));
|
||||
|
||||
switch (code.FromLanguage) {
|
||||
case "C#":
|
||||
switch (code.ToLanguage) {
|
||||
case "Visual Basic":
|
||||
return ConvVB.CSharpConverter.ConvertText(code.Text, code.References);
|
||||
}
|
||||
break;
|
||||
case "Visual Basic":
|
||||
switch (code.ToLanguage) {
|
||||
case "C#":
|
||||
return ConvCS.VisualBasicConverter.ConvertText(code.Text, code.References);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return new ConversionResult(new NotSupportedException($"Converting from {code.FromLanguage} {code.FromLanguageVersion} to {code.ToLanguage} {code.ToLanguageVersion} is not supported!"));
|
||||
}
|
||||
|
||||
static bool IsSupportedTarget(string toLanguage, int toLanguageVersion)
|
||||
{
|
||||
return (toLanguage == "Visual Basic" && toLanguageVersion == 14) || (toLanguage == "C#" && toLanguageVersion == 6);
|
||||
}
|
||||
|
||||
static bool IsSupportedSource(string fromLanguage, int fromLanguageVersion)
|
||||
{
|
||||
return (fromLanguage == "C#" && fromLanguageVersion == 6) || (fromLanguage == "Visual Basic" && fromLanguageVersion == 14);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
using Microsoft.CodeAnalysis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace RefactoringEssentials.Converter
|
||||
{
|
||||
public class CodeWithOptions
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public string FromLanguage { get; private set; }
|
||||
public int FromLanguageVersion { get; private set; }
|
||||
public string ToLanguage { get; private set; }
|
||||
public int ToLanguageVersion { get; private set; }
|
||||
|
||||
List<MetadataReference> references;
|
||||
|
||||
public MetadataReference[] References => references.ToArray();
|
||||
|
||||
public CodeWithOptions(string text)
|
||||
{
|
||||
Text = text;
|
||||
FromLanguage = LanguageNames.CSharp;
|
||||
ToLanguage = LanguageNames.VisualBasic;
|
||||
FromLanguageVersion = 6;
|
||||
ToLanguageVersion = 14;
|
||||
references = new List<MetadataReference>();
|
||||
}
|
||||
|
||||
public CodeWithOptions SetFromLanguage(string name = LanguageNames.CSharp, int version = 6)
|
||||
{
|
||||
FromLanguage = name;
|
||||
FromLanguageVersion = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodeWithOptions SetToLanguage(string name = LanguageNames.VisualBasic, int version = 14)
|
||||
{
|
||||
ToLanguage = name;
|
||||
ToLanguageVersion = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodeWithOptions WithDefaultReferences()
|
||||
{
|
||||
references = new List<MetadataReference>(new[] {
|
||||
MetadataReference.CreateFromFile(typeof(Action).GetAssemblyLocation()),
|
||||
MetadataReference.CreateFromFile(typeof(System.ComponentModel.EditorBrowsableAttribute).GetAssemblyLocation()),
|
||||
MetadataReference.CreateFromFile(typeof(Enumerable).GetAssemblyLocation())
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RefactoringEssentials.Converter
|
||||
{
|
||||
public class ConversionResult
|
||||
{
|
||||
public bool Success { get; private set; }
|
||||
public string ConvertedCode { get; private set; }
|
||||
public IReadOnlyList<Exception> Exceptions { get; private set; }
|
||||
|
||||
public ConversionResult(string convertedCode)
|
||||
{
|
||||
Success = !string.IsNullOrWhiteSpace(convertedCode);
|
||||
ConvertedCode = convertedCode;
|
||||
}
|
||||
|
||||
public ConversionResult(params Exception[] exceptions)
|
||||
{
|
||||
Success = exceptions.Length == 0;
|
||||
Exceptions = exceptions;
|
||||
}
|
||||
|
||||
public string GetExceptionsAsString()
|
||||
{
|
||||
if (Exceptions == null || Exceptions.Count == 0)
|
||||
return string.Empty;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
for (int i = 0; i < Exceptions.Count; i++) {
|
||||
builder.AppendFormat("----- Exception {0} of {1} -----" + Environment.NewLine, i + 1, Exceptions.Count);
|
||||
builder.AppendLine(Exceptions[i].ToString());
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard1.3</TargetFramework>
|
||||
<AssemblyName>ICSharpCode.CodeConverter</AssemblyName>
|
||||
<RootNamespace>ICSharpCode.CodeConverter</RootNamespace>
|
||||
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
|
||||
<Company>ICSharpCode</Company>
|
||||
<Description>Code Converter C# to VB.NET and vice versa (Roslyn-based).</Description>
|
||||
<Product>Code Converter</Product>
|
||||
<Copyright>Copyright (c) 2014-2018 AlphaSierraPapa and Xamarin Inc.</Copyright>
|
||||
<AssemblyVersion>5.5.0.0</AssemblyVersion>
|
||||
<FileVersion>5.5.0.0</FileVersion>
|
||||
<Version>5.5.0</Version>
|
||||
<PackageId>ICSharpCode.CodeConverter</PackageId>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DefineConstants>TRACE;DEBUG;NETSTANDARD1_3;NETSTANDARD1_3</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE;RELEASE;NETSTANDARD1_3;RE2017</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.6.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="2.6.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="2.6.1" />
|
||||
</ItemGroup>
|
||||
<!-- The InternalVisibleTo fails when building with signing -->
|
||||
<ItemGroup Condition="'$(SignAssembly)'=='True'">
|
||||
<Compile Remove="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,266 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
/// <summary>
|
||||
/// An AnnotationTable helps you attach your own annotation types/instances to syntax.
|
||||
///
|
||||
/// It maintains a map between your instances and actual SyntaxAnnotation's used to annotate the nodes
|
||||
/// and offers an API that matches the true annotation API on SyntaxNode.
|
||||
///
|
||||
/// The table controls the lifetime of when you can find and retrieve your annotations. You won't be able to
|
||||
/// find your annotations via HasAnnotations/GetAnnotations unless you use the same annotation table for these operations
|
||||
/// that you used for the WithAdditionalAnnotations operation.
|
||||
///
|
||||
/// Your custom annotations are not serialized with the syntax tree, so they won't move across boundaries unless the
|
||||
/// same AnnotationTable is available on both ends.
|
||||
///
|
||||
/// also, note that this table is not thread safe.
|
||||
/// </summary>
|
||||
internal class AnnotationTable<TAnnotation> where TAnnotation : class
|
||||
{
|
||||
private int _globalId = 0;
|
||||
|
||||
private readonly Dictionary<TAnnotation, SyntaxAnnotation> _realAnnotationMap = new Dictionary<TAnnotation, SyntaxAnnotation>();
|
||||
private readonly Dictionary<string, TAnnotation> _annotationMap = new Dictionary<string, TAnnotation>();
|
||||
|
||||
private readonly string _annotationKind;
|
||||
|
||||
public AnnotationTable(string annotationKind)
|
||||
{
|
||||
_annotationKind = annotationKind;
|
||||
}
|
||||
|
||||
private IEnumerable<SyntaxAnnotation> GetOrCreateRealAnnotations(TAnnotation[] annotations)
|
||||
{
|
||||
foreach (var annotation in annotations) {
|
||||
yield return this.GetOrCreateRealAnnotation(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
private SyntaxAnnotation GetOrCreateRealAnnotation(TAnnotation annotation)
|
||||
{
|
||||
SyntaxAnnotation realAnnotation;
|
||||
if (!_realAnnotationMap.TryGetValue(annotation, out realAnnotation)) {
|
||||
var id = Interlocked.Increment(ref _globalId);
|
||||
var idString = id.ToString();
|
||||
|
||||
realAnnotation = new SyntaxAnnotation(_annotationKind, idString);
|
||||
_annotationMap.Add(idString, annotation);
|
||||
_realAnnotationMap.Add(annotation, realAnnotation);
|
||||
}
|
||||
|
||||
return realAnnotation;
|
||||
}
|
||||
|
||||
private IEnumerable<SyntaxAnnotation> GetRealAnnotations(TAnnotation[] annotations)
|
||||
{
|
||||
foreach (var annotation in annotations) {
|
||||
var realAnnotation = this.GetRealAnnotation(annotation);
|
||||
if (realAnnotation != null) {
|
||||
yield return realAnnotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SyntaxAnnotation GetRealAnnotation(TAnnotation annotation)
|
||||
{
|
||||
SyntaxAnnotation realAnnotation;
|
||||
_realAnnotationMap.TryGetValue(annotation, out realAnnotation);
|
||||
return realAnnotation;
|
||||
}
|
||||
|
||||
public TSyntaxNode WithAdditionalAnnotations<TSyntaxNode>(TSyntaxNode node, params TAnnotation[] annotations) where TSyntaxNode : SyntaxNode
|
||||
{
|
||||
return node.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
public SyntaxToken WithAdditionalAnnotations(SyntaxToken token, params TAnnotation[] annotations)
|
||||
{
|
||||
return token.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
public SyntaxTrivia WithAdditionalAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations)
|
||||
{
|
||||
return trivia.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
public SyntaxNodeOrToken WithAdditionalAnnotations(SyntaxNodeOrToken nodeOrToken, params TAnnotation[] annotations)
|
||||
{
|
||||
return nodeOrToken.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
public TSyntaxNode WithoutAnnotations<TSyntaxNode>(TSyntaxNode node, params TAnnotation[] annotations) where TSyntaxNode : SyntaxNode
|
||||
{
|
||||
return node.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
public SyntaxToken WithoutAnnotations(SyntaxToken token, params TAnnotation[] annotations)
|
||||
{
|
||||
return token.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
public SyntaxTrivia WithoutAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations)
|
||||
{
|
||||
return trivia.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
public SyntaxNodeOrToken WithoutAnnotations(SyntaxNodeOrToken nodeOrToken, params TAnnotation[] annotations)
|
||||
{
|
||||
return nodeOrToken.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
|
||||
}
|
||||
|
||||
private IEnumerable<TAnnotation> GetAnnotations(IEnumerable<SyntaxAnnotation> realAnnotations)
|
||||
{
|
||||
foreach (var ra in realAnnotations) {
|
||||
TAnnotation annotation;
|
||||
if (_annotationMap.TryGetValue(ra.Data, out annotation)) {
|
||||
yield return annotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<TAnnotation> GetAnnotations(SyntaxNode node)
|
||||
{
|
||||
return GetAnnotations(node.GetAnnotations(_annotationKind));
|
||||
}
|
||||
|
||||
public IEnumerable<TAnnotation> GetAnnotations(SyntaxToken token)
|
||||
{
|
||||
return GetAnnotations(token.GetAnnotations(_annotationKind));
|
||||
}
|
||||
|
||||
public IEnumerable<TAnnotation> GetAnnotations(SyntaxTrivia trivia)
|
||||
{
|
||||
return GetAnnotations(trivia.GetAnnotations(_annotationKind));
|
||||
}
|
||||
|
||||
public IEnumerable<TAnnotation> GetAnnotations(SyntaxNodeOrToken nodeOrToken)
|
||||
{
|
||||
return GetAnnotations(nodeOrToken.GetAnnotations(_annotationKind));
|
||||
}
|
||||
|
||||
public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(node).OfType<TSpecificAnnotation>();
|
||||
}
|
||||
|
||||
public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxToken token) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(token).OfType<TSpecificAnnotation>();
|
||||
}
|
||||
|
||||
public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(trivia).OfType<TSpecificAnnotation>();
|
||||
}
|
||||
|
||||
public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxNodeOrToken nodeOrToken) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(nodeOrToken).OfType<TSpecificAnnotation>();
|
||||
}
|
||||
|
||||
public bool HasAnnotations(SyntaxNode node)
|
||||
{
|
||||
return node.HasAnnotations(_annotationKind);
|
||||
}
|
||||
|
||||
public bool HasAnnotations(SyntaxToken token)
|
||||
{
|
||||
return token.HasAnnotations(_annotationKind);
|
||||
}
|
||||
|
||||
public bool HasAnnotations(SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.HasAnnotations(_annotationKind);
|
||||
}
|
||||
|
||||
public bool HasAnnotations(SyntaxNodeOrToken nodeOrToken)
|
||||
{
|
||||
return nodeOrToken.HasAnnotations(_annotationKind);
|
||||
}
|
||||
|
||||
public bool HasAnnotations<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(node).OfType<TSpecificAnnotation>().Any();
|
||||
}
|
||||
|
||||
public bool HasAnnotations<TSpecificAnnotation>(SyntaxToken token) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(token).OfType<TSpecificAnnotation>().Any();
|
||||
}
|
||||
|
||||
public bool HasAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(trivia).OfType<TSpecificAnnotation>().Any();
|
||||
}
|
||||
|
||||
public bool HasAnnotations<TSpecificAnnotation>(SyntaxNodeOrToken nodeOrToken) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return this.GetAnnotations(nodeOrToken).OfType<TSpecificAnnotation>().Any();
|
||||
}
|
||||
|
||||
public bool HasAnnotation(SyntaxNode node, TAnnotation annotation)
|
||||
{
|
||||
return node.HasAnnotation(this.GetRealAnnotation(annotation));
|
||||
}
|
||||
|
||||
public bool HasAnnotation(SyntaxToken token, TAnnotation annotation)
|
||||
{
|
||||
return token.HasAnnotation(this.GetRealAnnotation(annotation));
|
||||
}
|
||||
|
||||
public bool HasAnnotation(SyntaxTrivia trivia, TAnnotation annotation)
|
||||
{
|
||||
return trivia.HasAnnotation(this.GetRealAnnotation(annotation));
|
||||
}
|
||||
|
||||
public bool HasAnnotation(SyntaxNodeOrToken nodeOrToken, TAnnotation annotation)
|
||||
{
|
||||
return nodeOrToken.HasAnnotation(this.GetRealAnnotation(annotation));
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxNodeOrToken> GetAnnotatedNodesAndTokens(SyntaxNode node)
|
||||
{
|
||||
return node.GetAnnotatedNodesAndTokens(_annotationKind);
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxNode> GetAnnotatedNodes(SyntaxNode node)
|
||||
{
|
||||
return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsNode).Select(nt => nt.AsNode());
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxToken> GetAnnotatedTokens(SyntaxNode node)
|
||||
{
|
||||
return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsToken).Select(nt => nt.AsToken());
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(SyntaxNode node)
|
||||
{
|
||||
return node.GetAnnotatedTrivia(_annotationKind);
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxNodeOrToken> GetAnnotatedNodesAndTokens<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => this.HasAnnotations<TSpecificAnnotation>(nt));
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxNode> GetAnnotatedNodes<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsNode && this.HasAnnotations<TSpecificAnnotation>(nt)).Select(nt => nt.AsNode());
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxToken> GetAnnotatedTokens<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsToken && this.HasAnnotations<TSpecificAnnotation>(nt)).Select(nt => nt.AsToken());
|
||||
}
|
||||
|
||||
public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
|
||||
{
|
||||
return node.GetAnnotatedTrivia(_annotationKind).Where(tr => this.HasAnnotations<TSpecificAnnotation>(tr));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
using System;
|
||||
using RefactoringEssentials;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
static class CSharpUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Inverts a boolean condition. Note: The condition object can be frozen (from AST) it's cloned internally.
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition to invert.</param>
|
||||
public static ExpressionSyntax InvertCondition(ExpressionSyntax condition)
|
||||
{
|
||||
return InvertConditionInternal(condition);
|
||||
}
|
||||
|
||||
static ExpressionSyntax InvertConditionInternal(ExpressionSyntax condition)
|
||||
{
|
||||
if (condition is ParenthesizedExpressionSyntax) {
|
||||
return SyntaxFactory.ParenthesizedExpression(InvertCondition(((ParenthesizedExpressionSyntax)condition).Expression));
|
||||
}
|
||||
|
||||
if (condition is PrefixUnaryExpressionSyntax) {
|
||||
var uOp = (PrefixUnaryExpressionSyntax)condition;
|
||||
if (uOp.IsKind(SyntaxKind.LogicalNotExpression)) {
|
||||
if (!(uOp.Parent is ExpressionSyntax))
|
||||
return uOp.Operand.SkipParens();
|
||||
return uOp.Operand;
|
||||
}
|
||||
return SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, uOp);
|
||||
}
|
||||
|
||||
if (condition is BinaryExpressionSyntax) {
|
||||
var bOp = (BinaryExpressionSyntax)condition;
|
||||
|
||||
if (bOp.IsKind(SyntaxKind.LogicalAndExpression) || bOp.IsKind(SyntaxKind.LogicalOrExpression))
|
||||
return SyntaxFactory.BinaryExpression(NegateConditionOperator(bOp.Kind()), InvertCondition(bOp.Left), InvertCondition(bOp.Right));
|
||||
|
||||
if (bOp.IsKind(SyntaxKind.EqualsExpression) ||
|
||||
bOp.IsKind(SyntaxKind.NotEqualsExpression) ||
|
||||
bOp.IsKind(SyntaxKind.GreaterThanExpression) ||
|
||||
bOp.IsKind(SyntaxKind.GreaterThanOrEqualExpression) ||
|
||||
bOp.IsKind(SyntaxKind.LessThanExpression) ||
|
||||
bOp.IsKind(SyntaxKind.LessThanOrEqualExpression))
|
||||
return SyntaxFactory.BinaryExpression(NegateRelationalOperator(bOp.Kind()), bOp.Left, bOp.Right);
|
||||
|
||||
return SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, SyntaxFactory.ParenthesizedExpression(condition));
|
||||
}
|
||||
|
||||
if (condition is ConditionalExpressionSyntax) {
|
||||
var cEx = condition as ConditionalExpressionSyntax;
|
||||
return cEx.WithCondition(InvertCondition(cEx.Condition));
|
||||
}
|
||||
|
||||
if (condition is LiteralExpressionSyntax) {
|
||||
if (condition.Kind() == SyntaxKind.TrueLiteralExpression)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.FalseLiteralExpression);
|
||||
if (condition.Kind() == SyntaxKind.FalseLiteralExpression)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression);
|
||||
}
|
||||
|
||||
return SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, AddParensIfRequired(condition, false));
|
||||
}
|
||||
|
||||
|
||||
public static SyntaxKind GetExpressionOperatorTokenKind(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.EqualsExpression:
|
||||
return SyntaxKind.EqualsEqualsToken;
|
||||
case SyntaxKind.NotEqualsExpression:
|
||||
return SyntaxKind.ExclamationEqualsToken;
|
||||
case SyntaxKind.GreaterThanExpression:
|
||||
return SyntaxKind.GreaterThanToken;
|
||||
case SyntaxKind.GreaterThanOrEqualExpression:
|
||||
return SyntaxKind.GreaterThanEqualsToken;
|
||||
case SyntaxKind.LessThanExpression:
|
||||
return SyntaxKind.LessThanToken;
|
||||
case SyntaxKind.LessThanOrEqualExpression:
|
||||
return SyntaxKind.LessThanEqualsToken;
|
||||
case SyntaxKind.BitwiseOrExpression:
|
||||
return SyntaxKind.BarToken;
|
||||
case SyntaxKind.LogicalOrExpression:
|
||||
return SyntaxKind.BarBarToken;
|
||||
case SyntaxKind.BitwiseAndExpression:
|
||||
return SyntaxKind.AmpersandToken;
|
||||
case SyntaxKind.LogicalAndExpression:
|
||||
return SyntaxKind.AmpersandAmpersandToken;
|
||||
case SyntaxKind.AddExpression:
|
||||
return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.SubtractExpression:
|
||||
return SyntaxKind.MinusToken;
|
||||
case SyntaxKind.MultiplyExpression:
|
||||
return SyntaxKind.AsteriskToken;
|
||||
case SyntaxKind.DivideExpression:
|
||||
return SyntaxKind.SlashToken;
|
||||
case SyntaxKind.ModuloExpression:
|
||||
return SyntaxKind.PercentToken;
|
||||
// assignments
|
||||
case SyntaxKind.SimpleAssignmentExpression:
|
||||
return SyntaxKind.EqualsToken;
|
||||
case SyntaxKind.AddAssignmentExpression:
|
||||
return SyntaxKind.PlusEqualsToken;
|
||||
case SyntaxKind.SubtractAssignmentExpression:
|
||||
return SyntaxKind.MinusEqualsToken;
|
||||
// unary
|
||||
case SyntaxKind.UnaryPlusExpression:
|
||||
return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.UnaryMinusExpression:
|
||||
return SyntaxKind.MinusToken;
|
||||
case SyntaxKind.LogicalNotExpression:
|
||||
return SyntaxKind.ExclamationToken;
|
||||
case SyntaxKind.BitwiseNotExpression:
|
||||
return SyntaxKind.TildeToken;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(op));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When negating an expression this is required, otherwise you would end up with
|
||||
/// a or b -> !a or b
|
||||
/// </summary>
|
||||
public static ExpressionSyntax AddParensIfRequired(ExpressionSyntax expression, bool parenthesesRequiredForUnaryExpressions = true)
|
||||
{
|
||||
if ((expression is BinaryExpressionSyntax) ||
|
||||
(expression is AssignmentExpressionSyntax) ||
|
||||
(expression is CastExpressionSyntax) ||
|
||||
(expression is ParenthesizedLambdaExpressionSyntax) ||
|
||||
(expression is SimpleLambdaExpressionSyntax) ||
|
||||
(expression is ConditionalExpressionSyntax)) {
|
||||
return SyntaxFactory.ParenthesizedExpression(expression);
|
||||
}
|
||||
|
||||
if (parenthesesRequiredForUnaryExpressions &&
|
||||
((expression is PostfixUnaryExpressionSyntax) ||
|
||||
(expression is PrefixUnaryExpressionSyntax))) {
|
||||
return SyntaxFactory.ParenthesizedExpression(expression);
|
||||
}
|
||||
|
||||
return expression;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get negation of the specified relational operator
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// negation of the specified relational operator, or BinaryOperatorType.Any if it's not a relational operator
|
||||
/// </returns>
|
||||
public static SyntaxKind NegateRelationalOperator(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.EqualsExpression:
|
||||
return SyntaxKind.NotEqualsExpression;
|
||||
case SyntaxKind.NotEqualsExpression:
|
||||
return SyntaxKind.EqualsExpression;
|
||||
case SyntaxKind.GreaterThanExpression:
|
||||
return SyntaxKind.LessThanOrEqualExpression;
|
||||
case SyntaxKind.GreaterThanOrEqualExpression:
|
||||
return SyntaxKind.LessThanExpression;
|
||||
case SyntaxKind.LessThanExpression:
|
||||
return SyntaxKind.GreaterThanOrEqualExpression;
|
||||
case SyntaxKind.LessThanOrEqualExpression:
|
||||
return SyntaxKind.GreaterThanExpression;
|
||||
case SyntaxKind.LogicalOrExpression:
|
||||
return SyntaxKind.LogicalAndExpression;
|
||||
case SyntaxKind.LogicalAndExpression:
|
||||
return SyntaxKind.LogicalOrExpression;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException("op");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the specified operator is a relational operator
|
||||
/// </summary>
|
||||
public static bool IsRelationalOperator(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.EqualsExpression:
|
||||
case SyntaxKind.NotEqualsExpression:
|
||||
case SyntaxKind.GreaterThanExpression:
|
||||
case SyntaxKind.GreaterThanOrEqualExpression:
|
||||
case SyntaxKind.LessThanExpression:
|
||||
case SyntaxKind.LessThanOrEqualExpression:
|
||||
case SyntaxKind.LogicalOrExpression:
|
||||
case SyntaxKind.LogicalAndExpression:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get negation of the condition operator
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// negation of the specified condition operator, or BinaryOperatorType.Any if it's not a condition operator
|
||||
/// </returns>
|
||||
public static SyntaxKind NegateConditionOperator(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.LogicalOrExpression:
|
||||
return SyntaxKind.LogicalAndExpression;
|
||||
case SyntaxKind.LogicalAndExpression:
|
||||
return SyntaxKind.LogicalOrExpression;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException("op");
|
||||
}
|
||||
|
||||
public static bool AreConditionsEqual(ExpressionSyntax cond1, ExpressionSyntax cond2)
|
||||
{
|
||||
if (cond1 == null || cond2 == null)
|
||||
return false;
|
||||
return cond1.SkipParens().IsEquivalentTo(cond2.SkipParens(), true);
|
||||
}
|
||||
|
||||
public static ExpressionSyntax ExtractUnaryOperand(this ExpressionSyntax expr)
|
||||
{
|
||||
if (expr == null)
|
||||
throw new ArgumentNullException(nameof(expr));
|
||||
if (expr is PostfixUnaryExpressionSyntax)
|
||||
return ((PostfixUnaryExpressionSyntax)expr).Operand;
|
||||
if (expr is PrefixUnaryExpressionSyntax)
|
||||
return ((PrefixUnaryExpressionSyntax)expr).Operand;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static T WithBody<T>(this T method, BlockSyntax body) where T : BaseMethodDeclarationSyntax
|
||||
{
|
||||
if (method == null)
|
||||
throw new ArgumentNullException(nameof(method));
|
||||
var m = method as MethodDeclarationSyntax;
|
||||
if (m != null)
|
||||
return (T)((BaseMethodDeclarationSyntax)m.WithBody(body));
|
||||
var d = method as DestructorDeclarationSyntax;
|
||||
if (d != null)
|
||||
return (T)((BaseMethodDeclarationSyntax)d.WithBody(body));
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public static TypeSyntax ToSyntax(this ITypeSymbol type, SemanticModel model, TypeSyntax typeSyntax)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
return SyntaxFactory.ParseTypeName(type.ToMinimalDisplayString(model, typeSyntax.SpanStart))
|
||||
.WithLeadingTrivia(typeSyntax.GetLeadingTrivia())
|
||||
.WithTrailingTrivia(typeSyntax.GetTrailingTrivia());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,325 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static partial class EnumerableExtensions
|
||||
{
|
||||
public static IEnumerable<T> Do<T>(this IEnumerable<T> source, Action<T> action)
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
if (action == null) {
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
// perf optimization. try to not use enumerator if possible
|
||||
var list = source as IList<T>;
|
||||
if (list != null) {
|
||||
for (int i = 0, count = list.Count; i < count; i++) {
|
||||
action(list[i]);
|
||||
}
|
||||
} else {
|
||||
foreach (var value in source) {
|
||||
action(value);
|
||||
}
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
public static ReadOnlyCollection<T> ToReadOnlyCollection<T>(this IEnumerable<T> source)
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
return new ReadOnlyCollection<T>(source.ToList());
|
||||
}
|
||||
|
||||
public static IEnumerable<T> Concat<T>(this IEnumerable<T> source, T value)
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
return source.ConcatWorker(value);
|
||||
}
|
||||
|
||||
private static IEnumerable<T> ConcatWorker<T>(this IEnumerable<T> source, T value)
|
||||
{
|
||||
foreach (var v in source) {
|
||||
yield return v;
|
||||
}
|
||||
|
||||
yield return value;
|
||||
}
|
||||
|
||||
public static bool SetEquals<T>(this IEnumerable<T> source1, IEnumerable<T> source2, IEqualityComparer<T> comparer)
|
||||
{
|
||||
if (source1 == null) {
|
||||
throw new ArgumentNullException(nameof(source1));
|
||||
}
|
||||
|
||||
if (source2 == null) {
|
||||
throw new ArgumentNullException(nameof(source2));
|
||||
}
|
||||
|
||||
return source1.ToSet(comparer).SetEquals(source2);
|
||||
}
|
||||
|
||||
public static bool SetEquals<T>(this IEnumerable<T> source1, IEnumerable<T> source2)
|
||||
{
|
||||
if (source1 == null) {
|
||||
throw new ArgumentNullException(nameof(source1));
|
||||
}
|
||||
|
||||
if (source2 == null) {
|
||||
throw new ArgumentNullException(nameof(source2));
|
||||
}
|
||||
|
||||
return source1.ToSet().SetEquals(source2);
|
||||
}
|
||||
|
||||
public static ISet<T> ToSet<T>(this IEnumerable<T> source, IEqualityComparer<T> comparer)
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
return new HashSet<T>(source, comparer);
|
||||
}
|
||||
|
||||
public static ISet<T> ToSet<T>(this IEnumerable<T> source)
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
return source as ISet<T> ?? new HashSet<T>(source);
|
||||
}
|
||||
|
||||
public static T? FirstOrNullable<T>(this IEnumerable<T> source)
|
||||
where T : struct
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
return source.Cast<T?>().FirstOrDefault();
|
||||
}
|
||||
|
||||
public static T? FirstOrNullable<T>(this IEnumerable<T> source, Func<T, bool> predicate)
|
||||
where T : struct
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
return source.Cast<T?>().FirstOrDefault(v => predicate(v.Value));
|
||||
}
|
||||
|
||||
public static T? LastOrNullable<T>(this IEnumerable<T> source)
|
||||
where T : struct
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
return source.Cast<T?>().LastOrDefault();
|
||||
}
|
||||
|
||||
public static bool IsSingle<T>(this IEnumerable<T> list)
|
||||
{
|
||||
using (var enumerator = list.GetEnumerator()) {
|
||||
return enumerator.MoveNext() && !enumerator.MoveNext();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsEmpty<T>(this IEnumerable<T> source)
|
||||
{
|
||||
var readOnlyCollection = source as IReadOnlyCollection<T>;
|
||||
if (readOnlyCollection != null) {
|
||||
return readOnlyCollection.Count == 0;
|
||||
}
|
||||
|
||||
var genericCollection = source as ICollection<T>;
|
||||
if (genericCollection != null) {
|
||||
return genericCollection.Count == 0;
|
||||
}
|
||||
|
||||
var collection = source as ICollection;
|
||||
if (collection != null) {
|
||||
return collection.Count == 0;
|
||||
}
|
||||
|
||||
var str = source as string;
|
||||
if (str != null) {
|
||||
return str.Length == 0;
|
||||
}
|
||||
|
||||
foreach (var t in source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsEmpty<T>(this IReadOnlyCollection<T> source)
|
||||
{
|
||||
return source.Count == 0;
|
||||
}
|
||||
|
||||
public static bool IsEmpty<T>(this ICollection<T> source)
|
||||
{
|
||||
return source.Count == 0;
|
||||
}
|
||||
|
||||
public static bool IsEmpty(this string source)
|
||||
{
|
||||
return source.Length == 0;
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This method is necessary to avoid an ambiguity between <see cref="IsEmpty{T}(IReadOnlyCollection{T})"/> and <see cref="IsEmpty{T}(ICollection{T})"/>.
|
||||
/// </remarks>
|
||||
public static bool IsEmpty<T>(this T[] source)
|
||||
{
|
||||
return source.Length == 0;
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This method is necessary to avoid an ambiguity between <see cref="IsEmpty{T}(IReadOnlyCollection{T})"/> and <see cref="IsEmpty{T}(ICollection{T})"/>.
|
||||
/// </remarks>
|
||||
public static bool IsEmpty<T>(this List<T> source)
|
||||
{
|
||||
return source.Count == 0;
|
||||
}
|
||||
|
||||
private static readonly Func<object, bool> s_notNullTest = x => x != null;
|
||||
|
||||
public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T> source)
|
||||
where T : class
|
||||
{
|
||||
if (source == null) {
|
||||
return SpecializedCollections.EmptyEnumerable<T>();
|
||||
}
|
||||
|
||||
return source.Where((Func<T, bool>)s_notNullTest);
|
||||
}
|
||||
|
||||
public static bool All(this IEnumerable<bool> source)
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
foreach (var b in source) {
|
||||
if (!b) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> Flatten<T>(this IEnumerable<IEnumerable<T>> sequence)
|
||||
{
|
||||
if (sequence == null) {
|
||||
throw new ArgumentNullException(nameof(sequence));
|
||||
}
|
||||
|
||||
return sequence.SelectMany(s => s);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> source, IComparer<T> comparer)
|
||||
{
|
||||
return source.OrderBy(t => t, comparer);
|
||||
}
|
||||
|
||||
// public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> source, Comparison<T> compare)
|
||||
// {
|
||||
// return source.OrderBy(new ComparisonComparer<T>(compare));
|
||||
// }
|
||||
|
||||
// public static IEnumerable<T> Order<T>(this IEnumerable<T> source) where T : IComparable<T>
|
||||
// {
|
||||
// return source.OrderBy((t1, t2) => t1.CompareTo(t2));
|
||||
// }
|
||||
|
||||
public static bool IsSorted<T>(this IEnumerable<T> enumerable, IComparer<T> comparer)
|
||||
{
|
||||
using (var e = enumerable.GetEnumerator()) {
|
||||
if (!e.MoveNext()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var previous = e.Current;
|
||||
while (e.MoveNext()) {
|
||||
if (comparer.Compare(previous, e.Current) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
previous = e.Current;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SequenceEqual<T>(this IEnumerable<T> first, IEnumerable<T> second, Func<T, T, bool> comparer)
|
||||
{
|
||||
Debug.Assert(comparer != null);
|
||||
|
||||
if (first == second) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (first == null || second == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
using (var enumerator = first.GetEnumerator())
|
||||
using (var enumerator2 = second.GetEnumerator()) {
|
||||
while (enumerator.MoveNext()) {
|
||||
if (!enumerator2.MoveNext() || !comparer(enumerator.Current, enumerator2.Current)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (enumerator2.MoveNext()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Contains<T>(this IEnumerable<T> sequence, Func<T, bool> predicate)
|
||||
{
|
||||
return sequence.Any(predicate);
|
||||
}
|
||||
|
||||
public static int IndexOf<T>(this IEnumerable<T> sequence, Func<T, bool> predicate)
|
||||
{
|
||||
if (sequence == null)
|
||||
throw new ArgumentNullException(nameof(sequence));
|
||||
int index = 0;
|
||||
foreach (var item in sequence) {
|
||||
if (predicate(item))
|
||||
return index;
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,125 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
internal static class FindTokenHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// If the position is inside of token, return that token; otherwise, return the token to the right.
|
||||
/// </summary>
|
||||
public static SyntaxToken FindTokenOnRightOfPosition<TRoot>(
|
||||
SyntaxNode root,
|
||||
int position,
|
||||
Func<SyntaxTriviaList, int, SyntaxToken> skippedTokenFinder,
|
||||
bool includeSkipped = false,
|
||||
bool includeDirectives = false,
|
||||
bool includeDocumentationComments = false)
|
||||
where TRoot : SyntaxNode
|
||||
{
|
||||
var findSkippedToken = skippedTokenFinder ?? ((l, p) => default(SyntaxToken));
|
||||
|
||||
var token = GetInitialToken<TRoot>(root, position, includeSkipped, includeDirectives, includeDocumentationComments);
|
||||
|
||||
if (position < token.SpanStart) {
|
||||
var skippedToken = findSkippedToken(token.LeadingTrivia, position);
|
||||
token = skippedToken.RawKind != 0 ? skippedToken : token;
|
||||
} else if (token.Span.End <= position) {
|
||||
do {
|
||||
var skippedToken = findSkippedToken(token.TrailingTrivia, position);
|
||||
token = skippedToken.RawKind != 0
|
||||
? skippedToken
|
||||
: token.GetNextToken(includeZeroWidth: false, includeSkipped: includeSkipped, includeDirectives: includeDirectives, includeDocumentationComments: includeDocumentationComments);
|
||||
}
|
||||
while (token.RawKind != 0 && token.Span.End <= position && token.Span.End <= root.FullSpan.End);
|
||||
}
|
||||
|
||||
if (token.Span.Length == 0) {
|
||||
token = token.GetNextToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the position is inside of token, return that token; otherwise, return the token to the left.
|
||||
/// </summary>
|
||||
public static SyntaxToken FindTokenOnLeftOfPosition<TRoot>(
|
||||
SyntaxNode root,
|
||||
int position,
|
||||
Func<SyntaxTriviaList, int, SyntaxToken> skippedTokenFinder,
|
||||
bool includeSkipped = false,
|
||||
bool includeDirectives = false,
|
||||
bool includeDocumentationComments = false)
|
||||
where TRoot : SyntaxNode
|
||||
{
|
||||
var findSkippedToken = skippedTokenFinder ?? ((l, p) => default(SyntaxToken));
|
||||
|
||||
var token = GetInitialToken<TRoot>(root, position, includeSkipped, includeDirectives, includeDocumentationComments);
|
||||
|
||||
if (position <= token.SpanStart) {
|
||||
do {
|
||||
var skippedToken = findSkippedToken(token.LeadingTrivia, position);
|
||||
token = skippedToken.RawKind != 0
|
||||
? skippedToken
|
||||
: token.GetPreviousToken(includeZeroWidth: false, includeSkipped: includeSkipped, includeDirectives: includeDirectives, includeDocumentationComments: includeDocumentationComments);
|
||||
}
|
||||
while (position <= token.SpanStart && root.FullSpan.Start < token.SpanStart);
|
||||
} else if (token.Span.End < position) {
|
||||
var skippedToken = findSkippedToken(token.TrailingTrivia, position);
|
||||
token = skippedToken.RawKind != 0 ? skippedToken : token;
|
||||
}
|
||||
|
||||
if (token.Span.Length == 0) {
|
||||
token = token.GetPreviousToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
private static SyntaxToken GetInitialToken<TRoot>(
|
||||
SyntaxNode root,
|
||||
int position,
|
||||
bool includeSkipped = false,
|
||||
bool includeDirectives = false,
|
||||
bool includeDocumentationComments = false)
|
||||
where TRoot : SyntaxNode
|
||||
{
|
||||
var token = (position < root.FullSpan.End || !(root is TRoot))
|
||||
? root.FindToken(position, includeSkipped || includeDirectives || includeDocumentationComments)
|
||||
: root.GetLastToken(includeZeroWidth: true, includeSkipped: true, includeDirectives: true, includeDocumentationComments: true)
|
||||
.GetPreviousToken(includeZeroWidth: false, includeSkipped: includeSkipped, includeDirectives: includeDirectives, includeDocumentationComments: includeDocumentationComments);
|
||||
return token;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Look inside a trivia list for a skipped token that contains the given position.
|
||||
/// </summary>
|
||||
public static SyntaxToken FindSkippedTokenBackward(IEnumerable<SyntaxToken> skippedTokenList, int position)
|
||||
{
|
||||
// the given skipped token list is already in order
|
||||
var skippedTokenContainingPosition = skippedTokenList.LastOrDefault(skipped => skipped.Span.Length > 0 && skipped.SpanStart <= position);
|
||||
if (skippedTokenContainingPosition != default(SyntaxToken)) {
|
||||
return skippedTokenContainingPosition;
|
||||
}
|
||||
|
||||
return default(SyntaxToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Look inside a trivia list for a skipped token that contains the given position.
|
||||
/// </summary>
|
||||
public static SyntaxToken FindSkippedTokenForward(IEnumerable<SyntaxToken> skippedTokenList, int position)
|
||||
{
|
||||
// the given token list is already in order
|
||||
var skippedTokenContainingPosition = skippedTokenList.FirstOrDefault(skipped => skipped.Span.Length > 0 && position <= skipped.Span.End);
|
||||
if (skippedTokenContainingPosition != default(SyntaxToken)) {
|
||||
return skippedTokenContainingPosition;
|
||||
}
|
||||
|
||||
return default(SyntaxToken);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class IAssemblySymbolExtensions
|
||||
{
|
||||
private const string AttributeSuffix = "Attribute";
|
||||
|
||||
public static bool ContainsNamespaceName(
|
||||
this List<IAssemblySymbol> assemblies,
|
||||
string namespaceName)
|
||||
{
|
||||
// PERF: Expansion of "assemblies.Any(a => a.NamespaceNames.Contains(namespaceName))"
|
||||
// to avoid allocating a lambda.
|
||||
foreach (var a in assemblies) {
|
||||
if (a.NamespaceNames.Contains(namespaceName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ContainsTypeName(this List<IAssemblySymbol> assemblies, string typeName, bool tryWithAttributeSuffix = false)
|
||||
{
|
||||
if (!tryWithAttributeSuffix) {
|
||||
// PERF: Expansion of "assemblies.Any(a => a.TypeNames.Contains(typeName))"
|
||||
// to avoid allocating a lambda.
|
||||
foreach (var a in assemblies) {
|
||||
if (a.TypeNames.Contains(typeName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var attributeName = typeName + AttributeSuffix;
|
||||
foreach (var a in assemblies) {
|
||||
var typeNames = a.TypeNames;
|
||||
if (typeNames.Contains(typeName) || typeNames.Contains(attributeName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsSameAssemblyOrHasFriendAccessTo(this IAssemblySymbol assembly, IAssemblySymbol toAssembly)
|
||||
{
|
||||
return
|
||||
Equals(assembly, toAssembly) ||
|
||||
(assembly.IsInteractive && toAssembly.IsInteractive) ||
|
||||
toAssembly.GivesAccessTo(assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static partial class INamespaceOrTypeSymbolExtensions
|
||||
{
|
||||
private static readonly ConditionalWeakTable<INamespaceOrTypeSymbol, List<string>> s_namespaceOrTypeToNameMap =
|
||||
new ConditionalWeakTable<INamespaceOrTypeSymbol, List<string>>();
|
||||
|
||||
private static readonly SymbolDisplayFormat s_shortNameFormat = new SymbolDisplayFormat(
|
||||
miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes | SymbolDisplayMiscellaneousOptions.ExpandNullable);
|
||||
|
||||
public static readonly Comparison<INamespaceOrTypeSymbol> CompareNamespaceOrTypeSymbols = CompareTo;
|
||||
|
||||
public static string GetShortName(this INamespaceOrTypeSymbol symbol)
|
||||
{
|
||||
return symbol.ToDisplayString(s_shortNameFormat);
|
||||
}
|
||||
|
||||
public static IEnumerable<IPropertySymbol> GetIndexers(this INamespaceOrTypeSymbol symbol)
|
||||
{
|
||||
return symbol == null
|
||||
? SpecializedCollections.EmptyEnumerable<IPropertySymbol>()
|
||||
: symbol.GetMembers(WellKnownMemberNames.Indexer).OfType<IPropertySymbol>().Where(p => p.IsIndexer);
|
||||
}
|
||||
|
||||
public static int CompareTo(this INamespaceOrTypeSymbol n1, INamespaceOrTypeSymbol n2)
|
||||
{
|
||||
var names1 = s_namespaceOrTypeToNameMap.GetValue(n1, GetNameParts);
|
||||
var names2 = s_namespaceOrTypeToNameMap.GetValue(n2, GetNameParts);
|
||||
|
||||
for (var i = 0; i < Math.Min(names1.Count, names2.Count); i++) {
|
||||
var comp = names1[i].CompareTo(names2[i]);
|
||||
if (comp != 0) {
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
return names1.Count - names2.Count;
|
||||
}
|
||||
|
||||
private static List<string> GetNameParts(INamespaceOrTypeSymbol namespaceSymbol)
|
||||
{
|
||||
var result = new List<string>();
|
||||
GetNameParts(namespaceSymbol, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void GetNameParts(INamespaceOrTypeSymbol namespaceOrTypeSymbol, List<string> result)
|
||||
{
|
||||
if (namespaceOrTypeSymbol == null || (namespaceOrTypeSymbol.IsNamespace && ((INamespaceSymbol)namespaceOrTypeSymbol).IsGlobalNamespace)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GetNameParts(namespaceOrTypeSymbol.ContainingNamespace, result);
|
||||
result.Add(namespaceOrTypeSymbol.Name);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Editing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class ISymbolExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if 'symbol' is accessible from within 'within'.
|
||||
/// </summary>
|
||||
public static bool IsAccessibleWithin(
|
||||
this ISymbol symbol,
|
||||
ISymbol within,
|
||||
ITypeSymbol throughTypeOpt = null)
|
||||
{
|
||||
if (within is IAssemblySymbol) {
|
||||
return symbol.IsAccessibleWithin((IAssemblySymbol)within, throughTypeOpt);
|
||||
} else if (within is INamedTypeSymbol) {
|
||||
return symbol.IsAccessibleWithin((INamedTypeSymbol)within, throughTypeOpt);
|
||||
} else {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
// Is a top-level type with accessibility "declaredAccessibility" inside assembly "assembly"
|
||||
// accessible from "within", which must be a named type of an assembly.
|
||||
private static bool IsNonNestedTypeAccessible(
|
||||
IAssemblySymbol assembly,
|
||||
Accessibility declaredAccessibility,
|
||||
ISymbol within)
|
||||
{
|
||||
// Contract.Requires(within is INamedTypeSymbol || within is IAssemblySymbol);
|
||||
// Contract.ThrowIfNull(assembly);
|
||||
var withinAssembly = (within as IAssemblySymbol) ?? ((INamedTypeSymbol)within).ContainingAssembly;
|
||||
|
||||
switch (declaredAccessibility) {
|
||||
case Accessibility.NotApplicable:
|
||||
case Accessibility.Public:
|
||||
// Public symbols are always accessible from any context
|
||||
return true;
|
||||
|
||||
case Accessibility.Private:
|
||||
case Accessibility.Protected:
|
||||
case Accessibility.ProtectedAndInternal:
|
||||
// Shouldn't happen except in error cases.
|
||||
return false;
|
||||
|
||||
case Accessibility.Internal:
|
||||
case Accessibility.ProtectedOrInternal:
|
||||
// An internal type is accessible if we're in the same assembly or we have
|
||||
// friend access to the assembly it was defined in.
|
||||
return withinAssembly.IsSameAssemblyOrHasFriendAccessTo(assembly);
|
||||
|
||||
default:
|
||||
throw new Exception("unreachable");
|
||||
}
|
||||
}
|
||||
|
||||
// Is a private symbol access
|
||||
private static bool IsPrivateSymbolAccessible(
|
||||
ISymbol within,
|
||||
INamedTypeSymbol originalContainingType)
|
||||
{
|
||||
//Contract.Requires(within is INamedTypeSymbol || within is IAssemblySymbol);
|
||||
|
||||
var withinType = within as INamedTypeSymbol;
|
||||
if (withinType == null) {
|
||||
// If we're not within a type, we can't access a private symbol
|
||||
return false;
|
||||
}
|
||||
|
||||
// A private symbol is accessible if we're (optionally nested) inside the type that it
|
||||
// was defined in.
|
||||
return IsNestedWithinOriginalContainingType(withinType, originalContainingType);
|
||||
}
|
||||
|
||||
// Is the type "withinType" nested within the original type "originalContainingType".
|
||||
private static bool IsNestedWithinOriginalContainingType(
|
||||
INamedTypeSymbol withinType,
|
||||
INamedTypeSymbol originalContainingType)
|
||||
{
|
||||
// Contract.ThrowIfNull(withinType);
|
||||
// Contract.ThrowIfNull(originalContainingType);
|
||||
|
||||
// Walk up my parent chain and see if I eventually hit the owner. If so then I'm a
|
||||
// nested type of that owner and I'm allowed access to everything inside of it.
|
||||
var current = withinType.OriginalDefinition;
|
||||
while (current != null) {
|
||||
//Contract.Requires(current.IsDefinition);
|
||||
if (current.Equals(originalContainingType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// NOTE(cyrusn): The container of an 'original' type is always original.
|
||||
current = current.ContainingType;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsDefinedInMetadata(this ISymbol symbol)
|
||||
{
|
||||
return symbol.Locations.Any(loc => loc.IsInMetadata);
|
||||
}
|
||||
|
||||
public static bool IsDefinedInSource(this ISymbol symbol)
|
||||
{
|
||||
return symbol.Locations.All(loc => loc.IsInSource);
|
||||
}
|
||||
|
||||
public static DeclarationModifiers GetSymbolModifiers(this ISymbol symbol)
|
||||
{
|
||||
// ported from roslyn source - why they didn't use DeclarationModifiers.From (symbol) ?
|
||||
return DeclarationModifiers.None
|
||||
.WithIsStatic(symbol.IsStatic)
|
||||
.WithIsAbstract(symbol.IsAbstract)
|
||||
.WithIsUnsafe(symbol.IsUnsafe())
|
||||
.WithIsVirtual(symbol.IsVirtual)
|
||||
.WithIsOverride(symbol.IsOverride)
|
||||
.WithIsSealed(symbol.IsSealed);
|
||||
}
|
||||
|
||||
public static IEnumerable<SyntaxReference> GetDeclarations(this ISymbol symbol)
|
||||
{
|
||||
return symbol != null
|
||||
? symbol.DeclaringSyntaxReferences.AsEnumerable()
|
||||
: SpecializedCollections.EmptyEnumerable<SyntaxReference>();
|
||||
}
|
||||
|
||||
public static ISymbol GetContainingMemberOrThis(this ISymbol symbol)
|
||||
{
|
||||
if (symbol == null)
|
||||
return null;
|
||||
switch (symbol.Kind) {
|
||||
case SymbolKind.Assembly:
|
||||
case SymbolKind.NetModule:
|
||||
case SymbolKind.Namespace:
|
||||
case SymbolKind.Preprocessing:
|
||||
case SymbolKind.Alias:
|
||||
case SymbolKind.ArrayType:
|
||||
case SymbolKind.DynamicType:
|
||||
case SymbolKind.ErrorType:
|
||||
case SymbolKind.NamedType:
|
||||
case SymbolKind.PointerType:
|
||||
case SymbolKind.Label:
|
||||
throw new NotSupportedException();
|
||||
case SymbolKind.Field:
|
||||
case SymbolKind.Property:
|
||||
case SymbolKind.Event:
|
||||
return symbol;
|
||||
case SymbolKind.Method:
|
||||
if (symbol.IsAccessorMethod())
|
||||
return ((IMethodSymbol)symbol).AssociatedSymbol;
|
||||
return symbol;
|
||||
case SymbolKind.Local:
|
||||
case SymbolKind.Parameter:
|
||||
case SymbolKind.TypeParameter:
|
||||
case SymbolKind.RangeVariable:
|
||||
return GetContainingMemberOrThis(symbol.ContainingSymbol);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class ITypeParameterSymbolExtensions
|
||||
{
|
||||
public static INamedTypeSymbol GetNamedTypeSymbolConstraint(this ITypeParameterSymbol typeParameter)
|
||||
{
|
||||
return typeParameter.ConstraintTypes.Select(GetNamedTypeSymbol).WhereNotNull().FirstOrDefault();
|
||||
}
|
||||
|
||||
private static INamedTypeSymbol GetNamedTypeSymbol(ITypeSymbol type)
|
||||
{
|
||||
return type is INamedTypeSymbol
|
||||
? (INamedTypeSymbol)type
|
||||
: type is ITypeParameterSymbol
|
||||
? GetNamedTypeSymbolConstraint((ITypeParameterSymbol)type)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,881 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.ComponentModel;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class ITypeSymbolExtensions
|
||||
{
|
||||
public static bool ImplementsSpecialTypeInterface(this ITypeSymbol symbol, SpecialType type)
|
||||
{
|
||||
if (symbol.SpecialType == type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var namedType = symbol as INamedTypeSymbol;
|
||||
if (namedType != null && namedType.IsGenericType && namedType != namedType.ConstructedFrom) {
|
||||
return namedType.ConstructedFrom.ImplementsSpecialTypeInterface(type);
|
||||
}
|
||||
|
||||
var typeParam = symbol as ITypeParameterSymbol;
|
||||
if (typeParam != null) {
|
||||
return typeParam.ConstraintTypes.Any(x => x.ImplementsSpecialTypeInterface(type));
|
||||
}
|
||||
|
||||
if (symbol.AllInterfaces.Any(x => x.ImplementsSpecialTypeInterface(type))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private const string DefaultParameterName = "p";
|
||||
private const string DefaultBuiltInParameterName = "v";
|
||||
|
||||
public static IList<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
|
||||
{
|
||||
var allInterfaces = type.AllInterfaces;
|
||||
var namedType = type as INamedTypeSymbol;
|
||||
if (namedType != null && namedType.TypeKind == TypeKind.Interface && !allInterfaces.Contains(namedType)) {
|
||||
var result = new List<INamedTypeSymbol>(allInterfaces.Length + 1);
|
||||
result.Add(namedType);
|
||||
result.AddRange(allInterfaces);
|
||||
return result;
|
||||
}
|
||||
|
||||
return allInterfaces;
|
||||
}
|
||||
|
||||
public static bool IsAbstractClass(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol?.TypeKind == TypeKind.Class && symbol.IsAbstract;
|
||||
}
|
||||
|
||||
public static bool IsSystemVoid(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol?.SpecialType == SpecialType.System_Void;
|
||||
}
|
||||
|
||||
public static bool IsNullable(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol?.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T;
|
||||
}
|
||||
|
||||
public static bool IsErrorType(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol?.TypeKind == TypeKind.Error;
|
||||
}
|
||||
|
||||
public static bool IsModuleType(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol?.TypeKind == TypeKind.Module;
|
||||
}
|
||||
|
||||
public static bool IsInterfaceType(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol?.TypeKind == TypeKind.Interface;
|
||||
}
|
||||
|
||||
public static bool IsDelegateType(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol?.TypeKind == TypeKind.Delegate;
|
||||
}
|
||||
|
||||
public static bool IsAnonymousType(this INamedTypeSymbol symbol)
|
||||
{
|
||||
return symbol?.IsAnonymousType == true;
|
||||
}
|
||||
|
||||
// public static ITypeSymbol RemoveNullableIfPresent(this ITypeSymbol symbol)
|
||||
// {
|
||||
// if (symbol.IsNullable())
|
||||
// {
|
||||
// return symbol.GetTypeArguments().Single();
|
||||
// }
|
||||
//
|
||||
// return symbol;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Returns the corresponding symbol in this type or a base type that implements
|
||||
// /// interfaceMember (either implicitly or explicitly), or null if no such symbol exists
|
||||
// /// (which might be either because this type doesn't implement the container of
|
||||
// /// interfaceMember, or this type doesn't supply a member that successfully implements
|
||||
// /// interfaceMember).
|
||||
// /// </summary>
|
||||
// public static IEnumerable<ISymbol> FindImplementationsForInterfaceMember(
|
||||
// this ITypeSymbol typeSymbol,
|
||||
// ISymbol interfaceMember,
|
||||
// Workspace workspace,
|
||||
// CancellationToken cancellationToken)
|
||||
// {
|
||||
// // This method can return multiple results. Consider the case of:
|
||||
// //
|
||||
// // interface IFoo<X> { void Foo(X x); }
|
||||
// //
|
||||
// // class C : IFoo<int>, IFoo<string> { void Foo(int x); void Foo(string x); }
|
||||
// //
|
||||
// // If you're looking for the implementations of IFoo<X>.Foo then you want to find both
|
||||
// // results in C.
|
||||
//
|
||||
// // TODO(cyrusn): Implement this using the actual code for
|
||||
// // TypeSymbol.FindImplementationForInterfaceMember
|
||||
//
|
||||
// if (typeSymbol == null || interfaceMember == null)
|
||||
// {
|
||||
// yield break;
|
||||
// }
|
||||
//
|
||||
// if (interfaceMember.Kind != SymbolKind.Event &&
|
||||
// interfaceMember.Kind != SymbolKind.Method &&
|
||||
// interfaceMember.Kind != SymbolKind.Property)
|
||||
// {
|
||||
// yield break;
|
||||
// }
|
||||
//
|
||||
// // WorkItem(4843)
|
||||
// //
|
||||
// // 'typeSymbol' has to at least implement the interface containing the member. note:
|
||||
// // this just means that the interface shows up *somewhere* in the inheritance chain of
|
||||
// // this type. However, this type may not actually say that it implements it. For
|
||||
// // example:
|
||||
// //
|
||||
// // interface I { void Foo(); }
|
||||
// //
|
||||
// // class B { }
|
||||
// //
|
||||
// // class C : B, I { }
|
||||
// //
|
||||
// // class D : C { }
|
||||
// //
|
||||
// // D does implement I transitively through C. However, even if D has a "Foo" method, it
|
||||
// // won't be an implementation of I.Foo. The implementation of I.Foo must be from a type
|
||||
// // that actually has I in it's direct interface chain, or a type that's a base type of
|
||||
// // that. in this case, that means only classes C or B.
|
||||
// var interfaceType = interfaceMember.ContainingType;
|
||||
// if (!typeSymbol.ImplementsIgnoringConstruction(interfaceType))
|
||||
// {
|
||||
// yield break;
|
||||
// }
|
||||
//
|
||||
// // We've ascertained that the type T implements some constructed type of the form I<X>.
|
||||
// // However, we're not precisely sure which constructions of I<X> are being used. For
|
||||
// // example, a type C might implement I<int> and I<string>. If we're searching for a
|
||||
// // method from I<X> we might need to find several methods that implement different
|
||||
// // instantiations of that method.
|
||||
// var originalInterfaceType = interfaceMember.ContainingType.OriginalDefinition;
|
||||
// var originalInterfaceMember = interfaceMember.OriginalDefinition;
|
||||
// var constructedInterfaces = typeSymbol.AllInterfaces.Where(i =>
|
||||
// SymbolEquivalenceComparer.Instance.Equals(i.OriginalDefinition, originalInterfaceType));
|
||||
//
|
||||
// foreach (var constructedInterface in constructedInterfaces)
|
||||
// {
|
||||
// cancellationToken.ThrowIfCancellationRequested();
|
||||
// var constructedInterfaceMember = constructedInterface.GetMembers().FirstOrDefault(m =>
|
||||
// SymbolEquivalenceComparer.Instance.Equals(m.OriginalDefinition, originalInterfaceMember));
|
||||
//
|
||||
// if (constructedInterfaceMember == null)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // Now we need to walk the base type chain, but we start at the first type that actually
|
||||
// // has the interface directly in its interface hierarchy.
|
||||
// var seenTypeDeclaringInterface = false;
|
||||
// for (var currentType = typeSymbol; currentType != null; currentType = currentType.BaseType)
|
||||
// {
|
||||
// seenTypeDeclaringInterface = seenTypeDeclaringInterface ||
|
||||
// currentType.GetOriginalInterfacesAndTheirBaseInterfaces().Contains(interfaceType.OriginalDefinition);
|
||||
//
|
||||
// if (seenTypeDeclaringInterface)
|
||||
// {
|
||||
// var result = constructedInterfaceMember.TypeSwitch(
|
||||
// (IEventSymbol eventSymbol) => FindImplementations(currentType, eventSymbol, workspace, e => e.ExplicitInterfaceImplementations),
|
||||
// (IMethodSymbol methodSymbol) => FindImplementations(currentType, methodSymbol, workspace, m => m.ExplicitInterfaceImplementations),
|
||||
// (IPropertySymbol propertySymbol) => FindImplementations(currentType, propertySymbol, workspace, p => p.ExplicitInterfaceImplementations));
|
||||
//
|
||||
// if (result != null)
|
||||
// {
|
||||
// yield return result;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static HashSet<INamedTypeSymbol> GetOriginalInterfacesAndTheirBaseInterfaces(
|
||||
// this ITypeSymbol type,
|
||||
// HashSet<INamedTypeSymbol> symbols = null)
|
||||
// {
|
||||
// symbols = symbols ?? new HashSet<INamedTypeSymbol>(SymbolEquivalenceComparer.Instance);
|
||||
//
|
||||
// foreach (var interfaceType in type.Interfaces)
|
||||
// {
|
||||
// symbols.Add(interfaceType.OriginalDefinition);
|
||||
// symbols.AddRange(interfaceType.AllInterfaces.Select(i => i.OriginalDefinition));
|
||||
// }
|
||||
//
|
||||
// return symbols;
|
||||
// }
|
||||
|
||||
// private static ISymbol FindImplementations<TSymbol>(
|
||||
// ITypeSymbol typeSymbol,
|
||||
// TSymbol interfaceSymbol,
|
||||
// Workspace workspace,
|
||||
// Func<TSymbol, ImmutableArray<TSymbol>> getExplicitInterfaceImplementations) where TSymbol : class, ISymbol
|
||||
// {
|
||||
// // Check the current type for explicit interface matches. Otherwise, check
|
||||
// // the current type and base types for implicit matches.
|
||||
// var explicitMatches =
|
||||
// from member in typeSymbol.GetMembers().OfType<TSymbol>()
|
||||
// where getExplicitInterfaceImplementations(member).Length > 0
|
||||
// from explicitInterfaceMethod in getExplicitInterfaceImplementations(member)
|
||||
// where SymbolEquivalenceComparer.Instance.Equals(explicitInterfaceMethod, interfaceSymbol)
|
||||
// select member;
|
||||
//
|
||||
// var provider = workspace.Services.GetLanguageServices(typeSymbol.Language);
|
||||
// var semanticFacts = provider.GetService<ISemanticFactsService>();
|
||||
//
|
||||
// // Even if a language only supports explicit interface implementation, we
|
||||
// // can't enforce it for types from metadata. For example, a VB symbol
|
||||
// // representing System.Xml.XmlReader will say it implements IDisposable, but
|
||||
// // the XmlReader.Dispose() method will not be an explicit implementation of
|
||||
// // IDisposable.Dispose()
|
||||
// if (!semanticFacts.SupportsImplicitInterfaceImplementation &&
|
||||
// typeSymbol.Locations.Any(location => location.IsInSource))
|
||||
// {
|
||||
// return explicitMatches.FirstOrDefault();
|
||||
// }
|
||||
//
|
||||
// var syntaxFacts = provider.GetService<ISyntaxFactsService>();
|
||||
// var implicitMatches =
|
||||
// from baseType in typeSymbol.GetBaseTypesAndThis()
|
||||
// from member in baseType.GetMembers(interfaceSymbol.Name).OfType<TSymbol>()
|
||||
// where member.DeclaredAccessibility == Accessibility.Public &&
|
||||
// !member.IsStatic &&
|
||||
// SignatureComparer.Instance.HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(member, interfaceSymbol, syntaxFacts.IsCaseSensitive)
|
||||
// select member;
|
||||
//
|
||||
// return explicitMatches.FirstOrDefault() ?? implicitMatches.FirstOrDefault();
|
||||
// }
|
||||
|
||||
public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol type)
|
||||
{
|
||||
var current = type;
|
||||
while (current != null) {
|
||||
yield return current;
|
||||
current = current.BaseType;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol type)
|
||||
{
|
||||
var current = type.BaseType;
|
||||
while (current != null) {
|
||||
yield return current;
|
||||
current = current.BaseType;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol type)
|
||||
{
|
||||
var current = type;
|
||||
while (current != null) {
|
||||
yield return current;
|
||||
current = current.ContainingType;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
|
||||
{
|
||||
var current = type.ContainingType;
|
||||
while (current != null) {
|
||||
yield return current;
|
||||
current = current.ContainingType;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsAttribute(this ITypeSymbol symbol)
|
||||
{
|
||||
for (var b = symbol.BaseType; b != null; b = b.BaseType) {
|
||||
if (b.MetadataName == "Attribute" &&
|
||||
b.ContainingType == null &&
|
||||
b.ContainingNamespace != null &&
|
||||
b.ContainingNamespace.Name == "System" &&
|
||||
b.ContainingNamespace.ContainingNamespace != null &&
|
||||
b.ContainingNamespace.ContainingNamespace.IsGlobalNamespace) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ITypeSymbol RemoveAnonymousTypes(
|
||||
this ITypeSymbol type,
|
||||
Compilation compilation)
|
||||
{
|
||||
return type?.Accept(new AnonymousTypeRemover(compilation));
|
||||
}
|
||||
|
||||
private class AnonymousTypeRemover : SymbolVisitor<ITypeSymbol>
|
||||
{
|
||||
private readonly Compilation _compilation;
|
||||
|
||||
public AnonymousTypeRemover(Compilation compilation)
|
||||
{
|
||||
_compilation = compilation;
|
||||
}
|
||||
|
||||
public override ITypeSymbol DefaultVisit(ISymbol node)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ITypeSymbol VisitDynamicType(IDynamicTypeSymbol symbol)
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public override ITypeSymbol VisitArrayType(IArrayTypeSymbol symbol)
|
||||
{
|
||||
var elementType = symbol.ElementType.Accept(this);
|
||||
if (elementType != null && elementType.Equals(symbol.ElementType)) {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
return _compilation.CreateArrayTypeSymbol(elementType, symbol.Rank);
|
||||
}
|
||||
|
||||
public override ITypeSymbol VisitNamedType(INamedTypeSymbol symbol)
|
||||
{
|
||||
if (symbol.IsNormalAnonymousType() ||
|
||||
symbol.IsAnonymousDelegateType()) {
|
||||
return _compilation.ObjectType;
|
||||
}
|
||||
|
||||
var arguments = symbol.TypeArguments.Select(t => t.Accept(this)).ToArray();
|
||||
if (arguments.SequenceEqual(symbol.TypeArguments)) {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
return symbol.ConstructedFrom.Construct(arguments.ToArray());
|
||||
}
|
||||
|
||||
public override ITypeSymbol VisitPointerType(IPointerTypeSymbol symbol)
|
||||
{
|
||||
var elementType = symbol.PointedAtType.Accept(this);
|
||||
if (elementType != null && elementType.Equals(symbol.PointedAtType)) {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
return _compilation.CreatePointerTypeSymbol(elementType);
|
||||
}
|
||||
|
||||
public override ITypeSymbol VisitTypeParameter(ITypeParameterSymbol symbol)
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static IList<ITypeParameterSymbol> GetReferencedMethodTypeParameters(
|
||||
this ITypeSymbol type, IList<ITypeParameterSymbol> result = null)
|
||||
{
|
||||
result = result ?? new List<ITypeParameterSymbol>();
|
||||
type?.Accept(new CollectTypeParameterSymbolsVisitor(result, onlyMethodTypeParameters: true));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(
|
||||
this ITypeSymbol type, IList<ITypeParameterSymbol> result = null)
|
||||
{
|
||||
result = result ?? new List<ITypeParameterSymbol>();
|
||||
type?.Accept(new CollectTypeParameterSymbolsVisitor(result, onlyMethodTypeParameters: false));
|
||||
return result;
|
||||
}
|
||||
|
||||
private class CollectTypeParameterSymbolsVisitor : SymbolVisitor
|
||||
{
|
||||
private readonly HashSet<ISymbol> _visited = new HashSet<ISymbol>();
|
||||
private readonly bool _onlyMethodTypeParameters;
|
||||
private readonly IList<ITypeParameterSymbol> _typeParameters;
|
||||
|
||||
public CollectTypeParameterSymbolsVisitor(
|
||||
IList<ITypeParameterSymbol> typeParameters,
|
||||
bool onlyMethodTypeParameters)
|
||||
{
|
||||
_onlyMethodTypeParameters = onlyMethodTypeParameters;
|
||||
_typeParameters = typeParameters;
|
||||
}
|
||||
|
||||
public override void DefaultVisit(ISymbol node)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void VisitDynamicType(IDynamicTypeSymbol symbol)
|
||||
{
|
||||
}
|
||||
|
||||
public override void VisitArrayType(IArrayTypeSymbol symbol)
|
||||
{
|
||||
if (!_visited.Add(symbol)) {
|
||||
return;
|
||||
}
|
||||
|
||||
symbol.ElementType.Accept(this);
|
||||
}
|
||||
|
||||
public override void VisitNamedType(INamedTypeSymbol symbol)
|
||||
{
|
||||
if (_visited.Add(symbol)) {
|
||||
foreach (var child in symbol.GetAllTypeArguments()) {
|
||||
child.Accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void VisitPointerType(IPointerTypeSymbol symbol)
|
||||
{
|
||||
if (!_visited.Add(symbol)) {
|
||||
return;
|
||||
}
|
||||
|
||||
symbol.PointedAtType.Accept(this);
|
||||
}
|
||||
|
||||
public override void VisitTypeParameter(ITypeParameterSymbol symbol)
|
||||
{
|
||||
if (_visited.Add(symbol)) {
|
||||
if (symbol.TypeParameterKind == TypeParameterKind.Method || !_onlyMethodTypeParameters) {
|
||||
if (!_typeParameters.Contains(symbol)) {
|
||||
_typeParameters.Add(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var constraint in symbol.ConstraintTypes) {
|
||||
constraint.Accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsUnexpressableTypeParameterConstraint(this ITypeSymbol typeSymbol)
|
||||
{
|
||||
if (typeSymbol.IsSealed || typeSymbol.IsValueType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (typeSymbol.TypeKind) {
|
||||
case TypeKind.Array:
|
||||
case TypeKind.Delegate:
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (typeSymbol.SpecialType) {
|
||||
case SpecialType.System_Array:
|
||||
case SpecialType.System_Delegate:
|
||||
case SpecialType.System_MulticastDelegate:
|
||||
case SpecialType.System_Enum:
|
||||
case SpecialType.System_ValueType:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsNumericType(this ITypeSymbol type)
|
||||
{
|
||||
if (type != null) {
|
||||
switch (type.SpecialType) {
|
||||
case SpecialType.System_Byte:
|
||||
case SpecialType.System_SByte:
|
||||
case SpecialType.System_Int16:
|
||||
case SpecialType.System_UInt16:
|
||||
case SpecialType.System_Int32:
|
||||
case SpecialType.System_UInt32:
|
||||
case SpecialType.System_Int64:
|
||||
case SpecialType.System_UInt64:
|
||||
case SpecialType.System_Single:
|
||||
case SpecialType.System_Double:
|
||||
case SpecialType.System_Decimal:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
|
||||
{
|
||||
return typeSymbol.Accept(MinimalAccessibilityVisitor.Instance);
|
||||
}
|
||||
private class MinimalAccessibilityVisitor : SymbolVisitor<Accessibility>
|
||||
{
|
||||
public static readonly SymbolVisitor<Accessibility> Instance = new MinimalAccessibilityVisitor();
|
||||
|
||||
public override Accessibility DefaultVisit(ISymbol node)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Accessibility VisitAlias(IAliasSymbol symbol)
|
||||
{
|
||||
return symbol.Target.Accept(this);
|
||||
}
|
||||
|
||||
public override Accessibility VisitArrayType(IArrayTypeSymbol symbol)
|
||||
{
|
||||
return symbol.ElementType.Accept(this);
|
||||
}
|
||||
|
||||
public override Accessibility VisitDynamicType(IDynamicTypeSymbol symbol)
|
||||
{
|
||||
return Accessibility.Public;
|
||||
}
|
||||
|
||||
public override Accessibility VisitPointerType(IPointerTypeSymbol symbol)
|
||||
{
|
||||
return symbol.PointedAtType.Accept(this);
|
||||
}
|
||||
|
||||
public override Accessibility VisitTypeParameter(ITypeParameterSymbol symbol)
|
||||
{
|
||||
// TODO(cyrusn): Do we have to consider the constraints?
|
||||
return Accessibility.Public;
|
||||
}
|
||||
}
|
||||
public static bool ContainsAnonymousType(this ITypeSymbol symbol)
|
||||
{
|
||||
return symbol.TypeSwitch(
|
||||
(IArrayTypeSymbol a) => ContainsAnonymousType(a.ElementType),
|
||||
(IPointerTypeSymbol p) => ContainsAnonymousType(p.PointedAtType),
|
||||
(INamedTypeSymbol n) => ContainsAnonymousType(n),
|
||||
_ => false);
|
||||
}
|
||||
|
||||
private static bool ContainsAnonymousType(INamedTypeSymbol type)
|
||||
{
|
||||
if (type.IsAnonymousType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (var typeArg in type.GetAllTypeArguments()) {
|
||||
if (ContainsAnonymousType(typeArg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
|
||||
{
|
||||
while (true) {
|
||||
var arrayType = type as IArrayTypeSymbol;
|
||||
if (arrayType != null) {
|
||||
type = arrayType.ElementType;
|
||||
continue;
|
||||
}
|
||||
|
||||
var pointerType = type as IPointerTypeSymbol;
|
||||
if (pointerType != null) {
|
||||
type = pointerType.PointedAtType;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var shortName = GetParameterName(type);
|
||||
return capitalize ? shortName.ToPascalCase() : shortName.ToCamelCase();
|
||||
}
|
||||
|
||||
private static string GetParameterName(ITypeSymbol type)
|
||||
{
|
||||
if (type == null || type.IsAnonymousType()) {
|
||||
return DefaultParameterName;
|
||||
}
|
||||
|
||||
if (type.IsSpecialType() || type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T) {
|
||||
return DefaultBuiltInParameterName;
|
||||
}
|
||||
|
||||
var shortName = type.GetShortName();
|
||||
return shortName.Length == 0
|
||||
? DefaultParameterName
|
||||
: shortName;
|
||||
}
|
||||
|
||||
private static bool IsSpecialType(this ITypeSymbol symbol)
|
||||
{
|
||||
if (symbol != null) {
|
||||
switch (symbol.SpecialType) {
|
||||
case SpecialType.System_Object:
|
||||
case SpecialType.System_Void:
|
||||
case SpecialType.System_Boolean:
|
||||
case SpecialType.System_SByte:
|
||||
case SpecialType.System_Byte:
|
||||
case SpecialType.System_Decimal:
|
||||
case SpecialType.System_Single:
|
||||
case SpecialType.System_Double:
|
||||
case SpecialType.System_Int16:
|
||||
case SpecialType.System_Int32:
|
||||
case SpecialType.System_Int64:
|
||||
case SpecialType.System_Char:
|
||||
case SpecialType.System_String:
|
||||
case SpecialType.System_UInt16:
|
||||
case SpecialType.System_UInt32:
|
||||
case SpecialType.System_UInt64:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol)
|
||||
{
|
||||
if (typeSymbol.AllInterfaces.Any(i => i.SpecialType == SpecialType.System_Collections_IEnumerable)) {
|
||||
var curType = typeSymbol;
|
||||
while (curType != null) {
|
||||
if (HasAddMethod(curType))
|
||||
return true;
|
||||
curType = curType.BaseType;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool HasAddMethod(ITypeSymbol typeSymbol)
|
||||
{
|
||||
return typeSymbol
|
||||
.GetMembers(WellKnownMemberNames.CollectionInitializerAddMethodName)
|
||||
.OfType<IMethodSymbol>().Any(m => m.Parameters.Any());
|
||||
}
|
||||
|
||||
//public static INamedTypeSymbol GetDelegateType(this ITypeSymbol typeSymbol, Compilation compilation)
|
||||
//{
|
||||
// if (typeSymbol != null)
|
||||
// {
|
||||
// var expressionOfT = compilation.ExpressionOfTType();
|
||||
// if (typeSymbol.OriginalDefinition.Equals(expressionOfT))
|
||||
// {
|
||||
// var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
|
||||
// return typeArgument as INamedTypeSymbol;
|
||||
// }
|
||||
|
||||
// if (typeSymbol.IsDelegateType())
|
||||
// {
|
||||
// return typeSymbol as INamedTypeSymbol;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
|
||||
{
|
||||
if (containingType == null) {
|
||||
return SpecializedCollections.EmptyEnumerable<T>();
|
||||
}
|
||||
|
||||
var types = containingType.GetBaseTypes();
|
||||
return types.SelectMany(x => x.GetMembers().OfType<T>().Where(m => m.IsAccessibleWithin(within)));
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
|
||||
{
|
||||
if (containingType == null) {
|
||||
return SpecializedCollections.EmptyEnumerable<T>();
|
||||
}
|
||||
|
||||
var types = containingType.GetBaseTypesAndThis();
|
||||
return types.SelectMany(x => x.GetMembers().OfType<T>().Where(m => m.IsAccessibleWithin(within)));
|
||||
}
|
||||
|
||||
public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
|
||||
{
|
||||
if (t1.Count != t2.Count) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// For t1 to be more specific than t2, it has to be not less specific in every member,
|
||||
// and more specific in at least one.
|
||||
|
||||
bool? result = null;
|
||||
for (int i = 0; i < t1.Count; ++i) {
|
||||
var r = t1[i].IsMoreSpecificThan(t2[i]);
|
||||
if (r == null) {
|
||||
// We learned nothing. Do nothing.
|
||||
} else if (result == null) {
|
||||
// We have found the first more specific type. See if
|
||||
// all the rest on this side are not less specific.
|
||||
result = r;
|
||||
} else if (result != r) {
|
||||
// We have more specific types on both left and right, so we
|
||||
// cannot succeed in picking a better type list. Bail out now.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
|
||||
{
|
||||
// SPEC: A type parameter is less specific than a non-type parameter.
|
||||
|
||||
var isTypeParameter1 = t1 is ITypeParameterSymbol;
|
||||
var isTypeParameter2 = t2 is ITypeParameterSymbol;
|
||||
|
||||
if (isTypeParameter1 && !isTypeParameter2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isTypeParameter1 && isTypeParameter2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isTypeParameter1) {
|
||||
Debug.Assert(isTypeParameter2);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (t1.TypeKind != t2.TypeKind) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// There is an identity conversion between the types and they are both substitutions on type parameters.
|
||||
// They had better be the same kind.
|
||||
|
||||
// UNDONE: Strip off the dynamics.
|
||||
|
||||
// SPEC: An array type is more specific than another
|
||||
// SPEC: array type (with the same number of dimensions)
|
||||
// SPEC: if the element type of the first is
|
||||
// SPEC: more specific than the element type of the second.
|
||||
|
||||
if (t1 is IArrayTypeSymbol) {
|
||||
var arr1 = (IArrayTypeSymbol)t1;
|
||||
var arr2 = (IArrayTypeSymbol)t2;
|
||||
|
||||
// We should not have gotten here unless there were identity conversions
|
||||
// between the two types.
|
||||
|
||||
return arr1.ElementType.IsMoreSpecificThan(arr2.ElementType);
|
||||
}
|
||||
|
||||
// SPEC EXTENSION: We apply the same rule to pointer types.
|
||||
|
||||
if (t1 is IPointerTypeSymbol) {
|
||||
var p1 = (IPointerTypeSymbol)t1;
|
||||
var p2 = (IPointerTypeSymbol)t2;
|
||||
return p1.PointedAtType.IsMoreSpecificThan(p2.PointedAtType);
|
||||
}
|
||||
|
||||
// SPEC: A constructed type is more specific than another
|
||||
// SPEC: constructed type (with the same number of type arguments) if at least one type
|
||||
// SPEC: argument is more specific and no type argument is less specific than the
|
||||
// SPEC: corresponding type argument in the other.
|
||||
|
||||
var n1 = t1 as INamedTypeSymbol;
|
||||
var n2 = t2 as INamedTypeSymbol;
|
||||
|
||||
if (n1 == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// We should not have gotten here unless there were identity conversions between the
|
||||
// two types.
|
||||
|
||||
var allTypeArgs1 = n1.GetAllTypeArguments().ToList();
|
||||
var allTypeArgs2 = n2.GetAllTypeArguments().ToList();
|
||||
|
||||
return allTypeArgs1.AreMoreSpecificThan(allTypeArgs2);
|
||||
}
|
||||
|
||||
//public static bool IsOrDerivesFromExceptionType(this ITypeSymbol type, Compilation compilation)
|
||||
//{
|
||||
// if (type != null)
|
||||
// {
|
||||
// foreach (var baseType in type.GetBaseTypesAndThis())
|
||||
// {
|
||||
// if (baseType.Equals(compilation.ExceptionType()))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return false;
|
||||
//}
|
||||
|
||||
public static bool IsEnumType(this ITypeSymbol type)
|
||||
{
|
||||
return type.IsValueType && type.TypeKind == TypeKind.Enum;
|
||||
}
|
||||
|
||||
|
||||
//public static async Task<ISymbol> FindApplicableAlias(this ITypeSymbol type, int position, SemanticModel semanticModel, CancellationToken cancellationToken)
|
||||
//{
|
||||
// if (semanticModel.IsSpeculativeSemanticModel)
|
||||
// {
|
||||
// position = semanticModel.OriginalPositionForSpeculation;
|
||||
// semanticModel = semanticModel.ParentModel;
|
||||
// }
|
||||
|
||||
// var root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// IEnumerable<UsingDirectiveSyntax> applicableUsings = GetApplicableUsings(position, root as CompilationUnitSyntax);
|
||||
// foreach (var applicableUsing in applicableUsings)
|
||||
// {
|
||||
// var alias = semanticModel.GetOriginalSemanticModel().GetDeclaredSymbol(applicableUsing, cancellationToken) as IAliasSymbol;
|
||||
|
||||
// if (alias != null && alias.Target == type)
|
||||
// {
|
||||
// return alias;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
|
||||
private static IEnumerable<UsingDirectiveSyntax> GetApplicableUsings(int position, SyntaxNode root)
|
||||
{
|
||||
var namespaceUsings = root.FindToken(position).Parent.GetAncestors<NamespaceDeclarationSyntax>().SelectMany(n => n.Usings);
|
||||
var allUsings = root is CompilationUnitSyntax
|
||||
? ((CompilationUnitSyntax)root).Usings.Concat(namespaceUsings)
|
||||
: namespaceUsings;
|
||||
return allUsings.Where(u => u.Alias != null);
|
||||
}
|
||||
|
||||
public static ITypeSymbol RemoveNullableIfPresent(this ITypeSymbol symbol)
|
||||
{
|
||||
if (symbol.IsNullable()) {
|
||||
return symbol.GetTypeArguments().Single();
|
||||
}
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public static bool IsIEnumerable(this ITypeSymbol typeSymbol)
|
||||
{
|
||||
return typeSymbol.ImplementsSpecialTypeInterface(SpecialType.System_Collections_IEnumerable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
abstract class Matcher<T>
|
||||
{
|
||||
// Tries to match this matcher against the provided sequence at the given index. If the
|
||||
// match succeeds, 'true' is returned, and 'index' points to the location after the match
|
||||
// ends. If the match fails, then false it returned and index remains the same. Note: the
|
||||
// matcher does not need to consume to the end of the sequence to succeed.
|
||||
public abstract bool TryMatch(IList<T> sequence, ref int index);
|
||||
|
||||
internal static Matcher<T> Repeat(Matcher<T> matcher)
|
||||
{
|
||||
return new RepeatMatcher(matcher);
|
||||
}
|
||||
|
||||
internal static Matcher<T> OneOrMore(Matcher<T> matcher)
|
||||
{
|
||||
// m+ is the same as (m m*)
|
||||
return Sequence(matcher, Repeat(matcher));
|
||||
}
|
||||
|
||||
internal static Matcher<T> Choice(Matcher<T> matcher1, Matcher<T> matcher2)
|
||||
{
|
||||
return new ChoiceMatcher(matcher1, matcher2);
|
||||
}
|
||||
|
||||
internal static Matcher<T> Sequence(params Matcher<T>[] matchers)
|
||||
{
|
||||
return new SequenceMatcher(matchers);
|
||||
}
|
||||
|
||||
internal static Matcher<T> Single(Func<T, bool> predicate, string description)
|
||||
{
|
||||
return new SingleMatcher(predicate, description);
|
||||
}
|
||||
private class ChoiceMatcher : Matcher<T>
|
||||
{
|
||||
private readonly Matcher<T> _matcher1;
|
||||
private readonly Matcher<T> _matcher2;
|
||||
|
||||
public ChoiceMatcher(Matcher<T> matcher1, Matcher<T> matcher2)
|
||||
{
|
||||
_matcher1 = matcher1;
|
||||
_matcher2 = matcher2;
|
||||
}
|
||||
|
||||
public override bool TryMatch(IList<T> sequence, ref int index)
|
||||
{
|
||||
return
|
||||
_matcher1.TryMatch(sequence, ref index) ||
|
||||
_matcher2.TryMatch(sequence, ref index);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}|{1})", _matcher1, _matcher2);
|
||||
}
|
||||
}
|
||||
private class RepeatMatcher : Matcher<T>
|
||||
{
|
||||
private readonly Matcher<T> _matcher;
|
||||
|
||||
public RepeatMatcher(Matcher<T> matcher)
|
||||
{
|
||||
_matcher = matcher;
|
||||
}
|
||||
|
||||
public override bool TryMatch(IList<T> sequence, ref int index)
|
||||
{
|
||||
while (_matcher.TryMatch(sequence, ref index)) {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}*)", _matcher);
|
||||
}
|
||||
}
|
||||
private class SequenceMatcher : Matcher<T>
|
||||
{
|
||||
private readonly Matcher<T>[] _matchers;
|
||||
|
||||
public SequenceMatcher(params Matcher<T>[] matchers)
|
||||
{
|
||||
_matchers = matchers;
|
||||
}
|
||||
|
||||
public override bool TryMatch(IList<T> sequence, ref int index)
|
||||
{
|
||||
var currentIndex = index;
|
||||
foreach (var matcher in _matchers) {
|
||||
if (!matcher.TryMatch(sequence, ref currentIndex)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
index = currentIndex;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0})", string.Join(",", (object[])_matchers));
|
||||
}
|
||||
}
|
||||
private class SingleMatcher : Matcher<T>
|
||||
{
|
||||
private readonly Func<T, bool> _predicate;
|
||||
private readonly string _description;
|
||||
|
||||
public SingleMatcher(Func<T, bool> predicate, string description)
|
||||
{
|
||||
_predicate = predicate;
|
||||
_description = description;
|
||||
}
|
||||
|
||||
public override bool TryMatch(IList<T> sequence, ref int index)
|
||||
{
|
||||
if (index < sequence.Count && _predicate(sequence[index])) {
|
||||
index++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
class Matcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Matcher equivalent to (m*)
|
||||
/// </summary>
|
||||
public static Matcher<T> Repeat<T>(Matcher<T> matcher)
|
||||
{
|
||||
return Matcher<T>.Repeat(matcher);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Matcher equivalent to (m+)
|
||||
/// </summary>
|
||||
public static Matcher<T> OneOrMore<T>(Matcher<T> matcher)
|
||||
{
|
||||
return Matcher<T>.OneOrMore(matcher);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Matcher equivalent to (m_1|m_2)
|
||||
/// </summary>
|
||||
public static Matcher<T> Choice<T>(Matcher<T> matcher1, Matcher<T> matcher2)
|
||||
{
|
||||
return Matcher<T>.Choice(matcher1, matcher2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Matcher equivalent to (m_1 ... m_n)
|
||||
/// </summary>
|
||||
public static Matcher<T> Sequence<T>(params Matcher<T>[] matchers)
|
||||
{
|
||||
return Matcher<T>.Sequence(matchers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Matcher that matches an element if the provide predicate returns true.
|
||||
/// </summary>
|
||||
public static Matcher<T> Single<T>(Func<T, bool> predicate, string description)
|
||||
{
|
||||
return Matcher<T>.Single(predicate, description);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
// 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.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
static class NameGenerator
|
||||
{
|
||||
public static IList<string> EnsureUniqueness(
|
||||
IList<string> names,
|
||||
Func<string, bool> canUse = null)
|
||||
{
|
||||
return EnsureUniqueness(names, names.Select(_ => false).ToList(), canUse);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that any 'names' is unique and does not collide with any other name. Names that
|
||||
/// are marked as IsFixed can not be touched. This does mean that if there are two names
|
||||
/// that are the same, and both are fixed that you will end up with non-unique names at the
|
||||
/// end.
|
||||
/// </summary>
|
||||
public static IList<string> EnsureUniqueness(
|
||||
IList<string> names,
|
||||
IList<bool> isFixed,
|
||||
Func<string, bool> canUse = null,
|
||||
bool isCaseSensitive = true)
|
||||
{
|
||||
var copy = names.ToList();
|
||||
EnsureUniquenessInPlace(copy, isFixed, canUse, isCaseSensitive);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static IList<string> EnsureUniqueness(IList<string> names, bool isCaseSensitive)
|
||||
{
|
||||
return EnsureUniqueness(names, names.Select(_ => false).ToList(), isCaseSensitive: isCaseSensitive);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms baseName into a name that does not conflict with any name in 'reservedNames'
|
||||
/// </summary>
|
||||
public static string EnsureUniqueness(
|
||||
string baseName,
|
||||
IEnumerable<string> reservedNames,
|
||||
bool isCaseSensitive = true)
|
||||
{
|
||||
var names = new List<string> { baseName };
|
||||
var isFixed = new List<bool> { false };
|
||||
|
||||
names.AddRange(reservedNames.Distinct());
|
||||
isFixed.AddRange(Enumerable.Repeat(true, names.Count - 1));
|
||||
|
||||
var result = EnsureUniqueness(names, isFixed, isCaseSensitive: isCaseSensitive);
|
||||
return result.First();
|
||||
}
|
||||
|
||||
private static void EnsureUniquenessInPlace(
|
||||
IList<string> names,
|
||||
IList<bool> isFixed,
|
||||
Func<string, bool> canUse,
|
||||
bool isCaseSensitive = true)
|
||||
{
|
||||
canUse = canUse ?? (s => true);
|
||||
|
||||
// Don't enumerate as we will be modifying the collection in place.
|
||||
for (var i = 0; i < names.Count; i++) {
|
||||
var name = names[i];
|
||||
var collisionIndices = GetCollisionIndices(names, name, isCaseSensitive);
|
||||
|
||||
if (canUse(name) && collisionIndices.Count < 2) {
|
||||
// no problems with this parameter name, move onto the next one.
|
||||
continue;
|
||||
}
|
||||
|
||||
HandleCollisions(isFixed, names, name, collisionIndices, canUse, isCaseSensitive);
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleCollisions(
|
||||
IList<bool> isFixed,
|
||||
IList<string> names,
|
||||
string name,
|
||||
List<int> collisionIndices,
|
||||
Func<string, bool> canUse,
|
||||
bool isCaseSensitive = true)
|
||||
{
|
||||
var suffix = 1;
|
||||
var comparer = isCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
|
||||
for (var i = 0; i < collisionIndices.Count; i++) {
|
||||
var collisionIndex = collisionIndices[i];
|
||||
if (isFixed[collisionIndex]) {
|
||||
// can't do anything about this name.
|
||||
continue;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
var newName = name + suffix++;
|
||||
if (!names.Contains(newName, comparer) && canUse(newName)) {
|
||||
// Found a name that doesn't conflict with anything else.
|
||||
names[collisionIndex] = newName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<int> GetCollisionIndices(
|
||||
IList<string> names,
|
||||
string name,
|
||||
bool isCaseSensitive = true)
|
||||
{
|
||||
var comparer = isCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
|
||||
var collisionIndices =
|
||||
names.Select((currentName, index) => new { currentName, index })
|
||||
.Where(t => comparer.Equals(t.currentName, name))
|
||||
.Select(t => t.index)
|
||||
.ToList();
|
||||
return collisionIndices;
|
||||
}
|
||||
|
||||
public static string GenerateUniqueName(string baseName, Func<string, bool> canUse)
|
||||
{
|
||||
return GenerateUniqueName(baseName, string.Empty, canUse);
|
||||
}
|
||||
|
||||
public static string GenerateUniqueName(string baseName, ISet<string> names, StringComparer comparer)
|
||||
{
|
||||
return GenerateUniqueName(baseName, x => !names.Contains(x, comparer));
|
||||
}
|
||||
|
||||
public static string GenerateUniqueName(string baseName, string extension, Func<string, bool> canUse)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(extension) && !extension.StartsWith(".")) {
|
||||
extension = "." + extension;
|
||||
}
|
||||
|
||||
var name = baseName + extension;
|
||||
var index = 1;
|
||||
|
||||
// Check for collisions
|
||||
while (!canUse(name)) {
|
||||
name = baseName + index + extension;
|
||||
index++;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static string GenerateSafeCSharpName(string name)
|
||||
{
|
||||
var token = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseToken(name);
|
||||
if (!token.IsKind(Microsoft.CodeAnalysis.CSharp.SyntaxKind.IdentifierToken))
|
||||
return "@" + name;
|
||||
return name;
|
||||
}
|
||||
|
||||
public static string GenerateSafeVBName(string name)
|
||||
{
|
||||
var token = Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseToken(name);
|
||||
if (!token.IsKind(Microsoft.CodeAnalysis.VisualBasic.SyntaxKind.IdentifierToken))
|
||||
return "[" + name + "]";
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,133 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
[Flags]
|
||||
internal enum BindingFlags
|
||||
{
|
||||
Default = 0,
|
||||
Instance = 1,
|
||||
Static = 2,
|
||||
Public = 4,
|
||||
NonPublic = 8,
|
||||
}
|
||||
|
||||
internal static class ReflectionCompatibilityExtensions
|
||||
{
|
||||
public static object[] GetCustomAttributes(this Type type, bool inherit)
|
||||
{
|
||||
return type.GetTypeInfo().GetCustomAttributes(inherit).ToArray();
|
||||
}
|
||||
|
||||
public static MethodInfo GetMethod(this Type type, string name)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(m => m.Name == name);
|
||||
}
|
||||
|
||||
public static MethodInfo GetMethod(this Type type, string name, BindingFlags bindingFlags)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(m => (m.Name == name) && IsConformWithBindingFlags(m, bindingFlags));
|
||||
}
|
||||
|
||||
public static MethodInfo GetMethod(this Type type, string name, Type[] types)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(
|
||||
m => (m.Name == name) && TypesAreEqual(m.GetParameters().Select(p => p.ParameterType).ToArray(), types));
|
||||
}
|
||||
|
||||
public static MethodInfo GetMethod(this Type type, string name, BindingFlags bindingFlags, object binder, Type[] types, object modifiers)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(
|
||||
m => (m.Name == name) && IsConformWithBindingFlags(m, bindingFlags) && TypesAreEqual(m.GetParameters().Select(p => p.ParameterType).ToArray(), types));
|
||||
}
|
||||
|
||||
public static IEnumerable<MethodInfo> GetMethods(this Type type)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMethods;
|
||||
}
|
||||
|
||||
public static IEnumerable<MethodInfo> GetMethods(this Type type, string name)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMethods.Where(m => m.Name == name);
|
||||
}
|
||||
|
||||
public static IEnumerable<MethodInfo> GetMethods(this Type type, BindingFlags bindingFlags)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMethods.Where(m => IsConformWithBindingFlags(m, bindingFlags));
|
||||
}
|
||||
|
||||
public static FieldInfo GetField(this Type type, string name)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredFields.FirstOrDefault(f => f.Name == name);
|
||||
}
|
||||
|
||||
public static FieldInfo GetField(this Type type, string name, BindingFlags bindingFlags)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredFields.FirstOrDefault(f => (f.Name == name) && IsConformWithBindingFlags(f, bindingFlags));
|
||||
}
|
||||
|
||||
public static PropertyInfo GetProperty(this Type type, string name)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredProperties.FirstOrDefault(p => p.Name == name);
|
||||
}
|
||||
|
||||
public static IEnumerable<PropertyInfo> GetProperties(this Type type)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredProperties;
|
||||
}
|
||||
|
||||
public static string GetAssemblyLocation(this Type type)
|
||||
{
|
||||
var asm = type.GetTypeInfo().Assembly;
|
||||
var locationProperty = asm.GetType().GetRuntimeProperties().Single(p => p.Name == "Location");
|
||||
return (string)locationProperty.GetValue(asm);
|
||||
}
|
||||
|
||||
private static bool TypesAreEqual(Type[] memberTypes, Type[] searchedTypes)
|
||||
{
|
||||
if (((memberTypes == null) || (searchedTypes == null)) && (memberTypes != searchedTypes))
|
||||
return false;
|
||||
|
||||
if (memberTypes.Length != searchedTypes.Length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < memberTypes.Length; i++) {
|
||||
if (memberTypes[i] != searchedTypes[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool IsConformWithBindingFlags(MethodBase method, BindingFlags bindingFlags)
|
||||
{
|
||||
if (method.IsPublic && !bindingFlags.HasFlag(BindingFlags.Public))
|
||||
return false;
|
||||
if (method.IsPrivate && !bindingFlags.HasFlag(BindingFlags.NonPublic))
|
||||
return false;
|
||||
if (method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Static))
|
||||
return false;
|
||||
if (!method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Instance))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool IsConformWithBindingFlags(FieldInfo method, BindingFlags bindingFlags)
|
||||
{
|
||||
if (method.IsPublic && !bindingFlags.HasFlag(BindingFlags.Public))
|
||||
return false;
|
||||
if (method.IsPrivate && !bindingFlags.HasFlag(BindingFlags.NonPublic))
|
||||
return false;
|
||||
if (method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Static))
|
||||
return false;
|
||||
if (!method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Instance))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,620 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static partial class SpecializedCollections
|
||||
{
|
||||
public static readonly byte[] EmptyBytes = EmptyArray<byte>();
|
||||
public static readonly object[] EmptyObjects = EmptyArray<object>();
|
||||
|
||||
public static T[] EmptyArray<T>()
|
||||
{
|
||||
return Empty.Array<T>.Instance;
|
||||
}
|
||||
|
||||
public static IEnumerator<T> EmptyEnumerator<T>()
|
||||
{
|
||||
return Empty.Enumerator<T>.Instance;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> EmptyEnumerable<T>()
|
||||
{
|
||||
return Empty.List<T>.Instance;
|
||||
}
|
||||
|
||||
public static ICollection<T> EmptyCollection<T>()
|
||||
{
|
||||
return Empty.List<T>.Instance;
|
||||
}
|
||||
|
||||
public static IList<T> EmptyList<T>()
|
||||
{
|
||||
return Empty.List<T>.Instance;
|
||||
}
|
||||
|
||||
public static IReadOnlyList<T> EmptyReadOnlyList<T>()
|
||||
{
|
||||
return Empty.List<T>.Instance;
|
||||
}
|
||||
|
||||
public static ISet<T> EmptySet<T>()
|
||||
{
|
||||
return Empty.Set<T>.Instance;
|
||||
}
|
||||
|
||||
public static IDictionary<TKey, TValue> EmptyDictionary<TKey, TValue>()
|
||||
{
|
||||
return Empty.Dictionary<TKey, TValue>.Instance;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> SingletonEnumerable<T>(T value)
|
||||
{
|
||||
return new Singleton.Collection<T>(value);
|
||||
}
|
||||
|
||||
public static ICollection<T> SingletonCollection<T>(T value)
|
||||
{
|
||||
return new Singleton.Collection<T>(value);
|
||||
}
|
||||
|
||||
public static IEnumerator<T> SingletonEnumerator<T>(T value)
|
||||
{
|
||||
return new Singleton.Enumerator<T>(value);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> ReadOnlyEnumerable<T>(IEnumerable<T> values)
|
||||
{
|
||||
return new ReadOnly.Enumerable<IEnumerable<T>, T>(values);
|
||||
}
|
||||
|
||||
public static ICollection<T> ReadOnlyCollection<T>(ICollection<T> collection)
|
||||
{
|
||||
return collection == null || collection.Count == 0
|
||||
? EmptyCollection<T>()
|
||||
: new ReadOnly.Collection<ICollection<T>, T>(collection);
|
||||
}
|
||||
|
||||
public static ISet<T> ReadOnlySet<T>(ISet<T> set)
|
||||
{
|
||||
return set == null || set.Count == 0
|
||||
? EmptySet<T>()
|
||||
: new ReadOnly.Set<ISet<T>, T>(set);
|
||||
}
|
||||
|
||||
public static ISet<T> ReadOnlySet<T>(IEnumerable<T> values)
|
||||
{
|
||||
if (values is ISet<T>) {
|
||||
return ReadOnlySet((ISet<T>)values);
|
||||
}
|
||||
|
||||
HashSet<T> result = null;
|
||||
foreach (var item in values) {
|
||||
result = result ?? new HashSet<T>();
|
||||
result.Add(item);
|
||||
}
|
||||
|
||||
return ReadOnlySet(result);
|
||||
}
|
||||
|
||||
private partial class Empty
|
||||
{
|
||||
internal class Array<T>
|
||||
{
|
||||
public static readonly T[] Instance = new T[0];
|
||||
}
|
||||
|
||||
internal class Collection<T> : Enumerable<T>, ICollection<T>
|
||||
{
|
||||
public static readonly ICollection<T> Instance = new Collection<T>();
|
||||
|
||||
protected Collection()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Dictionary<TKey, TValue> : Collection<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue>
|
||||
{
|
||||
public static readonly new IDictionary<TKey, TValue> Instance = new Dictionary<TKey, TValue>();
|
||||
|
||||
private Dictionary()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICollection<TKey> Keys {
|
||||
get {
|
||||
return Collection<TKey>.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
value = default(TValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICollection<TValue> Values {
|
||||
get {
|
||||
return Collection<TValue>.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
public TValue this[TKey key] {
|
||||
get {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
set {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class Enumerable<T> : IEnumerable<T>
|
||||
{
|
||||
// PERF: cache the instance of enumerator.
|
||||
// accessing a generic static field is kinda slow from here,
|
||||
// but since empty enumerables are singletons, there is no harm in having
|
||||
// one extra instance field
|
||||
private readonly IEnumerator<T> _enumerator = Enumerator<T>.Instance;
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return _enumerator;
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Enumerator : IEnumerator
|
||||
{
|
||||
public static readonly IEnumerator Instance = new Enumerator();
|
||||
|
||||
protected Enumerator()
|
||||
{
|
||||
}
|
||||
|
||||
public object Current {
|
||||
get {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Enumerator<T> : Enumerator, IEnumerator<T>
|
||||
{
|
||||
public static new readonly IEnumerator<T> Instance = new Enumerator<T>();
|
||||
|
||||
protected Enumerator()
|
||||
{
|
||||
}
|
||||
|
||||
public new T Current {
|
||||
get {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
internal class List<T> : Collection<T>, IList<T>, IReadOnlyList<T>
|
||||
{
|
||||
public static readonly new List<T> Instance = new List<T>();
|
||||
|
||||
protected List()
|
||||
{
|
||||
}
|
||||
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public T this[int index] {
|
||||
get {
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
|
||||
set {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class Set<T> : Collection<T>, ISet<T>
|
||||
{
|
||||
public static readonly new ISet<T> Instance = new Set<T>();
|
||||
|
||||
protected Set()
|
||||
{
|
||||
}
|
||||
|
||||
public new bool Add(T item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ExceptWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void IntersectWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsProperSubsetOf(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsProperSupersetOf(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsSubsetOf(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsSupersetOf(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Overlaps(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool SetEquals(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SymmetricExceptWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UnionWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public new System.Collections.IEnumerator GetEnumerator()
|
||||
{
|
||||
return Set<T>.Instance.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static partial class ReadOnly
|
||||
{
|
||||
internal class Collection<TUnderlying, T> : Enumerable<TUnderlying, T>, ICollection<T>
|
||||
where TUnderlying : ICollection<T>
|
||||
{
|
||||
public Collection(TUnderlying underlying)
|
||||
: base(underlying)
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return this.Underlying.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
this.Underlying.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return this.Underlying.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Enumerable<TUnderlying> : IEnumerable
|
||||
where TUnderlying : IEnumerable
|
||||
{
|
||||
protected readonly TUnderlying Underlying;
|
||||
|
||||
public Enumerable(TUnderlying underlying)
|
||||
{
|
||||
this.Underlying = underlying;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return this.Underlying.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Enumerable<TUnderlying, T> : Enumerable<TUnderlying>, IEnumerable<T>
|
||||
where TUnderlying : IEnumerable<T>
|
||||
{
|
||||
public Enumerable(TUnderlying underlying)
|
||||
: base(underlying)
|
||||
{
|
||||
}
|
||||
|
||||
public new IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return this.Underlying.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Set<TUnderlying, T> : Collection<TUnderlying, T>, ISet<T>
|
||||
where TUnderlying : ISet<T>
|
||||
{
|
||||
public Set(TUnderlying underlying)
|
||||
: base(underlying)
|
||||
{
|
||||
}
|
||||
|
||||
public new bool Add(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void ExceptWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void IntersectWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool IsProperSubsetOf(IEnumerable<T> other)
|
||||
{
|
||||
return Underlying.IsProperSubsetOf(other);
|
||||
}
|
||||
|
||||
public bool IsProperSupersetOf(IEnumerable<T> other)
|
||||
{
|
||||
return Underlying.IsProperSupersetOf(other);
|
||||
}
|
||||
|
||||
public bool IsSubsetOf(IEnumerable<T> other)
|
||||
{
|
||||
return Underlying.IsSubsetOf(other);
|
||||
}
|
||||
|
||||
public bool IsSupersetOf(IEnumerable<T> other)
|
||||
{
|
||||
return Underlying.IsSupersetOf(other);
|
||||
}
|
||||
|
||||
public bool Overlaps(IEnumerable<T> other)
|
||||
{
|
||||
return Underlying.Overlaps(other);
|
||||
}
|
||||
|
||||
public bool SetEquals(IEnumerable<T> other)
|
||||
{
|
||||
return Underlying.SetEquals(other);
|
||||
}
|
||||
|
||||
public void SymmetricExceptWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void UnionWith(IEnumerable<T> other)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static partial class Singleton
|
||||
{
|
||||
internal sealed class Collection<T> : ICollection<T>, IReadOnlyCollection<T>
|
||||
{
|
||||
private T _loneValue;
|
||||
|
||||
public Collection(T value)
|
||||
{
|
||||
_loneValue = value;
|
||||
}
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return EqualityComparer<T>.Default.Equals(_loneValue, item);
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
array[arrayIndex] = _loneValue;
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return new Enumerator<T>(_loneValue);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
internal class Enumerator<T> : IEnumerator<T>
|
||||
{
|
||||
private T _loneValue;
|
||||
private bool _moveNextCalled;
|
||||
|
||||
public Enumerator(T value)
|
||||
{
|
||||
_loneValue = value;
|
||||
_moveNextCalled = false;
|
||||
}
|
||||
|
||||
public T Current {
|
||||
get {
|
||||
return _loneValue;
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current {
|
||||
get {
|
||||
return _loneValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (!_moveNextCalled) {
|
||||
_moveNextCalled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_moveNextCalled = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,493 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Simplification;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class StringExtensions
|
||||
{
|
||||
public static int? GetFirstNonWhitespaceOffset(this string line)
|
||||
{
|
||||
// Contract.ThrowIfNull(line);
|
||||
|
||||
for (int i = 0; i < line.Length; i++) {
|
||||
if (!char.IsWhiteSpace(line[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetLeadingWhitespace(this string lineText)
|
||||
{
|
||||
// Contract.ThrowIfNull(lineText);
|
||||
|
||||
var firstOffset = lineText.GetFirstNonWhitespaceOffset();
|
||||
|
||||
return firstOffset.HasValue
|
||||
? lineText.Substring(0, firstOffset.Value)
|
||||
: lineText;
|
||||
}
|
||||
|
||||
public static int GetTextColumn(this string text, int tabSize, int initialColumn)
|
||||
{
|
||||
var lineText = text.GetLastLineText();
|
||||
if (text != lineText) {
|
||||
return lineText.GetColumnFromLineOffset(lineText.Length, tabSize);
|
||||
}
|
||||
|
||||
return text.ConvertTabToSpace(tabSize, initialColumn, text.Length) + initialColumn;
|
||||
}
|
||||
|
||||
public static int ConvertTabToSpace(this string textSnippet, int tabSize, int initialColumn, int endPosition)
|
||||
{
|
||||
// Contract.Requires(tabSize > 0);
|
||||
// Contract.Requires(endPosition >= 0 && endPosition <= textSnippet.Length);
|
||||
|
||||
int column = initialColumn;
|
||||
|
||||
// now this will calculate indentation regardless of actual content on the buffer except TAB
|
||||
for (int i = 0; i < endPosition; i++) {
|
||||
if (textSnippet[i] == '\t') {
|
||||
column += tabSize - column % tabSize;
|
||||
} else {
|
||||
column++;
|
||||
}
|
||||
}
|
||||
|
||||
return column - initialColumn;
|
||||
}
|
||||
|
||||
public static int IndexOf(this string text, Func<char, bool> predicate)
|
||||
{
|
||||
if (text == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < text.Length; i++) {
|
||||
if (predicate(text[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static string GetFirstLineText(this string text)
|
||||
{
|
||||
var lineBreak = text.IndexOf('\n');
|
||||
if (lineBreak < 0) {
|
||||
return text;
|
||||
}
|
||||
|
||||
return text.Substring(0, lineBreak + 1);
|
||||
}
|
||||
|
||||
public static string GetLastLineText(this string text)
|
||||
{
|
||||
var lineBreak = text.LastIndexOf('\n');
|
||||
if (lineBreak < 0) {
|
||||
return text;
|
||||
}
|
||||
|
||||
return text.Substring(lineBreak + 1);
|
||||
}
|
||||
|
||||
public static bool ContainsLineBreak(this string text)
|
||||
{
|
||||
foreach (char ch in text) {
|
||||
if (ch == '\n' || ch == '\r') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int GetNumberOfLineBreaks(this string text)
|
||||
{
|
||||
int lineBreaks = 0;
|
||||
for (int i = 0; i < text.Length; i++) {
|
||||
if (text[i] == '\n') {
|
||||
lineBreaks++;
|
||||
} else if (text[i] == '\r') {
|
||||
if (i + 1 == text.Length || text[i + 1] != '\n') {
|
||||
lineBreaks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lineBreaks;
|
||||
}
|
||||
|
||||
public static bool ContainsTab(this string text)
|
||||
{
|
||||
// PERF: Tried replacing this with "text.IndexOf('\t')>=0", but that was actually slightly slower
|
||||
foreach (char ch in text) {
|
||||
if (ch == '\t') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ImmutableArray<SymbolDisplayPart> ToSymbolDisplayParts(this string text)
|
||||
{
|
||||
return ImmutableArray.Create<SymbolDisplayPart>(new SymbolDisplayPart(SymbolDisplayPartKind.Text, null, text));
|
||||
}
|
||||
|
||||
public static int GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(this string line, int tabSize)
|
||||
{
|
||||
var firstNonWhitespaceChar = line.GetFirstNonWhitespaceOffset();
|
||||
|
||||
if (firstNonWhitespaceChar.HasValue) {
|
||||
return line.GetColumnFromLineOffset(firstNonWhitespaceChar.Value, tabSize);
|
||||
} else {
|
||||
// It's all whitespace, so go to the end
|
||||
return line.GetColumnFromLineOffset(line.Length, tabSize);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetColumnFromLineOffset(this string line, int endPosition, int tabSize)
|
||||
{
|
||||
// Contract.ThrowIfNull(line);
|
||||
// Contract.ThrowIfFalse(0 <= endPosition && endPosition <= line.Length);
|
||||
// Contract.ThrowIfFalse(tabSize > 0);
|
||||
|
||||
return ConvertTabToSpace(line, tabSize, 0, endPosition);
|
||||
}
|
||||
|
||||
public static int GetLineOffsetFromColumn(this string line, int column, int tabSize)
|
||||
{
|
||||
// Contract.ThrowIfNull(line);
|
||||
// Contract.ThrowIfFalse(column >= 0);
|
||||
// Contract.ThrowIfFalse(tabSize > 0);
|
||||
|
||||
var currentColumn = 0;
|
||||
|
||||
for (int i = 0; i < line.Length; i++) {
|
||||
if (currentColumn >= column) {
|
||||
return i;
|
||||
}
|
||||
|
||||
if (line[i] == '\t') {
|
||||
currentColumn += tabSize - (currentColumn % tabSize);
|
||||
} else {
|
||||
currentColumn++;
|
||||
}
|
||||
}
|
||||
|
||||
// We're asking for a column past the end of the line, so just go to the end.
|
||||
return line.Length;
|
||||
}
|
||||
|
||||
// public static void AppendToAliasNameSet(this string alias, ImmutableHashSet<string>.Builder builder)
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(alias))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// builder.Add(alias);
|
||||
//
|
||||
// var caseSensitive = builder.KeyComparer == StringComparer.Ordinal;
|
||||
// // Contract.Requires(builder.KeyComparer == StringComparer.Ordinal || builder.KeyComparer == StringComparer.OrdinalIgnoreCase);
|
||||
//
|
||||
// string aliasWithoutAttribute;
|
||||
// if (alias.TryGetWithoutAttributeSuffix(caseSensitive, out aliasWithoutAttribute))
|
||||
// {
|
||||
// builder.Add(aliasWithoutAttribute);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// builder.Add(alias.GetWithSingleAttributeSuffix(caseSensitive));
|
||||
// }
|
||||
|
||||
|
||||
private static ImmutableArray<string> s_lazyNumerals;
|
||||
|
||||
internal static string GetNumeral(int number)
|
||||
{
|
||||
var numerals = s_lazyNumerals;
|
||||
if (numerals.IsDefault) {
|
||||
numerals = ImmutableArray.Create("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
|
||||
ImmutableInterlocked.InterlockedInitialize(ref s_lazyNumerals, numerals);
|
||||
}
|
||||
|
||||
Debug.Assert(number >= 0);
|
||||
return (number < numerals.Length) ? numerals[number] : number.ToString();
|
||||
}
|
||||
|
||||
public static string Join(this IEnumerable<string> source, string separator)
|
||||
{
|
||||
if (source == null) {
|
||||
throw new ArgumentNullException("source");
|
||||
}
|
||||
|
||||
if (separator == null) {
|
||||
throw new ArgumentNullException("separator");
|
||||
}
|
||||
|
||||
return string.Join(separator, source);
|
||||
}
|
||||
|
||||
public static bool LooksLikeInterfaceName(this string name)
|
||||
{
|
||||
return name.Length >= 3 && name[0] == 'I' && char.IsUpper(name[1]) && char.IsLower(name[2]);
|
||||
}
|
||||
|
||||
public static bool LooksLikeTypeParameterName(this string name)
|
||||
{
|
||||
return name.Length >= 3 && name[0] == 'T' && char.IsUpper(name[1]) && char.IsLower(name[2]);
|
||||
}
|
||||
|
||||
private static readonly Func<char, char> s_toLower = char.ToLower;
|
||||
private static readonly Func<char, char> s_toUpper = char.ToUpper;
|
||||
|
||||
public static string ToPascalCase(
|
||||
this string shortName,
|
||||
bool trimLeadingTypePrefix = true)
|
||||
{
|
||||
return ConvertCase(shortName, trimLeadingTypePrefix, s_toUpper);
|
||||
}
|
||||
|
||||
public static string ToCamelCase(
|
||||
this string shortName,
|
||||
bool trimLeadingTypePrefix = true)
|
||||
{
|
||||
return ConvertCase(shortName, trimLeadingTypePrefix, s_toLower);
|
||||
}
|
||||
|
||||
private static string ConvertCase(
|
||||
this string shortName,
|
||||
bool trimLeadingTypePrefix,
|
||||
Func<char, char> convert)
|
||||
{
|
||||
// Special case the common .net pattern of "IFoo" as a type name. In this case we
|
||||
// want to generate "foo" as the parameter name.
|
||||
if (!string.IsNullOrEmpty(shortName)) {
|
||||
if (trimLeadingTypePrefix && (shortName.LooksLikeInterfaceName() || shortName.LooksLikeTypeParameterName())) {
|
||||
return convert(shortName[1]) + shortName.Substring(2);
|
||||
}
|
||||
|
||||
if (convert(shortName[0]) != shortName[0]) {
|
||||
return convert(shortName[0]) + shortName.Substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
return shortName;
|
||||
}
|
||||
|
||||
internal static bool IsValidClrTypeName(this string name)
|
||||
{
|
||||
return !string.IsNullOrEmpty(name) && name.IndexOf('\0') == -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the given name is a sequence of valid CLR names separated by a dot.
|
||||
/// </summary>
|
||||
internal static bool IsValidClrNamespaceName(this string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char lastChar = '.';
|
||||
foreach (char c in name) {
|
||||
if (c == '\0' || (c == '.' && lastChar == '.')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lastChar = c;
|
||||
}
|
||||
|
||||
return lastChar != '.';
|
||||
}
|
||||
|
||||
internal static string GetWithSingleAttributeSuffix(
|
||||
this string name,
|
||||
bool isCaseSensitive)
|
||||
{
|
||||
string cleaned = name;
|
||||
while ((cleaned = GetWithoutAttributeSuffix(cleaned, isCaseSensitive)) != null) {
|
||||
name = cleaned;
|
||||
}
|
||||
|
||||
return name + "Attribute";
|
||||
}
|
||||
|
||||
internal static bool TryGetWithoutAttributeSuffix(
|
||||
this string name,
|
||||
out string result)
|
||||
{
|
||||
return TryGetWithoutAttributeSuffix(name, isCaseSensitive: true, result: out result);
|
||||
}
|
||||
|
||||
internal static string GetWithoutAttributeSuffix(
|
||||
this string name,
|
||||
bool isCaseSensitive)
|
||||
{
|
||||
string result;
|
||||
return TryGetWithoutAttributeSuffix(name, isCaseSensitive, out result) ? result : null;
|
||||
}
|
||||
|
||||
internal static bool TryGetWithoutAttributeSuffix(
|
||||
this string name,
|
||||
bool isCaseSensitive,
|
||||
out string result)
|
||||
{
|
||||
const string AttributeSuffix = "Attribute";
|
||||
var comparison = isCaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
|
||||
if (name.Length > AttributeSuffix.Length && name.EndsWith(AttributeSuffix, comparison)) {
|
||||
result = name.Substring(0, name.Length - AttributeSuffix.Length);
|
||||
return true;
|
||||
}
|
||||
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool IsValidUnicodeString(this string str)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < str.Length) {
|
||||
char c = str[i++];
|
||||
|
||||
// (high surrogate, low surrogate) makes a valid pair, anything else is invalid:
|
||||
if (char.IsHighSurrogate(c)) {
|
||||
if (i < str.Length && char.IsLowSurrogate(str[i])) {
|
||||
i++;
|
||||
} else {
|
||||
// high surrogate not followed by low surrogate
|
||||
return false;
|
||||
}
|
||||
} else if (char.IsLowSurrogate(c)) {
|
||||
// previous character wasn't a high surrogate
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove one set of leading and trailing double quote characters, if both are present.
|
||||
/// </summary>
|
||||
internal static string Unquote(this string arg)
|
||||
{
|
||||
bool quoted;
|
||||
return Unquote(arg, out quoted);
|
||||
}
|
||||
|
||||
internal static string Unquote(this string arg, out bool quoted)
|
||||
{
|
||||
if (arg.Length > 1 && arg[0] == '"' && arg[arg.Length - 1] == '"') {
|
||||
quoted = true;
|
||||
return arg.Substring(1, arg.Length - 2);
|
||||
} else {
|
||||
quoted = false;
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
internal static int IndexOfBalancedParenthesis(this string str, int openingOffset, char closing)
|
||||
{
|
||||
char opening = str[openingOffset];
|
||||
|
||||
int depth = 1;
|
||||
for (int i = openingOffset + 1; i < str.Length; i++) {
|
||||
var c = str[i];
|
||||
if (c == opening) {
|
||||
depth++;
|
||||
} else if (c == closing) {
|
||||
depth--;
|
||||
if (depth == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// String isn't IEnumerable<char> in the current Portable profile.
|
||||
internal static char First(this string arg)
|
||||
{
|
||||
return arg[0];
|
||||
}
|
||||
|
||||
// String isn't IEnumerable<char> in the current Portable profile.
|
||||
internal static char Last(this string arg)
|
||||
{
|
||||
return arg[arg.Length - 1];
|
||||
}
|
||||
|
||||
// String isn't IEnumerable<char> in the current Portable profile.
|
||||
internal static bool All(this string arg, Predicate<char> predicate)
|
||||
{
|
||||
foreach (char c in arg) {
|
||||
if (!predicate(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string EscapeIdentifier(
|
||||
this string identifier,
|
||||
bool isQueryContext = false)
|
||||
{
|
||||
var nullIndex = identifier.IndexOf('\0');
|
||||
if (nullIndex >= 0) {
|
||||
identifier = identifier.Substring(0, nullIndex);
|
||||
}
|
||||
|
||||
var needsEscaping = SyntaxFacts.GetKeywordKind(identifier) != SyntaxKind.None;
|
||||
|
||||
// Check if we need to escape this contextual keyword
|
||||
needsEscaping = needsEscaping || (isQueryContext && SyntaxFacts.IsQueryContextualKeyword(SyntaxFacts.GetContextualKeywordKind(identifier)));
|
||||
|
||||
return needsEscaping ? "@" + identifier : identifier;
|
||||
}
|
||||
|
||||
public static SyntaxToken ToIdentifierToken(
|
||||
this string identifier,
|
||||
bool isQueryContext = false)
|
||||
{
|
||||
var escaped = identifier.EscapeIdentifier(isQueryContext);
|
||||
|
||||
if (escaped.Length == 0 || escaped[0] != '@') {
|
||||
return SyntaxFactory.Identifier(escaped);
|
||||
}
|
||||
|
||||
var unescaped = identifier.StartsWith("@", StringComparison.Ordinal)
|
||||
? identifier.Substring(1)
|
||||
: identifier;
|
||||
|
||||
var token = SyntaxFactory.Identifier(
|
||||
default(SyntaxTriviaList), SyntaxKind.None, "@" + unescaped, unescaped, default(SyntaxTriviaList));
|
||||
|
||||
if (!identifier.StartsWith("@", StringComparison.Ordinal)) {
|
||||
token = token.WithAdditionalAnnotations(Simplifier.Annotation);
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public static IdentifierNameSyntax ToIdentifierName(this string identifier)
|
||||
{
|
||||
return SyntaxFactory.IdentifierName(identifier.ToIdentifierToken());
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,377 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Shared.Extensions;
|
||||
using Roslyn.Utilities;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Extensions;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class SyntaxExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Look inside a trivia list for a skipped token that contains the given position.
|
||||
/// </summary>
|
||||
private static readonly Func<SyntaxTriviaList, int, SyntaxToken> s_findSkippedTokenBackward =
|
||||
(l, p) => FindTokenHelper.FindSkippedTokenBackward(GetSkippedTokens(l), p);
|
||||
|
||||
/// <summary>
|
||||
/// return only skipped tokens
|
||||
/// </summary>
|
||||
private static IEnumerable<SyntaxToken> GetSkippedTokens(SyntaxTriviaList list)
|
||||
{
|
||||
return list.Where(trivia => trivia.RawKind == (int)SyntaxKind.SkippedTokensTrivia)
|
||||
.SelectMany(t => ((SkippedTokensTriviaSyntax)t.GetStructure()).Tokens);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the position is inside of token, return that token; otherwise, return the token to the left.
|
||||
/// </summary>
|
||||
public static SyntaxToken FindTokenOnLeftOfPosition(
|
||||
this SyntaxNode root,
|
||||
int position,
|
||||
bool includeSkipped = true,
|
||||
bool includeDirectives = false,
|
||||
bool includeDocumentationComments = false)
|
||||
{
|
||||
var skippedTokenFinder = includeSkipped ? s_findSkippedTokenBackward : (Func<SyntaxTriviaList, int, SyntaxToken>)null;
|
||||
|
||||
return FindTokenHelper.FindTokenOnLeftOfPosition<CompilationUnitSyntax>(
|
||||
root, position, skippedTokenFinder, includeSkipped, includeDirectives, includeDocumentationComments);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public static bool IntersectsWith(this SyntaxToken token, int position)
|
||||
// {
|
||||
// return token.Span.IntersectsWith(position);
|
||||
// }
|
||||
|
||||
// public static bool IsLeftSideOfDot(this ExpressionSyntax syntax)
|
||||
// {
|
||||
// return (bool)isLeftSideOfDotMethod.Invoke(null, new object[] { syntax });
|
||||
// }
|
||||
//
|
||||
// public static bool IsRightSideOfDot(this ExpressionSyntax syntax)
|
||||
// {
|
||||
// return (bool)isRightSideOfDotMethod.Invoke(null, new object[] { syntax });
|
||||
// }
|
||||
|
||||
// public static INamedTypeSymbol GetEnclosingNamedType(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
|
||||
// {
|
||||
// return (INamedTypeSymbol)getEnclosingNamedTypeMethod.Invoke(null, new object[] { semanticModel, position, cancellationToken });
|
||||
// }
|
||||
//
|
||||
|
||||
|
||||
public static ExpressionSyntax SkipParens(this ExpressionSyntax expression)
|
||||
{
|
||||
if (expression == null)
|
||||
return null;
|
||||
while (expression != null && expression.IsKind(SyntaxKind.ParenthesizedExpression)) {
|
||||
expression = ((ParenthesizedExpressionSyntax)expression).Expression;
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
public static SyntaxNode SkipArgument(this SyntaxNode expression)
|
||||
{
|
||||
if (expression is Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax)
|
||||
return ((Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax)expression).Expression;
|
||||
if (expression is Microsoft.CodeAnalysis.VisualBasic.Syntax.ArgumentSyntax)
|
||||
return ((Microsoft.CodeAnalysis.VisualBasic.Syntax.ArgumentSyntax)expression).GetExpression();
|
||||
return expression;
|
||||
}
|
||||
|
||||
public static bool IsParentKind(this SyntaxNode node, SyntaxKind kind)
|
||||
{
|
||||
return node != null && node.Parent.IsKind(kind);
|
||||
}
|
||||
|
||||
public static bool IsParentKind(this SyntaxToken node, SyntaxKind kind)
|
||||
{
|
||||
return node.Parent != null && node.Parent.IsKind(kind);
|
||||
}
|
||||
|
||||
public static INamedTypeSymbol GetEnclosingNamedType(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
|
||||
{
|
||||
return semanticModel.GetEnclosingSymbol<INamedTypeSymbol>(position, cancellationToken);
|
||||
}
|
||||
|
||||
public static TSymbol GetEnclosingSymbol<TSymbol>(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
|
||||
where TSymbol : ISymbol
|
||||
{
|
||||
for (var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
|
||||
symbol != null;
|
||||
symbol = symbol.ContainingSymbol) {
|
||||
if (symbol is TSymbol) {
|
||||
return (TSymbol)symbol;
|
||||
}
|
||||
}
|
||||
|
||||
return default(TSymbol);
|
||||
}
|
||||
|
||||
internal static bool IsValidSymbolInfo(ISymbol symbol)
|
||||
{
|
||||
// name bound to only one symbol is valid
|
||||
return symbol != null && !symbol.IsErrorType();
|
||||
}
|
||||
|
||||
private static bool IsThisOrTypeOrNamespace(MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
|
||||
{
|
||||
if (memberAccess.Expression.Kind() == SyntaxKind.ThisExpression) {
|
||||
var previousToken = memberAccess.Expression.GetFirstToken().GetPreviousToken();
|
||||
|
||||
var symbol = semanticModel.GetSymbolInfo(memberAccess.Name).Symbol;
|
||||
|
||||
if (previousToken.Kind() == SyntaxKind.OpenParenToken &&
|
||||
previousToken.IsParentKind(SyntaxKind.ParenthesizedExpression) &&
|
||||
!previousToken.Parent.IsParentKind(SyntaxKind.ParenthesizedExpression) &&
|
||||
((ParenthesizedExpressionSyntax)previousToken.Parent).Expression.Kind() == SyntaxKind.SimpleMemberAccessExpression &&
|
||||
symbol != null && symbol.Kind == SymbolKind.Method) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var expressionInfo = semanticModel.GetSymbolInfo(memberAccess.Expression);
|
||||
if (IsValidSymbolInfo(expressionInfo.Symbol)) {
|
||||
if (expressionInfo.Symbol is INamespaceOrTypeSymbol) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expressionInfo.Symbol.IsThisParameter()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static SyntaxNode FindImmediatelyEnclosingLocalVariableDeclarationSpace(SyntaxNode syntax)
|
||||
{
|
||||
for (var declSpace = syntax; declSpace != null; declSpace = declSpace.Parent) {
|
||||
switch (declSpace.Kind()) {
|
||||
// These are declaration-space-defining syntaxes, by the spec:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.IndexerDeclaration:
|
||||
case SyntaxKind.OperatorDeclaration:
|
||||
case SyntaxKind.ConstructorDeclaration:
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ParenthesizedLambdaExpression:
|
||||
case SyntaxKind.SimpleLambdaExpression:
|
||||
case SyntaxKind.AnonymousMethodExpression:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.ForEachKeyword:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.UsingStatement:
|
||||
|
||||
// SPEC VIOLATION: We also want to stop walking out if, say, we are in a field
|
||||
// initializer. Technically according to the wording of the spec it should be
|
||||
// legal to use a simple name inconsistently inside a field initializer because
|
||||
// it does not define a local variable declaration space. In practice of course
|
||||
// we want to check for that. (As the native compiler does as well.)
|
||||
|
||||
case SyntaxKind.FieldDeclaration:
|
||||
return declSpace;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool ParserWouldTreatExpressionAsCast(ExpressionSyntax reducedNode, MemberAccessExpressionSyntax originalNode)
|
||||
{
|
||||
SyntaxNode parent = originalNode;
|
||||
while (parent != null) {
|
||||
if (parent.IsParentKind(SyntaxKind.SimpleMemberAccessExpression)) {
|
||||
parent = parent.Parent;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!parent.IsParentKind(SyntaxKind.ParenthesizedExpression)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var newExpression = parent.ReplaceNode((SyntaxNode)originalNode, reducedNode);
|
||||
|
||||
// detect cast ambiguities according to C# spec #7.7.6
|
||||
if (IsNameOrMemberAccessButNoExpression(newExpression)) {
|
||||
var nextToken = parent.Parent.GetLastToken().GetNextToken();
|
||||
|
||||
return nextToken.Kind() == SyntaxKind.OpenParenToken ||
|
||||
nextToken.Kind() == SyntaxKind.TildeToken ||
|
||||
nextToken.Kind() == SyntaxKind.ExclamationToken ||
|
||||
(SyntaxFacts.IsKeywordKind(nextToken.Kind()) && !(nextToken.Kind() == SyntaxKind.AsKeyword || nextToken.Kind() == SyntaxKind.IsKeyword));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsMemberAccessADynamicInvocation(MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
|
||||
{
|
||||
var ancestorInvocation = memberAccess.FirstAncestorOrSelf<InvocationExpressionSyntax>();
|
||||
|
||||
if (ancestorInvocation != null && ancestorInvocation.SpanStart == memberAccess.SpanStart) {
|
||||
var typeInfo = semanticModel.GetTypeInfo(ancestorInvocation);
|
||||
if (typeInfo.Type != null &&
|
||||
typeInfo.Type.Kind == SymbolKind.DynamicType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsNameOrMemberAccessButNoExpression(SyntaxNode node)
|
||||
{
|
||||
if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression)) {
|
||||
var memberAccess = (MemberAccessExpressionSyntax)node;
|
||||
|
||||
return memberAccess.Expression.IsKind(SyntaxKind.IdentifierName) ||
|
||||
IsNameOrMemberAccessButNoExpression(memberAccess.Expression);
|
||||
}
|
||||
|
||||
return node.IsKind(SyntaxKind.IdentifierName);
|
||||
}
|
||||
|
||||
private static bool AccessMethodWithDynamicArgumentInsideStructConstructor(this MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
|
||||
{
|
||||
var constructor = memberAccess.Ancestors().OfType<ConstructorDeclarationSyntax>().SingleOrDefault();
|
||||
|
||||
if (constructor == null || constructor.Parent.Kind() != SyntaxKind.StructDeclaration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return semanticModel.GetSymbolInfo(memberAccess.Name).CandidateReason == CandidateReason.LateBound;
|
||||
}
|
||||
|
||||
private static bool IsNullableTypeInPointerExpression(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
|
||||
{
|
||||
// Note: nullable type syntax is not allowed in pointer type syntax
|
||||
if (simplifiedNode.Kind() == SyntaxKind.NullableType &&
|
||||
simplifiedNode.DescendantNodes().Any(n => n is PointerTypeSyntax)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsAmbiguousCast(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
|
||||
{
|
||||
// Can't simplify a type name in a cast expression if it would then cause the cast to be
|
||||
// parsed differently. For example: (Foo::Bar)+1 is a cast. But if that simplifies to
|
||||
// (Bar)+1 then that's an arithmetic expression.
|
||||
if (expression.IsParentKind(SyntaxKind.CastExpression)) {
|
||||
var castExpression = (CastExpressionSyntax)expression.Parent;
|
||||
if (castExpression.Type == expression) {
|
||||
var newCastExpression = castExpression.ReplaceNode((SyntaxNode)castExpression.Type, simplifiedNode);
|
||||
var reparsedCastExpression = SyntaxFactory.ParseExpression(newCastExpression.ToString());
|
||||
|
||||
if (!reparsedCastExpression.IsKind(SyntaxKind.CastExpression)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private static bool IsNonNameSyntaxInUsingDirective(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
|
||||
{
|
||||
return
|
||||
expression.IsParentKind(SyntaxKind.UsingDirective) &&
|
||||
!(simplifiedNode is NameSyntax);
|
||||
}
|
||||
|
||||
private static bool IsNotNullableReplacable(this NameSyntax name, TypeSyntax reducedName)
|
||||
{
|
||||
var isNotNullableReplacable = false;
|
||||
// var isLeftSideOfDot = name.IsLeftSideOfDot();
|
||||
// var isRightSideOfDot = name.IsRightSideOfDot();
|
||||
|
||||
if (reducedName.Kind() == SyntaxKind.NullableType) {
|
||||
if (((NullableTypeSyntax)reducedName).ElementType.Kind() == SyntaxKind.OmittedTypeArgument) {
|
||||
isNotNullableReplacable = true;
|
||||
} else {
|
||||
isNotNullableReplacable = name.IsLeftSideOfDot() || name.IsRightSideOfDot();
|
||||
}
|
||||
}
|
||||
|
||||
return isNotNullableReplacable;
|
||||
}
|
||||
|
||||
public static SyntaxTokenList GetModifiers(this MemberDeclarationSyntax member)
|
||||
{
|
||||
if (member == null)
|
||||
throw new ArgumentNullException("member");
|
||||
var method = member as BaseMethodDeclarationSyntax;
|
||||
if (method != null)
|
||||
return method.Modifiers;
|
||||
var property = member as BasePropertyDeclarationSyntax;
|
||||
if (property != null)
|
||||
return property.Modifiers;
|
||||
var field = member as BaseFieldDeclarationSyntax;
|
||||
if (field != null)
|
||||
return field.Modifiers;
|
||||
return new SyntaxTokenList();
|
||||
}
|
||||
|
||||
public static ExplicitInterfaceSpecifierSyntax GetExplicitInterfaceSpecifierSyntax(this MemberDeclarationSyntax member)
|
||||
{
|
||||
if (member == null)
|
||||
throw new ArgumentNullException("member");
|
||||
var method = member as MethodDeclarationSyntax;
|
||||
if (method != null)
|
||||
return method.ExplicitInterfaceSpecifier;
|
||||
var property = member as BasePropertyDeclarationSyntax;
|
||||
if (property != null)
|
||||
return property.ExplicitInterfaceSpecifier;
|
||||
var evt = member as EventDeclarationSyntax;
|
||||
if (evt != null)
|
||||
return evt.ExplicitInterfaceSpecifier;
|
||||
return null;
|
||||
}
|
||||
// public static bool IsKind(this SyntaxToken token, SyntaxKind kind)
|
||||
// {
|
||||
// return token.RawKind == (int)kind;
|
||||
// }
|
||||
//
|
||||
// public static bool IsKind(this SyntaxTrivia trivia, SyntaxKind kind)
|
||||
// {
|
||||
// return trivia.RawKind == (int)kind;
|
||||
// }
|
||||
//
|
||||
// public static bool IsKind(this SyntaxNode node, SyntaxKind kind)
|
||||
// {
|
||||
// return node?.RawKind == (int)kind;
|
||||
// }
|
||||
//
|
||||
// public static bool IsKind(this SyntaxNodeOrToken nodeOrToken, SyntaxKind kind)
|
||||
// {
|
||||
// return nodeOrToken.RawKind == (int)kind;
|
||||
// }
|
||||
//
|
||||
|
||||
// public static SyntaxNode GetParent(this SyntaxNode node)
|
||||
// {
|
||||
// return node != null ? node.Parent : null;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,195 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
||||
using Microsoft.CodeAnalysis.Shared.Extensions;
|
||||
using Roslyn.Utilities;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class SyntaxTriviaExtensions
|
||||
{
|
||||
public static int Width(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.Span.Length;
|
||||
}
|
||||
|
||||
public static int FullWidth(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.FullSpan.Length;
|
||||
}
|
||||
|
||||
public static bool IsElastic(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.HasAnnotation(SyntaxAnnotation.ElasticAnnotation);
|
||||
}
|
||||
|
||||
public static bool MatchesKind(this SyntaxTrivia trivia, SyntaxKind kind)
|
||||
{
|
||||
return trivia.Kind() == kind;
|
||||
}
|
||||
|
||||
public static bool MatchesKind(this SyntaxTrivia trivia, SyntaxKind kind1, SyntaxKind kind2)
|
||||
{
|
||||
var triviaKind = trivia.Kind();
|
||||
return triviaKind == kind1 || triviaKind == kind2;
|
||||
}
|
||||
|
||||
public static bool MatchesKind(this SyntaxTrivia trivia, params SyntaxKind[] kinds)
|
||||
{
|
||||
return kinds.Contains(trivia.Kind());
|
||||
}
|
||||
|
||||
public static bool IsRegularComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.IsSingleLineComment() || trivia.IsMultiLineComment();
|
||||
}
|
||||
|
||||
public static bool IsRegularOrDocComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.IsSingleLineComment() || trivia.IsMultiLineComment() || trivia.IsDocComment();
|
||||
}
|
||||
|
||||
public static bool IsSingleLineComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.Kind() == SyntaxKind.SingleLineCommentTrivia;
|
||||
}
|
||||
|
||||
public static bool IsMultiLineComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.Kind() == SyntaxKind.MultiLineCommentTrivia;
|
||||
}
|
||||
|
||||
public static bool IsCompleteMultiLineComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
if (trivia.Kind() != SyntaxKind.MultiLineCommentTrivia) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var text = trivia.ToFullString();
|
||||
return text.Length >= 4
|
||||
&& text[text.Length - 1] == '/'
|
||||
&& text[text.Length - 2] == '*';
|
||||
}
|
||||
|
||||
public static bool IsDocComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.IsSingleLineDocComment() || trivia.IsMultiLineDocComment();
|
||||
}
|
||||
|
||||
public static bool IsSingleLineDocComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.Kind() == SyntaxKind.SingleLineDocumentationCommentTrivia;
|
||||
}
|
||||
|
||||
public static bool IsMultiLineDocComment(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia;
|
||||
}
|
||||
|
||||
public static string GetCommentText(this SyntaxTrivia trivia)
|
||||
{
|
||||
var commentText = trivia.ToString();
|
||||
if (trivia.Kind() == SyntaxKind.SingleLineCommentTrivia) {
|
||||
if (commentText.StartsWith("//")) {
|
||||
commentText = commentText.Substring(2);
|
||||
}
|
||||
|
||||
return commentText.TrimStart(null);
|
||||
} else if (trivia.Kind() == SyntaxKind.MultiLineCommentTrivia) {
|
||||
var textBuilder = new StringBuilder();
|
||||
|
||||
if (commentText.EndsWith("*/")) {
|
||||
commentText = commentText.Substring(0, commentText.Length - 2);
|
||||
}
|
||||
|
||||
if (commentText.StartsWith("/*")) {
|
||||
commentText = commentText.Substring(2);
|
||||
}
|
||||
|
||||
commentText = commentText.Trim();
|
||||
|
||||
var newLine = Environment.NewLine;
|
||||
var lines = commentText.Split(new[] { newLine }, StringSplitOptions.None);
|
||||
foreach (var line in lines) {
|
||||
var trimmedLine = line.Trim();
|
||||
|
||||
// Note: we trim leading '*' characters in multi-line comments.
|
||||
// If the '*' was intentional, sorry, it's gone.
|
||||
if (trimmedLine.StartsWith("*")) {
|
||||
trimmedLine = trimmedLine.TrimStart('*');
|
||||
trimmedLine = trimmedLine.TrimStart(null);
|
||||
}
|
||||
|
||||
textBuilder.AppendLine(trimmedLine);
|
||||
}
|
||||
|
||||
// remove last line break
|
||||
textBuilder.Remove(textBuilder.Length - newLine.Length, newLine.Length);
|
||||
|
||||
return textBuilder.ToString();
|
||||
} else {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public static string AsString(this IEnumerable<SyntaxTrivia> trivia)
|
||||
{
|
||||
//Contract.ThrowIfNull(trivia);
|
||||
|
||||
if (trivia.Any()) {
|
||||
var sb = new StringBuilder();
|
||||
trivia.Select(t => t.ToFullString()).Do((s) => sb.Append(s));
|
||||
return sb.ToString();
|
||||
} else {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetFullWidth(this IEnumerable<SyntaxTrivia> trivia)
|
||||
{
|
||||
//Contract.ThrowIfNull(trivia);
|
||||
return trivia.Sum(t => t.FullWidth());
|
||||
}
|
||||
|
||||
public static SyntaxTriviaList AsTrivia(this string s)
|
||||
{
|
||||
return SyntaxFactory.ParseLeadingTrivia(s ?? string.Empty);
|
||||
}
|
||||
|
||||
public static bool IsWhitespaceOrEndOfLine(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.Kind() == SyntaxKind.WhitespaceTrivia || trivia.Kind() == SyntaxKind.EndOfLineTrivia;
|
||||
}
|
||||
|
||||
public static SyntaxTrivia GetPreviousTrivia(
|
||||
this SyntaxTrivia trivia, SyntaxTree syntaxTree, CancellationToken cancellationToken, bool findInsideTrivia = false)
|
||||
{
|
||||
var span = trivia.FullSpan;
|
||||
if (span.Start == 0) {
|
||||
return default(SyntaxTrivia);
|
||||
}
|
||||
|
||||
return syntaxTree.GetRoot(cancellationToken).FindTrivia(span.Start - 1, findInsideTrivia);
|
||||
}
|
||||
|
||||
#if false
|
||||
public static int Width(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.Span.Length;
|
||||
}
|
||||
|
||||
public static int FullWidth(this SyntaxTrivia trivia)
|
||||
{
|
||||
return trivia.FullSpan.Length;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class TypeExtensions
|
||||
{
|
||||
#region GetDelegateInvokeMethod
|
||||
/// <summary>
|
||||
/// Gets the invoke method for a delegate type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returns null if the type is not a delegate type; or if the invoke method could not be found.
|
||||
/// </remarks>
|
||||
public static IMethodSymbol GetDelegateInvokeMethod(this ITypeSymbol type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException("type");
|
||||
if (type.TypeKind == TypeKind.Delegate)
|
||||
return type.GetMembers("Invoke").OfType<IMethodSymbol>().FirstOrDefault(m => m.MethodKind == MethodKind.DelegateInvoke);
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets the full name of the namespace.
|
||||
/// </summary>
|
||||
public static string GetFullName(this INamespaceSymbol ns)
|
||||
{
|
||||
return ns.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the full name. The full name is no 1:1 representation of a type it's missing generics and it has a poor
|
||||
/// representation for inner types (just dot separated).
|
||||
/// DO NOT use this method unless you're know what you do. It's only implemented for legacy code.
|
||||
/// </summary>
|
||||
public static string GetFullName(this ITypeSymbol type)
|
||||
{
|
||||
return type.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the type is public and was tagged with
|
||||
/// [System.ComponentModel.ToolboxItem (true)]
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if is designer browsable the specified symbol; otherwise, <c>false</c>.</returns>
|
||||
/// <param name="symbol">Symbol.</param>
|
||||
public static bool IsToolboxItem(this ITypeSymbol symbol)
|
||||
{
|
||||
if (symbol == null)
|
||||
throw new ArgumentNullException("symbol");
|
||||
if (symbol.DeclaredAccessibility != Accessibility.Public)
|
||||
return false;
|
||||
var toolboxItemAttr = symbol.GetAttributes().FirstOrDefault(attr => attr.AttributeClass.Name == "ToolboxItemAttribute" && attr.AttributeClass.ContainingNamespace.MetadataName == "System.ComponentModel");
|
||||
if (toolboxItemAttr != null && toolboxItemAttr.ConstructorArguments.Length == 1) {
|
||||
try {
|
||||
return (bool)toolboxItemAttr.ConstructorArguments[0].Value;
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsNullableType(this ITypeSymbol type)
|
||||
{
|
||||
var original = type.OriginalDefinition;
|
||||
return original.SpecialType == SpecialType.System_Nullable_T;
|
||||
}
|
||||
|
||||
public static ITypeSymbol GetNullableUnderlyingType(this ITypeSymbol type)
|
||||
{
|
||||
if (!IsNullableType(type))
|
||||
return null;
|
||||
return ((INamedTypeSymbol)type).TypeArguments[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all base classes.
|
||||
/// </summary>
|
||||
/// <returns>The all base classes.</returns>
|
||||
/// <param name="type">Type.</param>
|
||||
public static IEnumerable<INamedTypeSymbol> GetAllBaseClasses(this INamedTypeSymbol type, bool includeSuperType = false)
|
||||
{
|
||||
if (!includeSuperType)
|
||||
type = type.BaseType;
|
||||
while (type != null) {
|
||||
yield return type;
|
||||
type = type.BaseType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all base classes and interfaces.
|
||||
/// </summary>
|
||||
/// <returns>All classes and interfaces.</returns>
|
||||
/// <param name="type">Type.</param>
|
||||
public static IEnumerable<INamedTypeSymbol> GetAllBaseClassesAndInterfaces(this INamedTypeSymbol type, bool includeSuperType = false)
|
||||
{
|
||||
if (!includeSuperType)
|
||||
type = type.BaseType;
|
||||
var curType = type;
|
||||
while (curType != null) {
|
||||
yield return curType;
|
||||
curType = curType.BaseType;
|
||||
}
|
||||
|
||||
foreach (var inter in type.AllInterfaces) {
|
||||
yield return inter;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if derived from baseType. Includes itself and all base classes, but does not include interfaces.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if is derived from class the specified type baseType; otherwise, <c>false</c>.</returns>
|
||||
/// <param name="type">Type.</param>
|
||||
/// <param name="baseType">Base type.</param>
|
||||
public static bool IsDerivedFromClass(this INamedTypeSymbol type, INamedTypeSymbol baseType)
|
||||
{
|
||||
//NR5 is returning true also for same type
|
||||
for (; type != null; type = type.BaseType) {
|
||||
if (type == baseType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if derived from baseType. Includes itself, all base classes and all interfaces.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if is derived from the specified type baseType; otherwise, <c>false</c>.</returns>
|
||||
/// <param name="type">Type.</param>
|
||||
/// <param name="baseType">Base type.</param>
|
||||
public static bool IsDerivedFromClassOrInterface(this INamedTypeSymbol type, INamedTypeSymbol baseType)
|
||||
{
|
||||
//NR5 is returning true also for same type
|
||||
for (; type != null; type = type.BaseType) {
|
||||
if (type == baseType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//And interfaces
|
||||
foreach (var inter in type.AllInterfaces) {
|
||||
if (inter == baseType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the full name of the metadata.
|
||||
/// In case symbol is not INamedTypeSymbol it returns raw MetadataName
|
||||
/// Example: Generic type returns T1, T2...
|
||||
/// </summary>
|
||||
/// <returns>The full metadata name.</returns>
|
||||
/// <param name="symbol">Symbol.</param>
|
||||
public static string GetFullMetadataName(this ITypeSymbol symbol)
|
||||
{
|
||||
//This is for comaptibility with NR5 reflection name in case of generic types like T1, T2...
|
||||
var namedTypeSymbol = symbol as INamedTypeSymbol;
|
||||
return namedTypeSymbol != null ? GetFullMetadataName(namedTypeSymbol) : symbol.MetadataName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the full MetadataName(ReflectionName in NR5).
|
||||
/// Example: Namespace1.Namespace2.Classs1+NestedClassWithTwoGenericTypes`2+NestedClassWithoutGenerics
|
||||
/// </summary>
|
||||
/// <returns>The full metadata name.</returns>
|
||||
/// <param name="symbol">Symbol.</param>
|
||||
public static string GetFullMetadataName(this INamedTypeSymbol symbol)
|
||||
{
|
||||
var fullName = new StringBuilder(symbol.MetadataName);
|
||||
var parentType = symbol.ContainingType;
|
||||
while (parentType != null) {
|
||||
fullName.Insert(0, '+');
|
||||
fullName.Insert(0, parentType.MetadataName);
|
||||
parentType = parentType.ContainingType;
|
||||
}
|
||||
var ns = symbol.ContainingNamespace;
|
||||
while (ns != null && !ns.IsGlobalNamespace) {
|
||||
fullName.Insert(0, '.');
|
||||
fullName.Insert(0, ns.MetadataName);
|
||||
ns = ns.ContainingNamespace;
|
||||
}
|
||||
return fullName.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,275 @@
|
|||
using System;
|
||||
using RefactoringEssentials;
|
||||
using Microsoft.CodeAnalysis.VisualBasic.Syntax;
|
||||
using Microsoft.CodeAnalysis.VisualBasic;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
static class VBUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Inverts a boolean condition. Note: The condition object can be frozen (from AST) it's cloned internally.
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition to invert.</param>
|
||||
public static ExpressionSyntax InvertCondition(ExpressionSyntax condition)
|
||||
{
|
||||
if (condition is ParenthesizedExpressionSyntax) {
|
||||
return SyntaxFactory.ParenthesizedExpression(
|
||||
InvertCondition(((ParenthesizedExpressionSyntax)condition).Expression));
|
||||
}
|
||||
|
||||
if (condition is UnaryExpressionSyntax) {
|
||||
var uOp = (UnaryExpressionSyntax)condition;
|
||||
if (uOp.IsKind(SyntaxKind.NotExpression)) {
|
||||
return uOp.Operand;
|
||||
}
|
||||
return SyntaxFactory.UnaryExpression(
|
||||
SyntaxKind.NotExpression,
|
||||
uOp.OperatorToken,
|
||||
uOp);
|
||||
}
|
||||
|
||||
if (condition is BinaryExpressionSyntax) {
|
||||
var bOp = (BinaryExpressionSyntax)condition;
|
||||
|
||||
if (bOp.IsKind(SyntaxKind.AndExpression) ||
|
||||
bOp.IsKind(SyntaxKind.AndAlsoExpression) ||
|
||||
bOp.IsKind(SyntaxKind.OrExpression) ||
|
||||
bOp.IsKind(SyntaxKind.OrElseExpression)) {
|
||||
var kind = NegateConditionOperator(bOp.Kind());
|
||||
return SyntaxFactory.BinaryExpression(
|
||||
kind,
|
||||
InvertCondition(bOp.Left),
|
||||
SyntaxFactory.Token(GetExpressionOperatorTokenKind(kind)),
|
||||
InvertCondition(bOp.Right));
|
||||
}
|
||||
|
||||
if (bOp.IsKind(SyntaxKind.EqualsExpression) ||
|
||||
bOp.IsKind(SyntaxKind.NotEqualsExpression) ||
|
||||
bOp.IsKind(SyntaxKind.GreaterThanExpression) ||
|
||||
bOp.IsKind(SyntaxKind.GreaterThanOrEqualExpression) ||
|
||||
bOp.IsKind(SyntaxKind.LessThanExpression) ||
|
||||
bOp.IsKind(SyntaxKind.LessThanOrEqualExpression)) {
|
||||
var kind = NegateRelationalOperator(bOp.Kind());
|
||||
return SyntaxFactory.BinaryExpression(
|
||||
kind,
|
||||
bOp.Left,
|
||||
SyntaxFactory.Token(GetExpressionOperatorTokenKind(kind)),
|
||||
bOp.Right);
|
||||
}
|
||||
|
||||
return SyntaxFactory.UnaryExpression(
|
||||
SyntaxKind.NotExpression,
|
||||
SyntaxFactory.Token(SyntaxKind.NotKeyword),
|
||||
SyntaxFactory.ParenthesizedExpression(condition));
|
||||
}
|
||||
|
||||
if (condition is TernaryConditionalExpressionSyntax) {
|
||||
var cEx = condition as TernaryConditionalExpressionSyntax;
|
||||
return cEx.WithCondition(InvertCondition(cEx.Condition));
|
||||
}
|
||||
|
||||
if (condition is LiteralExpressionSyntax) {
|
||||
if (condition.Kind() == SyntaxKind.TrueLiteralExpression) {
|
||||
return SyntaxFactory.LiteralExpression(
|
||||
SyntaxKind.FalseLiteralExpression,
|
||||
SyntaxFactory.Token(SyntaxKind.FalseKeyword));
|
||||
}
|
||||
if (condition.Kind() == SyntaxKind.FalseLiteralExpression) {
|
||||
return SyntaxFactory.LiteralExpression(
|
||||
SyntaxKind.TrueLiteralExpression,
|
||||
SyntaxFactory.Token(SyntaxKind.TrueKeyword));
|
||||
}
|
||||
}
|
||||
|
||||
return SyntaxFactory.UnaryExpression(
|
||||
SyntaxKind.NotExpression,
|
||||
SyntaxFactory.Token(SyntaxKind.NotKeyword),
|
||||
AddParensForUnaryExpressionIfRequired(condition));
|
||||
}
|
||||
|
||||
public static SyntaxKind GetExpressionOperatorTokenKind(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.EqualsExpression:
|
||||
return SyntaxKind.EqualsToken;
|
||||
case SyntaxKind.NotEqualsExpression:
|
||||
return SyntaxKind.LessThanGreaterThanToken;
|
||||
case SyntaxKind.GreaterThanExpression:
|
||||
return SyntaxKind.GreaterThanToken;
|
||||
case SyntaxKind.GreaterThanOrEqualExpression:
|
||||
return SyntaxKind.GreaterThanEqualsToken;
|
||||
case SyntaxKind.LessThanExpression:
|
||||
return SyntaxKind.LessThanToken;
|
||||
case SyntaxKind.LessThanOrEqualExpression:
|
||||
return SyntaxKind.LessThanEqualsToken;
|
||||
case SyntaxKind.OrExpression:
|
||||
return SyntaxKind.OrKeyword;
|
||||
case SyntaxKind.OrElseExpression:
|
||||
return SyntaxKind.OrElseKeyword;
|
||||
case SyntaxKind.AndExpression:
|
||||
return SyntaxKind.AndKeyword;
|
||||
case SyntaxKind.AndAlsoExpression:
|
||||
return SyntaxKind.AndAlsoKeyword;
|
||||
case SyntaxKind.AddExpression:
|
||||
return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.ConcatenateExpression:
|
||||
return SyntaxKind.AmpersandToken;
|
||||
case SyntaxKind.SubtractExpression:
|
||||
return SyntaxKind.MinusToken;
|
||||
case SyntaxKind.MultiplyExpression:
|
||||
return SyntaxKind.AsteriskToken;
|
||||
case SyntaxKind.DivideExpression:
|
||||
return SyntaxKind.SlashToken;
|
||||
case SyntaxKind.ModuloExpression:
|
||||
return SyntaxKind.ModKeyword;
|
||||
// assignments
|
||||
case SyntaxKind.SimpleAssignmentStatement:
|
||||
return SyntaxKind.EqualsToken;
|
||||
case SyntaxKind.AddAssignmentStatement:
|
||||
return SyntaxKind.PlusEqualsToken;
|
||||
case SyntaxKind.SubtractAssignmentStatement:
|
||||
return SyntaxKind.MinusEqualsToken;
|
||||
// unary
|
||||
case SyntaxKind.UnaryPlusExpression:
|
||||
return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.UnaryMinusExpression:
|
||||
return SyntaxKind.MinusToken;
|
||||
case SyntaxKind.NotExpression:
|
||||
return SyntaxKind.NotKeyword;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(op));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When negating an expression this is required, otherwise you would end up with
|
||||
/// a or b -> !a or b
|
||||
/// </summary>
|
||||
public static ExpressionSyntax AddParensForUnaryExpressionIfRequired(ExpressionSyntax expression)
|
||||
{
|
||||
if ((expression is BinaryExpressionSyntax) ||
|
||||
(expression is CastExpressionSyntax) ||
|
||||
(expression is LambdaExpressionSyntax)) {
|
||||
return SyntaxFactory.ParenthesizedExpression(expression);
|
||||
}
|
||||
|
||||
return expression;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get negation of the specified relational operator
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// negation of the specified relational operator, or BinaryOperatorType.Any if it's not a relational operator
|
||||
/// </returns>
|
||||
public static SyntaxKind NegateRelationalOperator(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.EqualsExpression:
|
||||
return SyntaxKind.NotEqualsExpression;
|
||||
case SyntaxKind.NotEqualsExpression:
|
||||
return SyntaxKind.EqualsExpression;
|
||||
case SyntaxKind.GreaterThanExpression:
|
||||
return SyntaxKind.LessThanOrEqualExpression;
|
||||
case SyntaxKind.GreaterThanOrEqualExpression:
|
||||
return SyntaxKind.LessThanExpression;
|
||||
case SyntaxKind.LessThanExpression:
|
||||
return SyntaxKind.GreaterThanOrEqualExpression;
|
||||
case SyntaxKind.LessThanOrEqualExpression:
|
||||
return SyntaxKind.GreaterThanExpression;
|
||||
case SyntaxKind.OrExpression:
|
||||
return SyntaxKind.AndExpression;
|
||||
case SyntaxKind.OrElseExpression:
|
||||
return SyntaxKind.AndAlsoExpression;
|
||||
case SyntaxKind.AndExpression:
|
||||
return SyntaxKind.OrExpression;
|
||||
case SyntaxKind.AndAlsoExpression:
|
||||
return SyntaxKind.OrElseExpression;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(op));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get negation of the condition operator
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// negation of the specified condition operator, or BinaryOperatorType.Any if it's not a condition operator
|
||||
/// </returns>
|
||||
public static SyntaxKind NegateConditionOperator(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.OrExpression:
|
||||
return SyntaxKind.AndExpression;
|
||||
case SyntaxKind.OrElseExpression:
|
||||
return SyntaxKind.AndAlsoExpression;
|
||||
case SyntaxKind.AndExpression:
|
||||
return SyntaxKind.OrExpression;
|
||||
case SyntaxKind.AndAlsoExpression:
|
||||
return SyntaxKind.OrElseExpression;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(op));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the specified operator is a relational operator
|
||||
/// </summary>
|
||||
public static bool IsRelationalOperator(SyntaxKind op)
|
||||
{
|
||||
switch (op) {
|
||||
case SyntaxKind.EqualsExpression:
|
||||
case SyntaxKind.NotEqualsExpression:
|
||||
case SyntaxKind.GreaterThanExpression:
|
||||
case SyntaxKind.GreaterThanOrEqualExpression:
|
||||
case SyntaxKind.LessThanExpression:
|
||||
case SyntaxKind.LessThanOrEqualExpression:
|
||||
case SyntaxKind.OrExpression:
|
||||
case SyntaxKind.OrElseExpression:
|
||||
case SyntaxKind.AndExpression:
|
||||
case SyntaxKind.AndAlsoExpression:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2)
|
||||
{
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var vbKind = node.Kind();
|
||||
return vbKind == kind1 || vbKind == kind2;
|
||||
}
|
||||
|
||||
public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3)
|
||||
{
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var vbKind = node.Kind();
|
||||
return vbKind == kind1 || vbKind == kind2 || vbKind == kind3;
|
||||
}
|
||||
|
||||
public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3, SyntaxKind kind4)
|
||||
{
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var vbKind = node.Kind();
|
||||
return vbKind == kind1 || vbKind == kind2 || vbKind == kind3 || vbKind == kind4;
|
||||
}
|
||||
|
||||
public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3, SyntaxKind kind4, SyntaxKind kind5)
|
||||
{
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var vbKind = node.Kind();
|
||||
return vbKind == kind1 || vbKind == kind2 || vbKind == kind3 || vbKind == kind4 || vbKind == kind5;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,387 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
using CS = Microsoft.CodeAnalysis.CSharp;
|
||||
using CSS = Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.VisualBasic;
|
||||
using Microsoft.CodeAnalysis.VisualBasic.Syntax;
|
||||
using RefactoringEssentials.Converter;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace RefactoringEssentials.VB.Converter
|
||||
{
|
||||
public partial class CSharpConverter
|
||||
{
|
||||
enum TokenContext
|
||||
{
|
||||
Global,
|
||||
InterfaceOrModule,
|
||||
Member,
|
||||
VariableOrConst,
|
||||
Local
|
||||
}
|
||||
|
||||
public static VisualBasicSyntaxNode Convert(CS.CSharpSyntaxNode input, SemanticModel semanticModel, Document targetDocument)
|
||||
{
|
||||
return input.Accept(new NodesVisitor(semanticModel, targetDocument));
|
||||
}
|
||||
|
||||
public static ConversionResult ConvertText(string text, MetadataReference[] references)
|
||||
{
|
||||
if (text == null)
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
if (references == null)
|
||||
throw new ArgumentNullException(nameof(references));
|
||||
var tree = CS.SyntaxFactory.ParseSyntaxTree(SourceText.From(text));
|
||||
var compilation = CS.CSharpCompilation.Create("Conversion", new[] { tree }, references);
|
||||
try
|
||||
{
|
||||
return new ConversionResult(Convert((CS.CSharpSyntaxNode)tree.GetRoot(), compilation.GetSemanticModel(tree, true), null).NormalizeWhitespace().ToFullString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ConversionResult(ex);
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<SyntaxToken> ConvertModifiersCore(IEnumerable<SyntaxToken> modifiers, TokenContext context)
|
||||
{
|
||||
if (context != TokenContext.Local && context != TokenContext.InterfaceOrModule)
|
||||
{
|
||||
bool visibility = false;
|
||||
foreach (var token in modifiers)
|
||||
{
|
||||
if (IsVisibility(token, context))
|
||||
{
|
||||
visibility = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!visibility && context == TokenContext.Member)
|
||||
yield return CSharpDefaultVisibility(context);
|
||||
}
|
||||
foreach (var token in modifiers.Where(m => !IgnoreInContext(m, context)))
|
||||
{
|
||||
var m = ConvertModifier(token, context);
|
||||
if (m.HasValue) yield return m.Value;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IgnoreInContext(SyntaxToken m, TokenContext context)
|
||||
{
|
||||
switch (context)
|
||||
{
|
||||
case TokenContext.InterfaceOrModule:
|
||||
return m.IsKind(CS.SyntaxKind.PublicKeyword, CS.SyntaxKind.StaticKeyword);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsVisibility(SyntaxToken token, TokenContext context)
|
||||
{
|
||||
return token.IsKind(CS.SyntaxKind.PublicKeyword, CS.SyntaxKind.InternalKeyword, CS.SyntaxKind.ProtectedKeyword, CS.SyntaxKind.PrivateKeyword)
|
||||
|| (context == TokenContext.VariableOrConst && token.IsKind(CS.SyntaxKind.ConstKeyword));
|
||||
}
|
||||
|
||||
static SyntaxToken CSharpDefaultVisibility(TokenContext context)
|
||||
{
|
||||
switch (context)
|
||||
{
|
||||
case TokenContext.Global:
|
||||
return SyntaxFactory.Token(SyntaxKind.FriendKeyword);
|
||||
case TokenContext.Local:
|
||||
case TokenContext.VariableOrConst:
|
||||
case TokenContext.Member:
|
||||
return SyntaxFactory.Token(SyntaxKind.PrivateKeyword);
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(context));
|
||||
}
|
||||
|
||||
static SyntaxTokenList ConvertModifiers(IEnumerable<SyntaxToken> modifiers, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
return SyntaxFactory.TokenList(ConvertModifiersCore(modifiers, context));
|
||||
}
|
||||
|
||||
static SyntaxTokenList ConvertModifiers(SyntaxTokenList modifiers, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
return SyntaxFactory.TokenList(ConvertModifiersCore(modifiers, context));
|
||||
}
|
||||
|
||||
static SyntaxToken? ConvertModifier(SyntaxToken m, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
var token = ConvertToken(CS.CSharpExtensions.Kind(m), context);
|
||||
return token == SyntaxKind.None ? null : new SyntaxToken?(SyntaxFactory.Token(token));
|
||||
}
|
||||
|
||||
static SeparatedSyntaxList<VariableDeclaratorSyntax> RemodelVariableDeclaration(CSS.VariableDeclarationSyntax declaration, NodesVisitor nodesVisitor)
|
||||
{
|
||||
var type = (TypeSyntax)declaration.Type.Accept(nodesVisitor);
|
||||
var declaratorsWithoutInitializers = new List<CSS.VariableDeclaratorSyntax>();
|
||||
var declarators = new List<VariableDeclaratorSyntax>();
|
||||
|
||||
foreach (var v in declaration.Variables)
|
||||
{
|
||||
if (v.Initializer == null)
|
||||
{
|
||||
declaratorsWithoutInitializers.Add(v);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
declarators.Add(
|
||||
SyntaxFactory.VariableDeclarator(
|
||||
SyntaxFactory.SingletonSeparatedList(ExtractIdentifier(v)),
|
||||
declaration.Type.IsVar ? null : SyntaxFactory.SimpleAsClause(type),
|
||||
SyntaxFactory.EqualsValue((ExpressionSyntax)v.Initializer.Value.Accept(nodesVisitor))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (declaratorsWithoutInitializers.Count > 0)
|
||||
{
|
||||
declarators.Insert(0, SyntaxFactory.VariableDeclarator(SyntaxFactory.SeparatedList(declaratorsWithoutInitializers.Select(ExtractIdentifier)), SyntaxFactory.SimpleAsClause(type), null));
|
||||
}
|
||||
|
||||
return SyntaxFactory.SeparatedList(declarators);
|
||||
}
|
||||
|
||||
static ModifiedIdentifierSyntax ExtractIdentifier(CSS.VariableDeclaratorSyntax v)
|
||||
{
|
||||
return SyntaxFactory.ModifiedIdentifier(ConvertIdentifier(v.Identifier));
|
||||
}
|
||||
|
||||
static SyntaxToken ConvertIdentifier(SyntaxToken id)
|
||||
{
|
||||
var keywordKind = SyntaxFacts.GetKeywordKind(id.ValueText);
|
||||
if (keywordKind != SyntaxKind.None && !SyntaxFacts.IsPredefinedType(keywordKind))
|
||||
return SyntaxFactory.Identifier("[" + id.ValueText + "]");
|
||||
return SyntaxFactory.Identifier(id.ValueText);
|
||||
}
|
||||
|
||||
static ExpressionSyntax Literal(object o) => GetLiteralExpression(o);
|
||||
|
||||
internal static ExpressionSyntax GetLiteralExpression(object value)
|
||||
{
|
||||
if (value is bool)
|
||||
return (bool)value ? SyntaxFactory.TrueLiteralExpression(SyntaxFactory.Token(SyntaxKind.TrueKeyword)) : SyntaxFactory.FalseLiteralExpression(SyntaxFactory.Token(SyntaxKind.FalseKeyword));
|
||||
if (value is byte)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((byte)value));
|
||||
if (value is sbyte)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((sbyte)value));
|
||||
if (value is short)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((short)value));
|
||||
if (value is ushort)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((ushort)value));
|
||||
if (value is int)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((int)value));
|
||||
if (value is uint)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((uint)value));
|
||||
if (value is long)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((long)value));
|
||||
if (value is ulong)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((ulong)value));
|
||||
|
||||
if (value is float)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((float)value));
|
||||
if (value is double)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((double)value));
|
||||
if (value is decimal)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal((decimal)value));
|
||||
|
||||
if (value is char)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.CharacterLiteralExpression, SyntaxFactory.Literal((char)value));
|
||||
|
||||
if (value is string)
|
||||
return SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal((string)value));
|
||||
|
||||
if (value == null)
|
||||
return SyntaxFactory.NothingLiteralExpression(SyntaxFactory.Token(SyntaxKind.NothingKeyword));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static SyntaxKind ConvertToken(CS.SyntaxKind t, TokenContext context = TokenContext.Global)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case CS.SyntaxKind.None:
|
||||
return SyntaxKind.None;
|
||||
// built-in types
|
||||
case CS.SyntaxKind.BoolKeyword:
|
||||
return SyntaxKind.BooleanKeyword;
|
||||
case CS.SyntaxKind.ByteKeyword:
|
||||
return SyntaxKind.ByteKeyword;
|
||||
case CS.SyntaxKind.SByteKeyword:
|
||||
return SyntaxKind.SByteKeyword;
|
||||
case CS.SyntaxKind.ShortKeyword:
|
||||
return SyntaxKind.ShortKeyword;
|
||||
case CS.SyntaxKind.UShortKeyword:
|
||||
return SyntaxKind.UShortKeyword;
|
||||
case CS.SyntaxKind.IntKeyword:
|
||||
return SyntaxKind.IntegerKeyword;
|
||||
case CS.SyntaxKind.UIntKeyword:
|
||||
return SyntaxKind.UIntegerKeyword;
|
||||
case CS.SyntaxKind.LongKeyword:
|
||||
return SyntaxKind.LongKeyword;
|
||||
case CS.SyntaxKind.ULongKeyword:
|
||||
return SyntaxKind.ULongKeyword;
|
||||
case CS.SyntaxKind.DoubleKeyword:
|
||||
return SyntaxKind.DoubleKeyword;
|
||||
case CS.SyntaxKind.FloatKeyword:
|
||||
return SyntaxKind.SingleKeyword;
|
||||
case CS.SyntaxKind.DecimalKeyword:
|
||||
return SyntaxKind.DecimalKeyword;
|
||||
case CS.SyntaxKind.StringKeyword:
|
||||
return SyntaxKind.StringKeyword;
|
||||
case CS.SyntaxKind.CharKeyword:
|
||||
return SyntaxKind.CharKeyword;
|
||||
case CS.SyntaxKind.VoidKeyword:
|
||||
// not supported
|
||||
return SyntaxKind.None;
|
||||
case CS.SyntaxKind.ObjectKeyword:
|
||||
return SyntaxKind.ObjectKeyword;
|
||||
// literals
|
||||
case CS.SyntaxKind.NullKeyword:
|
||||
return SyntaxKind.NothingKeyword;
|
||||
case CS.SyntaxKind.TrueKeyword:
|
||||
return SyntaxKind.TrueKeyword;
|
||||
case CS.SyntaxKind.FalseKeyword:
|
||||
return SyntaxKind.FalseKeyword;
|
||||
case CS.SyntaxKind.ThisKeyword:
|
||||
return SyntaxKind.MeKeyword;
|
||||
case CS.SyntaxKind.BaseKeyword:
|
||||
return SyntaxKind.MyBaseKeyword;
|
||||
// modifiers
|
||||
case CS.SyntaxKind.PublicKeyword:
|
||||
return SyntaxKind.PublicKeyword;
|
||||
case CS.SyntaxKind.PrivateKeyword:
|
||||
return SyntaxKind.PrivateKeyword;
|
||||
case CS.SyntaxKind.InternalKeyword:
|
||||
return SyntaxKind.FriendKeyword;
|
||||
case CS.SyntaxKind.ProtectedKeyword:
|
||||
return SyntaxKind.ProtectedKeyword;
|
||||
case CS.SyntaxKind.StaticKeyword:
|
||||
return SyntaxKind.SharedKeyword;
|
||||
case CS.SyntaxKind.ReadOnlyKeyword:
|
||||
return SyntaxKind.ReadOnlyKeyword;
|
||||
case CS.SyntaxKind.SealedKeyword:
|
||||
return context == TokenContext.Global ? SyntaxKind.NotInheritableKeyword : SyntaxKind.NotOverridableKeyword;
|
||||
case CS.SyntaxKind.ConstKeyword:
|
||||
return SyntaxKind.ConstKeyword;
|
||||
case CS.SyntaxKind.OverrideKeyword:
|
||||
return SyntaxKind.OverridesKeyword;
|
||||
case CS.SyntaxKind.AbstractKeyword:
|
||||
return context == TokenContext.Global ? SyntaxKind.MustInheritKeyword : SyntaxKind.MustOverrideKeyword;
|
||||
case CS.SyntaxKind.VirtualKeyword:
|
||||
return SyntaxKind.OverridableKeyword;
|
||||
case CS.SyntaxKind.RefKeyword:
|
||||
return SyntaxKind.ByRefKeyword;
|
||||
case CS.SyntaxKind.OutKeyword:
|
||||
return SyntaxKind.ByRefKeyword;
|
||||
case CS.SyntaxKind.PartialKeyword:
|
||||
return SyntaxKind.PartialKeyword;
|
||||
case CS.SyntaxKind.AsyncKeyword:
|
||||
return SyntaxKind.AsyncKeyword;
|
||||
case CS.SyntaxKind.ExternKeyword:
|
||||
// not supported
|
||||
return SyntaxKind.None;
|
||||
case CS.SyntaxKind.NewKeyword:
|
||||
return SyntaxKind.ShadowsKeyword;
|
||||
case CS.SyntaxKind.ParamsKeyword:
|
||||
return SyntaxKind.ParamArrayKeyword;
|
||||
// others
|
||||
case CS.SyntaxKind.AscendingKeyword:
|
||||
return SyntaxKind.AscendingKeyword;
|
||||
case CS.SyntaxKind.DescendingKeyword:
|
||||
return SyntaxKind.DescendingKeyword;
|
||||
case CS.SyntaxKind.AwaitKeyword:
|
||||
return SyntaxKind.AwaitKeyword;
|
||||
// expressions
|
||||
case CS.SyntaxKind.AddExpression:
|
||||
return SyntaxKind.AddExpression;
|
||||
case CS.SyntaxKind.SubtractExpression:
|
||||
return SyntaxKind.SubtractExpression;
|
||||
case CS.SyntaxKind.MultiplyExpression:
|
||||
return SyntaxKind.MultiplyExpression;
|
||||
case CS.SyntaxKind.DivideExpression:
|
||||
return SyntaxKind.DivideExpression;
|
||||
case CS.SyntaxKind.ModuloExpression:
|
||||
return SyntaxKind.ModuloExpression;
|
||||
case CS.SyntaxKind.LeftShiftExpression:
|
||||
return SyntaxKind.LeftShiftExpression;
|
||||
case CS.SyntaxKind.RightShiftExpression:
|
||||
return SyntaxKind.RightShiftExpression;
|
||||
case CS.SyntaxKind.LogicalOrExpression:
|
||||
return SyntaxKind.OrElseExpression;
|
||||
case CS.SyntaxKind.LogicalAndExpression:
|
||||
return SyntaxKind.AndAlsoExpression;
|
||||
case CS.SyntaxKind.BitwiseOrExpression:
|
||||
return SyntaxKind.OrExpression;
|
||||
case CS.SyntaxKind.BitwiseAndExpression:
|
||||
return SyntaxKind.AndExpression;
|
||||
case CS.SyntaxKind.ExclusiveOrExpression:
|
||||
return SyntaxKind.ExclusiveOrExpression;
|
||||
case CS.SyntaxKind.EqualsExpression:
|
||||
return SyntaxKind.EqualsExpression;
|
||||
case CS.SyntaxKind.NotEqualsExpression:
|
||||
return SyntaxKind.NotEqualsExpression;
|
||||
case CS.SyntaxKind.LessThanExpression:
|
||||
return SyntaxKind.LessThanExpression;
|
||||
case CS.SyntaxKind.LessThanOrEqualExpression:
|
||||
return SyntaxKind.LessThanOrEqualExpression;
|
||||
case CS.SyntaxKind.GreaterThanExpression:
|
||||
return SyntaxKind.GreaterThanExpression;
|
||||
case CS.SyntaxKind.GreaterThanOrEqualExpression:
|
||||
return SyntaxKind.GreaterThanOrEqualExpression;
|
||||
case CS.SyntaxKind.SimpleAssignmentExpression:
|
||||
return SyntaxKind.SimpleAssignmentStatement;
|
||||
case CS.SyntaxKind.AddAssignmentExpression:
|
||||
return SyntaxKind.AddAssignmentStatement;
|
||||
case CS.SyntaxKind.SubtractAssignmentExpression:
|
||||
return SyntaxKind.SubtractAssignmentStatement;
|
||||
case CS.SyntaxKind.MultiplyAssignmentExpression:
|
||||
return SyntaxKind.MultiplyAssignmentStatement;
|
||||
case CS.SyntaxKind.DivideAssignmentExpression:
|
||||
return SyntaxKind.DivideAssignmentStatement;
|
||||
case CS.SyntaxKind.ModuloAssignmentExpression:
|
||||
return SyntaxKind.ModuloExpression;
|
||||
case CS.SyntaxKind.AndAssignmentExpression:
|
||||
return SyntaxKind.AndExpression;
|
||||
case CS.SyntaxKind.ExclusiveOrAssignmentExpression:
|
||||
return SyntaxKind.ExclusiveOrExpression;
|
||||
case CS.SyntaxKind.OrAssignmentExpression:
|
||||
return SyntaxKind.OrExpression;
|
||||
case CS.SyntaxKind.LeftShiftAssignmentExpression:
|
||||
break;
|
||||
case CS.SyntaxKind.RightShiftAssignmentExpression:
|
||||
break;
|
||||
case CS.SyntaxKind.UnaryPlusExpression:
|
||||
return SyntaxKind.UnaryPlusExpression;
|
||||
case CS.SyntaxKind.UnaryMinusExpression:
|
||||
return SyntaxKind.UnaryMinusExpression;
|
||||
case CS.SyntaxKind.BitwiseNotExpression:
|
||||
return SyntaxKind.NotExpression;
|
||||
case CS.SyntaxKind.LogicalNotExpression:
|
||||
return SyntaxKind.NotExpression;
|
||||
case CS.SyntaxKind.PreIncrementExpression:
|
||||
return SyntaxKind.AddAssignmentStatement;
|
||||
case CS.SyntaxKind.PreDecrementExpression:
|
||||
return SyntaxKind.SubtractAssignmentStatement;
|
||||
case CS.SyntaxKind.PostIncrementExpression:
|
||||
return SyntaxKind.AddAssignmentStatement;
|
||||
case CS.SyntaxKind.PostDecrementExpression:
|
||||
return SyntaxKind.SubtractAssignmentStatement;
|
||||
case CS.SyntaxKind.PlusPlusToken:
|
||||
return SyntaxKind.PlusToken;
|
||||
case CS.SyntaxKind.MinusMinusToken:
|
||||
return SyntaxKind.MinusToken;
|
||||
}
|
||||
|
||||
throw new NotSupportedException(t + " is not supported!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using CS = Microsoft.CodeAnalysis.CSharp;
|
||||
|
||||
namespace RefactoringEssentials.VB.Converter
|
||||
{
|
||||
static class ConversionExtensions
|
||||
{
|
||||
public static bool HasUsingDirective(this CS.CSharpSyntaxTree tree, string fullName)
|
||||
{
|
||||
if (tree == null)
|
||||
throw new ArgumentNullException(nameof(tree));
|
||||
if (string.IsNullOrWhiteSpace(fullName))
|
||||
throw new ArgumentException("given namespace cannot be null or empty.", nameof(fullName));
|
||||
fullName = fullName.Trim();
|
||||
return tree.GetRoot()
|
||||
.DescendantNodes(MatchesNamespaceOrRoot)
|
||||
.OfType<CS.Syntax.UsingDirectiveSyntax>()
|
||||
.Any(u => u.Name.ToString().Equals(fullName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private static bool MatchesNamespaceOrRoot(SyntaxNode arg)
|
||||
{
|
||||
return arg is CS.Syntax.NamespaceDeclarationSyntax || arg is CS.Syntax.CompilationUnitSyntax;
|
||||
}
|
||||
|
||||
public static IEnumerable<R> IndexedSelect<T, R>(this IEnumerable<T> source, Func<int, T, R> transform)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in source) {
|
||||
yield return transform(i, item);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,575 @@
|
|||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.VisualBasic;
|
||||
using Microsoft.CodeAnalysis.VisualBasic.Syntax;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CS = Microsoft.CodeAnalysis.CSharp;
|
||||
using CSS = Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace RefactoringEssentials.VB.Converter
|
||||
{
|
||||
public partial class CSharpConverter
|
||||
{
|
||||
class MethodBodyVisitor : CS.CSharpSyntaxVisitor<SyntaxList<StatementSyntax>>
|
||||
{
|
||||
SemanticModel semanticModel;
|
||||
NodesVisitor nodesVisitor;
|
||||
Stack<BlockInfo> blockInfo = new Stack<BlockInfo>(); // currently only works with switch blocks
|
||||
int switchCount = 0;
|
||||
public bool IsInterator { get; private set; }
|
||||
|
||||
class BlockInfo
|
||||
{
|
||||
public readonly List<VisualBasicSyntaxNode> GotoCaseExpressions = new List<VisualBasicSyntaxNode>();
|
||||
}
|
||||
|
||||
public MethodBodyVisitor(SemanticModel semanticModel, NodesVisitor nodesVisitor)
|
||||
{
|
||||
this.semanticModel = semanticModel;
|
||||
this.nodesVisitor = nodesVisitor;
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> DefaultVisit(SyntaxNode node)
|
||||
{
|
||||
throw new NotImplementedException(node.GetType() + " not implemented!");
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitLocalDeclarationStatement(CSS.LocalDeclarationStatementSyntax node)
|
||||
{
|
||||
var modifiers = ConvertModifiers(node.Modifiers, TokenContext.Local);
|
||||
if (modifiers.Count == 0)
|
||||
modifiers = modifiers.Add(SyntaxFactory.Token(SyntaxKind.DimKeyword));
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(
|
||||
SyntaxFactory.LocalDeclarationStatement(
|
||||
modifiers,
|
||||
RemodelVariableDeclaration(node.Declaration, nodesVisitor)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
StatementSyntax ConvertSingleExpression(CSS.ExpressionSyntax node)
|
||||
{
|
||||
var exprNode = node.Accept(nodesVisitor);
|
||||
if (!(exprNode is StatementSyntax))
|
||||
exprNode = SyntaxFactory.ExpressionStatement((ExpressionSyntax)exprNode);
|
||||
|
||||
return (StatementSyntax)exprNode;
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitExpressionStatement(CSS.ExpressionStatementSyntax node)
|
||||
{
|
||||
return SyntaxFactory.SingletonList(ConvertSingleExpression(node.Expression));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitIfStatement(CSS.IfStatementSyntax node)
|
||||
{
|
||||
IdentifierNameSyntax name;
|
||||
List<ArgumentSyntax> arguments = new List<ArgumentSyntax>();
|
||||
StatementSyntax stmt;
|
||||
if (node.Else == null && TryConvertRaiseEvent(node, out name, arguments)) {
|
||||
stmt = SyntaxFactory.RaiseEventStatement(name, SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(arguments)));
|
||||
return SyntaxFactory.SingletonList(stmt);
|
||||
}
|
||||
var elseIfBlocks = new List<ElseIfBlockSyntax>();
|
||||
ElseBlockSyntax elseBlock = null;
|
||||
CollectElseBlocks(node, elseIfBlocks, ref elseBlock);
|
||||
if (node.Statement is CSS.BlockSyntax) {
|
||||
stmt = SyntaxFactory.MultiLineIfBlock(
|
||||
SyntaxFactory.IfStatement((ExpressionSyntax)node.Condition.Accept(nodesVisitor)).WithThenKeyword(SyntaxFactory.Token(SyntaxKind.ThenKeyword)),
|
||||
ConvertBlock(node.Statement),
|
||||
SyntaxFactory.List(elseIfBlocks),
|
||||
elseBlock
|
||||
);
|
||||
} else {
|
||||
if (elseIfBlocks.Any() || !IsSimpleStatement(node.Statement)) {
|
||||
stmt = SyntaxFactory.MultiLineIfBlock(
|
||||
SyntaxFactory.IfStatement((ExpressionSyntax)node.Condition.Accept(nodesVisitor)).WithThenKeyword(SyntaxFactory.Token(SyntaxKind.ThenKeyword)),
|
||||
ConvertBlock(node.Statement),
|
||||
SyntaxFactory.List(elseIfBlocks),
|
||||
elseBlock
|
||||
);
|
||||
} else {
|
||||
stmt = SyntaxFactory.SingleLineIfStatement(
|
||||
(ExpressionSyntax)node.Condition.Accept(nodesVisitor),
|
||||
ConvertBlock(node.Statement),
|
||||
elseBlock == null ? null : SyntaxFactory.SingleLineElseClause(elseBlock.Statements)
|
||||
).WithThenKeyword(SyntaxFactory.Token(SyntaxKind.ThenKeyword));
|
||||
}
|
||||
}
|
||||
return SyntaxFactory.SingletonList(stmt);
|
||||
}
|
||||
|
||||
bool IsSimpleStatement(CSS.StatementSyntax statement)
|
||||
{
|
||||
return statement is CSS.ExpressionStatementSyntax
|
||||
|| statement is CSS.BreakStatementSyntax
|
||||
|| statement is CSS.ContinueStatementSyntax
|
||||
|| statement is CSS.ReturnStatementSyntax
|
||||
|| statement is CSS.YieldStatementSyntax
|
||||
|| statement is CSS.ThrowStatementSyntax;
|
||||
}
|
||||
|
||||
bool TryConvertRaiseEvent(CSS.IfStatementSyntax node, out IdentifierNameSyntax name, List<ArgumentSyntax> arguments)
|
||||
{
|
||||
name = null;
|
||||
var condition = node.Condition;
|
||||
while (condition is CSS.ParenthesizedExpressionSyntax)
|
||||
condition = ((CSS.ParenthesizedExpressionSyntax)condition).Expression;
|
||||
if (!(condition is CSS.BinaryExpressionSyntax))
|
||||
return false;
|
||||
var be = (CSS.BinaryExpressionSyntax)condition;
|
||||
if (!be.IsKind(CS.SyntaxKind.NotEqualsExpression) || (!be.Left.IsKind(CS.SyntaxKind.NullLiteralExpression) && !be.Right.IsKind(CS.SyntaxKind.NullLiteralExpression)))
|
||||
return false;
|
||||
CSS.ExpressionStatementSyntax singleStatement;
|
||||
if (node.Statement is CSS.BlockSyntax) {
|
||||
var block = ((CSS.BlockSyntax)node.Statement);
|
||||
if (block.Statements.Count != 1)
|
||||
return false;
|
||||
singleStatement = block.Statements[0] as CSS.ExpressionStatementSyntax;
|
||||
} else {
|
||||
singleStatement = node.Statement as CSS.ExpressionStatementSyntax;
|
||||
}
|
||||
if (singleStatement == null || !(singleStatement.Expression is CSS.InvocationExpressionSyntax))
|
||||
return false;
|
||||
var possibleEventName = GetPossibleEventName(be.Left) ?? GetPossibleEventName(be.Right);
|
||||
if (possibleEventName == null)
|
||||
return false;
|
||||
var invocation = (CSS.InvocationExpressionSyntax)singleStatement.Expression;
|
||||
var invocationName = GetPossibleEventName(invocation.Expression);
|
||||
if (possibleEventName != invocationName)
|
||||
return false;
|
||||
name = SyntaxFactory.IdentifierName(possibleEventName);
|
||||
arguments.AddRange(invocation.ArgumentList.Arguments.Select(a => (ArgumentSyntax)a.Accept(nodesVisitor)));
|
||||
return true;
|
||||
}
|
||||
|
||||
string GetPossibleEventName(CSS.ExpressionSyntax expression)
|
||||
{
|
||||
var ident = expression as CSS.IdentifierNameSyntax;
|
||||
if (ident != null)
|
||||
return ident.Identifier.Text;
|
||||
var fre = expression as CSS.MemberAccessExpressionSyntax;
|
||||
if (fre != null && fre.Expression.IsKind(CS.SyntaxKind.ThisExpression))
|
||||
return fre.Name.Identifier.Text;
|
||||
return null;
|
||||
}
|
||||
|
||||
void CollectElseBlocks(CSS.IfStatementSyntax node, List<ElseIfBlockSyntax> elseIfBlocks, ref ElseBlockSyntax elseBlock)
|
||||
{
|
||||
if (node.Else == null) return;
|
||||
if (node.Else.Statement is CSS.IfStatementSyntax) {
|
||||
var elseIf = (CSS.IfStatementSyntax)node.Else.Statement;
|
||||
elseIfBlocks.Add(
|
||||
SyntaxFactory.ElseIfBlock(
|
||||
SyntaxFactory.ElseIfStatement((ExpressionSyntax)elseIf.Condition.Accept(nodesVisitor)).WithThenKeyword(SyntaxFactory.Token(SyntaxKind.ThenKeyword)),
|
||||
ConvertBlock(elseIf.Statement)
|
||||
)
|
||||
);
|
||||
CollectElseBlocks(elseIf, elseIfBlocks, ref elseBlock);
|
||||
} else
|
||||
elseBlock = SyntaxFactory.ElseBlock(ConvertBlock(node.Else.Statement));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitSwitchStatement(CSS.SwitchStatementSyntax node)
|
||||
{
|
||||
StatementSyntax stmt;
|
||||
blockInfo.Push(new BlockInfo());
|
||||
try {
|
||||
var blocks = node.Sections.Select(ConvertSwitchSection).ToArray();
|
||||
stmt = SyntaxFactory.SelectBlock(
|
||||
SyntaxFactory.SelectStatement((ExpressionSyntax)node.Expression.Accept(nodesVisitor)).WithCaseKeyword(SyntaxFactory.Token(SyntaxKind.CaseKeyword)),
|
||||
SyntaxFactory.List(AddLabels(blocks, blockInfo.Peek().GotoCaseExpressions))
|
||||
);
|
||||
switchCount++;
|
||||
} finally {
|
||||
blockInfo.Pop();
|
||||
}
|
||||
return SyntaxFactory.SingletonList(stmt);
|
||||
}
|
||||
|
||||
IEnumerable<CaseBlockSyntax> AddLabels(CaseBlockSyntax[] blocks, List<VisualBasicSyntaxNode> gotoLabels)
|
||||
{
|
||||
foreach (var _block in blocks) {
|
||||
var block = _block;
|
||||
foreach (var caseClause in block.CaseStatement.Cases) {
|
||||
var expression = caseClause is ElseCaseClauseSyntax ? (VisualBasicSyntaxNode)caseClause : ((SimpleCaseClauseSyntax)caseClause).Value;
|
||||
if (gotoLabels.Any(label => label.IsEquivalentTo(expression)))
|
||||
block = block.WithStatements(block.Statements.Insert(0, SyntaxFactory.LabelStatement(MakeGotoSwitchLabel(expression))));
|
||||
}
|
||||
yield return block;
|
||||
}
|
||||
}
|
||||
|
||||
CaseBlockSyntax ConvertSwitchSection(CSS.SwitchSectionSyntax section)
|
||||
{
|
||||
if (section.Labels.OfType<CSS.DefaultSwitchLabelSyntax>().Any())
|
||||
return SyntaxFactory.CaseElseBlock(SyntaxFactory.CaseElseStatement(SyntaxFactory.ElseCaseClause()), ConvertSwitchSectionBlock(section));
|
||||
return SyntaxFactory.CaseBlock(SyntaxFactory.CaseStatement(SyntaxFactory.SeparatedList(section.Labels.OfType<CSS.CaseSwitchLabelSyntax>().Select(ConvertSwitchLabel))), ConvertSwitchSectionBlock(section));
|
||||
}
|
||||
|
||||
SyntaxList<StatementSyntax> ConvertSwitchSectionBlock(CSS.SwitchSectionSyntax section)
|
||||
{
|
||||
List<StatementSyntax> statements = new List<StatementSyntax>();
|
||||
var lastStatement = section.Statements.LastOrDefault();
|
||||
foreach (var s in section.Statements) {
|
||||
if (s == lastStatement && s is CSS.BreakStatementSyntax)
|
||||
continue;
|
||||
statements.AddRange(ConvertBlock(s));
|
||||
}
|
||||
return SyntaxFactory.List(statements);
|
||||
}
|
||||
|
||||
CaseClauseSyntax ConvertSwitchLabel(CSS.CaseSwitchLabelSyntax label)
|
||||
{
|
||||
return SyntaxFactory.SimpleCaseClause((ExpressionSyntax)label.Value.Accept(nodesVisitor));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitDoStatement(CSS.DoStatementSyntax node)
|
||||
{
|
||||
var condition = (ExpressionSyntax)node.Condition.Accept(nodesVisitor);
|
||||
var stmt = ConvertBlock(node.Statement);
|
||||
var block = SyntaxFactory.DoLoopWhileBlock(
|
||||
SyntaxFactory.DoStatement(SyntaxKind.SimpleDoStatement),
|
||||
stmt,
|
||||
SyntaxFactory.LoopStatement(SyntaxKind.LoopWhileStatement, SyntaxFactory.WhileClause(condition))
|
||||
);
|
||||
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(block);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitWhileStatement(CSS.WhileStatementSyntax node)
|
||||
{
|
||||
var condition = (ExpressionSyntax)node.Condition.Accept(nodesVisitor);
|
||||
var stmt = ConvertBlock(node.Statement);
|
||||
var block = SyntaxFactory.WhileBlock(
|
||||
SyntaxFactory.WhileStatement(condition),
|
||||
stmt
|
||||
);
|
||||
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(block);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitForStatement(CSS.ForStatementSyntax node)
|
||||
{
|
||||
StatementSyntax block;
|
||||
if (!ConvertForToSimpleForNext(node, out block)) {
|
||||
var stmts = ConvertBlock(node.Statement)
|
||||
.AddRange(node.Incrementors.Select(ConvertSingleExpression));
|
||||
var condition = node.Condition == null ? Literal(true) : (ExpressionSyntax)node.Condition.Accept(nodesVisitor);
|
||||
block = SyntaxFactory.WhileBlock(
|
||||
SyntaxFactory.WhileStatement(condition),
|
||||
stmts
|
||||
);
|
||||
return SyntaxFactory.List(node.Initializers.Select(ConvertSingleExpression)).Add(block);
|
||||
}
|
||||
return SyntaxFactory.SingletonList(block);
|
||||
}
|
||||
|
||||
bool ConvertForToSimpleForNext(CSS.ForStatementSyntax node, out StatementSyntax block)
|
||||
{
|
||||
// ForStatement -> ForNextStatement when for-loop is simple
|
||||
|
||||
// only the following forms of the for-statement are allowed:
|
||||
// for (TypeReference name = start; name < oneAfterEnd; name += step)
|
||||
// for (name = start; name < oneAfterEnd; name += step)
|
||||
// for (TypeReference name = start; name <= end; name += step)
|
||||
// for (name = start; name <= end; name += step)
|
||||
// for (TypeReference name = start; name > oneAfterEnd; name -= step)
|
||||
// for (name = start; name > oneAfterEnd; name -= step)
|
||||
// for (TypeReference name = start; name >= end; name -= step)
|
||||
// for (name = start; name >= end; name -= step)
|
||||
|
||||
block = null;
|
||||
|
||||
// check if the form is valid and collect TypeReference, name, start, end and step
|
||||
bool hasVariable = node.Declaration != null && node.Declaration.Variables.Count == 1;
|
||||
if (!hasVariable && node.Initializers.Count != 1)
|
||||
return false;
|
||||
if (node.Incrementors.Count != 1)
|
||||
return false;
|
||||
var iterator = node.Incrementors.FirstOrDefault()?.Accept(nodesVisitor) as AssignmentStatementSyntax;
|
||||
if (iterator == null || !iterator.IsKind(SyntaxKind.AddAssignmentStatement, SyntaxKind.SubtractAssignmentStatement))
|
||||
return false;
|
||||
var iteratorIdentifier = iterator.Left as IdentifierNameSyntax;
|
||||
if (iteratorIdentifier == null)
|
||||
return false;
|
||||
var stepExpression = iterator.Right as LiteralExpressionSyntax;
|
||||
if (stepExpression == null || !(stepExpression.Token.Value is int))
|
||||
return false;
|
||||
int step = (int)stepExpression.Token.Value;
|
||||
if (iterator.OperatorToken.IsKind(SyntaxKind.MinusToken))
|
||||
step = -step;
|
||||
|
||||
var condition = node.Condition as CSS.BinaryExpressionSyntax;
|
||||
if (condition == null || !(condition.Left is CSS.IdentifierNameSyntax))
|
||||
return false;
|
||||
if (((CSS.IdentifierNameSyntax)condition.Left).Identifier.IsEquivalentTo(iteratorIdentifier.Identifier))
|
||||
return false;
|
||||
|
||||
ExpressionSyntax end;
|
||||
if (iterator.IsKind(SyntaxKind.SubtractAssignmentStatement)) {
|
||||
if (condition.IsKind(CS.SyntaxKind.GreaterThanOrEqualExpression))
|
||||
end = (ExpressionSyntax)condition.Right.Accept(nodesVisitor);
|
||||
else if (condition.IsKind(CS.SyntaxKind.GreaterThanExpression))
|
||||
end = SyntaxFactory.BinaryExpression(SyntaxKind.AddExpression, (ExpressionSyntax)condition.Right.Accept(nodesVisitor), SyntaxFactory.Token(SyntaxKind.PlusToken), Literal(1));
|
||||
else return false;
|
||||
} else {
|
||||
if (condition.IsKind(CS.SyntaxKind.LessThanOrEqualExpression))
|
||||
end = (ExpressionSyntax)condition.Right.Accept(nodesVisitor);
|
||||
else if (condition.IsKind(CS.SyntaxKind.LessThanExpression))
|
||||
end = SyntaxFactory.BinaryExpression(SyntaxKind.SubtractExpression, (ExpressionSyntax)condition.Right.Accept(nodesVisitor), SyntaxFactory.Token(SyntaxKind.MinusToken), Literal(1));
|
||||
else return false;
|
||||
}
|
||||
|
||||
VisualBasicSyntaxNode variable;
|
||||
ExpressionSyntax start;
|
||||
if (hasVariable) {
|
||||
var v = node.Declaration.Variables[0];
|
||||
start = (ExpressionSyntax)v.Initializer?.Value.Accept(nodesVisitor);
|
||||
if (start == null)
|
||||
return false;
|
||||
variable = SyntaxFactory.VariableDeclarator(
|
||||
SyntaxFactory.SingletonSeparatedList(SyntaxFactory.ModifiedIdentifier(ConvertIdentifier(v.Identifier))),
|
||||
node.Declaration.Type.IsVar ? null : SyntaxFactory.SimpleAsClause((TypeSyntax)node.Declaration.Type.Accept(nodesVisitor)),
|
||||
null
|
||||
);
|
||||
} else {
|
||||
var initializer = node.Initializers.FirstOrDefault() as CSS.AssignmentExpressionSyntax;
|
||||
if (initializer == null || !initializer.IsKind(CS.SyntaxKind.SimpleAssignmentExpression))
|
||||
return false;
|
||||
if (!(initializer.Left is CSS.IdentifierNameSyntax))
|
||||
return false;
|
||||
if (((CSS.IdentifierNameSyntax)initializer.Left).Identifier.IsEquivalentTo(iteratorIdentifier.Identifier))
|
||||
return false;
|
||||
variable = initializer.Left.Accept(nodesVisitor);
|
||||
start = (ExpressionSyntax)initializer.Right.Accept(nodesVisitor);
|
||||
}
|
||||
|
||||
block = SyntaxFactory.ForBlock(
|
||||
SyntaxFactory.ForStatement(variable, start, end, step == 1 ? null : SyntaxFactory.ForStepClause(Literal(step))),
|
||||
ConvertBlock(node.Statement),
|
||||
SyntaxFactory.NextStatement()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitForEachStatement(CSS.ForEachStatementSyntax node)
|
||||
{
|
||||
VisualBasicSyntaxNode variable;
|
||||
if (node.Type.IsVar) {
|
||||
variable = SyntaxFactory.IdentifierName(ConvertIdentifier(node.Identifier));
|
||||
} else {
|
||||
variable = SyntaxFactory.VariableDeclarator(
|
||||
SyntaxFactory.SingletonSeparatedList(SyntaxFactory.ModifiedIdentifier(ConvertIdentifier(node.Identifier))),
|
||||
SyntaxFactory.SimpleAsClause((TypeSyntax)node.Type.Accept(nodesVisitor)),
|
||||
null
|
||||
);
|
||||
}
|
||||
var expression = (ExpressionSyntax)node.Expression.Accept(nodesVisitor);
|
||||
var stmt = ConvertBlock(node.Statement);
|
||||
var block = SyntaxFactory.ForEachBlock(
|
||||
SyntaxFactory.ForEachStatement(variable, expression),
|
||||
stmt,
|
||||
SyntaxFactory.NextStatement()
|
||||
);
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(block);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitTryStatement(CSS.TryStatementSyntax node)
|
||||
{
|
||||
var block = SyntaxFactory.TryBlock(
|
||||
ConvertBlock(node.Block),
|
||||
SyntaxFactory.List(node.Catches.IndexedSelect(ConvertCatchClause)),
|
||||
node.Finally == null ? null : SyntaxFactory.FinallyBlock(ConvertBlock(node.Finally.Block))
|
||||
);
|
||||
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(block);
|
||||
}
|
||||
|
||||
CatchBlockSyntax ConvertCatchClause(int index, CSS.CatchClauseSyntax catchClause)
|
||||
{
|
||||
var statements = ConvertBlock(catchClause.Block);
|
||||
if (catchClause.Declaration == null)
|
||||
return SyntaxFactory.CatchBlock(SyntaxFactory.CatchStatement(), statements);
|
||||
var type = (TypeSyntax)catchClause.Declaration.Type.Accept(nodesVisitor);
|
||||
string simpleTypeName;
|
||||
if (type is QualifiedNameSyntax)
|
||||
simpleTypeName = ((QualifiedNameSyntax)type).Right.ToString();
|
||||
else
|
||||
simpleTypeName = type.ToString();
|
||||
return SyntaxFactory.CatchBlock(
|
||||
SyntaxFactory.CatchStatement(
|
||||
SyntaxFactory.IdentifierName(catchClause.Declaration.Identifier.IsKind(CS.SyntaxKind.None) ? SyntaxFactory.Identifier($"__unused{simpleTypeName}{index + 1}__") : ConvertIdentifier(catchClause.Declaration.Identifier)),
|
||||
SyntaxFactory.SimpleAsClause(type),
|
||||
catchClause.Filter == null ? null : SyntaxFactory.CatchFilterClause((ExpressionSyntax)catchClause.Filter.FilterExpression.Accept(nodesVisitor))
|
||||
), statements
|
||||
);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitUsingStatement(CSS.UsingStatementSyntax node)
|
||||
{
|
||||
UsingStatementSyntax stmt;
|
||||
if (node.Declaration == null) {
|
||||
stmt = SyntaxFactory.UsingStatement(
|
||||
(ExpressionSyntax)node.Expression?.Accept(nodesVisitor),
|
||||
SyntaxFactory.SeparatedList<VariableDeclaratorSyntax>()
|
||||
);
|
||||
} else {
|
||||
stmt = SyntaxFactory.UsingStatement(null, RemodelVariableDeclaration(node.Declaration, nodesVisitor));
|
||||
}
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(SyntaxFactory.UsingBlock(stmt, ConvertBlock(node.Statement)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitLockStatement(CSS.LockStatementSyntax node)
|
||||
{
|
||||
var stmt = SyntaxFactory.SyncLockStatement(
|
||||
(ExpressionSyntax)node.Expression?.Accept(nodesVisitor)
|
||||
);
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(SyntaxFactory.SyncLockBlock(stmt, ConvertBlock(node.Statement)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitLabeledStatement(CSS.LabeledStatementSyntax node)
|
||||
{
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(SyntaxFactory.LabelStatement(ConvertIdentifier(node.Identifier)))
|
||||
.AddRange(ConvertBlock(node.Statement));
|
||||
}
|
||||
|
||||
string MakeGotoSwitchLabel(VisualBasicSyntaxNode expression)
|
||||
{
|
||||
string expressionText;
|
||||
if (expression is ElseCaseClauseSyntax)
|
||||
expressionText = "Default";
|
||||
else
|
||||
expressionText = expression.ToString();
|
||||
return $"_Select{switchCount}_Case{expressionText}";
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitGotoStatement(CSS.GotoStatementSyntax node)
|
||||
{
|
||||
LabelSyntax label;
|
||||
if (node.IsKind(CS.SyntaxKind.GotoCaseStatement, CS.SyntaxKind.GotoDefaultStatement)) {
|
||||
if (blockInfo.Count == 0)
|
||||
throw new InvalidOperationException("goto case/goto default outside switch is illegal!");
|
||||
var labelExpression = node.Expression?.Accept(nodesVisitor) ?? SyntaxFactory.ElseCaseClause();
|
||||
blockInfo.Peek().GotoCaseExpressions.Add(labelExpression);
|
||||
label = SyntaxFactory.Label(SyntaxKind.IdentifierLabel, MakeGotoSwitchLabel(labelExpression));
|
||||
} else {
|
||||
label = SyntaxFactory.Label(SyntaxKind.IdentifierLabel, ConvertIdentifier(((CSS.IdentifierNameSyntax)node.Expression).Identifier));
|
||||
}
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(SyntaxFactory.GoToStatement(label));
|
||||
}
|
||||
|
||||
SyntaxList<StatementSyntax> ConvertBlock(CSS.StatementSyntax node)
|
||||
{
|
||||
if (node is CSS.BlockSyntax) {
|
||||
var b = (CSS.BlockSyntax)node;
|
||||
return SyntaxFactory.List(b.Statements.Where(s => !(s is CSS.EmptyStatementSyntax)).SelectMany(s => s.Accept(this)));
|
||||
}
|
||||
if (node is CSS.EmptyStatementSyntax) {
|
||||
return SyntaxFactory.List<StatementSyntax>();
|
||||
}
|
||||
return node.Accept(this);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitReturnStatement(CSS.ReturnStatementSyntax node)
|
||||
{
|
||||
StatementSyntax stmt;
|
||||
if (node.Expression == null)
|
||||
stmt = SyntaxFactory.ReturnStatement();
|
||||
else
|
||||
stmt = SyntaxFactory.ReturnStatement((ExpressionSyntax)node.Expression.Accept(nodesVisitor));
|
||||
return SyntaxFactory.SingletonList(stmt);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitYieldStatement(CSS.YieldStatementSyntax node)
|
||||
{
|
||||
IsInterator = true;
|
||||
StatementSyntax stmt;
|
||||
if (node.Expression == null)
|
||||
stmt = SyntaxFactory.ReturnStatement();
|
||||
else
|
||||
stmt = SyntaxFactory.YieldStatement((ExpressionSyntax)node.Expression.Accept(nodesVisitor));
|
||||
return SyntaxFactory.SingletonList(stmt);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitThrowStatement(CSS.ThrowStatementSyntax node)
|
||||
{
|
||||
StatementSyntax stmt;
|
||||
if (node.Expression == null)
|
||||
stmt = SyntaxFactory.ThrowStatement();
|
||||
else
|
||||
stmt = SyntaxFactory.ThrowStatement((ExpressionSyntax)node.Expression.Accept(nodesVisitor));
|
||||
return SyntaxFactory.SingletonList(stmt);
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitContinueStatement(CSS.ContinueStatementSyntax node)
|
||||
{
|
||||
var statementKind = SyntaxKind.None;
|
||||
var keywordKind = SyntaxKind.None;
|
||||
foreach (var stmt in node.GetAncestors<CSS.StatementSyntax>()) {
|
||||
if (stmt is CSS.DoStatementSyntax) {
|
||||
statementKind = SyntaxKind.ContinueDoStatement;
|
||||
keywordKind = SyntaxKind.DoKeyword;
|
||||
break;
|
||||
}
|
||||
if (stmt is CSS.WhileStatementSyntax) {
|
||||
statementKind = SyntaxKind.ContinueWhileStatement;
|
||||
keywordKind = SyntaxKind.WhileKeyword;
|
||||
break;
|
||||
}
|
||||
if (stmt is CSS.ForStatementSyntax || stmt is CSS.ForEachStatementSyntax) {
|
||||
statementKind = SyntaxKind.ContinueForStatement;
|
||||
keywordKind = SyntaxKind.ForKeyword;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(SyntaxFactory.ContinueStatement(statementKind, SyntaxFactory.Token(keywordKind)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitBreakStatement(CSS.BreakStatementSyntax node)
|
||||
{
|
||||
var statementKind = SyntaxKind.None;
|
||||
var keywordKind = SyntaxKind.None;
|
||||
foreach (var stmt in node.GetAncestors<CSS.StatementSyntax>()) {
|
||||
if (stmt is CSS.DoStatementSyntax) {
|
||||
statementKind = SyntaxKind.ExitDoStatement;
|
||||
keywordKind = SyntaxKind.DoKeyword;
|
||||
break;
|
||||
}
|
||||
if (stmt is CSS.WhileStatementSyntax) {
|
||||
statementKind = SyntaxKind.ExitWhileStatement;
|
||||
keywordKind = SyntaxKind.WhileKeyword;
|
||||
break;
|
||||
}
|
||||
if (stmt is CSS.ForStatementSyntax || stmt is CSS.ForEachStatementSyntax) {
|
||||
statementKind = SyntaxKind.ExitForStatement;
|
||||
keywordKind = SyntaxKind.ForKeyword;
|
||||
break;
|
||||
}
|
||||
if (stmt is CSS.SwitchStatementSyntax) {
|
||||
statementKind = SyntaxKind.ExitSelectStatement;
|
||||
keywordKind = SyntaxKind.SelectKeyword;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SyntaxFactory.SingletonList<StatementSyntax>(SyntaxFactory.ExitStatement(statementKind, SyntaxFactory.Token(keywordKind)));
|
||||
}
|
||||
|
||||
public override SyntaxList<StatementSyntax> VisitCheckedStatement(CSS.CheckedStatementSyntax node)
|
||||
{
|
||||
return WrapInComment(ConvertBlock(node.Block), "Visual Basic does not support checked statements!");
|
||||
}
|
||||
|
||||
SyntaxList<StatementSyntax> WrapInComment(SyntaxList<StatementSyntax> nodes, string comment)
|
||||
{
|
||||
if (nodes.Count > 0) {
|
||||
nodes = nodes.Replace(nodes[0], nodes[0].WithPrependedLeadingTrivia(SyntaxFactory.CommentTrivia("BEGIN TODO : " + comment)));
|
||||
nodes = nodes.Replace(nodes.Last(), nodes.Last().WithAppendedTrailingTrivia(SyntaxFactory.CommentTrivia("END TODO : " + comment)));
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,599 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.CSharp.Converter
|
||||
{
|
||||
public class ExpressionTests : ConverterTestBase
|
||||
{
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void MultilineString()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim x = ""Hello,
|
||||
World!""
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var x = @""Hello,
|
||||
World!"";
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DateKeyword()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private DefaultDate as Date = Nothing
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private System.DateTime DefaultDate = default(Date);
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FullyTypeInferredEnumerableCreation()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim strings = { ""1"", ""2"" }
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var strings = new[] { ""1"", ""2"" };
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyArgumentLists()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim str = (New ThreadStaticAttribute).ToString
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var str = (new ThreadStaticAttribute()).ToString();
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringConcatenationAssignment()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim str = ""Hello, ""
|
||||
str &= ""World""
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var str = ""Hello, "";
|
||||
str += ""World"";
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetTypeExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim typ = GetType(String)
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var typ = typeof(string);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UsesSquareBracketsForIndexerButParenthesesForMethodInvocation()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Function TestMethod() As String()
|
||||
Dim s = ""1,2""
|
||||
Return s.Split(s(1))
|
||||
End Function
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private string[] TestMethod()
|
||||
{
|
||||
var s = ""1,2"";
|
||||
return s.Split(s[1]);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConditionalExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim result As Boolean = If((str = """"), True, False)
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod(string str)
|
||||
{
|
||||
bool result = (str == """") ? true : false;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullCoalescingExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Console.WriteLine(If(str, ""<null>""))
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod(string str)
|
||||
{
|
||||
Console.WriteLine(str ?? ""<null>"");
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MemberAccessAndInvocationExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim length As Integer
|
||||
length = str.Length
|
||||
Console.WriteLine(""Test"" & length)
|
||||
Console.ReadKey()
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod(string str)
|
||||
{
|
||||
int length;
|
||||
length = str.Length;
|
||||
Console.WriteLine(""Test"" + length);
|
||||
Console.ReadKey();
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ElvisOperatorExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim length As Integer = If(str?.Length, -1)
|
||||
Console.WriteLine(length)
|
||||
Console.ReadKey()
|
||||
Dim redirectUri As String = context.OwinContext.Authentication?.AuthenticationResponseChallenge?.Properties?.RedirectUri
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod(string str)
|
||||
{
|
||||
int length = str?.Length ?? -1;
|
||||
Console.WriteLine(length);
|
||||
Console.ReadKey();
|
||||
string redirectUri = context.OwinContext.Authentication?.AuthenticationResponseChallenge?.Properties?.RedirectUri;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void ObjectInitializerExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class StudentName
|
||||
Public LastName, FirstName As String
|
||||
End Class
|
||||
|
||||
Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim student2 As StudentName = New StudentName With {.FirstName = ""Craig"", .LastName = ""Playstead""}
|
||||
End Sub
|
||||
End Class", @"
|
||||
class StudentName
|
||||
{
|
||||
public string LastName, FirstName;
|
||||
}
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod(string str)
|
||||
{
|
||||
StudentName student2 = new StudentName
|
||||
{
|
||||
FirstName = ""Craig"",
|
||||
LastName = ""Playstead"",
|
||||
};
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void ObjectInitializerExpression2()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim student2 = New With {Key .FirstName = ""Craig"", Key .LastName = ""Playstead""}
|
||||
End Sub
|
||||
End Class", @"
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod(string str)
|
||||
{
|
||||
var student2 = new {
|
||||
FirstName = ""Craig"",
|
||||
LastName = ""Playstead"",
|
||||
};
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThisMemberAccessExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private member As Integer
|
||||
|
||||
Private Sub TestMethod()
|
||||
Me.member = 0
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private int member;
|
||||
|
||||
private void TestMethod()
|
||||
{
|
||||
this.member = 0;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BaseMemberAccessExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class BaseTestClass
|
||||
Public member As Integer
|
||||
End Class
|
||||
|
||||
Class TestClass
|
||||
Inherits BaseTestClass
|
||||
|
||||
Private Sub TestMethod()
|
||||
MyBase.member = 0
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class BaseTestClass
|
||||
{
|
||||
public int member;
|
||||
}
|
||||
|
||||
class TestClass : BaseTestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
base.member = 0;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DelegateExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim test = Function(ByVal a As Integer) a * 2
|
||||
test(3)
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var test = int a => a * 2;
|
||||
test(3);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LambdaBodyExpression()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim test = Function(a) a * 2
|
||||
Dim test2 = Function(a, b)
|
||||
If b > 0 Then Return a / b
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Dim test3 = Function(a, b) a Mod b
|
||||
test(3)
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var test = a => a * 2;
|
||||
var test2 = (a, b) =>
|
||||
{
|
||||
if (b > 0)
|
||||
return a / b;
|
||||
return 0;
|
||||
};
|
||||
var test3 = (a, b) => a % b;
|
||||
test(3);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Await()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Function SomeAsyncMethod() As Task(Of Integer)
|
||||
Return Task.FromResult(0)
|
||||
End Function
|
||||
|
||||
Private Async Sub TestMethod()
|
||||
Dim result As Integer = Await SomeAsyncMethod()
|
||||
Console.WriteLine(result)
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private Task<int> SomeAsyncMethod()
|
||||
{
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
private async void TestMethod()
|
||||
{
|
||||
int result = await SomeAsyncMethod();
|
||||
Console.WriteLine(result);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void Linq1()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Private Shared Sub SimpleQuery()
|
||||
Dim numbers As Integer() = {7, 9, 5, 3, 6}
|
||||
Dim res = From n In numbers Where n > 5 Select n
|
||||
|
||||
For Each n In res
|
||||
Console.WriteLine(n)
|
||||
Next
|
||||
End Sub",
|
||||
@"static void SimpleQuery()
|
||||
{
|
||||
int[] numbers = { 7, 9, 5, 3, 6 };
|
||||
|
||||
var res = from n in numbers
|
||||
where n > 5
|
||||
select n;
|
||||
|
||||
foreach (var n in res)
|
||||
Console.WriteLine(n);
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void Linq2()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Public Shared Sub Linq40()
|
||||
Dim numbers As Integer() = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}
|
||||
Dim numberGroups = From n In numbers Group n By __groupByKey1__ = n Mod 5 Into g Select New With {Key .Remainder = g.Key, Key .Numbers = g}
|
||||
|
||||
For Each g In numberGroups
|
||||
Console.WriteLine($""Numbers with a remainder of {g.Remainder} when divided by 5:"")
|
||||
|
||||
For Each n In g.Numbers
|
||||
Console.WriteLine(n)
|
||||
Next
|
||||
Next
|
||||
End Sub",
|
||||
@"public static void Linq40()
|
||||
{
|
||||
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
|
||||
|
||||
var numberGroups =
|
||||
from n in numbers
|
||||
group n by n % 5 into g
|
||||
select new { Remainder = g.Key, Numbers = g };
|
||||
|
||||
foreach (var g in numberGroups)
|
||||
{
|
||||
Console.WriteLine($""Numbers with a remainder of {g.Remainder} when divided by 5:"");
|
||||
foreach (var n in g.Numbers)
|
||||
{
|
||||
Console.WriteLine(n);
|
||||
}
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void Linq3()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class Product
|
||||
Public Category As String
|
||||
Public ProductName As String
|
||||
End Class
|
||||
|
||||
Class Test
|
||||
Public Sub Linq102()
|
||||
Dim categories As String() = New String() {""Beverages"", ""Condiments"", ""Vegetables"", ""Dairy Products"", ""Seafood""}
|
||||
Dim products As Product() = GetProductList()
|
||||
Dim q = From c In categories Join p In products On c Equals p.Category Select New With {Key .Category = c, p.ProductName}
|
||||
|
||||
For Each v In q
|
||||
Console.WriteLine($""{v.ProductName}: {v.Category}"")
|
||||
Next
|
||||
End Sub
|
||||
End Class",
|
||||
@"class Product {
|
||||
public string Category;
|
||||
public string ProductName;
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void Linq102()
|
||||
{
|
||||
string[] categories = new string[]{
|
||||
""Beverages"",
|
||||
""Condiments"",
|
||||
""Vegetables"",
|
||||
""Dairy Products"",
|
||||
""Seafood"" };
|
||||
|
||||
Product[] products = GetProductList();
|
||||
|
||||
var q =
|
||||
from c in categories
|
||||
join p in products on c equals p.Category
|
||||
select new { Category = c, p.ProductName };
|
||||
|
||||
foreach (var v in q)
|
||||
{
|
||||
Console.WriteLine($""{v.ProductName}: {v.Category}"");
|
||||
}
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void Linq4()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Public Sub Linq103()
|
||||
Dim categories As String() = New String() {""Beverages"", ""Condiments"", ""Vegetables"", ""Dairy Products"", ""Seafood""}
|
||||
Dim products = GetProductList()
|
||||
Dim q = From c In categories Group Join p In products On c Equals p.Category Into ps = Group Select New With {Key .Category = c, Key .Products = ps}
|
||||
|
||||
For Each v In q
|
||||
Console.WriteLine(v.Category & "":"")
|
||||
|
||||
For Each p In v.Products
|
||||
Console.WriteLine("" "" & p.ProductName)
|
||||
Next
|
||||
Next
|
||||
End Sub", @"public void Linq103()
|
||||
{
|
||||
string[] categories = new string[]{
|
||||
""Beverages"",
|
||||
""Condiments"",
|
||||
""Vegetables"",
|
||||
""Dairy Products"",
|
||||
""Seafood"" };
|
||||
|
||||
var products = GetProductList();
|
||||
|
||||
var q =
|
||||
from c in categories
|
||||
join p in products on c equals p.Category into ps
|
||||
select new { Category = c, Products = ps };
|
||||
|
||||
foreach (var v in q)
|
||||
{
|
||||
Console.WriteLine(v.Category + "":"");
|
||||
foreach (var p in v.Products)
|
||||
{
|
||||
Console.WriteLine("" "" + p.ProductName);
|
||||
}
|
||||
}
|
||||
}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,577 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.CSharp.Converter
|
||||
{
|
||||
public class MemberTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestField()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Const answer As Integer = 42
|
||||
Private value As Integer = 10
|
||||
ReadOnly v As Integer = 15
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
const int answer = 42;
|
||||
private int value = 10;
|
||||
private readonly int v = 15;
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMethod()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Public Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
argument = Nothing
|
||||
argument2 = Nothing
|
||||
argument3 = Nothing
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
|
||||
where T : class, new()
|
||||
where T2 : struct
|
||||
{
|
||||
argument = null;
|
||||
argument2 = default(T2);
|
||||
argument3 = default(T3);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMethodWithReturnType()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Public Function TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3) As Integer
|
||||
Return 0
|
||||
End Function
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public int TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
|
||||
where T : class, new()
|
||||
where T2 : struct
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestStaticMethod()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Public Shared Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
argument = Nothing
|
||||
argument2 = Nothing
|
||||
argument3 = Nothing
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public static void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
|
||||
where T : class, new()
|
||||
where T2 : struct
|
||||
{
|
||||
argument = null;
|
||||
argument2 = default(T2);
|
||||
argument3 = default(T3);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAbstractMethod()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Public MustOverride Sub TestMethod()
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public abstract void TestMethod();
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSealedMethod()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Public NotOverridable Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
argument = Nothing
|
||||
argument2 = Nothing
|
||||
argument3 = Nothing
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public sealed void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
|
||||
where T : class, new()
|
||||
where T2 : struct
|
||||
{
|
||||
argument = null;
|
||||
argument2 = default(T2);
|
||||
argument3 = default(T3);
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void TestExtensionMethod()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Imports System.Runtime.CompilerServices
|
||||
|
||||
Module TestClass
|
||||
<Extension()>
|
||||
Sub TestMethod(ByVal str As String)
|
||||
End Sub
|
||||
End Module", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
static class TestClass
|
||||
{
|
||||
public static void TestMethod(this String str)
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void TestExtensionMethodWithExistingImport()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Imports System.Runtime.CompilerServices
|
||||
|
||||
Module TestClass
|
||||
<Extension()>
|
||||
Sub TestMethod(ByVal str As String)
|
||||
End Sub
|
||||
End Module", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
static class TestClass
|
||||
{
|
||||
public static void TestMethod(this String str)
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestProperty()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Public Property Test As Integer
|
||||
|
||||
Public Property Test2 As Integer
|
||||
Get
|
||||
Return 0
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_test3 As Integer
|
||||
|
||||
Public Property Test3 As Integer
|
||||
Get
|
||||
Return Me.m_test3
|
||||
End Get
|
||||
Set(ByVal value As Integer)
|
||||
Me.m_test3 = value
|
||||
End Set
|
||||
End Property
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public int Test { get; set; }
|
||||
|
||||
public int Test2
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int m_test3;
|
||||
|
||||
public int Test3
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_test3;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.m_test3 = value;
|
||||
}
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestConstructor()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass(Of T As {Class, New}, T2 As Structure, T3)
|
||||
Public Sub New(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass<T, T2, T3>
|
||||
where T : class, new()
|
||||
where T2 : struct
|
||||
{
|
||||
public TestClass(out T argument, ref T2 argument2, T3 argument3)
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDestructor()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Protected Overrides Sub Finalize()
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
~TestClass()
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEvent()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Public Event MyEvent As EventHandler
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public event EventHandler MyEvent;
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void TestCustomEvent()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Private backingField As EventHandler
|
||||
|
||||
Public Event MyEvent As EventHandler
|
||||
AddHandler(ByVal value As EventHandler)
|
||||
AddHandler Me.backingField, value
|
||||
End AddHandler
|
||||
RemoveHandler(ByVal value As EventHandler)
|
||||
RemoveHandler Me.backingField, value
|
||||
End RemoveHandler
|
||||
End Event
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
EventHandler backingField;
|
||||
|
||||
public event EventHandler MyEvent {
|
||||
add {
|
||||
this.backingField += value;
|
||||
}
|
||||
remove {
|
||||
this.backingField -= value;
|
||||
}
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SynthesizedBackingFieldAccess()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Shared Property First As Integer
|
||||
|
||||
Private Second As Integer = _First
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private static int First { get; set; }
|
||||
|
||||
private int Second = First;
|
||||
}");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void PropertyInitializers()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private ReadOnly Property First As New List(Of String)
|
||||
Private Property Second As Integer = 0
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private List<string> First { get; } = new List<string>();
|
||||
private int Second { get; set; } = 0;
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PartialFriendClassWithOverloads()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"
|
||||
Partial Friend MustInherit Class TestClass1
|
||||
Public Shared Sub CreateStatic()
|
||||
End Sub
|
||||
|
||||
Public Sub CreateInstance()
|
||||
End Sub
|
||||
|
||||
Public MustOverride Sub CreateAbstractInstance()
|
||||
|
||||
Public Overridable Sub CreateVirtualInstance()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Friend Class TestClass2
|
||||
Inherits TestClass1
|
||||
Public Overloads Shared Sub CreateStatic()
|
||||
End Sub
|
||||
|
||||
Public Overloads Sub CreateInstance()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub CreateAbstractInstance()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub CreateVirtualInstance()
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
internal abstract partial class TestClass1
|
||||
{
|
||||
public static void CreateStatic()
|
||||
{
|
||||
}
|
||||
|
||||
public void CreateInstance()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void CreateAbstractInstance();
|
||||
|
||||
public virtual void CreateVirtualInstance()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
internal class TestClass2 : TestClass1
|
||||
{
|
||||
public new static void CreateStatic()
|
||||
{
|
||||
}
|
||||
|
||||
public new void CreateInstance()
|
||||
{
|
||||
}
|
||||
|
||||
public override void CreateAbstractInstance()
|
||||
{
|
||||
}
|
||||
|
||||
public override void CreateVirtualInstance()
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassWithGloballyQualifiedAttribute()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"<Global.System.Diagnostics.DebuggerDisplay(""Hello World"")>
|
||||
Class TestClass
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
[global::System.Diagnostics.DebuggerDisplay(""Hello World"")]
|
||||
class TestClass
|
||||
{
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FieldWithAttribute()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
<ThreadStatic>
|
||||
Private Shared First As Integer
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
[ThreadStatic]
|
||||
private static int First;
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParamArray()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub SomeBools(ParamArray anyName As Boolean())
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void SomeBools(params bool[] anyName)
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParamNamedBool()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub SomeBools(ParamArray bool As Boolean())
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void SomeBools(params bool[] @bool)
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void TestIndexer()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Default Public Property Item(ByVal index As Integer) As Integer
|
||||
|
||||
Default Public Property Item(ByVal index As String) As Integer
|
||||
Get
|
||||
Return 0
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_test3 As Integer
|
||||
|
||||
Default Public Property Item(ByVal index As Double) As Integer
|
||||
Get
|
||||
Return Me.m_test3
|
||||
End Get
|
||||
Set(ByVal value As Integer)
|
||||
Me.m_test3 = value
|
||||
End Set
|
||||
End Property
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public int this[int index] { get; set; }
|
||||
public int this[string index] {
|
||||
get { return 0; }
|
||||
}
|
||||
int m_test3;
|
||||
public int this[double index] {
|
||||
get { return this.m_test3; }
|
||||
set { this.m_test3 = value; }
|
||||
}
|
||||
}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.CSharp.Converter
|
||||
{
|
||||
public class NamespaceLevelTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestNamespace()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Namespace Test
|
||||
End Namespace", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTopLevelAttribute()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"<Assembly: CLSCompliant(True)>",
|
||||
@"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
[assembly: CLSCompliant(true)]");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestImports()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Imports SomeNamespace
|
||||
Imports VB = Microsoft.VisualBasic",
|
||||
@"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
using SomeNamespace;
|
||||
using VB = Microsoft.VisualBasic;");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestClass()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Namespace Test.[class]
|
||||
Class TestClass(Of T)
|
||||
End Class
|
||||
End Namespace", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Test.@class
|
||||
{
|
||||
class TestClass<T>
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestInternalStaticClass()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Namespace Test.[class]
|
||||
Friend Module TestClass
|
||||
Sub Test()
|
||||
End Sub
|
||||
|
||||
Private Sub Test2()
|
||||
End Sub
|
||||
End Module
|
||||
End Namespace", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Test.@class
|
||||
{
|
||||
internal static class TestClass
|
||||
{
|
||||
public static void Test()
|
||||
{
|
||||
}
|
||||
|
||||
private static void Test2()
|
||||
{
|
||||
}
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAbstractClass()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Namespace Test.[class]
|
||||
MustInherit Class TestClass
|
||||
End Class
|
||||
End Namespace", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Test.@class
|
||||
{
|
||||
abstract class TestClass
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSealedClass()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Namespace Test.[class]
|
||||
NotInheritable Class TestClass
|
||||
End Class
|
||||
End Namespace", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Test.@class
|
||||
{
|
||||
sealed class TestClass
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestInterface()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Interface ITest
|
||||
Inherits System.IDisposable
|
||||
|
||||
Sub Test()
|
||||
End Interface", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
interface ITest : System.IDisposable
|
||||
{
|
||||
void Test();
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEnum()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Friend Enum ExceptionResource
|
||||
Argument_ImplementIComparable
|
||||
ArgumentOutOfRange_NeedNonNegNum
|
||||
ArgumentOutOfRange_NeedNonNegNumRequired
|
||||
Arg_ArrayPlusOffTooSmall
|
||||
End Enum", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
internal enum ExceptionResource
|
||||
{
|
||||
Argument_ImplementIComparable,
|
||||
ArgumentOutOfRange_NeedNonNegNum,
|
||||
ArgumentOutOfRange_NeedNonNegNumRequired,
|
||||
Arg_ArrayPlusOffTooSmall
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestClassInheritanceList()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"MustInherit Class ClassA
|
||||
Implements System.IDisposable
|
||||
|
||||
Protected MustOverride Sub Test()
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
abstract class ClassA : System.IDisposable
|
||||
{
|
||||
protected abstract void Test();
|
||||
}");
|
||||
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"MustInherit Class ClassA
|
||||
Inherits System.EventArgs
|
||||
Implements System.IDisposable
|
||||
|
||||
Protected MustOverride Sub Test()
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
abstract class ClassA : System.EventArgs, System.IDisposable
|
||||
{
|
||||
protected abstract void Test();
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestStruct()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Structure MyType
|
||||
Implements System.IComparable(Of MyType)
|
||||
|
||||
Private Sub Test()
|
||||
End Sub
|
||||
End Structure", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
struct MyType : System.IComparable<MyType>
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDelegate()
|
||||
{
|
||||
const string usings = @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
";
|
||||
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Public Delegate Sub Test()",
|
||||
usings + @"public delegate void Test();");
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Public Delegate Function Test() As Integer",
|
||||
usings + @"public delegate int Test();");
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Public Delegate Sub Test(ByVal x As Integer)",
|
||||
usings + @"public delegate void Test(int x);");
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Public Delegate Sub Test(ByRef x As Integer)",
|
||||
usings + @"public delegate void Test(ref int x);");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassImplementsInterface()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class test
|
||||
Implements IComparable
|
||||
End Class",
|
||||
@"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class test : IComparable
|
||||
{
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassImplementsInterface2()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class test
|
||||
Implements System.IComparable
|
||||
End Class",
|
||||
@"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class test : System.IComparable
|
||||
{
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassInheritsClass()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Imports System.IO
|
||||
|
||||
Class test
|
||||
Inherits InvalidDataException
|
||||
End Class",
|
||||
@"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.IO;
|
||||
|
||||
class test : InvalidDataException
|
||||
{
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassInheritsClass2()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class test
|
||||
Inherits System.IO.InvalidDataException
|
||||
End Class",
|
||||
@"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class test : System.IO.InvalidDataException
|
||||
{
|
||||
}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.CSharp.Converter
|
||||
{
|
||||
public class SpecialConversionTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void RaiseEvent()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class TestClass
|
||||
Private Event MyEvent As EventHandler
|
||||
|
||||
Private Sub TestMethod()
|
||||
RaiseEvent MyEvent(Me, EventArgs.Empty)
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private event EventHandler MyEvent;
|
||||
|
||||
private void TestMethod()
|
||||
{
|
||||
MyEvent?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}");
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,204 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.CSharp.Converter
|
||||
{
|
||||
public class TypeCastTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void CastObjectToInteger()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = 5
|
||||
Dim i As Integer = CInt(o)
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = 5;
|
||||
int i = System.Convert.ToInt32(o);
|
||||
}
|
||||
}
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastObjectToString()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = ""Test""
|
||||
Dim s As String = CStr(o)
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = ""Test"";
|
||||
string s = System.Convert.ToString(o);
|
||||
}
|
||||
}
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastObjectToGenericList()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = New System.Collections.Generic.List(Of Integer)()
|
||||
Dim l As System.Collections.Generic.List(Of Integer) = CType(o, System.Collections.Generic.List(Of Integer))
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = new System.Collections.Generic.List<int>();
|
||||
System.Collections.Generic.List<int> l = (System.Collections.Generic.List<int>)o;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryCastObjectToInteger()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = 5
|
||||
Dim i As System.Nullable(Of Integer) = TryCast(o, Integer)
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = 5;
|
||||
System.Nullable<int> i = o as int;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryCastObjectToGenericList()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = New System.Collections.Generic.List(Of Integer)()
|
||||
Dim l As System.Collections.Generic.List(Of Integer) = TryCast(o, System.Collections.Generic.List(Of Integer))
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = new System.Collections.Generic.List<int>();
|
||||
System.Collections.Generic.List<int> l = o as System.Collections.Generic.List<int>;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastConstantNumberToLong()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = 5L
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = 5L;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastConstantNumberToFloat()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = 5F
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = 5F;
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastConstantNumberToDecimal()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(
|
||||
@"Class Class1
|
||||
Private Sub Test()
|
||||
Dim o As Object = 5.0D
|
||||
End Sub
|
||||
End Class
|
||||
", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class Class1
|
||||
{
|
||||
private void Test()
|
||||
{
|
||||
object o = 5.0M;
|
||||
}
|
||||
}
|
||||
");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Formatting;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.CodeAnalysis.VisualBasic;
|
||||
using RefactoringEssentials.VB.Converter;
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text;
|
||||
using RefactoringEssentials.Tests.Common;
|
||||
using Microsoft.CodeAnalysis.Formatting;
|
||||
using RefactoringEssentials.CSharp.Converter;
|
||||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests
|
||||
{
|
||||
public class ConverterTestBase
|
||||
{
|
||||
void CSharpWorkspaceSetup(out TestWorkspace workspace, out Document doc, CSharpParseOptions parseOptions = null)
|
||||
{
|
||||
workspace = new TestWorkspace();
|
||||
var projectId = ProjectId.CreateNewId();
|
||||
var documentId = DocumentId.CreateNewId(projectId);
|
||||
if (parseOptions == null) {
|
||||
parseOptions = new CSharpParseOptions(
|
||||
Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6,
|
||||
DocumentationMode.Diagnose | DocumentationMode.Parse,
|
||||
SourceCodeKind.Regular,
|
||||
ImmutableArray.Create("DEBUG", "TEST")
|
||||
);
|
||||
}
|
||||
workspace.Options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false);
|
||||
workspace.Open(ProjectInfo.Create(
|
||||
projectId,
|
||||
VersionStamp.Create(),
|
||||
"TestProject",
|
||||
"TestProject",
|
||||
LanguageNames.CSharp,
|
||||
null,
|
||||
null,
|
||||
new CSharpCompilationOptions(
|
||||
OutputKind.DynamicallyLinkedLibrary,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
"Script",
|
||||
new[] { "System", "System.Collections.Generic", "System.Linq" },
|
||||
OptimizationLevel.Debug,
|
||||
false,
|
||||
true
|
||||
),
|
||||
parseOptions,
|
||||
new[] {
|
||||
DocumentInfo.Create(
|
||||
documentId,
|
||||
"a.cs",
|
||||
null,
|
||||
SourceCodeKind.Regular
|
||||
)
|
||||
},
|
||||
null,
|
||||
DiagnosticTestBase.DefaultMetadataReferences
|
||||
)
|
||||
);
|
||||
doc = workspace.CurrentSolution.GetProject(projectId).GetDocument(documentId);
|
||||
}
|
||||
|
||||
void CSharpWorkspaceSetup(string text, out TestWorkspace workspace, out Document doc, CSharpParseOptions parseOptions = null)
|
||||
{
|
||||
workspace = new TestWorkspace();
|
||||
var projectId = ProjectId.CreateNewId();
|
||||
var documentId = DocumentId.CreateNewId(projectId);
|
||||
if (parseOptions == null) {
|
||||
parseOptions = new CSharpParseOptions(
|
||||
Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6,
|
||||
DocumentationMode.Diagnose | DocumentationMode.Parse,
|
||||
SourceCodeKind.Regular,
|
||||
ImmutableArray.Create("DEBUG", "TEST")
|
||||
);
|
||||
}
|
||||
workspace.Options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false);
|
||||
workspace.Open(ProjectInfo.Create(
|
||||
projectId,
|
||||
VersionStamp.Create(),
|
||||
"TestProject",
|
||||
"TestProject",
|
||||
LanguageNames.CSharp,
|
||||
null,
|
||||
null,
|
||||
new CSharpCompilationOptions(
|
||||
OutputKind.DynamicallyLinkedLibrary,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
"Script",
|
||||
new[] { "System", "System.Collections.Generic", "System.Linq" },
|
||||
OptimizationLevel.Debug,
|
||||
false,
|
||||
true
|
||||
),
|
||||
parseOptions,
|
||||
new[] {
|
||||
DocumentInfo.Create(
|
||||
documentId,
|
||||
"a.cs",
|
||||
null,
|
||||
SourceCodeKind.Regular,
|
||||
TextLoader.From(TextAndVersion.Create(SourceText.From(text), VersionStamp.Create()))
|
||||
)
|
||||
},
|
||||
null,
|
||||
DiagnosticTestBase.DefaultMetadataReferences
|
||||
)
|
||||
);
|
||||
doc = workspace.CurrentSolution.GetProject(projectId).GetDocument(documentId);
|
||||
}
|
||||
|
||||
void VBWorkspaceSetup(out TestWorkspace workspace, out Document doc, VisualBasicParseOptions parseOptions = null)
|
||||
{
|
||||
workspace = new TestWorkspace();
|
||||
var projectId = ProjectId.CreateNewId();
|
||||
var documentId = DocumentId.CreateNewId(projectId);
|
||||
if (parseOptions == null) {
|
||||
parseOptions = new VisualBasicParseOptions(
|
||||
Microsoft.CodeAnalysis.VisualBasic.LanguageVersion.VisualBasic14,
|
||||
DocumentationMode.Diagnose | DocumentationMode.Parse,
|
||||
SourceCodeKind.Regular
|
||||
);
|
||||
}
|
||||
workspace.Options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false);
|
||||
var compilationOptions = new VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
|
||||
.WithRootNamespace("TestProject")
|
||||
.WithGlobalImports(GlobalImport.Parse("System", "System.Collections.Generic", "System.Linq", "Microsoft.VisualBasic"));
|
||||
workspace.Open(ProjectInfo.Create(
|
||||
projectId,
|
||||
VersionStamp.Create(),
|
||||
"TestProject",
|
||||
"TestProject",
|
||||
LanguageNames.VisualBasic,
|
||||
null,
|
||||
null,
|
||||
compilationOptions,
|
||||
parseOptions,
|
||||
new[] {
|
||||
DocumentInfo.Create(
|
||||
documentId,
|
||||
"a.vb",
|
||||
null,
|
||||
SourceCodeKind.Regular
|
||||
)
|
||||
},
|
||||
null,
|
||||
DiagnosticTestBase.DefaultMetadataReferences
|
||||
)
|
||||
);
|
||||
doc = workspace.CurrentSolution.GetProject(projectId).GetDocument(documentId);
|
||||
}
|
||||
|
||||
void VBWorkspaceSetup(string text, out TestWorkspace workspace, out Document doc, VisualBasicParseOptions parseOptions = null)
|
||||
{
|
||||
workspace = new TestWorkspace();
|
||||
var projectId = ProjectId.CreateNewId();
|
||||
var documentId = DocumentId.CreateNewId(projectId);
|
||||
if (parseOptions == null) {
|
||||
parseOptions = new VisualBasicParseOptions(
|
||||
Microsoft.CodeAnalysis.VisualBasic.LanguageVersion.VisualBasic14,
|
||||
DocumentationMode.Diagnose | DocumentationMode.Parse,
|
||||
SourceCodeKind.Regular
|
||||
);
|
||||
}
|
||||
workspace.Options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false);
|
||||
var compilationOptions = new VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
|
||||
.WithRootNamespace("TestProject")
|
||||
.WithGlobalImports(GlobalImport.Parse("System", "System.Collections.Generic", "System.Linq", "Microsoft.VisualBasic"));
|
||||
workspace.Open(ProjectInfo.Create(
|
||||
projectId,
|
||||
VersionStamp.Create(),
|
||||
"TestProject",
|
||||
"TestProject",
|
||||
LanguageNames.VisualBasic,
|
||||
null,
|
||||
null,
|
||||
compilationOptions,
|
||||
parseOptions,
|
||||
new[] {
|
||||
DocumentInfo.Create(
|
||||
documentId,
|
||||
"a.vb",
|
||||
null,
|
||||
SourceCodeKind.Regular,
|
||||
TextLoader.From(TextAndVersion.Create(SourceText.From(text), VersionStamp.Create()))
|
||||
)
|
||||
},
|
||||
null,
|
||||
DiagnosticTestBase.DefaultMetadataReferences
|
||||
)
|
||||
);
|
||||
doc = workspace.CurrentSolution.GetProject(projectId).GetDocument(documentId);
|
||||
}
|
||||
|
||||
public void TestConversionCSharpToVisualBasic(string csharpCode, string expectedVisualBasicCode, CSharpParseOptions csharpOptions = null, VisualBasicParseOptions vbOptions = null)
|
||||
{
|
||||
TestWorkspace csharpWorkspace, vbWorkspace;
|
||||
Document inputDocument, outputDocument;
|
||||
CSharpWorkspaceSetup(csharpCode, out csharpWorkspace, out inputDocument, csharpOptions);
|
||||
VBWorkspaceSetup(out vbWorkspace, out outputDocument, vbOptions);
|
||||
var outputNode = Convert((CSharpSyntaxNode)inputDocument.GetSyntaxRootAsync().GetAwaiter().GetResult(), inputDocument.GetSemanticModelAsync().GetAwaiter().GetResult(), outputDocument);
|
||||
|
||||
var txt = outputDocument.WithSyntaxRoot(Formatter.Format(outputNode, vbWorkspace)).GetTextAsync().GetAwaiter().GetResult().ToString();
|
||||
txt = Utils.HomogenizeEol(txt).TrimEnd();
|
||||
expectedVisualBasicCode = Utils.HomogenizeEol(expectedVisualBasicCode).TrimEnd();
|
||||
if (expectedVisualBasicCode != txt) {
|
||||
Console.WriteLine("expected:");
|
||||
Console.WriteLine(expectedVisualBasicCode);
|
||||
Console.WriteLine("got:");
|
||||
Console.WriteLine(txt);
|
||||
Console.WriteLine("diff:");
|
||||
int l = Math.Max(expectedVisualBasicCode.Length, txt.Length);
|
||||
StringBuilder diff = new StringBuilder(l);
|
||||
for (int i = 0; i < l; i++) {
|
||||
if (i >= expectedVisualBasicCode.Length || i >= txt.Length || expectedVisualBasicCode[i] != txt[i])
|
||||
diff.Append('x');
|
||||
else
|
||||
diff.Append(expectedVisualBasicCode[i]);
|
||||
}
|
||||
Console.WriteLine(diff.ToString());
|
||||
Assert.True(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void TestConversionVisualBasicToCSharp(string visualBasicCode, string expectedCsharpCode, CSharpParseOptions csharpOptions = null, VisualBasicParseOptions vbOptions = null)
|
||||
{
|
||||
TestWorkspace csharpWorkspace, vbWorkspace;
|
||||
Document inputDocument, outputDocument;
|
||||
VBWorkspaceSetup(visualBasicCode, out vbWorkspace, out inputDocument, vbOptions);
|
||||
CSharpWorkspaceSetup(out csharpWorkspace, out outputDocument, csharpOptions);
|
||||
var outputNode = Convert((VisualBasicSyntaxNode)inputDocument.GetSyntaxRootAsync().Result, inputDocument.GetSemanticModelAsync().Result, outputDocument);
|
||||
|
||||
var txt = outputDocument.WithSyntaxRoot(Formatter.Format(outputNode, vbWorkspace)).GetTextAsync().Result.ToString();
|
||||
txt = Utils.HomogenizeEol(txt).TrimEnd();
|
||||
expectedCsharpCode = Utils.HomogenizeEol(expectedCsharpCode).TrimEnd();
|
||||
if (expectedCsharpCode != txt) {
|
||||
int l = Math.Max(expectedCsharpCode.Length, txt.Length);
|
||||
StringBuilder sb = new StringBuilder(l * 4);
|
||||
sb.AppendLine("expected:");
|
||||
sb.AppendLine(expectedCsharpCode);
|
||||
sb.AppendLine("got:");
|
||||
sb.AppendLine(txt);
|
||||
sb.AppendLine("diff:");
|
||||
for (int i = 0; i < l; i++) {
|
||||
if (i >= expectedCsharpCode.Length || i >= txt.Length || expectedCsharpCode[i] != txt[i])
|
||||
sb.Append('x');
|
||||
else
|
||||
sb.Append(expectedCsharpCode[i]);
|
||||
}
|
||||
Assert.True(false, sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
VisualBasicSyntaxNode Convert(CSharpSyntaxNode input, SemanticModel semanticModel, Document targetDocument)
|
||||
{
|
||||
return CSharpConverter.Convert(input, semanticModel, targetDocument);
|
||||
}
|
||||
|
||||
CSharpSyntaxNode Convert(VisualBasicSyntaxNode input, SemanticModel semanticModel, Document targetDocument)
|
||||
{
|
||||
return VisualBasicConverter.Convert(input, semanticModel, targetDocument);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RefactoringEssentials.Tests
|
||||
{
|
||||
public abstract class DiagnosticTestBase
|
||||
{
|
||||
static MetadataReference mscorlib;
|
||||
static MetadataReference systemAssembly;
|
||||
static MetadataReference systemXmlLinq;
|
||||
static MetadataReference systemCore;
|
||||
private static MetadataReference visualBasic;
|
||||
|
||||
internal static MetadataReference[] DefaultMetadataReferences;
|
||||
|
||||
static DiagnosticTestBase()
|
||||
{
|
||||
try {
|
||||
mscorlib = MetadataReference.CreateFromFile(typeof(Console).Assembly.Location);
|
||||
systemAssembly = MetadataReference.CreateFromFile(typeof(System.ComponentModel.BrowsableAttribute).Assembly.Location);
|
||||
systemXmlLinq = MetadataReference.CreateFromFile(typeof(System.Xml.Linq.XElement).Assembly.Location);
|
||||
systemCore = MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location);
|
||||
visualBasic = MetadataReference.CreateFromFile(typeof(Microsoft.VisualBasic.Constants).Assembly.Location);
|
||||
DefaultMetadataReferences = new[] {
|
||||
mscorlib,
|
||||
systemAssembly,
|
||||
systemCore,
|
||||
systemXmlLinq,
|
||||
visualBasic
|
||||
};
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace RefactoringEssentials.Tests
|
||||
{
|
||||
internal class TestWorkspace : Workspace
|
||||
{
|
||||
readonly static HostServices services = Microsoft.CodeAnalysis.Host.Mef.MefHostServices.DefaultHost;/* MefHostServices.Create(new [] {
|
||||
typeof(MefHostServices).Assembly,
|
||||
typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions).Assembly
|
||||
});*/
|
||||
|
||||
|
||||
public TestWorkspace(string workspaceKind = "Test") : base(services, workspaceKind)
|
||||
{
|
||||
/*
|
||||
foreach (var a in MefHostServices.DefaultAssemblies)
|
||||
{
|
||||
Console.WriteLine(a.FullName);
|
||||
}*/
|
||||
}
|
||||
|
||||
public void ChangeDocument(DocumentId id, SourceText text)
|
||||
{
|
||||
ApplyDocumentTextChanged(id, text);
|
||||
}
|
||||
|
||||
protected override void ApplyDocumentTextChanged(DocumentId id, SourceText text)
|
||||
{
|
||||
base.ApplyDocumentTextChanged(id, text);
|
||||
var document = CurrentSolution.GetDocument(id);
|
||||
if (document != null)
|
||||
OnDocumentTextChanged(id, text, PreservationMode.PreserveValue);
|
||||
}
|
||||
|
||||
public override bool CanApplyChange(ApplyChangesKind feature)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Open(ProjectInfo projectInfo)
|
||||
{
|
||||
var sInfo = SolutionInfo.Create(
|
||||
SolutionId.CreateNewId(),
|
||||
VersionStamp.Create(),
|
||||
null,
|
||||
new[] { projectInfo }
|
||||
);
|
||||
OnSolutionAdded(sInfo);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,252 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props" Condition="Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" />
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
|
||||
<Import Project="..\packages\Microsoft.DiaSymReader.Native.1.7.0\build\Microsoft.DiaSymReader.Native.props" Condition="Exists('..\packages\Microsoft.DiaSymReader.Native.1.7.0\build\Microsoft.DiaSymReader.Native.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{21DBA1CE-AF55-4159-B04B-B8C621BE8921}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>RefactoringEssentials.Tests</RootNamespace>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>C:\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;RE2017;UNIMPLEMENTED_CONVERTER_FEATURE_TESTS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AssemblyName>RefactoringEssentials.Tests</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AssemblyName>RefactoringEssentials.Tests</AssemblyName>
|
||||
<DefineConstants>RE2017</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Mono_Debug|AnyCPU' ">
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug_Mono.2017</OutputPath>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AssemblyName>Tests</AssemblyName>
|
||||
<DefineConstants>RE2017</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Mono_Release|AnyCPU' ">
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Mono_Release.2017</OutputPath>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AssemblyName>Tests</AssemblyName>
|
||||
<DefineConstants>RE2017</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Esent.Interop, Version=1.9.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ManagedEsent.1.9.4\lib\net40\Esent.Interop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.Elfie, Version=0.10.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Elfie.0.10.6\lib\net46\Microsoft.CodeAnalysis.Elfie.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.VisualBasic, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.VisualBasic.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.6.1\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.Workspaces.Desktop, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.6.1\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=1.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.AttributedModel, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.AttributedModel.1.1.0\lib\netstandard2.0\System.Composition.AttributedModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.Convention, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.Convention.1.1.0\lib\netstandard2.0\System.Composition.Convention.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.Hosting, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.Hosting.1.1.0\lib\netstandard2.0\System.Composition.Hosting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.Runtime, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.Runtime.1.1.0\lib\netstandard2.0\System.Composition.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.TypedParts, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.TypedParts.1.1.0\lib\netstandard2.0\System.Composition.TypedParts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Diagnostics.FileVersionInfo, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Diagnostics.StackTrace, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Reflection.Metadata, Version=1.4.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.Metadata.1.5.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encoding.CodePages, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encoding.CodePages.4.4.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Thread, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XPath, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XPath.XDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.execution.desktop, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ICSharpCode.CodeConverter\ICSharpCode.CodeConverter.csproj">
|
||||
<Project>{7ea075c6-6406-445c-ab77-6c47aff88d58}</Project>
|
||||
<Name>ICSharpCode.CodeConverter</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConverterTestBase.cs" />
|
||||
<Compile Include="CSharp\ExpressionTests.cs" />
|
||||
<Compile Include="CSharp\MemberTests.cs" />
|
||||
<Compile Include="CSharp\NamespaceLevelTests.cs" />
|
||||
<Compile Include="CSharp\SpecialConversionTests.cs" />
|
||||
<Compile Include="CSharp\StatementTests.cs" />
|
||||
<Compile Include="CSharp\TypeCastTests.cs" />
|
||||
<Compile Include="DiagnosticTestBase.cs" />
|
||||
<Compile Include="TestWorkspace.cs" />
|
||||
<Compile Include="UnicodeNewline.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="VB\ExpressionTests.cs" />
|
||||
<Compile Include="VB\MemberTests.cs" />
|
||||
<Compile Include="VB\NamespaceLevelTests.cs" />
|
||||
<Compile Include="VB\SpecialConversionTests.cs" />
|
||||
<Compile Include="VB\StatementTests.cs" />
|
||||
<Compile Include="VB\TypeCastTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Analyzer Include="..\packages\xunit.analyzers.0.7.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets') And '$(Configuration)'!='Mono_Debug' And '$(Configuration)'!='Mono_Release'" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild" Condition="'$(Configuration)'!='Mono_Debug' And '$(Configuration)'!='Mono_Release'">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.DiaSymReader.Native.1.7.0\build\Microsoft.DiaSymReader.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.DiaSymReader.Native.1.7.0\build\Microsoft.DiaSymReader.Native.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props'))" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentSwitchSection="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceAfterMethodCallName="False" SpaceBeforeOpenSquareBracket="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" />
|
||||
</Project>
|
|
@ -0,0 +1,373 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RefactoringEssentials
|
||||
{
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
enum UnicodeNewline
|
||||
{
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// Line Feed, U+000A
|
||||
/// </summary>
|
||||
LF = 0x0A,
|
||||
|
||||
|
||||
CRLF = 0x0D0A,
|
||||
|
||||
/// <summary>
|
||||
/// Carriage Return, U+000D
|
||||
/// </summary>
|
||||
CR = 0x0D,
|
||||
|
||||
/// <summary>
|
||||
/// Next Line, U+0085
|
||||
/// </summary>
|
||||
NEL = 0x85,
|
||||
|
||||
/// <summary>
|
||||
/// Vertical Tab, U+000B
|
||||
/// </summary>
|
||||
VT = 0x0B,
|
||||
|
||||
/// <summary>
|
||||
/// Form Feed, U+000C
|
||||
/// </summary>
|
||||
FF = 0x0C,
|
||||
|
||||
/// <summary>
|
||||
/// Line Separator, U+2028
|
||||
/// </summary>
|
||||
LS = 0x2028,
|
||||
|
||||
/// <summary>
|
||||
/// Paragraph Separator, U+2029
|
||||
/// </summary>
|
||||
PS = 0x2029
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Defines unicode new lines according to Unicode Technical Report #13
|
||||
/// http://www.unicode.org/standard/reports/tr13/tr13-5.html
|
||||
/// </summary>
|
||||
#if NR6
|
||||
public
|
||||
#endif
|
||||
static class NewLine
|
||||
{
|
||||
/// <summary>
|
||||
/// Carriage Return, U+000D
|
||||
/// </summary>
|
||||
public const char CR = (char)0x0D;
|
||||
|
||||
/// <summary>
|
||||
/// Line Feed, U+000A
|
||||
/// </summary>
|
||||
public const char LF = (char)0x0A;
|
||||
|
||||
/// <summary>
|
||||
/// Next Line, U+0085
|
||||
/// </summary>
|
||||
public const char NEL = (char)0x85;
|
||||
|
||||
/// <summary>
|
||||
/// Vertical Tab, U+000B
|
||||
/// </summary>
|
||||
public const char VT = (char)0x0B;
|
||||
|
||||
/// <summary>
|
||||
/// Form Feed, U+000C
|
||||
/// </summary>
|
||||
public const char FF = (char)0x0C;
|
||||
|
||||
/// <summary>
|
||||
/// Line Separator, U+2028
|
||||
/// </summary>
|
||||
public const char LS = (char)0x2028;
|
||||
|
||||
/// <summary>
|
||||
/// Paragraph Separator, U+2029
|
||||
/// </summary>
|
||||
public const char PS = (char)0x2029;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a char is a new line delimiter.
|
||||
/// </summary>
|
||||
/// <returns>0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.</returns>
|
||||
/// <param name="curChar">The current character.</param>
|
||||
/// <param name="nextChar">A callback getting the next character (may be null).</param>
|
||||
public static int GetDelimiterLength(char curChar, Func<char> nextChar = null)
|
||||
{
|
||||
if (curChar == CR) {
|
||||
if (nextChar != null && nextChar() == LF)
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (curChar == LF || curChar == NEL || curChar == VT || curChar == FF || curChar == LS || curChar == PS)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a char is a new line delimiter.
|
||||
/// </summary>
|
||||
/// <returns>0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.</returns>
|
||||
/// <param name="curChar">The current character.</param>
|
||||
/// <param name="nextChar">The next character (if != LF then length will always be 0 or 1).</param>
|
||||
public static int GetDelimiterLength(char curChar, char nextChar)
|
||||
{
|
||||
if (curChar == CR) {
|
||||
if (nextChar == LF)
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (curChar == LF || curChar == NEL || curChar == VT || curChar == FF || curChar == LS || curChar == PS)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a char is a new line delimiter.
|
||||
/// </summary>
|
||||
/// <returns>0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.</returns>
|
||||
/// <param name="curChar">The current character.</param>
|
||||
/// <param name = "length">The length of the delimiter</param>
|
||||
/// <param name = "type">The type of the delimiter</param>
|
||||
/// <param name="nextChar">A callback getting the next character (may be null).</param>
|
||||
public static bool TryGetDelimiterLengthAndType(char curChar, out int length, out UnicodeNewline type, Func<char> nextChar = null)
|
||||
{
|
||||
if (curChar == CR) {
|
||||
if (nextChar != null && nextChar() == LF) {
|
||||
length = 2;
|
||||
type = UnicodeNewline.CRLF;
|
||||
} else {
|
||||
length = 1;
|
||||
type = UnicodeNewline.CR;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (curChar) {
|
||||
case LF:
|
||||
type = UnicodeNewline.LF;
|
||||
length = 1;
|
||||
return true;
|
||||
case NEL:
|
||||
type = UnicodeNewline.NEL;
|
||||
length = 1;
|
||||
return true;
|
||||
case VT:
|
||||
type = UnicodeNewline.VT;
|
||||
length = 1;
|
||||
return true;
|
||||
case FF:
|
||||
type = UnicodeNewline.FF;
|
||||
length = 1;
|
||||
return true;
|
||||
case LS:
|
||||
type = UnicodeNewline.LS;
|
||||
length = 1;
|
||||
return true;
|
||||
case PS:
|
||||
type = UnicodeNewline.PS;
|
||||
length = 1;
|
||||
return true;
|
||||
}
|
||||
length = -1;
|
||||
type = UnicodeNewline.Unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a char is a new line delimiter.
|
||||
/// </summary>
|
||||
/// <returns>0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.</returns>
|
||||
/// <param name="curChar">The current character.</param>
|
||||
/// <param name = "length">The length of the delimiter</param>
|
||||
/// <param name = "type">The type of the delimiter</param>
|
||||
/// <param name="nextChar">The next character (if != LF then length will always be 0 or 1).</param>
|
||||
public static bool TryGetDelimiterLengthAndType(char curChar, out int length, out UnicodeNewline type, char nextChar)
|
||||
{
|
||||
if (curChar == CR) {
|
||||
if (nextChar == LF) {
|
||||
length = 2;
|
||||
type = UnicodeNewline.CRLF;
|
||||
} else {
|
||||
length = 1;
|
||||
type = UnicodeNewline.CR;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (curChar) {
|
||||
case LF:
|
||||
type = UnicodeNewline.LF;
|
||||
length = 1;
|
||||
return true;
|
||||
case NEL:
|
||||
type = UnicodeNewline.NEL;
|
||||
length = 1;
|
||||
return true;
|
||||
case VT:
|
||||
type = UnicodeNewline.VT;
|
||||
length = 1;
|
||||
return true;
|
||||
case FF:
|
||||
type = UnicodeNewline.FF;
|
||||
length = 1;
|
||||
return true;
|
||||
case LS:
|
||||
type = UnicodeNewline.LS;
|
||||
length = 1;
|
||||
return true;
|
||||
case PS:
|
||||
type = UnicodeNewline.PS;
|
||||
length = 1;
|
||||
return true;
|
||||
}
|
||||
length = -1;
|
||||
type = UnicodeNewline.Unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the new line type of a given char/next char.
|
||||
/// </summary>
|
||||
/// <returns>0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.</returns>
|
||||
/// <param name="curChar">The current character.</param>
|
||||
/// <param name="nextChar">A callback getting the next character (may be null).</param>
|
||||
public static UnicodeNewline GetDelimiterType(char curChar, Func<char> nextChar = null)
|
||||
{
|
||||
switch (curChar) {
|
||||
case CR:
|
||||
if (nextChar != null && nextChar() == LF)
|
||||
return UnicodeNewline.CRLF;
|
||||
return UnicodeNewline.CR;
|
||||
case LF:
|
||||
return UnicodeNewline.LF;
|
||||
case NEL:
|
||||
return UnicodeNewline.NEL;
|
||||
case VT:
|
||||
return UnicodeNewline.VT;
|
||||
case FF:
|
||||
return UnicodeNewline.FF;
|
||||
case LS:
|
||||
return UnicodeNewline.LS;
|
||||
case PS:
|
||||
return UnicodeNewline.PS;
|
||||
}
|
||||
return UnicodeNewline.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the new line type of a given char/next char.
|
||||
/// </summary>
|
||||
/// <returns>0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.</returns>
|
||||
/// <param name="curChar">The current character.</param>
|
||||
/// <param name="nextChar">The next character (if != LF then length will always be 0 or 1).</param>
|
||||
public static UnicodeNewline GetDelimiterType(char curChar, char nextChar)
|
||||
{
|
||||
switch (curChar) {
|
||||
case CR:
|
||||
if (nextChar == LF)
|
||||
return UnicodeNewline.CRLF;
|
||||
return UnicodeNewline.CR;
|
||||
case LF:
|
||||
return UnicodeNewline.LF;
|
||||
case NEL:
|
||||
return UnicodeNewline.NEL;
|
||||
case VT:
|
||||
return UnicodeNewline.VT;
|
||||
case FF:
|
||||
return UnicodeNewline.FF;
|
||||
case LS:
|
||||
return UnicodeNewline.LS;
|
||||
case PS:
|
||||
return UnicodeNewline.PS;
|
||||
}
|
||||
return UnicodeNewline.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a char is a new line delimiter.
|
||||
///
|
||||
/// Note that the only 2 char wide new line is CR LF and both chars are new line
|
||||
/// chars on their own. For most cases GetDelimiterLength is the better choice.
|
||||
/// </summary>
|
||||
public static bool IsNewLine(char ch)
|
||||
{
|
||||
return
|
||||
ch == NewLine.CR ||
|
||||
ch == NewLine.LF ||
|
||||
ch == NewLine.NEL ||
|
||||
ch == NewLine.VT ||
|
||||
ch == NewLine.FF ||
|
||||
ch == NewLine.LS ||
|
||||
ch == NewLine.PS;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the new line as a string.
|
||||
/// </summary>
|
||||
public static string GetString(UnicodeNewline newLine)
|
||||
{
|
||||
switch (newLine) {
|
||||
case UnicodeNewline.Unknown:
|
||||
return "";
|
||||
case UnicodeNewline.LF:
|
||||
return "\n";
|
||||
case UnicodeNewline.CRLF:
|
||||
return "\r\n";
|
||||
case UnicodeNewline.CR:
|
||||
return "\r";
|
||||
case UnicodeNewline.NEL:
|
||||
return "\u0085";
|
||||
case UnicodeNewline.VT:
|
||||
return "\u000B";
|
||||
case UnicodeNewline.FF:
|
||||
return "\u000C";
|
||||
case UnicodeNewline.LS:
|
||||
return "\u2028";
|
||||
case UnicodeNewline.PS:
|
||||
return "\u2029";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] SplitLines(string text)
|
||||
{
|
||||
var result = new List<string>();
|
||||
var sb = new StringBuilder();
|
||||
|
||||
int length;
|
||||
UnicodeNewline type;
|
||||
|
||||
for (int i = 0; i < text.Length; i++) {
|
||||
char ch = text[i];
|
||||
if (TryGetDelimiterLengthAndType(ch, out length, out type, () => i < text.Length - 1 ? text[i + 1] : '\0')) {
|
||||
result.Add(sb.ToString());
|
||||
sb.Length = 0;
|
||||
i += length - 1;
|
||||
continue;
|
||||
}
|
||||
sb.Append(ch);
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
result.Add(sb.ToString());
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using System.Text;
|
||||
|
||||
namespace RefactoringEssentials.Tests.Common
|
||||
{
|
||||
static class Utils
|
||||
{
|
||||
internal static string HomogenizeEol(string str)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (int i = 0; i < str.Length; i++) {
|
||||
var ch = str[i];
|
||||
var possibleNewline = NewLine.GetDelimiterLength(ch, i + 1 < str.Length ? str[i + 1] : '\0');
|
||||
if (possibleNewline > 0) {
|
||||
sb.AppendLine();
|
||||
if (possibleNewline == 2)
|
||||
i++;
|
||||
} else {
|
||||
sb.Append(ch);
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,431 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.VB.Converter
|
||||
{
|
||||
public class ExpressionTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void MultilineString()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
var x = @""Hello,
|
||||
World!"";
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim x = ""Hello,
|
||||
World!""
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConditionalExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(string str)
|
||||
{
|
||||
bool result = (str == """") ? true : false;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim result As Boolean = If((str = """"), True, False)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullCoalescingExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(string str)
|
||||
{
|
||||
Console.WriteLine(str ?? ""<null>"");
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Console.WriteLine(If(str, ""<null>""))
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MemberAccessAndInvocationExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(string str)
|
||||
{
|
||||
int length;
|
||||
length = str.Length;
|
||||
Console.WriteLine(""Test"" + length);
|
||||
Console.ReadKey();
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim length As Integer
|
||||
length = str.Length
|
||||
Console.WriteLine(""Test"" & length)
|
||||
Console.ReadKey()
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ElvisOperatorExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(string str)
|
||||
{
|
||||
int length = str?.Length ?? -1;
|
||||
Console.WriteLine(length);
|
||||
Console.ReadKey();
|
||||
string redirectUri = context.OwinContext.Authentication?.AuthenticationResponseChallenge?.Properties?.RedirectUri;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim length As Integer = If(str?.Length, -1)
|
||||
Console.WriteLine(length)
|
||||
Console.ReadKey()
|
||||
Dim redirectUri As String = context.OwinContext.Authentication?.AuthenticationResponseChallenge?.Properties?.RedirectUri
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void ObjectInitializerExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class StudentName
|
||||
{
|
||||
public string LastName, FirstName;
|
||||
}
|
||||
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(string str)
|
||||
{
|
||||
StudentName student2 = new StudentName
|
||||
{
|
||||
FirstName = ""Craig"",
|
||||
LastName = ""Playstead"",
|
||||
};
|
||||
}
|
||||
}", @"Class StudentName
|
||||
Public LastName, FirstName As String
|
||||
End Class
|
||||
|
||||
Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim student2 As StudentName = New StudentName With {.FirstName = ""Craig"", .LastName = ""Playstead""}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void ObjectInitializerExpression2()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(string str)
|
||||
{
|
||||
var student2 = new {
|
||||
FirstName = ""Craig"",
|
||||
LastName = ""Playstead"",
|
||||
};
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal str As String)
|
||||
Dim student2 = New With {Key .FirstName = ""Craig"", Key .LastName = ""Playstead""}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThisMemberAccessExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
private int member;
|
||||
|
||||
void TestMethod()
|
||||
{
|
||||
this.member = 0;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private member As Integer
|
||||
|
||||
Private Sub TestMethod()
|
||||
Me.member = 0
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BaseMemberAccessExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class BaseTestClass
|
||||
{
|
||||
public int member;
|
||||
}
|
||||
|
||||
class TestClass : BaseTestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
base.member = 0;
|
||||
}
|
||||
}", @"Class BaseTestClass
|
||||
Public member As Integer
|
||||
End Class
|
||||
|
||||
Class TestClass
|
||||
Inherits BaseTestClass
|
||||
|
||||
Private Sub TestMethod()
|
||||
MyBase.member = 0
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DelegateExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
var test = delegate(int a) { return a * 2 };
|
||||
|
||||
test(3);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim test = Function(ByVal a As Integer) a * 2
|
||||
test(3)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LambdaBodyExpression()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
var test = a => { return a * 2 };
|
||||
var test2 = (a, b) => { if (b > 0) return a / b; return 0; }
|
||||
var test3 = (a, b) => a % b;
|
||||
|
||||
test(3);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim test = Function(a) a * 2
|
||||
Dim test2 = Function(a, b)
|
||||
If b > 0 Then Return a / b
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Dim test3 = Function(a, b) a Mod b
|
||||
test(3)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Await()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
Task<int> SomeAsyncMethod()
|
||||
{
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
async void TestMethod()
|
||||
{
|
||||
int result = await SomeAsyncMethod();
|
||||
Console.WriteLine(result);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Function SomeAsyncMethod() As Task(Of Integer)
|
||||
Return Task.FromResult(0)
|
||||
End Function
|
||||
|
||||
Private Async Sub TestMethod()
|
||||
Dim result As Integer = Await SomeAsyncMethod()
|
||||
Console.WriteLine(result)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Linq1()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"static void SimpleQuery()
|
||||
{
|
||||
int[] numbers = { 7, 9, 5, 3, 6 };
|
||||
|
||||
var res = from n in numbers
|
||||
where n > 5
|
||||
select n;
|
||||
|
||||
foreach (var n in res)
|
||||
Console.WriteLine(n);
|
||||
}",
|
||||
@"Private Shared Sub SimpleQuery()
|
||||
Dim numbers As Integer() = {7, 9, 5, 3, 6}
|
||||
Dim res = From n In numbers Where n > 5 Select n
|
||||
|
||||
For Each n In res
|
||||
Console.WriteLine(n)
|
||||
Next
|
||||
End Sub");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void Linq2()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"public static void Linq40()
|
||||
{
|
||||
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
|
||||
|
||||
var numberGroups =
|
||||
from n in numbers
|
||||
group n by n % 5 into g
|
||||
select new { Remainder = g.Key, Numbers = g };
|
||||
|
||||
foreach (var g in numberGroups)
|
||||
{
|
||||
Console.WriteLine($""Numbers with a remainder of {g.Remainder} when divided by 5:"");
|
||||
foreach (var n in g.Numbers)
|
||||
{
|
||||
Console.WriteLine(n);
|
||||
}
|
||||
}
|
||||
}",
|
||||
@"Public Shared Sub Linq40()
|
||||
Dim numbers As Integer() = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}
|
||||
Dim numberGroups = From n In numbers Group n By __groupByKey1__ = n Mod 5 Into g Select New With {Key .Remainder = g.Key, Key .Numbers = g}
|
||||
|
||||
For Each g In numberGroups
|
||||
Console.WriteLine($""Numbers with a remainder of {g.Remainder} when divided by 5:"")
|
||||
|
||||
For Each n In g.Numbers
|
||||
Console.WriteLine(n)
|
||||
Next
|
||||
Next
|
||||
End Sub");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void Linq3()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"class Product {
|
||||
public string Category;
|
||||
public string ProductName;
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void Linq102()
|
||||
{
|
||||
string[] categories = new string[]{
|
||||
""Beverages"",
|
||||
""Condiments"",
|
||||
""Vegetables"",
|
||||
""Dairy Products"",
|
||||
""Seafood"" };
|
||||
|
||||
Product[] products = GetProductList();
|
||||
|
||||
var q =
|
||||
from c in categories
|
||||
join p in products on c equals p.Category
|
||||
select new { Category = c, p.ProductName };
|
||||
|
||||
foreach (var v in q)
|
||||
{
|
||||
Console.WriteLine($""{v.ProductName}: {v.Category}"");
|
||||
}
|
||||
}
|
||||
}",
|
||||
@"Class Product
|
||||
Public Category As String
|
||||
Public ProductName As String
|
||||
End Class
|
||||
|
||||
Class Test
|
||||
Public Sub Linq102()
|
||||
Dim categories As String() = New String() {""Beverages"", ""Condiments"", ""Vegetables"", ""Dairy Products"", ""Seafood""}
|
||||
Dim products As Product() = GetProductList()
|
||||
Dim q = From c In categories Join p In products On c Equals p.Category Select New With {Key .Category = c, p.ProductName}
|
||||
|
||||
For Each v In q
|
||||
Console.WriteLine($""{v.ProductName}: {v.Category}"")
|
||||
Next
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void Linq4()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"public void Linq103()
|
||||
{
|
||||
string[] categories = new string[]{
|
||||
""Beverages"",
|
||||
""Condiments"",
|
||||
""Vegetables"",
|
||||
""Dairy Products"",
|
||||
""Seafood"" };
|
||||
|
||||
var products = GetProductList();
|
||||
|
||||
var q =
|
||||
from c in categories
|
||||
join p in products on c equals p.Category into ps
|
||||
select new { Category = c, Products = ps };
|
||||
|
||||
foreach (var v in q)
|
||||
{
|
||||
Console.WriteLine(v.Category + "":"");
|
||||
foreach (var p in v.Products)
|
||||
{
|
||||
Console.WriteLine("" "" + p.ProductName);
|
||||
}
|
||||
}
|
||||
}", @"Public Sub Linq103()
|
||||
Dim categories As String() = New String() {""Beverages"", ""Condiments"", ""Vegetables"", ""Dairy Products"", ""Seafood""}
|
||||
Dim products = GetProductList()
|
||||
Dim q = From c In categories Group Join p In products On c Equals p.Category Into ps = Group Select New With {Key .Category = c, Key .Products = ps}
|
||||
|
||||
For Each v In q
|
||||
Console.WriteLine(v.Category & "":"")
|
||||
|
||||
For Each p In v.Products
|
||||
Console.WriteLine("" "" & p.ProductName)
|
||||
Next
|
||||
Next
|
||||
End Sub");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,301 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.VB.Converter
|
||||
{
|
||||
public class MemberTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestField()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
const int answer = 42;
|
||||
int value = 10;
|
||||
readonly int v = 15;
|
||||
}", @"Class TestClass
|
||||
Const answer As Integer = 42
|
||||
Private value As Integer = 10
|
||||
ReadOnly v As Integer = 15
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMethod()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3) where T : class, new where T2 : struct
|
||||
{
|
||||
argument = null;
|
||||
argument2 = default(T2);
|
||||
argument3 = default(T3);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Public Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
argument = Nothing
|
||||
argument2 = Nothing
|
||||
argument3 = Nothing
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMethodWithReturnType()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public int TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3) where T : class, new where T2 : struct
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Public Function TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3) As Integer
|
||||
Return 0
|
||||
End Function
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestStaticMethod()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public static void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3) where T : class, new where T2 : struct
|
||||
{
|
||||
argument = null;
|
||||
argument2 = default(T2);
|
||||
argument3 = default(T3);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Public Shared Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
argument = Nothing
|
||||
argument2 = Nothing
|
||||
argument3 = Nothing
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAbstractMethod()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public abstract void TestMethod();
|
||||
}", @"Class TestClass
|
||||
Public MustOverride Sub TestMethod()
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSealedMethod()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public sealed void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3) where T : class, new where T2 : struct
|
||||
{
|
||||
argument = null;
|
||||
argument2 = default(T2);
|
||||
argument3 = default(T3);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Public NotOverridable Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
argument = Nothing
|
||||
argument2 = Nothing
|
||||
argument3 = Nothing
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestExtensionMethod()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"static class TestClass
|
||||
{
|
||||
public static void TestMethod(this String str)
|
||||
{
|
||||
}
|
||||
}", @"Imports System.Runtime.CompilerServices
|
||||
|
||||
Module TestClass
|
||||
<Extension()>
|
||||
Sub TestMethod(ByVal str As String)
|
||||
End Sub
|
||||
End Module");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestExtensionMethodWithExistingImport()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"using System.Runtime.CompilerServices;
|
||||
|
||||
static class TestClass
|
||||
{
|
||||
public static void TestMethod(this String str)
|
||||
{
|
||||
}
|
||||
}", @"Imports System.Runtime.CompilerServices
|
||||
|
||||
Module TestClass
|
||||
<Extension()>
|
||||
Sub TestMethod(ByVal str As String)
|
||||
End Sub
|
||||
End Module");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestProperty()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public int Test { get; set; }
|
||||
public int Test2 {
|
||||
get { return 0; }
|
||||
}
|
||||
int m_test3;
|
||||
public int Test3 {
|
||||
get { return this.m_test3; }
|
||||
set { this.m_test3 = value; }
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Public Property Test As Integer
|
||||
|
||||
Public Property Test2 As Integer
|
||||
Get
|
||||
Return 0
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_test3 As Integer
|
||||
|
||||
Public Property Test3 As Integer
|
||||
Get
|
||||
Return Me.m_test3
|
||||
End Get
|
||||
Set(ByVal value As Integer)
|
||||
Me.m_test3 = value
|
||||
End Set
|
||||
End Property
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestConstructor()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass<T, T2, T3> where T : class, new where T2 : struct
|
||||
{
|
||||
public TestClass(out T argument, ref T2 argument2, T3 argument3)
|
||||
{
|
||||
}
|
||||
}", @"Class TestClass(Of T As {Class, New}, T2 As Structure, T3)
|
||||
Public Sub New(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDestructor()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
~TestClass()
|
||||
{
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Protected Overrides Sub Finalize()
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEvent()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public event EventHandler MyEvent;
|
||||
}", @"Class TestClass
|
||||
Public Event MyEvent As EventHandler
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCustomEvent()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"using System;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
EventHandler backingField;
|
||||
|
||||
public event EventHandler MyEvent {
|
||||
add {
|
||||
this.backingField += value;
|
||||
}
|
||||
remove {
|
||||
this.backingField -= value;
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private backingField As EventHandler
|
||||
|
||||
Public Event MyEvent As EventHandler
|
||||
AddHandler(ByVal value As EventHandler)
|
||||
AddHandler Me.backingField, value
|
||||
End AddHandler
|
||||
RemoveHandler(ByVal value As EventHandler)
|
||||
RemoveHandler Me.backingField, value
|
||||
End RemoveHandler
|
||||
End Event
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestIndexer()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
public int this[int index] { get; set; }
|
||||
public int this[string index] {
|
||||
get { return 0; }
|
||||
}
|
||||
int m_test3;
|
||||
public int this[double index] {
|
||||
get { return this.m_test3; }
|
||||
set { this.m_test3 = value; }
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Default Public Property Item(ByVal index As Integer) As Integer
|
||||
|
||||
Default Public Property Item(ByVal index As String) As Integer
|
||||
Get
|
||||
Return 0
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_test3 As Integer
|
||||
|
||||
Default Public Property Item(ByVal index As Double) As Integer
|
||||
Get
|
||||
Return Me.m_test3
|
||||
End Get
|
||||
Set(ByVal value As Integer)
|
||||
Me.m_test3 = value
|
||||
End Set
|
||||
End Property
|
||||
End Class");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,235 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.VB.Converter
|
||||
{
|
||||
public class NamespaceLevelTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestNamespace()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"namespace Test
|
||||
{
|
||||
|
||||
}", @"Namespace Test
|
||||
End Namespace");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTopLevelAttribute()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"[assembly: CLSCompliant(true)]",
|
||||
@"<Assembly: CLSCompliant(True)>");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestImports()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"using SomeNamespace;
|
||||
using VB = Microsoft.VisualBasic;",
|
||||
@"Imports SomeNamespace
|
||||
Imports VB = Microsoft.VisualBasic");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestClass()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"namespace Test.@class
|
||||
{
|
||||
class TestClass<T>
|
||||
{
|
||||
}
|
||||
}", @"Namespace Test.[class]
|
||||
Class TestClass(Of T)
|
||||
End Class
|
||||
End Namespace");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestInternalStaticClass()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"namespace Test.@class
|
||||
{
|
||||
internal static class TestClass
|
||||
{
|
||||
public static void Test() {}
|
||||
static void Test2() {}
|
||||
}
|
||||
}", @"Namespace Test.[class]
|
||||
Friend Module TestClass
|
||||
Sub Test()
|
||||
End Sub
|
||||
|
||||
Private Sub Test2()
|
||||
End Sub
|
||||
End Module
|
||||
End Namespace");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAbstractClass()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"namespace Test.@class
|
||||
{
|
||||
abstract class TestClass
|
||||
{
|
||||
}
|
||||
}", @"Namespace Test.[class]
|
||||
MustInherit Class TestClass
|
||||
End Class
|
||||
End Namespace");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSealedClass()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"namespace Test.@class
|
||||
{
|
||||
sealed class TestClass
|
||||
{
|
||||
}
|
||||
}", @"Namespace Test.[class]
|
||||
NotInheritable Class TestClass
|
||||
End Class
|
||||
End Namespace");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestInterface()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"interface ITest : System.IDisposable
|
||||
{
|
||||
void Test ();
|
||||
}", @"Interface ITest
|
||||
Inherits System.IDisposable
|
||||
|
||||
Sub Test()
|
||||
End Interface");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEnum()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"internal enum ExceptionResource
|
||||
{
|
||||
Argument_ImplementIComparable,
|
||||
ArgumentOutOfRange_NeedNonNegNum,
|
||||
ArgumentOutOfRange_NeedNonNegNumRequired,
|
||||
Arg_ArrayPlusOffTooSmall
|
||||
}", @"Friend Enum ExceptionResource
|
||||
Argument_ImplementIComparable
|
||||
ArgumentOutOfRange_NeedNonNegNum
|
||||
ArgumentOutOfRange_NeedNonNegNumRequired
|
||||
Arg_ArrayPlusOffTooSmall
|
||||
End Enum");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestClassInheritanceList()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"abstract class ClassA : System.IDisposable
|
||||
{
|
||||
protected abstract void Test();
|
||||
}", @"MustInherit Class ClassA
|
||||
Implements System.IDisposable
|
||||
|
||||
Protected MustOverride Sub Test()
|
||||
End Class");
|
||||
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"abstract class ClassA : System.EventArgs, System.IDisposable
|
||||
{
|
||||
protected abstract void Test();
|
||||
}", @"MustInherit Class ClassA
|
||||
Inherits System.EventArgs
|
||||
Implements System.IDisposable
|
||||
|
||||
Protected MustOverride Sub Test()
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestStruct()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"struct MyType : System.IComparable<MyType>
|
||||
{
|
||||
void Test() {}
|
||||
}", @"Structure MyType
|
||||
Implements System.IComparable(Of MyType)
|
||||
|
||||
Private Sub Test()
|
||||
End Sub
|
||||
End Structure");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDelegate()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"public delegate void Test();",
|
||||
@"Public Delegate Sub Test()");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"public delegate int Test();",
|
||||
@"Public Delegate Function Test() As Integer");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"public delegate void Test(int x);",
|
||||
@"Public Delegate Sub Test(ByVal x As Integer)");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"public delegate void Test(ref int x);",
|
||||
@"Public Delegate Sub Test(ByRef x As Integer)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveImportsStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic("namespace test { using SomeNamespace; }",
|
||||
@"Imports SomeNamespace
|
||||
|
||||
Namespace test
|
||||
End Namespace");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassImplementsInterface()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic("using System; class test : IComparable { }",
|
||||
@"Class test
|
||||
Implements IComparable
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassImplementsInterface2()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic("class test : System.IComparable { }",
|
||||
@"Class test
|
||||
Implements System.IComparable
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassInheritsClass()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic("using System.IO; class test : InvalidDataException { }",
|
||||
@"Imports System.IO
|
||||
|
||||
Class test
|
||||
Inherits InvalidDataException
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassInheritsClass2()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic("class test : System.IO.InvalidDataException { }",
|
||||
@"Class test
|
||||
Inherits System.IO.InvalidDataException
|
||||
End Class");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.VB.Converter
|
||||
{
|
||||
public class SpecialConversionTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestSimpleInlineAssign()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int a, b;
|
||||
b = a = 5;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim a, b As Integer
|
||||
b = __InlineAssignHelper(a, 5)
|
||||
End Sub
|
||||
|
||||
<Obsolete(""Please refactor code that uses this function, it is a simple work-around to simulate inline assignment in VB!"")>
|
||||
Private Shared Function __InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
|
||||
target = value
|
||||
Return value
|
||||
End Function
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSimplePostIncrementAssign()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int a = 5, b;
|
||||
b = a++;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer, a As Integer = 5
|
||||
b = Math.Min(System.Threading.Interlocked.Increment(a), a - 1)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RaiseEvent()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
event EventHandler MyEvent;
|
||||
|
||||
void TestMethod()
|
||||
{
|
||||
if (MyEvent != null) MyEvent(this, EventArgs.Empty);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Event MyEvent As EventHandler
|
||||
|
||||
Private Sub TestMethod()
|
||||
RaiseEvent MyEvent(Me, EventArgs.Empty)
|
||||
End Sub
|
||||
End Class");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if ((MyEvent != null)) MyEvent(this, EventArgs.Empty);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
RaiseEvent MyEvent(Me, EventArgs.Empty)
|
||||
End Sub
|
||||
End Class");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (null != MyEvent) { MyEvent(this, EventArgs.Empty); }
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
RaiseEvent MyEvent(Me, EventArgs.Empty)
|
||||
End Sub
|
||||
End Class");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (this.MyEvent != null) MyEvent(this, EventArgs.Empty);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
RaiseEvent MyEvent(Me, EventArgs.Empty)
|
||||
End Sub
|
||||
End Class");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (MyEvent != null) this.MyEvent(this, EventArgs.Empty);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
RaiseEvent MyEvent(Me, EventArgs.Empty)
|
||||
End Sub
|
||||
End Class");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if ((this.MyEvent != null)) { this.MyEvent(this, EventArgs.Empty); }
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
RaiseEvent MyEvent(Me, EventArgs.Empty)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IfStatementSimilarToRaiseEvent()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (FullImage != null) DrawImage();
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
If FullImage IsNot Nothing Then DrawImage()
|
||||
End Sub
|
||||
End Class");
|
||||
// regression test:
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (FullImage != null) e.DrawImage();
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
If FullImage IsNot Nothing Then e.DrawImage()
|
||||
End Sub
|
||||
End Class");
|
||||
// with braces:
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (FullImage != null) { DrawImage(); }
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
If FullImage IsNot Nothing Then
|
||||
DrawImage()
|
||||
End If
|
||||
End Sub
|
||||
End Class");
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (FullImage != null) { e.DrawImage(); }
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
If FullImage IsNot Nothing Then
|
||||
e.DrawImage()
|
||||
End If
|
||||
End Sub
|
||||
End Class");
|
||||
// another bug related to the IfStatement code:
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (Tiles != null) foreach (Tile t in Tiles) this.TileTray.Controls.Remove(t);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
If Tiles IsNot Nothing Then
|
||||
|
||||
For Each t As Tile In Tiles
|
||||
Me.TileTray.Controls.Remove(t)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,943 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.VB.Converter
|
||||
{
|
||||
public class StatementTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void EmptyStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
if (true) ;
|
||||
while (true) ;
|
||||
for (;;) ;
|
||||
do ; while (true);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
If True Then
|
||||
End If
|
||||
|
||||
While True
|
||||
End While
|
||||
|
||||
While True
|
||||
End While
|
||||
|
||||
Do
|
||||
Loop While True
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AssignmentStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int b;
|
||||
b = 0;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer
|
||||
b = 0
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AssignmentStatementInDeclaration()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int b = 0;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer = 0
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AssignmentStatementInVarDeclaration()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
var b = 0;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b = 0
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ObjectInitializationStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
string b;
|
||||
b = new string(""test"");
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As String
|
||||
b = New String(""test"")
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ObjectInitializationStatementInDeclaration()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
string b = new string(""test"");
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As String = New String(""test"")
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ObjectInitializationStatementInVarDeclaration()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
var b = new string(""test"");
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b = New String(""test"")
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ArrayDeclarationStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[] b;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer()
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ArrayInitializationStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[] b = { 1, 2, 3 };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer() = {1, 2, 3}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ArrayInitializationStatementInVarDeclaration()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
var b = { 1, 2, 3 };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b = {1, 2, 3}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ArrayInitializationStatementWithType()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[] b = new int[] { 1, 2, 3 };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer() = New Integer() {1, 2, 3}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ArrayInitializationStatementWithLength()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[] b = new int[3] { 1, 2, 3 };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer() = New Integer(2) {1, 2, 3}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MultidimensionalArrayDeclarationStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[,] b;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer(,)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void MultidimensionalArrayInitializationStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[,] b = { { 1, 2 }, { 3, 4 } };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer(,) = {{1, 2}, {3, 4}}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void MultidimensionalArrayInitializationStatementWithType()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[,] b = new int[,] { { 1, 2 }, { 3, 4 } };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer(,) = New Integer(,) {{1, 2}, {3, 4}}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not implemented!")]
|
||||
public void MultidimensionalArrayInitializationStatementWithLengths()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[,] b = new int[2, 2] { { 1, 2 }, { 3, 4 } };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer(,) = New Integer(1, 1) {{1, 2}, {3, 4}}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JaggedArrayDeclarationStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[][] b;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer()()
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JaggedArrayInitializationStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[][] b = { new int[] { 1, 2 }, new int[] { 3, 4 } };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer()() = {New Integer() {1, 2}, New Integer() {3, 4}}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JaggedArrayInitializationStatementWithType()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[][] b = new int[][] { new int[] { 1, 2 }, new int[] { 3, 4 } };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer()() = New Integer()() {New Integer() {1, 2}, New Integer() {3, 4}}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JaggedArrayInitializationStatementWithLength()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int[][] b = new int[2][] { new int[] { 1, 2 }, new int[] { 3, 4 } };
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer()() = New Integer(1)() {New Integer() {1, 2}, New Integer() {3, 4}}
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeclarationStatements()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"class Test {
|
||||
void TestMethod()
|
||||
{
|
||||
the_beginning:
|
||||
int value = 1;
|
||||
const double myPIe = System.Math.PI;
|
||||
var text = ""This is my text!"";
|
||||
goto the_beginning;
|
||||
}
|
||||
}", @"Class Test
|
||||
Private Sub TestMethod()
|
||||
the_beginning:
|
||||
Dim value As Integer = 1
|
||||
Const myPIe As Double = System.Math.PI
|
||||
Dim text = ""This is my text!""
|
||||
GoTo the_beginning
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IfStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod (int a)
|
||||
{
|
||||
int b;
|
||||
if (a == 0) {
|
||||
b = 0;
|
||||
} else if (a == 1) {
|
||||
b = 1;
|
||||
} else if (a == 2 || a == 3) {
|
||||
b = 2;
|
||||
} else {
|
||||
b = 3;
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal a As Integer)
|
||||
Dim b As Integer
|
||||
|
||||
If a = 0 Then
|
||||
b = 0
|
||||
ElseIf a = 1 Then
|
||||
b = 1
|
||||
ElseIf a = 2 OrElse a = 3 Then
|
||||
b = 2
|
||||
Else
|
||||
b = 3
|
||||
End If
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhileStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int b;
|
||||
b = 0;
|
||||
while (b == 0)
|
||||
{
|
||||
if (b == 2)
|
||||
continue;
|
||||
if (b == 3)
|
||||
break;
|
||||
b = 1;
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer
|
||||
b = 0
|
||||
|
||||
While b = 0
|
||||
If b = 2 Then Continue While
|
||||
If b = 3 Then Exit While
|
||||
b = 1
|
||||
End While
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DoWhileStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
int b;
|
||||
b = 0;
|
||||
do
|
||||
{
|
||||
if (b == 2)
|
||||
continue;
|
||||
if (b == 3)
|
||||
break;
|
||||
b = 1;
|
||||
}
|
||||
while (b == 0);
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim b As Integer
|
||||
b = 0
|
||||
|
||||
Do
|
||||
If b = 2 Then Continue Do
|
||||
If b = 3 Then Exit Do
|
||||
b = 1
|
||||
Loop While b = 0
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForEachStatementWithExplicitType()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(int[] values)
|
||||
{
|
||||
foreach (int val in values)
|
||||
{
|
||||
if (val == 2)
|
||||
continue;
|
||||
if (val == 3)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal values As Integer())
|
||||
For Each val As Integer In values
|
||||
If val = 2 Then Continue For
|
||||
If val = 3 Then Exit For
|
||||
Next
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForEachStatementWithVar()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(int[] values)
|
||||
{
|
||||
foreach (var val in values)
|
||||
{
|
||||
if (val == 2)
|
||||
continue;
|
||||
if (val == 3)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal values As Integer())
|
||||
For Each val In values
|
||||
If val = 2 Then Continue For
|
||||
If val = 3 Then Exit For
|
||||
Next
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyncLockStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(object nullObject)
|
||||
{
|
||||
if (nullObject == null)
|
||||
throw new ArgumentNullException(nameof(nullObject));
|
||||
lock (nullObject) {
|
||||
Console.WriteLine(nullObject);
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal nullObject As Object)
|
||||
If nullObject Is Nothing Then Throw New ArgumentNullException(NameOf(nullObject))
|
||||
|
||||
SyncLock nullObject
|
||||
Console.WriteLine(nullObject)
|
||||
End SyncLock
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForWithUnknownConditionAndSingleStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
for (i = 0; unknownCondition; i++)
|
||||
b[i] = s[i];
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
i = 0
|
||||
|
||||
While unknownCondition
|
||||
b(i) = s(i)
|
||||
i += 1
|
||||
End While
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForWithUnknownConditionAndBlock()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
for (i = 0; unknownCondition; i++) {
|
||||
b[i] = s[i];
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
i = 0
|
||||
|
||||
While unknownCondition
|
||||
b(i) = s(i)
|
||||
i += 1
|
||||
End While
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForWithSingleStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
for (i = 0; i < end; i++) b[i] = s[i];
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
For i = 0 To [end] - 1
|
||||
b(i) = s(i)
|
||||
Next
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForWithBlock()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
{
|
||||
for (i = 0; i < end; i++) {
|
||||
b[i] = s[i];
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
For i = 0 To [end] - 1
|
||||
b(i) = s(i)
|
||||
Next
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LabeledAndForStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class GotoTest1
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
int x = 200, y = 4;
|
||||
int count = 0;
|
||||
string[,] array = new string[x, y];
|
||||
|
||||
for (int i = 0; i < x; i++)
|
||||
|
||||
for (int j = 0; j < y; j++)
|
||||
array[i, j] = (++count).ToString();
|
||||
|
||||
Console.Write(""Enter the number to search for: "");
|
||||
|
||||
string myNumber = Console.ReadLine();
|
||||
|
||||
for (int i = 0; i < x; i++)
|
||||
{
|
||||
for (int j = 0; j < y; j++)
|
||||
{
|
||||
if (array[i, j].Equals(myNumber))
|
||||
{
|
||||
goto Found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine(""The number {0} was not found."", myNumber);
|
||||
goto Finish;
|
||||
|
||||
Found:
|
||||
Console.WriteLine(""The number {0} is found."", myNumber);
|
||||
|
||||
Finish:
|
||||
Console.WriteLine(""End of search."");
|
||||
|
||||
|
||||
Console.WriteLine(""Press any key to exit."");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}", @"Class GotoTest1
|
||||
Private Shared Sub Main()
|
||||
Dim x As Integer = 200, y As Integer = 4
|
||||
Dim count As Integer = 0
|
||||
Dim array As String(,) = New String(x - 1, y - 1) {}
|
||||
|
||||
For i As Integer = 0 To x - 1
|
||||
|
||||
For j As Integer = 0 To y - 1
|
||||
array(i, j) = (System.Threading.Interlocked.Increment(count)).ToString()
|
||||
Next
|
||||
Next
|
||||
|
||||
Console.Write(""Enter the number to search for: "")
|
||||
Dim myNumber As String = Console.ReadLine()
|
||||
|
||||
For i As Integer = 0 To x - 1
|
||||
|
||||
For j As Integer = 0 To y - 1
|
||||
|
||||
If array(i, j).Equals(myNumber) Then
|
||||
GoTo Found
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
Console.WriteLine(""The number {0} was not found."", myNumber)
|
||||
GoTo Finish
|
||||
Found:
|
||||
Console.WriteLine(""The number {0} is found."", myNumber)
|
||||
Finish:
|
||||
Console.WriteLine(""End of search."")
|
||||
Console.WriteLine(""Press any key to exit."")
|
||||
Console.ReadKey()
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowStatement()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(object nullObject)
|
||||
{
|
||||
if (nullObject == null)
|
||||
throw new ArgumentNullException(nameof(nullObject));
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal nullObject As Object)
|
||||
If nullObject Is Nothing Then Throw New ArgumentNullException(NameOf(nullObject))
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRemoveHandler()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"using System;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public event EventHandler MyEvent;
|
||||
|
||||
void TestMethod(EventHandler e)
|
||||
{
|
||||
this.MyEvent += e;
|
||||
this.MyEvent += MyHandler;
|
||||
}
|
||||
|
||||
void TestMethod2(EventHandler e)
|
||||
{
|
||||
this.MyEvent -= e;
|
||||
this.MyEvent -= MyHandler;
|
||||
}
|
||||
|
||||
void MyHandler(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Public Event MyEvent As EventHandler
|
||||
|
||||
Private Sub TestMethod(ByVal e As EventHandler)
|
||||
AddHandler Me.MyEvent, e
|
||||
AddHandler Me.MyEvent, AddressOf MyHandler
|
||||
End Sub
|
||||
|
||||
Private Sub TestMethod2(ByVal e As EventHandler)
|
||||
RemoveHandler Me.MyEvent, e
|
||||
RemoveHandler Me.MyEvent, AddressOf MyHandler
|
||||
End Sub
|
||||
|
||||
Private Sub MyHandler(ByVal sender As Object, ByVal e As EventArgs)
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectCase1()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(int number)
|
||||
{
|
||||
switch (number) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
Console.Write(""number is 0, 1, 2"");
|
||||
break;
|
||||
case 3:
|
||||
Console.Write(""section 3"");
|
||||
goto case 5;
|
||||
case 4:
|
||||
Console.Write(""section 4"");
|
||||
goto default;
|
||||
case 5:
|
||||
Console.Write(""section 5"");
|
||||
break;
|
||||
default:
|
||||
Console.Write(""default section"");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Sub TestMethod(ByVal number As Integer)
|
||||
Select Case number
|
||||
Case 0, 1, 2
|
||||
Console.Write(""number is 0, 1, 2"")
|
||||
Case 3
|
||||
Console.Write(""section 3"")
|
||||
GoTo _Select0_Case5
|
||||
Case 4
|
||||
Console.Write(""section 4"")
|
||||
GoTo _Select0_CaseDefault
|
||||
Case 5
|
||||
_Select0_Case5:
|
||||
Console.Write(""section 5"")
|
||||
Case Else
|
||||
_Select0_CaseDefault:
|
||||
Console.Write(""default section"")
|
||||
End Select
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryCatch()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
static bool Log(string message)
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
void TestMethod(int number)
|
||||
{
|
||||
try {
|
||||
Console.WriteLine(""try"");
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine(""catch1"");
|
||||
} catch {
|
||||
Console.WriteLine(""catch all"");
|
||||
} finally {
|
||||
Console.WriteLine(""finally"");
|
||||
}
|
||||
try {
|
||||
Console.WriteLine(""try"");
|
||||
} catch (System.IO.IOException) {
|
||||
Console.WriteLine(""catch1"");
|
||||
} catch (Exception e) when (Log(e.Message)) {
|
||||
Console.WriteLine(""catch2"");
|
||||
}
|
||||
try {
|
||||
Console.WriteLine(""try"");
|
||||
} finally {
|
||||
Console.WriteLine(""finally"");
|
||||
}
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Shared Function Log(ByVal message As String) As Boolean
|
||||
Console.WriteLine(message)
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Private Sub TestMethod(ByVal number As Integer)
|
||||
Try
|
||||
Console.WriteLine(""try"")
|
||||
Catch e As Exception
|
||||
Console.WriteLine(""catch1"")
|
||||
Catch
|
||||
Console.WriteLine(""catch all"")
|
||||
Finally
|
||||
Console.WriteLine(""finally"")
|
||||
End Try
|
||||
|
||||
Try
|
||||
Console.WriteLine(""try"")
|
||||
Catch __unusedIOException1__ As System.IO.IOException
|
||||
Console.WriteLine(""catch1"")
|
||||
Catch e As Exception When Log(e.Message)
|
||||
Console.WriteLine(""catch2"")
|
||||
End Try
|
||||
|
||||
Try
|
||||
Console.WriteLine(""try"")
|
||||
Finally
|
||||
Console.WriteLine(""finally"")
|
||||
End Try
|
||||
End Sub
|
||||
End Class");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Yield()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(@"
|
||||
class TestClass
|
||||
{
|
||||
IEnumerable<int> TestMethod(int number)
|
||||
{
|
||||
if (number < 0)
|
||||
yield break;
|
||||
for (int i = 0; i < number; i++)
|
||||
yield return i;
|
||||
}
|
||||
}", @"Class TestClass
|
||||
Private Iterator Function TestMethod(ByVal number As Integer) As IEnumerable(Of Integer)
|
||||
If number < 0 Then Return
|
||||
|
||||
For i As Integer = 0 To number - 1
|
||||
Yield i
|
||||
Next
|
||||
End Function
|
||||
End Class");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
using Xunit;
|
||||
|
||||
namespace RefactoringEssentials.Tests.VB.Converter
|
||||
{
|
||||
public class TypeCastTests : ConverterTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void CastObjectToInteger()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = 5;
|
||||
int i = (int) o;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = 5
|
||||
Dim i As Integer = CInt(o)
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastObjectToString()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = ""Test"";
|
||||
string s = (string) o;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = ""Test""
|
||||
Dim s As String = CStr(o)
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastObjectToGenericList()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = new System.Collections.Generic.List<int>();
|
||||
System.Collections.Generic.List<int> l = (System.Collections.Generic.List<int>) o;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = New System.Collections.Generic.List(Of Integer)()
|
||||
Dim l As System.Collections.Generic.List(Of Integer) = CType(o, System.Collections.Generic.List(Of Integer))
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryCastObjectToInteger()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = 5;
|
||||
System.Nullable<int> i = o as int;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = 5
|
||||
Dim i As System.Nullable(Of Integer) = TryCast(o, Integer)
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryCastObjectToGenericList()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = new System.Collections.Generic.List<int>();
|
||||
System.Collections.Generic.List<int> l = o as System.Collections.Generic.List<int>;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = New System.Collections.Generic.List(Of Integer)()
|
||||
Dim l As System.Collections.Generic.List(Of Integer) = TryCast(o, System.Collections.Generic.List(Of Integer))
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastConstantNumberToLong()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = 5L;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = 5L
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastConstantNumberToFloat()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = 5.0f;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = 5F
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CastConstantNumberToDecimal()
|
||||
{
|
||||
TestConversionCSharpToVisualBasic(
|
||||
@"void Test()
|
||||
{
|
||||
object o = 5.0m;
|
||||
}
|
||||
", @"Private Sub Test()
|
||||
Dim o As Object = 5.0D
|
||||
End Sub
|
||||
");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Composition.AttributedModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.32.0" newVersion="1.0.32.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Composition.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.32.0" newVersion="1.0.32.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Composition.TypedParts" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.32.0" newVersion="1.0.32.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Composition.Hosting" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.32.0" newVersion="1.0.32.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup></configuration>
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ManagedEsent" version="1.9.4" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis" version="2.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.Common" version="2.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.CSharp" version="2.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="2.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.Elfie" version="0.10.6" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.VisualBasic" version="2.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="2.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="2.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.Composition" version="1.0.31" targetFramework="net461" />
|
||||
<package id="Microsoft.DiaSymReader.Native" version="1.7.0" targetFramework="net461" />
|
||||
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Collections.Immutable" version="1.4.0" targetFramework="net461" />
|
||||
<package id="System.Composition" version="1.1.0" targetFramework="net461" />
|
||||
<package id="System.Composition.AttributedModel" version="1.1.0" targetFramework="net461" />
|
||||
<package id="System.Composition.Convention" version="1.1.0" targetFramework="net461" />
|
||||
<package id="System.Composition.Hosting" version="1.1.0" targetFramework="net461" />
|
||||
<package id="System.Composition.Runtime" version="1.1.0" targetFramework="net461" />
|
||||
<package id="System.Composition.TypedParts" version="1.1.0" targetFramework="net461" />
|
||||
<package id="System.Console" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Diagnostics.Contracts" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Globalization" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.IO" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.IO.Compression" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Linq" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Linq.Parallel" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.ObjectModel" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Reflection" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Reflection.Metadata" version="1.5.0" targetFramework="net461" />
|
||||
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Runtime" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net461" />
|
||||
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net461" />
|
||||
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Text.Encoding.CodePages" version="4.4.0" targetFramework="net461" />
|
||||
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Threading" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Threading.Thread" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Xml.XPath" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net461" />
|
||||
<package id="xunit" version="2.3.1" targetFramework="net461" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" />
|
||||
<package id="xunit.analyzers" version="0.7.0" targetFramework="net461" />
|
||||
<package id="xunit.assert" version="2.3.1" targetFramework="net461" />
|
||||
<package id="xunit.core" version="2.3.1" targetFramework="net461" />
|
||||
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net461" />
|
||||
<package id="xunit.extensibility.execution" version="2.3.1" targetFramework="net461" />
|
||||
<package id="xunit.runner.console" version="2.3.1" targetFramework="net461" developmentDependency="true" />
|
||||
<package id="xunit.runner.visualstudio" version="2.3.1" targetFramework="net461" developmentDependency="true" />
|
||||
</packages>
|
|
@ -0,0 +1,181 @@
|
|||
using Microsoft.VisualStudio.Shell;
|
||||
using Microsoft.VisualStudio.Shell.Interop;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
using Microsoft.VisualStudio.Text.Editor;
|
||||
using RefactoringEssentials.Converter;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace RefactoringEssentials.VsExtension
|
||||
{
|
||||
static class CodeConversion
|
||||
{
|
||||
public static readonly string CSToVBConversionTitle = "Convert C# to VB:";
|
||||
public static readonly string VBToCSConversionTitle = "Convert VB to C#:";
|
||||
|
||||
public static void PerformCSToVBConversion(IServiceProvider serviceProvider, string inputCode)
|
||||
{
|
||||
string convertedText = null;
|
||||
try {
|
||||
var result = TryConvertingCSToVBCode(inputCode);
|
||||
if (!result.Success) {
|
||||
var newLines = Environment.NewLine + Environment.NewLine;
|
||||
VsShellUtilities.ShowMessageBox(
|
||||
serviceProvider,
|
||||
$"Selected C# code seems to have errors or to be incomplete:{newLines}{result.GetExceptionsAsString()}",
|
||||
CSToVBConversionTitle,
|
||||
OLEMSGICON.OLEMSGICON_WARNING,
|
||||
OLEMSGBUTTON.OLEMSGBUTTON_OK,
|
||||
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
|
||||
return;
|
||||
}
|
||||
|
||||
convertedText = result.ConvertedCode;
|
||||
} catch (Exception ex) {
|
||||
VisualStudioInteraction.ShowException(serviceProvider, CSToVBConversionTitle, ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Direct output for debugging
|
||||
//string message = convertedText;
|
||||
//VsShellUtilities.ShowMessageBox(
|
||||
// serviceProvider,
|
||||
// message,
|
||||
// CSToVBConversionTitle,
|
||||
// OLEMSGICON.OLEMSGICON_INFO,
|
||||
// OLEMSGBUTTON.OLEMSGBUTTON_OK,
|
||||
// OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
|
||||
|
||||
WriteStatusBarText(serviceProvider, "Copied converted VB code to clipboard.");
|
||||
|
||||
Clipboard.SetText(convertedText);
|
||||
}
|
||||
|
||||
static ConversionResult TryConvertingCSToVBCode(string inputCode)
|
||||
{
|
||||
var codeWithOptions = new CodeWithOptions(inputCode)
|
||||
.SetFromLanguage("C#")
|
||||
.SetToLanguage("Visual Basic")
|
||||
.WithDefaultReferences();
|
||||
return CodeConverter.Convert(codeWithOptions);
|
||||
}
|
||||
|
||||
public static void PerformVBToCSConversion(IServiceProvider serviceProvider, string inputCode)
|
||||
{
|
||||
string convertedText = null;
|
||||
try {
|
||||
var result = TryConvertingVBToCSCode(inputCode);
|
||||
if (!result.Success) {
|
||||
var newLines = Environment.NewLine + Environment.NewLine;
|
||||
VsShellUtilities.ShowMessageBox(
|
||||
serviceProvider,
|
||||
$"Selected VB code seems to have errors or to be incomplete:{newLines}{result.GetExceptionsAsString()}",
|
||||
VBToCSConversionTitle,
|
||||
OLEMSGICON.OLEMSGICON_WARNING,
|
||||
OLEMSGBUTTON.OLEMSGBUTTON_OK,
|
||||
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
|
||||
return;
|
||||
}
|
||||
|
||||
convertedText = result.ConvertedCode;
|
||||
} catch (Exception ex) {
|
||||
VisualStudioInteraction.ShowException(serviceProvider, VBToCSConversionTitle, ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Direct output for debugging
|
||||
//string message = convertedText;
|
||||
//VsShellUtilities.ShowMessageBox(
|
||||
// serviceProvider,
|
||||
// message,
|
||||
// VBToCSConversionTitle,
|
||||
// OLEMSGICON.OLEMSGICON_INFO,
|
||||
// OLEMSGBUTTON.OLEMSGBUTTON_OK,
|
||||
// OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
|
||||
|
||||
WriteStatusBarText(serviceProvider, "Copied converted C# code to clipboard.");
|
||||
|
||||
Clipboard.SetText(convertedText);
|
||||
}
|
||||
|
||||
static ConversionResult TryConvertingVBToCSCode(string inputCode)
|
||||
{
|
||||
var codeWithOptions = new CodeWithOptions(inputCode)
|
||||
.SetFromLanguage("Visual Basic", 14)
|
||||
.SetToLanguage("C#", 6)
|
||||
.WithDefaultReferences();
|
||||
return CodeConverter.Convert(codeWithOptions);
|
||||
}
|
||||
|
||||
static void WriteStatusBarText(IServiceProvider serviceProvider, string text)
|
||||
{
|
||||
IVsStatusbar statusBar = (IVsStatusbar)serviceProvider.GetService(typeof(SVsStatusbar));
|
||||
if (statusBar == null)
|
||||
return;
|
||||
|
||||
int frozen;
|
||||
statusBar.IsFrozen(out frozen);
|
||||
if (frozen != 0) {
|
||||
statusBar.FreezeOutput(0);
|
||||
}
|
||||
|
||||
statusBar.SetText(text);
|
||||
|
||||
statusBar.FreezeOutput(1);
|
||||
}
|
||||
|
||||
static IWpfTextViewHost GetCurrentCSViewHost(IServiceProvider serviceProvider)
|
||||
{
|
||||
IWpfTextViewHost viewHost = VisualStudioInteraction.GetCurrentViewHost(serviceProvider);
|
||||
if (viewHost == null)
|
||||
return null;
|
||||
|
||||
ITextDocument textDocument = viewHost.GetTextDocument();
|
||||
if ((textDocument == null) || !IsCSFileName(textDocument.FilePath))
|
||||
return null;
|
||||
|
||||
return viewHost;
|
||||
}
|
||||
|
||||
public static bool IsCSFileName(string fileName)
|
||||
{
|
||||
return fileName.EndsWith(".cs", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static ITextSelection GetCSSelectionInCurrentView(IServiceProvider serviceProvider)
|
||||
{
|
||||
IWpfTextViewHost viewHost = GetCurrentCSViewHost(serviceProvider);
|
||||
if (viewHost == null)
|
||||
return null;
|
||||
|
||||
return viewHost.TextView.Selection;
|
||||
}
|
||||
|
||||
static IWpfTextViewHost GetCurrentVBViewHost(IServiceProvider serviceProvider)
|
||||
{
|
||||
IWpfTextViewHost viewHost = VisualStudioInteraction.GetCurrentViewHost(serviceProvider);
|
||||
if (viewHost == null)
|
||||
return null;
|
||||
|
||||
ITextDocument textDocument = viewHost.GetTextDocument();
|
||||
if ((textDocument == null) || !IsVBFileName(textDocument.FilePath))
|
||||
return null;
|
||||
|
||||
return viewHost;
|
||||
}
|
||||
|
||||
public static bool IsVBFileName(string fileName)
|
||||
{
|
||||
return fileName.EndsWith(".vb", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static ITextSelection GetVBSelectionInCurrentView(IServiceProvider serviceProvider)
|
||||
{
|
||||
IWpfTextViewHost viewHost = GetCurrentVBViewHost(serviceProvider);
|
||||
if (viewHost == null)
|
||||
return null;
|
||||
|
||||
return viewHost.TextView.Selection;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using System.IO;
|
||||
|
||||
namespace RefactoringEssentials.VsExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Command handler
|
||||
/// </summary>
|
||||
internal sealed class ConvertCSToVBCommand
|
||||
{
|
||||
public const int MainMenuCommandId = 0x0100;
|
||||
public const int CtxMenuCommandId = 0x0101;
|
||||
public const int ProjectItemCtxMenuCommandId = 0x0102;
|
||||
|
||||
/// <summary>
|
||||
/// Command menu group (command set GUID).
|
||||
/// </summary>
|
||||
public static readonly Guid CommandSet = new Guid("a3378a21-e939-40c9-9e4b-eb0cec7b7854");
|
||||
|
||||
/// <summary>
|
||||
/// VS Package that provides this command, not null.
|
||||
/// </summary>
|
||||
readonly REConverterPackage package;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the command.
|
||||
/// </summary>
|
||||
public static ConvertCSToVBCommand Instance {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service provider from the owner package.
|
||||
/// </summary>
|
||||
IServiceProvider ServiceProvider {
|
||||
get {
|
||||
return this.package;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the singleton instance of the command.
|
||||
/// </summary>
|
||||
/// <param name="package">Owner package, not null.</param>
|
||||
public static void Initialize(REConverterPackage package)
|
||||
{
|
||||
Instance = new ConvertCSToVBCommand(package);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConvertCSToVBCommand"/> class.
|
||||
/// Adds our command handlers for menu (commands must exist in the command table file)
|
||||
/// </summary>
|
||||
/// <param name="package">Owner package, not null.</param>
|
||||
ConvertCSToVBCommand(REConverterPackage package)
|
||||
{
|
||||
if (package == null) {
|
||||
throw new ArgumentNullException(nameof(package));
|
||||
}
|
||||
|
||||
this.package = package;
|
||||
|
||||
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
|
||||
if (commandService != null) {
|
||||
// Command in main menu
|
||||
var menuCommandID = new CommandID(CommandSet, MainMenuCommandId);
|
||||
var menuItem = new OleMenuCommand(CodeEditorMenuItemCallback, menuCommandID);
|
||||
menuItem.BeforeQueryStatus += CodeEditorMenuItem_BeforeQueryStatus;
|
||||
commandService.AddCommand(menuItem);
|
||||
|
||||
// Command in code editor's context menu
|
||||
var ctxMenuCommandID = new CommandID(CommandSet, CtxMenuCommandId);
|
||||
var ctxMenuItem = new OleMenuCommand(CodeEditorMenuItemCallback, ctxMenuCommandID);
|
||||
ctxMenuItem.BeforeQueryStatus += CodeEditorMenuItem_BeforeQueryStatus;
|
||||
commandService.AddCommand(ctxMenuItem);
|
||||
|
||||
// Command in project item context menu
|
||||
var projectItemCtxMenuCommandID = new CommandID(CommandSet, ProjectItemCtxMenuCommandId);
|
||||
var projectItemCtxMenuItem = new OleMenuCommand(ProjectItemMenuItemCallback, projectItemCtxMenuCommandID);
|
||||
projectItemCtxMenuItem.BeforeQueryStatus += ProjectItemMenuItem_BeforeQueryStatus;
|
||||
commandService.AddCommand(projectItemCtxMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEditorMenuItem_BeforeQueryStatus(object sender, EventArgs e)
|
||||
{
|
||||
var menuItem = sender as OleMenuCommand;
|
||||
if (menuItem != null) {
|
||||
|
||||
menuItem.Visible = !CodeConversion.GetCSSelectionInCurrentView(ServiceProvider)?.StreamSelectionSpan.IsEmpty ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectItemMenuItem_BeforeQueryStatus(object sender, EventArgs e)
|
||||
{
|
||||
var menuItem = sender as OleMenuCommand;
|
||||
if (menuItem != null) {
|
||||
menuItem.Visible = false;
|
||||
menuItem.Enabled = false;
|
||||
|
||||
string itemPath = VisualStudioInteraction.GetSingleSelectedItemPath();
|
||||
var fileInfo = new FileInfo(itemPath);
|
||||
if (!CodeConversion.IsCSFileName(fileInfo.Name))
|
||||
return;
|
||||
|
||||
menuItem.Visible = true;
|
||||
menuItem.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEditorMenuItemCallback(object sender, EventArgs e)
|
||||
{
|
||||
string selectedText = CodeConversion.GetCSSelectionInCurrentView(ServiceProvider)?.StreamSelectionSpan.GetText();
|
||||
CodeConversion.PerformCSToVBConversion(ServiceProvider, selectedText);
|
||||
}
|
||||
|
||||
async void ProjectItemMenuItemCallback(object sender, EventArgs e)
|
||||
{
|
||||
string itemPath = VisualStudioInteraction.GetSingleSelectedItemPath();
|
||||
var fileInfo = new FileInfo(itemPath);
|
||||
if (!CodeConversion.IsCSFileName(fileInfo.Name))
|
||||
return;
|
||||
|
||||
try {
|
||||
using (StreamReader reader = new StreamReader(itemPath)) {
|
||||
string csCode = await reader.ReadToEndAsync();
|
||||
CodeConversion.PerformCSToVBConversion(ServiceProvider, csCode);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
VisualStudioInteraction.ShowException(ServiceProvider, CodeConversion.CSToVBConversionTitle, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using System.IO;
|
||||
|
||||
namespace RefactoringEssentials.VsExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Command handler
|
||||
/// </summary>
|
||||
internal sealed class ConvertVBToCSCommand
|
||||
{
|
||||
public const int MainMenuCommandId = 0x0200;
|
||||
public const int CtxMenuCommandId = 0x0201;
|
||||
public const int ProjectItemCtxMenuCommandId = 0x0202;
|
||||
|
||||
/// <summary>
|
||||
/// Command menu group (command set GUID).
|
||||
/// </summary>
|
||||
public static readonly Guid CommandSet = new Guid("a3378a21-e939-40c9-9e4b-eb0cec7b7854");
|
||||
|
||||
/// <summary>
|
||||
/// VS Package that provides this command, not null.
|
||||
/// </summary>
|
||||
readonly REConverterPackage package;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the command.
|
||||
/// </summary>
|
||||
public static ConvertVBToCSCommand Instance {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service provider from the owner package.
|
||||
/// </summary>
|
||||
IServiceProvider ServiceProvider {
|
||||
get {
|
||||
return this.package;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the singleton instance of the command.
|
||||
/// </summary>
|
||||
/// <param name="package">Owner package, not null.</param>
|
||||
public static void Initialize(REConverterPackage package)
|
||||
{
|
||||
Instance = new ConvertVBToCSCommand(package);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConvertVBToCSCommand"/> class.
|
||||
/// Adds our command handlers for menu (commands must exist in the command table file)
|
||||
/// </summary>
|
||||
/// <param name="package">Owner package, not null.</param>
|
||||
ConvertVBToCSCommand(REConverterPackage package)
|
||||
{
|
||||
if (package == null) {
|
||||
throw new ArgumentNullException(nameof(package));
|
||||
}
|
||||
|
||||
this.package = package;
|
||||
|
||||
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
|
||||
if (commandService != null) {
|
||||
// Command in main menu
|
||||
var menuCommandID = new CommandID(CommandSet, MainMenuCommandId);
|
||||
var menuItem = new OleMenuCommand(CodeEditorMenuItemCallback, menuCommandID);
|
||||
menuItem.BeforeQueryStatus += CodeEditorMenuItem_BeforeQueryStatus;
|
||||
commandService.AddCommand(menuItem);
|
||||
|
||||
// Command in code editor's context menu
|
||||
var ctxMenuCommandID = new CommandID(CommandSet, CtxMenuCommandId);
|
||||
var ctxMenuItem = new OleMenuCommand(CodeEditorMenuItemCallback, ctxMenuCommandID);
|
||||
ctxMenuItem.BeforeQueryStatus += CodeEditorMenuItem_BeforeQueryStatus;
|
||||
commandService.AddCommand(ctxMenuItem);
|
||||
|
||||
// Command in project item context menu
|
||||
var projectItemCtxMenuCommandID = new CommandID(CommandSet, ProjectItemCtxMenuCommandId);
|
||||
var projectItemCtxMenuItem = new OleMenuCommand(ProjectItemMenuItemCallback, projectItemCtxMenuCommandID);
|
||||
projectItemCtxMenuItem.BeforeQueryStatus += ProjectItemMenuItem_BeforeQueryStatus;
|
||||
commandService.AddCommand(projectItemCtxMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEditorMenuItem_BeforeQueryStatus(object sender, EventArgs e)
|
||||
{
|
||||
var menuItem = sender as OleMenuCommand;
|
||||
if (menuItem != null) {
|
||||
|
||||
menuItem.Visible = !CodeConversion.GetVBSelectionInCurrentView(ServiceProvider)?.StreamSelectionSpan.IsEmpty ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectItemMenuItem_BeforeQueryStatus(object sender, EventArgs e)
|
||||
{
|
||||
var menuItem = sender as OleMenuCommand;
|
||||
if (menuItem != null) {
|
||||
menuItem.Visible = false;
|
||||
menuItem.Enabled = false;
|
||||
|
||||
string itemPath = VisualStudioInteraction.GetSingleSelectedItemPath();
|
||||
var fileInfo = new FileInfo(itemPath);
|
||||
if (!CodeConversion.IsVBFileName(fileInfo.Name))
|
||||
return;
|
||||
|
||||
menuItem.Visible = true;
|
||||
menuItem.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEditorMenuItemCallback(object sender, EventArgs e)
|
||||
{
|
||||
string selectedText = CodeConversion.GetVBSelectionInCurrentView(ServiceProvider)?.StreamSelectionSpan.GetText();
|
||||
CodeConversion.PerformVBToCSConversion(ServiceProvider, selectedText);
|
||||
}
|
||||
|
||||
async void ProjectItemMenuItemCallback(object sender, EventArgs e)
|
||||
{
|
||||
string itemPath = VisualStudioInteraction.GetSingleSelectedItemPath();
|
||||
var fileInfo = new FileInfo(itemPath);
|
||||
if (!CodeConversion.IsVBFileName(fileInfo.Name))
|
||||
return;
|
||||
|
||||
try {
|
||||
using (StreamReader reader = new StreamReader(itemPath)) {
|
||||
string csCode = await reader.ReadToEndAsync();
|
||||
CodeConversion.PerformVBToCSConversion(ServiceProvider, csCode);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
VisualStudioInteraction.ShowException(ServiceProvider, CodeConversion.VBToCSConversionTitle, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.3 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 11 KiB |
|
@ -0,0 +1,67 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ConvertCSToVBCommandPackage.cs" company="Company">
|
||||
// Copyright (c) Company. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.VisualStudio;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
|
||||
namespace RefactoringEssentials.VsExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the class that implements the package exposed by this assembly.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The minimum requirement for a class to be considered a valid package for Visual Studio
|
||||
/// is to implement the IVsPackage interface and register itself with the shell.
|
||||
/// This package uses the helper classes defined inside the Managed Package Framework (MPF)
|
||||
/// to do it: it derives from the Package class that provides the implementation of the
|
||||
/// IVsPackage interface and uses the registration attributes defined in the framework to
|
||||
/// register itself and its components with the shell. These attributes tell the pkgdef creation
|
||||
/// utility what data to put into .pkgdef file.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ...> in .vsixmanifest file.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[PackageRegistration(UseManagedResourcesOnly = true)]
|
||||
[InstalledProductRegistration("#110", "#112", "1.0")] // Info on this package for Help/About
|
||||
[ProvideMenuResource("Menus.ctmenu", 1)]
|
||||
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string)]
|
||||
[Guid(REConverterPackage.PackageGuidString)]
|
||||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
|
||||
public sealed class REConverterPackage : Package
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertCSToVBCommandPackage GUID string.
|
||||
/// </summary>
|
||||
public const string PackageGuidString = "60378c8b-d75c-4fb2-aa2b-58609d67f886";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of package class.
|
||||
/// </summary>
|
||||
public REConverterPackage()
|
||||
{
|
||||
// Inside this method you can place any initialization code that does not require
|
||||
// any Visual Studio service because at this point the package object is created but
|
||||
// not sited yet inside Visual Studio environment. The place to do all the other
|
||||
// initialization is the Initialize method.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialization of the package; this method is called right after the package is sited, so this is the place
|
||||
/// where you can put all the initialization code that rely on services provided by VisualStudio.
|
||||
/// </summary>
|
||||
protected override void Initialize()
|
||||
{
|
||||
ConvertCSToVBCommand.Initialize(this);
|
||||
ConvertVBToCSCommand.Initialize(this);
|
||||
base.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
|
||||
<Extern href="stdidcmd.h"/>
|
||||
<Extern href="vsshlids.h"/>
|
||||
|
||||
<Commands package="guidREConverterPackage">
|
||||
<Groups>
|
||||
<Group guid="guidREConverterCommandPackageCmdSet" id="REConverterMenuGroup" priority="0x0600">
|
||||
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_EDIT"/>
|
||||
</Group>
|
||||
<Group guid="guidREConverterCommandPackageCmdSet" id="REConverterCtxMenuGroup" priority="0x0600">
|
||||
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
|
||||
</Group>
|
||||
<Group guid="guidREConverterCommandPackageCmdSet" id="REConverterProjectItemCtxMenuGroup" priority="0x0600">
|
||||
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/>
|
||||
</Group>
|
||||
</Groups>
|
||||
|
||||
<Buttons>
|
||||
<!-- C# to VB convertion commands -->
|
||||
<Button guid="guidREConverterCommandPackageCmdSet" id="ConvertCSToVBCommandId" priority="0x0100" type="Button">
|
||||
<Parent guid="guidREConverterCommandPackageCmdSet" id="REConverterMenuGroup" />
|
||||
<CommandFlag>DefaultInvisible</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
<Strings>
|
||||
<ButtonText>Convert to VB and copy to clipboard</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
<Button guid="guidREConverterCommandPackageCmdSet" id="ConvertCSToVBCtxCommandId" priority="0x0100" type="Button">
|
||||
<Parent guid="guidREConverterCommandPackageCmdSet" id="REConverterCtxMenuGroup" />
|
||||
<CommandFlag>DefaultInvisible</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
<Strings>
|
||||
<ButtonText>Convert to VB and copy to clipboard</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
<Button guid="guidREConverterCommandPackageCmdSet" id="ConvertCSToVBProjectItemCtxCommandId" priority="0x0100" type="Button">
|
||||
<Parent guid="guidREConverterCommandPackageCmdSet" id="REConverterProjectItemCtxMenuGroup" />
|
||||
<CommandFlag>DefaultInvisible</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
<Strings>
|
||||
<ButtonText>Convert to VB and copy to clipboard</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
|
||||
<!-- VB to C# conversion commands -->
|
||||
<Button guid="guidREConverterCommandPackageCmdSet" id="ConvertVBToCSCommandId" priority="0x0100" type="Button">
|
||||
<Parent guid="guidREConverterCommandPackageCmdSet" id="REConverterMenuGroup" />
|
||||
<CommandFlag>DefaultInvisible</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
<Strings>
|
||||
<ButtonText>Convert to C# and copy to clipboard</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
<Button guid="guidREConverterCommandPackageCmdSet" id="ConvertVBToCSCtxCommandId" priority="0x0100" type="Button">
|
||||
<Parent guid="guidREConverterCommandPackageCmdSet" id="REConverterCtxMenuGroup" />
|
||||
<CommandFlag>DefaultInvisible</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
<Strings>
|
||||
<ButtonText>Convert to C# and copy to clipboard</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
<Button guid="guidREConverterCommandPackageCmdSet" id="ConvertVBToCSProjectItemCtxCommandId" priority="0x0100" type="Button">
|
||||
<Parent guid="guidREConverterCommandPackageCmdSet" id="REConverterProjectItemCtxMenuGroup" />
|
||||
<CommandFlag>DefaultInvisible</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
<Strings>
|
||||
<ButtonText>Convert to C# and copy to clipboard</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
</Buttons>
|
||||
</Commands>
|
||||
|
||||
<Symbols>
|
||||
<!-- This is the package guid. -->
|
||||
<GuidSymbol name="guidREConverterPackage" value="{60378c8b-d75c-4fb2-aa2b-58609d67f886}" />
|
||||
|
||||
<!-- This is the guid used to group the menu commands together -->
|
||||
<GuidSymbol name="guidREConverterCommandPackageCmdSet" value="{a3378a21-e939-40c9-9e4b-eb0cec7b7854}">
|
||||
<IDSymbol name="REConverterMenuGroup" value="0x1020" />
|
||||
<IDSymbol name="REConverterCtxMenuGroup" value="0x1021" />
|
||||
<IDSymbol name="REConverterProjectItemCtxMenuGroup" value="0x1022" />
|
||||
<IDSymbol name="ConvertCSToVBCommandId" value="0x0100" />
|
||||
<IDSymbol name="ConvertCSToVBCtxCommandId" value="0x0101" />
|
||||
<IDSymbol name="ConvertCSToVBProjectItemCtxCommandId" value="0x0102" />
|
||||
<IDSymbol name="ConvertVBToCSCommandId" value="0x0200" />
|
||||
<IDSymbol name="ConvertVBToCSCtxCommandId" value="0x0201" />
|
||||
<IDSymbol name="ConvertVBToCSProjectItemCtxCommandId" value="0x0202" />
|
||||
</GuidSymbol>
|
||||
</Symbols>
|
||||
</CommandTable>
|
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
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">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<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" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</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>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="110" xml:space="preserve">
|
||||
<value>Refactoring Essentials</value>
|
||||
</data>
|
||||
<data name="112" xml:space="preserve">
|
||||
<value>Refactoring Essentials Extension Details</value>
|
||||
</data>
|
||||
</root>
|
|
@ -0,0 +1,109 @@
|
|||
using Microsoft.VisualStudio;
|
||||
using Microsoft.VisualStudio.Editor;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using Microsoft.VisualStudio.Shell.Interop;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
using Microsoft.VisualStudio.Text.Editor;
|
||||
using Microsoft.VisualStudio.TextManager.Interop;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RefactoringEssentials.VsExtension
|
||||
{
|
||||
static class VisualStudioInteraction
|
||||
{
|
||||
public static bool GetSingleSelectedItem(out IVsHierarchy hierarchy, out uint itemID)
|
||||
{
|
||||
hierarchy = null;
|
||||
itemID = VSConstants.VSITEMID_NIL;
|
||||
int hresult = VSConstants.S_OK;
|
||||
|
||||
var monitorSelection = Package.GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
|
||||
var solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
|
||||
if ((monitorSelection == null) || (solution == null))
|
||||
return false;
|
||||
|
||||
IVsMultiItemSelect multiItemSelect = null;
|
||||
IntPtr hierarchyPtr = IntPtr.Zero;
|
||||
IntPtr selectionContainerPtr = IntPtr.Zero;
|
||||
|
||||
try {
|
||||
hresult = monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemID, out multiItemSelect, out selectionContainerPtr);
|
||||
if (ErrorHandler.Failed(hresult) || (hierarchyPtr == IntPtr.Zero) || (itemID == VSConstants.VSITEMID_NIL))
|
||||
return false;
|
||||
|
||||
if (multiItemSelect != null)
|
||||
return false;
|
||||
|
||||
if (itemID == VSConstants.VSITEMID_ROOT)
|
||||
return false;
|
||||
|
||||
hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy;
|
||||
if (hierarchy == null)
|
||||
return false;
|
||||
|
||||
Guid guidProjectID = Guid.Empty;
|
||||
|
||||
if (ErrorHandler.Failed(solution.GetGuidOfProject(hierarchy, out guidProjectID)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
if (selectionContainerPtr != IntPtr.Zero) {
|
||||
Marshal.Release(selectionContainerPtr);
|
||||
}
|
||||
|
||||
if (hierarchyPtr != IntPtr.Zero) {
|
||||
Marshal.Release(hierarchyPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSingleSelectedItemPath()
|
||||
{
|
||||
IVsHierarchy hierarchy = null;
|
||||
uint itemID = VSConstants.VSITEMID_NIL;
|
||||
if (!GetSingleSelectedItem(out hierarchy, out itemID))
|
||||
return null;
|
||||
|
||||
string itemPath = null;
|
||||
((IVsProject)hierarchy).GetMkDocument(itemID, out itemPath);
|
||||
return itemPath;
|
||||
}
|
||||
|
||||
public static IWpfTextViewHost GetCurrentViewHost(IServiceProvider serviceProvider)
|
||||
{
|
||||
IVsTextManager txtMgr = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager));
|
||||
IVsTextView vTextView = null;
|
||||
int mustHaveFocus = 1;
|
||||
txtMgr.GetActiveView(mustHaveFocus, null, out vTextView);
|
||||
IVsUserData userData = vTextView as IVsUserData;
|
||||
if (userData == null)
|
||||
return null;
|
||||
|
||||
object holder;
|
||||
Guid guidViewHost = DefGuidList.guidIWpfTextViewHost;
|
||||
userData.GetData(ref guidViewHost, out holder);
|
||||
|
||||
return holder as IWpfTextViewHost;
|
||||
}
|
||||
|
||||
public static ITextDocument GetTextDocument(this IWpfTextViewHost viewHost)
|
||||
{
|
||||
ITextDocument textDocument = null;
|
||||
viewHost.TextView.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument);
|
||||
return textDocument;
|
||||
}
|
||||
|
||||
public static void ShowException(IServiceProvider serviceProvider, string title, Exception ex)
|
||||
{
|
||||
VsShellUtilities.ShowMessageBox(
|
||||
serviceProvider,
|
||||
$"An error has occured during conversion: {ex}",
|
||||
title,
|
||||
OLEMSGICON.OLEMSGICON_CRITICAL,
|
||||
OLEMSGBUTTON.OLEMSGBUTTON_OK,
|
||||
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,321 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!--<Import Project="..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.props" Condition="Exists('..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.props')" />-->
|
||||
<Import Project="..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.props" Condition="Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.props')" />
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}</ProjectGuid>
|
||||
<ProjectTypeGuids>{82B43B9B-A64C-4715-B499-D71E9CA2BD60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>RefactoringEssentials</RootNamespace>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
<UseCodebase>true</UseCodebase>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>14.0</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<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>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<ProjectGuid>{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RefactoringEssentials.VsExtension</RootNamespace>
|
||||
<AssemblyName>RefactoringEssentials.VsExtension.2017</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<GeneratePkgDefFile>true</GeneratePkgDefFile>
|
||||
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
|
||||
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
|
||||
<IncludeDebugSymbolsInLocalVSIXDeployment>true</IncludeDebugSymbolsInLocalVSIXDeployment>
|
||||
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
|
||||
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
|
||||
<VSSDKTargetPlatformRegRootSuffix>Roslyn</VSSDKTargetPlatformRegRootSuffix>
|
||||
</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>
|
||||
<PropertyGroup>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
|
||||
<StartArguments>/rootsuffix Roslyn</StartArguments>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<VSCTCompile Include="REConverterPackage.vsct">
|
||||
<ResourceName>Menus.ctmenu</ResourceName>
|
||||
<SubType>Designer</SubType>
|
||||
</VSCTCompile>
|
||||
<Content Include="Images\refactoringessentials-logo90.png">
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\refactoringessentials-preview.png">
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="license.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<None Include="source.extension.vsixmanifest" />
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="EnvDTE100, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="EnvDTE90, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Build.Framework" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualStudio.CommandBars, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.CoreUtility.15.0.26201\lib\net45\Microsoft.VisualStudio.CoreUtility.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Editor, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Editor.15.0.26201\lib\net45\Microsoft.VisualStudio.Editor.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Imaging, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Imaging.15.0.26201\lib\net45\Microsoft.VisualStudio.Imaging.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.14.0.14.3.25407\lib\Microsoft.VisualStudio.Shell.14.0.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Immutable.10.0.10.0.30319\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Immutable.12.0.12.0.21003\lib\net45\Microsoft.VisualStudio.Shell.Immutable.12.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.10.0.10.0.30319\lib\Microsoft.VisualStudio.Shell.Interop.10.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.Shell.Interop.12.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Text.Data.15.0.26201\lib\net45\Microsoft.VisualStudio.Text.Data.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Text.Logic.15.0.26201\lib\net45\Microsoft.VisualStudio.Text.Logic.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Text.UI.15.0.26201\lib\net45\Microsoft.VisualStudio.Text.UI.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Text.UI.Wpf.15.0.26201\lib\net45\Microsoft.VisualStudio.Text.UI.Wpf.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Threading, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Threading.15.0.240\lib\net45\Microsoft.VisualStudio.Threading.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Utilities.15.0.26201\lib\net45\Microsoft.VisualStudio.Utilities.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.Validation, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.VisualStudio.Validation.15.0.82\lib\net45\Microsoft.VisualStudio.Validation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CodeConversion.cs" />
|
||||
<Compile Include="ConvertCSToVBCommand.cs" />
|
||||
<Compile Include="ConvertVBToCSCommand.cs" />
|
||||
<Compile Include="REConverterPackage.cs" />
|
||||
<Compile Include="VisualStudioInteraction.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="VSPackage.resx">
|
||||
<MergeWithCTO>true</MergeWithCTO>
|
||||
<ManifestResourceName>VSPackage</ManifestResourceName>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ICSharpCode.CodeConverter\ICSharpCode.CodeConverter.csproj">
|
||||
<Project>{7ea075c6-6406-445c-ab77-6c47aff88d58}</Project>
|
||||
<Name>ICSharpCode.CodeConverter</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- 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>
|
||||
-->
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Mono_Debug|AnyCPU' ">
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug_Mono.2017</OutputPath>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AssemblyName>Vsix</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Mono_Release|AnyCPU' ">
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Mono_Release.2017</OutputPath>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AssemblyName>Vsix</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets')" />
|
||||
<!--<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.VSSDK.BuildTools.14.2.25123\build\Microsoft.VSSDK.BuildTools.targets')" />-->
|
||||
<!--<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.14.1.24720\build\Microsoft.VSSDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.14.1.24720\build\Microsoft.VSSDK.BuildTools.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.14.1.24720\build\Microsoft.VSSDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.14.1.24720\build\Microsoft.VSSDK.BuildTools.targets'))" />
|
||||
</Target>-->
|
||||
</Project>
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.CodeAnalysis.VisualBasic" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.VisualStudio.Utilities" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-15.0.0.0" newVersion="15.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.VisualStudio.CoreUtility" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-15.0.0.0" newVersion="15.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.VisualStudio.Threading" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-15.0.0.0" newVersion="15.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.VisualStudio.Imaging" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-15.0.0.0" newVersion="15.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup></configuration>
|
|
@ -0,0 +1,9 @@
|
|||
MIT license
|
||||
|
||||
Copyright (c) 2011-2016 AlphaSierraPapa for the SharpDevelop team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.VisualStudio.CoreUtility" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Editor" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Imaging" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.OLE.Interop" version="7.10.6070" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.14.0" version="14.3.25407" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Immutable.10.0" version="10.0.30319" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Immutable.11.0" version="11.0.50727" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Immutable.12.0" version="12.0.21003" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Immutable.14.0" version="14.3.25407" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Interop" version="7.10.6071" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Interop.10.0" version="10.0.30319" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Interop.11.0" version="11.0.61030" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Interop.12.0" version="12.0.30110" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Interop.8.0" version="8.0.50727" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Shell.Interop.9.0" version="9.0.30729" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Text.Data" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Text.Logic" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Text.UI" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Text.UI.Wpf" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.TextManager.Interop" version="7.10.6070" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.TextManager.Interop.8.0" version="8.0.50727" targetFramework="net45" />
|
||||
<package id="Microsoft.VisualStudio.Threading" version="15.0.240" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Utilities" version="15.0.26201" targetFramework="net461" />
|
||||
<package id="Microsoft.VisualStudio.Validation" version="15.0.82" targetFramework="net461" />
|
||||
<package id="Microsoft.VSSDK.BuildTools" version="15.1.192" targetFramework="net461" developmentDependency="true" />
|
||||
</packages>
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
|
||||
<Metadata>
|
||||
<Identity Id="CodeConverter.Vsix.7e2a69d6-193b-4cdf-878d-3370d5931942" Version="5.4.0.0" Language="en-US" Publisher="IC#Code"/>
|
||||
<DisplayName>Code Converter C# to/from VB.NET</DisplayName>
|
||||
<Description xml:space="preserve">Based on Roslyn, this converter allows you to convert C# code to VB.NET and vice versa</Description>
|
||||
<License>license.txt</License>
|
||||
<GettingStartedGuide>https://github.com/icsharpcode/CodeConverter</GettingStartedGuide>
|
||||
<ReleaseNotes>https://github.com/icsharpcode/CodeConverter</ReleaseNotes>
|
||||
<Icon>Images\refactoringessentials-logo90.png</Icon>
|
||||
<PreviewImage>Images\refactoringessentials-preview.png</PreviewImage>
|
||||
</Metadata>
|
||||
<Installation>
|
||||
<InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Pro" />
|
||||
<InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Community" />
|
||||
<InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" />
|
||||
</Installation>
|
||||
<Dependencies>
|
||||
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
|
||||
<!--<Dependency Id="Microsoft.VisualStudio.MPF.14.0" DisplayName="Visual Studio MPF 14.0" d:Source="Installed" Version="[14.0]" />-->
|
||||
</Dependencies>
|
||||
<Assets>
|
||||
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
|
||||
</Assets>
|
||||
<Prerequisites>
|
||||
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0.26004.1,16.0)" DisplayName="Visual Studio core editor" />
|
||||
</Prerequisites>
|
||||
</PackageManifest>
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace CodeConverterWebApp
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
public static void RegisterRoutes(RouteCollection routes)
|
||||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
routes.MapRoute(
|
||||
name: "Default",
|
||||
url: "{controller}/{action}/{id}",
|
||||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,255 @@
|
|||
using System.Web.Http;
|
||||
using WebActivatorEx;
|
||||
using CodeConverterWebApp;
|
||||
using Swashbuckle.Application;
|
||||
|
||||
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
|
||||
|
||||
namespace CodeConverterWebApp
|
||||
{
|
||||
public class SwaggerConfig
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
var thisAssembly = typeof(SwaggerConfig).Assembly;
|
||||
|
||||
GlobalConfiguration.Configuration
|
||||
.EnableSwagger(c =>
|
||||
{
|
||||
// By default, the service root url is inferred from the request used to access the docs.
|
||||
// However, there may be situations (e.g. proxy and load-balanced environments) where this does not
|
||||
// resolve correctly. You can workaround this by providing your own code to determine the root URL.
|
||||
//
|
||||
//c.RootUrl(req => GetRootUrlFromAppConfig());
|
||||
|
||||
// If schemes are not explicitly provided in a Swagger 2.0 document, then the scheme used to access
|
||||
// the docs is taken as the default. If your API supports multiple schemes and you want to be explicit
|
||||
// about them, you can use the "Schemes" option as shown below.
|
||||
//
|
||||
//c.Schemes(new[] { "http", "https" });
|
||||
|
||||
// Use "SingleApiVersion" to describe a single version API. Swagger 2.0 includes an "Info" object to
|
||||
// hold additional metadata for an API. Version and title are required but you can also provide
|
||||
// additional fields by chaining methods off SingleApiVersion.
|
||||
//
|
||||
c.SingleApiVersion("v1", "CodeConverterWebApp");
|
||||
|
||||
// If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option.
|
||||
//
|
||||
//c.PrettyPrint();
|
||||
|
||||
// If your API has multiple versions, use "MultipleApiVersions" instead of "SingleApiVersion".
|
||||
// In this case, you must provide a lambda that tells Swashbuckle which actions should be
|
||||
// included in the docs for a given API version. Like "SingleApiVersion", each call to "Version"
|
||||
// returns an "Info" builder so you can provide additional metadata per API version.
|
||||
//
|
||||
//c.MultipleApiVersions(
|
||||
// (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion),
|
||||
// (vc) =>
|
||||
// {
|
||||
// vc.Version("v2", "Swashbuckle Dummy API V2");
|
||||
// vc.Version("v1", "Swashbuckle Dummy API V1");
|
||||
// });
|
||||
|
||||
// You can use "BasicAuth", "ApiKey" or "OAuth2" options to describe security schemes for the API.
|
||||
// See https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md for more details.
|
||||
// NOTE: These only define the schemes and need to be coupled with a corresponding "security" property
|
||||
// at the document or operation level to indicate which schemes are required for an operation. To do this,
|
||||
// you'll need to implement a custom IDocumentFilter and/or IOperationFilter to set these properties
|
||||
// according to your specific authorization implementation
|
||||
//
|
||||
//c.BasicAuth("basic")
|
||||
// .Description("Basic HTTP Authentication");
|
||||
//
|
||||
// NOTE: You must also configure 'EnableApiKeySupport' below in the SwaggerUI section
|
||||
//c.ApiKey("apiKey")
|
||||
// .Description("API Key Authentication")
|
||||
// .Name("apiKey")
|
||||
// .In("header");
|
||||
//
|
||||
//c.OAuth2("oauth2")
|
||||
// .Description("OAuth2 Implicit Grant")
|
||||
// .Flow("implicit")
|
||||
// .AuthorizationUrl("http://petstore.swagger.wordnik.com/api/oauth/dialog")
|
||||
// //.TokenUrl("https://tempuri.org/token")
|
||||
// .Scopes(scopes =>
|
||||
// {
|
||||
// scopes.Add("read", "Read access to protected resources");
|
||||
// scopes.Add("write", "Write access to protected resources");
|
||||
// });
|
||||
|
||||
// Set this flag to omit descriptions for any actions decorated with the Obsolete attribute
|
||||
//c.IgnoreObsoleteActions();
|
||||
|
||||
// Each operation be assigned one or more tags which are then used by consumers for various reasons.
|
||||
// For example, the swagger-ui groups operations according to the first tag of each operation.
|
||||
// By default, this will be controller name but you can use the "GroupActionsBy" option to
|
||||
// override with any value.
|
||||
//
|
||||
//c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString());
|
||||
|
||||
// You can also specify a custom sort order for groups (as defined by "GroupActionsBy") to dictate
|
||||
// the order in which operations are listed. For example, if the default grouping is in place
|
||||
// (controller name) and you specify a descending alphabetic sort order, then actions from a
|
||||
// ProductsController will be listed before those from a CustomersController. This is typically
|
||||
// used to customize the order of groupings in the swagger-ui.
|
||||
//
|
||||
//c.OrderActionGroupsBy(new DescendingAlphabeticComparer());
|
||||
|
||||
// If you annotate Controllers and API Types with
|
||||
// Xml comments (http://msdn.microsoft.com/en-us/library/b2s063f7(v=vs.110).aspx), you can incorporate
|
||||
// those comments into the generated docs and UI. You can enable this by providing the path to one or
|
||||
// more Xml comment files.
|
||||
//
|
||||
//c.IncludeXmlComments(GetXmlCommentsPath());
|
||||
|
||||
// Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types
|
||||
// exposed in your API. However, there may be occasions when more control of the output is needed.
|
||||
// This is supported through the "MapType" and "SchemaFilter" options:
|
||||
//
|
||||
// Use the "MapType" option to override the Schema generation for a specific type.
|
||||
// It should be noted that the resulting Schema will be placed "inline" for any applicable Operations.
|
||||
// While Swagger 2.0 supports inline definitions for "all" Schema types, the swagger-ui tool does not.
|
||||
// It expects "complex" Schemas to be defined separately and referenced. For this reason, you should only
|
||||
// use the "MapType" option when the resulting Schema is a primitive or array type. If you need to alter a
|
||||
// complex Schema, use a Schema filter.
|
||||
//
|
||||
//c.MapType<ProductType>(() => new Schema { type = "integer", format = "int32" });
|
||||
|
||||
// If you want to post-modify "complex" Schemas once they've been generated, across the board or for a
|
||||
// specific type, you can wire up one or more Schema filters.
|
||||
//
|
||||
//c.SchemaFilter<ApplySchemaVendorExtensions>();
|
||||
|
||||
// In a Swagger 2.0 document, complex types are typically declared globally and referenced by unique
|
||||
// Schema Id. By default, Swashbuckle does NOT use the full type name in Schema Ids. In most cases, this
|
||||
// works well because it prevents the "implementation detail" of type namespaces from leaking into your
|
||||
// Swagger docs and UI. However, if you have multiple types in your API with the same class name, you'll
|
||||
// need to opt out of this behavior to avoid Schema Id conflicts.
|
||||
//
|
||||
//c.UseFullTypeNameInSchemaIds();
|
||||
|
||||
// Alternatively, you can provide your own custom strategy for inferring SchemaId's for
|
||||
// describing "complex" types in your API.
|
||||
//
|
||||
//c.SchemaId(t => t.FullName.Contains('`') ? t.FullName.Substring(0, t.FullName.IndexOf('`')) : t.FullName);
|
||||
|
||||
// Set this flag to omit schema property descriptions for any type properties decorated with the
|
||||
// Obsolete attribute
|
||||
//c.IgnoreObsoleteProperties();
|
||||
|
||||
// In accordance with the built in JsonSerializer, Swashbuckle will, by default, describe enums as integers.
|
||||
// You can change the serializer behavior by configuring the StringToEnumConverter globally or for a given
|
||||
// enum type. Swashbuckle will honor this change out-of-the-box. However, if you use a different
|
||||
// approach to serialize enums as strings, you can also force Swashbuckle to describe them as strings.
|
||||
//
|
||||
//c.DescribeAllEnumsAsStrings();
|
||||
|
||||
// Similar to Schema filters, Swashbuckle also supports Operation and Document filters:
|
||||
//
|
||||
// Post-modify Operation descriptions once they've been generated by wiring up one or more
|
||||
// Operation filters.
|
||||
//
|
||||
//c.OperationFilter<AddDefaultResponse>();
|
||||
//
|
||||
// If you've defined an OAuth2 flow as described above, you could use a custom filter
|
||||
// to inspect some attribute on each action and infer which (if any) OAuth2 scopes are required
|
||||
// to execute the operation
|
||||
//
|
||||
//c.OperationFilter<AssignOAuth2SecurityRequirements>();
|
||||
|
||||
// Post-modify the entire Swagger document by wiring up one or more Document filters.
|
||||
// This gives full control to modify the final SwaggerDocument. You should have a good understanding of
|
||||
// the Swagger 2.0 spec. - https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md
|
||||
// before using this option.
|
||||
//
|
||||
//c.DocumentFilter<ApplyDocumentVendorExtensions>();
|
||||
|
||||
// In contrast to WebApi, Swagger 2.0 does not include the query string component when mapping a URL
|
||||
// to an action. As a result, Swashbuckle will raise an exception if it encounters multiple actions
|
||||
// with the same path (sans query string) and HTTP method. You can workaround this by providing a
|
||||
// custom strategy to pick a winner or merge the descriptions for the purposes of the Swagger docs
|
||||
//
|
||||
//c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
|
||||
|
||||
// Wrap the default SwaggerGenerator with additional behavior (e.g. caching) or provide an
|
||||
// alternative implementation for ISwaggerProvider with the CustomProvider option.
|
||||
//
|
||||
//c.CustomProvider((defaultProvider) => new CachingSwaggerProvider(defaultProvider));
|
||||
})
|
||||
.EnableSwaggerUi(c =>
|
||||
{
|
||||
// Use the "DocumentTitle" option to change the Document title.
|
||||
// Very helpful when you have multiple Swagger pages open, to tell them apart.
|
||||
//
|
||||
//c.DocumentTitle("My Swagger UI");
|
||||
|
||||
// Use the "InjectStylesheet" option to enrich the UI with one or more additional CSS stylesheets.
|
||||
// The file must be included in your project as an "Embedded Resource", and then the resource's
|
||||
// "Logical Name" is passed to the method as shown below.
|
||||
//
|
||||
//c.InjectStylesheet(containingAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testStyles1.css");
|
||||
|
||||
// Use the "InjectJavaScript" option to invoke one or more custom JavaScripts after the swagger-ui
|
||||
// has loaded. The file must be included in your project as an "Embedded Resource", and then the resource's
|
||||
// "Logical Name" is passed to the method as shown above.
|
||||
//
|
||||
//c.InjectJavaScript(thisAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testScript1.js");
|
||||
|
||||
// The swagger-ui renders boolean data types as a dropdown. By default, it provides "true" and "false"
|
||||
// strings as the possible choices. You can use this option to change these to something else,
|
||||
// for example 0 and 1.
|
||||
//
|
||||
//c.BooleanValues(new[] { "0", "1" });
|
||||
|
||||
// By default, swagger-ui will validate specs against swagger.io's online validator and display the result
|
||||
// in a badge at the bottom of the page. Use these options to set a different validator URL or to disable the
|
||||
// feature entirely.
|
||||
//c.SetValidatorUrl("http://localhost/validator");
|
||||
//c.DisableValidator();
|
||||
|
||||
// Use this option to control how the Operation listing is displayed.
|
||||
// It can be set to "None" (default), "List" (shows operations for each resource),
|
||||
// or "Full" (fully expanded: shows operations and their details).
|
||||
//
|
||||
//c.DocExpansion(DocExpansion.List);
|
||||
|
||||
// Specify which HTTP operations will have the 'Try it out!' option. An empty paramter list disables
|
||||
// it for all operations.
|
||||
//
|
||||
//c.SupportedSubmitMethods("GET", "HEAD");
|
||||
|
||||
// Use the CustomAsset option to provide your own version of assets used in the swagger-ui.
|
||||
// It's typically used to instruct Swashbuckle to return your version instead of the default
|
||||
// when a request is made for "index.html". As with all custom content, the file must be included
|
||||
// in your project as an "Embedded Resource", and then the resource's "Logical Name" is passed to
|
||||
// the method as shown below.
|
||||
//
|
||||
//c.CustomAsset("index", containingAssembly, "YourWebApiProject.SwaggerExtensions.index.html");
|
||||
|
||||
// If your API has multiple versions and you've applied the MultipleApiVersions setting
|
||||
// as described above, you can also enable a select box in the swagger-ui, that displays
|
||||
// a discovery URL for each version. This provides a convenient way for users to browse documentation
|
||||
// for different API versions.
|
||||
//
|
||||
//c.EnableDiscoveryUrlSelector();
|
||||
|
||||
// If your API supports the OAuth2 Implicit flow, and you've described it correctly, according to
|
||||
// the Swagger 2.0 specification, you can enable UI support as shown below.
|
||||
//
|
||||
//c.EnableOAuth2Support(
|
||||
// clientId: "test-client-id",
|
||||
// clientSecret: null,
|
||||
// realm: "test-realm",
|
||||
// appName: "Swagger UI"
|
||||
// //additionalQueryStringParams: new Dictionary<string, string>() { { "foo", "bar" } }
|
||||
//);
|
||||
|
||||
// If your API supports ApiKey, you can override the default values.
|
||||
// "apiKeyIn" can either be "query" or "header"
|
||||
//
|
||||
//c.EnableApiKeySupport("apiKey", "header");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace CodeConverterWebApp
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
// Web API configuration and services
|
||||
|
||||
// Web API routes
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,363 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" />
|
||||
<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>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D1FF18B5-68A8-439B-9D00-C35258AA7833}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CodeConverterWebApp</RootNamespace>
|
||||
<AssemblyName>CodeConverterWebApp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<Use64BitIISExpress />
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</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\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Esent.Interop, Version=1.9.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ManagedEsent.1.9.4\lib\net40\Esent.Interop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.VisualBasic, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.VisualBasic.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.6.1\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.Workspaces.Desktop, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.6.1\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Swashbuckle.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cd1bb07a5ac7c7bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Swashbuckle.Core.5.6.0\lib\net40\Swashbuckle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.AppContext">
|
||||
<HintPath>..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=1.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Composition.AttributedModel, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.AttributedModel.1.1.0\lib\netstandard2.0\System.Composition.AttributedModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.Convention, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.Convention.1.1.0\lib\netstandard2.0\System.Composition.Convention.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.Hosting, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.Hosting.1.1.0\lib\netstandard2.0\System.Composition.Hosting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.Runtime, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.Runtime.1.1.0\lib\netstandard2.0\System.Composition.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Composition.TypedParts, Version=1.0.32.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Composition.TypedParts.1.1.0\lib\netstandard2.0\System.Composition.TypedParts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Console">
|
||||
<HintPath>..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Diagnostics.FileVersionInfo">
|
||||
<HintPath>..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Diagnostics.StackTrace, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO">
|
||||
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem">
|
||||
<HintPath>..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem.Primitives">
|
||||
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Linq">
|
||||
<HintPath>..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Linq.Expressions">
|
||||
<HintPath>..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Reflection">
|
||||
<HintPath>..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Reflection.Metadata, Version=1.4.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.Metadata.1.5.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime">
|
||||
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Extensions">
|
||||
<HintPath>..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.InteropServices">
|
||||
<HintPath>..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Encoding">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Primitives">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.X509Certificates">
|
||||
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encoding.CodePages, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encoding.CodePages.4.4.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Thread">
|
||||
<HintPath>..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple">
|
||||
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml.ReaderWriter">
|
||||
<HintPath>..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XmlDocument">
|
||||
<HintPath>..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XPath">
|
||||
<HintPath>..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XPath.XDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="WebActivatorEx, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7b26dc2a43f6a0d4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\WebActivatorEx.2.2.0\lib\net40\WebActivatorEx.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\bootstrap-theme.css" />
|
||||
<Content Include="Content\bootstrap-theme.min.css" />
|
||||
<Content Include="Content\bootstrap.css" />
|
||||
<Content Include="Content\bootstrap.min.css" />
|
||||
<Content Include="Content\site.css" />
|
||||
<Content Include="favicon.ico" />
|
||||
<Content Include="fonts\glyphicons-halflings-regular.svg" />
|
||||
<Content Include="Global.asax" />
|
||||
<Content Include="Images\refactoringessentials-logo.png" />
|
||||
<Content Include="robots.txt" />
|
||||
<Content Include="fonts\glyphicons-halflings-regular.woff2" />
|
||||
<Content Include="fonts\glyphicons-halflings-regular.woff" />
|
||||
<Content Include="fonts\glyphicons-halflings-regular.ttf" />
|
||||
<Content Include="fonts\glyphicons-halflings-regular.eot" />
|
||||
<Content Include="Content\bootstrap.min.css.map" />
|
||||
<Content Include="Content\bootstrap.css.map" />
|
||||
<Content Include="Content\bootstrap-theme.min.css.map" />
|
||||
<Content Include="Content\bootstrap-theme.css.map" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\PublishProfiles\roslyncodeconverter-Deployment - Web Deploy.pubxml" />
|
||||
<Content Include="Scripts\angular-mocks.js" />
|
||||
<Content Include="Scripts\angular.js" />
|
||||
<Content Include="Scripts\angular.min.js" />
|
||||
<None Include="Scripts\jquery-2.2.2.intellisense.js" />
|
||||
<Content Include="Scripts\bootstrap.js" />
|
||||
<Content Include="Scripts\bootstrap.min.js" />
|
||||
<Content Include="Scripts\jquery-2.2.2.js" />
|
||||
<Content Include="Scripts\jquery-2.2.2.min.js" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\_ViewStart.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="App_Start\SwaggerConfig.cs" />
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Controllers\ConverterController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\ConvertRequest.cs" />
|
||||
<Compile Include="Models\ConvertResponse.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\web.config" />
|
||||
<Content Include="Views\Shared\_Layout.cshtml" />
|
||||
<Content Include="Views\Home\Index.cshtml" />
|
||||
<Content Include="Views\Home\About.cshtml" />
|
||||
<Content Include="Scripts\angular.min.js.map" />
|
||||
<Content Include="Scripts\jquery-2.2.2.min.map" />
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
<None Include="Web.Release.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ICSharpCode.CodeConverter\ICSharpCode.CodeConverter.csproj">
|
||||
<Project>{7ea075c6-6406-445c-ab77-6c47aff88d58}</Project>
|
||||
<Name>ICSharpCode.CodeConverter</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>16032</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:16032/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
|
||||
</Target>
|
||||
<!-- 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>
|
|
@ -0,0 +1,587 @@
|
|||
/*!
|
||||
* Bootstrap v3.3.6 (http://getbootstrap.com)
|
||||
* Copyright 2011-2015 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
*/
|
||||
.btn-default,
|
||||
.btn-primary,
|
||||
.btn-success,
|
||||
.btn-info,
|
||||
.btn-warning,
|
||||
.btn-danger {
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
|
||||
}
|
||||
.btn-default:active,
|
||||
.btn-primary:active,
|
||||
.btn-success:active,
|
||||
.btn-info:active,
|
||||
.btn-warning:active,
|
||||
.btn-danger:active,
|
||||
.btn-default.active,
|
||||
.btn-primary.active,
|
||||
.btn-success.active,
|
||||
.btn-info.active,
|
||||
.btn-warning.active,
|
||||
.btn-danger.active {
|
||||
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
|
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
|
||||
}
|
||||
.btn-default.disabled,
|
||||
.btn-primary.disabled,
|
||||
.btn-success.disabled,
|
||||
.btn-info.disabled,
|
||||
.btn-warning.disabled,
|
||||
.btn-danger.disabled,
|
||||
.btn-default[disabled],
|
||||
.btn-primary[disabled],
|
||||
.btn-success[disabled],
|
||||
.btn-info[disabled],
|
||||
.btn-warning[disabled],
|
||||
.btn-danger[disabled],
|
||||
fieldset[disabled] .btn-default,
|
||||
fieldset[disabled] .btn-primary,
|
||||
fieldset[disabled] .btn-success,
|
||||
fieldset[disabled] .btn-info,
|
||||
fieldset[disabled] .btn-warning,
|
||||
fieldset[disabled] .btn-danger {
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.btn-default .badge,
|
||||
.btn-primary .badge,
|
||||
.btn-success .badge,
|
||||
.btn-info .badge,
|
||||
.btn-warning .badge,
|
||||
.btn-danger .badge {
|
||||
text-shadow: none;
|
||||
}
|
||||
.btn:active,
|
||||
.btn.active {
|
||||
background-image: none;
|
||||
}
|
||||
.btn-default {
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
|
||||
background-image: -o-linear-gradient(top, #fff 0%, #e0e0e0 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#e0e0e0));
|
||||
background-image: linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #dbdbdb;
|
||||
border-color: #ccc;
|
||||
}
|
||||
.btn-default:hover,
|
||||
.btn-default:focus {
|
||||
background-color: #e0e0e0;
|
||||
background-position: 0 -15px;
|
||||
}
|
||||
.btn-default:active,
|
||||
.btn-default.active {
|
||||
background-color: #e0e0e0;
|
||||
border-color: #dbdbdb;
|
||||
}
|
||||
.btn-default.disabled,
|
||||
.btn-default[disabled],
|
||||
fieldset[disabled] .btn-default,
|
||||
.btn-default.disabled:hover,
|
||||
.btn-default[disabled]:hover,
|
||||
fieldset[disabled] .btn-default:hover,
|
||||
.btn-default.disabled:focus,
|
||||
.btn-default[disabled]:focus,
|
||||
fieldset[disabled] .btn-default:focus,
|
||||
.btn-default.disabled.focus,
|
||||
.btn-default[disabled].focus,
|
||||
fieldset[disabled] .btn-default.focus,
|
||||
.btn-default.disabled:active,
|
||||
.btn-default[disabled]:active,
|
||||
fieldset[disabled] .btn-default:active,
|
||||
.btn-default.disabled.active,
|
||||
.btn-default[disabled].active,
|
||||
fieldset[disabled] .btn-default.active {
|
||||
background-color: #e0e0e0;
|
||||
background-image: none;
|
||||
}
|
||||
.btn-primary {
|
||||
background-image: -webkit-linear-gradient(top, #337ab7 0%, #265a88 100%);
|
||||
background-image: -o-linear-gradient(top, #337ab7 0%, #265a88 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#265a88));
|
||||
background-image: linear-gradient(to bottom, #337ab7 0%, #265a88 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff265a88', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #245580;
|
||||
}
|
||||
.btn-primary:hover,
|
||||
.btn-primary:focus {
|
||||
background-color: #265a88;
|
||||
background-position: 0 -15px;
|
||||
}
|
||||
.btn-primary:active,
|
||||
.btn-primary.active {
|
||||
background-color: #265a88;
|
||||
border-color: #245580;
|
||||
}
|
||||
.btn-primary.disabled,
|
||||
.btn-primary[disabled],
|
||||
fieldset[disabled] .btn-primary,
|
||||
.btn-primary.disabled:hover,
|
||||
.btn-primary[disabled]:hover,
|
||||
fieldset[disabled] .btn-primary:hover,
|
||||
.btn-primary.disabled:focus,
|
||||
.btn-primary[disabled]:focus,
|
||||
fieldset[disabled] .btn-primary:focus,
|
||||
.btn-primary.disabled.focus,
|
||||
.btn-primary[disabled].focus,
|
||||
fieldset[disabled] .btn-primary.focus,
|
||||
.btn-primary.disabled:active,
|
||||
.btn-primary[disabled]:active,
|
||||
fieldset[disabled] .btn-primary:active,
|
||||
.btn-primary.disabled.active,
|
||||
.btn-primary[disabled].active,
|
||||
fieldset[disabled] .btn-primary.active {
|
||||
background-color: #265a88;
|
||||
background-image: none;
|
||||
}
|
||||
.btn-success {
|
||||
background-image: -webkit-linear-gradient(top, #5cb85c 0%, #419641 100%);
|
||||
background-image: -o-linear-gradient(top, #5cb85c 0%, #419641 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#419641));
|
||||
background-image: linear-gradient(to bottom, #5cb85c 0%, #419641 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #3e8f3e;
|
||||
}
|
||||
.btn-success:hover,
|
||||
.btn-success:focus {
|
||||
background-color: #419641;
|
||||
background-position: 0 -15px;
|
||||
}
|
||||
.btn-success:active,
|
||||
.btn-success.active {
|
||||
background-color: #419641;
|
||||
border-color: #3e8f3e;
|
||||
}
|
||||
.btn-success.disabled,
|
||||
.btn-success[disabled],
|
||||
fieldset[disabled] .btn-success,
|
||||
.btn-success.disabled:hover,
|
||||
.btn-success[disabled]:hover,
|
||||
fieldset[disabled] .btn-success:hover,
|
||||
.btn-success.disabled:focus,
|
||||
.btn-success[disabled]:focus,
|
||||
fieldset[disabled] .btn-success:focus,
|
||||
.btn-success.disabled.focus,
|
||||
.btn-success[disabled].focus,
|
||||
fieldset[disabled] .btn-success.focus,
|
||||
.btn-success.disabled:active,
|
||||
.btn-success[disabled]:active,
|
||||
fieldset[disabled] .btn-success:active,
|
||||
.btn-success.disabled.active,
|
||||
.btn-success[disabled].active,
|
||||
fieldset[disabled] .btn-success.active {
|
||||
background-color: #419641;
|
||||
background-image: none;
|
||||
}
|
||||
.btn-info {
|
||||
background-image: -webkit-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);
|
||||
background-image: -o-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#2aabd2));
|
||||
background-image: linear-gradient(to bottom, #5bc0de 0%, #2aabd2 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #28a4c9;
|
||||
}
|
||||
.btn-info:hover,
|
||||
.btn-info:focus {
|
||||
background-color: #2aabd2;
|
||||
background-position: 0 -15px;
|
||||
}
|
||||
.btn-info:active,
|
||||
.btn-info.active {
|
||||
background-color: #2aabd2;
|
||||
border-color: #28a4c9;
|
||||
}
|
||||
.btn-info.disabled,
|
||||
.btn-info[disabled],
|
||||
fieldset[disabled] .btn-info,
|
||||
.btn-info.disabled:hover,
|
||||
.btn-info[disabled]:hover,
|
||||
fieldset[disabled] .btn-info:hover,
|
||||
.btn-info.disabled:focus,
|
||||
.btn-info[disabled]:focus,
|
||||
fieldset[disabled] .btn-info:focus,
|
||||
.btn-info.disabled.focus,
|
||||
.btn-info[disabled].focus,
|
||||
fieldset[disabled] .btn-info.focus,
|
||||
.btn-info.disabled:active,
|
||||
.btn-info[disabled]:active,
|
||||
fieldset[disabled] .btn-info:active,
|
||||
.btn-info.disabled.active,
|
||||
.btn-info[disabled].active,
|
||||
fieldset[disabled] .btn-info.active {
|
||||
background-color: #2aabd2;
|
||||
background-image: none;
|
||||
}
|
||||
.btn-warning {
|
||||
background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);
|
||||
background-image: -o-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#eb9316));
|
||||
background-image: linear-gradient(to bottom, #f0ad4e 0%, #eb9316 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #e38d13;
|
||||
}
|
||||
.btn-warning:hover,
|
||||
.btn-warning:focus {
|
||||
background-color: #eb9316;
|
||||
background-position: 0 -15px;
|
||||
}
|
||||
.btn-warning:active,
|
||||
.btn-warning.active {
|
||||
background-color: #eb9316;
|
||||
border-color: #e38d13;
|
||||
}
|
||||
.btn-warning.disabled,
|
||||
.btn-warning[disabled],
|
||||
fieldset[disabled] .btn-warning,
|
||||
.btn-warning.disabled:hover,
|
||||
.btn-warning[disabled]:hover,
|
||||
fieldset[disabled] .btn-warning:hover,
|
||||
.btn-warning.disabled:focus,
|
||||
.btn-warning[disabled]:focus,
|
||||
fieldset[disabled] .btn-warning:focus,
|
||||
.btn-warning.disabled.focus,
|
||||
.btn-warning[disabled].focus,
|
||||
fieldset[disabled] .btn-warning.focus,
|
||||
.btn-warning.disabled:active,
|
||||
.btn-warning[disabled]:active,
|
||||
fieldset[disabled] .btn-warning:active,
|
||||
.btn-warning.disabled.active,
|
||||
.btn-warning[disabled].active,
|
||||
fieldset[disabled] .btn-warning.active {
|
||||
background-color: #eb9316;
|
||||
background-image: none;
|
||||
}
|
||||
.btn-danger {
|
||||
background-image: -webkit-linear-gradient(top, #d9534f 0%, #c12e2a 100%);
|
||||
background-image: -o-linear-gradient(top, #d9534f 0%, #c12e2a 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c12e2a));
|
||||
background-image: linear-gradient(to bottom, #d9534f 0%, #c12e2a 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #b92c28;
|
||||
}
|
||||
.btn-danger:hover,
|
||||
.btn-danger:focus {
|
||||
background-color: #c12e2a;
|
||||
background-position: 0 -15px;
|
||||
}
|
||||
.btn-danger:active,
|
||||
.btn-danger.active {
|
||||
background-color: #c12e2a;
|
||||
border-color: #b92c28;
|
||||
}
|
||||
.btn-danger.disabled,
|
||||
.btn-danger[disabled],
|
||||
fieldset[disabled] .btn-danger,
|
||||
.btn-danger.disabled:hover,
|
||||
.btn-danger[disabled]:hover,
|
||||
fieldset[disabled] .btn-danger:hover,
|
||||
.btn-danger.disabled:focus,
|
||||
.btn-danger[disabled]:focus,
|
||||
fieldset[disabled] .btn-danger:focus,
|
||||
.btn-danger.disabled.focus,
|
||||
.btn-danger[disabled].focus,
|
||||
fieldset[disabled] .btn-danger.focus,
|
||||
.btn-danger.disabled:active,
|
||||
.btn-danger[disabled]:active,
|
||||
fieldset[disabled] .btn-danger:active,
|
||||
.btn-danger.disabled.active,
|
||||
.btn-danger[disabled].active,
|
||||
fieldset[disabled] .btn-danger.active {
|
||||
background-color: #c12e2a;
|
||||
background-image: none;
|
||||
}
|
||||
.thumbnail,
|
||||
.img-thumbnail {
|
||||
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
|
||||
}
|
||||
.dropdown-menu > li > a:hover,
|
||||
.dropdown-menu > li > a:focus {
|
||||
background-color: #e8e8e8;
|
||||
background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
|
||||
background-image: -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));
|
||||
background-image: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.dropdown-menu > .active > a,
|
||||
.dropdown-menu > .active > a:hover,
|
||||
.dropdown-menu > .active > a:focus {
|
||||
background-color: #2e6da4;
|
||||
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
|
||||
background-image: -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));
|
||||
background-image: linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.navbar-default {
|
||||
background-image: -webkit-linear-gradient(top, #fff 0%, #f8f8f8 100%);
|
||||
background-image: -o-linear-gradient(top, #fff 0%, #f8f8f8 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f8f8f8));
|
||||
background-image: linear-gradient(to bottom, #fff 0%, #f8f8f8 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-radius: 4px;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
|
||||
}
|
||||
.navbar-default .navbar-nav > .open > a,
|
||||
.navbar-default .navbar-nav > .active > a {
|
||||
background-image: -webkit-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);
|
||||
background-image: -o-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#dbdbdb), to(#e2e2e2));
|
||||
background-image: linear-gradient(to bottom, #dbdbdb 0%, #e2e2e2 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
-webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
|
||||
box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
|
||||
}
|
||||
.navbar-brand,
|
||||
.navbar-nav > li > a {
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
|
||||
}
|
||||
.navbar-inverse {
|
||||
background-image: -webkit-linear-gradient(top, #3c3c3c 0%, #222 100%);
|
||||
background-image: -o-linear-gradient(top, #3c3c3c 0%, #222 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#3c3c3c), to(#222));
|
||||
background-image: linear-gradient(to bottom, #3c3c3c 0%, #222 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
background-repeat: repeat-x;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.navbar-inverse .navbar-nav > .open > a,
|
||||
.navbar-inverse .navbar-nav > .active > a {
|
||||
background-image: -webkit-linear-gradient(top, #080808 0%, #0f0f0f 100%);
|
||||
background-image: -o-linear-gradient(top, #080808 0%, #0f0f0f 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#080808), to(#0f0f0f));
|
||||
background-image: linear-gradient(to bottom, #080808 0%, #0f0f0f 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
-webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
|
||||
box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
|
||||
}
|
||||
.navbar-inverse .navbar-brand,
|
||||
.navbar-inverse .navbar-nav > li > a {
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
|
||||
}
|
||||
.navbar-static-top,
|
||||
.navbar-fixed-top,
|
||||
.navbar-fixed-bottom {
|
||||
border-radius: 0;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.navbar .navbar-nav .open .dropdown-menu > .active > a,
|
||||
.navbar .navbar-nav .open .dropdown-menu > .active > a:hover,
|
||||
.navbar .navbar-nav .open .dropdown-menu > .active > a:focus {
|
||||
color: #fff;
|
||||
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
|
||||
background-image: -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));
|
||||
background-image: linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
}
|
||||
.alert {
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, .2);
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
|
||||
}
|
||||
.alert-success {
|
||||
background-image: -webkit-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);
|
||||
background-image: -o-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#c8e5bc));
|
||||
background-image: linear-gradient(to bottom, #dff0d8 0%, #c8e5bc 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #b2dba1;
|
||||
}
|
||||
.alert-info {
|
||||
background-image: -webkit-linear-gradient(top, #d9edf7 0%, #b9def0 100%);
|
||||
background-image: -o-linear-gradient(top, #d9edf7 0%, #b9def0 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#b9def0));
|
||||
background-image: linear-gradient(to bottom, #d9edf7 0%, #b9def0 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #9acfea;
|
||||
}
|
||||
.alert-warning {
|
||||
background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);
|
||||
background-image: -o-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#f8efc0));
|
||||
background-image: linear-gradient(to bottom, #fcf8e3 0%, #f8efc0 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #f5e79e;
|
||||
}
|
||||
.alert-danger {
|
||||
background-image: -webkit-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);
|
||||
background-image: -o-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#e7c3c3));
|
||||
background-image: linear-gradient(to bottom, #f2dede 0%, #e7c3c3 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #dca7a7;
|
||||
}
|
||||
.progress {
|
||||
background-image: -webkit-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);
|
||||
background-image: -o-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#f5f5f5));
|
||||
background-image: linear-gradient(to bottom, #ebebeb 0%, #f5f5f5 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.progress-bar {
|
||||
background-image: -webkit-linear-gradient(top, #337ab7 0%, #286090 100%);
|
||||
background-image: -o-linear-gradient(top, #337ab7 0%, #286090 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#286090));
|
||||
background-image: linear-gradient(to bottom, #337ab7 0%, #286090 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff286090', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.progress-bar-success {
|
||||
background-image: -webkit-linear-gradient(top, #5cb85c 0%, #449d44 100%);
|
||||
background-image: -o-linear-gradient(top, #5cb85c 0%, #449d44 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#449d44));
|
||||
background-image: linear-gradient(to bottom, #5cb85c 0%, #449d44 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.progress-bar-info {
|
||||
background-image: -webkit-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);
|
||||
background-image: -o-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#31b0d5));
|
||||
background-image: linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.progress-bar-warning {
|
||||
background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);
|
||||
background-image: -o-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#ec971f));
|
||||
background-image: linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.progress-bar-danger {
|
||||
background-image: -webkit-linear-gradient(top, #d9534f 0%, #c9302c 100%);
|
||||
background-image: -o-linear-gradient(top, #d9534f 0%, #c9302c 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c9302c));
|
||||
background-image: linear-gradient(to bottom, #d9534f 0%, #c9302c 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.progress-bar-striped {
|
||||
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
|
||||
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
|
||||
}
|
||||
.list-group {
|
||||
border-radius: 4px;
|
||||
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
|
||||
}
|
||||
.list-group-item.active,
|
||||
.list-group-item.active:hover,
|
||||
.list-group-item.active:focus {
|
||||
text-shadow: 0 -1px 0 #286090;
|
||||
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2b669a 100%);
|
||||
background-image: -o-linear-gradient(top, #337ab7 0%, #2b669a 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2b669a));
|
||||
background-image: linear-gradient(to bottom, #337ab7 0%, #2b669a 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2b669a', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #2b669a;
|
||||
}
|
||||
.list-group-item.active .badge,
|
||||
.list-group-item.active:hover .badge,
|
||||
.list-group-item.active:focus .badge {
|
||||
text-shadow: none;
|
||||
}
|
||||
.panel {
|
||||
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
||||
}
|
||||
.panel-default > .panel-heading {
|
||||
background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
|
||||
background-image: -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));
|
||||
background-image: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.panel-primary > .panel-heading {
|
||||
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
|
||||
background-image: -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));
|
||||
background-image: linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.panel-success > .panel-heading {
|
||||
background-image: -webkit-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);
|
||||
background-image: -o-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#d0e9c6));
|
||||
background-image: linear-gradient(to bottom, #dff0d8 0%, #d0e9c6 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.panel-info > .panel-heading {
|
||||
background-image: -webkit-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);
|
||||
background-image: -o-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#c4e3f3));
|
||||
background-image: linear-gradient(to bottom, #d9edf7 0%, #c4e3f3 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.panel-warning > .panel-heading {
|
||||
background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);
|
||||
background-image: -o-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#faf2cc));
|
||||
background-image: linear-gradient(to bottom, #fcf8e3 0%, #faf2cc 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.panel-danger > .panel-heading {
|
||||
background-image: -webkit-linear-gradient(top, #f2dede 0%, #ebcccc 100%);
|
||||
background-image: -o-linear-gradient(top, #f2dede 0%, #ebcccc 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#ebcccc));
|
||||
background-image: linear-gradient(to bottom, #f2dede 0%, #ebcccc 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.well {
|
||||
background-image: -webkit-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);
|
||||
background-image: -o-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#e8e8e8), to(#f5f5f5));
|
||||
background-image: linear-gradient(to bottom, #e8e8e8 0%, #f5f5f5 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #dcdcdc;
|
||||
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
|
||||
box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
|
||||
}
|
||||
/*# sourceMappingURL=bootstrap-theme.css.map */
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,68 @@
|
|||
body {
|
||||
padding-top: 50px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Wrapping element */
|
||||
/* Set some basic padding to keep content from hitting the edges */
|
||||
.body-content {
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
/* Set widths on the form inputs since otherwise they're 100% wide */
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
/* Carousel */
|
||||
.carousel-caption {
|
||||
z-index: 10 !important;
|
||||
}
|
||||
|
||||
.carousel-caption p {
|
||||
font-size: 20px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.carousel-caption {
|
||||
z-index: 10 !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* http://stephanwagner.me/only-css-loading-spinner */
|
||||
@keyframes spinner {
|
||||
to {transform: rotate(360deg);}
|
||||
}
|
||||
|
||||
@-webkit-keyframes spinner {
|
||||
to {-webkit-transform: rotate(360deg);}
|
||||
}
|
||||
|
||||
.spinner {
|
||||
min-width: 24px;
|
||||
min-height: 24px;
|
||||
}
|
||||
|
||||
.spinner:before {
|
||||
content: 'Loading…';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-top: -10px;
|
||||
margin-left: -10px;
|
||||
}
|
||||
|
||||
.spinner:not(:required):before {
|
||||
content: '';
|
||||
border-radius: 50%;
|
||||
border-top: 2px solid #03ade0;
|
||||
border-right: 2px solid transparent;
|
||||
animation: spinner .6s linear infinite;
|
||||
-webkit-animation: spinner .6s linear infinite;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Description;
|
||||
using CodeConverterWebApp.Models;
|
||||
using RefactoringEssentials.Converter;
|
||||
|
||||
namespace CodeConverterWebApp.Controllers
|
||||
{
|
||||
public class ConverterController : ApiController
|
||||
{
|
||||
[HttpPost]
|
||||
[ResponseType(typeof(ConvertResponse))]
|
||||
public IHttpActionResult Post([FromBody]ConvertRequest todo)
|
||||
{
|
||||
var languages = todo.requestedConversion.Split('2');
|
||||
|
||||
string fromLanguage = "C#";
|
||||
string toLanguage = "Visual Basic";
|
||||
int fromVersion = 6;
|
||||
int toVersion = 14;
|
||||
|
||||
if (languages.Length == 2)
|
||||
{
|
||||
fromLanguage = ParseLanguage(languages[0]);
|
||||
fromVersion = GetDefaultVersionForLanguage(languages[0]);
|
||||
toLanguage = ParseLanguage(languages[1]);
|
||||
toVersion = GetDefaultVersionForLanguage(languages[1]);
|
||||
}
|
||||
|
||||
var codeWithOptions = new CodeWithOptions(todo.code)
|
||||
.WithDefaultReferences()
|
||||
.SetFromLanguage(fromLanguage, fromVersion)
|
||||
.SetToLanguage(toLanguage, toVersion);
|
||||
var result = CodeConverter.Convert(codeWithOptions);
|
||||
|
||||
var response = new ConvertResponse()
|
||||
{
|
||||
conversionOk = result.Success,
|
||||
convertedCode = result.ConvertedCode,
|
||||
errorMessage = result.GetExceptionsAsString()
|
||||
};
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
string ParseLanguage(string language)
|
||||
{
|
||||
if (language == null)
|
||||
throw new ArgumentNullException(nameof(language));
|
||||
if (language.StartsWith("cs", StringComparison.OrdinalIgnoreCase))
|
||||
return "C#";
|
||||
if (language.StartsWith("vb", StringComparison.OrdinalIgnoreCase))
|
||||
return "Visual Basic";
|
||||
throw new ArgumentException($"{language} not supported!");
|
||||
}
|
||||
|
||||
int GetDefaultVersionForLanguage(string language)
|
||||
{
|
||||
if (language == null)
|
||||
throw new ArgumentNullException(nameof(language));
|
||||
if (language.StartsWith("cs", StringComparison.OrdinalIgnoreCase))
|
||||
return 6;
|
||||
if (language.StartsWith("vb", StringComparison.OrdinalIgnoreCase))
|
||||
return 14;
|
||||
throw new ArgumentException($"{language} not supported!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace CodeConverterWebApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult About()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<%@ Application Codebehind="Global.asax.cs" Inherits="CodeConverterWebApp.Global" Language="C#" %>
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace CodeConverterWebApp
|
||||
{
|
||||
public class Global : HttpApplication
|
||||
{
|
||||
void Application_Start(object sender, EventArgs e)
|
||||
{
|
||||
// Code that runs on application startup
|
||||
AreaRegistration.RegisterAllAreas();
|
||||
GlobalConfiguration.Configure(WebApiConfig.Register);
|
||||
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
||||
}
|
||||
}
|
||||
}
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 6.8 KiB |
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeConverterWebApp.Models
|
||||
{
|
||||
public class ConvertRequest
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string requestedConversion { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeConverterWebApp.Models
|
||||
{
|
||||
public class ConvertResponse
|
||||
{
|
||||
public bool conversionOk { get; set; }
|
||||
public string convertedCode { get; set; }
|
||||
public string errorMessage { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
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("CodeConverterWebApp")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CodeConverterWebApp")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[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("d1ff18b5-68a8-439b-9d00-c35258aa7833")]
|
||||
|
||||
// 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 Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,309 @@
|
|||
/*
|
||||
AngularJS v1.5.2
|
||||
(c) 2010-2016 Google, Inc. http://angularjs.org
|
||||
License: MIT
|
||||
*/
|
||||
(function(N,Q,w){'use strict';function O(a){return function(){var b=arguments[0],d;d="["+(a?a+":":"")+b+"] http://errors.angularjs.org/1.5.2/"+(a?a+"/":"")+b;for(b=1;b<arguments.length;b++){d=d+(1==b?"?":"&")+"p"+(b-1)+"=";var c=encodeURIComponent,e;e=arguments[b];e="function"==typeof e?e.toString().replace(/ \{[\s\S]*$/,""):"undefined"==typeof e?"undefined":"string"!=typeof e?JSON.stringify(e):e;d+=c(e)}return Error(d)}}function Ca(a){if(null==a||Xa(a))return!1;if(L(a)||D(a)||G&&a instanceof G)return!0;
|
||||
var b="length"in Object(a)&&a.length;return W(b)&&(0<=b&&(b-1 in a||a instanceof Array)||"function"==typeof a.item)}function p(a,b,d){var c,e;if(a)if(H(a))for(c in a)"prototype"==c||"length"==c||"name"==c||a.hasOwnProperty&&!a.hasOwnProperty(c)||b.call(d,a[c],c,a);else if(L(a)||Ca(a)){var f="object"!==typeof a;c=0;for(e=a.length;c<e;c++)(f||c in a)&&b.call(d,a[c],c,a)}else if(a.forEach&&a.forEach!==p)a.forEach(b,d,a);else if(nc(a))for(c in a)b.call(d,a[c],c,a);else if("function"===typeof a.hasOwnProperty)for(c in a)a.hasOwnProperty(c)&&
|
||||
b.call(d,a[c],c,a);else for(c in a)sa.call(a,c)&&b.call(d,a[c],c,a);return a}function oc(a,b,d){for(var c=Object.keys(a).sort(),e=0;e<c.length;e++)b.call(d,a[c[e]],c[e]);return c}function pc(a){return function(b,d){a(d,b)}}function Ud(){return++pb}function Nb(a,b,d){for(var c=a.$$hashKey,e=0,f=b.length;e<f;++e){var g=b[e];if(I(g)||H(g))for(var h=Object.keys(g),k=0,l=h.length;k<l;k++){var m=h[k],n=g[m];d&&I(n)?ga(n)?a[m]=new Date(n.valueOf()):Ya(n)?a[m]=new RegExp(n):n.nodeName?a[m]=n.cloneNode(!0):
|
||||
Ob(n)?a[m]=n.clone():(I(a[m])||(a[m]=L(n)?[]:{}),Nb(a[m],[n],!0)):a[m]=n}}c?a.$$hashKey=c:delete a.$$hashKey;return a}function S(a){return Nb(a,ya.call(arguments,1),!1)}function Vd(a){return Nb(a,ya.call(arguments,1),!0)}function da(a){return parseInt(a,10)}function Pb(a,b){return S(Object.create(a),b)}function z(){}function Za(a){return a}function ia(a){return function(){return a}}function qc(a){return H(a.toString)&&a.toString!==ha}function v(a){return"undefined"===typeof a}function A(a){return"undefined"!==
|
||||
typeof a}function I(a){return null!==a&&"object"===typeof a}function nc(a){return null!==a&&"object"===typeof a&&!rc(a)}function D(a){return"string"===typeof a}function W(a){return"number"===typeof a}function ga(a){return"[object Date]"===ha.call(a)}function H(a){return"function"===typeof a}function Ya(a){return"[object RegExp]"===ha.call(a)}function Xa(a){return a&&a.window===a}function $a(a){return a&&a.$evalAsync&&a.$watch}function Ma(a){return"boolean"===typeof a}function Wd(a){return a&&W(a.length)&&
|
||||
Xd.test(ha.call(a))}function Ob(a){return!(!a||!(a.nodeName||a.prop&&a.attr&&a.find))}function Yd(a){var b={};a=a.split(",");var d;for(d=0;d<a.length;d++)b[a[d]]=!0;return b}function pa(a){return E(a.nodeName||a[0]&&a[0].nodeName)}function ab(a,b){var d=a.indexOf(b);0<=d&&a.splice(d,1);return d}function qa(a,b){function d(a,b){var d=b.$$hashKey,e;if(L(a)){e=0;for(var f=a.length;e<f;e++)b.push(c(a[e]))}else if(nc(a))for(e in a)b[e]=c(a[e]);else if(a&&"function"===typeof a.hasOwnProperty)for(e in a)a.hasOwnProperty(e)&&
|
||||
(b[e]=c(a[e]));else for(e in a)sa.call(a,e)&&(b[e]=c(a[e]));d?b.$$hashKey=d:delete b.$$hashKey;return b}function c(a){if(!I(a))return a;var b=f.indexOf(a);if(-1!==b)return g[b];if(Xa(a)||$a(a))throw Da("cpws");var b=!1,c=e(a);c===w&&(c=L(a)?[]:Object.create(rc(a)),b=!0);f.push(a);g.push(c);return b?d(a,c):c}function e(a){switch(ha.call(a)){case "[object Int8Array]":case "[object Int16Array]":case "[object Int32Array]":case "[object Float32Array]":case "[object Float64Array]":case "[object Uint8Array]":case "[object Uint8ClampedArray]":case "[object Uint16Array]":case "[object Uint32Array]":return new a.constructor(c(a.buffer));
|
||||
case "[object ArrayBuffer]":if(!a.slice){var b=new ArrayBuffer(a.byteLength);(new Uint8Array(b)).set(new Uint8Array(a));return b}return a.slice(0);case "[object Boolean]":case "[object Number]":case "[object String]":case "[object Date]":return new a.constructor(a.valueOf());case "[object RegExp]":return b=new RegExp(a.source,a.toString().match(/[^\/]*$/)[0]),b.lastIndex=a.lastIndex,b;case "[object Blob]":return new a.constructor([a],{type:a.type})}if(H(a.cloneNode))return a.cloneNode(!0)}var f=[],
|
||||
g=[];if(b){if(Wd(b)||"[object ArrayBuffer]"===ha.call(b))throw Da("cpta");if(a===b)throw Da("cpi");L(b)?b.length=0:p(b,function(a,c){"$$hashKey"!==c&&delete b[c]});f.push(a);g.push(b);return d(a,b)}return c(a)}function ma(a,b){if(L(a)){b=b||[];for(var d=0,c=a.length;d<c;d++)b[d]=a[d]}else if(I(a))for(d in b=b||{},a)if("$"!==d.charAt(0)||"$"!==d.charAt(1))b[d]=a[d];return b||a}function oa(a,b){if(a===b)return!0;if(null===a||null===b)return!1;if(a!==a&&b!==b)return!0;var d=typeof a,c;if(d==typeof b&&
|
||||
"object"==d)if(L(a)){if(!L(b))return!1;if((d=a.length)==b.length){for(c=0;c<d;c++)if(!oa(a[c],b[c]))return!1;return!0}}else{if(ga(a))return ga(b)?oa(a.getTime(),b.getTime()):!1;if(Ya(a))return Ya(b)?a.toString()==b.toString():!1;if($a(a)||$a(b)||Xa(a)||Xa(b)||L(b)||ga(b)||Ya(b))return!1;d=X();for(c in a)if("$"!==c.charAt(0)&&!H(a[c])){if(!oa(a[c],b[c]))return!1;d[c]=!0}for(c in b)if(!(c in d)&&"$"!==c.charAt(0)&&A(b[c])&&!H(b[c]))return!1;return!0}return!1}function bb(a,b,d){return a.concat(ya.call(b,
|
||||
d))}function sc(a,b){var d=2<arguments.length?ya.call(arguments,2):[];return!H(b)||b instanceof RegExp?b:d.length?function(){return arguments.length?b.apply(a,bb(d,arguments,0)):b.apply(a,d)}:function(){return arguments.length?b.apply(a,arguments):b.call(a)}}function Zd(a,b){var d=b;"string"===typeof a&&"$"===a.charAt(0)&&"$"===a.charAt(1)?d=w:Xa(b)?d="$WINDOW":b&&Q===b?d="$DOCUMENT":$a(b)&&(d="$SCOPE");return d}function cb(a,b){if(v(a))return w;W(b)||(b=b?2:null);return JSON.stringify(a,Zd,b)}function tc(a){return D(a)?
|
||||
JSON.parse(a):a}function uc(a,b){a=a.replace($d,"");var d=Date.parse("Jan 01, 1970 00:00:00 "+a)/6E4;return isNaN(d)?b:d}function Qb(a,b,d){d=d?-1:1;var c=a.getTimezoneOffset();b=uc(b,c);d*=b-c;a=new Date(a.getTime());a.setMinutes(a.getMinutes()+d);return a}function ta(a){a=G(a).clone();try{a.empty()}catch(b){}var d=G("<div>").append(a).html();try{return a[0].nodeType===Na?E(d):d.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+E(b)})}catch(c){return E(d)}}function vc(a){try{return decodeURIComponent(a)}catch(b){}}
|
||||
function wc(a){var b={};p((a||"").split("&"),function(a){var c,e,f;a&&(e=a=a.replace(/\+/g,"%20"),c=a.indexOf("="),-1!==c&&(e=a.substring(0,c),f=a.substring(c+1)),e=vc(e),A(e)&&(f=A(f)?vc(f):!0,sa.call(b,e)?L(b[e])?b[e].push(f):b[e]=[b[e],f]:b[e]=f))});return b}function Rb(a){var b=[];p(a,function(a,c){L(a)?p(a,function(a){b.push(ja(c,!0)+(!0===a?"":"="+ja(a,!0)))}):b.push(ja(c,!0)+(!0===a?"":"="+ja(a,!0)))});return b.length?b.join("&"):""}function qb(a){return ja(a,!0).replace(/%26/gi,"&").replace(/%3D/gi,
|
||||
"=").replace(/%2B/gi,"+")}function ja(a,b){return encodeURIComponent(a).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%20/g,b?"%20":"+")}function ae(a,b){var d,c,e=Oa.length;for(c=0;c<e;++c)if(d=Oa[c]+b,D(d=a.getAttribute(d)))return d;return null}function be(a,b){var d,c,e={};p(Oa,function(b){b+="app";!d&&a.hasAttribute&&a.hasAttribute(b)&&(d=a,c=a.getAttribute(b))});p(Oa,function(b){b+="app";var e;!d&&(e=a.querySelector("["+b.replace(":",
|
||||
"\\:")+"]"))&&(d=e,c=e.getAttribute(b))});d&&(e.strictDi=null!==ae(d,"strict-di"),b(d,c?[c]:[],e))}function xc(a,b,d){I(d)||(d={});d=S({strictDi:!1},d);var c=function(){a=G(a);if(a.injector()){var c=a[0]===Q?"document":ta(a);throw Da("btstrpd",c.replace(/</,"<").replace(/>/,">"));}b=b||[];b.unshift(["$provide",function(b){b.value("$rootElement",a)}]);d.debugInfoEnabled&&b.push(["$compileProvider",function(a){a.debugInfoEnabled(!0)}]);b.unshift("ng");c=db(b,d.strictDi);c.invoke(["$rootScope",
|
||||
"$rootElement","$compile","$injector",function(a,b,c,d){a.$apply(function(){b.data("$injector",d);c(b)(a)})}]);return c},e=/^NG_ENABLE_DEBUG_INFO!/,f=/^NG_DEFER_BOOTSTRAP!/;N&&e.test(N.name)&&(d.debugInfoEnabled=!0,N.name=N.name.replace(e,""));if(N&&!f.test(N.name))return c();N.name=N.name.replace(f,"");ea.resumeBootstrap=function(a){p(a,function(a){b.push(a)});return c()};H(ea.resumeDeferredBootstrap)&&ea.resumeDeferredBootstrap()}function ce(){N.name="NG_ENABLE_DEBUG_INFO!"+N.name;N.location.reload()}
|
||||
function de(a){a=ea.element(a).injector();if(!a)throw Da("test");return a.get("$$testability")}function yc(a,b){b=b||"_";return a.replace(ee,function(a,c){return(c?b:"")+a.toLowerCase()})}function fe(){var a;if(!zc){var b=rb();(ra=v(b)?N.jQuery:b?N[b]:w)&&ra.fn.on?(G=ra,S(ra.fn,{scope:Pa.scope,isolateScope:Pa.isolateScope,controller:Pa.controller,injector:Pa.injector,inheritedData:Pa.inheritedData}),a=ra.cleanData,ra.cleanData=function(b){for(var c,e=0,f;null!=(f=b[e]);e++)(c=ra._data(f,"events"))&&
|
||||
c.$destroy&&ra(f).triggerHandler("$destroy");a(b)}):G=Y;ea.element=G;zc=!0}}function sb(a,b,d){if(!a)throw Da("areq",b||"?",d||"required");return a}function Qa(a,b,d){d&&L(a)&&(a=a[a.length-1]);sb(H(a),b,"not a function, got "+(a&&"object"===typeof a?a.constructor.name||"Object":typeof a));return a}function Ra(a,b){if("hasOwnProperty"===a)throw Da("badname",b);}function Ac(a,b,d){if(!b)return a;b=b.split(".");for(var c,e=a,f=b.length,g=0;g<f;g++)c=b[g],a&&(a=(e=a)[c]);return!d&&H(a)?sc(e,a):a}function tb(a){for(var b=
|
||||
a[0],d=a[a.length-1],c,e=1;b!==d&&(b=b.nextSibling);e++)if(c||a[e]!==b)c||(c=G(ya.call(a,0,e))),c.push(b);return c||a}function X(){return Object.create(null)}function ge(a){function b(a,b,c){return a[b]||(a[b]=c())}var d=O("$injector"),c=O("ng");a=b(a,"angular",Object);a.$$minErr=a.$$minErr||O;return b(a,"module",function(){var a={};return function(f,g,h){if("hasOwnProperty"===f)throw c("badname","module");g&&a.hasOwnProperty(f)&&(a[f]=null);return b(a,f,function(){function a(b,d,e,f){f||(f=c);return function(){f[e||
|
||||
"push"]([b,d,arguments]);return K}}function b(a,d){return function(b,e){e&&H(e)&&(e.$$moduleName=f);c.push([a,d,arguments]);return K}}if(!g)throw d("nomod",f);var c=[],e=[],y=[],B=a("$injector","invoke","push",e),K={_invokeQueue:c,_configBlocks:e,_runBlocks:y,requires:g,name:f,provider:b("$provide","provider"),factory:b("$provide","factory"),service:b("$provide","service"),value:a("$provide","value"),constant:a("$provide","constant","unshift"),decorator:b("$provide","decorator"),animation:b("$animateProvider",
|
||||
"register"),filter:b("$filterProvider","register"),controller:b("$controllerProvider","register"),directive:b("$compileProvider","directive"),component:b("$compileProvider","component"),config:B,run:function(a){y.push(a);return this}};h&&B(h);return K})}})}function he(a){S(a,{bootstrap:xc,copy:qa,extend:S,merge:Vd,equals:oa,element:G,forEach:p,injector:db,noop:z,bind:sc,toJson:cb,fromJson:tc,identity:Za,isUndefined:v,isDefined:A,isString:D,isFunction:H,isObject:I,isNumber:W,isElement:Ob,isArray:L,
|
||||
version:ie,isDate:ga,lowercase:E,uppercase:ub,callbacks:{counter:0},getTestability:de,$$minErr:O,$$csp:Ea,reloadWithDebugInfo:ce});Sb=ge(N);Sb("ng",["ngLocale"],["$provide",function(a){a.provider({$$sanitizeUri:je});a.provider("$compile",Bc).directive({a:ke,input:Cc,textarea:Cc,form:le,script:me,select:ne,style:oe,option:pe,ngBind:qe,ngBindHtml:re,ngBindTemplate:se,ngClass:te,ngClassEven:ue,ngClassOdd:ve,ngCloak:we,ngController:xe,ngForm:ye,ngHide:ze,ngIf:Ae,ngInclude:Be,ngInit:Ce,ngNonBindable:De,
|
||||
ngPluralize:Ee,ngRepeat:Fe,ngShow:Ge,ngStyle:He,ngSwitch:Ie,ngSwitchWhen:Je,ngSwitchDefault:Ke,ngOptions:Le,ngTransclude:Me,ngModel:Ne,ngList:Oe,ngChange:Pe,pattern:Dc,ngPattern:Dc,required:Ec,ngRequired:Ec,minlength:Fc,ngMinlength:Fc,maxlength:Gc,ngMaxlength:Gc,ngValue:Qe,ngModelOptions:Re}).directive({ngInclude:Se}).directive(vb).directive(Hc);a.provider({$anchorScroll:Te,$animate:Ue,$animateCss:Ve,$$animateJs:We,$$animateQueue:Xe,$$AnimateRunner:Ye,$$animateAsyncRun:Ze,$browser:$e,$cacheFactory:af,
|
||||
$controller:bf,$document:cf,$exceptionHandler:df,$filter:Ic,$$forceReflow:ef,$interpolate:ff,$interval:gf,$http:hf,$httpParamSerializer:jf,$httpParamSerializerJQLike:kf,$httpBackend:lf,$xhrFactory:mf,$location:nf,$log:of,$parse:pf,$rootScope:qf,$q:rf,$$q:sf,$sce:tf,$sceDelegate:uf,$sniffer:vf,$templateCache:wf,$templateRequest:xf,$$testability:yf,$timeout:zf,$window:Af,$$rAF:Bf,$$jqLite:Cf,$$HashMap:Df,$$cookieReader:Ef})}])}function eb(a){return a.replace(Ff,function(a,d,c,e){return e?c.toUpperCase():
|
||||
c}).replace(Gf,"Moz$1")}function Jc(a){a=a.nodeType;return 1===a||!a||9===a}function Kc(a,b){var d,c,e=b.createDocumentFragment(),f=[];if(Tb.test(a)){d=d||e.appendChild(b.createElement("div"));c=(Hf.exec(a)||["",""])[1].toLowerCase();c=ka[c]||ka._default;d.innerHTML=c[1]+a.replace(If,"<$1></$2>")+c[2];for(c=c[0];c--;)d=d.lastChild;f=bb(f,d.childNodes);d=e.firstChild;d.textContent=""}else f.push(b.createTextNode(a));e.textContent="";e.innerHTML="";p(f,function(a){e.appendChild(a)});return e}function Lc(a,
|
||||
b){var d=a.parentNode;d&&d.replaceChild(b,a);b.appendChild(a)}function Y(a){if(a instanceof Y)return a;var b;D(a)&&(a=Z(a),b=!0);if(!(this instanceof Y)){if(b&&"<"!=a.charAt(0))throw Ub("nosel");return new Y(a)}if(b){b=Q;var d;a=(d=Jf.exec(a))?[b.createElement(d[1])]:(d=Kc(a,b))?d.childNodes:[]}Mc(this,a)}function Vb(a){return a.cloneNode(!0)}function wb(a,b){b||fb(a);if(a.querySelectorAll)for(var d=a.querySelectorAll("*"),c=0,e=d.length;c<e;c++)fb(d[c])}function Nc(a,b,d,c){if(A(c))throw Ub("offargs");
|
||||
var e=(c=xb(a))&&c.events,f=c&&c.handle;if(f)if(b){var g=function(b){var c=e[b];A(d)&&ab(c||[],d);A(d)&&c&&0<c.length||(a.removeEventListener(b,f,!1),delete e[b])};p(b.split(" "),function(a){g(a);yb[a]&&g(yb[a])})}else for(b in e)"$destroy"!==b&&a.removeEventListener(b,f,!1),delete e[b]}function fb(a,b){var d=a.ng339,c=d&&gb[d];c&&(b?delete c.data[b]:(c.handle&&(c.events.$destroy&&c.handle({},"$destroy"),Nc(a)),delete gb[d],a.ng339=w))}function xb(a,b){var d=a.ng339,d=d&&gb[d];b&&!d&&(a.ng339=d=++Kf,
|
||||
d=gb[d]={events:{},data:{},handle:w});return d}function Wb(a,b,d){if(Jc(a)){var c=A(d),e=!c&&b&&!I(b),f=!b;a=(a=xb(a,!e))&&a.data;if(c)a[b]=d;else{if(f)return a;if(e)return a&&a[b];S(a,b)}}}function zb(a,b){return a.getAttribute?-1<(" "+(a.getAttribute("class")||"")+" ").replace(/[\n\t]/g," ").indexOf(" "+b+" "):!1}function Ab(a,b){b&&a.setAttribute&&p(b.split(" "),function(b){a.setAttribute("class",Z((" "+(a.getAttribute("class")||"")+" ").replace(/[\n\t]/g," ").replace(" "+Z(b)+" "," ")))})}function Bb(a,
|
||||
b){if(b&&a.setAttribute){var d=(" "+(a.getAttribute("class")||"")+" ").replace(/[\n\t]/g," ");p(b.split(" "),function(a){a=Z(a);-1===d.indexOf(" "+a+" ")&&(d+=a+" ")});a.setAttribute("class",Z(d))}}function Mc(a,b){if(b)if(b.nodeType)a[a.length++]=b;else{var d=b.length;if("number"===typeof d&&b.window!==b){if(d)for(var c=0;c<d;c++)a[a.length++]=b[c]}else a[a.length++]=b}}function Oc(a,b){return Cb(a,"$"+(b||"ngController")+"Controller")}function Cb(a,b,d){9==a.nodeType&&(a=a.documentElement);for(b=
|
||||
L(b)?b:[b];a;){for(var c=0,e=b.length;c<e;c++)if(A(d=G.data(a,b[c])))return d;a=a.parentNode||11===a.nodeType&&a.host}}function Pc(a){for(wb(a,!0);a.firstChild;)a.removeChild(a.firstChild)}function Xb(a,b){b||wb(a);var d=a.parentNode;d&&d.removeChild(a)}function Lf(a,b){b=b||N;if("complete"===b.document.readyState)b.setTimeout(a);else G(b).on("load",a)}function Qc(a,b){var d=Db[b.toLowerCase()];return d&&Rc[pa(a)]&&d}function Mf(a,b){var d=function(c,d){c.isDefaultPrevented=function(){return c.defaultPrevented};
|
||||
var f=b[d||c.type],g=f?f.length:0;if(g){if(v(c.immediatePropagationStopped)){var h=c.stopImmediatePropagation;c.stopImmediatePropagation=function(){c.immediatePropagationStopped=!0;c.stopPropagation&&c.stopPropagation();h&&h.call(c)}}c.isImmediatePropagationStopped=function(){return!0===c.immediatePropagationStopped};var k=f.specialHandlerWrapper||Nf;1<g&&(f=ma(f));for(var l=0;l<g;l++)c.isImmediatePropagationStopped()||k(a,c,f[l])}};d.elem=a;return d}function Nf(a,b,d){d.call(a,b)}function Of(a,b,
|
||||
d){var c=b.relatedTarget;c&&(c===a||Pf.call(a,c))||d.call(a,b)}function Cf(){this.$get=function(){return S(Y,{hasClass:function(a,b){a.attr&&(a=a[0]);return zb(a,b)},addClass:function(a,b){a.attr&&(a=a[0]);return Bb(a,b)},removeClass:function(a,b){a.attr&&(a=a[0]);return Ab(a,b)}})}}function Fa(a,b){var d=a&&a.$$hashKey;if(d)return"function"===typeof d&&(d=a.$$hashKey()),d;d=typeof a;return d="function"==d||"object"==d&&null!==a?a.$$hashKey=d+":"+(b||Ud)():d+":"+a}function Sa(a,b){if(b){var d=0;this.nextUid=
|
||||
function(){return++d}}p(a,this.put,this)}function Sc(a){a=a.toString().replace(Qf,"");return a.match(Rf)||a.match(Sf)}function Tf(a){return(a=Sc(a))?"function("+(a[1]||"").replace(/[\s\r\n]+/," ")+")":"fn"}function db(a,b){function d(a){return function(b,c){if(I(b))p(b,pc(a));else return a(b,c)}}function c(a,b){Ra(a,"service");if(H(b)||L(b))b=y.instantiate(b);if(!b.$get)throw Ga("pget",a);return n[a+"Provider"]=b}function e(a,b){return function(){var c=x.invoke(b,this);if(v(c))throw Ga("undef",a);
|
||||
return c}}function f(a,b,d){return c(a,{$get:!1!==d?e(a,b):b})}function g(a){sb(v(a)||L(a),"modulesToLoad","not an array");var b=[],c;p(a,function(a){function d(a){var b,c;b=0;for(c=a.length;b<c;b++){var e=a[b],f=y.get(e[0]);f[e[1]].apply(f,e[2])}}if(!m.get(a)){m.put(a,!0);try{D(a)?(c=Sb(a),b=b.concat(g(c.requires)).concat(c._runBlocks),d(c._invokeQueue),d(c._configBlocks)):H(a)?b.push(y.invoke(a)):L(a)?b.push(y.invoke(a)):Qa(a,"module")}catch(e){throw L(a)&&(a=a[a.length-1]),e.message&&e.stack&&
|
||||
-1==e.stack.indexOf(e.message)&&(e=e.message+"\n"+e.stack),Ga("modulerr",a,e.stack||e.message||e);}}});return b}function h(a,c){function d(b,e){if(a.hasOwnProperty(b)){if(a[b]===k)throw Ga("cdep",b+" <- "+l.join(" <- "));return a[b]}try{return l.unshift(b),a[b]=k,a[b]=c(b,e)}catch(f){throw a[b]===k&&delete a[b],f;}finally{l.shift()}}function e(a,c,f){var g=[];a=db.$$annotate(a,b,f);for(var h=0,k=a.length;h<k;h++){var l=a[h];if("string"!==typeof l)throw Ga("itkn",l);g.push(c&&c.hasOwnProperty(l)?c[l]:
|
||||
d(l,f))}return g}return{invoke:function(a,b,c,d){"string"===typeof c&&(d=c,c=null);c=e(a,c,d);L(a)&&(a=a[a.length-1]);d=11>=za?!1:"function"===typeof a&&/^(?:class\s|constructor\()/.test(Function.prototype.toString.call(a));return d?(c.unshift(null),new (Function.prototype.bind.apply(a,c))):a.apply(b,c)},instantiate:function(a,b,c){var d=L(a)?a[a.length-1]:a;a=e(a,b,c);a.unshift(null);return new (Function.prototype.bind.apply(d,a))},get:d,annotate:db.$$annotate,has:function(b){return n.hasOwnProperty(b+
|
||||
"Provider")||a.hasOwnProperty(b)}}}b=!0===b;var k={},l=[],m=new Sa([],!0),n={$provide:{provider:d(c),factory:d(f),service:d(function(a,b){return f(a,["$injector",function(a){return a.instantiate(b)}])}),value:d(function(a,b){return f(a,ia(b),!1)}),constant:d(function(a,b){Ra(a,"constant");n[a]=b;B[a]=b}),decorator:function(a,b){var c=y.get(a+"Provider"),d=c.$get;c.$get=function(){var a=x.invoke(d,c);return x.invoke(b,null,{$delegate:a})}}}},y=n.$injector=h(n,function(a,b){ea.isString(b)&&l.push(b);
|
||||
throw Ga("unpr",l.join(" <- "));}),B={},K=h(B,function(a,b){var c=y.get(a+"Provider",b);return x.invoke(c.$get,c,w,a)}),x=K;n.$injectorProvider={$get:ia(K)};var q=g(a),x=K.get("$injector");x.strictDi=b;p(q,function(a){a&&x.invoke(a)});return x}function Te(){var a=!0;this.disableAutoScrolling=function(){a=!1};this.$get=["$window","$location","$rootScope",function(b,d,c){function e(a){var b=null;Array.prototype.some.call(a,function(a){if("a"===pa(a))return b=a,!0});return b}function f(a){if(a){a.scrollIntoView();
|
||||
var c;c=g.yOffset;H(c)?c=c():Ob(c)?(c=c[0],c="fixed"!==b.getComputedStyle(c).position?0:c.getBoundingClientRect().bottom):W(c)||(c=0);c&&(a=a.getBoundingClientRect().top,b.scrollBy(0,a-c))}else b.scrollTo(0,0)}function g(a){a=D(a)?a:d.hash();var b;a?(b=h.getElementById(a))?f(b):(b=e(h.getElementsByName(a)))?f(b):"top"===a&&f(null):f(null)}var h=b.document;a&&c.$watch(function(){return d.hash()},function(a,b){a===b&&""===a||Lf(function(){c.$evalAsync(g)})});return g}]}function hb(a,b){if(!a&&!b)return"";
|
||||
if(!a)return b;if(!b)return a;L(a)&&(a=a.join(" "));L(b)&&(b=b.join(" "));return a+" "+b}function Uf(a){D(a)&&(a=a.split(" "));var b=X();p(a,function(a){a.length&&(b[a]=!0)});return b}function Ha(a){return I(a)?a:{}}function Vf(a,b,d,c){function e(a){try{a.apply(null,ya.call(arguments,1))}finally{if(K--,0===K)for(;x.length;)try{x.pop()()}catch(b){d.error(b)}}}function f(){M=null;g();h()}function g(){a:{try{q=m.state;break a}catch(a){}q=void 0}q=v(q)?null:q;oa(q,T)&&(q=T);T=q}function h(){if(u!==k.url()||
|
||||
t!==q)u=k.url(),t=q,p(C,function(a){a(k.url(),q)})}var k=this,l=a.location,m=a.history,n=a.setTimeout,y=a.clearTimeout,B={};k.isMock=!1;var K=0,x=[];k.$$completeOutstandingRequest=e;k.$$incOutstandingRequestCount=function(){K++};k.notifyWhenNoOutstandingRequests=function(a){0===K?a():x.push(a)};var q,t,u=l.href,s=b.find("base"),M=null;g();t=q;k.url=function(b,d,e){v(e)&&(e=null);l!==a.location&&(l=a.location);m!==a.history&&(m=a.history);if(b){var f=t===e;if(u===b&&(!c.history||f))return k;var h=
|
||||
u&&Ia(u)===Ia(b);u=b;t=e;if(!c.history||h&&f){if(!h||M)M=b;d?l.replace(b):h?(d=l,e=b.indexOf("#"),e=-1===e?"":b.substr(e),d.hash=e):l.href=b;l.href!==b&&(M=b)}else m[d?"replaceState":"pushState"](e,"",b),g(),t=q;return k}return M||l.href.replace(/%27/g,"'")};k.state=function(){return q};var C=[],J=!1,T=null;k.onUrlChange=function(b){if(!J){if(c.history)G(a).on("popstate",f);G(a).on("hashchange",f);J=!0}C.push(b);return b};k.$$applicationDestroyed=function(){G(a).off("hashchange popstate",f)};k.$$checkUrlChange=
|
||||
h;k.baseHref=function(){var a=s.attr("href");return a?a.replace(/^(https?\:)?\/\/[^\/]*/,""):""};k.defer=function(a,b){var c;K++;c=n(function(){delete B[c];e(a)},b||0);B[c]=!0;return c};k.defer.cancel=function(a){return B[a]?(delete B[a],y(a),e(z),!0):!1}}function $e(){this.$get=["$window","$log","$sniffer","$document",function(a,b,d,c){return new Vf(a,c,b,d)}]}function af(){this.$get=function(){function a(a,c){function e(a){a!=n&&(y?y==a&&(y=a.n):y=a,f(a.n,a.p),f(a,n),n=a,n.n=null)}function f(a,
|
||||
b){a!=b&&(a&&(a.p=b),b&&(b.n=a))}if(a in b)throw O("$cacheFactory")("iid",a);var g=0,h=S({},c,{id:a}),k=X(),l=c&&c.capacity||Number.MAX_VALUE,m=X(),n=null,y=null;return b[a]={put:function(a,b){if(!v(b)){if(l<Number.MAX_VALUE){var c=m[a]||(m[a]={key:a});e(c)}a in k||g++;k[a]=b;g>l&&this.remove(y.key);return b}},get:function(a){if(l<Number.MAX_VALUE){var b=m[a];if(!b)return;e(b)}return k[a]},remove:function(a){if(l<Number.MAX_VALUE){var b=m[a];if(!b)return;b==n&&(n=b.p);b==y&&(y=b.n);f(b.n,b.p);delete m[a]}a in
|
||||
k&&(delete k[a],g--)},removeAll:function(){k=X();g=0;m=X();n=y=null},destroy:function(){m=h=k=null;delete b[a]},info:function(){return S({},h,{size:g})}}}var b={};a.info=function(){var a={};p(b,function(b,e){a[e]=b.info()});return a};a.get=function(a){return b[a]};return a}}function wf(){this.$get=["$cacheFactory",function(a){return a("templates")}]}function Bc(a,b){function d(a,b,c){var d=/^\s*([@&<]|=(\*?))(\??)\s*(\w*)\s*$/,e={};p(a,function(a,f){if(a in m)e[f]=m[a];else{var g=a.match(d);if(!g)throw la("iscp",
|
||||
b,f,a,c?"controller bindings definition":"isolate scope definition");e[f]={mode:g[1][0],collection:"*"===g[2],optional:"?"===g[3],attrName:g[4]||f};g[4]&&(m[a]=e[f])}});return e}function c(a){var b=a.charAt(0);if(!b||b!==E(b))throw la("baddir",a);if(a!==a.trim())throw la("baddir",a);}var e={},f=/^\s*directive\:\s*([\w\-]+)\s+(.*)$/,g=/(([\w\-]+)(?:\:([^;]+))?;?)/,h=Yd("ngSrc,ngSrcset,src,srcset"),k=/^(?:(\^\^?)?(\?)?(\^\^?)?)?/,l=/^(on[a-z]+|formaction)$/,m=X();this.directive=function B(b,d){Ra(b,
|
||||
"directive");D(b)?(c(b),sb(d,"directiveFactory"),e.hasOwnProperty(b)||(e[b]=[],a.factory(b+"Directive",["$injector","$exceptionHandler",function(a,c){var d=[];p(e[b],function(e,f){try{var g=a.invoke(e);H(g)?g={compile:ia(g)}:!g.compile&&g.link&&(g.compile=ia(g.link));g.priority=g.priority||0;g.index=f;g.name=g.name||b;g.require=g.require||g.controller&&g.name;g.restrict=g.restrict||"EA";g.$$moduleName=e.$$moduleName;d.push(g)}catch(h){c(h)}});return d}])),e[b].push(d)):p(b,pc(B));return this};this.component=
|
||||
function(a,b){function c(a){function e(b){return H(b)||L(b)?function(c,d){return a.invoke(b,this,{$element:c,$attrs:d})}:b}var f=b.template||b.templateUrl?b.template:"";return{controller:d,controllerAs:Tc(b.controller)||b.controllerAs||"$ctrl",template:e(f),templateUrl:e(b.templateUrl),transclude:b.transclude,scope:{},bindToController:b.bindings||{},restrict:"E",require:b.require}}var d=b.controller||z;p(b,function(a,b){"$"===b.charAt(0)&&(c[b]=a,d[b]=a)});c.$inject=["$injector"];return this.directive(a,
|
||||
c)};this.aHrefSanitizationWhitelist=function(a){return A(a)?(b.aHrefSanitizationWhitelist(a),this):b.aHrefSanitizationWhitelist()};this.imgSrcSanitizationWhitelist=function(a){return A(a)?(b.imgSrcSanitizationWhitelist(a),this):b.imgSrcSanitizationWhitelist()};var n=!0;this.debugInfoEnabled=function(a){return A(a)?(n=a,this):n};this.$get=["$injector","$interpolate","$exceptionHandler","$templateRequest","$parse","$controller","$rootScope","$sce","$animate","$$sanitizeUri",function(a,b,c,m,t,u,s,M,
|
||||
C,J){function T(a,b){if(b){var c=Object.keys(b),d,e,f;d=0;for(e=c.length;d<e;d++)f=c[d],this[f]=b[f]}else this.$attr={};this.$$element=a}function F(a,b,c){fa.innerHTML="<span "+b+">";b=fa.firstChild.attributes;var d=b[0];b.removeNamedItem(d.name);d.value=c;a.attributes.setNamedItem(d)}function $(a,b){try{a.addClass(b)}catch(c){}}function R(a,b,c,d,e){a instanceof G||(a=G(a));for(var f=/\S+/,g=0,h=a.length;g<h;g++){var k=a[g];k.nodeType===Na&&k.nodeValue.match(f)&&Lc(k,a[g]=Q.createElement("span"))}var l=
|
||||
P(a,b,a,c,d,e);R.$$addScopeClass(a);var m=null;return function(b,c,d){sb(b,"scope");e&&e.needsNewScope&&(b=b.$parent.$new());d=d||{};var f=d.parentBoundTranscludeFn,g=d.transcludeControllers;d=d.futureParentElement;f&&f.$$boundTransclude&&(f=f.$$boundTransclude);m||(m=(d=d&&d[0])?"foreignobject"!==pa(d)&&ha.call(d).match(/SVG/)?"svg":"html":"html");d="html"!==m?G(da(m,G("<div>").append(a).html())):c?Pa.clone.call(a):a;if(g)for(var h in g)d.data("$"+h+"Controller",g[h].instance);R.$$addScopeInfo(d,
|
||||
b);c&&c(d,b);l&&l(b,d,d,f);return d}}function P(a,b,c,d,e,f){function g(a,c,d,e){var f,k,l,m,n,C,u;if(q)for(u=Array(c.length),m=0;m<h.length;m+=3)f=h[m],u[f]=c[f];else u=c;m=0;for(n=h.length;m<n;)k=u[h[m++]],c=h[m++],f=h[m++],c?(c.scope?(l=a.$new(),R.$$addScopeInfo(G(k),l)):l=a,C=c.transcludeOnThisElement?ca(a,c.transclude,e):!c.templateOnThisElement&&e?e:!e&&b?ca(a,b):null,c(f,l,k,d,C)):f&&f(a,k.childNodes,w,e)}for(var h=[],k,l,m,n,q,C=0;C<a.length;C++){k=new T;l=Aa(a[C],[],k,0===C?d:w,e);(f=l.length?
|
||||
O(l,a[C],k,b,c,null,[],[],f):null)&&f.scope&&R.$$addScopeClass(k.$$element);k=f&&f.terminal||!(m=a[C].childNodes)||!m.length?null:P(m,f?(f.transcludeOnThisElement||!f.templateOnThisElement)&&f.transclude:b);if(f||k)h.push(C,f,k),n=!0,q=q||f;f=null}return n?g:null}function ca(a,b,c){function d(e,f,g,h,k){e||(e=a.$new(!1,k),e.$$transcluded=!0);return b(e,f,{parentBoundTranscludeFn:c,transcludeControllers:g,futureParentElement:h})}var e=d.$$slots=X(),f;for(f in b.$$slots)e[f]=b.$$slots[f]?ca(a,b.$$slots[f],
|
||||
c):null;return d}function Aa(a,b,c,d,e){var h=c.$attr,k;switch(a.nodeType){case 1:N(b,ua(pa(a)),"E",d,e);for(var l,m,n,q=a.attributes,C=0,u=q&&q.length;C<u;C++){var t=!1,J=!1;l=q[C];k=l.name;m=Z(l.value);l=ua(k);if(n=wa.test(l))k=k.replace(Uc,"").substr(8).replace(/_(.)/g,function(a,b){return b.toUpperCase()});(l=l.match(xa))&&va(l[1])&&(t=k,J=k.substr(0,k.length-5)+"end",k=k.substr(0,k.length-6));l=ua(k.toLowerCase());h[l]=k;if(n||!c.hasOwnProperty(l))c[l]=m,Qc(a,l)&&(c[l]=!0);ea(a,b,m,l,n);N(b,
|
||||
l,"A",d,e,t,J)}a=a.className;I(a)&&(a=a.animVal);if(D(a)&&""!==a)for(;k=g.exec(a);)l=ua(k[2]),N(b,l,"C",d,e)&&(c[l]=Z(k[3])),a=a.substr(k.index+k[0].length);break;case Na:if(11===za)for(;a.parentNode&&a.nextSibling&&a.nextSibling.nodeType===Na;)a.nodeValue+=a.nextSibling.nodeValue,a.parentNode.removeChild(a.nextSibling);ba(b,a.nodeValue);break;case 8:try{if(k=f.exec(a.nodeValue))l=ua(k[1]),N(b,l,"M",d,e)&&(c[l]=Z(k[2]))}catch(B){}}b.sort(V);return b}function r(a,b,c){var d=[],e=0;if(b&&a.hasAttribute&&
|
||||
a.hasAttribute(b)){do{if(!a)throw la("uterdir",b,c);1==a.nodeType&&(a.hasAttribute(b)&&e++,a.hasAttribute(c)&&e--);d.push(a);a=a.nextSibling}while(0<e)}else d.push(a);return G(d)}function A(a,b,c){return function(d,e,f,g,h){e=r(e[0],b,c);return a(d,e,f,g,h)}}function Yb(a,b,c,d,e,f){var g;return a?R(b,c,d,e,f):function(){g||(g=R(b,c,d,e,f),b=c=f=null);return g.apply(this,arguments)}}function O(a,b,d,e,f,g,h,k,l){function m(a,b,c,d){if(a){c&&(a=A(a,c,d));a.require=s.require;a.directiveName=K;if(t===
|
||||
s||s.$$isolateScope)a=ia(a,{isolateScope:!0});h.push(a)}if(b){c&&(b=A(b,c,d));b.require=s.require;b.directiveName=K;if(t===s||s.$$isolateScope)b=ia(b,{isolateScope:!0});k.push(b)}}function n(a,c,e,f,g){function l(a,b,c,d){var e;$a(a)||(d=c,c=b,b=a,a=w);M&&(e=F);c||(c=M?x.parent():x);if(d){var f=g.$$slots[d];if(f)return f(a,b,e,c,Aa);if(v(f))throw la("noslot",d,ta(x));}else return g(a,b,e,c,Aa)}var m,q,B,s,F,$,x,P;b===e?(f=d,x=d.$$element):(x=G(e),f=new T(x,d));B=c;t?s=c.$new(!0):C&&(B=c.$parent);
|
||||
g&&($=l,$.$$boundTransclude=g,$.isSlotFilled=function(a){return!!g.$$slots[a]});u&&(F=Xf(x,f,$,u,s,c,t));t&&(R.$$addScopeInfo(x,s,!0,!(J&&(J===t||J===t.$$originalDirective))),R.$$addScopeClass(x,!0),s.$$isolateBindings=t.$$isolateBindings,(P=ja(c,f,s,s.$$isolateBindings,t))&&s.$on("$destroy",P));for(q in F){P=u[q];var Ta=F[q],K=P.$$bindings.bindToController;Ta.identifier&&K&&(m=ja(B,f,Ta.instance,K,P));var ca=Ta();ca!==Ta.instance&&(Ta.instance=ca,x.data("$"+P.name+"Controller",ca),m&&m(),m=ja(B,
|
||||
f,Ta.instance,K,P))}p(u,function(a,b){var c=a.require;a.bindToController&&!L(c)&&I(c)&&S(F[b].instance,ib(b,c,x,F))});p(F,function(a){H(a.instance.$onInit)&&a.instance.$onInit()});m=0;for(q=h.length;m<q;m++)B=h[m],ma(B,B.isolateScope?s:c,x,f,B.require&&ib(B.directiveName,B.require,x,F),$);var Aa=c;t&&(t.template||null===t.templateUrl)&&(Aa=s);a&&a(Aa,e.childNodes,w,g);for(m=k.length-1;0<=m;m--)B=k[m],ma(B,B.isolateScope?s:c,x,f,B.require&&ib(B.directiveName,B.require,x,F),$)}l=l||{};for(var q=-Number.MAX_VALUE,
|
||||
C=l.newScopeDirective,u=l.controllerDirectives,t=l.newIsolateScopeDirective,J=l.templateDirective,B=l.nonTlbTranscludeDirective,F=!1,$=!1,M=l.hasElementTranscludeDirective,P=d.$$element=G(b),s,K,ca,z=e,D,va=!1,N=!1,E,Q=0,Ua=a.length;Q<Ua;Q++){s=a[Q];var V=s.$$start,ba=s.$$end;V&&(P=r(b,V,ba));ca=w;if(q>s.priority)break;if(E=s.scope)s.templateUrl||(I(E)?(aa("new/isolated scope",t||C,s,P),t=s):aa("new/isolated scope",t,s,P)),C=C||s;K=s.name;if(!va&&(s.replace&&(s.templateUrl||s.template)||s.transclude&&
|
||||
!s.$$tlb)){for(E=Q+1;va=a[E++];)if(va.transclude&&!va.$$tlb||va.replace&&(va.templateUrl||va.template)){N=!0;break}va=!0}!s.templateUrl&&s.controller&&(E=s.controller,u=u||X(),aa("'"+K+"' controller",u[K],s,P),u[K]=s);if(E=s.transclude)if(F=!0,s.$$tlb||(aa("transclusion",B,s,P),B=s),"element"==E)M=!0,q=s.priority,ca=P,P=d.$$element=G(R.$$createComment(K,d[K])),b=P[0],ga(f,ya.call(ca,0),b),z=Yb(N,ca,e,q,g&&g.name,{nonTlbTranscludeDirective:B});else{var U=X();ca=G(Vb(b)).contents();if(I(E)){ca=[];var ea=
|
||||
X(),fa=X();p(E,function(a,b){var c="?"===a.charAt(0);a=c?a.substring(1):a;ea[a]=b;U[b]=null;fa[b]=c});p(P.contents(),function(a){var b=ea[ua(pa(a))];b?(fa[b]=!0,U[b]=U[b]||[],U[b].push(a)):ca.push(a)});p(fa,function(a,b){if(!a)throw la("reqslot",b);});for(var ha in U)U[ha]&&(U[ha]=Yb(N,U[ha],e))}P.empty();z=Yb(N,ca,e,w,w,{needsNewScope:s.$$isolateScope||s.$$newScope});z.$$slots=U}if(s.template)if($=!0,aa("template",J,s,P),J=s,E=H(s.template)?s.template(P,d):s.template,E=ra(E),s.replace){g=s;ca=Tb.test(E)?
|
||||
Vc(da(s.templateNamespace,Z(E))):[];b=ca[0];if(1!=ca.length||1!==b.nodeType)throw la("tplrt",K,"");ga(f,P,b);Ua={$attr:{}};E=Aa(b,[],Ua);var ka=a.splice(Q+1,a.length-(Q+1));(t||C)&&Wc(E,t,C);a=a.concat(E).concat(ka);W(d,Ua);Ua=a.length}else P.html(E);if(s.templateUrl)$=!0,aa("template",J,s,P),J=s,s.replace&&(g=s),n=Y(a.splice(Q,a.length-Q),P,d,f,F&&z,h,k,{controllerDirectives:u,newScopeDirective:C!==s&&C,newIsolateScopeDirective:t,templateDirective:J,nonTlbTranscludeDirective:B}),Ua=a.length;else if(s.compile)try{D=
|
||||
s.compile(P,d,z),H(D)?m(null,D,V,ba):D&&m(D.pre,D.post,V,ba)}catch(Wf){c(Wf,ta(P))}s.terminal&&(n.terminal=!0,q=Math.max(q,s.priority))}n.scope=C&&!0===C.scope;n.transcludeOnThisElement=F;n.templateOnThisElement=$;n.transclude=z;l.hasElementTranscludeDirective=M;return n}function ib(a,b,c,d){var e;if(D(b)){var f=b.match(k);b=b.substring(f[0].length);var g=f[1]||f[3],f="?"===f[2];"^^"===g?c=c.parent():e=(e=d&&d[b])&&e.instance;if(!e){var h="$"+b+"Controller";e=g?c.inheritedData(h):c.data(h)}if(!e&&
|
||||
!f)throw la("ctreq",b,a);}else if(L(b))for(e=[],g=0,f=b.length;g<f;g++)e[g]=ib(a,b[g],c,d);else I(b)&&(e={},p(b,function(b,f){e[f]=ib(a,b,c,d)}));return e||null}function Xf(a,b,c,d,e,f,g){var h=X(),k;for(k in d){var l=d[k],m={$scope:l===g||l.$$isolateScope?e:f,$element:a,$attrs:b,$transclude:c},n=l.controller;"@"==n&&(n=b[l.name]);m=u(n,m,!0,l.controllerAs);h[l.name]=m;a.data("$"+l.name+"Controller",m.instance)}return h}function Wc(a,b,c){for(var d=0,e=a.length;d<e;d++)a[d]=Pb(a[d],{$$isolateScope:b,
|
||||
$$newScope:c})}function N(b,f,g,h,k,l,m){if(f===k)return null;k=null;if(e.hasOwnProperty(f)){var n;f=a.get(f+"Directive");for(var q=0,C=f.length;q<C;q++)try{if(n=f[q],(v(h)||h>n.priority)&&-1!=n.restrict.indexOf(g)){l&&(n=Pb(n,{$$start:l,$$end:m}));if(!n.$$bindings){var u=n,t=n,J=n.name,s={isolateScope:null,bindToController:null};I(t.scope)&&(!0===t.bindToController?(s.bindToController=d(t.scope,J,!0),s.isolateScope={}):s.isolateScope=d(t.scope,J,!1));I(t.bindToController)&&(s.bindToController=d(t.bindToController,
|
||||
J,!0));if(I(s.bindToController)){var F=t.controller,$=t.controllerAs;if(!F)throw la("noctrl",J);if(!Tc(F,$))throw la("noident",J);}var T=u.$$bindings=s;I(T.isolateScope)&&(n.$$isolateBindings=T.isolateScope)}b.push(n);k=n}}catch(P){c(P)}}return k}function va(b){if(e.hasOwnProperty(b))for(var c=a.get(b+"Directive"),d=0,f=c.length;d<f;d++)if(b=c[d],b.multiElement)return!0;return!1}function W(a,b){var c=b.$attr,d=a.$attr,e=a.$$element;p(a,function(d,e){"$"!=e.charAt(0)&&(b[e]&&b[e]!==d&&(d+=("style"===
|
||||
e?";":" ")+b[e]),a.$set(e,d,!0,c[e]))});p(b,function(b,f){"class"==f?($(e,b),a["class"]=(a["class"]?a["class"]+" ":"")+b):"style"==f?(e.attr("style",e.attr("style")+";"+b),a.style=(a.style?a.style+";":"")+b):"$"==f.charAt(0)||a.hasOwnProperty(f)||(a[f]=b,d[f]=c[f])})}function Y(a,b,c,d,e,f,g,h){var k=[],l,n,C=b[0],u=a.shift(),t=Pb(u,{templateUrl:null,transclude:null,replace:null,$$originalDirective:u}),J=H(u.templateUrl)?u.templateUrl(b,c):u.templateUrl,B=u.templateNamespace;b.empty();m(J).then(function(m){var q,
|
||||
s;m=ra(m);if(u.replace){m=Tb.test(m)?Vc(da(B,Z(m))):[];q=m[0];if(1!=m.length||1!==q.nodeType)throw la("tplrt",u.name,J);m={$attr:{}};ga(d,b,q);var F=Aa(q,[],m);I(u.scope)&&Wc(F,!0);a=F.concat(a);W(c,m)}else q=C,b.html(m);a.unshift(t);l=O(a,q,c,e,b,u,f,g,h);p(d,function(a,c){a==q&&(d[c]=b[0])});for(n=P(b[0].childNodes,e);k.length;){m=k.shift();s=k.shift();var x=k.shift(),T=k.shift(),F=b[0];if(!m.$$destroyed){if(s!==C){var R=s.className;h.hasElementTranscludeDirective&&u.replace||(F=Vb(q));ga(x,G(s),
|
||||
F);$(G(F),R)}s=l.transcludeOnThisElement?ca(m,l.transclude,T):T;l(n,m,F,d,s)}}k=null});return function(a,b,c,d,e){a=e;b.$$destroyed||(k?k.push(b,c,d,a):(l.transcludeOnThisElement&&(a=ca(b,l.transclude,e)),l(n,b,c,d,a)))}}function V(a,b){var c=b.priority-a.priority;return 0!==c?c:a.name!==b.name?a.name<b.name?-1:1:a.index-b.index}function aa(a,b,c,d){function e(a){return a?" (module: "+a+")":""}if(b)throw la("multidir",b.name,e(b.$$moduleName),c.name,e(c.$$moduleName),a,ta(d));}function ba(a,c){var d=
|
||||
b(c,!0);d&&a.push({priority:0,compile:function(a){a=a.parent();var b=!!a.length;b&&R.$$addBindingClass(a);return function(a,c){var e=c.parent();b||R.$$addBindingClass(e);R.$$addBindingInfo(e,d.expressions);a.$watch(d,function(a){c[0].nodeValue=a})}}})}function da(a,b){a=E(a||"html");switch(a){case "svg":case "math":var c=Q.createElement("div");c.innerHTML="<"+a+">"+b+"</"+a+">";return c.childNodes[0].childNodes;default:return b}}function U(a,b){if("srcdoc"==b)return M.HTML;var c=pa(a);if("xlinkHref"==
|
||||
b||"form"==c&&"action"==b||"img"!=c&&("src"==b||"ngSrc"==b))return M.RESOURCE_URL}function ea(a,c,d,e,f){var g=U(a,e);f=h[e]||f;var k=b(d,!0,g,f);if(k){if("multiple"===e&&"select"===pa(a))throw la("selmulti",ta(a));c.push({priority:100,compile:function(){return{pre:function(a,c,h){c=h.$$observers||(h.$$observers=X());if(l.test(e))throw la("nodomevents");var m=h[e];m!==d&&(k=m&&b(m,!0,g,f),d=m);k&&(h[e]=k(a),(c[e]||(c[e]=[])).$$inter=!0,(h.$$observers&&h.$$observers[e].$$scope||a).$watch(k,function(a,
|
||||
b){"class"===e&&a!=b?h.$updateClass(a,b):h.$set(e,a)}))}}}})}}function ga(a,b,c){var d=b[0],e=b.length,f=d.parentNode,g,h;if(a)for(g=0,h=a.length;g<h;g++)if(a[g]==d){a[g++]=c;h=g+e-1;for(var k=a.length;g<k;g++,h++)h<k?a[g]=a[h]:delete a[g];a.length-=e-1;a.context===d&&(a.context=c);break}f&&f.replaceChild(c,d);a=Q.createDocumentFragment();for(g=0;g<e;g++)a.appendChild(b[g]);G.hasData(d)&&(G.data(c,G.data(d)),G(d).off("$destroy"));G.cleanData(a.querySelectorAll("*"));for(g=1;g<e;g++)delete b[g];b[0]=
|
||||
c;b.length=1}function ia(a,b){return S(function(){return a.apply(null,arguments)},a,b)}function ma(a,b,d,e,f,g){try{a(b,d,e,f,g)}catch(h){c(h,ta(d))}}function ja(a,c,d,e,f){var g=[];p(e,function(e,h){var k=e.attrName,l=e.optional,m,n,q,C;switch(e.mode){case "@":l||sa.call(c,k)||(d[h]=c[k]=void 0);c.$observe(k,function(a){D(a)&&(d[h]=a)});c.$$observers[k].$$scope=a;m=c[k];D(m)?d[h]=b(m)(a):Ma(m)&&(d[h]=m);break;case "=":if(!sa.call(c,k)){if(l)break;c[k]=void 0}if(l&&!c[k])break;n=t(c[k]);C=n.literal?
|
||||
oa:function(a,b){return a===b||a!==a&&b!==b};q=n.assign||function(){m=d[h]=n(a);throw la("nonassign",c[k],k,f.name);};m=d[h]=n(a);l=function(b){C(b,d[h])||(C(b,m)?q(a,b=d[h]):d[h]=b);return m=b};l.$stateful=!0;l=e.collection?a.$watchCollection(c[k],l):a.$watch(t(c[k],l),null,n.literal);g.push(l);break;case "<":if(!sa.call(c,k)){if(l)break;c[k]=void 0}if(l&&!c[k])break;n=t(c[k]);d[h]=n(a);l=a.$watch(n,function(a){d[h]=a},n.literal);g.push(l);break;case "&":n=c.hasOwnProperty(k)?t(c[k]):z;if(n===z&&
|
||||
l)break;d[h]=function(b){return n(a,b)}}});return g.length&&function(){for(var a=0,b=g.length;a<b;++a)g[a]()}}var ka=/^\w/,fa=Q.createElement("div");T.prototype={$normalize:ua,$addClass:function(a){a&&0<a.length&&C.addClass(this.$$element,a)},$removeClass:function(a){a&&0<a.length&&C.removeClass(this.$$element,a)},$updateClass:function(a,b){var c=Xc(a,b);c&&c.length&&C.addClass(this.$$element,c);(c=Xc(b,a))&&c.length&&C.removeClass(this.$$element,c)},$set:function(a,b,d,e){var f=Qc(this.$$element[0],
|
||||
a),g=Yc[a],h=a;f?(this.$$element.prop(a,b),e=f):g&&(this[g]=b,h=g);this[a]=b;e?this.$attr[a]=e:(e=this.$attr[a])||(this.$attr[a]=e=yc(a,"-"));f=pa(this.$$element);if("a"===f&&("href"===a||"xlinkHref"===a)||"img"===f&&"src"===a)this[a]=b=J(b,"src"===a);else if("img"===f&&"srcset"===a){for(var f="",g=Z(b),k=/(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/,k=/\s/.test(g)?k:/(,)/,g=g.split(k),k=Math.floor(g.length/2),l=0;l<k;l++)var m=2*l,f=f+J(Z(g[m]),!0),f=f+(" "+Z(g[m+1]));g=Z(g[2*l]).split(/\s/);f+=J(Z(g[0]),
|
||||
!0);2===g.length&&(f+=" "+Z(g[1]));this[a]=b=f}!1!==d&&(null===b||v(b)?this.$$element.removeAttr(e):ka.test(e)?this.$$element.attr(e,b):F(this.$$element[0],e,b));(a=this.$$observers)&&p(a[h],function(a){try{a(b)}catch(d){c(d)}})},$observe:function(a,b){var c=this,d=c.$$observers||(c.$$observers=X()),e=d[a]||(d[a]=[]);e.push(b);s.$evalAsync(function(){e.$$inter||!c.hasOwnProperty(a)||v(c[a])||b(c[a])});return function(){ab(e,b)}}};var na=b.startSymbol(),qa=b.endSymbol(),ra="{{"==na&&"}}"==qa?Za:function(a){return a.replace(/\{\{/g,
|
||||
na).replace(/}}/g,qa)},wa=/^ngAttr[A-Z]/,xa=/^(.+)Start$/;R.$$addBindingInfo=n?function(a,b){var c=a.data("$binding")||[];L(b)?c=c.concat(b):c.push(b);a.data("$binding",c)}:z;R.$$addBindingClass=n?function(a){$(a,"ng-binding")}:z;R.$$addScopeInfo=n?function(a,b,c,d){a.data(c?d?"$isolateScopeNoTemplate":"$isolateScope":"$scope",b)}:z;R.$$addScopeClass=n?function(a,b){$(a,b?"ng-isolate-scope":"ng-scope")}:z;R.$$createComment=function(a,b){var c="";n&&(c=" "+(a||"")+": "+(b||"")+" ");return Q.createComment(c)};
|
||||
return R}]}function ua(a){return eb(a.replace(Uc,""))}function Xc(a,b){var d="",c=a.split(/\s+/),e=b.split(/\s+/),f=0;a:for(;f<c.length;f++){for(var g=c[f],h=0;h<e.length;h++)if(g==e[h])continue a;d+=(0<d.length?" ":"")+g}return d}function Vc(a){a=G(a);var b=a.length;if(1>=b)return a;for(;b--;)8===a[b].nodeType&&Yf.call(a,b,1);return a}function Tc(a,b){if(b&&D(b))return b;if(D(a)){var d=Zc.exec(a);if(d)return d[3]}}function bf(){var a={},b=!1;this.has=function(b){return a.hasOwnProperty(b)};this.register=
|
||||
function(b,c){Ra(b,"controller");I(b)?S(a,b):a[b]=c};this.allowGlobals=function(){b=!0};this.$get=["$injector","$window",function(d,c){function e(a,b,c,d){if(!a||!I(a.$scope))throw O("$controller")("noscp",d,b);a.$scope[b]=c}return function(f,g,h,k){var l,m,n;h=!0===h;k&&D(k)&&(n=k);if(D(f)){k=f.match(Zc);if(!k)throw Zf("ctrlfmt",f);m=k[1];n=n||k[3];f=a.hasOwnProperty(m)?a[m]:Ac(g.$scope,m,!0)||(b?Ac(c,m,!0):w);Qa(f,m,!0)}if(h)return h=(L(f)?f[f.length-1]:f).prototype,l=Object.create(h||null),n&&
|
||||
e(g,n,l,m||f.name),S(function(){var a=d.invoke(f,l,g,m);a!==l&&(I(a)||H(a))&&(l=a,n&&e(g,n,l,m||f.name));return l},{instance:l,identifier:n});l=d.instantiate(f,g,m);n&&e(g,n,l,m||f.name);return l}}]}function cf(){this.$get=["$window",function(a){return G(a.document)}]}function df(){this.$get=["$log",function(a){return function(b,d){a.error.apply(a,arguments)}}]}function Zb(a){return I(a)?ga(a)?a.toISOString():cb(a):a}function jf(){this.$get=function(){return function(a){if(!a)return"";var b=[];oc(a,
|
||||
function(a,c){null===a||v(a)||(L(a)?p(a,function(a){b.push(ja(c)+"="+ja(Zb(a)))}):b.push(ja(c)+"="+ja(Zb(a))))});return b.join("&")}}}function kf(){this.$get=function(){return function(a){function b(a,e,f){null===a||v(a)||(L(a)?p(a,function(a,c){b(a,e+"["+(I(a)?c:"")+"]")}):I(a)&&!ga(a)?oc(a,function(a,c){b(a,e+(f?"":"[")+c+(f?"":"]"))}):d.push(ja(e)+"="+ja(Zb(a))))}if(!a)return"";var d=[];b(a,"",!0);return d.join("&")}}}function $b(a,b){if(D(a)){var d=a.replace($f,"").trim();if(d){var c=b("Content-Type");
|
||||
(c=c&&0===c.indexOf($c))||(c=(c=d.match(ag))&&bg[c[0]].test(d));c&&(a=tc(d))}}return a}function ad(a){var b=X(),d;D(a)?p(a.split("\n"),function(a){d=a.indexOf(":");var e=E(Z(a.substr(0,d)));a=Z(a.substr(d+1));e&&(b[e]=b[e]?b[e]+", "+a:a)}):I(a)&&p(a,function(a,d){var f=E(d),g=Z(a);f&&(b[f]=b[f]?b[f]+", "+g:g)});return b}function bd(a){var b;return function(d){b||(b=ad(a));return d?(d=b[E(d)],void 0===d&&(d=null),d):b}}function cd(a,b,d,c){if(H(c))return c(a,b,d);p(c,function(c){a=c(a,b,d)});return a}
|
||||
function hf(){var a=this.defaults={transformResponse:[$b],transformRequest:[function(a){return I(a)&&"[object File]"!==ha.call(a)&&"[object Blob]"!==ha.call(a)&&"[object FormData]"!==ha.call(a)?cb(a):a}],headers:{common:{Accept:"application/json, text/plain, */*"},post:ma(ac),put:ma(ac),patch:ma(ac)},xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",paramSerializer:"$httpParamSerializer"},b=!1;this.useApplyAsync=function(a){return A(a)?(b=!!a,this):b};var d=!0;this.useLegacyPromiseExtensions=
|
||||
function(a){return A(a)?(d=!!a,this):d};var c=this.interceptors=[];this.$get=["$httpBackend","$$cookieReader","$cacheFactory","$rootScope","$q","$injector",function(e,f,g,h,k,l){function m(b){function c(a){var b=S({},a);b.data=cd(a.data,a.headers,a.status,f.transformResponse);a=a.status;return 200<=a&&300>a?b:k.reject(b)}function e(a,b){var c,d={};p(a,function(a,e){H(a)?(c=a(b),null!=c&&(d[e]=c)):d[e]=a});return d}if(!I(b))throw O("$http")("badreq",b);if(!D(b.url))throw O("$http")("badreq",b.url);
|
||||
var f=S({method:"get",transformRequest:a.transformRequest,transformResponse:a.transformResponse,paramSerializer:a.paramSerializer},b);f.headers=function(b){var c=a.headers,d=S({},b.headers),f,g,h,c=S({},c.common,c[E(b.method)]);a:for(f in c){g=E(f);for(h in d)if(E(h)===g)continue a;d[f]=c[f]}return e(d,ma(b))}(b);f.method=ub(f.method);f.paramSerializer=D(f.paramSerializer)?l.get(f.paramSerializer):f.paramSerializer;var g=[function(b){var d=b.headers,e=cd(b.data,bd(d),w,b.transformRequest);v(e)&&p(d,
|
||||
function(a,b){"content-type"===E(b)&&delete d[b]});v(b.withCredentials)&&!v(a.withCredentials)&&(b.withCredentials=a.withCredentials);return n(b,e).then(c,c)},w],h=k.when(f);for(p(K,function(a){(a.request||a.requestError)&&g.unshift(a.request,a.requestError);(a.response||a.responseError)&&g.push(a.response,a.responseError)});g.length;){b=g.shift();var m=g.shift(),h=h.then(b,m)}d?(h.success=function(a){Qa(a,"fn");h.then(function(b){a(b.data,b.status,b.headers,f)});return h},h.error=function(a){Qa(a,
|
||||
"fn");h.then(null,function(b){a(b.data,b.status,b.headers,f)});return h}):(h.success=dd("success"),h.error=dd("error"));return h}function n(c,d){function g(a,c,d,e){function f(){l(c,a,d,e)}T&&(200<=a&&300>a?T.put(R,[a,c,ad(d),e]):T.remove(R));b?h.$applyAsync(f):(f(),h.$$phase||h.$apply())}function l(a,b,d,e){b=-1<=b?b:0;(200<=b&&300>b?C.resolve:C.reject)({data:a,status:b,headers:bd(d),config:c,statusText:e})}function n(a){l(a.data,a.status,ma(a.headers()),a.statusText)}function K(){var a=m.pendingRequests.indexOf(c);
|
||||
-1!==a&&m.pendingRequests.splice(a,1)}var C=k.defer(),J=C.promise,T,F,$=c.headers,R=y(c.url,c.paramSerializer(c.params));m.pendingRequests.push(c);J.then(K,K);!c.cache&&!a.cache||!1===c.cache||"GET"!==c.method&&"JSONP"!==c.method||(T=I(c.cache)?c.cache:I(a.cache)?a.cache:B);T&&(F=T.get(R),A(F)?F&&H(F.then)?F.then(n,n):L(F)?l(F[1],F[0],ma(F[2]),F[3]):l(F,200,{},"OK"):T.put(R,J));v(F)&&((F=ed(c.url)?f()[c.xsrfCookieName||a.xsrfCookieName]:w)&&($[c.xsrfHeaderName||a.xsrfHeaderName]=F),e(c.method,R,d,
|
||||
g,$,c.timeout,c.withCredentials,c.responseType));return J}function y(a,b){0<b.length&&(a+=(-1==a.indexOf("?")?"?":"&")+b);return a}var B=g("$http");a.paramSerializer=D(a.paramSerializer)?l.get(a.paramSerializer):a.paramSerializer;var K=[];p(c,function(a){K.unshift(D(a)?l.get(a):l.invoke(a))});m.pendingRequests=[];(function(a){p(arguments,function(a){m[a]=function(b,c){return m(S({},c||{},{method:a,url:b}))}})})("get","delete","head","jsonp");(function(a){p(arguments,function(a){m[a]=function(b,c,
|
||||
d){return m(S({},d||{},{method:a,url:b,data:c}))}})})("post","put","patch");m.defaults=a;return m}]}function mf(){this.$get=function(){return function(){return new N.XMLHttpRequest}}}function lf(){this.$get=["$browser","$window","$document","$xhrFactory",function(a,b,d,c){return cg(a,c,a.defer,b.angular.callbacks,d[0])}]}function cg(a,b,d,c,e){function f(a,b,d){var f=e.createElement("script"),m=null;f.type="text/javascript";f.src=a;f.async=!0;m=function(a){f.removeEventListener("load",m,!1);f.removeEventListener("error",
|
||||
m,!1);e.body.removeChild(f);f=null;var g=-1,B="unknown";a&&("load"!==a.type||c[b].called||(a={type:"error"}),B=a.type,g="error"===a.type?404:200);d&&d(g,B)};f.addEventListener("load",m,!1);f.addEventListener("error",m,!1);e.body.appendChild(f);return m}return function(e,h,k,l,m,n,y,B){function K(){t&&t();u&&u.abort()}function x(b,c,e,f,g){A(M)&&d.cancel(M);t=u=null;b(c,e,f,g);a.$$completeOutstandingRequest(z)}a.$$incOutstandingRequestCount();h=h||a.url();if("jsonp"==E(e)){var q="_"+(c.counter++).toString(36);
|
||||
c[q]=function(a){c[q].data=a;c[q].called=!0};var t=f(h.replace("JSON_CALLBACK","angular.callbacks."+q),q,function(a,b){x(l,a,c[q].data,"",b);c[q]=z})}else{var u=b(e,h);u.open(e,h,!0);p(m,function(a,b){A(a)&&u.setRequestHeader(b,a)});u.onload=function(){var a=u.statusText||"",b="response"in u?u.response:u.responseText,c=1223===u.status?204:u.status;0===c&&(c=b?200:"file"==wa(h).protocol?404:0);x(l,c,b,u.getAllResponseHeaders(),a)};e=function(){x(l,-1,null,null,"")};u.onerror=e;u.onabort=e;y&&(u.withCredentials=
|
||||
!0);if(B)try{u.responseType=B}catch(s){if("json"!==B)throw s;}u.send(v(k)?null:k)}if(0<n)var M=d(K,n);else n&&H(n.then)&&n.then(K)}}function ff(){var a="{{",b="}}";this.startSymbol=function(b){return b?(a=b,this):a};this.endSymbol=function(a){return a?(b=a,this):b};this.$get=["$parse","$exceptionHandler","$sce",function(d,c,e){function f(a){return"\\\\\\"+a}function g(c){return c.replace(n,a).replace(y,b)}function h(a,b,c,d){var e;return e=a.$watch(function(a){e();return d(a)},b,c)}function k(f,k,
|
||||
n,q){function y(a){try{var b=a;a=n?e.getTrusted(n,b):e.valueOf(b);var d;if(q&&!A(a))d=a;else if(null==a)d="";else{switch(typeof a){case "string":break;case "number":a=""+a;break;default:a=cb(a)}d=a}return d}catch(g){c(Ja.interr(f,g))}}if(!f.length||-1===f.indexOf(a)){var u;k||(k=g(f),u=ia(k),u.exp=f,u.expressions=[],u.$$watchDelegate=h);return u}q=!!q;var s,p,C=0,J=[],T=[];u=f.length;for(var F=[],$=[];C<u;)if(-1!=(s=f.indexOf(a,C))&&-1!=(p=f.indexOf(b,s+l)))C!==s&&F.push(g(f.substring(C,s))),C=f.substring(s+
|
||||
l,p),J.push(C),T.push(d(C,y)),C=p+m,$.push(F.length),F.push("");else{C!==u&&F.push(g(f.substring(C)));break}n&&1<F.length&&Ja.throwNoconcat(f);if(!k||J.length){var R=function(a){for(var b=0,c=J.length;b<c;b++){if(q&&v(a[b]))return;F[$[b]]=a[b]}return F.join("")};return S(function(a){var b=0,d=J.length,e=Array(d);try{for(;b<d;b++)e[b]=T[b](a);return R(e)}catch(g){c(Ja.interr(f,g))}},{exp:f,expressions:J,$$watchDelegate:function(a,b){var c;return a.$watchGroup(T,function(d,e){var f=R(d);H(b)&&b.call(this,
|
||||
f,d!==e?c:f,a);c=f})}})}}var l=a.length,m=b.length,n=new RegExp(a.replace(/./g,f),"g"),y=new RegExp(b.replace(/./g,f),"g");k.startSymbol=function(){return a};k.endSymbol=function(){return b};return k}]}function gf(){this.$get=["$rootScope","$window","$q","$$q","$browser",function(a,b,d,c,e){function f(f,k,l,m){function n(){y?f.apply(null,B):f(q)}var y=4<arguments.length,B=y?ya.call(arguments,4):[],p=b.setInterval,x=b.clearInterval,q=0,t=A(m)&&!m,u=(t?c:d).defer(),s=u.promise;l=A(l)?l:0;s.$$intervalId=
|
||||
p(function(){t?e.defer(n):a.$evalAsync(n);u.notify(q++);0<l&&q>=l&&(u.resolve(q),x(s.$$intervalId),delete g[s.$$intervalId]);t||a.$apply()},k);g[s.$$intervalId]=u;return s}var g={};f.cancel=function(a){return a&&a.$$intervalId in g?(g[a.$$intervalId].reject("canceled"),b.clearInterval(a.$$intervalId),delete g[a.$$intervalId],!0):!1};return f}]}function bc(a){a=a.split("/");for(var b=a.length;b--;)a[b]=qb(a[b]);return a.join("/")}function fd(a,b){var d=wa(a);b.$$protocol=d.protocol;b.$$host=d.hostname;
|
||||
b.$$port=da(d.port)||dg[d.protocol]||null}function gd(a,b){var d="/"!==a.charAt(0);d&&(a="/"+a);var c=wa(a);b.$$path=decodeURIComponent(d&&"/"===c.pathname.charAt(0)?c.pathname.substring(1):c.pathname);b.$$search=wc(c.search);b.$$hash=decodeURIComponent(c.hash);b.$$path&&"/"!=b.$$path.charAt(0)&&(b.$$path="/"+b.$$path)}function na(a,b){if(0===b.indexOf(a))return b.substr(a.length)}function Ia(a){var b=a.indexOf("#");return-1==b?a:a.substr(0,b)}function jb(a){return a.replace(/(#.+)|#$/,"$1")}function cc(a,
|
||||
b,d){this.$$html5=!0;d=d||"";fd(a,this);this.$$parse=function(a){var d=na(b,a);if(!D(d))throw Eb("ipthprfx",a,b);gd(d,this);this.$$path||(this.$$path="/");this.$$compose()};this.$$compose=function(){var a=Rb(this.$$search),d=this.$$hash?"#"+qb(this.$$hash):"";this.$$url=bc(this.$$path)+(a?"?"+a:"")+d;this.$$absUrl=b+this.$$url.substr(1)};this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),!0;var f,g;A(f=na(a,c))?(g=f,g=A(f=na(d,f))?b+(na("/",f)||f):a+g):A(f=na(b,c))?g=
|
||||
b+f:b==c+"/"&&(g=b);g&&this.$$parse(g);return!!g}}function dc(a,b,d){fd(a,this);this.$$parse=function(c){var e=na(a,c)||na(b,c),f;v(e)||"#"!==e.charAt(0)?this.$$html5?f=e:(f="",v(e)&&(a=c,this.replace())):(f=na(d,e),v(f)&&(f=e));gd(f,this);c=this.$$path;var e=a,g=/^\/[A-Z]:(\/.*)/;0===f.indexOf(e)&&(f=f.replace(e,""));g.exec(f)||(c=(f=g.exec(c))?f[1]:c);this.$$path=c;this.$$compose()};this.$$compose=function(){var b=Rb(this.$$search),e=this.$$hash?"#"+qb(this.$$hash):"";this.$$url=bc(this.$$path)+
|
||||
(b?"?"+b:"")+e;this.$$absUrl=a+(this.$$url?d+this.$$url:"")};this.$$parseLinkUrl=function(b,d){return Ia(a)==Ia(b)?(this.$$parse(b),!0):!1}}function hd(a,b,d){this.$$html5=!0;dc.apply(this,arguments);this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),!0;var f,g;a==Ia(c)?f=c:(g=na(b,c))?f=a+d+g:b===c+"/"&&(f=b);f&&this.$$parse(f);return!!f};this.$$compose=function(){var b=Rb(this.$$search),e=this.$$hash?"#"+qb(this.$$hash):"";this.$$url=bc(this.$$path)+(b?"?"+b:"")+e;this.$$absUrl=
|
||||
a+d+this.$$url}}function Fb(a){return function(){return this[a]}}function id(a,b){return function(d){if(v(d))return this[a];this[a]=b(d);this.$$compose();return this}}function nf(){var a="",b={enabled:!1,requireBase:!0,rewriteLinks:!0};this.hashPrefix=function(b){return A(b)?(a=b,this):a};this.html5Mode=function(a){return Ma(a)?(b.enabled=a,this):I(a)?(Ma(a.enabled)&&(b.enabled=a.enabled),Ma(a.requireBase)&&(b.requireBase=a.requireBase),Ma(a.rewriteLinks)&&(b.rewriteLinks=a.rewriteLinks),this):b};
|
||||
this.$get=["$rootScope","$browser","$sniffer","$rootElement","$window",function(d,c,e,f,g){function h(a,b,d){var e=l.url(),f=l.$$state;try{c.url(a,b,d),l.$$state=c.state()}catch(g){throw l.url(e),l.$$state=f,g;}}function k(a,b){d.$broadcast("$locationChangeSuccess",l.absUrl(),a,l.$$state,b)}var l,m;m=c.baseHref();var n=c.url(),y;if(b.enabled){if(!m&&b.requireBase)throw Eb("nobase");y=n.substring(0,n.indexOf("/",n.indexOf("//")+2))+(m||"/");m=e.history?cc:hd}else y=Ia(n),m=dc;var B=y.substr(0,Ia(y).lastIndexOf("/")+
|
||||
1);l=new m(y,B,"#"+a);l.$$parseLinkUrl(n,n);l.$$state=c.state();var p=/^\s*(javascript|mailto):/i;f.on("click",function(a){if(b.rewriteLinks&&!a.ctrlKey&&!a.metaKey&&!a.shiftKey&&2!=a.which&&2!=a.button){for(var e=G(a.target);"a"!==pa(e[0]);)if(e[0]===f[0]||!(e=e.parent())[0])return;var h=e.prop("href"),k=e.attr("href")||e.attr("xlink:href");I(h)&&"[object SVGAnimatedString]"===h.toString()&&(h=wa(h.animVal).href);p.test(h)||!h||e.attr("target")||a.isDefaultPrevented()||!l.$$parseLinkUrl(h,k)||(a.preventDefault(),
|
||||
l.absUrl()!=c.url()&&(d.$apply(),g.angular["ff-684208-preventDefault"]=!0))}});jb(l.absUrl())!=jb(n)&&c.url(l.absUrl(),!0);var x=!0;c.onUrlChange(function(a,b){v(na(B,a))?g.location.href=a:(d.$evalAsync(function(){var c=l.absUrl(),e=l.$$state,f;a=jb(a);l.$$parse(a);l.$$state=b;f=d.$broadcast("$locationChangeStart",a,c,b,e).defaultPrevented;l.absUrl()===a&&(f?(l.$$parse(c),l.$$state=e,h(c,!1,e)):(x=!1,k(c,e)))}),d.$$phase||d.$digest())});d.$watch(function(){var a=jb(c.url()),b=jb(l.absUrl()),f=c.state(),
|
||||
g=l.$$replace,m=a!==b||l.$$html5&&e.history&&f!==l.$$state;if(x||m)x=!1,d.$evalAsync(function(){var b=l.absUrl(),c=d.$broadcast("$locationChangeStart",b,a,l.$$state,f).defaultPrevented;l.absUrl()===b&&(c?(l.$$parse(a),l.$$state=f):(m&&h(b,g,f===l.$$state?null:l.$$state),k(a,f)))});l.$$replace=!1});return l}]}function of(){var a=!0,b=this;this.debugEnabled=function(b){return A(b)?(a=b,this):a};this.$get=["$window",function(d){function c(a){a instanceof Error&&(a.stack?a=a.message&&-1===a.stack.indexOf(a.message)?
|
||||
"Error: "+a.message+"\n"+a.stack:a.stack:a.sourceURL&&(a=a.message+"\n"+a.sourceURL+":"+a.line));return a}function e(a){var b=d.console||{},e=b[a]||b.log||z;a=!1;try{a=!!e.apply}catch(k){}return a?function(){var a=[];p(arguments,function(b){a.push(c(b))});return e.apply(b,a)}:function(a,b){e(a,null==b?"":b)}}return{log:e("log"),info:e("info"),warn:e("warn"),error:e("error"),debug:function(){var c=e("debug");return function(){a&&c.apply(b,arguments)}}()}}]}function Va(a,b){if("__defineGetter__"===
|
||||
a||"__defineSetter__"===a||"__lookupGetter__"===a||"__lookupSetter__"===a||"__proto__"===a)throw U("isecfld",b);return a}function eg(a){return a+""}function xa(a,b){if(a){if(a.constructor===a)throw U("isecfn",b);if(a.window===a)throw U("isecwindow",b);if(a.children&&(a.nodeName||a.prop&&a.attr&&a.find))throw U("isecdom",b);if(a===Object)throw U("isecobj",b);}return a}function jd(a,b){if(a){if(a.constructor===a)throw U("isecfn",b);if(a===fg||a===gg||a===hg)throw U("isecff",b);}}function Gb(a,b){if(a&&
|
||||
(a===(0).constructor||a===(!1).constructor||a==="".constructor||a==={}.constructor||a===[].constructor||a===Function.constructor))throw U("isecaf",b);}function ig(a,b){return"undefined"!==typeof a?a:b}function kd(a,b){return"undefined"===typeof a?b:"undefined"===typeof b?a:a+b}function V(a,b){var d,c;switch(a.type){case r.Program:d=!0;p(a.body,function(a){V(a.expression,b);d=d&&a.expression.constant});a.constant=d;break;case r.Literal:a.constant=!0;a.toWatch=[];break;case r.UnaryExpression:V(a.argument,
|
||||
b);a.constant=a.argument.constant;a.toWatch=a.argument.toWatch;break;case r.BinaryExpression:V(a.left,b);V(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.left.toWatch.concat(a.right.toWatch);break;case r.LogicalExpression:V(a.left,b);V(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.constant?[]:[a];break;case r.ConditionalExpression:V(a.test,b);V(a.alternate,b);V(a.consequent,b);a.constant=a.test.constant&&a.alternate.constant&&a.consequent.constant;a.toWatch=
|
||||
a.constant?[]:[a];break;case r.Identifier:a.constant=!1;a.toWatch=[a];break;case r.MemberExpression:V(a.object,b);a.computed&&V(a.property,b);a.constant=a.object.constant&&(!a.computed||a.property.constant);a.toWatch=[a];break;case r.CallExpression:d=a.filter?!b(a.callee.name).$stateful:!1;c=[];p(a.arguments,function(a){V(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});a.constant=d;a.toWatch=a.filter&&!b(a.callee.name).$stateful?c:[a];break;case r.AssignmentExpression:V(a.left,b);V(a.right,
|
||||
b);a.constant=a.left.constant&&a.right.constant;a.toWatch=[a];break;case r.ArrayExpression:d=!0;c=[];p(a.elements,function(a){V(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});a.constant=d;a.toWatch=c;break;case r.ObjectExpression:d=!0;c=[];p(a.properties,function(a){V(a.value,b);d=d&&a.value.constant;a.value.constant||c.push.apply(c,a.value.toWatch)});a.constant=d;a.toWatch=c;break;case r.ThisExpression:a.constant=!1;a.toWatch=[];break;case r.LocalsExpression:a.constant=!1,a.toWatch=
|
||||
[]}}function ld(a){if(1==a.length){a=a[0].expression;var b=a.toWatch;return 1!==b.length?b:b[0]!==a?b:w}}function md(a){return a.type===r.Identifier||a.type===r.MemberExpression}function nd(a){if(1===a.body.length&&md(a.body[0].expression))return{type:r.AssignmentExpression,left:a.body[0].expression,right:{type:r.NGValueParameter},operator:"="}}function od(a){return 0===a.body.length||1===a.body.length&&(a.body[0].expression.type===r.Literal||a.body[0].expression.type===r.ArrayExpression||a.body[0].expression.type===
|
||||
r.ObjectExpression)}function pd(a,b){this.astBuilder=a;this.$filter=b}function qd(a,b){this.astBuilder=a;this.$filter=b}function Hb(a){return"constructor"==a}function ec(a){return H(a.valueOf)?a.valueOf():jg.call(a)}function pf(){var a=X(),b=X(),d={"true":!0,"false":!1,"null":null,undefined:w};this.addLiteral=function(a,b){d[a]=b};this.$get=["$filter",function(c){function e(d,e,g){var y,p,C;g=g||x;switch(typeof d){case "string":C=d=d.trim();var J=g?b:a;y=J[C];if(!y){":"===d.charAt(0)&&":"===d.charAt(1)&&
|
||||
(p=!0,d=d.substring(2));y=g?K:B;var T=new fc(y);y=(new gc(T,c,y)).parse(d);y.constant?y.$$watchDelegate=m:p?y.$$watchDelegate=y.literal?l:k:y.inputs&&(y.$$watchDelegate=h);g&&(y=f(y));J[C]=y}return n(y,e);case "function":return n(d,e);default:return n(z,e)}}function f(a){function b(c,d,e,f){var g=x;x=!0;try{return a(c,d,e,f)}finally{x=g}}if(!a)return a;b.$$watchDelegate=a.$$watchDelegate;b.assign=f(a.assign);b.constant=a.constant;b.literal=a.literal;for(var c=0;a.inputs&&c<a.inputs.length;++c)a.inputs[c]=
|
||||
f(a.inputs[c]);b.inputs=a.inputs;return b}function g(a,b){return null==a||null==b?a===b:"object"===typeof a&&(a=ec(a),"object"===typeof a)?!1:a===b||a!==a&&b!==b}function h(a,b,c,d,e){var f=d.inputs,h;if(1===f.length){var k=g,f=f[0];return a.$watch(function(a){var b=f(a);g(b,k)||(h=d(a,w,w,[b]),k=b&&ec(b));return h},b,c,e)}for(var l=[],m=[],n=0,y=f.length;n<y;n++)l[n]=g,m[n]=null;return a.$watch(function(a){for(var b=!1,c=0,e=f.length;c<e;c++){var k=f[c](a);if(b||(b=!g(k,l[c])))m[c]=k,l[c]=k&&ec(k)}b&&
|
||||
(h=d(a,w,w,m));return h},b,c,e)}function k(a,b,c,d){var e,f;return e=a.$watch(function(a){return d(a)},function(a,c,d){f=a;H(b)&&b.apply(this,arguments);A(a)&&d.$$postDigest(function(){A(f)&&e()})},c)}function l(a,b,c,d){function e(a){var b=!0;p(a,function(a){A(a)||(b=!1)});return b}var f,g;return f=a.$watch(function(a){return d(a)},function(a,c,d){g=a;H(b)&&b.call(this,a,c,d);e(a)&&d.$$postDigest(function(){e(g)&&f()})},c)}function m(a,b,c,d){var e;return e=a.$watch(function(a){e();return d(a)},
|
||||
b,c)}function n(a,b){if(!b)return a;var c=a.$$watchDelegate,d=!1,c=c!==l&&c!==k?function(c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}:function(c,d,e,f){e=a(c,d,e,f);c=b(e,c,d);return A(e)?c:e};a.$$watchDelegate&&a.$$watchDelegate!==h?c.$$watchDelegate=a.$$watchDelegate:b.$stateful||(c.$$watchDelegate=h,d=!a.inputs,c.inputs=a.inputs?a.inputs:[a]);return c}var y=Ea().noUnsafeEval,B={csp:y,expensiveChecks:!1,literals:qa(d)},K={csp:y,expensiveChecks:!0,literals:qa(d)},x=!1;e.$$runningExpensiveChecks=
|
||||
function(){return x};return e}]}function rf(){this.$get=["$rootScope","$exceptionHandler",function(a,b){return rd(function(b){a.$evalAsync(b)},b)}]}function sf(){this.$get=["$browser","$exceptionHandler",function(a,b){return rd(function(b){a.defer(b)},b)}]}function rd(a,b){function d(){this.$$state={status:0}}function c(a,b){return function(c){b.call(a,c)}}function e(c){!c.processScheduled&&c.pending&&(c.processScheduled=!0,a(function(){var a,d,e;e=c.pending;c.processScheduled=!1;c.pending=w;for(var f=
|
||||
0,g=e.length;f<g;++f){d=e[f][0];a=e[f][c.status];try{H(a)?d.resolve(a(c.value)):1===c.status?d.resolve(c.value):d.reject(c.value)}catch(h){d.reject(h),b(h)}}}))}function f(){this.promise=new d}var g=O("$q",TypeError);S(d.prototype,{then:function(a,b,c){if(v(a)&&v(b)&&v(c))return this;var d=new f;this.$$state.pending=this.$$state.pending||[];this.$$state.pending.push([d,a,b,c]);0<this.$$state.status&&e(this.$$state);return d.promise},"catch":function(a){return this.then(null,a)},"finally":function(a,
|
||||
b){return this.then(function(b){return k(b,!0,a)},function(b){return k(b,!1,a)},b)}});S(f.prototype,{resolve:function(a){this.promise.$$state.status||(a===this.promise?this.$$reject(g("qcycle",a)):this.$$resolve(a))},$$resolve:function(a){function d(a){k||(k=!0,h.$$resolve(a))}function f(a){k||(k=!0,h.$$reject(a))}var g,h=this,k=!1;try{if(I(a)||H(a))g=a&&a.then;H(g)?(this.promise.$$state.status=-1,g.call(a,d,f,c(this,this.notify))):(this.promise.$$state.value=a,this.promise.$$state.status=1,e(this.promise.$$state))}catch(l){f(l),
|
||||
b(l)}},reject:function(a){this.promise.$$state.status||this.$$reject(a)},$$reject:function(a){this.promise.$$state.value=a;this.promise.$$state.status=2;e(this.promise.$$state)},notify:function(c){var d=this.promise.$$state.pending;0>=this.promise.$$state.status&&d&&d.length&&a(function(){for(var a,e,f=0,g=d.length;f<g;f++){e=d[f][0];a=d[f][3];try{e.notify(H(a)?a(c):c)}catch(h){b(h)}}})}});var h=function(a,b){var c=new f;b?c.resolve(a):c.reject(a);return c.promise},k=function(a,b,c){var d=null;try{H(c)&&
|
||||
(d=c())}catch(e){return h(e,!1)}return d&&H(d.then)?d.then(function(){return h(a,b)},function(a){return h(a,!1)}):h(a,b)},l=function(a,b,c,d){var e=new f;e.resolve(a);return e.promise.then(b,c,d)},m=function(a){if(!H(a))throw g("norslvr",a);var b=new f;a(function(a){b.resolve(a)},function(a){b.reject(a)});return b.promise};m.prototype=d.prototype;m.defer=function(){var a=new f;a.resolve=c(a,a.resolve);a.reject=c(a,a.reject);a.notify=c(a,a.notify);return a};m.reject=function(a){var b=new f;b.reject(a);
|
||||
return b.promise};m.when=l;m.resolve=l;m.all=function(a){var b=new f,c=0,d=L(a)?[]:{};p(a,function(a,e){c++;l(a).then(function(a){d.hasOwnProperty(e)||(d[e]=a,--c||b.resolve(d))},function(a){d.hasOwnProperty(e)||b.reject(a)})});0===c&&b.resolve(d);return b.promise};return m}function Bf(){this.$get=["$window","$timeout",function(a,b){var d=a.requestAnimationFrame||a.webkitRequestAnimationFrame,c=a.cancelAnimationFrame||a.webkitCancelAnimationFrame||a.webkitCancelRequestAnimationFrame,e=!!d,f=e?function(a){var b=
|
||||
d(a);return function(){c(b)}}:function(a){var c=b(a,16.66,!1);return function(){b.cancel(c)}};f.supported=e;return f}]}function qf(){function a(a){function b(){this.$$watchers=this.$$nextSibling=this.$$childHead=this.$$childTail=null;this.$$listeners={};this.$$listenerCount={};this.$$watchersCount=0;this.$id=++pb;this.$$ChildScope=null}b.prototype=a;return b}var b=10,d=O("$rootScope"),c=null,e=null;this.digestTtl=function(a){arguments.length&&(b=a);return b};this.$get=["$exceptionHandler","$parse",
|
||||
"$browser",function(f,g,h){function k(a){a.currentScope.$$destroyed=!0}function l(a){9===za&&(a.$$childHead&&l(a.$$childHead),a.$$nextSibling&&l(a.$$nextSibling));a.$parent=a.$$nextSibling=a.$$prevSibling=a.$$childHead=a.$$childTail=a.$root=a.$$watchers=null}function m(){this.$id=++pb;this.$$phase=this.$parent=this.$$watchers=this.$$nextSibling=this.$$prevSibling=this.$$childHead=this.$$childTail=null;this.$root=this;this.$$destroyed=!1;this.$$listeners={};this.$$listenerCount={};this.$$watchersCount=
|
||||
0;this.$$isolateBindings=null}function n(a){if(t.$$phase)throw d("inprog",t.$$phase);t.$$phase=a}function y(a,b){do a.$$watchersCount+=b;while(a=a.$parent)}function B(a,b,c){do a.$$listenerCount[c]-=b,0===a.$$listenerCount[c]&&delete a.$$listenerCount[c];while(a=a.$parent)}function r(){}function x(){for(;M.length;)try{M.shift()()}catch(a){f(a)}e=null}function q(){null===e&&(e=h.defer(function(){t.$apply(x)}))}m.prototype={constructor:m,$new:function(b,c){var d;c=c||this;b?(d=new m,d.$root=this.$root):
|
||||
(this.$$ChildScope||(this.$$ChildScope=a(this)),d=new this.$$ChildScope);d.$parent=c;d.$$prevSibling=c.$$childTail;c.$$childHead?(c.$$childTail.$$nextSibling=d,c.$$childTail=d):c.$$childHead=c.$$childTail=d;(b||c!=this)&&d.$on("$destroy",k);return d},$watch:function(a,b,d,e){var f=g(a);if(f.$$watchDelegate)return f.$$watchDelegate(this,b,d,f,a);var h=this,k=h.$$watchers,l={fn:b,last:r,get:f,exp:e||a,eq:!!d};c=null;H(b)||(l.fn=z);k||(k=h.$$watchers=[]);k.unshift(l);y(this,1);return function(){0<=ab(k,
|
||||
l)&&y(h,-1);c=null}},$watchGroup:function(a,b){function c(){h=!1;k?(k=!1,b(e,e,g)):b(e,d,g)}var d=Array(a.length),e=Array(a.length),f=[],g=this,h=!1,k=!0;if(!a.length){var l=!0;g.$evalAsync(function(){l&&b(e,e,g)});return function(){l=!1}}if(1===a.length)return this.$watch(a[0],function(a,c,f){e[0]=a;d[0]=c;b(e,a===c?e:d,f)});p(a,function(a,b){var k=g.$watch(a,function(a,f){e[b]=a;d[b]=f;h||(h=!0,g.$evalAsync(c))});f.push(k)});return function(){for(;f.length;)f.shift()()}},$watchCollection:function(a,
|
||||
b){function c(a){e=a;var b,d,g,h;if(!v(e)){if(I(e))if(Ca(e))for(f!==n&&(f=n,u=f.length=0,l++),a=e.length,u!==a&&(l++,f.length=u=a),b=0;b<a;b++)h=f[b],g=e[b],d=h!==h&&g!==g,d||h===g||(l++,f[b]=g);else{f!==y&&(f=y={},u=0,l++);a=0;for(b in e)sa.call(e,b)&&(a++,g=e[b],h=f[b],b in f?(d=h!==h&&g!==g,d||h===g||(l++,f[b]=g)):(u++,f[b]=g,l++));if(u>a)for(b in l++,f)sa.call(e,b)||(u--,delete f[b])}else f!==e&&(f=e,l++);return l}}c.$stateful=!0;var d=this,e,f,h,k=1<b.length,l=0,m=g(a,c),n=[],y={},q=!0,u=0;return this.$watch(m,
|
||||
function(){q?(q=!1,b(e,e,d)):b(e,h,d);if(k)if(I(e))if(Ca(e)){h=Array(e.length);for(var a=0;a<e.length;a++)h[a]=e[a]}else for(a in h={},e)sa.call(e,a)&&(h[a]=e[a]);else h=e})},$digest:function(){var a,g,k,l,m,y,q,B,p=b,M,w=[],A,v;n("$digest");h.$$checkUrlChange();this===t&&null!==e&&(h.defer.cancel(e),x());c=null;do{B=!1;for(M=this;u.length;){try{v=u.shift(),v.scope.$eval(v.expression,v.locals)}catch(z){f(z)}c=null}a:do{if(y=M.$$watchers)for(q=y.length;q--;)try{if(a=y[q])if(m=a.get,(g=m(M))!==(k=a.last)&&
|
||||
!(a.eq?oa(g,k):"number"===typeof g&&"number"===typeof k&&isNaN(g)&&isNaN(k)))B=!0,c=a,a.last=a.eq?qa(g,null):g,l=a.fn,l(g,k===r?g:k,M),5>p&&(A=4-p,w[A]||(w[A]=[]),w[A].push({msg:H(a.exp)?"fn: "+(a.exp.name||a.exp.toString()):a.exp,newVal:g,oldVal:k}));else if(a===c){B=!1;break a}}catch(G){f(G)}if(!(y=M.$$watchersCount&&M.$$childHead||M!==this&&M.$$nextSibling))for(;M!==this&&!(y=M.$$nextSibling);)M=M.$parent}while(M=y);if((B||u.length)&&!p--)throw t.$$phase=null,d("infdig",b,w);}while(B||u.length);
|
||||
for(t.$$phase=null;s.length;)try{s.shift()()}catch(D){f(D)}},$destroy:function(){if(!this.$$destroyed){var a=this.$parent;this.$broadcast("$destroy");this.$$destroyed=!0;this===t&&h.$$applicationDestroyed();y(this,-this.$$watchersCount);for(var b in this.$$listenerCount)B(this,this.$$listenerCount[b],b);a&&a.$$childHead==this&&(a.$$childHead=this.$$nextSibling);a&&a.$$childTail==this&&(a.$$childTail=this.$$prevSibling);this.$$prevSibling&&(this.$$prevSibling.$$nextSibling=this.$$nextSibling);this.$$nextSibling&&
|
||||
(this.$$nextSibling.$$prevSibling=this.$$prevSibling);this.$destroy=this.$digest=this.$apply=this.$evalAsync=this.$applyAsync=z;this.$on=this.$watch=this.$watchGroup=function(){return z};this.$$listeners={};this.$$nextSibling=null;l(this)}},$eval:function(a,b){return g(a)(this,b)},$evalAsync:function(a,b){t.$$phase||u.length||h.defer(function(){u.length&&t.$digest()});u.push({scope:this,expression:g(a),locals:b})},$$postDigest:function(a){s.push(a)},$apply:function(a){try{n("$apply");try{return this.$eval(a)}finally{t.$$phase=
|
||||
null}}catch(b){f(b)}finally{try{t.$digest()}catch(c){throw f(c),c;}}},$applyAsync:function(a){function b(){c.$eval(a)}var c=this;a&&M.push(b);a=g(a);q()},$on:function(a,b){var c=this.$$listeners[a];c||(this.$$listeners[a]=c=[]);c.push(b);var d=this;do d.$$listenerCount[a]||(d.$$listenerCount[a]=0),d.$$listenerCount[a]++;while(d=d.$parent);var e=this;return function(){var d=c.indexOf(b);-1!==d&&(c[d]=null,B(e,1,a))}},$emit:function(a,b){var c=[],d,e=this,g=!1,h={name:a,targetScope:e,stopPropagation:function(){g=
|
||||
!0},preventDefault:function(){h.defaultPrevented=!0},defaultPrevented:!1},k=bb([h],arguments,1),l,m;do{d=e.$$listeners[a]||c;h.currentScope=e;l=0;for(m=d.length;l<m;l++)if(d[l])try{d[l].apply(null,k)}catch(n){f(n)}else d.splice(l,1),l--,m--;if(g)return h.currentScope=null,h;e=e.$parent}while(e);h.currentScope=null;return h},$broadcast:function(a,b){var c=this,d=this,e={name:a,targetScope:this,preventDefault:function(){e.defaultPrevented=!0},defaultPrevented:!1};if(!this.$$listenerCount[a])return e;
|
||||
for(var g=bb([e],arguments,1),h,k;c=d;){e.currentScope=c;d=c.$$listeners[a]||[];h=0;for(k=d.length;h<k;h++)if(d[h])try{d[h].apply(null,g)}catch(l){f(l)}else d.splice(h,1),h--,k--;if(!(d=c.$$listenerCount[a]&&c.$$childHead||c!==this&&c.$$nextSibling))for(;c!==this&&!(d=c.$$nextSibling);)c=c.$parent}e.currentScope=null;return e}};var t=new m,u=t.$$asyncQueue=[],s=t.$$postDigestQueue=[],M=t.$$applyAsyncQueue=[];return t}]}function je(){var a=/^\s*(https?|ftp|mailto|tel|file):/,b=/^\s*((https?|ftp|file|blob):|data:image\/)/;
|
||||
this.aHrefSanitizationWhitelist=function(b){return A(b)?(a=b,this):a};this.imgSrcSanitizationWhitelist=function(a){return A(a)?(b=a,this):b};this.$get=function(){return function(d,c){var e=c?b:a,f;f=wa(d).href;return""===f||f.match(e)?d:"unsafe:"+f}}}function kg(a){if("self"===a)return a;if(D(a)){if(-1<a.indexOf("***"))throw Ba("iwcard",a);a=sd(a).replace("\\*\\*",".*").replace("\\*","[^:/.?&;]*");return new RegExp("^"+a+"$")}if(Ya(a))return new RegExp("^"+a.source+"$");throw Ba("imatcher");}function td(a){var b=
|
||||
[];A(a)&&p(a,function(a){b.push(kg(a))});return b}function uf(){this.SCE_CONTEXTS=fa;var a=["self"],b=[];this.resourceUrlWhitelist=function(b){arguments.length&&(a=td(b));return a};this.resourceUrlBlacklist=function(a){arguments.length&&(b=td(a));return b};this.$get=["$injector",function(d){function c(a,b){return"self"===a?ed(b):!!a.exec(b.href)}function e(a){var b=function(a){this.$$unwrapTrustedValue=function(){return a}};a&&(b.prototype=new a);b.prototype.valueOf=function(){return this.$$unwrapTrustedValue()};
|
||||
b.prototype.toString=function(){return this.$$unwrapTrustedValue().toString()};return b}var f=function(a){throw Ba("unsafe");};d.has("$sanitize")&&(f=d.get("$sanitize"));var g=e(),h={};h[fa.HTML]=e(g);h[fa.CSS]=e(g);h[fa.URL]=e(g);h[fa.JS]=e(g);h[fa.RESOURCE_URL]=e(h[fa.URL]);return{trustAs:function(a,b){var c=h.hasOwnProperty(a)?h[a]:null;if(!c)throw Ba("icontext",a,b);if(null===b||v(b)||""===b)return b;if("string"!==typeof b)throw Ba("itype",a);return new c(b)},getTrusted:function(d,e){if(null===
|
||||
e||v(e)||""===e)return e;var g=h.hasOwnProperty(d)?h[d]:null;if(g&&e instanceof g)return e.$$unwrapTrustedValue();if(d===fa.RESOURCE_URL){var g=wa(e.toString()),n,y,B=!1;n=0;for(y=a.length;n<y;n++)if(c(a[n],g)){B=!0;break}if(B)for(n=0,y=b.length;n<y;n++)if(c(b[n],g)){B=!1;break}if(B)return e;throw Ba("insecurl",e.toString());}if(d===fa.HTML)return f(e);throw Ba("unsafe");},valueOf:function(a){return a instanceof g?a.$$unwrapTrustedValue():a}}}]}function tf(){var a=!0;this.enabled=function(b){arguments.length&&
|
||||
(a=!!b);return a};this.$get=["$parse","$sceDelegate",function(b,d){if(a&&8>za)throw Ba("iequirks");var c=ma(fa);c.isEnabled=function(){return a};c.trustAs=d.trustAs;c.getTrusted=d.getTrusted;c.valueOf=d.valueOf;a||(c.trustAs=c.getTrusted=function(a,b){return b},c.valueOf=Za);c.parseAs=function(a,d){var e=b(d);return e.literal&&e.constant?e:b(d,function(b){return c.getTrusted(a,b)})};var e=c.parseAs,f=c.getTrusted,g=c.trustAs;p(fa,function(a,b){var d=E(b);c[eb("parse_as_"+d)]=function(b){return e(a,
|
||||
b)};c[eb("get_trusted_"+d)]=function(b){return f(a,b)};c[eb("trust_as_"+d)]=function(b){return g(a,b)}});return c}]}function vf(){this.$get=["$window","$document",function(a,b){var d={},c=da((/android (\d+)/.exec(E((a.navigator||{}).userAgent))||[])[1]),e=/Boxee/i.test((a.navigator||{}).userAgent),f=b[0]||{},g,h=/^(Moz|webkit|ms)(?=[A-Z])/,k=f.body&&f.body.style,l=!1,m=!1;if(k){for(var n in k)if(l=h.exec(n)){g=l[0];g=g.substr(0,1).toUpperCase()+g.substr(1);break}g||(g="WebkitOpacity"in k&&"webkit");
|
||||
l=!!("transition"in k||g+"Transition"in k);m=!!("animation"in k||g+"Animation"in k);!c||l&&m||(l=D(k.webkitTransition),m=D(k.webkitAnimation))}return{history:!(!a.history||!a.history.pushState||4>c||e),hasEvent:function(a){if("input"===a&&11>=za)return!1;if(v(d[a])){var b=f.createElement("div");d[a]="on"+a in b}return d[a]},csp:Ea(),vendorPrefix:g,transitions:l,animations:m,android:c}}]}function xf(){var a;this.httpOptions=function(b){return b?(a=b,this):a};this.$get=["$templateCache","$http","$q",
|
||||
"$sce",function(b,d,c,e){function f(g,h){f.totalPendingRequests++;D(g)&&b.get(g)||(g=e.getTrustedResourceUrl(g));var k=d.defaults&&d.defaults.transformResponse;L(k)?k=k.filter(function(a){return a!==$b}):k===$b&&(k=null);return d.get(g,S({cache:b,transformResponse:k},a))["finally"](function(){f.totalPendingRequests--}).then(function(a){b.put(g,a.data);return a.data},function(a){if(!h)throw lg("tpload",g,a.status,a.statusText);return c.reject(a)})}f.totalPendingRequests=0;return f}]}function yf(){this.$get=
|
||||
["$rootScope","$browser","$location",function(a,b,d){return{findBindings:function(a,b,d){a=a.getElementsByClassName("ng-binding");var g=[];p(a,function(a){var c=ea.element(a).data("$binding");c&&p(c,function(c){d?(new RegExp("(^|\\s)"+sd(b)+"(\\s|\\||$)")).test(c)&&g.push(a):-1!=c.indexOf(b)&&g.push(a)})});return g},findModels:function(a,b,d){for(var g=["ng-","data-ng-","ng\\:"],h=0;h<g.length;++h){var k=a.querySelectorAll("["+g[h]+"model"+(d?"=":"*=")+'"'+b+'"]');if(k.length)return k}},getLocation:function(){return d.url()},
|
||||
setLocation:function(b){b!==d.url()&&(d.url(b),a.$digest())},whenStable:function(a){b.notifyWhenNoOutstandingRequests(a)}}}]}function zf(){this.$get=["$rootScope","$browser","$q","$$q","$exceptionHandler",function(a,b,d,c,e){function f(f,k,l){H(f)||(l=k,k=f,f=z);var m=ya.call(arguments,3),n=A(l)&&!l,y=(n?c:d).defer(),B=y.promise,p;p=b.defer(function(){try{y.resolve(f.apply(null,m))}catch(b){y.reject(b),e(b)}finally{delete g[B.$$timeoutId]}n||a.$apply()},k);B.$$timeoutId=p;g[p]=y;return B}var g={};
|
||||
f.cancel=function(a){return a&&a.$$timeoutId in g?(g[a.$$timeoutId].reject("canceled"),delete g[a.$$timeoutId],b.defer.cancel(a.$$timeoutId)):!1};return f}]}function wa(a){za&&(aa.setAttribute("href",a),a=aa.href);aa.setAttribute("href",a);return{href:aa.href,protocol:aa.protocol?aa.protocol.replace(/:$/,""):"",host:aa.host,search:aa.search?aa.search.replace(/^\?/,""):"",hash:aa.hash?aa.hash.replace(/^#/,""):"",hostname:aa.hostname,port:aa.port,pathname:"/"===aa.pathname.charAt(0)?aa.pathname:"/"+
|
||||
aa.pathname}}function ed(a){a=D(a)?wa(a):a;return a.protocol===ud.protocol&&a.host===ud.host}function Af(){this.$get=ia(N)}function vd(a){function b(a){try{return decodeURIComponent(a)}catch(b){return a}}var d=a[0]||{},c={},e="";return function(){var a,g,h,k,l;a=d.cookie||"";if(a!==e)for(e=a,a=e.split("; "),c={},h=0;h<a.length;h++)g=a[h],k=g.indexOf("="),0<k&&(l=b(g.substring(0,k)),v(c[l])&&(c[l]=b(g.substring(k+1))));return c}}function Ef(){this.$get=vd}function Ic(a){function b(d,c){if(I(d)){var e=
|
||||
{};p(d,function(a,c){e[c]=b(c,a)});return e}return a.factory(d+"Filter",c)}this.register=b;this.$get=["$injector",function(a){return function(b){return a.get(b+"Filter")}}];b("currency",wd);b("date",xd);b("filter",mg);b("json",ng);b("limitTo",og);b("lowercase",pg);b("number",yd);b("orderBy",zd);b("uppercase",qg)}function mg(){return function(a,b,d){if(!Ca(a)){if(null==a)return a;throw O("filter")("notarray",a);}var c;switch(hc(b)){case "function":break;case "boolean":case "null":case "number":case "string":c=
|
||||
!0;case "object":b=rg(b,d,c);break;default:return a}return Array.prototype.filter.call(a,b)}}function rg(a,b,d){var c=I(a)&&"$"in a;!0===b?b=oa:H(b)||(b=function(a,b){if(v(a))return!1;if(null===a||null===b)return a===b;if(I(b)||I(a)&&!qc(a))return!1;a=E(""+a);b=E(""+b);return-1!==a.indexOf(b)});return function(e){return c&&!I(e)?Ka(e,a.$,b,!1):Ka(e,a,b,d)}}function Ka(a,b,d,c,e){var f=hc(a),g=hc(b);if("string"===g&&"!"===b.charAt(0))return!Ka(a,b.substring(1),d,c);if(L(a))return a.some(function(a){return Ka(a,
|
||||
b,d,c)});switch(f){case "object":var h;if(c){for(h in a)if("$"!==h.charAt(0)&&Ka(a[h],b,d,!0))return!0;return e?!1:Ka(a,b,d,!1)}if("object"===g){for(h in b)if(e=b[h],!H(e)&&!v(e)&&(f="$"===h,!Ka(f?a:a[h],e,d,f,f)))return!1;return!0}return d(a,b);case "function":return!1;default:return d(a,b)}}function hc(a){return null===a?"null":typeof a}function wd(a){var b=a.NUMBER_FORMATS;return function(a,c,e){v(c)&&(c=b.CURRENCY_SYM);v(e)&&(e=b.PATTERNS[1].maxFrac);return null==a?a:Ad(a,b.PATTERNS[1],b.GROUP_SEP,
|
||||
b.DECIMAL_SEP,e).replace(/\u00A4/g,c)}}function yd(a){var b=a.NUMBER_FORMATS;return function(a,c){return null==a?a:Ad(a,b.PATTERNS[0],b.GROUP_SEP,b.DECIMAL_SEP,c)}}function sg(a){var b=0,d,c,e,f,g;-1<(c=a.indexOf(Bd))&&(a=a.replace(Bd,""));0<(e=a.search(/e/i))?(0>c&&(c=e),c+=+a.slice(e+1),a=a.substring(0,e)):0>c&&(c=a.length);for(e=0;a.charAt(e)==ic;e++);if(e==(g=a.length))d=[0],c=1;else{for(g--;a.charAt(g)==ic;)g--;c-=e;d=[];for(f=0;e<=g;e++,f++)d[f]=+a.charAt(e)}c>Cd&&(d=d.splice(0,Cd-1),b=c-1,
|
||||
c=1);return{d:d,e:b,i:c}}function tg(a,b,d,c){var e=a.d,f=e.length-a.i;b=v(b)?Math.min(Math.max(d,f),c):+b;d=b+a.i;c=e[d];if(0<d){e.splice(Math.max(a.i,d));for(var g=d;g<e.length;g++)e[g]=0}else for(f=Math.max(0,f),a.i=1,e.length=Math.max(1,d=b+1),e[0]=0,g=1;g<d;g++)e[g]=0;if(5<=c)if(0>d-1){for(c=0;c>d;c--)e.unshift(0),a.i++;e.unshift(1);a.i++}else e[d-1]++;for(;f<Math.max(0,b);f++)e.push(0);if(b=e.reduceRight(function(a,b,c,d){b+=a;d[c]=b%10;return Math.floor(b/10)},0))e.unshift(b),a.i++}function Ad(a,
|
||||
b,d,c,e){if(!D(a)&&!W(a)||isNaN(a))return"";var f=!isFinite(a),g=!1,h=Math.abs(a)+"",k="";if(f)k="\u221e";else{g=sg(h);tg(g,e,b.minFrac,b.maxFrac);k=g.d;h=g.i;e=g.e;f=[];for(g=k.reduce(function(a,b){return a&&!b},!0);0>h;)k.unshift(0),h++;0<h?f=k.splice(h):(f=k,k=[0]);h=[];for(k.length>b.lgSize&&h.unshift(k.splice(-b.lgSize).join(""));k.length>b.gSize;)h.unshift(k.splice(-b.gSize).join(""));k.length&&h.unshift(k.join(""));k=h.join(d);f.length&&(k+=c+f.join(""));e&&(k+="e+"+e)}return 0>a&&!g?b.negPre+
|
||||
k+b.negSuf:b.posPre+k+b.posSuf}function Ib(a,b,d,c){var e="";if(0>a||c&&0>=a)c?a=-a+1:(a=-a,e="-");for(a=""+a;a.length<b;)a=ic+a;d&&(a=a.substr(a.length-b));return e+a}function ba(a,b,d,c,e){d=d||0;return function(f){f=f["get"+a]();if(0<d||f>-d)f+=d;0===f&&-12==d&&(f=12);return Ib(f,b,c,e)}}function kb(a,b,d){return function(c,e){var f=c["get"+a](),g=ub((d?"STANDALONE":"")+(b?"SHORT":"")+a);return e[g][f]}}function Dd(a){var b=(new Date(a,0,1)).getDay();return new Date(a,0,(4>=b?5:12)-b)}function Ed(a){return function(b){var d=
|
||||
Dd(b.getFullYear());b=+new Date(b.getFullYear(),b.getMonth(),b.getDate()+(4-b.getDay()))-+d;b=1+Math.round(b/6048E5);return Ib(b,a)}}function jc(a,b){return 0>=a.getFullYear()?b.ERAS[0]:b.ERAS[1]}function xd(a){function b(a){var b;if(b=a.match(d)){a=new Date(0);var f=0,g=0,h=b[8]?a.setUTCFullYear:a.setFullYear,k=b[8]?a.setUTCHours:a.setHours;b[9]&&(f=da(b[9]+b[10]),g=da(b[9]+b[11]));h.call(a,da(b[1]),da(b[2])-1,da(b[3]));f=da(b[4]||0)-f;g=da(b[5]||0)-g;h=da(b[6]||0);b=Math.round(1E3*parseFloat("0."+
|
||||
(b[7]||0)));k.call(a,f,g,h,b)}return a}var d=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;return function(c,d,f){var g="",h=[],k,l;d=d||"mediumDate";d=a.DATETIME_FORMATS[d]||d;D(c)&&(c=ug.test(c)?da(c):b(c));W(c)&&(c=new Date(c));if(!ga(c)||!isFinite(c.getTime()))return c;for(;d;)(l=vg.exec(d))?(h=bb(h,l,1),d=h.pop()):(h.push(d),d=null);var m=c.getTimezoneOffset();f&&(m=uc(f,m),c=Qb(c,f,!0));p(h,function(b){k=wg[b];g+=k?k(c,a.DATETIME_FORMATS,
|
||||
m):"''"===b?"'":b.replace(/(^'|'$)/g,"").replace(/''/g,"'")});return g}}function ng(){return function(a,b){v(b)&&(b=2);return cb(a,b)}}function og(){return function(a,b,d){b=Infinity===Math.abs(Number(b))?Number(b):da(b);if(isNaN(b))return a;W(a)&&(a=a.toString());if(!L(a)&&!D(a))return a;d=!d||isNaN(d)?0:da(d);d=0>d?Math.max(0,a.length+d):d;return 0<=b?a.slice(d,d+b):0===d?a.slice(b,a.length):a.slice(Math.max(0,d+b),d)}}function zd(a){function b(b,d){d=d?-1:1;return b.map(function(b){var c=1,h=Za;
|
||||
if(H(b))h=b;else if(D(b)){if("+"==b.charAt(0)||"-"==b.charAt(0))c="-"==b.charAt(0)?-1:1,b=b.substring(1);if(""!==b&&(h=a(b),h.constant))var k=h(),h=function(a){return a[k]}}return{get:h,descending:c*d}})}function d(a){switch(typeof a){case "number":case "boolean":case "string":return!0;default:return!1}}return function(a,e,f){if(null==a)return a;if(!Ca(a))throw O("orderBy")("notarray",a);L(e)||(e=[e]);0===e.length&&(e=["+"]);var g=b(e,f);g.push({get:function(){return{}},descending:f?-1:1});a=Array.prototype.map.call(a,
|
||||
function(a,b){return{value:a,predicateValues:g.map(function(c){var e=c.get(a);c=typeof e;if(null===e)c="string",e="null";else if("string"===c)e=e.toLowerCase();else if("object"===c)a:{if("function"===typeof e.valueOf&&(e=e.valueOf(),d(e)))break a;if(qc(e)&&(e=e.toString(),d(e)))break a;e=b}return{value:e,type:c}})}});a.sort(function(a,b){for(var c=0,d=0,e=g.length;d<e;++d){var c=a.predicateValues[d],f=b.predicateValues[d],p=0;c.type===f.type?c.value!==f.value&&(p=c.value<f.value?-1:1):p=c.type<f.type?
|
||||
-1:1;if(c=p*g[d].descending)break}return c});return a=a.map(function(a){return a.value})}}function La(a){H(a)&&(a={link:a});a.restrict=a.restrict||"AC";return ia(a)}function Fd(a,b,d,c,e){var f=this,g=[];f.$error={};f.$$success={};f.$pending=w;f.$name=e(b.name||b.ngForm||"")(d);f.$dirty=!1;f.$pristine=!0;f.$valid=!0;f.$invalid=!1;f.$submitted=!1;f.$$parentForm=Jb;f.$rollbackViewValue=function(){p(g,function(a){a.$rollbackViewValue()})};f.$commitViewValue=function(){p(g,function(a){a.$commitViewValue()})};
|
||||
f.$addControl=function(a){Ra(a.$name,"input");g.push(a);a.$name&&(f[a.$name]=a);a.$$parentForm=f};f.$$renameControl=function(a,b){var c=a.$name;f[c]===a&&delete f[c];f[b]=a;a.$name=b};f.$removeControl=function(a){a.$name&&f[a.$name]===a&&delete f[a.$name];p(f.$pending,function(b,c){f.$setValidity(c,null,a)});p(f.$error,function(b,c){f.$setValidity(c,null,a)});p(f.$$success,function(b,c){f.$setValidity(c,null,a)});ab(g,a);a.$$parentForm=Jb};Gd({ctrl:this,$element:a,set:function(a,b,c){var d=a[b];d?
|
||||
-1===d.indexOf(c)&&d.push(c):a[b]=[c]},unset:function(a,b,c){var d=a[b];d&&(ab(d,c),0===d.length&&delete a[b])},$animate:c});f.$setDirty=function(){c.removeClass(a,Wa);c.addClass(a,Kb);f.$dirty=!0;f.$pristine=!1;f.$$parentForm.$setDirty()};f.$setPristine=function(){c.setClass(a,Wa,Kb+" ng-submitted");f.$dirty=!1;f.$pristine=!0;f.$submitted=!1;p(g,function(a){a.$setPristine()})};f.$setUntouched=function(){p(g,function(a){a.$setUntouched()})};f.$setSubmitted=function(){c.addClass(a,"ng-submitted");
|
||||
f.$submitted=!0;f.$$parentForm.$setSubmitted()}}function kc(a){a.$formatters.push(function(b){return a.$isEmpty(b)?b:b.toString()})}function lb(a,b,d,c,e,f){var g=E(b[0].type);if(!e.android){var h=!1;b.on("compositionstart",function(){h=!0});b.on("compositionend",function(){h=!1;l()})}var k,l=function(a){k&&(f.defer.cancel(k),k=null);if(!h){var e=b.val();a=a&&a.type;"password"===g||d.ngTrim&&"false"===d.ngTrim||(e=Z(e));(c.$viewValue!==e||""===e&&c.$$hasNativeValidators)&&c.$setViewValue(e,a)}};if(e.hasEvent("input"))b.on("input",
|
||||
l);else{var m=function(a,b,c){k||(k=f.defer(function(){k=null;b&&b.value===c||l(a)}))};b.on("keydown",function(a){var b=a.keyCode;91===b||15<b&&19>b||37<=b&&40>=b||m(a,this,this.value)});if(e.hasEvent("paste"))b.on("paste cut",m)}b.on("change",l);if(Hd[g]&&c.$$hasNativeValidators&&g===d.type)b.on("keydown wheel mousedown",function(a){if(!k){var b=this.validity,c=b.badInput,d=b.typeMismatch;k=f.defer(function(){k=null;b.badInput===c&&b.typeMismatch===d||l(a)})}});c.$render=function(){var a=c.$isEmpty(c.$viewValue)?
|
||||
"":c.$viewValue;b.val()!==a&&b.val(a)}}function Lb(a,b){return function(d,c){var e,f;if(ga(d))return d;if(D(d)){'"'==d.charAt(0)&&'"'==d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));if(xg.test(d))return new Date(d);a.lastIndex=0;if(e=a.exec(d))return e.shift(),f=c?{yyyy:c.getFullYear(),MM:c.getMonth()+1,dd:c.getDate(),HH:c.getHours(),mm:c.getMinutes(),ss:c.getSeconds(),sss:c.getMilliseconds()/1E3}:{yyyy:1970,MM:1,dd:1,HH:0,mm:0,ss:0,sss:0},p(e,function(a,c){c<b.length&&(f[b[c]]=+a)}),new Date(f.yyyy,
|
||||
f.MM-1,f.dd,f.HH,f.mm,f.ss||0,1E3*f.sss||0)}return NaN}}function mb(a,b,d,c){return function(e,f,g,h,k,l,m){function n(a){return a&&!(a.getTime&&a.getTime()!==a.getTime())}function y(a){return A(a)&&!ga(a)?d(a)||w:a}Id(e,f,g,h);lb(e,f,g,h,k,l);var p=h&&h.$options&&h.$options.timezone,r;h.$$parserName=a;h.$parsers.push(function(a){return h.$isEmpty(a)?null:b.test(a)?(a=d(a,r),p&&(a=Qb(a,p)),a):w});h.$formatters.push(function(a){if(a&&!ga(a))throw nb("datefmt",a);if(n(a))return(r=a)&&p&&(r=Qb(r,p,!0)),
|
||||
m("date")(a,c,p);r=null;return""});if(A(g.min)||g.ngMin){var x;h.$validators.min=function(a){return!n(a)||v(x)||d(a)>=x};g.$observe("min",function(a){x=y(a);h.$validate()})}if(A(g.max)||g.ngMax){var q;h.$validators.max=function(a){return!n(a)||v(q)||d(a)<=q};g.$observe("max",function(a){q=y(a);h.$validate()})}}}function Id(a,b,d,c){(c.$$hasNativeValidators=I(b[0].validity))&&c.$parsers.push(function(a){var c=b.prop("validity")||{};return c.badInput||c.typeMismatch?w:a})}function Jd(a,b,d,c,e){if(A(c)){a=
|
||||
a(c);if(!a.constant)throw nb("constexpr",d,c);return a(b)}return e}function lc(a,b){a="ngClass"+a;return["$animate",function(d){function c(a,b){var c=[],d=0;a:for(;d<a.length;d++){for(var e=a[d],m=0;m<b.length;m++)if(e==b[m])continue a;c.push(e)}return c}function e(a){var b=[];return L(a)?(p(a,function(a){b=b.concat(e(a))}),b):D(a)?a.split(" "):I(a)?(p(a,function(a,c){a&&(b=b.concat(c.split(" ")))}),b):a}return{restrict:"AC",link:function(f,g,h){function k(a,b){var c=g.data("$classCounts")||X(),d=
|
||||
[];p(a,function(a){if(0<b||c[a])c[a]=(c[a]||0)+b,c[a]===+(0<b)&&d.push(a)});g.data("$classCounts",c);return d.join(" ")}function l(a){if(!0===b||f.$index%2===b){var l=e(a||[]);if(!m){var p=k(l,1);h.$addClass(p)}else if(!oa(a,m)){var r=e(m),p=c(l,r),l=c(r,l),p=k(p,1),l=k(l,-1);p&&p.length&&d.addClass(g,p);l&&l.length&&d.removeClass(g,l)}}m=ma(a)}var m;f.$watch(h[a],l,!0);h.$observe("class",function(b){l(f.$eval(h[a]))});"ngClass"!==a&&f.$watch("$index",function(c,d){var g=c&1;if(g!==(d&1)){var l=e(f.$eval(h[a]));
|
||||
g===b?(g=k(l,1),h.$addClass(g)):(g=k(l,-1),h.$removeClass(g))}})}}}]}function Gd(a){function b(a,b){b&&!f[a]?(k.addClass(e,a),f[a]=!0):!b&&f[a]&&(k.removeClass(e,a),f[a]=!1)}function d(a,c){a=a?"-"+yc(a,"-"):"";b(ob+a,!0===c);b(Kd+a,!1===c)}var c=a.ctrl,e=a.$element,f={},g=a.set,h=a.unset,k=a.$animate;f[Kd]=!(f[ob]=e.hasClass(ob));c.$setValidity=function(a,e,f){v(e)?(c.$pending||(c.$pending={}),g(c.$pending,a,f)):(c.$pending&&h(c.$pending,a,f),Ld(c.$pending)&&(c.$pending=w));Ma(e)?e?(h(c.$error,a,
|
||||
f),g(c.$$success,a,f)):(g(c.$error,a,f),h(c.$$success,a,f)):(h(c.$error,a,f),h(c.$$success,a,f));c.$pending?(b(Md,!0),c.$valid=c.$invalid=w,d("",null)):(b(Md,!1),c.$valid=Ld(c.$error),c.$invalid=!c.$valid,d("",c.$valid));e=c.$pending&&c.$pending[a]?w:c.$error[a]?!1:c.$$success[a]?!0:null;d(a,e);c.$$parentForm.$setValidity(a,e,c)}}function Ld(a){if(a)for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}var yg=/^\/(.+)\/([a-z]*)$/,sa=Object.prototype.hasOwnProperty,E=function(a){return D(a)?a.toLowerCase():
|
||||
a},ub=function(a){return D(a)?a.toUpperCase():a},za,G,ra,ya=[].slice,Yf=[].splice,zg=[].push,ha=Object.prototype.toString,rc=Object.getPrototypeOf,Da=O("ng"),ea=N.angular||(N.angular={}),Sb,pb=0;za=Q.documentMode;z.$inject=[];Za.$inject=[];var L=Array.isArray,Xd=/^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/,Z=function(a){return D(a)?a.trim():a},sd=function(a){return a.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")},Ea=function(){if(!A(Ea.rules)){var a=
|
||||
Q.querySelector("[ng-csp]")||Q.querySelector("[data-ng-csp]");if(a){var b=a.getAttribute("ng-csp")||a.getAttribute("data-ng-csp");Ea.rules={noUnsafeEval:!b||-1!==b.indexOf("no-unsafe-eval"),noInlineStyle:!b||-1!==b.indexOf("no-inline-style")}}else{a=Ea;try{new Function(""),b=!1}catch(d){b=!0}a.rules={noUnsafeEval:b,noInlineStyle:!1}}}return Ea.rules},rb=function(){if(A(rb.name_))return rb.name_;var a,b,d=Oa.length,c,e;for(b=0;b<d;++b)if(c=Oa[b],a=Q.querySelector("["+c.replace(":","\\:")+"jq]")){e=
|
||||
a.getAttribute(c+"jq");break}return rb.name_=e},$d=/:/g,Oa=["ng-","data-ng-","ng:","x-ng-"],ee=/[A-Z]/g,zc=!1,Na=3,ie={full:"1.5.2",major:1,minor:5,dot:2,codeName:"differential-recovery"};Y.expando="ng339";var gb=Y.cache={},Kf=1;Y._data=function(a){return this.cache[a[this.expando]]||{}};var Ff=/([\:\-\_]+(.))/g,Gf=/^moz([A-Z])/,yb={mouseleave:"mouseout",mouseenter:"mouseover"},Ub=O("jqLite"),Jf=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,Tb=/<|&#?\w+;/,Hf=/<([\w:-]+)/,If=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
|
||||
ka={option:[1,'<select multiple="multiple">',"</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ka.optgroup=ka.option;ka.tbody=ka.tfoot=ka.colgroup=ka.caption=ka.thead;ka.th=ka.td;var Pf=Node.prototype.contains||function(a){return!!(this.compareDocumentPosition(a)&16)},Pa=Y.prototype={ready:function(a){function b(){d||(d=!0,a())}var d=!1;"complete"===
|
||||
Q.readyState?setTimeout(b):(this.on("DOMContentLoaded",b),Y(N).on("load",b))},toString:function(){var a=[];p(this,function(b){a.push(""+b)});return"["+a.join(", ")+"]"},eq:function(a){return 0<=a?G(this[a]):G(this[this.length+a])},length:0,push:zg,sort:[].sort,splice:[].splice},Db={};p("multiple selected checked disabled readOnly required open".split(" "),function(a){Db[E(a)]=a});var Rc={};p("input select option textarea button form details".split(" "),function(a){Rc[a]=!0});var Yc={ngMinlength:"minlength",
|
||||
ngMaxlength:"maxlength",ngMin:"min",ngMax:"max",ngPattern:"pattern"};p({data:Wb,removeData:fb,hasData:function(a){for(var b in gb[a.ng339])return!0;return!1},cleanData:function(a){for(var b=0,d=a.length;b<d;b++)fb(a[b])}},function(a,b){Y[b]=a});p({data:Wb,inheritedData:Cb,scope:function(a){return G.data(a,"$scope")||Cb(a.parentNode||a,["$isolateScope","$scope"])},isolateScope:function(a){return G.data(a,"$isolateScope")||G.data(a,"$isolateScopeNoTemplate")},controller:Oc,injector:function(a){return Cb(a,
|
||||
"$injector")},removeAttr:function(a,b){a.removeAttribute(b)},hasClass:zb,css:function(a,b,d){b=eb(b);if(A(d))a.style[b]=d;else return a.style[b]},attr:function(a,b,d){var c=a.nodeType;if(c!==Na&&2!==c&&8!==c)if(c=E(b),Db[c])if(A(d))d?(a[b]=!0,a.setAttribute(b,c)):(a[b]=!1,a.removeAttribute(c));else return a[b]||(a.attributes.getNamedItem(b)||z).specified?c:w;else if(A(d))a.setAttribute(b,d);else if(a.getAttribute)return a=a.getAttribute(b,2),null===a?w:a},prop:function(a,b,d){if(A(d))a[b]=d;else return a[b]},
|
||||
text:function(){function a(a,d){if(v(d)){var c=a.nodeType;return 1===c||c===Na?a.textContent:""}a.textContent=d}a.$dv="";return a}(),val:function(a,b){if(v(b)){if(a.multiple&&"select"===pa(a)){var d=[];p(a.options,function(a){a.selected&&d.push(a.value||a.text)});return 0===d.length?null:d}return a.value}a.value=b},html:function(a,b){if(v(b))return a.innerHTML;wb(a,!0);a.innerHTML=b},empty:Pc},function(a,b){Y.prototype[b]=function(b,c){var e,f,g=this.length;if(a!==Pc&&v(2==a.length&&a!==zb&&a!==Oc?
|
||||
b:c)){if(I(b)){for(e=0;e<g;e++)if(a===Wb)a(this[e],b);else for(f in b)a(this[e],f,b[f]);return this}e=a.$dv;g=v(e)?Math.min(g,1):g;for(f=0;f<g;f++){var h=a(this[f],b,c);e=e?e+h:h}return e}for(e=0;e<g;e++)a(this[e],b,c);return this}});p({removeData:fb,on:function(a,b,d,c){if(A(c))throw Ub("onargs");if(Jc(a)){c=xb(a,!0);var e=c.events,f=c.handle;f||(f=c.handle=Mf(a,e));c=0<=b.indexOf(" ")?b.split(" "):[b];for(var g=c.length,h=function(b,c,g){var h=e[b];h||(h=e[b]=[],h.specialHandlerWrapper=c,"$destroy"===
|
||||
b||g||a.addEventListener(b,f,!1));h.push(d)};g--;)b=c[g],yb[b]?(h(yb[b],Of),h(b,w,!0)):h(b)}},off:Nc,one:function(a,b,d){a=G(a);a.on(b,function e(){a.off(b,d);a.off(b,e)});a.on(b,d)},replaceWith:function(a,b){var d,c=a.parentNode;wb(a);p(new Y(b),function(b){d?c.insertBefore(b,d.nextSibling):c.replaceChild(b,a);d=b})},children:function(a){var b=[];p(a.childNodes,function(a){1===a.nodeType&&b.push(a)});return b},contents:function(a){return a.contentDocument||a.childNodes||[]},append:function(a,b){var d=
|
||||
a.nodeType;if(1===d||11===d){b=new Y(b);for(var d=0,c=b.length;d<c;d++)a.appendChild(b[d])}},prepend:function(a,b){if(1===a.nodeType){var d=a.firstChild;p(new Y(b),function(b){a.insertBefore(b,d)})}},wrap:function(a,b){Lc(a,G(b).eq(0).clone()[0])},remove:Xb,detach:function(a){Xb(a,!0)},after:function(a,b){var d=a,c=a.parentNode;b=new Y(b);for(var e=0,f=b.length;e<f;e++){var g=b[e];c.insertBefore(g,d.nextSibling);d=g}},addClass:Bb,removeClass:Ab,toggleClass:function(a,b,d){b&&p(b.split(" "),function(b){var e=
|
||||
d;v(e)&&(e=!zb(a,b));(e?Bb:Ab)(a,b)})},parent:function(a){return(a=a.parentNode)&&11!==a.nodeType?a:null},next:function(a){return a.nextElementSibling},find:function(a,b){return a.getElementsByTagName?a.getElementsByTagName(b):[]},clone:Vb,triggerHandler:function(a,b,d){var c,e,f=b.type||b,g=xb(a);if(g=(g=g&&g.events)&&g[f])c={preventDefault:function(){this.defaultPrevented=!0},isDefaultPrevented:function(){return!0===this.defaultPrevented},stopImmediatePropagation:function(){this.immediatePropagationStopped=
|
||||
!0},isImmediatePropagationStopped:function(){return!0===this.immediatePropagationStopped},stopPropagation:z,type:f,target:a},b.type&&(c=S(c,b)),b=ma(g),e=d?[c].concat(d):[c],p(b,function(b){c.isImmediatePropagationStopped()||b.apply(a,e)})}},function(a,b){Y.prototype[b]=function(b,c,e){for(var f,g=0,h=this.length;g<h;g++)v(f)?(f=a(this[g],b,c,e),A(f)&&(f=G(f))):Mc(f,a(this[g],b,c,e));return A(f)?f:this};Y.prototype.bind=Y.prototype.on;Y.prototype.unbind=Y.prototype.off});Sa.prototype={put:function(a,
|
||||
b){this[Fa(a,this.nextUid)]=b},get:function(a){return this[Fa(a,this.nextUid)]},remove:function(a){var b=this[a=Fa(a,this.nextUid)];delete this[a];return b}};var Df=[function(){this.$get=[function(){return Sa}]}],Rf=/^([^\(]+?)=>/,Sf=/^[^\(]*\(\s*([^\)]*)\)/m,Ag=/,/,Bg=/^\s*(_?)(\S+?)\1\s*$/,Qf=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg,Ga=O("$injector");db.$$annotate=function(a,b,d){var c;if("function"===typeof a){if(!(c=a.$inject)){c=[];if(a.length){if(b)throw D(d)&&d||(d=a.name||Tf(a)),Ga("strictdi",d);
|
||||
b=Sc(a);p(b[1].split(Ag),function(a){a.replace(Bg,function(a,b,d){c.push(d)})})}a.$inject=c}}else L(a)?(b=a.length-1,Qa(a[b],"fn"),c=a.slice(0,b)):Qa(a,"fn",!0);return c};var Nd=O("$animate"),We=function(){this.$get=z},Xe=function(){var a=new Sa,b=[];this.$get=["$$AnimateRunner","$rootScope",function(d,c){function e(a,b,c){var d=!1;b&&(b=D(b)?b.split(" "):L(b)?b:[],p(b,function(b){b&&(d=!0,a[b]=c)}));return d}function f(){p(b,function(b){var c=a.get(b);if(c){var d=Uf(b.attr("class")),e="",f="";p(c,
|
||||
function(a,b){a!==!!d[b]&&(a?e+=(e.length?" ":"")+b:f+=(f.length?" ":"")+b)});p(b,function(a){e&&Bb(a,e);f&&Ab(a,f)});a.remove(b)}});b.length=0}return{enabled:z,on:z,off:z,pin:z,push:function(g,h,k,l){l&&l();k=k||{};k.from&&g.css(k.from);k.to&&g.css(k.to);if(k.addClass||k.removeClass)if(h=k.addClass,l=k.removeClass,k=a.get(g)||{},h=e(k,h,!0),l=e(k,l,!1),h||l)a.put(g,k),b.push(g),1===b.length&&c.$$postDigest(f);g=new d;g.complete();return g}}}]},Ue=["$provide",function(a){var b=this;this.$$registeredAnimations=
|
||||
Object.create(null);this.register=function(d,c){if(d&&"."!==d.charAt(0))throw Nd("notcsel",d);var e=d+"-animation";b.$$registeredAnimations[d.substr(1)]=e;a.factory(e,c)};this.classNameFilter=function(a){if(1===arguments.length&&(this.$$classNameFilter=a instanceof RegExp?a:null)&&/(\s+|\/)ng-animate(\s+|\/)/.test(this.$$classNameFilter.toString()))throw Nd("nongcls","ng-animate");return this.$$classNameFilter};this.$get=["$$animateQueue",function(a){function b(a,c,d){if(d){var h;a:{for(h=0;h<d.length;h++){var k=
|
||||
d[h];if(1===k.nodeType){h=k;break a}}h=void 0}!h||h.parentNode||h.previousElementSibling||(d=null)}d?d.after(a):c.prepend(a)}return{on:a.on,off:a.off,pin:a.pin,enabled:a.enabled,cancel:function(a){a.end&&a.end()},enter:function(e,f,g,h){f=f&&G(f);g=g&&G(g);f=f||g.parent();b(e,f,g);return a.push(e,"enter",Ha(h))},move:function(e,f,g,h){f=f&&G(f);g=g&&G(g);f=f||g.parent();b(e,f,g);return a.push(e,"move",Ha(h))},leave:function(b,c){return a.push(b,"leave",Ha(c),function(){b.remove()})},addClass:function(b,
|
||||
c,g){g=Ha(g);g.addClass=hb(g.addclass,c);return a.push(b,"addClass",g)},removeClass:function(b,c,g){g=Ha(g);g.removeClass=hb(g.removeClass,c);return a.push(b,"removeClass",g)},setClass:function(b,c,g,h){h=Ha(h);h.addClass=hb(h.addClass,c);h.removeClass=hb(h.removeClass,g);return a.push(b,"setClass",h)},animate:function(b,c,g,h,k){k=Ha(k);k.from=k.from?S(k.from,c):c;k.to=k.to?S(k.to,g):g;k.tempClasses=hb(k.tempClasses,h||"ng-inline-animate");return a.push(b,"animate",k)}}}]}],Ze=function(){this.$get=
|
||||
["$$rAF",function(a){function b(b){d.push(b);1<d.length||a(function(){for(var a=0;a<d.length;a++)d[a]();d=[]})}var d=[];return function(){var a=!1;b(function(){a=!0});return function(d){a?d():b(d)}}}]},Ye=function(){this.$get=["$q","$sniffer","$$animateAsyncRun","$document","$timeout",function(a,b,d,c,e){function f(a){this.setHost(a);var b=d();this._doneCallbacks=[];this._tick=function(a){var d=c[0];d&&d.hidden?e(a,0,!1):b(a)};this._state=0}f.chain=function(a,b){function c(){if(d===a.length)b(!0);
|
||||
else a[d](function(a){!1===a?b(!1):(d++,c())})}var d=0;c()};f.all=function(a,b){function c(f){e=e&&f;++d===a.length&&b(e)}var d=0,e=!0;p(a,function(a){a.done(c)})};f.prototype={setHost:function(a){this.host=a||{}},done:function(a){2===this._state?a():this._doneCallbacks.push(a)},progress:z,getPromise:function(){if(!this.promise){var b=this;this.promise=a(function(a,c){b.done(function(b){!1===b?c():a()})})}return this.promise},then:function(a,b){return this.getPromise().then(a,b)},"catch":function(a){return this.getPromise()["catch"](a)},
|
||||
"finally":function(a){return this.getPromise()["finally"](a)},pause:function(){this.host.pause&&this.host.pause()},resume:function(){this.host.resume&&this.host.resume()},end:function(){this.host.end&&this.host.end();this._resolve(!0)},cancel:function(){this.host.cancel&&this.host.cancel();this._resolve(!1)},complete:function(a){var b=this;0===b._state&&(b._state=1,b._tick(function(){b._resolve(a)}))},_resolve:function(a){2!==this._state&&(p(this._doneCallbacks,function(b){b(a)}),this._doneCallbacks.length=
|
||||
0,this._state=2)}};return f}]},Ve=function(){this.$get=["$$rAF","$q","$$AnimateRunner",function(a,b,d){return function(b,e){function f(){a(function(){g.addClass&&(b.addClass(g.addClass),g.addClass=null);g.removeClass&&(b.removeClass(g.removeClass),g.removeClass=null);g.to&&(b.css(g.to),g.to=null);h||k.complete();h=!0});return k}var g=e||{};g.$$prepared||(g=qa(g));g.cleanupStyles&&(g.from=g.to=null);g.from&&(b.css(g.from),g.from=null);var h,k=new d;return{start:f,end:f}}}]},la=O("$compile");Bc.$inject=
|
||||
["$provide","$$sanitizeUriProvider"];var Uc=/^((?:x|data)[\:\-_])/i,Zf=O("$controller"),Zc=/^(\S+)(\s+as\s+([\w$]+))?$/,ef=function(){this.$get=["$document",function(a){return function(b){b?!b.nodeType&&b instanceof G&&(b=b[0]):b=a[0].body;return b.offsetWidth+1}}]},$c="application/json",ac={"Content-Type":$c+";charset=utf-8"},ag=/^\[|^\{(?!\{)/,bg={"[":/]$/,"{":/}$/},$f=/^\)\]\}',?\n/,Cg=O("$http"),dd=function(a){return function(){throw Cg("legacy",a);}},Ja=ea.$interpolateMinErr=O("$interpolate");
|
||||
Ja.throwNoconcat=function(a){throw Ja("noconcat",a);};Ja.interr=function(a,b){return Ja("interr",a,b.toString())};var Dg=/^([^\?#]*)(\?([^#]*))?(#(.*))?$/,dg={http:80,https:443,ftp:21},Eb=O("$location"),Eg={$$html5:!1,$$replace:!1,absUrl:Fb("$$absUrl"),url:function(a){if(v(a))return this.$$url;var b=Dg.exec(a);(b[1]||""===a)&&this.path(decodeURIComponent(b[1]));(b[2]||b[1]||""===a)&&this.search(b[3]||"");this.hash(b[5]||"");return this},protocol:Fb("$$protocol"),host:Fb("$$host"),port:Fb("$$port"),
|
||||
path:id("$$path",function(a){a=null!==a?a.toString():"";return"/"==a.charAt(0)?a:"/"+a}),search:function(a,b){switch(arguments.length){case 0:return this.$$search;case 1:if(D(a)||W(a))a=a.toString(),this.$$search=wc(a);else if(I(a))a=qa(a,{}),p(a,function(b,c){null==b&&delete a[c]}),this.$$search=a;else throw Eb("isrcharg");break;default:v(b)||null===b?delete this.$$search[a]:this.$$search[a]=b}this.$$compose();return this},hash:id("$$hash",function(a){return null!==a?a.toString():""}),replace:function(){this.$$replace=
|
||||
!0;return this}};p([hd,dc,cc],function(a){a.prototype=Object.create(Eg);a.prototype.state=function(b){if(!arguments.length)return this.$$state;if(a!==cc||!this.$$html5)throw Eb("nostate");this.$$state=v(b)?null:b;return this}});var U=O("$parse"),fg=Function.prototype.call,gg=Function.prototype.apply,hg=Function.prototype.bind,Mb=X();p("+ - * / % === !== == != < > <= >= && || ! = |".split(" "),function(a){Mb[a]=!0});var Fg={n:"\n",f:"\f",r:"\r",t:"\t",v:"\v","'":"'",'"':'"'},fc=function(a){this.options=
|
||||
a};fc.prototype={constructor:fc,lex:function(a){this.text=a;this.index=0;for(this.tokens=[];this.index<this.text.length;)if(a=this.text.charAt(this.index),'"'===a||"'"===a)this.readString(a);else if(this.isNumber(a)||"."===a&&this.isNumber(this.peek()))this.readNumber();else if(this.isIdent(a))this.readIdent();else if(this.is(a,"(){}[].,;:?"))this.tokens.push({index:this.index,text:a}),this.index++;else if(this.isWhitespace(a))this.index++;else{var b=a+this.peek(),d=b+this.peek(2),c=Mb[b],e=Mb[d];
|
||||
Mb[a]||c||e?(a=e?d:c?b:a,this.tokens.push({index:this.index,text:a,operator:!0}),this.index+=a.length):this.throwError("Unexpected next character ",this.index,this.index+1)}return this.tokens},is:function(a,b){return-1!==b.indexOf(a)},peek:function(a){a=a||1;return this.index+a<this.text.length?this.text.charAt(this.index+a):!1},isNumber:function(a){return"0"<=a&&"9">=a&&"string"===typeof a},isWhitespace:function(a){return" "===a||"\r"===a||"\t"===a||"\n"===a||"\v"===a||"\u00a0"===a},isIdent:function(a){return"a"<=
|
||||
a&&"z">=a||"A"<=a&&"Z">=a||"_"===a||"$"===a},isExpOperator:function(a){return"-"===a||"+"===a||this.isNumber(a)},throwError:function(a,b,d){d=d||this.index;b=A(b)?"s "+b+"-"+this.index+" ["+this.text.substring(b,d)+"]":" "+d;throw U("lexerr",a,b,this.text);},readNumber:function(){for(var a="",b=this.index;this.index<this.text.length;){var d=E(this.text.charAt(this.index));if("."==d||this.isNumber(d))a+=d;else{var c=this.peek();if("e"==d&&this.isExpOperator(c))a+=d;else if(this.isExpOperator(d)&&c&&
|
||||
this.isNumber(c)&&"e"==a.charAt(a.length-1))a+=d;else if(!this.isExpOperator(d)||c&&this.isNumber(c)||"e"!=a.charAt(a.length-1))break;else this.throwError("Invalid exponent")}this.index++}this.tokens.push({index:b,text:a,constant:!0,value:Number(a)})},readIdent:function(){for(var a=this.index;this.index<this.text.length;){var b=this.text.charAt(this.index);if(!this.isIdent(b)&&!this.isNumber(b))break;this.index++}this.tokens.push({index:a,text:this.text.slice(a,this.index),identifier:!0})},readString:function(a){var b=
|
||||
this.index;this.index++;for(var d="",c=a,e=!1;this.index<this.text.length;){var f=this.text.charAt(this.index),c=c+f;if(e)"u"===f?(e=this.text.substring(this.index+1,this.index+5),e.match(/[\da-f]{4}/i)||this.throwError("Invalid unicode escape [\\u"+e+"]"),this.index+=4,d+=String.fromCharCode(parseInt(e,16))):d+=Fg[f]||f,e=!1;else if("\\"===f)e=!0;else{if(f===a){this.index++;this.tokens.push({index:b,text:c,constant:!0,value:d});return}d+=f}this.index++}this.throwError("Unterminated quote",b)}};var r=
|
||||
function(a,b){this.lexer=a;this.options=b};r.Program="Program";r.ExpressionStatement="ExpressionStatement";r.AssignmentExpression="AssignmentExpression";r.ConditionalExpression="ConditionalExpression";r.LogicalExpression="LogicalExpression";r.BinaryExpression="BinaryExpression";r.UnaryExpression="UnaryExpression";r.CallExpression="CallExpression";r.MemberExpression="MemberExpression";r.Identifier="Identifier";r.Literal="Literal";r.ArrayExpression="ArrayExpression";r.Property="Property";r.ObjectExpression=
|
||||
"ObjectExpression";r.ThisExpression="ThisExpression";r.LocalsExpression="LocalsExpression";r.NGValueParameter="NGValueParameter";r.prototype={ast:function(a){this.text=a;this.tokens=this.lexer.lex(a);a=this.program();0!==this.tokens.length&&this.throwError("is an unexpected token",this.tokens[0]);return a},program:function(){for(var a=[];;)if(0<this.tokens.length&&!this.peek("}",")",";","]")&&a.push(this.expressionStatement()),!this.expect(";"))return{type:r.Program,body:a}},expressionStatement:function(){return{type:r.ExpressionStatement,
|
||||
expression:this.filterChain()}},filterChain:function(){for(var a=this.expression();this.expect("|");)a=this.filter(a);return a},expression:function(){return this.assignment()},assignment:function(){var a=this.ternary();this.expect("=")&&(a={type:r.AssignmentExpression,left:a,right:this.assignment(),operator:"="});return a},ternary:function(){var a=this.logicalOR(),b,d;return this.expect("?")&&(b=this.expression(),this.consume(":"))?(d=this.expression(),{type:r.ConditionalExpression,test:a,alternate:b,
|
||||
consequent:d}):a},logicalOR:function(){for(var a=this.logicalAND();this.expect("||");)a={type:r.LogicalExpression,operator:"||",left:a,right:this.logicalAND()};return a},logicalAND:function(){for(var a=this.equality();this.expect("&&");)a={type:r.LogicalExpression,operator:"&&",left:a,right:this.equality()};return a},equality:function(){for(var a=this.relational(),b;b=this.expect("==","!=","===","!==");)a={type:r.BinaryExpression,operator:b.text,left:a,right:this.relational()};return a},relational:function(){for(var a=
|
||||
this.additive(),b;b=this.expect("<",">","<=",">=");)a={type:r.BinaryExpression,operator:b.text,left:a,right:this.additive()};return a},additive:function(){for(var a=this.multiplicative(),b;b=this.expect("+","-");)a={type:r.BinaryExpression,operator:b.text,left:a,right:this.multiplicative()};return a},multiplicative:function(){for(var a=this.unary(),b;b=this.expect("*","/","%");)a={type:r.BinaryExpression,operator:b.text,left:a,right:this.unary()};return a},unary:function(){var a;return(a=this.expect("+",
|
||||
"-","!"))?{type:r.UnaryExpression,operator:a.text,prefix:!0,argument:this.unary()}:this.primary()},primary:function(){var a;this.expect("(")?(a=this.filterChain(),this.consume(")")):this.expect("[")?a=this.arrayDeclaration():this.expect("{")?a=this.object():this.selfReferential.hasOwnProperty(this.peek().text)?a=qa(this.selfReferential[this.consume().text]):this.options.literals.hasOwnProperty(this.peek().text)?a={type:r.Literal,value:this.options.literals[this.consume().text]}:this.peek().identifier?
|
||||
a=this.identifier():this.peek().constant?a=this.constant():this.throwError("not a primary expression",this.peek());for(var b;b=this.expect("(","[",".");)"("===b.text?(a={type:r.CallExpression,callee:a,arguments:this.parseArguments()},this.consume(")")):"["===b.text?(a={type:r.MemberExpression,object:a,property:this.expression(),computed:!0},this.consume("]")):"."===b.text?a={type:r.MemberExpression,object:a,property:this.identifier(),computed:!1}:this.throwError("IMPOSSIBLE");return a},filter:function(a){a=
|
||||
[a];for(var b={type:r.CallExpression,callee:this.identifier(),arguments:a,filter:!0};this.expect(":");)a.push(this.expression());return b},parseArguments:function(){var a=[];if(")"!==this.peekToken().text){do a.push(this.expression());while(this.expect(","))}return a},identifier:function(){var a=this.consume();a.identifier||this.throwError("is not a valid identifier",a);return{type:r.Identifier,name:a.text}},constant:function(){return{type:r.Literal,value:this.consume().value}},arrayDeclaration:function(){var a=
|
||||
[];if("]"!==this.peekToken().text){do{if(this.peek("]"))break;a.push(this.expression())}while(this.expect(","))}this.consume("]");return{type:r.ArrayExpression,elements:a}},object:function(){var a=[],b;if("}"!==this.peekToken().text){do{if(this.peek("}"))break;b={type:r.Property,kind:"init"};this.peek().constant?b.key=this.constant():this.peek().identifier?b.key=this.identifier():this.throwError("invalid key",this.peek());this.consume(":");b.value=this.expression();a.push(b)}while(this.expect(","))
|
||||
}this.consume("}");return{type:r.ObjectExpression,properties:a}},throwError:function(a,b){throw U("syntax",b.text,a,b.index+1,this.text,this.text.substring(b.index));},consume:function(a){if(0===this.tokens.length)throw U("ueoe",this.text);var b=this.expect(a);b||this.throwError("is unexpected, expecting ["+a+"]",this.peek());return b},peekToken:function(){if(0===this.tokens.length)throw U("ueoe",this.text);return this.tokens[0]},peek:function(a,b,d,c){return this.peekAhead(0,a,b,d,c)},peekAhead:function(a,
|
||||
b,d,c,e){if(this.tokens.length>a){a=this.tokens[a];var f=a.text;if(f===b||f===d||f===c||f===e||!(b||d||c||e))return a}return!1},expect:function(a,b,d,c){return(a=this.peek(a,b,d,c))?(this.tokens.shift(),a):!1},selfReferential:{"this":{type:r.ThisExpression},$locals:{type:r.LocalsExpression}}};pd.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.state={nextId:0,filters:{},expensiveChecks:b,fn:{vars:[],body:[],own:{}},assign:{vars:[],body:[],own:{}},inputs:[]};V(c,d.$filter);
|
||||
var e="",f;this.stage="assign";if(f=nd(c))this.state.computing="assign",e=this.nextId(),this.recurse(f,e),this.return_(e),e="fn.assign="+this.generateFunction("assign","s,v,l");f=ld(c.body);d.stage="inputs";p(f,function(a,b){var c="fn"+b;d.state[c]={vars:[],body:[],own:{}};d.state.computing=c;var e=d.nextId();d.recurse(a,e);d.return_(e);d.state.inputs.push(c);a.watchId=b});this.state.computing="fn";this.stage="main";this.recurse(c);e='"'+this.USE+" "+this.STRICT+'";\n'+this.filterPrefix()+"var fn="+
|
||||
this.generateFunction("fn","s,l,a,i")+e+this.watchFns()+"return fn;";e=(new Function("$filter","ensureSafeMemberName","ensureSafeObject","ensureSafeFunction","getStringValue","ensureSafeAssignContext","ifDefined","plus","text",e))(this.$filter,Va,xa,jd,eg,Gb,ig,kd,a);this.state=this.stage=w;e.literal=od(c);e.constant=c.constant;return e},USE:"use",STRICT:"strict",watchFns:function(){var a=[],b=this.state.inputs,d=this;p(b,function(b){a.push("var "+b+"="+d.generateFunction(b,"s"))});b.length&&a.push("fn.inputs=["+
|
||||
b.join(",")+"];");return a.join("")},generateFunction:function(a,b){return"function("+b+"){"+this.varsPrefix(a)+this.body(a)+"};"},filterPrefix:function(){var a=[],b=this;p(this.state.filters,function(d,c){a.push(d+"=$filter("+b.escape(c)+")")});return a.length?"var "+a.join(",")+";":""},varsPrefix:function(a){return this.state[a].vars.length?"var "+this.state[a].vars.join(",")+";":""},body:function(a){return this.state[a].body.join("")},recurse:function(a,b,d,c,e,f){var g,h,k=this,l,m;c=c||z;if(!f&&
|
||||
A(a.watchId))b=b||this.nextId(),this.if_("i",this.lazyAssign(b,this.computedMember("i",a.watchId)),this.lazyRecurse(a,b,d,c,e,!0));else switch(a.type){case r.Program:p(a.body,function(b,c){k.recurse(b.expression,w,w,function(a){h=a});c!==a.body.length-1?k.current().body.push(h,";"):k.return_(h)});break;case r.Literal:m=this.escape(a.value);this.assign(b,m);c(m);break;case r.UnaryExpression:this.recurse(a.argument,w,w,function(a){h=a});m=a.operator+"("+this.ifDefined(h,0)+")";this.assign(b,m);c(m);
|
||||
break;case r.BinaryExpression:this.recurse(a.left,w,w,function(a){g=a});this.recurse(a.right,w,w,function(a){h=a});m="+"===a.operator?this.plus(g,h):"-"===a.operator?this.ifDefined(g,0)+a.operator+this.ifDefined(h,0):"("+g+")"+a.operator+"("+h+")";this.assign(b,m);c(m);break;case r.LogicalExpression:b=b||this.nextId();k.recurse(a.left,b);k.if_("&&"===a.operator?b:k.not(b),k.lazyRecurse(a.right,b));c(b);break;case r.ConditionalExpression:b=b||this.nextId();k.recurse(a.test,b);k.if_(b,k.lazyRecurse(a.alternate,
|
||||
b),k.lazyRecurse(a.consequent,b));c(b);break;case r.Identifier:b=b||this.nextId();d&&(d.context="inputs"===k.stage?"s":this.assign(this.nextId(),this.getHasOwnProperty("l",a.name)+"?l:s"),d.computed=!1,d.name=a.name);Va(a.name);k.if_("inputs"===k.stage||k.not(k.getHasOwnProperty("l",a.name)),function(){k.if_("inputs"===k.stage||"s",function(){e&&1!==e&&k.if_(k.not(k.nonComputedMember("s",a.name)),k.lazyAssign(k.nonComputedMember("s",a.name),"{}"));k.assign(b,k.nonComputedMember("s",a.name))})},b&&
|
||||
k.lazyAssign(b,k.nonComputedMember("l",a.name)));(k.state.expensiveChecks||Hb(a.name))&&k.addEnsureSafeObject(b);c(b);break;case r.MemberExpression:g=d&&(d.context=this.nextId())||this.nextId();b=b||this.nextId();k.recurse(a.object,g,w,function(){k.if_(k.notNull(g),function(){e&&1!==e&&k.addEnsureSafeAssignContext(g);if(a.computed)h=k.nextId(),k.recurse(a.property,h),k.getStringValue(h),k.addEnsureSafeMemberName(h),e&&1!==e&&k.if_(k.not(k.computedMember(g,h)),k.lazyAssign(k.computedMember(g,h),"{}")),
|
||||
m=k.ensureSafeObject(k.computedMember(g,h)),k.assign(b,m),d&&(d.computed=!0,d.name=h);else{Va(a.property.name);e&&1!==e&&k.if_(k.not(k.nonComputedMember(g,a.property.name)),k.lazyAssign(k.nonComputedMember(g,a.property.name),"{}"));m=k.nonComputedMember(g,a.property.name);if(k.state.expensiveChecks||Hb(a.property.name))m=k.ensureSafeObject(m);k.assign(b,m);d&&(d.computed=!1,d.name=a.property.name)}},function(){k.assign(b,"undefined")});c(b)},!!e);break;case r.CallExpression:b=b||this.nextId();a.filter?
|
||||
(h=k.filter(a.callee.name),l=[],p(a.arguments,function(a){var b=k.nextId();k.recurse(a,b);l.push(b)}),m=h+"("+l.join(",")+")",k.assign(b,m),c(b)):(h=k.nextId(),g={},l=[],k.recurse(a.callee,h,g,function(){k.if_(k.notNull(h),function(){k.addEnsureSafeFunction(h);p(a.arguments,function(a){k.recurse(a,k.nextId(),w,function(a){l.push(k.ensureSafeObject(a))})});g.name?(k.state.expensiveChecks||k.addEnsureSafeObject(g.context),m=k.member(g.context,g.name,g.computed)+"("+l.join(",")+")"):m=h+"("+l.join(",")+
|
||||
")";m=k.ensureSafeObject(m);k.assign(b,m)},function(){k.assign(b,"undefined")});c(b)}));break;case r.AssignmentExpression:h=this.nextId();g={};if(!md(a.left))throw U("lval");this.recurse(a.left,w,g,function(){k.if_(k.notNull(g.context),function(){k.recurse(a.right,h);k.addEnsureSafeObject(k.member(g.context,g.name,g.computed));k.addEnsureSafeAssignContext(g.context);m=k.member(g.context,g.name,g.computed)+a.operator+h;k.assign(b,m);c(b||m)})},1);break;case r.ArrayExpression:l=[];p(a.elements,function(a){k.recurse(a,
|
||||
k.nextId(),w,function(a){l.push(a)})});m="["+l.join(",")+"]";this.assign(b,m);c(m);break;case r.ObjectExpression:l=[];p(a.properties,function(a){k.recurse(a.value,k.nextId(),w,function(b){l.push(k.escape(a.key.type===r.Identifier?a.key.name:""+a.key.value)+":"+b)})});m="{"+l.join(",")+"}";this.assign(b,m);c(m);break;case r.ThisExpression:this.assign(b,"s");c("s");break;case r.LocalsExpression:this.assign(b,"l");c("l");break;case r.NGValueParameter:this.assign(b,"v"),c("v")}},getHasOwnProperty:function(a,
|
||||
b){var d=a+"."+b,c=this.current().own;c.hasOwnProperty(d)||(c[d]=this.nextId(!1,a+"&&("+this.escape(b)+" in "+a+")"));return c[d]},assign:function(a,b){if(a)return this.current().body.push(a,"=",b,";"),a},filter:function(a){this.state.filters.hasOwnProperty(a)||(this.state.filters[a]=this.nextId(!0));return this.state.filters[a]},ifDefined:function(a,b){return"ifDefined("+a+","+this.escape(b)+")"},plus:function(a,b){return"plus("+a+","+b+")"},return_:function(a){this.current().body.push("return ",
|
||||
a,";")},if_:function(a,b,d){if(!0===a)b();else{var c=this.current().body;c.push("if(",a,"){");b();c.push("}");d&&(c.push("else{"),d(),c.push("}"))}},not:function(a){return"!("+a+")"},notNull:function(a){return a+"!=null"},nonComputedMember:function(a,b){return a+"."+b},computedMember:function(a,b){return a+"["+b+"]"},member:function(a,b,d){return d?this.computedMember(a,b):this.nonComputedMember(a,b)},addEnsureSafeObject:function(a){this.current().body.push(this.ensureSafeObject(a),";")},addEnsureSafeMemberName:function(a){this.current().body.push(this.ensureSafeMemberName(a),
|
||||
";")},addEnsureSafeFunction:function(a){this.current().body.push(this.ensureSafeFunction(a),";")},addEnsureSafeAssignContext:function(a){this.current().body.push(this.ensureSafeAssignContext(a),";")},ensureSafeObject:function(a){return"ensureSafeObject("+a+",text)"},ensureSafeMemberName:function(a){return"ensureSafeMemberName("+a+",text)"},ensureSafeFunction:function(a){return"ensureSafeFunction("+a+",text)"},getStringValue:function(a){this.assign(a,"getStringValue("+a+")")},ensureSafeAssignContext:function(a){return"ensureSafeAssignContext("+
|
||||
a+",text)"},lazyRecurse:function(a,b,d,c,e,f){var g=this;return function(){g.recurse(a,b,d,c,e,f)}},lazyAssign:function(a,b){var d=this;return function(){d.assign(a,b)}},stringEscapeRegex:/[^ a-zA-Z0-9]/g,stringEscapeFn:function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)},escape:function(a){if(D(a))return"'"+a.replace(this.stringEscapeRegex,this.stringEscapeFn)+"'";if(W(a))return a.toString();if(!0===a)return"true";if(!1===a)return"false";if(null===a)return"null";if("undefined"===
|
||||
typeof a)return"undefined";throw U("esc");},nextId:function(a,b){var d="v"+this.state.nextId++;a||this.current().vars.push(d+(b?"="+b:""));return d},current:function(){return this.state[this.state.computing]}};qd.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.expression=a;this.expensiveChecks=b;V(c,d.$filter);var e,f;if(e=nd(c))f=this.recurse(e);e=ld(c.body);var g;e&&(g=[],p(e,function(a,b){var c=d.recurse(a);a.input=c;g.push(c);a.watchId=b}));var h=[];p(c.body,function(a){h.push(d.recurse(a.expression))});
|
||||
e=0===c.body.length?z:1===c.body.length?h[0]:function(a,b){var c;p(h,function(d){c=d(a,b)});return c};f&&(e.assign=function(a,b,c){return f(a,c,b)});g&&(e.inputs=g);e.literal=od(c);e.constant=c.constant;return e},recurse:function(a,b,d){var c,e,f=this,g;if(a.input)return this.inputs(a.input,a.watchId);switch(a.type){case r.Literal:return this.value(a.value,b);case r.UnaryExpression:return e=this.recurse(a.argument),this["unary"+a.operator](e,b);case r.BinaryExpression:return c=this.recurse(a.left),
|
||||
e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case r.LogicalExpression:return c=this.recurse(a.left),e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case r.ConditionalExpression:return this["ternary?:"](this.recurse(a.test),this.recurse(a.alternate),this.recurse(a.consequent),b);case r.Identifier:return Va(a.name,f.expression),f.identifier(a.name,f.expensiveChecks||Hb(a.name),b,d,f.expression);case r.MemberExpression:return c=this.recurse(a.object,!1,!!d),a.computed||(Va(a.property.name,
|
||||
f.expression),e=a.property.name),a.computed&&(e=this.recurse(a.property)),a.computed?this.computedMember(c,e,b,d,f.expression):this.nonComputedMember(c,e,f.expensiveChecks,b,d,f.expression);case r.CallExpression:return g=[],p(a.arguments,function(a){g.push(f.recurse(a))}),a.filter&&(e=this.$filter(a.callee.name)),a.filter||(e=this.recurse(a.callee,!0)),a.filter?function(a,c,d,f){for(var n=[],p=0;p<g.length;++p)n.push(g[p](a,c,d,f));a=e.apply(w,n,f);return b?{context:w,name:w,value:a}:a}:function(a,
|
||||
c,d,m){var n=e(a,c,d,m),p;if(null!=n.value){xa(n.context,f.expression);jd(n.value,f.expression);p=[];for(var r=0;r<g.length;++r)p.push(xa(g[r](a,c,d,m),f.expression));p=xa(n.value.apply(n.context,p),f.expression)}return b?{value:p}:p};case r.AssignmentExpression:return c=this.recurse(a.left,!0,1),e=this.recurse(a.right),function(a,d,g,m){var n=c(a,d,g,m);a=e(a,d,g,m);xa(n.value,f.expression);Gb(n.context);n.context[n.name]=a;return b?{value:a}:a};case r.ArrayExpression:return g=[],p(a.elements,function(a){g.push(f.recurse(a))}),
|
||||
function(a,c,d,e){for(var f=[],p=0;p<g.length;++p)f.push(g[p](a,c,d,e));return b?{value:f}:f};case r.ObjectExpression:return g=[],p(a.properties,function(a){g.push({key:a.key.type===r.Identifier?a.key.name:""+a.key.value,value:f.recurse(a.value)})}),function(a,c,d,e){for(var f={},p=0;p<g.length;++p)f[g[p].key]=g[p].value(a,c,d,e);return b?{value:f}:f};case r.ThisExpression:return function(a){return b?{value:a}:a};case r.LocalsExpression:return function(a,c){return b?{value:c}:c};case r.NGValueParameter:return function(a,
|
||||
c,d){return b?{value:d}:d}}},"unary+":function(a,b){return function(d,c,e,f){d=a(d,c,e,f);d=A(d)?+d:0;return b?{value:d}:d}},"unary-":function(a,b){return function(d,c,e,f){d=a(d,c,e,f);d=A(d)?-d:0;return b?{value:d}:d}},"unary!":function(a,b){return function(d,c,e,f){d=!a(d,c,e,f);return b?{value:d}:d}},"binary+":function(a,b,d){return function(c,e,f,g){var h=a(c,e,f,g);c=b(c,e,f,g);h=kd(h,c);return d?{value:h}:h}},"binary-":function(a,b,d){return function(c,e,f,g){var h=a(c,e,f,g);c=b(c,e,f,g);
|
||||
h=(A(h)?h:0)-(A(c)?c:0);return d?{value:h}:h}},"binary*":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)*b(c,e,f,g);return d?{value:c}:c}},"binary/":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)/b(c,e,f,g);return d?{value:c}:c}},"binary%":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)%b(c,e,f,g);return d?{value:c}:c}},"binary===":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)===b(c,e,f,g);return d?{value:c}:c}},"binary!==":function(a,b,d){return function(c,e,f,g){c=a(c,
|
||||
e,f,g)!==b(c,e,f,g);return d?{value:c}:c}},"binary==":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)==b(c,e,f,g);return d?{value:c}:c}},"binary!=":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)!=b(c,e,f,g);return d?{value:c}:c}},"binary<":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)<b(c,e,f,g);return d?{value:c}:c}},"binary>":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)>b(c,e,f,g);return d?{value:c}:c}},"binary<=":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,
|
||||
g)<=b(c,e,f,g);return d?{value:c}:c}},"binary>=":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)>=b(c,e,f,g);return d?{value:c}:c}},"binary&&":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)&&b(c,e,f,g);return d?{value:c}:c}},"binary||":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)||b(c,e,f,g);return d?{value:c}:c}},"ternary?:":function(a,b,d,c){return function(e,f,g,h){e=a(e,f,g,h)?b(e,f,g,h):d(e,f,g,h);return c?{value:e}:e}},value:function(a,b){return function(){return b?{context:w,
|
||||
name:w,value:a}:a}},identifier:function(a,b,d,c,e){return function(f,g,h,k){f=g&&a in g?g:f;c&&1!==c&&f&&!f[a]&&(f[a]={});g=f?f[a]:w;b&&xa(g,e);return d?{context:f,name:a,value:g}:g}},computedMember:function(a,b,d,c,e){return function(f,g,h,k){var l=a(f,g,h,k),m,n;null!=l&&(m=b(f,g,h,k),m+="",Va(m,e),c&&1!==c&&(Gb(l),l&&!l[m]&&(l[m]={})),n=l[m],xa(n,e));return d?{context:l,name:m,value:n}:n}},nonComputedMember:function(a,b,d,c,e,f){return function(g,h,k,l){g=a(g,h,k,l);e&&1!==e&&(Gb(g),g&&!g[b]&&
|
||||
(g[b]={}));h=null!=g?g[b]:w;(d||Hb(b))&&xa(h,f);return c?{context:g,name:b,value:h}:h}},inputs:function(a,b){return function(d,c,e,f){return f?f[b]:a(d,c,e)}}};var gc=function(a,b,d){this.lexer=a;this.$filter=b;this.options=d;this.ast=new r(a,d);this.astCompiler=d.csp?new qd(this.ast,b):new pd(this.ast,b)};gc.prototype={constructor:gc,parse:function(a){return this.astCompiler.compile(a,this.options.expensiveChecks)}};var jg=Object.prototype.valueOf,Ba=O("$sce"),fa={HTML:"html",CSS:"css",URL:"url",
|
||||
RESOURCE_URL:"resourceUrl",JS:"js"},lg=O("$compile"),aa=Q.createElement("a"),ud=wa(N.location.href);vd.$inject=["$document"];Ic.$inject=["$provide"];var Cd=22,Bd=".",ic="0";wd.$inject=["$locale"];yd.$inject=["$locale"];var wg={yyyy:ba("FullYear",4,0,!1,!0),yy:ba("FullYear",2,0,!0,!0),y:ba("FullYear",1,0,!1,!0),MMMM:kb("Month"),MMM:kb("Month",!0),MM:ba("Month",2,1),M:ba("Month",1,1),LLLL:kb("Month",!1,!0),dd:ba("Date",2),d:ba("Date",1),HH:ba("Hours",2),H:ba("Hours",1),hh:ba("Hours",2,-12),h:ba("Hours",
|
||||
1,-12),mm:ba("Minutes",2),m:ba("Minutes",1),ss:ba("Seconds",2),s:ba("Seconds",1),sss:ba("Milliseconds",3),EEEE:kb("Day"),EEE:kb("Day",!0),a:function(a,b){return 12>a.getHours()?b.AMPMS[0]:b.AMPMS[1]},Z:function(a,b,d){a=-1*d;return a=(0<=a?"+":"")+(Ib(Math[0<a?"floor":"ceil"](a/60),2)+Ib(Math.abs(a%60),2))},ww:Ed(2),w:Ed(1),G:jc,GG:jc,GGG:jc,GGGG:function(a,b){return 0>=a.getFullYear()?b.ERANAMES[0]:b.ERANAMES[1]}},vg=/((?:[^yMLdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/,
|
||||
ug=/^\-?\d+$/;xd.$inject=["$locale"];var pg=ia(E),qg=ia(ub);zd.$inject=["$parse"];var ke=ia({restrict:"E",compile:function(a,b){if(!b.href&&!b.xlinkHref)return function(a,b){if("a"===b[0].nodeName.toLowerCase()){var e="[object SVGAnimatedString]"===ha.call(b.prop("href"))?"xlink:href":"href";b.on("click",function(a){b.attr(e)||a.preventDefault()})}}}}),vb={};p(Db,function(a,b){function d(a,d,e){a.$watch(e[c],function(a){e.$set(b,!!a)})}if("multiple"!=a){var c=ua("ng-"+b),e=d;"checked"===a&&(e=function(a,
|
||||
b,e){e.ngModel!==e[c]&&d(a,b,e)});vb[c]=function(){return{restrict:"A",priority:100,link:e}}}});p(Yc,function(a,b){vb[b]=function(){return{priority:100,link:function(a,c,e){if("ngPattern"===b&&"/"==e.ngPattern.charAt(0)&&(c=e.ngPattern.match(yg))){e.$set("ngPattern",new RegExp(c[1],c[2]));return}a.$watch(e[b],function(a){e.$set(b,a)})}}}});p(["src","srcset","href"],function(a){var b=ua("ng-"+a);vb[b]=function(){return{priority:99,link:function(d,c,e){var f=a,g=a;"href"===a&&"[object SVGAnimatedString]"===
|
||||
ha.call(c.prop("href"))&&(g="xlinkHref",e.$attr[g]="xlink:href",f=null);e.$observe(b,function(b){b?(e.$set(g,b),za&&f&&c.prop(f,e[g])):"href"===a&&e.$set(g,null)})}}}});var Jb={$addControl:z,$$renameControl:function(a,b){a.$name=b},$removeControl:z,$setValidity:z,$setDirty:z,$setPristine:z,$setSubmitted:z};Fd.$inject=["$element","$attrs","$scope","$animate","$interpolate"];var Od=function(a){return["$timeout","$parse",function(b,d){function c(a){return""===a?d('this[""]').assign:d(a).assign||z}return{name:"form",
|
||||
restrict:a?"EAC":"E",require:["form","^^?form"],controller:Fd,compile:function(d,f){d.addClass(Wa).addClass(ob);var g=f.name?"name":a&&f.ngForm?"ngForm":!1;return{pre:function(a,d,e,f){var n=f[0];if(!("action"in e)){var p=function(b){a.$apply(function(){n.$commitViewValue();n.$setSubmitted()});b.preventDefault()};d[0].addEventListener("submit",p,!1);d.on("$destroy",function(){b(function(){d[0].removeEventListener("submit",p,!1)},0,!1)})}(f[1]||n.$$parentForm).$addControl(n);var r=g?c(n.$name):z;g&&
|
||||
(r(a,n),e.$observe(g,function(b){n.$name!==b&&(r(a,w),n.$$parentForm.$$renameControl(n,b),r=c(n.$name),r(a,n))}));d.on("$destroy",function(){n.$$parentForm.$removeControl(n);r(a,w);S(n,Jb)})}}}}}]},le=Od(),ye=Od(!0),xg=/^\d{4,}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+(?:[+-][0-2]\d:[0-5]\d|Z)$/,Gg=/^[a-z][a-z\d.+-]*:\/*(?:[^:@]+(?::[^@]+)?@)?(?:[^\s:/?#]+|\[[a-f\d:]+\])(?::\d+)?(?:\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i,Hg=/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,
|
||||
Ig=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/,Pd=/^(\d{4,})-(\d{2})-(\d{2})$/,Qd=/^(\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,mc=/^(\d{4,})-W(\d\d)$/,Rd=/^(\d{4,})-(\d\d)$/,Sd=/^(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,Hd=X();p(["date","datetime-local","month","time","week"],function(a){Hd[a]=!0});var Td={text:function(a,b,d,c,e,f){lb(a,b,d,c,e,f);kc(c)},date:mb("date",Pd,Lb(Pd,["yyyy","MM","dd"]),"yyyy-MM-dd"),"datetime-local":mb("datetimelocal",Qd,Lb(Qd,"yyyy MM dd HH mm ss sss".split(" ")),
|
||||
"yyyy-MM-ddTHH:mm:ss.sss"),time:mb("time",Sd,Lb(Sd,["HH","mm","ss","sss"]),"HH:mm:ss.sss"),week:mb("week",mc,function(a,b){if(ga(a))return a;if(D(a)){mc.lastIndex=0;var d=mc.exec(a);if(d){var c=+d[1],e=+d[2],f=d=0,g=0,h=0,k=Dd(c),e=7*(e-1);b&&(d=b.getHours(),f=b.getMinutes(),g=b.getSeconds(),h=b.getMilliseconds());return new Date(c,0,k.getDate()+e,d,f,g,h)}}return NaN},"yyyy-Www"),month:mb("month",Rd,Lb(Rd,["yyyy","MM"]),"yyyy-MM"),number:function(a,b,d,c,e,f){Id(a,b,d,c);lb(a,b,d,c,e,f);c.$$parserName=
|
||||
"number";c.$parsers.push(function(a){return c.$isEmpty(a)?null:Ig.test(a)?parseFloat(a):w});c.$formatters.push(function(a){if(!c.$isEmpty(a)){if(!W(a))throw nb("numfmt",a);a=a.toString()}return a});if(A(d.min)||d.ngMin){var g;c.$validators.min=function(a){return c.$isEmpty(a)||v(g)||a>=g};d.$observe("min",function(a){A(a)&&!W(a)&&(a=parseFloat(a,10));g=W(a)&&!isNaN(a)?a:w;c.$validate()})}if(A(d.max)||d.ngMax){var h;c.$validators.max=function(a){return c.$isEmpty(a)||v(h)||a<=h};d.$observe("max",function(a){A(a)&&
|
||||
!W(a)&&(a=parseFloat(a,10));h=W(a)&&!isNaN(a)?a:w;c.$validate()})}},url:function(a,b,d,c,e,f){lb(a,b,d,c,e,f);kc(c);c.$$parserName="url";c.$validators.url=function(a,b){var d=a||b;return c.$isEmpty(d)||Gg.test(d)}},email:function(a,b,d,c,e,f){lb(a,b,d,c,e,f);kc(c);c.$$parserName="email";c.$validators.email=function(a,b){var d=a||b;return c.$isEmpty(d)||Hg.test(d)}},radio:function(a,b,d,c){v(d.name)&&b.attr("name",++pb);b.on("click",function(a){b[0].checked&&c.$setViewValue(d.value,a&&a.type)});c.$render=
|
||||
function(){b[0].checked=d.value==c.$viewValue};d.$observe("value",c.$render)},checkbox:function(a,b,d,c,e,f,g,h){var k=Jd(h,a,"ngTrueValue",d.ngTrueValue,!0),l=Jd(h,a,"ngFalseValue",d.ngFalseValue,!1);b.on("click",function(a){c.$setViewValue(b[0].checked,a&&a.type)});c.$render=function(){b[0].checked=c.$viewValue};c.$isEmpty=function(a){return!1===a};c.$formatters.push(function(a){return oa(a,k)});c.$parsers.push(function(a){return a?k:l})},hidden:z,button:z,submit:z,reset:z,file:z},Cc=["$browser",
|
||||
"$sniffer","$filter","$parse",function(a,b,d,c){return{restrict:"E",require:["?ngModel"],link:{pre:function(e,f,g,h){h[0]&&(Td[E(g.type)]||Td.text)(e,f,g,h[0],b,a,d,c)}}}}],Jg=/^(true|false|\d+)$/,Qe=function(){return{restrict:"A",priority:100,compile:function(a,b){return Jg.test(b.ngValue)?function(a,b,e){e.$set("value",a.$eval(e.ngValue))}:function(a,b,e){a.$watch(e.ngValue,function(a){e.$set("value",a)})}}}},qe=["$compile",function(a){return{restrict:"AC",compile:function(b){a.$$addBindingClass(b);
|
||||
return function(b,c,e){a.$$addBindingInfo(c,e.ngBind);c=c[0];b.$watch(e.ngBind,function(a){c.textContent=v(a)?"":a})}}}}],se=["$interpolate","$compile",function(a,b){return{compile:function(d){b.$$addBindingClass(d);return function(c,d,f){c=a(d.attr(f.$attr.ngBindTemplate));b.$$addBindingInfo(d,c.expressions);d=d[0];f.$observe("ngBindTemplate",function(a){d.textContent=v(a)?"":a})}}}}],re=["$sce","$parse","$compile",function(a,b,d){return{restrict:"A",compile:function(c,e){var f=b(e.ngBindHtml),g=
|
||||
b(e.ngBindHtml,function(a){return(a||"").toString()});d.$$addBindingClass(c);return function(b,c,e){d.$$addBindingInfo(c,e.ngBindHtml);b.$watch(g,function(){c.html(a.getTrustedHtml(f(b))||"")})}}}}],Pe=ia({restrict:"A",require:"ngModel",link:function(a,b,d,c){c.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}),te=lc("",!0),ve=lc("Odd",0),ue=lc("Even",1),we=La({compile:function(a,b){b.$set("ngCloak",w);a.removeClass("ng-cloak")}}),xe=[function(){return{restrict:"A",scope:!0,controller:"@",
|
||||
priority:500}}],Hc={},Kg={blur:!0,focus:!0};p("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste".split(" "),function(a){var b=ua("ng-"+a);Hc[b]=["$parse","$rootScope",function(d,c){return{restrict:"A",compile:function(e,f){var g=d(f[b],null,!0);return function(b,d){d.on(a,function(d){var e=function(){g(b,{$event:d})};Kg[a]&&c.$$phase?b.$evalAsync(e):b.$apply(e)})}}}}]});var Ae=["$animate","$compile",function(a,
|
||||
b){return{multiElement:!0,transclude:"element",priority:600,terminal:!0,restrict:"A",$$tlb:!0,link:function(d,c,e,f,g){var h,k,l;d.$watch(e.ngIf,function(d){d?k||g(function(d,f){k=f;d[d.length++]=b.$$createComment("end ngIf",e.ngIf);h={clone:d};a.enter(d,c.parent(),c)}):(l&&(l.remove(),l=null),k&&(k.$destroy(),k=null),h&&(l=tb(h.clone),a.leave(l).then(function(){l=null}),h=null))})}}}],Be=["$templateRequest","$anchorScroll","$animate",function(a,b,d){return{restrict:"ECA",priority:400,terminal:!0,
|
||||
transclude:"element",controller:ea.noop,compile:function(c,e){var f=e.ngInclude||e.src,g=e.onload||"",h=e.autoscroll;return function(c,e,m,n,p){var r=0,w,x,q,t=function(){x&&(x.remove(),x=null);w&&(w.$destroy(),w=null);q&&(d.leave(q).then(function(){x=null}),x=q,q=null)};c.$watch(f,function(f){var m=function(){!A(h)||h&&!c.$eval(h)||b()},x=++r;f?(a(f,!0).then(function(a){if(!c.$$destroyed&&x===r){var b=c.$new();n.template=a;a=p(b,function(a){t();d.enter(a,null,e).then(m)});w=b;q=a;w.$emit("$includeContentLoaded",
|
||||
f);c.$eval(g)}},function(){c.$$destroyed||x!==r||(t(),c.$emit("$includeContentError",f))}),c.$emit("$includeContentRequested",f)):(t(),n.template=null)})}}}}],Se=["$compile",function(a){return{restrict:"ECA",priority:-400,require:"ngInclude",link:function(b,d,c,e){ha.call(d[0]).match(/SVG/)?(d.empty(),a(Kc(e.template,Q).childNodes)(b,function(a){d.append(a)},{futureParentElement:d})):(d.html(e.template),a(d.contents())(b))}}}],Ce=La({priority:450,compile:function(){return{pre:function(a,b,d){a.$eval(d.ngInit)}}}}),
|
||||
Oe=function(){return{restrict:"A",priority:100,require:"ngModel",link:function(a,b,d,c){var e=b.attr(d.$attr.ngList)||", ",f="false"!==d.ngTrim,g=f?Z(e):e;c.$parsers.push(function(a){if(!v(a)){var b=[];a&&p(a.split(g),function(a){a&&b.push(f?Z(a):a)});return b}});c.$formatters.push(function(a){return L(a)?a.join(e):w});c.$isEmpty=function(a){return!a||!a.length}}}},ob="ng-valid",Kd="ng-invalid",Wa="ng-pristine",Kb="ng-dirty",Md="ng-pending",nb=O("ngModel"),Lg=["$scope","$exceptionHandler","$attrs",
|
||||
"$element","$parse","$animate","$timeout","$rootScope","$q","$interpolate",function(a,b,d,c,e,f,g,h,k,l){this.$modelValue=this.$viewValue=Number.NaN;this.$$rawModelValue=w;this.$validators={};this.$asyncValidators={};this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$untouched=!0;this.$touched=!1;this.$pristine=!0;this.$dirty=!1;this.$valid=!0;this.$invalid=!1;this.$error={};this.$$success={};this.$pending=w;this.$name=l(d.name||"",!1)(a);this.$$parentForm=Jb;var m=e(d.ngModel),
|
||||
n=m.assign,r=m,B=n,K=null,x,q=this;this.$$setOptions=function(a){if((q.$options=a)&&a.getterSetter){var b=e(d.ngModel+"()"),f=e(d.ngModel+"($$$p)");r=function(a){var c=m(a);H(c)&&(c=b(a));return c};B=function(a,b){H(m(a))?f(a,{$$$p:b}):n(a,b)}}else if(!m.assign)throw nb("nonassign",d.ngModel,ta(c));};this.$render=z;this.$isEmpty=function(a){return v(a)||""===a||null===a||a!==a};this.$$updateEmptyClasses=function(a){q.$isEmpty(a)?(f.removeClass(c,"ng-not-empty"),f.addClass(c,"ng-empty")):(f.removeClass(c,
|
||||
"ng-empty"),f.addClass(c,"ng-not-empty"))};var t=0;Gd({ctrl:this,$element:c,set:function(a,b){a[b]=!0},unset:function(a,b){delete a[b]},$animate:f});this.$setPristine=function(){q.$dirty=!1;q.$pristine=!0;f.removeClass(c,Kb);f.addClass(c,Wa)};this.$setDirty=function(){q.$dirty=!0;q.$pristine=!1;f.removeClass(c,Wa);f.addClass(c,Kb);q.$$parentForm.$setDirty()};this.$setUntouched=function(){q.$touched=!1;q.$untouched=!0;f.setClass(c,"ng-untouched","ng-touched")};this.$setTouched=function(){q.$touched=
|
||||
!0;q.$untouched=!1;f.setClass(c,"ng-touched","ng-untouched")};this.$rollbackViewValue=function(){g.cancel(K);q.$viewValue=q.$$lastCommittedViewValue;q.$render()};this.$validate=function(){if(!W(q.$modelValue)||!isNaN(q.$modelValue)){var a=q.$$rawModelValue,b=q.$valid,c=q.$modelValue,d=q.$options&&q.$options.allowInvalid;q.$$runValidators(a,q.$$lastCommittedViewValue,function(e){d||b===e||(q.$modelValue=e?a:w,q.$modelValue!==c&&q.$$writeModelToScope())})}};this.$$runValidators=function(a,b,c){function d(){var c=
|
||||
!0;p(q.$validators,function(d,e){var g=d(a,b);c=c&&g;f(e,g)});return c?!0:(p(q.$asyncValidators,function(a,b){f(b,null)}),!1)}function e(){var c=[],d=!0;p(q.$asyncValidators,function(e,g){var h=e(a,b);if(!h||!H(h.then))throw nb("nopromise",h);f(g,w);c.push(h.then(function(){f(g,!0)},function(){d=!1;f(g,!1)}))});c.length?k.all(c).then(function(){g(d)},z):g(!0)}function f(a,b){h===t&&q.$setValidity(a,b)}function g(a){h===t&&c(a)}t++;var h=t;(function(){var a=q.$$parserName||"parse";if(v(x))f(a,null);
|
||||
else return x||(p(q.$validators,function(a,b){f(b,null)}),p(q.$asyncValidators,function(a,b){f(b,null)})),f(a,x),x;return!0})()?d()?e():g(!1):g(!1)};this.$commitViewValue=function(){var a=q.$viewValue;g.cancel(K);if(q.$$lastCommittedViewValue!==a||""===a&&q.$$hasNativeValidators)q.$$updateEmptyClasses(a),q.$$lastCommittedViewValue=a,q.$pristine&&this.$setDirty(),this.$$parseAndValidate()};this.$$parseAndValidate=function(){var b=q.$$lastCommittedViewValue;if(x=v(b)?w:!0)for(var c=0;c<q.$parsers.length;c++)if(b=
|
||||
q.$parsers[c](b),v(b)){x=!1;break}W(q.$modelValue)&&isNaN(q.$modelValue)&&(q.$modelValue=r(a));var d=q.$modelValue,e=q.$options&&q.$options.allowInvalid;q.$$rawModelValue=b;e&&(q.$modelValue=b,q.$modelValue!==d&&q.$$writeModelToScope());q.$$runValidators(b,q.$$lastCommittedViewValue,function(a){e||(q.$modelValue=a?b:w,q.$modelValue!==d&&q.$$writeModelToScope())})};this.$$writeModelToScope=function(){B(a,q.$modelValue);p(q.$viewChangeListeners,function(a){try{a()}catch(c){b(c)}})};this.$setViewValue=
|
||||
function(a,b){q.$viewValue=a;q.$options&&!q.$options.updateOnDefault||q.$$debounceViewValueCommit(b)};this.$$debounceViewValueCommit=function(b){var c=0,d=q.$options;d&&A(d.debounce)&&(d=d.debounce,W(d)?c=d:W(d[b])?c=d[b]:W(d["default"])&&(c=d["default"]));g.cancel(K);c?K=g(function(){q.$commitViewValue()},c):h.$$phase?q.$commitViewValue():a.$apply(function(){q.$commitViewValue()})};a.$watch(function(){var b=r(a);if(b!==q.$modelValue&&(q.$modelValue===q.$modelValue||b===b)){q.$modelValue=q.$$rawModelValue=
|
||||
b;x=w;for(var c=q.$formatters,d=c.length,e=b;d--;)e=c[d](e);q.$viewValue!==e&&(q.$$updateEmptyClasses(e),q.$viewValue=q.$$lastCommittedViewValue=e,q.$render(),q.$$runValidators(b,e,z))}return b})}],Ne=["$rootScope",function(a){return{restrict:"A",require:["ngModel","^?form","^?ngModelOptions"],controller:Lg,priority:1,compile:function(b){b.addClass(Wa).addClass("ng-untouched").addClass(ob);return{pre:function(a,b,e,f){var g=f[0];b=f[1]||g.$$parentForm;g.$$setOptions(f[2]&&f[2].$options);b.$addControl(g);
|
||||
e.$observe("name",function(a){g.$name!==a&&g.$$parentForm.$$renameControl(g,a)});a.$on("$destroy",function(){g.$$parentForm.$removeControl(g)})},post:function(b,c,e,f){var g=f[0];if(g.$options&&g.$options.updateOn)c.on(g.$options.updateOn,function(a){g.$$debounceViewValueCommit(a&&a.type)});c.on("blur",function(){g.$touched||(a.$$phase?b.$evalAsync(g.$setTouched):b.$apply(g.$setTouched))})}}}}}],Mg=/(\s+|^)default(\s+|$)/,Re=function(){return{restrict:"A",controller:["$scope","$attrs",function(a,
|
||||
b){var d=this;this.$options=qa(a.$eval(b.ngModelOptions));A(this.$options.updateOn)?(this.$options.updateOnDefault=!1,this.$options.updateOn=Z(this.$options.updateOn.replace(Mg,function(){d.$options.updateOnDefault=!0;return" "}))):this.$options.updateOnDefault=!0}]}},De=La({terminal:!0,priority:1E3}),Ng=O("ngOptions"),Og=/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?(?:\s+disable\s+when\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/,
|
||||
Le=["$compile","$parse",function(a,b){function d(a,c,d){function e(a,b,c,d,f){this.selectValue=a;this.viewValue=b;this.label=c;this.group=d;this.disabled=f}function l(a){var b;if(!p&&Ca(a))b=a;else{b=[];for(var c in a)a.hasOwnProperty(c)&&"$"!==c.charAt(0)&&b.push(c)}return b}var m=a.match(Og);if(!m)throw Ng("iexp",a,ta(c));var n=m[5]||m[7],p=m[6];a=/ as /.test(m[0])&&m[1];var r=m[9];c=b(m[2]?m[1]:n);var w=a&&b(a)||c,x=r&&b(r),q=r?function(a,b){return x(d,b)}:function(a){return Fa(a)},t=function(a,
|
||||
b){return q(a,z(a,b))},u=b(m[2]||m[1]),s=b(m[3]||""),A=b(m[4]||""),C=b(m[8]),v={},z=p?function(a,b){v[p]=b;v[n]=a;return v}:function(a){v[n]=a;return v};return{trackBy:r,getTrackByValue:t,getWatchables:b(C,function(a){var b=[];a=a||[];for(var c=l(a),e=c.length,f=0;f<e;f++){var g=a===c?f:c[f],k=a[g],g=z(k,g),k=q(k,g);b.push(k);if(m[2]||m[1])k=u(d,g),b.push(k);m[4]&&(g=A(d,g),b.push(g))}return b}),getOptions:function(){for(var a=[],b={},c=C(d)||[],f=l(c),g=f.length,m=0;m<g;m++){var n=c===f?m:f[m],p=
|
||||
z(c[n],n),y=w(d,p),n=q(y,p),x=u(d,p),v=s(d,p),p=A(d,p),y=new e(n,y,x,v,p);a.push(y);b[n]=y}return{items:a,selectValueMap:b,getOptionFromViewValue:function(a){return b[t(a)]},getViewValueFromOption:function(a){return r?ea.copy(a.viewValue):a.viewValue}}}}}var c=Q.createElement("option"),e=Q.createElement("optgroup");return{restrict:"A",terminal:!0,require:["select","ngModel"],link:{pre:function(a,b,c,d){d[0].registerOption=z},post:function(b,g,h,k){function l(a,b){a.element=b;b.disabled=a.disabled;
|
||||
a.label!==b.label&&(b.label=a.label,b.textContent=a.label);a.value!==b.value&&(b.value=a.selectValue)}function m(a,b,c,d){b&&E(b.nodeName)===c?c=b:(c=d.cloneNode(!1),b?a.insertBefore(c,b):a.appendChild(c));return c}function n(a){for(var b;a;)b=a.nextSibling,Xb(a),a=b}function r(a){var b=t&&t[0],c=C&&C[0];if(b||c)for(;a&&(a===b||a===c||8===a.nodeType||"option"===pa(a)&&""===a.value);)a=a.nextSibling;return a}function w(){var a=J&&v.readValue();J=D.getOptions();var b={},d=g[0].firstChild;z&&g.prepend(t);
|
||||
d=r(d);J.items.forEach(function(a){var f,h;A(a.group)?(f=b[a.group],f||(f=m(g[0],d,"optgroup",e),d=f.nextSibling,f.label=a.group,f=b[a.group]={groupElement:f,currentOptionElement:f.firstChild}),h=m(f.groupElement,f.currentOptionElement,"option",c),l(a,h),f.currentOptionElement=h.nextSibling):(h=m(g[0],d,"option",c),l(a,h),d=h.nextSibling)});Object.keys(b).forEach(function(a){n(b[a].currentOptionElement)});n(d);x.$render();if(!x.$isEmpty(a)){var f=v.readValue();(D.trackBy||q?oa(a,f):a===f)||(x.$setViewValue(f),
|
||||
x.$render())}}var v=k[0],x=k[1],q=h.multiple,t;k=0;for(var u=g.children(),s=u.length;k<s;k++)if(""===u[k].value){t=u.eq(k);break}var z=!!t,C=G(c.cloneNode(!1));C.val("?");var J,D=d(h.ngOptions,g,b);q?(x.$isEmpty=function(a){return!a||0===a.length},v.writeValue=function(a){J.items.forEach(function(a){a.element.selected=!1});a&&a.forEach(function(a){(a=J.getOptionFromViewValue(a))&&!a.disabled&&(a.element.selected=!0)})},v.readValue=function(){var a=g.val()||[],b=[];p(a,function(a){(a=J.selectValueMap[a])&&
|
||||
!a.disabled&&b.push(J.getViewValueFromOption(a))});return b},D.trackBy&&b.$watchCollection(function(){if(L(x.$viewValue))return x.$viewValue.map(function(a){return D.getTrackByValue(a)})},function(){x.$render()})):(v.writeValue=function(a){var b=J.getOptionFromViewValue(a);b&&!b.disabled?(g[0].value!==b.selectValue&&(C.remove(),z||t.remove(),g[0].value=b.selectValue,b.element.selected=!0),b.element.setAttribute("selected","selected")):null===a||z?(C.remove(),z||g.prepend(t),g.val(""),t.prop("selected",
|
||||
!0),t.attr("selected",!0)):(z||t.remove(),g.prepend(C),g.val("?"),C.prop("selected",!0),C.attr("selected",!0))},v.readValue=function(){var a=J.selectValueMap[g.val()];return a&&!a.disabled?(z||t.remove(),C.remove(),J.getViewValueFromOption(a)):null},D.trackBy&&b.$watch(function(){return D.getTrackByValue(x.$viewValue)},function(){x.$render()}));z?(t.remove(),a(t)(b),t.removeClass("ng-scope")):t=G(c.cloneNode(!1));w();b.$watchCollection(D.getWatchables,w)}}}}],Ee=["$locale","$interpolate","$log",function(a,
|
||||
b,d){var c=/{}/g,e=/^when(Minus)?(.+)$/;return{link:function(f,g,h){function k(a){g.text(a||"")}var l=h.count,m=h.$attr.when&&g.attr(h.$attr.when),n=h.offset||0,r=f.$eval(m)||{},w={},A=b.startSymbol(),x=b.endSymbol(),q=A+l+"-"+n+x,t=ea.noop,u;p(h,function(a,b){var c=e.exec(b);c&&(c=(c[1]?"-":"")+E(c[2]),r[c]=g.attr(h.$attr[b]))});p(r,function(a,d){w[d]=b(a.replace(c,q))});f.$watch(l,function(b){var c=parseFloat(b),e=isNaN(c);e||c in r||(c=a.pluralCat(c-n));c===u||e&&W(u)&&isNaN(u)||(t(),e=w[c],v(e)?
|
||||
(null!=b&&d.debug("ngPluralize: no rule defined for '"+c+"' in "+m),t=z,k()):t=f.$watch(e,k),u=c)})}}}],Fe=["$parse","$animate","$compile",function(a,b,d){var c=O("ngRepeat"),e=function(a,b,c,d,e,m,n){a[c]=d;e&&(a[e]=m);a.$index=b;a.$first=0===b;a.$last=b===n-1;a.$middle=!(a.$first||a.$last);a.$odd=!(a.$even=0===(b&1))};return{restrict:"A",multiElement:!0,transclude:"element",priority:1E3,terminal:!0,$$tlb:!0,compile:function(f,g){var h=g.ngRepeat,k=d.$$createComment("end ngRepeat",h),l=h.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
|
||||
if(!l)throw c("iexp",h);var m=l[1],n=l[2],r=l[3],v=l[4],l=m.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);if(!l)throw c("iidexp",m);var A=l[3]||l[1],x=l[2];if(r&&(!/^[$a-zA-Z_][$a-zA-Z0-9_]*$/.test(r)||/^(null|undefined|this|\$index|\$first|\$middle|\$last|\$even|\$odd|\$parent|\$root|\$id)$/.test(r)))throw c("badident",r);var q,t,u,s,z={$id:Fa};v?q=a(v):(u=function(a,b){return Fa(b)},s=function(a){return a});return function(a,d,f,g,l){q&&(t=function(b,c,d){x&&(z[x]=b);z[A]=c;z.$index=
|
||||
d;return q(a,z)});var m=X();a.$watchCollection(n,function(f){var g,n,q=d[0],v,B=X(),z,D,G,F,H,E,I;r&&(a[r]=f);if(Ca(f))H=f,n=t||u;else for(I in n=t||s,H=[],f)sa.call(f,I)&&"$"!==I.charAt(0)&&H.push(I);z=H.length;I=Array(z);for(g=0;g<z;g++)if(D=f===H?g:H[g],G=f[D],F=n(D,G,g),m[F])E=m[F],delete m[F],B[F]=E,I[g]=E;else{if(B[F])throw p(I,function(a){a&&a.scope&&(m[a.id]=a)}),c("dupes",h,F,G);I[g]={id:F,scope:w,clone:w};B[F]=!0}for(v in m){E=m[v];F=tb(E.clone);b.leave(F);if(F[0].parentNode)for(g=0,n=F.length;g<
|
||||
n;g++)F[g].$$NG_REMOVED=!0;E.scope.$destroy()}for(g=0;g<z;g++)if(D=f===H?g:H[g],G=f[D],E=I[g],E.scope){v=q;do v=v.nextSibling;while(v&&v.$$NG_REMOVED);E.clone[0]!=v&&b.move(tb(E.clone),null,q);q=E.clone[E.clone.length-1];e(E.scope,g,A,G,x,D,z)}else l(function(a,c){E.scope=c;var d=k.cloneNode(!1);a[a.length++]=d;b.enter(a,null,q);q=d;E.clone=a;B[E.id]=E;e(E.scope,g,A,G,x,D,z)});m=B})}}}}],Ge=["$animate",function(a){return{restrict:"A",multiElement:!0,link:function(b,d,c){b.$watch(c.ngShow,function(b){a[b?
|
||||
"removeClass":"addClass"](d,"ng-hide",{tempClasses:"ng-hide-animate"})})}}}],ze=["$animate",function(a){return{restrict:"A",multiElement:!0,link:function(b,d,c){b.$watch(c.ngHide,function(b){a[b?"addClass":"removeClass"](d,"ng-hide",{tempClasses:"ng-hide-animate"})})}}}],He=La(function(a,b,d){a.$watch(d.ngStyle,function(a,d){d&&a!==d&&p(d,function(a,c){b.css(c,"")});a&&b.css(a)},!0)}),Ie=["$animate","$compile",function(a,b){return{require:"ngSwitch",controller:["$scope",function(){this.cases={}}],
|
||||
link:function(d,c,e,f){var g=[],h=[],k=[],l=[],m=function(a,b){return function(){a.splice(b,1)}};d.$watch(e.ngSwitch||e.on,function(c){var d,e;d=0;for(e=k.length;d<e;++d)a.cancel(k[d]);d=k.length=0;for(e=l.length;d<e;++d){var r=tb(h[d].clone);l[d].$destroy();(k[d]=a.leave(r)).then(m(k,d))}h.length=0;l.length=0;(g=f.cases["!"+c]||f.cases["?"])&&p(g,function(c){c.transclude(function(d,e){l.push(e);var f=c.element;d[d.length++]=b.$$createComment("end ngSwitchWhen");h.push({clone:d});a.enter(d,f.parent(),
|
||||
f)})})})}}}],Je=La({transclude:"element",priority:1200,require:"^ngSwitch",multiElement:!0,link:function(a,b,d,c,e){c.cases["!"+d.ngSwitchWhen]=c.cases["!"+d.ngSwitchWhen]||[];c.cases["!"+d.ngSwitchWhen].push({transclude:e,element:b})}}),Ke=La({transclude:"element",priority:1200,require:"^ngSwitch",multiElement:!0,link:function(a,b,d,c,e){c.cases["?"]=c.cases["?"]||[];c.cases["?"].push({transclude:e,element:b})}}),Pg=O("ngTransclude"),Me=La({restrict:"EAC",link:function(a,b,d,c,e){d.ngTransclude===
|
||||
d.$attr.ngTransclude&&(d.ngTransclude="");if(!e)throw Pg("orphan",ta(b));e(function(a){a.length&&(b.empty(),b.append(a))},null,d.ngTransclude||d.ngTranscludeSlot)}}),me=["$templateCache",function(a){return{restrict:"E",terminal:!0,compile:function(b,d){"text/ng-template"==d.type&&a.put(d.id,b[0].text)}}}],Qg={$setViewValue:z,$render:z},Rg=["$element","$scope",function(a,b){var d=this,c=new Sa;d.ngModelCtrl=Qg;d.unknownOption=G(Q.createElement("option"));d.renderUnknownOption=function(b){b="? "+Fa(b)+
|
||||
" ?";d.unknownOption.val(b);a.prepend(d.unknownOption);a.val(b)};b.$on("$destroy",function(){d.renderUnknownOption=z});d.removeUnknownOption=function(){d.unknownOption.parent()&&d.unknownOption.remove()};d.readValue=function(){d.removeUnknownOption();return a.val()};d.writeValue=function(b){d.hasOption(b)?(d.removeUnknownOption(),a.val(b),""===b&&d.emptyOption.prop("selected",!0)):null==b&&d.emptyOption?(d.removeUnknownOption(),a.val("")):d.renderUnknownOption(b)};d.addOption=function(a,b){if(8!==
|
||||
b[0].nodeType){Ra(a,'"option value"');""===a&&(d.emptyOption=b);var g=c.get(a)||0;c.put(a,g+1);d.ngModelCtrl.$render();b[0].hasAttribute("selected")&&(b[0].selected=!0)}};d.removeOption=function(a){var b=c.get(a);b&&(1===b?(c.remove(a),""===a&&(d.emptyOption=w)):c.put(a,b-1))};d.hasOption=function(a){return!!c.get(a)};d.registerOption=function(a,b,c,h,k){if(h){var l;c.$observe("value",function(a){A(l)&&d.removeOption(l);l=a;d.addOption(a,b)})}else k?a.$watch(k,function(a,e){c.$set("value",a);e!==
|
||||
a&&d.removeOption(e);d.addOption(a,b)}):d.addOption(c.value,b);b.on("$destroy",function(){d.removeOption(c.value);d.ngModelCtrl.$render()})}}],ne=function(){return{restrict:"E",require:["select","?ngModel"],controller:Rg,priority:1,link:{pre:function(a,b,d,c){var e=c[1];if(e){var f=c[0];f.ngModelCtrl=e;b.on("change",function(){a.$apply(function(){e.$setViewValue(f.readValue())})});if(d.multiple){f.readValue=function(){var a=[];p(b.find("option"),function(b){b.selected&&a.push(b.value)});return a};
|
||||
f.writeValue=function(a){var c=new Sa(a);p(b.find("option"),function(a){a.selected=A(c.get(a.value))})};var g,h=NaN;a.$watch(function(){h!==e.$viewValue||oa(g,e.$viewValue)||(g=ma(e.$viewValue),e.$render());h=e.$viewValue});e.$isEmpty=function(a){return!a||0===a.length}}}},post:function(a,b,d,c){var e=c[1];if(e){var f=c[0];e.$render=function(){f.writeValue(e.$viewValue)}}}}}},pe=["$interpolate",function(a){return{restrict:"E",priority:100,compile:function(b,d){if(A(d.value))var c=a(d.value,!0);else{var e=
|
||||
a(b.text(),!0);e||d.$set("value",b.text())}return function(a,b,d){var k=b.parent();(k=k.data("$selectController")||k.parent().data("$selectController"))&&k.registerOption(a,b,d,c,e)}}}}],oe=ia({restrict:"E",terminal:!1}),Ec=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){c&&(d.required=!0,c.$validators.required=function(a,b){return!d.required||!c.$isEmpty(b)},d.$observe("required",function(){c.$validate()}))}}},Dc=function(){return{restrict:"A",require:"?ngModel",link:function(a,
|
||||
b,d,c){if(c){var e,f=d.ngPattern||d.pattern;d.$observe("pattern",function(a){D(a)&&0<a.length&&(a=new RegExp("^"+a+"$"));if(a&&!a.test)throw O("ngPattern")("noregexp",f,a,ta(b));e=a||w;c.$validate()});c.$validators.pattern=function(a,b){return c.$isEmpty(b)||v(e)||e.test(b)}}}}},Gc=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){if(c){var e=-1;d.$observe("maxlength",function(a){a=da(a);e=isNaN(a)?-1:a;c.$validate()});c.$validators.maxlength=function(a,b){return 0>e||c.$isEmpty(b)||
|
||||
b.length<=e}}}}},Fc=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){if(c){var e=0;d.$observe("minlength",function(a){e=da(a)||0;c.$validate()});c.$validators.minlength=function(a,b){return c.$isEmpty(b)||b.length>=e}}}}};N.angular.bootstrap?N.console&&console.log("WARNING: Tried to load angular more than once."):(fe(),he(ea),ea.module("ngLocale",[],["$provide",function(a){function b(a){a+="";var b=a.indexOf(".");return-1==b?0:a.length-b-1}a.value("$locale",{DATETIME_FORMATS:{AMPMS:["AM",
|
||||
"PM"],DAY:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ERANAMES:["Before Christ","Anno Domini"],ERAS:["BC","AD"],FIRSTDAYOFWEEK:6,MONTH:"January February March April May June July August September October November December".split(" "),SHORTDAY:"Sun Mon Tue Wed Thu Fri Sat".split(" "),SHORTMONTH:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),STANDALONEMONTH:"January February March April May June July August September October November December".split(" "),WEEKENDRANGE:[5,
|
||||
6],fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",medium:"MMM d, y h:mm:ss a",mediumDate:"MMM d, y",mediumTime:"h:mm:ss a","short":"M/d/yy h:mm a",shortDate:"M/d/yy",shortTime:"h:mm a"},NUMBER_FORMATS:{CURRENCY_SYM:"$",DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{gSize:3,lgSize:3,maxFrac:3,minFrac:0,minInt:1,negPre:"-",negSuf:"",posPre:"",posSuf:""},{gSize:3,lgSize:3,maxFrac:2,minFrac:2,minInt:1,negPre:"-\u00a4",negSuf:"",posPre:"\u00a4",posSuf:""}]},id:"en-us",localeID:"en_US",pluralCat:function(a,
|
||||
c){var e=a|0,f=c;w===f&&(f=Math.min(b(a),3));Math.pow(10,f);return 1==e&&0==f?"one":"other"}})}]),G(Q).ready(function(){be(Q,xc)}))})(window,document);!window.angular.$$csp().noInlineStyle&&window.angular.element(document.head).prepend('<style type="text/css">@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>');
|
||||
//# sourceMappingURL=angular.min.js.map
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче