private void VerifyFix(
            string language,
            DiagnosticAnalyzer analyzerOpt,
            CodeFixProvider codeFixProvider,
            string[] oldSources,
            string[] newSources,
            int?codeFixIndex,
            bool allowNewCompilerDiagnostics,
            bool onlyFixFirstFixableDiagnostic,
            bool allowUnsafeCode,
            TestValidationMode validationMode,
            ReferenceFlags referenceFlags = ReferenceFlags.None)
        {
            var runner = new CodeFixRunner(analyzerOpt, codeFixProvider, validationMode);

            Assert.True(oldSources.Length == newSources.Length, "Length of expected and actual sources arrays must match.");
            Document[] documents = CreateDocuments(oldSources, language, referenceFlags, allowUnsafeCode: allowUnsafeCode);

            var      project = documents.First().Project;
            Solution newSolution;

            if (onlyFixFirstFixableDiagnostic)
            {
                newSolution = runner.ApplySingleFix(project, ImmutableArray <TestAdditionalDocument> .Empty, codeFixIndex ?? 0);
            }
            else
            {
                newSolution = runner.ApplyFixesOneByOne(project.Solution, ImmutableArray <TestAdditionalDocument> .Empty, allowNewCompilerDiagnostics, codeFixIndex ?? 0);
            }

            VerifyDocuments(newSolution, documents, newSources);
        }
 public static IReference Find(this IReference reference, ReferenceFlags flag)
 {
     if (reference.HasFlag(flag))
     {
         return(reference);
     }
     else if (reference.Other.HasFlag(flag))
     {
         return(reference.Other);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 public static bool HasAnyFlag(this IReference metadata, ReferenceFlags flag) => (metadata.Flags & flag) != ReferenceFlags.None;
Exemplo n.º 4
0
 public static bool HasFlag(this IReference metadata, ReferenceFlags flag) => (metadata.Flags & flag) == flag;
Exemplo n.º 5
0
 public PhpSmartReference(object value)
     : base(value)
 {
     flags = ReferenceFlags.IsSet;
 }
Exemplo n.º 6
0
 public PhpSmartReference()
     : base()
 {
     flags = ReferenceFlags.IsSet;
 }
 protected void VerifyCSharpFix(string[] oldSources, string[] newSources, int?codeFixIndex = null, bool allowNewCompilerDiagnostics = false, bool onlyFixFirstFixableDiagnostic = false, TestValidationMode validationMode = DefaultTestValidationMode, ReferenceFlags referenceFlags = ReferenceFlags.None)
 {
     VerifyFix(LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), GetCSharpCodeFixProvider(), oldSources, newSources, codeFixIndex, allowNewCompilerDiagnostics, onlyFixFirstFixableDiagnostic, allowUnsafeCode: false, validationMode: validationMode, referenceFlags: referenceFlags);
 }
 public static IReferenceKey FindKey(this IReference reference, ReferenceFlags flag) => reference.Find(flag)?.Key;
 protected void VerifyBasicFix(string[] oldSources, string[] newSources, int?codeFixIndex = null, bool allowNewCompilerDiagnostics = false, bool onlyFixFirstFixableDiagnostic = false, FixAllScope?testFixAllScope = FixAllScope.Project, TestValidationMode validationMode = DefaultTestValidationMode, ReferenceFlags referenceFlags = ReferenceFlags.None)
 {
     VerifyFix(LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), GetBasicCodeFixProvider(), oldSources, newSources, codeFixIndex, allowNewCompilerDiagnostics, onlyFixFirstFixableDiagnostic, testFixAllScope, allowUnsafeCode: false, validationMode: validationMode, referenceFlags: referenceFlags);
 }