Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DocumentationCommentId.GetSymbolsForDeclarationId does not work for local functions, even though CreateDeclarationId does #49692

Open
svick opened this issue Dec 1, 2020 · 2 comments
Assignees
Milestone

Comments

@svick
Copy link
Contributor

svick commented Dec 1, 2020

Version Used: master

Steps to Reproduce:

Execute the following test:

[Fact]
public void LocalFunction()
{
    string code = @"
class C
{
    void M() { void Local() {} }
}";

    var comp = CreateCompilation(code);

    var tree = comp.SyntaxTrees.Single();
    var syntax = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
    var symbol = comp.GetSemanticModel(tree).GetDeclaredSymbol(syntax)!;

    var actualDocId = DocumentationCommentId.CreateDeclarationId(symbol);

    string expectedDocId = "M:C.M.Local";

    Assert.Equal(expectedDocId, actualDocId);

    var foundSymbols = DocumentationCommentId.GetSymbolsForDeclarationId(expectedDocId, comp);

    Assert.Equal(new[] { symbol }, foundSymbols);
}

Actual Behavior:

The second asert fails, because GetSymbolsForDeclarationId returns an empty collection.

Expected Behavior:

The whole test succeeds. Or possibly the first Assert does not succeed, if local functions are not supported in documentation comment IDs.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 1, 2020
@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 7, 2020
@jaredpar jaredpar added this to the Compiler.Next milestone Dec 7, 2020
@RikkiGibson
Copy link
Contributor

At a glance it seems like you should not be able to create a declaration id for a local function.

@Youssef1313
Copy link
Member

Related to: dotnet/csharplang#2110

@jaredpar jaredpar modified the milestones: Compiler.Next, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants