-
Notifications
You must be signed in to change notification settings - Fork 1
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
Replace calls to .Any() with .Count is not 0. #37
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
namespace IDisposableGenerator; | ||
|
||
internal class WorkItemCollection | ||
internal class WorkItemCollection(Compilation compilation) | ||
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved
Hide resolved
|
||
{ | ||
internal Compilation Compilation { get; } | ||
private List<WorkItem> WorkItems { get; } = new(); | ||
|
||
public WorkItemCollection(Compilation compilation) | ||
=> this.Compilation = compilation; | ||
internal Compilation Compilation { get; } = compilation; | ||
private List<WorkItem> WorkItems { get; } = []; | ||
|
||
public int Count => this.WorkItems.Count; | ||
|
||
public void Process(INamedTypeSymbol testClass, CancellationToken ct) | ||
{ | ||
ct.ThrowIfCancellationRequested(); | ||
AddFromNamespace(testClass.FullNamespace()); | ||
var workItem = FindWithNamespace(testClass.FullNamespace()); | ||
this.AddFromNamespace(testClass.FullNamespace()); | ||
var workItem = this.FindWithNamespace(testClass.FullNamespace()); | ||
ct.ThrowIfCancellationRequested(); | ||
|
||
// Avoid a bug that would set namespace to "IDisposableGenerator" | ||
|
@@ -28,7 +25,7 @@ public void Process(INamedTypeSymbol testClass, CancellationToken ct) | |
var classItemsQuery = | ||
from att in testClass.GetAttributes() | ||
where att.AttributeClass!.Name.Equals( | ||
"GenerateDisposeAttribute") | ||
"GenerateDisposeAttribute", StringComparison.Ordinal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like that very much however the attribute code files does not get directly compiled to be a part of the generator assembly, instead it gets provided as basically an output from the generator itself. I guess a workaround is to reference the generator and having it run here and then use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's included in the generated output files, it's fine. I don't find a reason to change how the API for the generator is accessible to the user. |
||
select GetClassItem(att, testClass); | ||
var memberQuery = | ||
from member in testClass.GetMembers() | ||
|
@@ -94,7 +91,7 @@ private void AddFromNamespace(string nameSpace) | |
return; | ||
} | ||
|
||
WorkItems.Add(new WorkItem | ||
this.WorkItems.Add(new WorkItem | ||
{ | ||
Namespace = nameSpace, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure if applying this pattern is healthy