Skip to content

tighten up AnalyzerOptions #8605

@heejaechang

Description

@heejaechang

we should do what @tmat suggested.

...

    public AnalyzerOptions AnalyzerOptions
    {
        get
        {
            if (analyzerOptions == null)
            {
                this.analyzerOptions = new AnalyzerOptions(this.additionalDocumentStates.Values.Select(d => new AdditionalDocumentStream(d)), globalOptions: null);
            }

            return analyzerOptions;
        }
    }

    private static AnalyzerOptions CreateAnalyzerOptions(ImmutableDictionary<DocumentId, TextDocumentState> additionalDocStates)
    {
        return new AnalyzerOptions(additionalDocStates.Values.Select(d => new AdditionalDocumentStream(d)), globalOptions: null);
    }

I couple of concerns

  1. CreateAnalyzerOptions seems to be unreachable and duplicating logic in the getter – I think it would be better to change analyzerOptions to readonly Lazy lazyAnalyzerOptions.
  2. The order of documents in the list passed to AnalyzerOptions is non-deterministic. Since this is then exposed as AnalyzerOptions.AdditionalFiles API it seems like we should order it in some way. Especially since AnalyzerOptions have value equality semantics.
  3. AnalyzerOptions should be sealed and implement IEquatable

Tomas

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions