Skip to content

Commit

Permalink
Add copyright header in C# files and improve Stylecop.Analyzer usage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Mar 18, 2022
1 parent 39c46f1 commit dfa682d
Show file tree
Hide file tree
Showing 213 changed files with 3,407 additions and 115 deletions.
12 changes: 12 additions & 0 deletions Common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<!-- StyleCop -->
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.*" PrivateAssets="all" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
<Compile Include="$(MSBuildThisFileDirectory)GlobalSuppressions.cs" Link="GlobalSuppressions.solution.cs" />
</ItemGroup>
</Project>
10 changes: 2 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)Common.props" />

<PropertyGroup>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<LangVersion>10.0</LangVersion>
</PropertyGroup>

<!-- StyleCop -->
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.*" PrivateAssets="all" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
<Compile Include="$(MSBuildThisFileDirectory)GlobalSuppressions.cs" Link="GlobalSuppressions.solution.cs" />
</ItemGroup>

<!-- Deterministic builds -->
<PropertyGroup Condition="'$(TF_BUILD)' == 'true' OR '$(GITLAB_CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
Expand Down
17 changes: 16 additions & 1 deletion GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="GlobalSuppressions.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
Expand All @@ -6,7 +22,6 @@
using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1309:FieldNamesMustNotBeginWithUnderscore", Justification = "Reviewed.")]
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File must have header", Justification = "Reviewed.")]
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Reviewed.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:UsingDirectivesMustBePlacedWithinNamespace", Justification = "Reviewed.")]
[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1512:Single-line comments must not be followed by blank line", Justification = "Reviewed.")]
Expand Down
8 changes: 1 addition & 7 deletions OpenTelemetry.AutoInstrumentation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenTelemetry.AutoInstrumentation.Native.Tests", "test\OpenTelemetry.AutoInstrumentation.Native.Tests\OpenTelemetry.AutoInstrumentation.Native.Tests.vcxproj", "{5728056A-51AA-4FF5-AD0C-E86E44E36102}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependency-libs", "dependency-libs", "{82A3CE96-0935-45E5-A9AA-A93A5B63500B}"
ProjectSection(SolutionItems) = preProject
test\test-applications\integrations\dependency-libs\Directory.Build.props = test\test-applications\integrations\dependency-libs\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ExampleLibrary", "test\test-applications\integrations\dependency-libs\Samples.ExampleLibrary\Samples.ExampleLibrary.csproj", "{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}"
EndProject
Expand Down Expand Up @@ -112,11 +109,8 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.MongoDB", "test\test-applications\integrations\Samples.MongoDB\Samples.MongoDB.csproj", "{02D6A472-A602-4BF4-A539-8AD165097898}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "aspnet", "aspnet", "{2E1F47D9-BEC1-4DCE-A84D-847FE5BBBE9E}"
ProjectSection(SolutionItems) = preProject
test\test-applications\integrations\aspnet\Directory.Build.props = test\test-applications\integrations\aspnet\Directory.Build.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.AspNet", "test\test-applications\integrations\aspnet\Samples.AspNet\Samples.AspNet.csproj", "{5FDB5603-21D3-446A-8B50-36DACCF7C2FF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.AspNet", "test\test-applications\integrations\aspnet\Samples.AspNet\Samples.AspNet.csproj", "{5FDB5603-21D3-446A-8B50-36DACCF7C2FF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "aspnet", "aspnet", "{A0B40A84-EF97-47DB-8455-796A9BCA1097}"
EndProject
Expand Down
18 changes: 17 additions & 1 deletion samples/BindingRedirect/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="Program.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Threading.Tasks;
using OldReference;

Expand All @@ -9,4 +25,4 @@ public static async Task Main(string[] args)
{
await InstrumentedHttpCall.GetAsync("https://www.google.com");
}
}
}
20 changes: 18 additions & 2 deletions samples/ConsoleApp.SelfBootstrap/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="Program.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Diagnostics;
using System.Net.Http;
Expand Down Expand Up @@ -28,7 +44,7 @@ private static async Task<int> Main()
});

_tracerProvider = builder.Build();

using (var activity = MyActivitySource.StartActivity("Main"))
{
activity?.SetTag("foo", "bar");
Expand All @@ -47,4 +63,4 @@ private static async Task<int> Main()
return 0;
}
}
}
}
20 changes: 18 additions & 2 deletions samples/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
// <copyright file="Program.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Diagnostics;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using OpenTracing.Propagation;
Expand Down Expand Up @@ -88,4 +104,4 @@ private static async Task HttpGet(string url)
Console.WriteLine($"HttpRequestException occurred while calling {url}, {e}");
}
}
}
}
16 changes: 16 additions & 0 deletions samples/ConsoleApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="AssemblyInfo.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Reflection;

[assembly:AssemblyKeyFileAttribute("ConsoleApp.snk")]
7 changes: 7 additions & 0 deletions samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)..\Common.props" />

<PropertyGroup>
<LangVersion>10.0</LangVersion>
</PropertyGroup>

<!-- StyleCop -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)GlobalSuppressions.cs" Link="GlobalSuppressions.samples.cs" />
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions samples/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// <copyright file="GlobalSuppressions.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed.")]
21 changes: 18 additions & 3 deletions samples/OldReference/InstrumentedHttpCall.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="InstrumentedHttpCall.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Diagnostics;
using System.Linq;
Expand All @@ -8,15 +24,14 @@ namespace OldReference;

public static class InstrumentedHttpCall
{

public static async Task GetAsync(string url)
{
Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>> System.Diagnostics.DiagnosticSource assemblies loaded:");
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
var loaded = assemblies
.Where(assembly => assembly.FullName.Contains("System.Diagnostics.DiagnosticSource"))
.Select(assembly => $">>>>>>>>>>>>>>>>>>>>>>> {assembly.FullName}");

Console.WriteLine(string.Join("\n", loaded));

var activity = new Activity("RunAsync");
Expand All @@ -35,4 +50,4 @@ public static async Task GetAsync(string url)
activity.Stop();
}
}
}
}
16 changes: 16 additions & 0 deletions samples/OpenTracingLibrary/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="AssemblyInfo.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Reflection;

[assembly:AssemblyKeyFileAttribute("OpenTracingLibrary.snk")]
20 changes: 18 additions & 2 deletions samples/OpenTracingLibrary/Wrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
using System;
// <copyright file="Wrapper.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenTracing.Util;
Expand Down Expand Up @@ -36,4 +52,4 @@ public static async Task WithOpenTracingSpanAsync(string spanKind, Func<Task> wr
}
}
}
}
}
18 changes: 17 additions & 1 deletion samples/Samples.AspNetCoreMvc31/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="ApiController.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -35,4 +51,4 @@ private void AddCorrelationIdentifierToResponse()
Response.Headers.Add(CorrelationIdentifierHeaderName, Request.Headers[CorrelationIdentifierHeaderName]);
}
}
}
}
18 changes: 17 additions & 1 deletion samples/Samples.AspNetCoreMvc31/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// <copyright file="HomeController.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -83,4 +99,4 @@ private void AddCorrelationIdentifierToResponse()
Response.Headers.Add(CorrelationIdentifierHeaderName, Request.Headers[CorrelationIdentifierHeaderName]);
}
}
}
}
Loading

0 comments on commit dfa682d

Please sign in to comment.