示例#1
0
            /// <summary>
            /// Searches for extension methods exactly called 'Deconstruct'.  Returns
            /// <see cref="SymbolReference"/>s to the <see cref="INamespaceSymbol"/>s that contain
            /// the static classes that those extension methods are contained in.
            /// </summary>
            private async Task <ImmutableArray <SymbolReference> > GetReferencesForDeconstructAsync(SearchScope searchScope)
            {
                searchScope.CancellationToken.ThrowIfCancellationRequested();

                if (_owner.CanAddImportForDeconstruct(_diagnosticId, _node))
                {
                    var type = _owner.GetDeconstructInfo(_semanticModel, _node, searchScope.CancellationToken);
                    if (type != null)
                    {
                        // Note: we could check that the extension methods have the right number of out-params.
                        // But that would involve figuring out what we're trying to deconstruct into.  For now
                        // we'll just be permissive, with the assumption that there won't be that many matching
                        // 'Deconstruct' extension methods for the type of node that we're on.
                        return(await GetReferencesForExtensionMethodAsync(
                                   searchScope, "Deconstruct", type,
                                   m => m.ReturnsVoid).ConfigureAwait(false));
                    }
                }

                return(ImmutableArray <SymbolReference> .Empty);
            }