public void SqlKeywordsDelimitedBySpace_DotnetFramework(string sqlNamespace) { var references = MetadataReferenceFacade.GetSystemData() .Concat(NuGetMetadataReference.Dapper()) .Concat(NuGetMetadataReference.EntityFramework()) .Concat(NuGetMetadataReference.MicrosoftDataSqliteCore()) .Concat(NuGetMetadataReference.MicrosoftSqlServerCompact()) .Concat(NuGetMetadataReference.NHibernate()) .Concat(NuGetMetadataReference.PetaPocoCompiled()) .Concat(NuGetMetadataReference.SystemDataOdbc()) .Concat(NuGetMetadataReference.SystemDataSqlClient()) .Concat(NuGetMetadataReference.SystemDataSQLiteCore()); Verifier.VerifyCSharpAnalyzer($@" using {sqlNamespace}; namespace TestNamespace {{ public class Test {{ private string field = ""SELECT * FROM table"" + ""WHERE col ="" + // Noncompliant ""val""; }} }} ", new SqlKeywordsDelimitedBySpace(), additionalReferences: references.ToArray()); }
public void XmlExternalEntityShouldNotBeParsed_XPathDocument_CSharp9() => Verifier.VerifyAnalyzerFromCSharp9Console(@"TestCases\XmlExternalEntityShouldNotBeParsed_XPathDocument_CSharp9.cs", new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(NetFrameworkVersion.After452)), MetadataReferenceFacade.GetSystemXml() .Concat(MetadataReferenceFacade.GetSystemData()) .Concat(MetadataReferenceFacade.GetSystemXmlLinq()) .ToArray());
public void XmlExternalEntityShouldNotBeParsed_XmlDocument(NetFrameworkVersion version, string testFilePath) => Verifier.VerifyAnalyzer(testFilePath, new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)), additionalReferences: MetadataReferenceFacade.GetSystemXml() .Concat(MetadataReferenceFacade.GetSystemData()) .Concat(MetadataReferenceFacade.GetSystemXmlLinq()) .Concat(NuGetMetadataReference.MicrosoftWebXdt()) .ToArray());
private static void VerifyRule(NetFrameworkVersion version, string testFilePath, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, IEnumerable <ParseOptions> options = null) => Verifier.VerifyAnalyzer(testFilePath, new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)), additionalReferences: MetadataReferenceFacade.GetSystemXml() .Concat(MetadataReferenceFacade.GetSystemData()) .Concat(MetadataReferenceFacade.GetSystemXmlLinq()) .ToArray(), outputKind: outputKind, options: options);
private static void VerifyRule(NetFrameworkVersion version, string testFilePath) { var rule = new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)); Verifier.VerifyAnalyzer(testFilePath, rule, additionalReferences: MetadataReferenceFacade.GetSystemXml() .Concat(MetadataReferenceFacade.GetSystemData()) .Concat(MetadataReferenceFacade.GetSystemXmlLinq()) .ToArray()); }
public void XmlExternalEntityShouldNotBeParsed_XmlDocument(NetFrameworkVersion version, string testFilePath) { // setup var rule = new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)); // act & verify Verifier.VerifyAnalyzer(testFilePath, rule, additionalReferences: MetadataReferenceFacade.GetSystemXml() .Concat(MetadataReferenceFacade.GetSystemData()) .Concat(MetadataReferenceFacade.GetSystemXmlLinq()) .Concat(NuGetMetadataReference.MicrosoftWebXdt()) .ToArray(), options: ParseOptionsHelper.FromCSharp8); }
public void SqlKeywordsDelimitedBySpace_DotnetCore(string sqlNamespace) { var references = MetadataReferenceFacade.GetSystemData() .Concat(NuGetMetadataReference.MicrosoftEntityFrameworkCore("2.2.0")) .Concat(NuGetMetadataReference.ServiceStackOrmLite()) .Concat(NuGetMetadataReference.SystemDataSqlClient()) .Concat(NuGetMetadataReference.SystemDataOracleClient()); Verifier.VerifyCSharpAnalyzer($@" using {sqlNamespace}; namespace TestNamespace {{ public class Test {{ private string field = ""SELECT * FROM table"" + ""WHERE col ="" + // Noncompliant ""val""; }} }} ", new SqlKeywordsDelimitedBySpace(), additionalReferences: references.ToArray()); }
public void SetLocaleForDataTypes_CSharp9() => Verifier.VerifyAnalyzerFromCSharp9Console(@"TestCases\SetLocaleForDataTypes.CSharp9.cs", new SetLocaleForDataTypes(), MetadataReferenceFacade.GetSystemData());
public void SetLocaleForDataTypes() => Verifier.VerifyAnalyzer(@"TestCases\SetLocaleForDataTypes.cs", new SetLocaleForDataTypes(), additionalReferences: MetadataReferenceFacade.GetSystemData());