Skip to content

Commit

Permalink
fix analyzers (#2489)
Browse files Browse the repository at this point in the history
* fix analyzers

* add Test.props to these extra projects

* cleanup obsolete warnings
  • Loading branch information
TimothyMothra committed Dec 2, 2021
1 parent 3128843 commit 1e945be
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .props/Product.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

<ItemGroup Condition=" $(OS) == 'Windows_NT'">
<!--Analyzers-->
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
Expand Down Expand Up @@ -52,7 +49,6 @@
<!--<EnableNETAnalyzers>true</EnableNETAnalyzers>-->



<!--Removing the SRC folder from the output directory-->
<CorePath>$(RelativeOutputPathBase)</CorePath>
<OutputPath>$(BinRoot)\$(Configuration)\$(CorePath)</OutputPath>
Expand Down
9 changes: 8 additions & 1 deletion .props/Test.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</Target>

<Import Project=".\_Common.props" />
<Import Project=".\_AnalyzerSettings.props" />

<PropertyGroup>
<!-- Our test matrix includes every currently supported version of .NET
Expand All @@ -26,6 +25,14 @@

<PropertyGroup>
<IsPackable>false</IsPackable>

<!--
We have a significant backlog of analyzer issues in the Test projects. Turning these off for now.
https://docs.microsoft.com/en-us/visualstudio/code-quality/disable-code-analysis?view=vs-2022#net-framework-projects
https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysismode
-->
<AnalysisMode>None</AnalysisMode>
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ public IActionResult Exception()

public IActionResult Dependency()
{
this.telemetryClient.TrackDependency("MyDependency", "MyCommand", DateTimeOffset.Now, TimeSpan.FromMilliseconds(1), success: true);
this.telemetryClient.TrackDependency(
dependencyTypeName: "test",
dependencyName: "MyDependency",
data: "MyCommand",
startTime: DateTimeOffset.Now,
duration: TimeSpan.FromMilliseconds(1),
success: true);
return View();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(PropsRoot)\Test.props" />

<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(PropsRoot)\Test.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ public void ActiveConfigurationIsNotCorruptedAfterWebHostIsDisposed()
// Active config could be used multiple times in the same process before this test
// let's reassign it

#pragma warning disable CS0618 // Type or member is obsolete
TelemetryConfiguration.Active.Dispose();
#pragma warning restore CS0618 // Type or member is obsolete
MethodInfo setActive =
typeof(TelemetryConfiguration).GetMethod("set_Active", BindingFlags.Static | BindingFlags.NonPublic);
setActive.Invoke(null, new object[] { TelemetryConfiguration.CreateDefault() });

#pragma warning disable CS0618 // Type or member is obsolete
var activeConfig = TelemetryConfiguration.Active;
#pragma warning restore CS0618 // Type or member is obsolete
using (var server = new InProcessServer(assemblyName, this.output, (aiOptions) => aiOptions.EnableActiveTelemetryConfigurationSetup = true))
{
this.ExecuteRequest(server.BaseHost + requestPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(PropsRoot)\Test.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<Import Project="$(PropsRoot)\Test.props" />

<!--
Integration tests evaluate an app's components on a broader level than unit tests.
Unit tests are used to test isolated software components, such as individual class methods.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<Import Project="$(PropsRoot)\Test.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
</PropertyGroup>
Expand Down

0 comments on commit 1e945be

Please sign in to comment.