public void MethodShouldBeNamedAccordingToSynchronicity_MVC_Core(string aspNetCoreMvcVersion,
                                                                  string aspNetCoreRoutingVersion) =>
 Verifier.VerifyAnalyzer(@"TestCases\MethodShouldBeNamedAccordingToSynchronicity.MVC.Core.cs",
                         new MethodShouldBeNamedAccordingToSynchronicity(),
                         additionalReferences: NetStandardMetadataReference.Netstandard
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcCore(aspNetCoreMvcVersion))
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcViewFeatures(aspNetCoreMvcVersion))
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreRoutingAbstractions(aspNetCoreRoutingVersion)));
示例#2
0
 public void MemberShouldBeStatic(string aspnetCoreVersion, string aspnetVersion) =>
 Verifier.VerifyAnalyzer(@"TestCases\MemberShouldBeStatic.cs",
                         new MemberShouldBeStatic(),
                         additionalReferences: NuGetMetadataReference.MicrosoftAspNetCoreMvcWebApiCompatShim(aspnetCoreVersion)
                         .Concat(NuGetMetadataReference.MicrosoftAspNetMvc(aspnetVersion))
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcCore(aspnetCoreVersion))
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcViewFeatures(aspnetCoreVersion))
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreRoutingAbstractions(aspnetCoreVersion))
                         .ToImmutableArray());
 public void UriShouldNotBeHardcoded_CSharp_VirtualPath_AspNetCore(string aspNetCoreMvcVersion, string aspNetCoreRoutingVersion)
 {
     Verifier.VerifyAnalyzer(@"TestCases\UriShouldNotBeHardcoded.AspNetCore.cs",
                             new UriShouldNotBeHardcoded(),
                             additionalReferences:
                             // for VirtualFileResult
                             NuGetMetadataReference.MicrosoftAspNetCoreMvcCore(aspNetCoreMvcVersion)
                             // for Controller
                             .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcViewFeatures(aspNetCoreMvcVersion))
                             // for IRouter and VirtualPathData
                             .Concat(NuGetMetadataReference.MicrosoftAspNetCoreRoutingAbstractions(aspNetCoreRoutingVersion))
                             .ToArray());
 }
示例#4
0
 public void UriShouldNotBeHardcoded_CSharp_VirtualPath_AspNetCore(string aspNetCoreMvcVersion, string aspNetCoreRoutingVersion, string netHttpHeadersVersion) =>
 Verifier.VerifyAnalyzer(@"TestCases\UriShouldNotBeHardcoded.AspNetCore.cs",
                         new CS.UriShouldNotBeHardcoded(),
                         // for VirtualFileResult
                         NuGetMetadataReference.MicrosoftAspNetCoreMvcCore(aspNetCoreMvcVersion)
                         // for Controller
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcViewFeatures(aspNetCoreMvcVersion))
                         // for IRouter and VirtualPathData
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreRoutingAbstractions(aspNetCoreRoutingVersion))
                         // for IRouteBuilder
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreRouting(aspNetCoreRoutingVersion))
                         // for IActionResult
                         .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcAbstractions(aspNetCoreMvcVersion))
                         .Concat(NuGetMetadataReference.MicrosoftNetHttpHeaders(netHttpHeadersVersion))
                         .ToImmutableArray());
        public void Methods_In_Classes_With_NonControllerAttribute_Are_Not_EntryPoints(string aspNetMvcVersion)
        {
            const string code        = @"
[Microsoft.AspNetCore.Mvc.NonControllerAttribute]
public class Foo : Microsoft.AspNetCore.Mvc.ControllerBase
{
    public void PublicFoo() { }
}
";
            var          compilation = TestHelper.Compile(code,
                                                          additionalReferences:
                                                          FrameworkMetadataReference.Netstandard
                                                          .Union(NuGetMetadataReference.MicrosoftAspNetCoreMvcCore(aspNetMvcVersion))
                                                          .ToArray());

            var publicFoo = compilation.GetMethodSymbol("PublicFoo");

            AspNetMvcHelper.IsControllerMethod(publicFoo).Should().Be(false);
        }
 internal static IEnumerable <MetadataReference> GetAdditionalReferences() =>
 NetStandardMetadataReference.Netstandard
 .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcCore(Constants.NuGetLatestVersion))
 .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcViewFeatures(Constants.NuGetLatestVersion));
 public static IEnumerable <MetadataReference> GetAdditionalReferences_NetCore(string aspnetCoreVersion) =>
 FrameworkMetadataReference.Netstandard
 .Concat(NuGetMetadataReference.MicrosoftAspNetCoreMvcCore(aspnetCoreVersion));