public IImmutableDictionary <IBuildRequest, Task <BuildResult> > Build(IImmutableSet <IBuildRequest> buildRequests) { if (buildRequests.Count == 1 && buildRequests.First().BuildRequestData.TargetNames.Contains("Build")) { var result = BuildProjectAsync(buildRequests.First().CancellationToken); return(ImmutableDictionary.Create <IBuildRequest, Task <BuildResult> >().Add(buildRequests.First(), result)); } return(m_solutionBuildManagerHost.Value.Build(buildRequests)); }
protected async Task<ImmutableArray<Document>> FindDocumentsAsync(Project project, IImmutableSet<Document> scope, Func<Document, CancellationToken, Task<bool>> predicateAsync, CancellationToken cancellationToken) { // special case for HR if (scope != null && scope.Count == 1) { var document = scope.First(); if (document.Project == project) { return scope.ToImmutableArray(); } return ImmutableArray<Document>.Empty; } var documents = ArrayBuilder<Document>.GetInstance(); foreach (var document in project.Documents) { if (scope != null && !scope.Contains(document)) { continue; } if (await predicateAsync(document, cancellationToken).ConfigureAwait(false)) { documents.Add(document); } } return documents.ToImmutableAndFree(); }
private void Register() { var actorSelections = CoordinatorSelection; foreach (var coordinator in actorSelections) { coordinator.Tell(RegistrationMessage); } if (ShardBuffers.Count != 0 && _retryCount >= RetryCountThreshold) { if (actorSelections.Count > 0) { var coordinatorMessage = Cluster.State.Unreachable.Contains(MembersByAge.First()) ? $"Coordinator [{MembersByAge.First()}] is unreachable." : $"Coordinator [{MembersByAge.First()}] is reachable."; Log.Warning("Trying to register to coordinator at [{0}], but no acknowledgement. Total [{1}] buffered messages. [{2}]", string.Join(", ", actorSelections.Select(i => i.PathString)), TotalBufferSize, coordinatorMessage); } else { // Members start off as "Removed" var partOfCluster = Cluster.SelfMember.Status != MemberStatus.Removed; var possibleReason = partOfCluster ? "Has Cluster Sharding been started on every node and nodes been configured with the correct role(s)?" : "Probably, no seed-nodes configured and manual cluster join not performed?"; Log.Warning("No coordinator found to register. {0} Total [{1}] buffered messages.", possibleReason, TotalBufferSize); } } }
protected async Task <ImmutableArray <Document> > FindDocumentsAsync(Project project, IImmutableSet <Document> scope, Func <Document, CancellationToken, Task <bool> > predicateAsync, CancellationToken cancellationToken) { // special case for HR if (scope != null && scope.Count == 1) { var document = scope.First(); if (document.Project == project) { return(scope.ToImmutableArray()); } return(ImmutableArray <Document> .Empty); } var documents = ArrayBuilder <Document> .GetInstance(); foreach (var document in project.Documents) { if (scope != null && !scope.Contains(document)) { continue; } if (await predicateAsync(document, cancellationToken).ConfigureAwait(false)) { documents.Add(document); } } return(documents.ToImmutableAndFree()); }
public static string GetSingleNodePath(this IImmutableSet <IProjectTree> nodes) { if (nodes != null && nodes.Count == 1) { return(nodes.First().FilePath); } return(string.Empty); }
public static bool IsFolder(this IImmutableSet <IProjectTree> nodes) { if (nodes != null && nodes.Count == 1) { return(nodes.First().IsFolder); } return(false); }
protected override sealed Task <bool> TryHandleCommandAsync(IImmutableSet <IProjectTree> nodes, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut) { if (nodes.Count == 1) { return(TryHandleCommandAsync(nodes.First(), focused, commandExecuteOptions, variantArgIn, variantArgOut)); } return(TaskResult.False); }
protected override sealed Task <CommandStatusResult> GetCommandStatusAsync(IImmutableSet <IProjectTree> nodes, bool focused, string commandText, CommandStatus progressiveStatus) { if (nodes.Count == 1) { return(GetCommandStatusAsync(nodes.First(), focused, commandText, progressiveStatus)); } return(GetCommandStatusResult.Unhandled); }
public Task <CommandStatusResult> GetCommandStatusAsync(IImmutableSet <IProjectTree> nodes, long commandId, bool focused, string?commandText, CommandStatus progressiveStatus) { Requires.NotNull(nodes, nameof(nodes)); if (nodes.Count == 1 && _addItemDialogService.CanAddNewOrExistingItemTo(nodes.First()) && TryGetTemplateDetails(commandId, out _)) { return(GetCommandStatusResult.Handled(commandText, CommandStatus.Enabled)); } return(GetCommandStatusResult.Unhandled); }
public async Task <bool> TryHandleCommandAsync(IImmutableSet <IProjectTree> nodes, long commandId, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut) { Requires.NotNull(nodes, nameof(nodes)); if (nodes.Count == 1 && _addItemDialogService.CanAddNewOrExistingItemTo(nodes.First()) && TryGetTemplateDetails(commandId, out TemplateDetails? result)) { // Look up the resources from each package to get the strings to pass to the Add Item dialog. // These strings must match what is used in the template exactly, including localized versions. Rather than relying on // our localizations being the same as the VS repository localizations we just load the right strings using the same // resource IDs as the templates themselves use. string localizedDirectoryName = _vsShell.Value !.LoadPackageString(result.DirNamePackageGuid, result.DirNameResourceId); string localizedTemplateName = _vsShell.Value !.LoadPackageString(result.TemplateNamePackageGuid, result.TemplateNameResourceId); await _addItemDialogService.ShowAddNewItemDialogAsync(nodes.First(), localizedDirectoryName, localizedTemplateName); return(true); } return(false); }
public async Task <bool> TryHandleCommandAsync(IImmutableSet <IProjectTree> nodes, long commandId, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut) { Requires.NotNull(nodes, nameof(nodes)); // We only support single node selections if (nodes.Count != 1) { return(false); } IProjectTree node = nodes.First(); // We only support nodes that can actually have things added to it if (!_projectTree.NodeCanHaveAdditions(node)) { return(false); } if (TryGetTemplateDetails(commandId, out TemplateDetails result)) { __VSADDITEMFLAGS uiFlags = __VSADDITEMFLAGS.VSADDITEM_AddNewItems | __VSADDITEMFLAGS.VSADDITEM_SuggestTemplateName | __VSADDITEMFLAGS.VSADDITEM_AllowHiddenTreeView; string strBrowseLocations = _projectTree.TreeProvider.GetAddNewItemDirectory(node); await _projectVsServices.ThreadingService.SwitchToUIThread(); // Look up the resources from each package to get the strings to pass to the Add Item dialog. // These strings must match what is used in the template exactly, including localized versions. Rather than relying on // our localizations being the same as the VS repository localizations we just load the right strings using the same // resource IDs as the templates themselves use. string dirName = _vsShell.Value.LoadPackageString(result.DirNamePackageGuid, result.DirNameResourceId); string templateName = _vsShell.Value.LoadPackageString(result.TemplateNamePackageGuid, result.TemplateNameResourceId); string strFilter = string.Empty; Guid addItemTemplateGuid = Guid.Empty; // Let the dialog ask the hierarchy itself HResult res = _addItemDialog.Value.AddProjectItemDlg(node.GetHierarchyId(), ref addItemTemplateGuid, _projectVsServices.VsProject, (uint)uiFlags, dirName, templateName, ref strBrowseLocations, ref strFilter, out _); // Return true here regardless of whether or not the user clicked OK or they clicked Cancel. This ensures that some other // handler isn't called after we run. return(res == HResult.OK || res == HResult.Ole.PromptSaveCancelled); } return(false); }
public Task <CommandStatusResult> GetCommandStatusAsync(IImmutableSet <IProjectTree> nodes, long commandId, bool focused, string commandText, CommandStatus progressiveStatus) { Requires.NotNull(nodes, nameof(nodes)); if (nodes.Count == 1 && _projectTree.NodeCanHaveAdditions(nodes.First()) && TryGetTemplateDetails(commandId, out _)) { return(GetCommandStatusResult.Handled(commandText, CommandStatus.Enabled)); } return(GetCommandStatusResult.Unhandled); }
public static string GetSelectedFolderPath(this IImmutableSet <IProjectTree> nodes, UnconfiguredProject unconfiguredProject) { if (nodes.Count == 1) { var n = nodes.First(); if (n.IsRoot()) { return(Path.GetDirectoryName(unconfiguredProject.FullPath)); } return(nodes.GetNodeFolderPath()); } return(string.Empty); }
public Task HintedAsync(IImmutableDictionary <Guid, IImmutableSet <IProjectChangeHint> > hints) { IImmutableSet <IProjectChangeHint> files = hints[ProjectChangeFileSystemEntityRenameHint.RenamedFile]; if (files.Count == 1) { var hint = (IProjectChangeFileRenameHint)files.First(); if (!hint.ChangeAlreadyOccurred) { KeyValuePair <string, string> kvp = hint.RenamedFiles.First(); ScheduleRename(kvp.Key, kvp.Value); } } return(Task.CompletedTask); }
private void Register() { var coordinator = CoordinatorSelection; coordinator?.Tell(RegistrationMessage); if (ShardBuffers.Count != 0 && _retryCount >= RetryCountThreshold) { if (coordinator != null) { var coordinatorMessage = Cluster.State.Unreachable.Contains(MembersByAge.First()) ? $"Coordinator [{MembersByAge.First()}] is unreachable." : $"Coordinator [{MembersByAge.First()}] is reachable."; Log.Warning("Trying to register to coordinator at [{0}], but no acknowledgement. Total [{1}] buffered messages. [{2}]", coordinator != null ? coordinator.PathString : string.Empty, TotalBufferSize, coordinatorMessage); } else { Log.Warning("No coordinator found to register. Probably, no seed-nodes configured and manual cluster join not performed? Total [{0}] buffered messages.", TotalBufferSize); } } }
public Task <CommandStatusResult> GetCommandStatusAsync( IImmutableSet <IProjectTree> nodes, long commandId, bool focused, string commandText, CommandStatus progressiveStatus) { var node = nodes.First(); if (node.IsRoot() && commandId == BootableProjectSystemPackage.PublishBootableProjectContextMenuCmdId) { return(Task.FromResult( new CommandStatusResult(true, "Publish OS", CommandStatus.Supported | CommandStatus.Enabled))); } else { return(Task.FromResult( new CommandStatusResult(false, commandText, progressiveStatus))); } }
protected async Task <IEnumerable <Document> > FindDocumentsAsync(Project project, IImmutableSet <Document> scope, Func <Document, CancellationToken, Task <bool> > predicateAsync, CancellationToken cancellationToken) { // special case for HR if (scope != null && scope.Count == 1) { var document = scope.First(); if (document.Project == project) { return(scope); } return(SpecializedCollections.EmptyEnumerable <Document>()); } List <Document> documents = null; foreach (var document in project.Documents) { if (scope != null && !scope.Contains(document)) { continue; } if (await predicateAsync(document, cancellationToken).ConfigureAwait(false)) { documents = documents ?? new List <Document>(); documents.Add(document); } } if (documents == null) { return(SpecializedCollections.EmptyEnumerable <Document>()); } else { return(documents); } }
public static bool IsProjectSelected(this IImmutableSet <IProjectTree> nodes) { return(nodes != null && nodes.Count == 1 && nodes.First().Root == nodes.First()); }
public void Verify() { Assert.Equal((short)1, MyInt16); Assert.Equal((int)2, MyInt32); Assert.Equal((long)3, MyInt64); Assert.Equal((ushort)4, MyUInt16); Assert.Equal((uint)5, MyUInt32); Assert.Equal((ulong)6, MyUInt64); Assert.Equal((byte)7, MyByte); Assert.Equal((sbyte)8, MySByte); Assert.Equal('a', MyChar); Assert.Equal("Hello", MyString); Assert.Equal(3.3m, MyDecimal); Assert.False(MyBooleanFalse); Assert.True(MyBooleanTrue); Assert.Equal(1.1f, MySingle); Assert.Equal(2.2d, MyDouble); Assert.Equal(new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc), MyDateTime); Assert.Equal(new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0)), MyDateTimeOffset); Assert.Equal(new Guid("1B33498A-7B7D-4DDA-9C13-F6AA4AB449A6"), MyGuid); Assert.Equal(new Uri("https://github.com/dotnet/runtime"), MyUri); Assert.Equal(SampleEnum.Two, MyEnum); Assert.Equal(SampleEnumInt64.MinNegative, MyInt64Enum); Assert.Equal(SampleEnumUInt64.Max, MyUInt64Enum); Assert.Equal(11, MySimpleStruct.One); Assert.Equal(1.9999, MySimpleStruct.Two); Assert.Equal(64, MySimpleTestStruct.MyInt64); Assert.Equal("Hello", MySimpleTestStruct.MyString); Assert.Equal(32, MySimpleTestStruct.MyInt32Array[0]); Assert.Equal((short)1, MyInt16Array[0]); Assert.Equal((int)2, MyInt32Array[0]); Assert.Equal((long)3, MyInt64Array[0]); Assert.Equal((ushort)4, MyUInt16Array[0]); Assert.Equal((uint)5, MyUInt32Array[0]); Assert.Equal((ulong)6, MyUInt64Array[0]); Assert.Equal((byte)7, MyByteArray[0]); Assert.Equal((sbyte)8, MySByteArray[0]); Assert.Equal('a', MyCharArray[0]); Assert.Equal("Hello", MyStringArray[0]); Assert.Equal(3.3m, MyDecimalArray[0]); Assert.False(MyBooleanFalseArray[0]); Assert.True(MyBooleanTrueArray[0]); Assert.Equal(1.1f, MySingleArray[0]); Assert.Equal(2.2d, MyDoubleArray[0]); Assert.Equal(new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc), MyDateTimeArray[0]); Assert.Equal(new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0)), MyDateTimeOffsetArray[0]); Assert.Equal(new Guid("1B33498A-7B7D-4DDA-9C13-F6AA4AB449A6"), MyGuidArray[0]); Assert.Equal(new Uri("https://github.com/dotnet/runtime"), MyUriArray[0]); Assert.Equal(SampleEnum.Two, MyEnumArray[0]); Assert.Equal(10, MyInt16TwoDimensionArray[0][0]); Assert.Equal(11, MyInt16TwoDimensionArray[0][1]); Assert.Equal(20, MyInt16TwoDimensionArray[1][0]); Assert.Equal(21, MyInt16TwoDimensionArray[1][1]); Assert.Equal(10, MyInt16TwoDimensionList[0][0]); Assert.Equal(11, MyInt16TwoDimensionList[0][1]); Assert.Equal(20, MyInt16TwoDimensionList[1][0]); Assert.Equal(21, MyInt16TwoDimensionList[1][1]); Assert.Equal(11, MyInt16ThreeDimensionArray[0][0][0]); Assert.Equal(12, MyInt16ThreeDimensionArray[0][0][1]); Assert.Equal(13, MyInt16ThreeDimensionArray[0][1][0]); Assert.Equal(14, MyInt16ThreeDimensionArray[0][1][1]); Assert.Equal(21, MyInt16ThreeDimensionArray[1][0][0]); Assert.Equal(22, MyInt16ThreeDimensionArray[1][0][1]); Assert.Equal(23, MyInt16ThreeDimensionArray[1][1][0]); Assert.Equal(24, MyInt16ThreeDimensionArray[1][1][1]); Assert.Equal(11, MyInt16ThreeDimensionList[0][0][0]); Assert.Equal(12, MyInt16ThreeDimensionList[0][0][1]); Assert.Equal(13, MyInt16ThreeDimensionList[0][1][0]); Assert.Equal(14, MyInt16ThreeDimensionList[0][1][1]); Assert.Equal(21, MyInt16ThreeDimensionList[1][0][0]); Assert.Equal(22, MyInt16ThreeDimensionList[1][0][1]); Assert.Equal(23, MyInt16ThreeDimensionList[1][1][0]); Assert.Equal(24, MyInt16ThreeDimensionList[1][1][1]); Assert.Equal("Hello", MyStringList[0]); IEnumerator enumerator = MyStringIEnumerable.GetEnumerator(); enumerator.MoveNext(); { // Verifying after deserialization. if (enumerator.Current is JsonElement currentJsonElement) { Assert.Equal("Hello", currentJsonElement.GetString()); } // Verifying test data. else { Assert.Equal("Hello", enumerator.Current); } } { // Verifying after deserialization. if (MyStringIList[0] is JsonElement currentJsonElement) { Assert.Equal("Hello", currentJsonElement.GetString()); } // Verifying test data. else { Assert.Equal("Hello", enumerator.Current); } } enumerator = MyStringICollection.GetEnumerator(); enumerator.MoveNext(); { // Verifying after deserialization. if (enumerator.Current is JsonElement currentJsonElement) { Assert.Equal("Hello", currentJsonElement.GetString()); } // Verifying test data. else { Assert.Equal("Hello", enumerator.Current); } } Assert.Equal("Hello", MyStringIEnumerableT.First()); Assert.Equal("Hello", MyStringIListT[0]); Assert.Equal("Hello", MyStringICollectionT.First()); Assert.Equal("Hello", MyStringIReadOnlyCollectionT.First()); Assert.Equal("Hello", MyStringIReadOnlyListT[0]); Assert.Equal("Hello", MyStringISetT.First()); enumerator = MyStringToStringIDict.GetEnumerator(); enumerator.MoveNext(); { // Verifying after deserialization. if (enumerator.Current is JsonElement currentJsonElement) { IEnumerator jsonEnumerator = currentJsonElement.EnumerateObject(); jsonEnumerator.MoveNext(); JsonProperty property = (JsonProperty)jsonEnumerator.Current; Assert.Equal("key", property.Name); Assert.Equal("value", property.Value.GetString()); } // Verifying test data. else { DictionaryEntry entry = (DictionaryEntry)enumerator.Current; Assert.Equal("key", entry.Key); if (entry.Value is JsonElement element) { Assert.Equal("value", element.GetString()); } else { Assert.Equal("value", entry.Value); } } } Assert.Equal("value", MyStringToStringGenericDict["key"]); Assert.Equal("value", MyStringToStringGenericIDict["key"]); Assert.Equal("value", MyStringToStringGenericIReadOnlyDict["key"]); Assert.Equal("value", MyStringToStringImmutableDict["key"]); Assert.Equal("value", MyStringToStringIImmutableDict["key"]); Assert.Equal("value", MyStringToStringImmutableSortedDict["key"]); Assert.Equal("myKey", MyStringToStringKeyValuePair.Key); Assert.Equal("myValue", MyStringToStringKeyValuePair.Value); Assert.Equal(2, MyStringStackT.Count); Assert.True(MyStringStackT.Contains("Hello")); Assert.True(MyStringStackT.Contains("World")); string[] expectedQueue = { "Hello", "World" }; int i = 0; foreach (string item in MyStringQueueT) { Assert.Equal(expectedQueue[i], item); i++; } Assert.Equal("Hello", MyStringHashSetT.First()); Assert.Equal("Hello", MyStringLinkedListT.First()); Assert.Equal("Hello", MyStringSortedSetT.First()); Assert.Equal("Hello", MyStringIImmutableListT[0]); Assert.Equal("Hello", MyStringIImmutableStackT.First()); Assert.Equal("Hello", MyStringIImmutableQueueT.First()); Assert.Equal("Hello", MyStringIImmutableSetT.First()); Assert.Equal("Hello", MyStringImmutableHashSetT.First()); Assert.Equal("Hello", MyStringImmutableListT[0]); Assert.Equal("Hello", MyStringImmutableStackT.First()); Assert.Equal("Hello", MyStringImmutablQueueT.First()); Assert.Equal("Hello", MyStringImmutableSortedSetT.First()); Assert.Null(MyListOfNullString[0]); }