Skip to content
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

Expression bodied function crashes analyzers #41

Closed
memark opened this issue Jun 8, 2018 · 2 comments · Fixed by #42
Closed

Expression bodied function crashes analyzers #41

memark opened this issue Jun 8, 2018 · 2 comments · Fixed by #42
Labels

Comments

@memark
Copy link

memark commented Jun 8, 2018

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.'.
@memark
Copy link
Author

memark commented Jun 8, 2018

Changing the function to a normal function with { ... } causes the warnings to go away!

@Meir017
Copy link
Member

Meir017 commented Jun 9, 2018

Release 0.10.1 coming up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants