Skip to content

Commit

Permalink
Merge pull request #51410 from dotnet/merges/master-to-master-vs-deps
Browse files Browse the repository at this point in the history
Merge master to master-vs-deps
  • Loading branch information
msftbot[bot] authored Feb 23, 2021
2 parents f266be2 + dbe9d2f commit e413580
Show file tree
Hide file tree
Showing 49 changed files with 385 additions and 248 deletions.
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/BuildValidator/Debug/netcoreapp3.1/BuildValidator.dll",
"args": [
"--assembliesPath", "./artifacts/obj/RunTests",
"--assembliesPath", "./artifacts/obj/csc/Debug/netcoreapp3.1",
"--referencesPath", "./artifacts/bin",
"--referencesPath", "C:/Program Files/dotnet/packs/Microsoft.AspNetCore.App.Ref",
"--referencesPath", "C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref",
"--debugPath", "./artifacts/BuildValidator",
"--sourcePath", "."
],
Expand Down
11 changes: 3 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ jobs:

- job: Correctness_Rebuild
pool:
vmImage: windows-2019
name: NetCorePublic-Pool
queue: BuildPool.Windows.10.Amd64.Open
timeoutInMinutes: 90
steps:
- template: eng/pipelines/checkout-windows-task.yml
Expand All @@ -226,13 +227,7 @@ jobs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLog

- task: PowerShell@2
displayName: Build
inputs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -build -bootstrap -publish -binaryLog -skipDocumentation

- script: .\artifacts\bin\BuildValidator\Debug\net472\BuildValidator.exe --assembliesPath .\artifacts\obj\Microsoft.CodeAnalysis --debugPath .\artifacts\BuildValidator --sourcePath .
- powershell: .\eng\test-rebuild.ps1 -ci
displayName: Run BuildValidator

- task: PublishBuildArtifacts@1
Expand Down
5 changes: 2 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@
<MicrosoftDiaSymReaderNativeVersion>16.9.0-beta1.21055.5</MicrosoftDiaSymReaderNativeVersion>
<MicrosoftDiaSymReaderPortablePdbVersion>1.5.0</MicrosoftDiaSymReaderPortablePdbVersion>
<MicrosoftDotNetVersionToolsVersion>3.0.0-preview1-03617-02</MicrosoftDotNetVersionToolsVersion>
<MicrosoftExtensionsDependencyInjectionVersion>2.1.1</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsLoggingVersion>2.1.1</MicrosoftExtensionsLoggingVersion>
<MicrosoftExtensionsLoggingConsoleVersion>2.1.1</MicrosoftExtensionsLoggingConsoleVersion>
<MicrosoftExtensionsLoggingVersion>5.0.0</MicrosoftExtensionsLoggingVersion>
<MicrosoftExtensionsLoggingConsoleVersion>5.0.0</MicrosoftExtensionsLoggingConsoleVersion>
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.8.27812-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>14.3.25407-alpha</MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>
Expand Down
2 changes: 1 addition & 1 deletion eng/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function Make-BootstrapBuild([switch]$force32 = $false) {

Run-MSBuild $projectPath "/restore /t:Pack /p:RoslynEnforceCodeStyle=false /p:RunAnalyzersDuringBuild=false /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP /p:PackageOutputPath=`"$dir`" /p:EnableNgenOptimization=false /p:PublishWindowsPdb=false $force32Flag" -logFileName "Bootstrap" -configuration $bootstrapConfiguration -runAnalyzers
$packageFile = Get-ChildItem -Path $dir -Filter "$packageName.*.nupkg"
Unzip (Join-Path $dir $packageFile) $dir
Unzip (Join-Path $dir $packageFile.Name) $dir

Write-Host "Cleaning Bootstrap compiler artifacts"
Run-MSBuild $projectPath "/t:Clean" -logFileName "BootstrapClean"
Expand Down
20 changes: 17 additions & 3 deletions eng/test-rebuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
param(
[string]$configuration = "Debug",
[switch]$ci = $false,
[switch]$noBuild = $false,
[switch]$help)

Set-StrictMode -version 2.0
Expand All @@ -15,6 +16,7 @@ function Print-Usage() {
Write-Host "Usage: test-rebuild.ps1"
Write-Host " -configuration Build configuration ('Debug' or 'Release')"
Write-Host " -ci Set when running on CI server"
Write-Host " -noBuild If set, skips running a bootstrap build before running the rebuild"
Write-Host " -help Print help and exit"
}

Expand All @@ -27,9 +29,21 @@ try {
. (Join-Path $PSScriptRoot "build-utils.ps1")
Push-Location $RepoRoot

Write-Host "Building Roslyn"
Exec-Console (Join-Path $PSScriptRoot "build.ps1") "-restore -build -ci:$ci -configuration:$configuration -pack -binaryLog"
Exec-Console "artifacts\bin\BuildValidator\$configuration\net472\BuildValidator.exe" "--assembliesPath '$ArtifactsDir/obj/Microsoft.CodeAnalysis'"
if (-not $noBuild) {
Write-Host "Building Roslyn"
Exec-Block { & (Join-Path $PSScriptRoot "build.ps1") -build -bootstrap -ci:$ci -configuration:$configuration -pack -binaryLog }
}

$dotnetInstallDir = (InitializeDotNetCli -install:$true)
$rebuildArgs = ("--verbose" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis/$configuration`"" +
" --assembliesPath $ArtifactsDir/obj/csc/$configuration/netcoreapp3.1" +
" --debugPath `"$ArtifactsDir/BuildValidator`"" +
" --sourcePath `"$RepoRoot`"" +
" --referencesPath `"$ArtifactsDir/bin`"" +
" --referencesPath `"$dotnetInstallDir/packs/Microsoft.AspNetCore.App.Ref`"" +
" --referencesPath `"$dotnetInstallDir/packs/Microsoft.NETCore.App.Ref`"")
Exec-Console "$ArtifactsDir/bin/BuildValidator/$configuration/net472/BuildValidator.exe" $rebuildArgs

exit 0
}
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/csc/csc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ServerGarbageCollection>true</ServerGarbageCollection>
<UseAppHost>false</UseAppHost>
<GenerateMicrosoftCodeAnalysisCommitHashAttribute>true</GenerateMicrosoftCodeAnalysisCommitHashAttribute>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Core\Portable\Microsoft.CodeAnalysis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ public class ExtensionMethodImportCompletionProviderTests : AbstractCSharpComple

private bool HideAdvancedMembers { get; set; }

private bool UsePartialSemantic { get; set; } = false;

protected override OptionSet WithChangedOptions(OptionSet options)
{
return options
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, ShowImportCompletionItemsOptionValue)
.WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, IsExpandedCompletion)
.WithChangedOption(CompletionOptions.HideAdvancedMembers, LanguageNames.CSharp, HideAdvancedMembers)
.WithChangedOption(CompletionServiceOptions.TimeoutInMillisecondsForExtensionMethodImportCompletion, TimeoutInMilliseconds);
.WithChangedOption(CompletionServiceOptions.TimeoutInMillisecondsForExtensionMethodImportCompletion, TimeoutInMilliseconds)
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForImportCompletion, UsePartialSemantic);
}

protected override TestComposition GetComposition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ internal override Type GetCompletionProviderType()

private bool HideAdvancedMembers { get; set; }

private bool UsePartialSemantic { get; set; } = false;

protected override OptionSet WithChangedOptions(OptionSet options)
{
return options
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, ShowImportCompletionItemsOptionValue)
.WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, IsExpandedCompletion)
.WithChangedOption(CompletionServiceOptions.DisallowAddingImports, DisallowAddingImports)
.WithChangedOption(CompletionOptions.HideAdvancedMembers, LanguageNames.CSharp, HideAdvancedMembers);
.WithChangedOption(CompletionOptions.HideAdvancedMembers, LanguageNames.CSharp, HideAdvancedMembers)
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForImportCompletion, UsePartialSemantic);
}

protected override TestComposition GetComposition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,14 @@ public Task<bool> WriteStreamAsync(Document document, string name, Stream stream
return SpecializedTasks.True;
}

public virtual void Dispose()
public void Dispose()
{
}

public ValueTask DisposeAsync()
{
return ValueTaskFactory.CompletedTask;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/EditorFeatures/Test/Preview/PreviewWorkspaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public async Task TestPreviewServices()

var persistentService = previewWorkspace.Services.GetRequiredService<IPersistentStorageService>();

using var storage = await persistentService.GetStorageAsync(previewWorkspace.CurrentSolution, CancellationToken.None);
await using var storage = await persistentService.GetStorageAsync(previewWorkspace.CurrentSolution, CancellationToken.None);
Assert.IsType<NoOpPersistentStorage>(storage);
}

Expand Down
13 changes: 0 additions & 13 deletions src/EditorFeatures/Text/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,6 @@ public static IEnumerable<Document> GetRelatedDocumentsWithChanges(this ITextSna
public static IEnumerable<Document> GetRelatedDocuments(this ITextBuffer buffer)
=> buffer.AsTextContainer().GetRelatedDocuments();

/// <summary>
/// Tries to get the document corresponding to the text from the current partial solution
/// associated with the text's container. If the document does not contain the exact text a document
/// from a new solution containing the specified text is constructed. If no document is associated
/// with the specified text's container, or the text's container isn't associated with a workspace,
/// then the method returns false.
/// </summary>
internal static Document? GetDocumentWithFrozenPartialSemantics(this SourceText text, CancellationToken cancellationToken)
{
var document = text.GetOpenDocumentInCurrentContextWithChanges();
return document?.WithFrozenPartialSemantics(cancellationToken);
}

internal static bool CanApplyChangeDocumentToWorkspace(this ITextBuffer buffer)
=> Workspace.TryGetWorkspace(buffer.AsTextContainer(), out var workspace) &&
workspace.CanApplyChange(ApplyChangesKind.ChangeDocument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
Private Property TimeoutInMilliseconds As Integer = -1

Private Property ShowImportCompletionItemsOptionValue As Boolean = True
Private Property UsePartialSemantic As Boolean = False

Protected Overrides Function WithChangedOptions(options As OptionSet) As OptionSet
Return options _
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.VisualBasic, ShowImportCompletionItemsOptionValue) _
.WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, IsExpandedCompletion) _
.WithChangedOption(CompletionServiceOptions.TimeoutInMillisecondsForExtensionMethodImportCompletion, TimeoutInMilliseconds)
.WithChangedOption(CompletionServiceOptions.TimeoutInMillisecondsForExtensionMethodImportCompletion, TimeoutInMilliseconds) _
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForImportCompletion, UsePartialSemantic)
End Function

Protected Overrides Function GetComposition() As TestComposition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
Private Property ShowImportCompletionItemsOptionValue As Boolean = True

Private Property IsExpandedCompletion As Boolean = True
Private Property UsePartialSemantic As Boolean = False

Protected Overrides Function WithChangedOptions(options As OptionSet) As OptionSet
Return options _
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.VisualBasic, ShowImportCompletionItemsOptionValue) _
.WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, IsExpandedCompletion)
.WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, IsExpandedCompletion) _
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForImportCompletion, UsePartialSemantic)
End Function

Protected Overrides Function GetComposition() As TestComposition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ protected override ImmutableArray<string> GetImportedNamespaces(
CancellationToken cancellationToken)
=> ImportCompletionProviderHelper.GetImportedNamespaces(location, semanticModel);

protected override Task<SyntaxContext> CreateContextAsync(Document document, int position, CancellationToken cancellationToken)
=> ImportCompletionProviderHelper.CreateContextAsync(document, position, cancellationToken);
protected override Task<SyntaxContext> CreateContextAsync(Document document, int position, bool usePartialSemantic, CancellationToken cancellationToken)
=> ImportCompletionProviderHelper.CreateContextAsync(document, position, usePartialSemantic, cancellationToken);

protected override bool IsFinalSemicolonOfUsingOrExtern(SyntaxNode directive, SyntaxToken token)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ public static ImmutableArray<string> GetImportedNamespaces(
=> semanticModel.GetUsingNamespacesInScope(location)
.SelectAsArray(namespaceSymbol => namespaceSymbol.ToDisplayString(SymbolDisplayFormats.NameFormat));

public static async Task<SyntaxContext> CreateContextAsync(Document document, int position, CancellationToken cancellationToken)
public static async Task<SyntaxContext> CreateContextAsync(Document document, int position, bool usePartialSemantic, CancellationToken cancellationToken)
{
// Need regular semantic model because we will use it to get imported namespace symbols. Otherwise we will try to
// reach outside of the span and ended up with "node not within syntax tree" error from the speculative model.
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
// Also we use partial model unless full model is explictly request (e.g. in tests) so that we don't have to wait for all semantics to be computed.
var semanticModel = usePartialSemantic
? await document.GetPartialSemanticModelAsync(cancellationToken).ConfigureAwait(false)
: await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
Contract.ThrowIfNull(semanticModel);
return CSharpSyntaxContext.CreateContext(document.Project.Solution.Workspace, semanticModel, position, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected override ImmutableArray<string> GetImportedNamespaces(
CancellationToken cancellationToken)
=> ImportCompletionProviderHelper.GetImportedNamespaces(location, semanticModel);

protected override Task<SyntaxContext> CreateContextAsync(Document document, int position, CancellationToken cancellationToken)
=> ImportCompletionProviderHelper.CreateContextAsync(document, position, cancellationToken);
protected override Task<SyntaxContext> CreateContextAsync(Document document, int position, bool usePartialSemantic, CancellationToken cancellationToken)
=> ImportCompletionProviderHelper.CreateContextAsync(document, position, usePartialSemantic, cancellationToken);

protected override bool IsFinalSemicolonOfUsingOrExtern(SyntaxNode directive, SyntaxToken token)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ internal static class CompletionServiceOptions
public static readonly Option2<bool> IsExpandedCompletion
= new(nameof(CompletionServiceOptions), nameof(IsExpandedCompletion), defaultValue: false);

/// <summary>
/// For testing only. Changing the default value in actual product might cause perf issues.
/// </summary>
public static readonly Option2<bool> UsePartialSemanticForImportCompletion
= new(nameof(CompletionServiceOptions), nameof(UsePartialSemanticForImportCompletion), defaultValue: true);

/// <summary>
/// Indicates if the completion should be disallowed to add imports.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.CodeAnalysis.Completion.Providers
{
internal abstract class AbstractImportCompletionProvider : LSPCompletionProvider
{
protected abstract Task<SyntaxContext> CreateContextAsync(Document document, int position, CancellationToken cancellationToken);
protected abstract Task<SyntaxContext> CreateContextAsync(Document document, int position, bool usePartialSemantic, CancellationToken cancellationToken);
protected abstract ImmutableArray<string> GetImportedNamespaces(SyntaxNode location, SemanticModel semanticModel, CancellationToken cancellationToken);
protected abstract bool ShouldProvideCompletion(CompletionContext completionContext, SyntaxContext syntaxContext);
protected abstract Task AddCompletionItemsAsync(CompletionContext completionContext, SyntaxContext syntaxContext, HashSet<string> namespacesInScope, bool isExpandedCompletion, CancellationToken cancellationToken);
Expand Down Expand Up @@ -54,7 +54,8 @@ public override async Task ProvideCompletionsAsync(CompletionContext completionC

// We need to check for context before option values, so we can tell completion service that we are in a context to provide expanded items
// even though import completion might be disabled. This would show the expander in completion list which user can then use to explicitly ask for unimported items.
var syntaxContext = await CreateContextAsync(document, completionContext.Position, cancellationToken).ConfigureAwait(false);
var usePartialSemantic = completionContext.Options.GetOption(CompletionServiceOptions.UsePartialSemanticForImportCompletion);
var syntaxContext = await CreateContextAsync(document, completionContext.Position, usePartialSemantic, cancellationToken).ConfigureAwait(false);
if (!ShouldProvideCompletion(completionContext, syntaxContext))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public async Task<TData> TryGetExistingDataAsync(TValue value, CancellationToken

try
{
using var storage = await persistService.GetStorageAsync(solution, cancellationToken).ConfigureAwait(false);
var storage = await persistService.GetStorageAsync(solution, cancellationToken).ConfigureAwait(false);
await using var _ = storage.ConfigureAwait(false);
using var stream = await ReadStreamAsync(storage, value, cancellationToken).ConfigureAwait(false);

if (stream != null)
Expand Down Expand Up @@ -102,7 +103,8 @@ private async Task<bool> WriteToStreamAsync(TValue value, TData data, Cancellati
var solution = GetSolution(value);
var persistService = solution.Workspace.Services.GetService<IPersistentStorageService>();

using var storage = await persistService.GetStorageAsync(solution, cancellationToken).ConfigureAwait(false);
var storage = await persistService.GetStorageAsync(solution, cancellationToken).ConfigureAwait(false);
await using var _ = storage.ConfigureAwait(false);
stream.Position = 0;
return await WriteStreamAsync(storage, value, stream, cancellationToken).ConfigureAwait(false);
}
Expand Down
Loading

0 comments on commit e413580

Please sign in to comment.