cezarypiatek / RoslynTestKit

A lightweight framework for writing unit tests for Roslyn diagnostic analyzers, code fixes, refactorings and completion providers.
Other
24 stars 7 forks source link

Readme - Examples Outdated? #28

Closed broderickt2 closed 7 months ago

broderickt2 commented 7 months ago

I was following along the 2nd listed example as shown below and cannot find the methods: CreateDocumentFromMarkup, GetMarkerLocation. I found CreateDocumentFromCode exists but this lives in the abstract class BaseTestFixture. Assuming this is the correct method, this cannot be called so easily.

[Test]
public void AutoPropDeclaredAndUsedInConstructor()
{
    const string markup = @"
class C
{
    public bool MyProperty { get; [|private set;|] }
    public C(bool f)
    {
        MyProperty = f;
    }
}";

    var fixture = RoslynFixtureFactory.Create<UseGetterOnlyAutoPropertyAnalyzer>();

    var document = this.CreateDocumentFromMarkup(markup, "MySampleProject", "MySampleDocument");
    var diagnosticLocation = this.GetMarkerLocation(markup);
    fixture.HasDiagnostic(document, DiagnosticIds.UseGetterOnlyAutoProperty, diagnosticLocation);
}
cezarypiatek commented 7 months ago

Yes, that seems to be outdated and it looks like the ability to override the project and document names has been removed. Do you need such a feature? What's your use case?

broderickt2 commented 7 months ago

I don't need this feature. More specifically what I was trying to do is described in issue 29; I wanted 2 classes in the code block. When I saw this code example, I was trying to setup a document and then add the 2 classes but then found this method did not exist which confused me.

broderickt2 commented 7 months ago

Closing this out for now. Takeaway, the readme could have its examples updated if you get a moment. Thanks!