Update analyzer tests to use Microsoft.AspNetCore.Analyzer.Testing
This commit is contained in:
parent
9f0d3712eb
commit
f52c9c0f97
|
|
@ -5,81 +5,82 @@
|
||||||
<PropertyGroup Label="Package Versions">
|
<PropertyGroup Label="Package Versions">
|
||||||
<AngleSharpPackageVersion>0.9.9</AngleSharpPackageVersion>
|
<AngleSharpPackageVersion>0.9.9</AngleSharpPackageVersion>
|
||||||
<BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion>
|
<BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion>
|
||||||
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-17047</InternalAspNetCoreSdkPackageVersion>
|
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-17048</InternalAspNetCoreSdkPackageVersion>
|
||||||
<MicrosoftAspNetCoreAntiforgeryPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreAntiforgeryPackageVersion>
|
<MicrosoftAspNetCoreAnalyzerTestingPackageVersion>2.2.0-a-preview1-a2-16496</MicrosoftAspNetCoreAnalyzerTestingPackageVersion>
|
||||||
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
|
<MicrosoftAspNetCoreAntiforgeryPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreAntiforgeryPackageVersion>
|
||||||
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
|
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
|
||||||
<MicrosoftAspNetCoreAuthenticationPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreAuthenticationPackageVersion>
|
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
|
||||||
<MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>
|
<MicrosoftAspNetCoreAuthenticationPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreAuthenticationPackageVersion>
|
||||||
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
|
<MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>
|
||||||
<MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion>
|
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
|
||||||
<MicrosoftAspNetCoreCookiePolicyPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreCookiePolicyPackageVersion>
|
<MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion>
|
||||||
<MicrosoftAspNetCoreCorsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreCorsPackageVersion>
|
<MicrosoftAspNetCoreCookiePolicyPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreCookiePolicyPackageVersion>
|
||||||
<MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion>
|
<MicrosoftAspNetCoreCorsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreCorsPackageVersion>
|
||||||
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
<MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreDiagnosticsAbstractionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
||||||
<MicrosoftAspNetCoreHostingPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreHostingPackageVersion>
|
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>
|
<MicrosoftAspNetCoreHostingPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreHostingPackageVersion>
|
||||||
<MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreHttpExtensionsPackageVersion>
|
<MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreHttpPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreHttpPackageVersion>
|
<MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreHttpExtensionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreJsonPatchPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreJsonPatchPackageVersion>
|
<MicrosoftAspNetCoreHttpPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreHttpPackageVersion>
|
||||||
<MicrosoftAspNetCoreLocalizationPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreLocalizationPackageVersion>
|
<MicrosoftAspNetCoreJsonPatchPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreJsonPatchPackageVersion>
|
||||||
<MicrosoftAspNetCoreLocalizationRoutingPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreLocalizationRoutingPackageVersion>
|
<MicrosoftAspNetCoreLocalizationPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreLocalizationPackageVersion>
|
||||||
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
|
<MicrosoftAspNetCoreLocalizationRoutingPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreLocalizationRoutingPackageVersion>
|
||||||
<MicrosoftAspNetCoreRangeHelperSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreRangeHelperSourcesPackageVersion>
|
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreRazorDesignPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreRazorDesignPackageVersion>
|
<MicrosoftAspNetCoreRangeHelperSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreRangeHelperSourcesPackageVersion>
|
||||||
<MicrosoftAspNetCoreRazorLanguagePackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreRazorLanguagePackageVersion>
|
<MicrosoftAspNetCoreRazorDesignPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreRazorDesignPackageVersion>
|
||||||
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreRazorRuntimePackageVersion>
|
<MicrosoftAspNetCoreRazorLanguagePackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreRazorLanguagePackageVersion>
|
||||||
<MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion>
|
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreRazorRuntimePackageVersion>
|
||||||
<MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion>
|
<MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion>
|
||||||
<MicrosoftAspNetCoreResponseCachingPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreResponseCachingPackageVersion>
|
<MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreResponseCachingAbstractionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreRoutingAbstractionsPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreRoutingAbstractionsPackageVersion>
|
<MicrosoftAspNetCoreResponseCachingPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreResponseCachingPackageVersion>
|
||||||
<MicrosoftAspNetCoreRoutingPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreRoutingPackageVersion>
|
<MicrosoftAspNetCoreRoutingAbstractionsPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreRoutingAbstractionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
<MicrosoftAspNetCoreRoutingPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreRoutingPackageVersion>
|
||||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
||||||
<MicrosoftAspNetCoreSessionPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreSessionPackageVersion>
|
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
<MicrosoftAspNetCoreSessionPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreSessionPackageVersion>
|
||||||
<MicrosoftAspNetCoreTestHostPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreTestHostPackageVersion>
|
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||||
<MicrosoftAspNetCoreTestingPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreTestingPackageVersion>
|
<MicrosoftAspNetCoreTestHostPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreTestHostPackageVersion>
|
||||||
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.2.0-preview1-34135</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
|
<MicrosoftAspNetCoreTestingPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreTestingPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.2.0-preview1-34136</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
|
||||||
<MicrosoftAspNetWebApiClientPackageVersion>5.2.4</MicrosoftAspNetWebApiClientPackageVersion>
|
<MicrosoftAspNetWebApiClientPackageVersion>5.2.4</MicrosoftAspNetWebApiClientPackageVersion>
|
||||||
<MicrosoftCodeAnalysisCSharpPackageVersion>2.8.0</MicrosoftCodeAnalysisCSharpPackageVersion>
|
<MicrosoftCodeAnalysisCSharpPackageVersion>2.8.0-beta3</MicrosoftCodeAnalysisCSharpPackageVersion>
|
||||||
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>2.8.0</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
|
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>2.8.0-beta3</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
|
||||||
<MicrosoftCodeAnalysisRazorPackageVersion>2.2.0-preview1-34135</MicrosoftCodeAnalysisRazorPackageVersion>
|
<MicrosoftCodeAnalysisRazorPackageVersion>2.2.0-preview1-34136</MicrosoftCodeAnalysisRazorPackageVersion>
|
||||||
<MicrosoftDiaSymReaderNativePackageVersion>1.7.0</MicrosoftDiaSymReaderNativePackageVersion>
|
<MicrosoftDiaSymReaderNativePackageVersion>1.7.0</MicrosoftDiaSymReaderNativePackageVersion>
|
||||||
<MicrosoftExtensionsCachingMemoryPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsCachingMemoryPackageVersion>
|
<MicrosoftExtensionsCachingMemoryPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsCachingMemoryPackageVersion>
|
||||||
<MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>
|
<MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
||||||
<MicrosoftExtensionsConfigurationPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsConfigurationPackageVersion>
|
<MicrosoftExtensionsConfigurationPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsConfigurationPackageVersion>
|
||||||
<MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion>
|
<MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion>
|
||||||
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsDependencyInjectionPackageVersion>
|
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsDependencyInjectionPackageVersion>
|
||||||
<MicrosoftExtensionsDependencyModelPackageVersion>2.2.0-preview1-26424-04</MicrosoftExtensionsDependencyModelPackageVersion>
|
<MicrosoftExtensionsDependencyModelPackageVersion>2.2.0-preview1-26424-04</MicrosoftExtensionsDependencyModelPackageVersion>
|
||||||
<MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsDiagnosticAdapterPackageVersion>
|
<MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsDiagnosticAdapterPackageVersion>
|
||||||
<MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>
|
<MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>
|
||||||
<MicrosoftExtensionsFileProvidersCompositePackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsFileProvidersCompositePackageVersion>
|
<MicrosoftExtensionsFileProvidersCompositePackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsFileProvidersCompositePackageVersion>
|
||||||
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>
|
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>
|
||||||
<MicrosoftExtensionsFileSystemGlobbingPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsFileSystemGlobbingPackageVersion>
|
<MicrosoftExtensionsFileSystemGlobbingPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsFileSystemGlobbingPackageVersion>
|
||||||
<MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion>
|
<MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsLocalizationPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsLocalizationPackageVersion>
|
<MicrosoftExtensionsLocalizationPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsLocalizationPackageVersion>
|
||||||
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
|
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
|
||||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsLoggingConsolePackageVersion>
|
<MicrosoftExtensionsLoggingConsolePackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||||
<MicrosoftExtensionsLoggingDebugPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsLoggingDebugPackageVersion>
|
<MicrosoftExtensionsLoggingDebugPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||||
<MicrosoftExtensionsLoggingPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsLoggingPackageVersion>
|
<MicrosoftExtensionsLoggingPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsLoggingPackageVersion>
|
||||||
<MicrosoftExtensionsLoggingTestingPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsLoggingTestingPackageVersion>
|
<MicrosoftExtensionsLoggingTestingPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsLoggingTestingPackageVersion>
|
||||||
<MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>
|
<MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsOptionsPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsOptionsPackageVersion>
|
<MicrosoftExtensionsOptionsPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsOptionsPackageVersion>
|
||||||
<MicrosoftExtensionsParameterDefaultValueSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsParameterDefaultValueSourcesPackageVersion>
|
<MicrosoftExtensionsParameterDefaultValueSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsParameterDefaultValueSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsPrimitivesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsPrimitivesPackageVersion>
|
<MicrosoftExtensionsPrimitivesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsPrimitivesPackageVersion>
|
||||||
<MicrosoftExtensionsPropertyActivatorSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsPropertyActivatorSourcesPackageVersion>
|
<MicrosoftExtensionsPropertyActivatorSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsPropertyActivatorSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsPropertyHelperSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsPropertyHelperSourcesPackageVersion>
|
<MicrosoftExtensionsPropertyHelperSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsPropertyHelperSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsSecurityHelperSourcesPackageVersion>
|
<MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsSecurityHelperSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsTypeNameHelperSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsTypeNameHelperSourcesPackageVersion>
|
<MicrosoftExtensionsTypeNameHelperSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsTypeNameHelperSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsValueStopwatchSourcesPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsValueStopwatchSourcesPackageVersion>
|
<MicrosoftExtensionsValueStopwatchSourcesPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsValueStopwatchSourcesPackageVersion>
|
||||||
<MicrosoftExtensionsWebEncodersPackageVersion>2.2.0-preview1-34135</MicrosoftExtensionsWebEncodersPackageVersion>
|
<MicrosoftExtensionsWebEncodersPackageVersion>2.2.0-preview1-34136</MicrosoftExtensionsWebEncodersPackageVersion>
|
||||||
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
||||||
<MicrosoftNETCoreApp21PackageVersion>2.2.0-preview1-26424-04</MicrosoftNETCoreApp21PackageVersion>
|
<MicrosoftNETCoreApp21PackageVersion>2.2.0-preview1-26424-04</MicrosoftNETCoreApp21PackageVersion>
|
||||||
<MicrosoftNetHttpHeadersPackageVersion>2.2.0-preview1-34135</MicrosoftNetHttpHeadersPackageVersion>
|
<MicrosoftNetHttpHeadersPackageVersion>2.2.0-preview1-34136</MicrosoftNetHttpHeadersPackageVersion>
|
||||||
<MicrosoftNETSdkRazorPackageVersion>2.2.0-preview1-34135</MicrosoftNETSdkRazorPackageVersion>
|
<MicrosoftNETSdkRazorPackageVersion>2.2.0-preview1-34136</MicrosoftNETSdkRazorPackageVersion>
|
||||||
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
|
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
|
||||||
<MoqPackageVersion>4.7.49</MoqPackageVersion>
|
<MoqPackageVersion>4.7.49</MoqPackageVersion>
|
||||||
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
|
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
version:2.2.0-preview1-17047
|
version:2.2.0-preview1-17048
|
||||||
commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c
|
commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CodeFixes;
|
using Microsoft.CodeAnalysis.CodeFixes;
|
||||||
|
|
@ -12,6 +14,8 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
|
||||||
{
|
{
|
||||||
public class ActionsMustNotBeAsyncVoidFacts : AnalyzerTestBase
|
public class ActionsMustNotBeAsyncVoidFacts : AnalyzerTestBase
|
||||||
{
|
{
|
||||||
|
private static DiagnosticDescriptor DiagnosticDescriptor = DiagnosticDescriptors.MVC7003_ActionsMustNotBeAsyncVoid;
|
||||||
|
|
||||||
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
||||||
= new ActionsMustNotBeAsyncVoidAnalyzer();
|
= new ActionsMustNotBeAsyncVoidAnalyzer();
|
||||||
|
|
||||||
|
|
@ -57,13 +61,7 @@ public class UserViewModel
|
||||||
public async Task DiagnosticsAreReturned_WhenMethodIsAControllerAction()
|
public async Task DiagnosticsAreReturned_WhenMethodIsAControllerAction()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var location = new DiagnosticLocation("Test.cs", 7, 18);
|
||||||
{
|
|
||||||
Id = "MVC7003",
|
|
||||||
Message = "Controller actions must not have async void signature.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 7, 18) }
|
|
||||||
};
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -92,7 +90,7 @@ public class HomeController : Controller
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(location, actualDiagnostics);
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
@ -101,13 +99,7 @@ public class HomeController : Controller
|
||||||
public async Task DiagnosticsAreReturned_WhenActionMethodIsExpressionBodied()
|
public async Task DiagnosticsAreReturned_WhenActionMethodIsExpressionBodied()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var location = new DiagnosticLocation("Test.cs", 7, 18);
|
||||||
{
|
|
||||||
Id = "MVC7003",
|
|
||||||
Message = "Controller actions must not have async void signature.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 7, 18) }
|
|
||||||
};
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -130,7 +122,7 @@ public class HomeController : Controller
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(location, actualDiagnostics);
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
@ -139,13 +131,7 @@ public class HomeController : Controller
|
||||||
public async Task CodeFix_ProducesFullyQualifiedNamespaces()
|
public async Task CodeFix_ProducesFullyQualifiedNamespaces()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var location = new DiagnosticLocation("Test.cs", 6, 18);
|
||||||
{
|
|
||||||
Id = "MVC7003",
|
|
||||||
Message = "Controller actions must not have async void signature.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 6, 18) }
|
|
||||||
};
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -166,9 +152,22 @@ public class HomeController : Controller
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(location, actualDiagnostics);
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AssertDiagnostic(DiagnosticLocation expectedLocation, Diagnostic[] actualDiagnostics)
|
||||||
|
{
|
||||||
|
// Assert
|
||||||
|
Assert.Collection(
|
||||||
|
actualDiagnostics,
|
||||||
|
diagnostic =>
|
||||||
|
{
|
||||||
|
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
||||||
|
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
||||||
|
AnalyzerAssert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CodeFixes;
|
using Microsoft.CodeAnalysis.CodeFixes;
|
||||||
|
|
@ -12,6 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
|
||||||
{
|
{
|
||||||
public class ApiActionsDoNotRequireExplicitModelValidationCheckFacts : AnalyzerTestBase
|
public class ApiActionsDoNotRequireExplicitModelValidationCheckFacts : AnalyzerTestBase
|
||||||
{
|
{
|
||||||
|
private static DiagnosticDescriptor DiagnosticDescriptor = DiagnosticDescriptors.MVC7001_ApiActionsHaveBadModelStateFilter;
|
||||||
|
|
||||||
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
||||||
= new ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer();
|
= new ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer();
|
||||||
|
|
||||||
|
|
@ -199,48 +202,11 @@ public class PetController : ControllerBase
|
||||||
return VerifyAsync(test);
|
return VerifyAsync(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task VerifyAsync(string test)
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
|
||||||
{
|
|
||||||
Id = "MVC7001",
|
|
||||||
Message = "Actions on types annotated with ApiControllerAttribute do not require explicit ModelState validity check.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 9, 9) }
|
|
||||||
};
|
|
||||||
var expectedFix =
|
|
||||||
@"
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
public class PetController : ControllerBase
|
|
||||||
{
|
|
||||||
public IActionResult GetPetId()
|
|
||||||
{
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}";
|
|
||||||
var project = CreateProject(test);
|
|
||||||
|
|
||||||
// Act & Assert
|
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task DiagnosticsAndCodeFixes_WhenModelStateIsInElseIf()
|
public async Task DiagnosticsAndCodeFixes_WhenModelStateIsInElseIf()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var expectedLocation = new DiagnosticLocation("Test.cs", 13, 9);
|
||||||
{
|
|
||||||
Id = "MVC7001",
|
|
||||||
Message = "Actions on types annotated with ApiControllerAttribute do not require explicit ModelState validity check.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 13, 9) }
|
|
||||||
};
|
|
||||||
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
|
|
@ -284,7 +250,7 @@ public class PetController : ControllerBase
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(expectedLocation, actualDiagnostics);
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
@ -293,13 +259,7 @@ public class PetController : ControllerBase
|
||||||
public async Task DiagnosticsAndCodeFixes_WhenModelStateIsInNestedBlock()
|
public async Task DiagnosticsAndCodeFixes_WhenModelStateIsInNestedBlock()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var expectedLocation = new DiagnosticLocation("Test.cs", 15, 13);
|
||||||
{
|
|
||||||
Id = "MVC7001",
|
|
||||||
Message = "Actions on types annotated with ApiControllerAttribute do not require explicit ModelState validity check.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 15, 13) }
|
|
||||||
};
|
|
||||||
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
|
|
@ -353,9 +313,47 @@ public class PetController : ControllerBase
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(expectedLocation, actualDiagnostics);
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task VerifyAsync(string test)
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var expectedLocation = new DiagnosticLocation("Test.cs", 9, 9);
|
||||||
|
var expectedFix =
|
||||||
|
@"
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
public class PetController : ControllerBase
|
||||||
|
{
|
||||||
|
public IActionResult GetPetId()
|
||||||
|
{
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}";
|
||||||
|
var project = CreateProject(test);
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
|
AssertDiagnostic(expectedLocation, actualDiagnostics);
|
||||||
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AssertDiagnostic(DiagnosticLocation expectedLocation, Diagnostic[] actualDiagnostics)
|
||||||
|
{
|
||||||
|
// Assert
|
||||||
|
Assert.Collection(
|
||||||
|
actualDiagnostics,
|
||||||
|
diagnostic =>
|
||||||
|
{
|
||||||
|
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
||||||
|
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
||||||
|
AnalyzerAssert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CodeFixes;
|
using Microsoft.CodeAnalysis.CodeFixes;
|
||||||
|
|
@ -12,6 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
|
||||||
{
|
{
|
||||||
public class ApiActionsAreAttributeRoutedFacts : AnalyzerTestBase
|
public class ApiActionsAreAttributeRoutedFacts : AnalyzerTestBase
|
||||||
{
|
{
|
||||||
|
private static DiagnosticDescriptor DiagnosticDescriptor = DiagnosticDescriptors.MVC7000_ApiActionsMustBeAttributeRouted;
|
||||||
|
|
||||||
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
||||||
= new ApiActionsAreAttributeRoutedAnalyzer();
|
= new ApiActionsAreAttributeRoutedAnalyzer();
|
||||||
|
|
||||||
|
|
@ -128,13 +131,7 @@ public class PetController : Controller
|
||||||
public async Task DiagnosticsAndCodeFixes_WhenApiControllerActionDoesNotHaveAttribute()
|
public async Task DiagnosticsAndCodeFixes_WhenApiControllerActionDoesNotHaveAttribute()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var expectedLocation = new DiagnosticLocation("Test.cs", 8, 16);
|
||||||
{
|
|
||||||
Id = "MVC7000",
|
|
||||||
Message = "Actions on types annotated with ApiControllerAttribute must be attribute routed.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 8, 16) }
|
|
||||||
};
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -160,7 +157,7 @@ public class PetController : Controller
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(expectedLocation, actualDiagnostics);
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
@ -290,5 +287,18 @@ public class PetController
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics, codeFixIndex: 3);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics, codeFixIndex: 3);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AssertDiagnostic(DiagnosticLocation expectedLocation, Diagnostic[] actualDiagnostics)
|
||||||
|
{
|
||||||
|
// Assert
|
||||||
|
Assert.Collection(
|
||||||
|
actualDiagnostics,
|
||||||
|
diagnostic =>
|
||||||
|
{
|
||||||
|
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
||||||
|
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
||||||
|
AnalyzerAssert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CodeFixes;
|
using Microsoft.CodeAnalysis.CodeFixes;
|
||||||
|
|
@ -12,6 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
|
||||||
{
|
{
|
||||||
public class ApiActionsShouldUseActionResultOfTFacts : AnalyzerTestBase
|
public class ApiActionsShouldUseActionResultOfTFacts : AnalyzerTestBase
|
||||||
{
|
{
|
||||||
|
private static DiagnosticDescriptor DiagnosticDescriptor = DiagnosticDescriptors.MVC7002_ApiActionsShouldReturnActionResultOf;
|
||||||
|
|
||||||
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; }
|
||||||
= new ApiActionsShouldUseActionResultOfTAnalyzer();
|
= new ApiActionsShouldUseActionResultOfTAnalyzer();
|
||||||
|
|
||||||
|
|
@ -156,13 +159,7 @@ public class PetController: ControllerBase
|
||||||
public async Task DiagnosticsAreReturned_WhenActionsReturnIActionResult()
|
public async Task DiagnosticsAreReturned_WhenActionsReturnIActionResult()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var expectedLocation = new DiagnosticLocation("Test.cs", 9, 12);
|
||||||
{
|
|
||||||
Id = "MVC7002",
|
|
||||||
Message = "Actions on types annotated with ApiControllerAttribute should return ActionResult<T>.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 9, 12) }
|
|
||||||
};
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -195,7 +192,7 @@ public class PetController: ControllerBase
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(expectedLocation, actualDiagnostics);
|
||||||
|
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
|
|
@ -205,13 +202,7 @@ public class PetController: ControllerBase
|
||||||
public async Task DiagnosticsAreReturned_WhenActionReturnsAsyncIActionResult()
|
public async Task DiagnosticsAreReturned_WhenActionReturnsAsyncIActionResult()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedDiagnostic = new DiagnosticResult
|
var expectedLocation = new DiagnosticLocation("Test.cs", 8, 18);
|
||||||
{
|
|
||||||
Id = "MVC7002",
|
|
||||||
Message = "Actions on types annotated with ApiControllerAttribute should return ActionResult<T>.",
|
|
||||||
Severity = DiagnosticSeverity.Warning,
|
|
||||||
Locations = new[] { new DiagnosticResultLocation("Test.cs", 8, 18) }
|
|
||||||
};
|
|
||||||
|
|
||||||
var test =
|
var test =
|
||||||
@"
|
@"
|
||||||
|
|
@ -248,10 +239,23 @@ public class Pet {}";
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var actualDiagnostics = await GetDiagnosticAsync(project);
|
var actualDiagnostics = await GetDiagnosticAsync(project);
|
||||||
Assert.DiagnosticsEqual(new[] { expectedDiagnostic }, actualDiagnostics);
|
AssertDiagnostic(expectedLocation, actualDiagnostics);
|
||||||
|
|
||||||
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
var actualFix = await ApplyCodeFixAsync(project, actualDiagnostics);
|
||||||
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
Assert.Equal(expectedFix, actualFix, ignoreLineEndingDifferences: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AssertDiagnostic(DiagnosticLocation expectedLocation, Diagnostic[] actualDiagnostics)
|
||||||
|
{
|
||||||
|
// Assert
|
||||||
|
Assert.Collection(
|
||||||
|
actualDiagnostics,
|
||||||
|
diagnostic =>
|
||||||
|
{
|
||||||
|
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
||||||
|
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
||||||
|
AnalyzerAssert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
using Microsoft.AspNetCore.Testing;
|
using Microsoft.AspNetCore.Testing;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CodeActions;
|
using Microsoft.CodeAnalysis.CodeActions;
|
||||||
|
|
@ -17,6 +18,7 @@ using Microsoft.CodeAnalysis.CSharp;
|
||||||
using Microsoft.CodeAnalysis.Diagnostics;
|
using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
using Microsoft.CodeAnalysis.Text;
|
||||||
using Microsoft.Extensions.DependencyModel;
|
using Microsoft.Extensions.DependencyModel;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure
|
namespace Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure
|
||||||
{
|
{
|
||||||
|
|
@ -30,9 +32,9 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure
|
||||||
|
|
||||||
protected virtual CodeFixProvider CodeFixProvider { get; }
|
protected virtual CodeFixProvider CodeFixProvider { get; }
|
||||||
|
|
||||||
public IDictionary<string, DiagnosticResultLocation> MarkerLocations { get; } = new Dictionary<string, DiagnosticResultLocation>();
|
public IDictionary<string, DiagnosticLocation> MarkerLocations { get; } = new Dictionary<string, DiagnosticLocation>();
|
||||||
|
|
||||||
public DiagnosticResultLocation? DefaultMarkerLocation { get; private set; }
|
public DiagnosticLocation DefaultMarkerLocation { get; private set; }
|
||||||
|
|
||||||
protected Project CreateProjectFromFile([CallerMemberName] string fileName = "")
|
protected Project CreateProjectFromFile([CallerMemberName] string fileName = "")
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +59,7 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure
|
||||||
{
|
{
|
||||||
var markerEndIndex = line.IndexOf(MarkerEnd, markerStartIndex, StringComparison.Ordinal);
|
var markerEndIndex = line.IndexOf(MarkerEnd, markerStartIndex, StringComparison.Ordinal);
|
||||||
var markerName = line.Substring(markerStartIndex + 2, markerEndIndex - markerStartIndex - 2);
|
var markerName = line.Substring(markerStartIndex + 2, markerEndIndex - markerStartIndex - 2);
|
||||||
var resultLocation = new DiagnosticResultLocation(i + 1, markerStartIndex + 1); ;
|
var resultLocation = new DiagnosticLocation(i + 1, markerStartIndex + 1); ;
|
||||||
|
|
||||||
if (DefaultMarkerLocation == null)
|
if (DefaultMarkerLocation == null)
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||||
|
|
@ -7,13 +7,13 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||||
<Compile Include="..\Microsoft.AspNetCore.Mvc.Analyzers.Test\Infrastructure\*.cs" Link="Infrastructure\%(FileName)%(Extension)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Analyzers.Experimental\Microsoft.AspNetCore.Mvc.Analyzers.Experimental.csproj" />
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Analyzers.Experimental\Microsoft.AspNetCore.Mvc.Analyzers.Experimental.csproj" />
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Analyzer.Testing" Version="$(MicrosoftAspNetCoreAnalyzerTestingPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
|
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,77 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.Diagnostics;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Analyzers
|
namespace Microsoft.AspNetCore.Mvc.Analyzers
|
||||||
{
|
{
|
||||||
public class AvoidHtmlPartialAnalyzerTest : AnalyzerTestBase
|
public class AvoidHtmlPartialAnalyzerTest
|
||||||
{
|
{
|
||||||
private static DiagnosticDescriptor DiagnosticDescriptor = DiagnosticDescriptors.MVC1000_HtmlHelperPartialShouldBeAvoided;
|
private static DiagnosticDescriptor DiagnosticDescriptor = DiagnosticDescriptors.MVC1000_HtmlHelperPartialShouldBeAvoided;
|
||||||
|
|
||||||
protected override DiagnosticAnalyzer DiagnosticAnalyzer { get; } = new AvoidHtmlPartialAnalyzer();
|
private MvcDiagnosticAnalyzerRunner Executor { get; } = new MvcDiagnosticAnalyzerRunner(new AvoidHtmlPartialAnalyzer());
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task NoDiagnosticsAreReturned_FoEmptyScenarios()
|
public Task NoDiagnosticsAreReturned_FoEmptyScenarios()
|
||||||
{
|
=> VerifyNoDiagnosticsAreReturned(source: string.Empty);
|
||||||
// Arrange
|
|
||||||
var project = CreateProject(source: string.Empty);
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task NoDiagnosticsAreReturned_ForNonUseOfHtmlPartial()
|
||||||
|
=> VerifyNoDiagnosticsAreReturned(ReadTestSource().Source);
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task NoDiagnosticsAreReturned_ForUseOfHtmlPartialAsync()
|
||||||
|
=> VerifyNoDiagnosticsAreReturned(ReadTestSource().Source);
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task DiagnosticsAreReturned_ForUseOfHtmlPartial()
|
||||||
|
=> VerifyDefault(ReadTestSource());
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task DiagnosticsAreReturned_ForUseOfHtmlPartial_WithAdditionalParameters()
|
||||||
|
=> VerifyDefault(ReadTestSource());
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task DiagnosticsAreReturned_ForUseOfHtmlPartial_InSections()
|
||||||
|
=> VerifyDefault(ReadTestSource());
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task NoDiagnosticsAreReturned_ForUseOfRenderPartialAsync()
|
||||||
|
=> VerifyNoDiagnosticsAreReturned(ReadTestSource().Source);
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task DiagnosticsAreReturned_ForUseOfRenderPartial()
|
||||||
|
=> VerifyDefault(ReadTestSource());
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task DiagnosticsAreReturned_ForUseOfRenderPartial_WithAdditionalParameters()
|
||||||
|
=> VerifyDefault(ReadTestSource());
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public Task DiagnosticsAreReturned_ForUseOfRenderPartial_InSections()
|
||||||
|
=> VerifyDefault(ReadTestSource());
|
||||||
|
|
||||||
|
private async Task VerifyNoDiagnosticsAreReturned(string source)
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var result = await GetDiagnosticAsync(project);
|
var result = await Executor.GetDiagnosticsAsync(source);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Empty(result);
|
Assert.Empty(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
private async Task VerifyDefault(TestSource testSource)
|
||||||
public async Task NoDiagnosticsAreReturned_ForNonUseOfHtmlPartial()
|
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var project = CreateProjectFromFile();
|
var expectedLocation = testSource.DefaultMarkerLocation;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await GetDiagnosticAsync(project);
|
var result = await Executor.GetDiagnosticsAsync(testSource.Source);
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Empty(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task NoDiagnosticsAreReturned_ForUseOfHtmlPartialAsync()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Empty(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DiagnosticsAreReturned_ForUseOfHtmlPartial()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
var expectedLocation = DefaultMarkerLocation.Value;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Collection(
|
Assert.Collection(
|
||||||
|
|
@ -72,131 +81,11 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
|
||||||
|
|
||||||
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
||||||
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
||||||
Assert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
AnalyzerAssert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
private static TestSource ReadTestSource([CallerMemberName] string testMethod = "") =>
|
||||||
public async Task DiagnosticsAreReturned_ForUseOfHtmlPartial_WithAdditionalParameters()
|
MvcTestSource.Read(nameof(AvoidHtmlPartialAnalyzerTest), testMethod);
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
var expectedLocation = DefaultMarkerLocation.Value;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Collection(
|
|
||||||
result,
|
|
||||||
diagnostic =>
|
|
||||||
{
|
|
||||||
|
|
||||||
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
|
||||||
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
|
||||||
Assert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DiagnosticsAreReturned_ForUseOfHtmlPartial_InSections()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
var expectedLocation = DefaultMarkerLocation.Value;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Collection(
|
|
||||||
result,
|
|
||||||
diagnostic =>
|
|
||||||
{
|
|
||||||
|
|
||||||
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
|
||||||
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
|
||||||
Assert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task NoDiagnosticsAreReturned_ForUseOfRenderPartialAsync()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Empty(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DiagnosticsAreReturned_ForUseOfRenderPartial()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
var expectedLocation = DefaultMarkerLocation.Value;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Collection(
|
|
||||||
result,
|
|
||||||
diagnostic =>
|
|
||||||
{
|
|
||||||
|
|
||||||
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
|
||||||
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
|
||||||
Assert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DiagnosticsAreReturned_ForUseOfRenderPartial_WithAdditionalParameters()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
var expectedLocation = DefaultMarkerLocation.Value;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Collection(
|
|
||||||
result,
|
|
||||||
diagnostic =>
|
|
||||||
{
|
|
||||||
|
|
||||||
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
|
||||||
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
|
||||||
Assert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DiagnosticsAreReturned_ForUseOfRenderPartial_InSections()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var project = CreateProjectFromFile();
|
|
||||||
var expectedLocation = DefaultMarkerLocation.Value;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await GetDiagnosticAsync(project);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Collection(
|
|
||||||
result,
|
|
||||||
diagnostic =>
|
|
||||||
{
|
|
||||||
|
|
||||||
Assert.Equal(DiagnosticDescriptor.Id, diagnostic.Id);
|
|
||||||
Assert.Same(DiagnosticDescriptor, diagnostic.Descriptor);
|
|
||||||
Assert.DiagnosticLocation(expectedLocation, diagnostic.Location);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,194 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure;
|
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.CodeAnalysis.Formatting;
|
|
||||||
using Microsoft.CodeAnalysis.Simplification;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Analyzers
|
|
||||||
{
|
|
||||||
internal class Assert : Xunit.Assert
|
|
||||||
{
|
|
||||||
public static void DiagnosticsEqual(IEnumerable<DiagnosticResult> expected, IEnumerable<Diagnostic> actual)
|
|
||||||
{
|
|
||||||
var expectedCount = expected.Count();
|
|
||||||
var actualCount = actual.Count();
|
|
||||||
|
|
||||||
if (expectedCount != actualCount)
|
|
||||||
{
|
|
||||||
throw new DiagnosticsAssertException(
|
|
||||||
expected,
|
|
||||||
actual,
|
|
||||||
$"Mismatch between number of diagnostics returned, expected \"{expectedCount}\" actual \"{actualCount}.");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var (expectedItem, actualItem) in expected.Zip(actual, (a, b) => (a, b)))
|
|
||||||
{
|
|
||||||
if (expectedItem.Line == -1 && expectedItem.Column == -1)
|
|
||||||
{
|
|
||||||
if (actualItem.Location != Location.None)
|
|
||||||
{
|
|
||||||
throw new DiagnosticAssertException(
|
|
||||||
expectedItem,
|
|
||||||
actualItem,
|
|
||||||
$"Expected: A project diagnostic with no location. Actual {actualItem.Location}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VerifyLocation(expectedItem, actualItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actualItem.Id != expectedItem.Id)
|
|
||||||
{
|
|
||||||
throw new DiagnosticAssertException(
|
|
||||||
expectedItem,
|
|
||||||
actualItem,
|
|
||||||
$"Expected: Expected id: {expectedItem.Id}. Actual id: {actualItem.Id}.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actualItem.Severity != expectedItem.Severity)
|
|
||||||
{
|
|
||||||
throw new DiagnosticAssertException(
|
|
||||||
expectedItem,
|
|
||||||
actualItem,
|
|
||||||
$"Expected: Expected severity: {expectedItem.Severity}. Actual severity: {actualItem.Severity}.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actualItem.GetMessage() != expectedItem.Message)
|
|
||||||
{
|
|
||||||
throw new DiagnosticAssertException(
|
|
||||||
expectedItem,
|
|
||||||
actualItem,
|
|
||||||
$"Expected: Expected message: {expectedItem.Message}. Actual message: {actualItem.GetMessage()}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void VerifyLocation(DiagnosticResult expected, Diagnostic actual)
|
|
||||||
{
|
|
||||||
if (expected.Locations.Length == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var expectedLocation = expected.Locations[0];
|
|
||||||
Assert.DiagnosticLocation(expectedLocation, actual.Location);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DiagnosticLocation(DiagnosticResultLocation expected, Location actual)
|
|
||||||
{
|
|
||||||
var actualSpan = actual.GetLineSpan();
|
|
||||||
var actualLinePosition = actualSpan.StartLinePosition;
|
|
||||||
|
|
||||||
// Only check line position if there is an actual line in the real diagnostic
|
|
||||||
if (actualLinePosition.Line > 0)
|
|
||||||
{
|
|
||||||
if (actualLinePosition.Line + 1 != expected.Line)
|
|
||||||
{
|
|
||||||
throw new DiagnosticLocationAssertException(
|
|
||||||
expected,
|
|
||||||
actual,
|
|
||||||
$"Expected diagnostic to be on line \"{expected.Line}\" was actually on line \"{actualLinePosition.Line + 1}\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only check column position if there is an actual column position in the real diagnostic
|
|
||||||
if (actualLinePosition.Character > 0)
|
|
||||||
{
|
|
||||||
if (actualLinePosition.Character + 1 != expected.Column)
|
|
||||||
{
|
|
||||||
throw new DiagnosticLocationAssertException(
|
|
||||||
expected,
|
|
||||||
actual,
|
|
||||||
$"Expected diagnostic to start at column \"{expected.Column}\" was actually on line \"{actualLinePosition.Character + 1}\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string FormatDiagnostics(IEnumerable<Diagnostic> diagnostics)
|
|
||||||
{
|
|
||||||
return string.Join(Environment.NewLine, diagnostics.Select(FormatDiagnostic));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string FormatDiagnostic(Diagnostic diagnostic)
|
|
||||||
{
|
|
||||||
var builder = new StringBuilder();
|
|
||||||
builder.AppendLine(diagnostic.ToString());
|
|
||||||
|
|
||||||
var location = diagnostic.Location;
|
|
||||||
if (location == Location.None)
|
|
||||||
{
|
|
||||||
builder.Append($"Location unknown: ({diagnostic.Id})");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
True(location.IsInSource,
|
|
||||||
$"Test base does not currently handle diagnostics in metadata locations. Diagnostic in metadata: {diagnostic}");
|
|
||||||
|
|
||||||
var linePosition = location.GetLineSpan().StartLinePosition;
|
|
||||||
builder.Append($"({(linePosition.Line + 1)}, {(linePosition.Character + 1)}, {diagnostic.Id})");
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<string> GetStringFromDocumentAsync(Document document)
|
|
||||||
{
|
|
||||||
var simplifiedDoc = await Simplifier.ReduceAsync(document, Simplifier.Annotation);
|
|
||||||
var root = await simplifiedDoc.GetSyntaxRootAsync();
|
|
||||||
root = Formatter.Format(root, Formatter.Annotation, simplifiedDoc.Project.Solution.Workspace);
|
|
||||||
return root.GetText().ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DiagnosticsAssertException : Xunit.Sdk.EqualException
|
|
||||||
{
|
|
||||||
public DiagnosticsAssertException(
|
|
||||||
IEnumerable<DiagnosticResult> expected,
|
|
||||||
IEnumerable<Diagnostic> actual,
|
|
||||||
string message)
|
|
||||||
: base(expected, actual)
|
|
||||||
{
|
|
||||||
Message = message + Environment.NewLine + FormatDiagnostics(actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Message { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DiagnosticAssertException : Xunit.Sdk.EqualException
|
|
||||||
{
|
|
||||||
public DiagnosticAssertException(
|
|
||||||
DiagnosticResult expected,
|
|
||||||
Diagnostic actual,
|
|
||||||
string message)
|
|
||||||
: base(expected, actual)
|
|
||||||
{
|
|
||||||
Message = message + Environment.NewLine + FormatDiagnostic(actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Message { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DiagnosticLocationAssertException : Xunit.Sdk.EqualException
|
|
||||||
{
|
|
||||||
public DiagnosticLocationAssertException(
|
|
||||||
DiagnosticResultLocation expected,
|
|
||||||
Location actual,
|
|
||||||
string message)
|
|
||||||
: base(expected, actual)
|
|
||||||
{
|
|
||||||
Message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Message { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Location where the diagnostic appears, as determined by path, line number, and column number.
|
|
||||||
/// </summary>
|
|
||||||
public struct DiagnosticResultLocation
|
|
||||||
{
|
|
||||||
public DiagnosticResultLocation(int line, int column)
|
|
||||||
: this("Test.cs", line, column)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiagnosticResultLocation(string path, int line, int column)
|
|
||||||
{
|
|
||||||
if (line < -1)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(line), "line must be >= -1");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (column < -1)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(column), "column must be >= -1");
|
|
||||||
}
|
|
||||||
|
|
||||||
Path = path;
|
|
||||||
Line = line;
|
|
||||||
Column = column;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Path { get; }
|
|
||||||
public int Line { get; }
|
|
||||||
public int Column { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Struct that stores information about a Diagnostic appearing in a source
|
|
||||||
/// </summary>
|
|
||||||
public struct DiagnosticResult
|
|
||||||
{
|
|
||||||
private DiagnosticResultLocation[] _locations;
|
|
||||||
|
|
||||||
public DiagnosticResultLocation[] Locations
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_locations == null)
|
|
||||||
{
|
|
||||||
_locations = new DiagnosticResultLocation[] { };
|
|
||||||
}
|
|
||||||
|
|
||||||
return _locations;
|
|
||||||
}
|
|
||||||
|
|
||||||
set => _locations = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiagnosticSeverity Severity { get; set; }
|
|
||||||
|
|
||||||
public string Id { get; set; }
|
|
||||||
|
|
||||||
public string Message { get; set; }
|
|
||||||
|
|
||||||
public string Path => Locations.Length > 0 ? Locations[0].Path : "";
|
|
||||||
|
|
||||||
public int Line => Locations.Length > 0 ? Locations[0].Line : -1;
|
|
||||||
|
|
||||||
public int Column => Locations.Length > 0 ? Locations[0].Column : -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure
|
||||||
|
{
|
||||||
|
public class MvcDiagnosticAnalyzerRunner : DiagnosticAnalyzerRunner
|
||||||
|
{
|
||||||
|
public MvcDiagnosticAnalyzerRunner(DiagnosticAnalyzer analyzer)
|
||||||
|
{
|
||||||
|
Analyzer = analyzer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiagnosticAnalyzer Analyzer { get; }
|
||||||
|
|
||||||
|
public Task<Diagnostic[]> GetDiagnosticsAsync(string source)
|
||||||
|
{
|
||||||
|
return GetDiagnosticsAsync(sources: new[] { source }, Analyzer, Array.Empty<string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
||||||
|
using Microsoft.AspNetCore.Testing;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Mvc.Analyzers.Infrastructure
|
||||||
|
{
|
||||||
|
public static class MvcTestSource
|
||||||
|
{
|
||||||
|
private static readonly string ProjectDirectory = GetProjectDirectory();
|
||||||
|
|
||||||
|
public static TestSource Read(string testClassName, string testMethod)
|
||||||
|
{
|
||||||
|
var filePath = Path.Combine(ProjectDirectory, "TestFiles", testClassName, testMethod + ".cs");
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"TestFile {testMethod} could not be found at {filePath}.", filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileContent = File.ReadAllText(filePath);
|
||||||
|
return TestSource.Read(fileContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetProjectDirectory()
|
||||||
|
{
|
||||||
|
var solutionDirectory = TestPathUtilities.GetSolutionRootDirectory("Mvc");
|
||||||
|
var assemblyName = typeof(MvcTestSource).Assembly.GetName().Name;
|
||||||
|
var projectDirectory = Path.Combine(solutionDirectory, "test", assemblyName);
|
||||||
|
return projectDirectory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Analyzers\Microsoft.AspNetCore.Mvc.Analyzers.csproj" />
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Analyzers\Microsoft.AspNetCore.Mvc.Analyzers.csproj" />
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Analyzer.Testing" Version="$(MicrosoftAspNetCoreAnalyzerTestingPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
|
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue