public Test() { SolutionTransforms.Add((solution, projectId) => { solution = solution .AddMetadataReference(projectId, CodeAnalyzerHelper.XunitAbstractionsReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.XunitAssertReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.XunitCoreReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.SystemThreadingTasksReference); #if NETCOREAPP solution = solution .AddMetadataReference(projectId, CodeAnalyzerHelper.SystemCollectionsReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.SystemCollectionsNonGenericReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.SystemConsoleReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.SystemRuntimeReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.SystemRuntimeExtensionsReference) .AddMetadataReference(projectId, CodeAnalyzerHelper.SystemTextRegularExpressionsReference); #endif return(solution); }); // xunit diagnostics are reported in both normal and generated code TestBehaviors |= TestBehaviors.SkipGeneratedCodeCheck; }
public EpiserverTest() { SolutionTransforms.Add((solution, projectId) => { solution = solution .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(System.Web.Mvc.FilterAttribute).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(System.ComponentModel.DataAnnotations.DisplayAttribute).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(System.Data.IDataReader).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(log4net.LogManager).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.DataFactory).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.Data.Entity.IReadOnly).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.Web.Routing.IRoutable).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.Core.PageReference).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.Framework.Initialization.InitializationModule).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.Cms.Shell.CmsModule).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.Commerce.Catalog.ContentTypes.VariationContent).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(EPiServer.Commerce.Marketing.EntryPromotion).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(Mediachase.Commerce.Currency).GetTypeInfo().Assembly.Location)) .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(Mediachase.MetaDataPlus.MetaObject).GetTypeInfo().Assembly.Location)); return(solution); }); Exclusions &= ~AnalysisExclusions.GeneratedCode; }
public Test(ReferenceAssemblies?references, bool usePreviewLanguageVersion, int numberOfIterations) { // Code Fixer generates partial methods that will need to use the source generator to be filled. this.CompilerDiagnostics = CompilerDiagnostics.None; if (references != null) { ReferenceAssemblies = references; } else { // Clear out the default reference assemblies. We explicitly add references from the live ref pack, // so we don't want the Roslyn test infrastructure to resolve/add any default reference assemblies ReferenceAssemblies = new ReferenceAssemblies(string.Empty); TestState.AdditionalReferences.AddRange(RegexGeneratorHelper.References); } NumberOfFixAllIterations = numberOfIterations; SolutionTransforms.Add((solution, projectId) => { if (usePreviewLanguageVersion) { CSharpParseOptions parseOptions = solution.GetProject(projectId).ParseOptions as CSharpParseOptions; parseOptions = parseOptions.WithLanguageVersion(LanguageVersion.Preview); solution = solution.WithProjectParseOptions(projectId, parseOptions); } return(solution); }); }
public Test() { SolutionTransforms.Add((solution, projectId) => { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.Netstandard); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemXmlReference); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemRuntimeFacadeRef); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemThreadingFacadeRef); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemThreadingTaskFacadeRef); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.WorkspacesReference); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemDiagnosticsDebugReference); if (IncludeCodeAnalysisReference) { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.VisualBasicSymbolsReference); } if (!IncludeImmutableCollectionsReference) { solution = solution.RemoveMetadataReference(projectId, MetadataReferences.SystemCollectionsImmutableReference); } if (IncludeSystemDataReference) { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemDataReference) .AddMetadataReference(projectId, AdditionalMetadataReferences.SystemXmlDataReference); } var parseOptions = (VisualBasicParseOptions)solution.GetProject(projectId).ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); return(solution); }); }
public Test() { SolutionTransforms.Add((solution, projectId) => { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemXmlReference); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemRuntimeFacadeRef); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemThreadingFacadeRef); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemThreadingTaskFacadeRef); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.WorkspacesReference); solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemDiagnosticsDebugReference); if (IncludeCodeAnalysisReference) { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.CSharpSymbolsReference); } if (!IncludeImmutableCollectionsReference) { solution = solution.RemoveMetadataReference(projectId, MetadataReferences.SystemCollectionsImmutableReference); } if (IncludeSystemDataReference) { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemDataReference) .AddMetadataReference(projectId, AdditionalMetadataReferences.SystemXmlDataReference); } return(solution); }); }
public AzureAnalyzerTest(LanguageVersion languageVersion = LanguageVersion.Latest) { SolutionTransforms.Add((solution, projectId) => { var project = solution.GetProject(projectId); var parseOptions = (CSharpParseOptions)project.ParseOptions; return(solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(languageVersion))); }); ReferenceAssemblies = DefaultReferenceAssemblies; }
public Test() { SolutionTransforms.Add((solution, projectId) => { var compilationOptions = solution.GetProject(projectId).CompilationOptions; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); }
public Test() { ReferenceAssemblies = AdditionalMetadataReferences.Default; SolutionTransforms.Add((solution, projectId) => { var parseOptions = (VisualBasicParseOptions)solution.GetProject(projectId).ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); return(solution); }); }
public Test() { CompilerDiagnostics = Microsoft.CodeAnalysis.Testing.CompilerDiagnostics.None; ReferenceAssemblies = ReferenceAssemblies.WithPackages(ReferencesHelper.Packages); SolutionTransforms.Add((solution, projectId) => { var compilationOptions = solution.GetProject(projectId).CompilationOptions; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); }
public Test() { RuntimeHelpers.RunClassConstructor(typeof(CSharpVerifierHelper).TypeHandle); SolutionTransforms.Add((solution, projectId) => { var compilationOptions = solution.GetProject(projectId).CompilationOptions; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); }
public Test() { ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.WindowsForms; SolutionTransforms.Add((solution, projectId) => { var compilationOptions = solution.GetProject(projectId).CompilationOptions; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); }
public Test() { SolutionTransforms.Add((solution, projectId) => { solution = solution.AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(Regulus.Remote.Attributes.SyntaxHelper).Assembly.Location)); solution = solution.AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(Regulus.Remote.Value <>).Assembly.Location)); var compilationOptions = solution.GetProject(projectId).CompilationOptions; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); }
public Test() { ReferenceAssemblies = AdditionalMetadataReferences.Default; SolutionTransforms.Add((solution, projectId) => { var parseOptions = (CSharpParseOptions)solution.GetProject(projectId).ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); var compilationOptions = solution.GetProject(projectId).CompilationOptions; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); }
public Test() { SolutionTransforms.Add((solution, projectId) => { var project = solution.GetProject(projectId); var parseOptions = (VisualBasicParseOptions)project.ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); return(solution); }); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.SystemCollections); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.SystemCollectionsConcurrent); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.SystemConsole); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.SystemRuntime); }
public Test() { SolutionTransforms.Add((solution, projectId) => { var project = solution.GetProject(projectId); var parseOptions = (CSharpParseOptions)project.ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); if (IncludeContracts) { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.RuntimeContracts) .AddMetadataReference(projectId, AdditionalMetadataReferences.SystemRuntime); } return(solution); }); }
public Test() { SolutionTransforms.Add((solution, projectId) => { var compilationOptions = solution.GetProject(projectId).CompilationOptions; compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); TestState.AdditionalReferences.AddRange(new[] { MetadataReferenceFactory.CreateFromType <IGenericTypeConstraintAttribute>(), MetadataReferenceFactory.CreateFromType <ExampleAttribute>(), }); }
public Test() { ReferenceAssemblies = AdditionalMetadataReferences.DefaultReferenceAssemblies; SolutionTransforms.Add((solution, projectId) => { var project = solution.GetProject(projectId); var parseOptions = (VisualBasicParseOptions)project.ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); if (IncludeContracts) { solution = solution.AddMetadataReference(projectId, AdditionalMetadataReferences.RuntimeContracts); } return(solution); }); }
public Test() { ReferenceAssemblies = AdditionalMetadataReferences.ReferenceAssemblies; SolutionTransforms.Add((solution, projectId) => { var project = solution.GetProject(projectId); var parseOptions = (CSharpParseOptions?)project?.ParseOptions; if (parseOptions == null) { return(solution); } solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); return(solution); }); }
public Test() { ReferenceAssemblies = AdditionalMetadataReferences.DefaultReferenceAssemblies; TestState.AdditionalReferences.Add(AdditionalMetadataReferences.MSDataDataViewReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.MLNetCoreReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.MLNetDataReference); SolutionTransforms.Add((solution, projectId) => { if (LanguageVersion != null) { var parseOptions = (CSharpParseOptions)solution.GetProject(projectId).ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion.Value)); } return(solution); }); }
public Test() { TestState.AdditionalReferences.Add(AdditionalMetadataReferences.StandardReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.RuntimeReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.CSharpSymbolsReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.MSDataDataViewReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.MLNetCoreReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.MLNetDataReference); TestState.AdditionalReferences.Add(AdditionalMetadataReferences.MLNetStaticPipeReference); SolutionTransforms.Add((solution, projectId) => { if (LanguageVersion != null) { var parseOptions = (CSharpParseOptions)solution.GetProject(projectId).ParseOptions; solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion.Value)); } return(solution); }); }
public Test(string testCode, bool ignoreSuppressedDiagnostics, IDictionary <string, ReportDiagnostic> diagnosticOptions = null) { _ignoreSuppressedDiagnostics = ignoreSuppressedDiagnostics; TestCode = testCode; TestBehaviors = TestBehaviors.SkipGeneratedCodeCheck; diagnosticOptions ??= new Dictionary <string, ReportDiagnostic>(); SolutionTransforms.Add((solution, projectId) => { var compilationOptions = (CSharpCompilationOptions)solution .GetProject(projectId) .CompilationOptions; compilationOptions = compilationOptions .WithGeneralDiagnosticOption(ReportDiagnostic.Error) .WithSpecificDiagnosticOptions(diagnosticOptions) .WithNullableContextOptions(NullableContextOptions.Enable); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return(solution); }); }
public Test() { SolutionTransforms.Add((solution, project) => solution.WithProjectFilePath(project, "Project.csproj")); }