-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Do not load generators in VS process #74444
Changes from 31 commits
c0de5f3
f4e75f7
f939303
0abf15f
3f0a8f9
e7f86d9
e680b53
1e80bfd
da19817
4b62941
417f3e2
b6ceb4a
d56dd56
f98bd36
50fb7e2
7790fe3
5da25eb
8340b71
521c1ad
1c83cf6
02fa4de
972d236
d2687f3
7a54020
1f98ad8
0ef1d34
51a7663
236d952
d71c784
8a23513
cf36ddd
d503540
ad64b9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.ComponentModel; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
|
@@ -30,29 +29,16 @@ internal sealed partial class DiagnosticItem( | |
|
||
public ProjectId ProjectId { get; } = projectId; | ||
public DiagnosticDescriptor Descriptor { get; } = descriptor; | ||
public ReportDiagnostic EffectiveSeverity { get; private set; } = effectiveSeverity; | ||
|
||
public override event PropertyChangedEventHandler? PropertyChanged; | ||
private readonly ReportDiagnostic _effectiveSeverity = effectiveSeverity; | ||
|
||
public override ImageMoniker IconMoniker | ||
=> MapEffectiveSeverityToIconMoniker(this.EffectiveSeverity); | ||
=> MapEffectiveSeverityToIconMoniker(_effectiveSeverity); | ||
|
||
public override IContextMenuController ContextMenuController => _commandHandler.DiagnosticContextMenuController; | ||
|
||
public override object GetBrowseObject() | ||
=> new BrowseObject(this); | ||
|
||
internal void UpdateEffectiveSeverity(ReportDiagnostic newEffectiveSeverity) | ||
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. we no longer update these in place (it makes equality/hash semantics non-ideal, which does impact how the observable collection and virtual tree view operate). instead, if things do change (the rare case) we rebuild the collection, with all the data immutable in it. 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. 💭 Will this cause the solution explorer to collapse nodes that are expanded when the children change? We've seen bugs of that form in other contexts before, so just asking. 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. missed thsi. the answer is likely 'yes'. If we feel like that's important to address, we can potentially do it by breaking out the portion of the anlaysis to determine if we think an actual change to the list happened, versus a property change to an item in the list. that said. only the item itself collapses. not the parent. so it's notthat bad imo. |
||
{ | ||
if (EffectiveSeverity != newEffectiveSeverity) | ||
{ | ||
EffectiveSeverity = newEffectiveSeverity; | ||
|
||
NotifyPropertyChanged(nameof(EffectiveSeverity)); | ||
NotifyPropertyChanged(nameof(IconMoniker)); | ||
} | ||
} | ||
|
||
private static ImageMoniker MapEffectiveSeverityToIconMoniker(ReportDiagnostic effectiveSeverity) | ||
=> effectiveSeverity switch | ||
{ | ||
|
@@ -64,11 +50,6 @@ private static ImageMoniker MapEffectiveSeverityToIconMoniker(ReportDiagnostic e | |
_ => default, | ||
}; | ||
|
||
private void NotifyPropertyChanged(string propertyName) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
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. no more notifications, as thsi is now an immutable vlaue. |
||
|
||
internal void SetRuleSetSeverity(ReportDiagnostic value, string pathToRuleSet) | ||
{ | ||
var ruleSetDocument = XDocument.Load(pathToRuleSet); | ||
|
@@ -88,7 +69,7 @@ internal Task<Solution> GetSolutionWithUpdatedAnalyzerConfigSeverityAsync(Report | |
public override int GetHashCode() | ||
=> Hash.Combine(this.Name, | ||
Hash.Combine(this.ProjectId, | ||
Hash.Combine(this.Descriptor.GetHashCode(), (int)this.EffectiveSeverity))); | ||
Hash.Combine(this.Descriptor.GetHashCode(), (int)_effectiveSeverity))); | ||
|
||
public override bool Equals(object obj) | ||
=> Equals(obj as DiagnosticItem); | ||
|
@@ -102,6 +83,6 @@ public bool Equals(DiagnosticItem? other) | |
this.Name == other.Name && | ||
this.ProjectId == other.ProjectId && | ||
this.Descriptor.Equals(other.Descriptor) && | ||
this.EffectiveSeverity == other.EffectiveSeverity; | ||
_effectiveSeverity == other._effectiveSeverity; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,4 +132,21 @@ await assetProvider.GetAssetHelper<AnalyzerReference>().GetAssetsAsync( | |
|
||
return false; | ||
} | ||
|
||
public ValueTask<ImmutableArray<SourceGeneratorIdentity>> GetSourceGeneratorIdentitiesAsync( | ||
Checksum solutionChecksum, | ||
ProjectId projectId, | ||
string analyzerReferenceFullPath, | ||
CancellationToken cancellationToken) | ||
{ | ||
return RunServiceAsync(solutionChecksum, solution => | ||
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. remote side of this call is trivial. we just retrieve hte AnalyzerFileRef requested, fetch its generators and get the identities from that. |
||
{ | ||
var project = solution.GetRequiredProject(projectId); | ||
var analyzerReference = project.AnalyzerReferences | ||
.OfType<AnalyzerFileReference>() | ||
.First(r => r.FullPath == analyzerReferenceFullPath); | ||
|
||
return ValueTaskFactory.FromResult(SourceGeneratorIdentity.GetIdentities(analyzerReference, project.Language)); | ||
}, cancellationToken); | ||
} | ||
} |
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.
Moved to base class. note that this comment is important. it was an invariant of this subclass that it would only set this once. We check for thsi invariant in the base class now.
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.
You should be able to use
[DisallowNull]
for this.