initial
This commit is contained in:
commit
baa0056244
352 changed files with 47928 additions and 0 deletions
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
|
||||
{
|
||||
internal static class CompleteAttributeValue
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 16,
|
||||
startColumnNumber: 38,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion1 = new()
|
||||
{
|
||||
Kind = CompletionItemKind.Property,
|
||||
Detail = "System.Boolean ValueFromPipeline",
|
||||
FilterText = "ValueFromPipeline",
|
||||
InsertText = "ValueFromPipeline",
|
||||
Label = "ValueFromPipeline",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "ValueFromPipeline",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 15, Character = 32 },
|
||||
End = new Position { Line = 15, Character = 37 }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion2 = new()
|
||||
{
|
||||
Kind = CompletionItemKind.Property,
|
||||
Detail = "System.Boolean ValueFromPipelineByPropertyName",
|
||||
FilterText = "ValueFromPipelineByPropertyName",
|
||||
InsertText = "ValueFromPipelineByPropertyName",
|
||||
Label = "ValueFromPipelineByPropertyName",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "ValueFromPipelineByPropertyName",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 15, Character = 32 },
|
||||
End = new Position { Line = 15, Character = 37 }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion3 = new()
|
||||
{
|
||||
Kind = CompletionItemKind.Property,
|
||||
Detail = "System.Boolean ValueFromRemainingArguments",
|
||||
FilterText = "ValueFromRemainingArguments",
|
||||
InsertText = "ValueFromRemainingArguments",
|
||||
Label = "ValueFromRemainingArguments",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "ValueFromRemainingArguments",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 15, Character = 32 },
|
||||
End = new Position { Line = 15, Character = 37 }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
|
||||
{
|
||||
internal static class CompleteCommandFromModule
|
||||
{
|
||||
public const string GetRandomDetail =
|
||||
"Get-Random [[-Maximum] <Object>] [-SetSeed <int>] [-Minimum <Object>]";
|
||||
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 13,
|
||||
startColumnNumber: 8,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion = new()
|
||||
{
|
||||
Kind = CompletionItemKind.Function,
|
||||
Detail = "", // OS-dependent, checked separately.
|
||||
FilterText = "Get-Random",
|
||||
InsertText = "Get-Random",
|
||||
Label = "Get-Random",
|
||||
SortText = "0001Get-Random",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "Get-Random",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 12, Character = 0 },
|
||||
End = new Position { Line = 12, Character = 8 }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
|
||||
{
|
||||
internal static class CompleteCommandInFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 8,
|
||||
startColumnNumber: 10,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion = new()
|
||||
{
|
||||
Kind = CompletionItemKind.Function,
|
||||
Detail = "",
|
||||
FilterText = "Get-XYZSomething",
|
||||
InsertText = "Get-XYZSomething",
|
||||
Label = "Get-XYZSomething",
|
||||
SortText = "0001Get-XYZSomething",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "Get-XYZSomething",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 7, Character = 0 },
|
||||
End = new Position { Line = 7, Character = 9 }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
|
||||
{
|
||||
internal static class CompleteFilePath
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 19,
|
||||
startColumnNumber: 15,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly TextEdit ExpectedEdit = new()
|
||||
{
|
||||
NewText = "",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 18, Character = 14 },
|
||||
End = new Position { Line = 18, Character = 14 }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
|
||||
{
|
||||
internal static class CompleteNamespace
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 22,
|
||||
startColumnNumber: 15,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion = new()
|
||||
{
|
||||
Kind = CompletionItemKind.Module,
|
||||
Detail = "Namespace System.Collections",
|
||||
FilterText = "System.Collections",
|
||||
InsertText = "System.Collections",
|
||||
Label = "Collections",
|
||||
SortText = "0001Collections",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "System.Collections",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 21, Character = 1 },
|
||||
End = new Position { Line = 21, Character = 15 }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
|
||||
{
|
||||
internal static class CompleteTypeName
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 21,
|
||||
startColumnNumber: 25,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion = new()
|
||||
{
|
||||
Kind = CompletionItemKind.TypeParameter,
|
||||
Detail = "System.Collections.ArrayList",
|
||||
FilterText = "System.Collections.ArrayList",
|
||||
InsertText = "System.Collections.ArrayList",
|
||||
Label = "ArrayList",
|
||||
SortText = "0001ArrayList",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "System.Collections.ArrayList",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 20, Character = 1 },
|
||||
End = new Position { Line = 20, Character = 29 }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
|
||||
{
|
||||
internal static class CompleteVariableInFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 10,
|
||||
startColumnNumber: 9,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly CompletionItem ExpectedCompletion = new()
|
||||
{
|
||||
Kind = CompletionItemKind.Variable,
|
||||
// PowerShell 7.4 now lights up a type for the detail, otherwise it's the same as the
|
||||
// label and therefore hidden.
|
||||
Detail = Utility.VersionUtils.IsPS74 ? "[string]" : "",
|
||||
FilterText = "$testVar1",
|
||||
InsertText = "$testVar1",
|
||||
Label = "testVar1",
|
||||
SortText = "0001testVar1",
|
||||
TextEdit = new TextEdit
|
||||
{
|
||||
NewText = "$testVar1",
|
||||
Range = new Range
|
||||
{
|
||||
Start = new Position { Line = 9, Character = 0 },
|
||||
End = new Position { Line = 9, Character = 8 }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
function Get-XYZSomething
|
||||
{
|
||||
$testVar2 = "Shouldn't find this variable"
|
||||
}
|
||||
|
||||
$testVar1 = "Should find this variable"
|
||||
|
||||
Get-XYZSo
|
||||
|
||||
$testVar
|
||||
|
||||
Import-Module PowerShellGet
|
||||
Get-Rand
|
||||
|
||||
function Test-Completion {
|
||||
param([Parameter(Mandatory, Value)]$test)
|
||||
}
|
||||
|
||||
Get-ChildItem /
|
||||
|
||||
[System.Collections.ArrayList].GetType()
|
||||
[System.Collect
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
param($Param1, $Param2, [switch]$Force)
|
||||
|
||||
"args are $args"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
$i = 1
|
||||
|
||||
while ($i -le 500000)
|
||||
{
|
||||
$str = "Output $i"
|
||||
Write-Host $str
|
||||
$i = $i + 1
|
||||
}
|
||||
|
||||
Write-Host "Done!"
|
||||
Get-Date
|
||||
Get-Host
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$file = Get-ChildItem -Path "." | Select-Object -First 1
|
||||
Write-Host "Debug over"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
$promptSawDebug = $false
|
||||
|
||||
function prompt {
|
||||
if (Test-Path variable:/PSDebugContext -ErrorAction SilentlyContinue) {
|
||||
$promptSawDebug = $true
|
||||
}
|
||||
|
||||
return "$promptSawDebug > "
|
||||
}
|
||||
|
||||
Write-Host "Debug over"
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
class MyClass {
|
||||
[String] $Name;
|
||||
[Int32] $Number; }
|
||||
[bool]$scriptBool = $false
|
||||
$scriptInt = 42
|
||||
function Test-Variables {
|
||||
$strVar = "Hello"
|
||||
[string]$strVar2 = "Hello2"
|
||||
$arrVar = @(1, 2, $strVar, $objVar)
|
||||
$assocArrVar = @{ firstChild = "Child"; secondChild = 42 }
|
||||
$classVar = [MyClass]::new();
|
||||
$classVar.Name = "Test"
|
||||
$classVar.Number = 42;
|
||||
$enumVar = $ErrorActionPreference
|
||||
$nullString = [NullString]::Value
|
||||
$psObjVar = New-Object -TypeName PSObject -Property @{Name = 'John'; Age = 75 }
|
||||
$psCustomObjVar = [PSCustomObject] @{Name = 'Paul'; Age = 73 }
|
||||
$procVar = Get-Process -PID $PID
|
||||
$trueVar = $true
|
||||
$falseVar = $false
|
||||
Write-Output "Done"
|
||||
}
|
||||
|
||||
Test-Variables
|
||||
# NOTE: If a line is added to the function above, the line numbers in the
|
||||
# associated unit tests MUST be adjusted accordingly.
|
||||
|
||||
$SCRIPT:simpleArray = @(
|
||||
1
|
||||
2
|
||||
'red'
|
||||
'blue'
|
||||
)
|
||||
|
||||
# This is a dummy function that the test will use to stop and evaluate the debug environment
|
||||
function __BreakDebuggerEnumerableShowsRawView{}; __BreakDebuggerEnumerableShowsRawView
|
||||
|
||||
$SCRIPT:simpleDictionary = @{
|
||||
item1 = 1
|
||||
item2 = 2
|
||||
item3 = 'red'
|
||||
item4 = 'blue'
|
||||
}
|
||||
function __BreakDebuggerDictionaryShowsRawView{}; __BreakDebuggerDictionaryShowsRawView
|
||||
|
||||
$SCRIPT:sortedDictionary = [Collections.Generic.SortedDictionary[string, object]]::new()
|
||||
$sortedDictionary[1] = 1
|
||||
$sortedDictionary[2] = 2
|
||||
$sortedDictionary['red'] = 'red'
|
||||
$sortedDictionary['blue'] = 'red'
|
||||
|
||||
# This is a dummy function that the test will use to stop and evaluate the debug environment
|
||||
function __BreakDebuggerDerivedDictionaryPropertyInRawView{}; __BreakDebuggerDerivedDictionaryPropertyInRawView
|
||||
|
||||
class CustomToString {
|
||||
[String]$String = 'Hello'
|
||||
[String]ToString() {
|
||||
return $this.String.ToUpper()
|
||||
}
|
||||
}
|
||||
$SCRIPT:CustomToStrings = 1..1000 | ForEach-Object {
|
||||
[CustomToString]::new()
|
||||
}
|
||||
|
||||
# This is a dummy function that the test will use to stop and evaluate the debug environment
|
||||
function __BreakDebuggerToStringShouldMarshallToPipeline{}; __BreakDebuggerToStringShouldMarshallToPipeline
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
|
||||
{
|
||||
public static class FindsFunctionDefinitionData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 3,
|
||||
startColumnNumber: 12,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
|
||||
{
|
||||
public static class FindsFunctionDefinitionInWorkspaceData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/FileWithReferences.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 3,
|
||||
startColumnNumber: 6,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
|
||||
{
|
||||
public static class FindsFunctionDefinitionOfAliasData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 20,
|
||||
startColumnNumber: 4,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
|
||||
{
|
||||
public static class FindsTypeSymbolsDefinitionData
|
||||
{
|
||||
public static readonly ScriptRegion ClassSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 8,
|
||||
startColumnNumber: 14,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion EnumSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 39,
|
||||
startColumnNumber: 10,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion TypeExpressionSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 45,
|
||||
startColumnNumber: 5,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion TypeConstraintSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 25,
|
||||
startColumnNumber: 24,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion ConstructorSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 9,
|
||||
startColumnNumber: 14,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion MethodSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 19,
|
||||
startColumnNumber: 25,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion PropertySourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 15,
|
||||
startColumnNumber: 32,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion EnumMemberSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 41,
|
||||
startColumnNumber: 11,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
|
||||
{
|
||||
public static class FindsTypedVariableDefinitionData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 25,
|
||||
startColumnNumber: 13,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
|
||||
{
|
||||
public static class FindsVariableDefinitionData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 8,
|
||||
startColumnNumber: 3,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Occurrences
|
||||
{
|
||||
public static class FindOccurrencesOnParameterData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 1,
|
||||
startColumnNumber: 31,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Occurrences
|
||||
{
|
||||
public static class FindsOccurrencesOnFunctionData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 1,
|
||||
startColumnNumber: 17,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Occurrences
|
||||
{
|
||||
public static class FindsOccurrencesOnTypeSymbolsData
|
||||
{
|
||||
public static readonly ScriptRegion ClassSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 8,
|
||||
startColumnNumber: 16,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion EnumSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 39,
|
||||
startColumnNumber: 7,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion TypeExpressionSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 34,
|
||||
startColumnNumber: 16,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion TypeConstraintSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 8,
|
||||
startColumnNumber: 24,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion ConstructorSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 13,
|
||||
startColumnNumber: 14,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion MethodSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 28,
|
||||
startColumnNumber: 22,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion PropertySourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 15,
|
||||
startColumnNumber: 18,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion EnumMemberSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 45,
|
||||
startColumnNumber: 16,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Occurrences
|
||||
{
|
||||
public static class FindsOccurrencesOnVariableData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 8,
|
||||
startColumnNumber: 3,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<HelpInfo xmlns="http://schemas.microsoft.com/powershell/help/2010/05">
|
||||
<HelpContentURI>https://aka.ms/powershell75-help</HelpContentURI>
|
||||
<SupportedUICultures>
|
||||
<UICulture>
|
||||
<UICultureName>en-US</UICultureName>
|
||||
<UICultureVersion>7.5.0.0</UICultureVersion>
|
||||
</UICulture>
|
||||
</SupportedUICultures>
|
||||
</HelpInfo>
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<HelpInfo xmlns="http://schemas.microsoft.com/powershell/help/2010/05">
|
||||
<HelpContentURI>https://aka.ms/powershell51-help</HelpContentURI>
|
||||
<SupportedUICultures>
|
||||
<UICulture>
|
||||
<UICultureName>en-US</UICultureName>
|
||||
<UICultureVersion>5.2.0.0</UICultureVersion>
|
||||
</UICulture>
|
||||
</SupportedUICultures>
|
||||
</HelpInfo>
|
||||
Binary file not shown.
3
test/PowerShellEditorServices.Test.Shared/PSHelp/README
Normal file
3
test/PowerShellEditorServices.Test.Shared/PSHelp/README
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Several CI platforms do not ship with PowerShell help. The build script updates help offline using this information.
|
||||
As some of the CI platforms do not have internet access.
|
||||
Linux servers use the zip file, while windows uses the cab files.
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.ParameterHint
|
||||
{
|
||||
public static class FindsParameterSetsOnCommandData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("ParameterHints/ParamHints.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 1,
|
||||
startColumnNumber: 14,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.ParameterHint
|
||||
{
|
||||
public static class FindsParameterSetsOnCommandWithSpacesData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("ParameterHints/ParamHints.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 9,
|
||||
startColumnNumber: 31,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Get-Process -
|
||||
|
||||
function Do-Stuff($things){
|
||||
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
|
||||
Write-Host ()
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), PowerShellEditorServices.Common.props))\PowerShellEditorServices.Common.props" />
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>0.9.0-beta</VersionPrefix>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<AssemblyName>Microsoft.PowerShell.EditorServices.Test.Shared</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\PowerShellEditorServices\PowerShellEditorServices.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
|
||||
<_Parameter1>Microsoft.PowerShell.EditorServices.Test</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1 @@
|
|||
Assert-ProfileLoaded
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
if (-not $PROFILE) {
|
||||
throw
|
||||
}
|
||||
|
||||
function Assert-ProfileLoaded {
|
||||
return $true
|
||||
}
|
||||
|
||||
Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -MaxTriggerCount 1 -Action { $global:handledInProfile = $true }
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
. ./SimpleFile.ps1
|
||||
|
||||
My-Function "test"
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
|
||||
{
|
||||
public static class FindsReferencesOnBuiltInCommandWithAliasData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 14,
|
||||
startColumnNumber: 3,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
|
||||
{
|
||||
public static class FindsReferencesOnFunctionData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 3,
|
||||
startColumnNumber: 8,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
|
||||
{
|
||||
public static class FindsReferencesOnTypeSymbolsData
|
||||
{
|
||||
public static readonly ScriptRegion ClassSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 8,
|
||||
startColumnNumber: 12,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion EnumSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 39,
|
||||
startColumnNumber: 8,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion ConstructorSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 9,
|
||||
startColumnNumber: 8,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion MethodSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 36,
|
||||
startColumnNumber: 16,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion PropertySourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 35,
|
||||
startColumnNumber: 12,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion EnumMemberSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 45,
|
||||
startColumnNumber: 16,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion TypeExpressionSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 34,
|
||||
startColumnNumber: 12,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
|
||||
public static readonly ScriptRegion TypeConstraintSourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/TypeAndClassesFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 25,
|
||||
startColumnNumber: 22,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
|
||||
{
|
||||
public static class FindsReferencesOnVariableData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 10,
|
||||
startColumnNumber: 17,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
function BasicFunction {}
|
||||
BasicFunction
|
||||
|
||||
function FunctionWithExtraSpace
|
||||
{
|
||||
|
||||
} FunctionWithExtraSpace
|
||||
|
||||
function
|
||||
|
||||
|
||||
FunctionNameOnDifferentLine
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{}
|
||||
|
||||
|
||||
FunctionNameOnDifferentLine
|
||||
|
||||
function IndentedFunction { } IndentedFunction
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
function My-Function ($myInput)
|
||||
{
|
||||
My-Function $myInput
|
||||
}
|
||||
|
||||
$things = 4
|
||||
|
||||
$things = 3
|
||||
|
||||
My-Function $things
|
||||
|
||||
Write-Output "Hello World";
|
||||
|
||||
Get-ChildItem
|
||||
gci
|
||||
dir
|
||||
Write-Host
|
||||
Get-ChildItem
|
||||
|
||||
My-Alias
|
||||
|
||||
Invoke-Command -ScriptBlock ${Function:My-Function}
|
||||
|
||||
[string]$hello = "test"
|
||||
Write-Host $hello
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
Get-ChildItem ./file1.ps1
|
||||
$myScriptVar = 123
|
||||
|
||||
class BaseClass {
|
||||
|
||||
}
|
||||
|
||||
class SuperClass : BaseClass {
|
||||
SuperClass([string]$name) {
|
||||
|
||||
}
|
||||
|
||||
SuperClass() { }
|
||||
|
||||
[string]$SomePropWithDefault = 'this is a default value'
|
||||
|
||||
[int]$SomeProp
|
||||
|
||||
[string]MyClassMethod([string]$param1, $param2, [int]$param3) {
|
||||
$this.SomePropWithDefault = 'something happend'
|
||||
return 'finished'
|
||||
}
|
||||
|
||||
[string]
|
||||
MyClassMethod([MyEnum]$param1) {
|
||||
return 'hello world'
|
||||
}
|
||||
[string]MyClassMethod() {
|
||||
return 'hello world'
|
||||
}
|
||||
}
|
||||
|
||||
New-Object SuperClass
|
||||
$o = [SuperClass]::new()
|
||||
$o.SomeProp
|
||||
$o.MyClassMethod()
|
||||
|
||||
|
||||
enum MyEnum {
|
||||
First
|
||||
Second
|
||||
Third
|
||||
}
|
||||
|
||||
[MyEnum]::First
|
||||
'First' -is [MyEnum]
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.SymbolDetails
|
||||
{
|
||||
public static class FindsDetailsForBuiltInCommandData
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails = new(
|
||||
file: TestUtilities.NormalizePath("SymbolDetails/SymbolDetails.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 1,
|
||||
startColumnNumber: 10,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
Expand-Archive -Path $TEMP
|
||||
# References Test uses this one
|
||||
Get-Process -Name 'powershell*'
|
||||
|
||||
<#
|
||||
.Synopsis
|
||||
Short description
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
.EXAMPLE
|
||||
Example of how to use this cmdlet
|
||||
.EXAMPLE
|
||||
Another example of how to use this cmdlet
|
||||
#>
|
||||
function Get-Thing {
|
||||
[Alias()]
|
||||
[OutputType([int])]
|
||||
Param
|
||||
(
|
||||
# Param1 help description
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
Position = 0)]
|
||||
$Name
|
||||
)
|
||||
|
||||
Begin
|
||||
{
|
||||
}
|
||||
Process
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
End
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Get-Thing -Name "test"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# This file represents a script with a DSC configuration
|
||||
configuration AConfiguration {
|
||||
Node "TEST-PC" {}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
|
||||
{
|
||||
public static class FindSymbolsInDSCFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails =
|
||||
new(
|
||||
file: TestUtilities.NormalizePath("Symbols/DSCFile.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 0,
|
||||
startColumnNumber: 0,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
|
||||
{
|
||||
public static class FindSymbolsInMultiSymbolFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails =
|
||||
new(
|
||||
file: TestUtilities.NormalizePath("Symbols/MultipleSymbols.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 0,
|
||||
startColumnNumber: 0,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
|
||||
{
|
||||
public static class FindSymbolsInNewLineSymbolFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails =
|
||||
new(
|
||||
file: TestUtilities.NormalizePath("Symbols/NewLineSymbols.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 0,
|
||||
startColumnNumber: 0,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
|
||||
{
|
||||
public static class FindSymbolsInNoSymbolsFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails =
|
||||
new(
|
||||
file: TestUtilities.NormalizePath("Symbols/NoSymbols.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 0,
|
||||
startColumnNumber: 0,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
|
||||
{
|
||||
public static class FindSymbolsInPSDFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails =
|
||||
new(
|
||||
file: TestUtilities.NormalizePath("Symbols/PowerShellDataFile.psd1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 0,
|
||||
startColumnNumber: 0,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
|
||||
{
|
||||
public static class FindSymbolsInPSKoansFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails =
|
||||
new(
|
||||
file: TestUtilities.NormalizePath("Symbols/PesterFile.Koans.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 0,
|
||||
startColumnNumber: 0,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
|
||||
{
|
||||
public static class FindSymbolsInPesterFile
|
||||
{
|
||||
public static readonly ScriptRegion SourceDetails =
|
||||
new(
|
||||
file: TestUtilities.NormalizePath("Symbols/PesterFile.tests.ps1"),
|
||||
text: string.Empty,
|
||||
startLineNumber: 0,
|
||||
startColumnNumber: 0,
|
||||
startOffset: 0,
|
||||
endLineNumber: 0,
|
||||
endColumnNumber: 0,
|
||||
endOffset: 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
$Global:GlobalVar = 0
|
||||
$UnqualifiedScriptVar = 1
|
||||
$Script:ScriptVar2 = 2
|
||||
|
||||
"`$Script:ScriptVar2 is $Script:ScriptVar2"
|
||||
|
||||
function script:AFunction {}
|
||||
|
||||
filter AFilter {$_}
|
||||
|
||||
function AnAdvancedFunction {
|
||||
begin {
|
||||
$LocalVar = 'LocalVar'
|
||||
function ANestedFunction() {
|
||||
$nestedVar = 42
|
||||
"`$nestedVar is $nestedVar"
|
||||
}
|
||||
}
|
||||
process {}
|
||||
end {}
|
||||
}
|
||||
|
||||
workflow AWorkflow {}
|
||||
|
||||
class AClass {
|
||||
[string]$AProperty
|
||||
|
||||
AClass([string]$AParameter) {
|
||||
|
||||
}
|
||||
|
||||
[void]AMethod([string]$param1, [int]$param2, $param3) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
enum AEnum {
|
||||
AValue = 0
|
||||
}
|
||||
|
||||
AFunction
|
||||
1..3 | AFilter
|
||||
AnAdvancedFunction
|
||||
|
||||
<#
|
||||
#region don't find me inside comment block
|
||||
abc
|
||||
#endregion
|
||||
#>
|
||||
|
||||
#region find me outer
|
||||
#region find me inner
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
#region ignore this unclosed region
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
function
|
||||
returnTrue {
|
||||
$true
|
||||
}
|
||||
|
||||
class
|
||||
NewLineClass {
|
||||
NewLineClass() {
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
hidden
|
||||
[string]
|
||||
$SomePropWithDefault = 'some value'
|
||||
|
||||
static
|
||||
hidden
|
||||
[string]
|
||||
MyClassMethod([MyNewLineEnum]$param1) {
|
||||
return 'hello world $param1'
|
||||
}
|
||||
}
|
||||
|
||||
enum
|
||||
MyNewLineEnum {
|
||||
First
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
# This file represents a script with no symbols
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
Describe "Testing Pester symbols in a PSKoans-file" {
|
||||
Context "Simple demo" {
|
||||
BeforeAll {
|
||||
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
|
||||
}
|
||||
|
||||
It "Should return Pester symbols" {
|
||||
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
BeforeDiscovery {
|
||||
|
||||
}
|
||||
|
||||
BeforeAll {
|
||||
|
||||
}
|
||||
|
||||
Describe "Testing Pester symbols" {
|
||||
Context "When a Pester file is given" {
|
||||
BeforeAll {
|
||||
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
|
||||
}
|
||||
|
||||
It "Should return it symbols" {
|
||||
|
||||
}
|
||||
|
||||
It "Should return context symbols" {
|
||||
|
||||
}
|
||||
|
||||
It "Should return describe symbols" {
|
||||
|
||||
}
|
||||
|
||||
It "Should return setup and teardown symbols" {
|
||||
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
@{
|
||||
property1 = "value1"
|
||||
property2 = "value2"
|
||||
property3 = "value3"
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Test.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Convenience class to simplify cross-platform testing
|
||||
/// </summary>
|
||||
public static class TestUtilities
|
||||
{
|
||||
private static readonly char[] s_unixNewlines = new[] { '\n' };
|
||||
|
||||
/// <summary>
|
||||
/// Takes a UNIX-style path and converts it to the path appropriate to the platform.
|
||||
/// </summary>
|
||||
/// <param name="unixPath">A forward-slash separated path.</param>
|
||||
/// <returns>A path with directories separated by the appropriate separator.</returns>
|
||||
public static string NormalizePath(string unixPath)
|
||||
{
|
||||
if (unixPath == null)
|
||||
{
|
||||
return unixPath;
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return unixPath.Replace('/', Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
return unixPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a normalized path from the directory of this assembly to the given path under the
|
||||
/// shared test folder.
|
||||
/// </summary>
|
||||
/// <param name="path">A path or file under the shared test folder.</param>
|
||||
/// <returns>The normalized and resolved path to it.</returns>
|
||||
public static string GetSharedPath(string path)
|
||||
{
|
||||
// TODO: When testing net462 with x64 host, another .. is needed!
|
||||
return NormalizePath(Path.Combine(
|
||||
Path.GetDirectoryName(typeof(TestUtilities).Assembly.Location),
|
||||
"../../../../PowerShellEditorServices.Test.Shared",
|
||||
path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take a string with UNIX newlines and replaces them with platform-appropriate newlines.
|
||||
/// </summary>
|
||||
/// <param name="unixString">The string with UNIX-style newlines.</param>
|
||||
/// <returns>The platform-newline-normalized string.</returns>
|
||||
public static string NormalizeNewlines(string unixString)
|
||||
{
|
||||
if (unixString == null)
|
||||
{
|
||||
return unixString;
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return string.Join(Environment.NewLine, unixString.Split(s_unixNewlines));
|
||||
}
|
||||
|
||||
return unixString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Platform-normalize a string -- takes a UNIX-style string and gives it platform-appropriate newlines and path separators.
|
||||
/// </summary>
|
||||
/// <param name="unixString">The string to normalize for the platform, given with UNIX-specific separators.</param>
|
||||
/// <returns>The same string but separated by platform-appropriate directory and newline separators.</returns>
|
||||
public static string PlatformNormalize(string unixString) => NormalizeNewlines(NormalizePath(unixString));
|
||||
|
||||
/// <summary>
|
||||
/// Not for use in production -- convenience code for debugging tests.
|
||||
/// </summary>
|
||||
public static void AwaitDebuggerHere(
|
||||
[CallerMemberName] string callerName = null,
|
||||
[CallerFilePath] string callerPath = null,
|
||||
[CallerLineNumber] int callerLine = -1)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
System.Console.WriteLine();
|
||||
System.Console.WriteLine("===== AWAITING DEBUGGER =====");
|
||||
System.Console.WriteLine($" PID: {Process.GetCurrentProcess().Id}");
|
||||
System.Console.WriteLine($" Waiting at {callerPath} line {callerLine} ({callerName})");
|
||||
System.Console.WriteLine(" PRESS ANY KEY TO CONTINUE");
|
||||
System.Console.WriteLine("=============================");
|
||||
System.Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
function Hello
|
||||
{
|
||||
"Bye"
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Write-Output "Windows won't let me put * or ? in the name of this file..."
|
||||
Loading…
Add table
Add a link
Reference in a new issue