Skip to content

Expression bodied function crashes analyzers #41

@memark

Description

@memark

When using a simple EBF (expression based function) the analyzers crash in Visual Studio 15.7.3.

To reproduce:

  • Create a new solution.
  • Add a new C# project (.NET Core/Standard/Framework doesn't matter)
  • Add a package reference to FluentAssertions.Analyzers 0.10.0.
  • Add the following code
public class TestClass
{
    private SomeClass CreateSomeClass() => new SomeClass();
 
    public class SomeClass
    { }
}
  • Build the project.

Expected:
No errors.

Actual:

1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountLessOrEqualToAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountGreaterOrEqualToAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldNotBeNullOrEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotBeEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldEqualOtherCollectionByComparerAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotHaveCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldBeInAscendingOrderAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountGreaterThanAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotContainItemAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainPropertyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldBeInDescendingOrderAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountLessThanAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldOnlyHaveUniqueItemsByComparerAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldOnlyContainPropertyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldOnlyHaveUniqueItemsAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.NumericShouldBeApproximatelyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveSameCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotIntersectWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldBeNullOrWhiteSpaceAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotContainPropertyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainSingleAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldEndWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldBeEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldStartWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldBeNullOrEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainItemAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveElementAtAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldIntersectWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotBeNullOrEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotContainNullsAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotHaveSameCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldHaveLengthAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldNotBeNullOrWhiteSpaceAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions