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

Change IEnumerable to ImmutableArray #50323

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt
Expand Up @@ -5,9 +5,9 @@ Microsoft.CodeAnalysis.CodeFixes.FixAllContext.WithDocument(Microsoft.CodeAnalys
Microsoft.CodeAnalysis.CodeFixes.FixAllContext.WithProject(Microsoft.CodeAnalysis.Project project) -> Microsoft.CodeAnalysis.CodeFixes.FixAllContext
Microsoft.CodeAnalysis.CodeFixes.FixAllContext.WithScope(Microsoft.CodeAnalysis.CodeFixes.FixAllScope scope) -> Microsoft.CodeAnalysis.CodeFixes.FixAllContext
Microsoft.CodeAnalysis.Project.GetSourceGeneratedDocumentAsync(Microsoft.CodeAnalysis.DocumentId documentId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.CodeAnalysis.SourceGeneratedDocument>
Microsoft.CodeAnalysis.Project.GetSourceGeneratedDocumentsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SourceGeneratedDocument>>
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.RecordName = "record name" -> string
Microsoft.CodeAnalysis.Editing.DeclarationKind.Record = 29 -> Microsoft.CodeAnalysis.Editing.DeclarationKind
Microsoft.CodeAnalysis.Project.GetSourceGeneratedDocumentsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SourceGeneratedDocument>>
Microsoft.CodeAnalysis.Solution.GetSourceGeneratedDocumentAsync(Microsoft.CodeAnalysis.DocumentId documentId, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<Microsoft.CodeAnalysis.SourceGeneratedDocument>
Microsoft.CodeAnalysis.SourceGeneratedDocument
Microsoft.CodeAnalysis.SourceGeneratedDocument.HintName.get -> string
Expand Down
6 changes: 5 additions & 1 deletion src/Workspaces/Core/Portable/Workspace/Solution/Project.cs
Expand Up @@ -256,7 +256,11 @@ public bool ContainsAnalyzerConfigDocument(DocumentId documentId)

return ImmutableHashMapExtensions.GetOrAdd(ref _idToAnalyzerConfigDocumentMap, documentId, s_createAnalyzerConfigDocumentFunction, this);
}
public async ValueTask<IEnumerable<SourceGeneratedDocument>> GetSourceGeneratedDocumentsAsync(CancellationToken cancellationToken = default)

/// <summary>
/// Gets all source generated documents in this project.
/// </summary>
public async ValueTask<ImmutableArray<SourceGeneratedDocument>> GetSourceGeneratedDocumentsAsync(CancellationToken cancellationToken = default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an interface to return that is immutable but not directly ImmutableArray? I worry if we end up with projects with thousands of generated files whether the larger arrays will cause issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and yes the implementation would need some tweaking in that case, but at least we're not locked in with the current signature)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean we would not want to instantiate all of the SourceGeneratedDocuments?

{
var generatedDocumentStates = await _solution.State.GetSourceGeneratedDocumentStatesAsync(this.State, cancellationToken).ConfigureAwait(false);
using var _ = ArrayBuilder<SourceGeneratedDocument>.GetInstance(generatedDocumentStates.Length, out var builder);
Expand Down