public void TryGetUnauditedReason_WhenSymbolDoesNotHaveUnauditedAttribute_ThrowsException()
        {
            TestSymbol <IFieldSymbol> field = CompileAndGetFooField(@"
public class Foo {
	public string foo;
}
");

            Assert.That(() => BecauseHelpers.GetUnauditedReason(field.Symbol), Throws.Exception);
        }
        public void TryGetUnauditedReason_WhenSymbolIsAnnotatedWithUnauditedReasonAndHasBucket_ReturnsCorrectReason(string expectedReason)
        {
            TestSymbol <IFieldSymbol> field = CompileAndGetFooField($@"
public class Foo {{
	[Mutability.Unaudited( Because.{expectedReason}, UndiffBucket.Core )]
	public string foo;
}}
");

            string reason = BecauseHelpers.GetUnauditedReason(field.Symbol);

            Assert.That(reason, Is.EqualTo(expectedReason));
        }
        private MutabilityInspectionResult InspectMemberRecursive(
            ISymbol symbol,
            HashSet <ITypeSymbol> typeStack
            )
        {
            // if the member is audited or unaudited, ignore it
            if (Attributes.Mutability.Audited.IsDefined(symbol))
            {
                return(MutabilityInspectionResult.NotMutable());
            }
            if (Attributes.Mutability.Unaudited.IsDefined(symbol))
            {
                string unauditedReason = BecauseHelpers.GetUnauditedReason(symbol);
                return(MutabilityInspectionResult.NotMutable(ImmutableHashSet.Create(unauditedReason)));
            }

            switch (symbol.Kind)
            {
            case SymbolKind.Property:
                return(InspectProperty(
                           symbol as IPropertySymbol,
                           typeStack
                           ));

            case SymbolKind.Field:
                return(InspectField(
                           symbol as IFieldSymbol,
                           typeStack
                           ));

            case SymbolKind.Method:
            case SymbolKind.NamedType:
                // ignore these symbols, because they do not contribute to immutability
                return(MutabilityInspectionResult.NotMutable());

            default:
                // we've got a member (event, etc.) that we can't currently be smart about, so fail
                return(MutabilityInspectionResult.PotentiallyMutableMember(symbol));
            }
        }