public async Task VerifyGetFixes()
        {
            var code = File.ReadAllText(
                $@"Targets\{nameof(EvaluateManagedBackingFieldsCodeFixTests)}\{(nameof(this.VerifyGetFixes))}.cs");
            var document = TestHelpers.Create(code);
            var tree     = await document.GetSyntaxTreeAsync();

            var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new EvaluateManagedBackingFieldsAnalayzer());

            var sourceSpan = diagnostics[0].Location.SourceSpan;

            var actions = new List <CodeAction>();
            var codeActionRegistration = new Action <CodeAction, ImmutableArray <Diagnostic> >(
                (a, _) => { actions.Add(a); });

            var fix            = new EvaluateManagedBackingFieldsCodeFix();
            var codeFixContext = new CodeFixContext(document, diagnostics[0],
                                                    codeActionRegistration, new CancellationToken(false));
            await fix.RegisterCodeFixesAsync(codeFixContext);

            Assert.AreEqual(1, actions.Count, nameof(actions.Count));

            await TestHelpers.VerifyActionAsync(actions,
                                                EvaluateManagedBackingFieldsCodeFixConstants.FixManagedBackingFieldDescription, document,
                                                tree, new[] { $@"    public static readonly " });
        }
        public async Task VerifyGetFixesWithTrivia()
        {
            var code =
                @"using Csla;

public class A : BusinessBase<A>
{
  #region Properties
  private static readonly PropertyInfo<string> DataProperty = RegisterProperty<string>(_ => _.Data);
  #endregion

  public string Data => GetProperty(DataProperty);
}";
            var document = TestHelpers.Create(code);
            var tree     = await document.GetSyntaxTreeAsync();

            var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new EvaluateManagedBackingFieldsAnalayzer());

            var sourceSpan = diagnostics[0].Location.SourceSpan;

            var actions = new List <CodeAction>();
            var codeActionRegistration = new Action <CodeAction, ImmutableArray <Diagnostic> >(
                (a, _) => { actions.Add(a); });

            var fix            = new EvaluateManagedBackingFieldsCodeFix();
            var codeFixContext = new CodeFixContext(document, diagnostics[0],
                                                    codeActionRegistration, new CancellationToken(false));
            await fix.RegisterCodeFixesAsync(codeFixContext);

            Assert.AreEqual(1, actions.Count, nameof(actions.Count));

            await TestHelpers.VerifyActionAsync(actions,
                                                EvaluateManagedBackingFieldsCodeFixConstants.FixManagedBackingFieldDescription, document,
                                                tree, new[] { "#region Properties", "public" });
        }
        public void VerifyGetFixableDiagnosticIds()
        {
            var fix = new EvaluateManagedBackingFieldsCodeFix();
            var ids = fix.FixableDiagnosticIds.ToList();

            Assert.AreEqual(1, ids.Count, nameof(ids.Count));
            Assert.AreEqual(EvaluateManagedBackingFieldsAnalayzerConstants.DiagnosticId, ids[0],
                            nameof(EvaluateManagedBackingFieldsAnalayzerConstants.DiagnosticId));
        }
    public void VerifyGetFixableDiagnosticIds()
    {
      var fix = new EvaluateManagedBackingFieldsCodeFix();
      var ids = fix.FixableDiagnosticIds.ToList();

      Assert.AreEqual(1, ids.Count, nameof(ids.Count));
      Assert.AreEqual(ids[0], Constants.AnalyzerIdentifiers.EvaluateManagedBackingFields,
        nameof(Constants.AnalyzerIdentifiers.EvaluateManagedBackingFields));
    }
        public void VerifyGetFixableDiagnosticIds()
        {
            var fix = new EvaluateManagedBackingFieldsCodeFix();
            var ids = fix.FixableDiagnosticIds.ToList();

            Assert.AreEqual(1, ids.Count, nameof(ids.Count));
            Assert.AreEqual(ids[0], Constants.AnalyzerIdentifiers.EvaluateManagedBackingFields,
                            nameof(Constants.AnalyzerIdentifiers.EvaluateManagedBackingFields));
        }
        public async Task VerifyGetFixes()
        {
            var code =
                @"using Csla;

public class A : BusinessBase<A>
{
  PropertyInfo<string> DataProperty =
    RegisterProperty<string>(_ => _.Data);
  public string Data
  {
    get { return GetProperty(DataProperty); }
    set { SetProperty(DataProperty, value); }
  }
}";
            var document = TestHelpers.Create(code);
            var tree     = await document.GetSyntaxTreeAsync();

            var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new EvaluateManagedBackingFieldsAnalayzer());

            var sourceSpan = diagnostics[0].Location.SourceSpan;

            var actions = new List <CodeAction>();
            var codeActionRegistration = new Action <CodeAction, ImmutableArray <Diagnostic> >(
                (a, _) => { actions.Add(a); });

            var fix            = new EvaluateManagedBackingFieldsCodeFix();
            var codeFixContext = new CodeFixContext(document, diagnostics[0],
                                                    codeActionRegistration, new CancellationToken(false));
            await fix.RegisterCodeFixesAsync(codeFixContext);

            Assert.AreEqual(1, actions.Count, nameof(actions.Count));

            await TestHelpers.VerifyChangesAsync(actions,
                                                 EvaluateManagedBackingFieldsCodeFixConstants.FixManagedBackingFieldDescription, document,
                                                 (model, newRoot) =>
            {
                var fieldNode   = newRoot.DescendantNodes(_ => true).OfType <FieldDeclarationSyntax>().Single().Declaration.Variables[0];
                var fieldSymbol = model.GetDeclaredSymbol(fieldNode) as IFieldSymbol;

                Assert.IsTrue(fieldSymbol.DeclaredAccessibility == Accessibility.Public);
                Assert.IsTrue(fieldSymbol.IsStatic);
                Assert.IsTrue(fieldSymbol.IsReadOnly);
            });
        }
        public async Task VerifyGetFixes()
        {
            var code =
                @"namespace Csla.Analyzers.Tests.Targets.EvaluateManagedBackingFieldsCodeFixTests
{
  public class User 
    : BusinessBase<User>
  {
    PropertyInfo<string> DataProperty =
      RegisterProperty<string>(_ => _.Data);
    public string Data
    {
      get { return GetProperty(DataProperty); }
      set { SetProperty(DataProperty, value); }
    }
  }
}";
            var document = TestHelpers.Create(code);
            var tree     = await document.GetSyntaxTreeAsync();

            var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new EvaluateManagedBackingFieldsAnalayzer());

            var sourceSpan = diagnostics[0].Location.SourceSpan;

            var actions = new List <CodeAction>();
            var codeActionRegistration = new Action <CodeAction, ImmutableArray <Diagnostic> >(
                (a, _) => { actions.Add(a); });

            var fix            = new EvaluateManagedBackingFieldsCodeFix();
            var codeFixContext = new CodeFixContext(document, diagnostics[0],
                                                    codeActionRegistration, new CancellationToken(false));
            await fix.RegisterCodeFixesAsync(codeFixContext);

            Assert.AreEqual(1, actions.Count, nameof(actions.Count));

            await TestHelpers.VerifyActionAsync(actions,
                                                EvaluateManagedBackingFieldsCodeFixConstants.FixManagedBackingFieldDescription, document,
                                                tree, new[] { "public static readonly" });
        }
    public async Task VerifyGetFixesWithTrivia()
    {
      var code = File.ReadAllText(
        $@"Targets\{nameof(EvaluateManagedBackingFieldsCodeFixTests)}\{(nameof(this.VerifyGetFixesWithTrivia))}.cs");
      var document = TestHelpers.Create(code);
      var tree = await document.GetSyntaxTreeAsync();
      var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new EvaluateManagedBackingFieldsAnalayzer());
      var sourceSpan = diagnostics[0].Location.SourceSpan;

      var actions = new List<CodeAction>();
      var codeActionRegistration = new Action<CodeAction, ImmutableArray<Diagnostic>>(
        (a, _) => { actions.Add(a); });

      var fix = new EvaluateManagedBackingFieldsCodeFix();
      var codeFixContext = new CodeFixContext(document, diagnostics[0],
        codeActionRegistration, new CancellationToken(false));
      await fix.RegisterCodeFixesAsync(codeFixContext);

      Assert.AreEqual(1, actions.Count, nameof(actions.Count));

      await TestHelpers.VerifyActionAsync(actions,
        EvaluateManagedBackingFieldsCodeFixConstants.FixManagedBackingFieldDescription, document,
        tree, new[] { "    #region Properties\r\n        public" });
    }