Skip to content

Commit eb6dc9b

Browse files
amiru3fAmir Solhi
authored andcommitted
cleanup and AnalyzerRelease
2 parents b821c3e + 104994f commit eb6dc9b

File tree

8 files changed

+51
-18
lines changed

8 files changed

+51
-18
lines changed

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
</Dependency>
1818
</ProductDependencies>
1919
<ToolsetDependencies>
20-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23364.2">
20+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23371.1">
2121
<Uri>https://github.com/dotnet/arcade</Uri>
22-
<Sha>60ea5b2eca5af06fc63b250f8669d2c70179b18c</Sha>
22+
<Sha>602351e3681015ea789b2aeaa7b2a9156a8baf38</Sha>
2323
<SourceBuild RepoName="arcade" ManagedOnly="true" />
2424
</Dependency>
2525
<!-- Used in repo tooling. Not updated automatically -->
@@ -32,9 +32,9 @@
3232
<Sha>d2e046aec870a5a7601cc51c5607f34463cc2d42</Sha>
3333
<SourceBuild RepoName="sourcelink" ManagedOnly="true" />
3434
</Dependency>
35-
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23360.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
35+
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23368.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
3636
<Uri>https://github.com/dotnet/xliff-tasks</Uri>
37-
<Sha>a171b61473272e5a6d272117963864ba958a012a</Sha>
37+
<Sha>3aa0b2b84cab7d94b9136547563d027fd78e82a6</Sha>
3838
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
3939
</Dependency>
4040
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.5.0">

eng/common/sdl/configure-sdl-tool.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ try {
9393
}
9494
'binskim' {
9595
if ($targetDirectory) {
96-
$tool.Args += "`"Target < $TargetDirectory\**`""
96+
# Binskim crashes due to specific PDBs. GitHub issue: https://github.com/microsoft/binskim/issues/924.
97+
# We are excluding all `_.pdb` files from the scan.
98+
$tool.Args += "`"Target < $TargetDirectory\**;-:file|$TargetDirectory\**\_.pdb`""
9799
}
98100
$tool.Args += $BinskimAdditionalRunConfigParams
99101
}

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"rollForward": "patch"
1919
},
2020
"msbuild-sdks": {
21-
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23364.2"
21+
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23371.1"
2222
}
2323
}

src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ CA1862 | Performance | Info | RecommendCaseInsensitiveStringComparison, [Documen
1919
CA1863 | Performance | Hidden | UseCompositeFormatAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1862)
2020
CA1864 | Performance | Info | PreferDictionaryTryAddValueOverGuardedAddAnalyzer, [Documentation](https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1864)
2121
CA2021 | Reliability | Warning | DoNotCallEnumerableCastOrOfTypeWithIncompatibleTypesAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2021)
22+
CA2262 | Usage | Info | ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2262)
2223

2324
### Removed Rules
2425

2526
Rule ID | Category | Severity | Notes
2627
--------|----------|----------|-------
2728
CA2109 | Security | Disabled | ReviewVisibleEventHandlersAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2109)
28-
CA2262 | Usage | Enabled | ReviewVisibleEventHandlersAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2109)

src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,15 @@
13461346
<data name="ProvideCorrectArgumentToEnumHasFlagDescription" xml:space="preserve">
13471347
<value>'Enum.HasFlag' method expects the 'enum' argument to be of the same 'enum' type as the instance on which the method is invoked and that this 'enum' is marked with 'System.FlagsAttribute'. If these are different 'enum' types, an unhandled exception will be thrown at runtime. If the 'enum' type is not marked with 'System.FlagsAttribute' the call will always return 'false' at runtime.</value>
13481348
</data>
1349+
<data name="ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectlyTitle" xml:space="preserve">
1350+
<value>Make sure you are providing a correct value</value>
1351+
</data>
1352+
<data name="ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectlyMessage" xml:space="preserve">
1353+
<value>Make sure the value '{0}' is provided correctly. This value is measured in KB not bytes.</value>
1354+
</data>
1355+
<data name="ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectlyDescription" xml:space="preserve">
1356+
<value>The property 'MaxResponseHeadersLength' is measured in KB, not in bytes. Note that the provided value will automatically be multiplied by 1024 in the background.</value>
1357+
</data>
13491358
<data name="ProvideCorrectArgumentToEnumHasFlagMessageDifferentType" xml:space="preserve">
13501359
<value>The argument type, '{0}', must be the same as the enum type '{1}'</value>
13511360
</data>

src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectly.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.
22

3+
using System;
34
using System.Collections.Immutable;
45
using Analyzer.Utilities;
56
using Analyzer.Utilities.Extensions;
@@ -48,12 +49,12 @@ public override void Initialize(AnalysisContext context)
4849
return;
4950
}
5051

51-
if (!propertyAssignment.Value.ConstantValue.HasValue)
52+
if (propertyAssignment.Value is null || !propertyAssignment.Value.ConstantValue.HasValue || propertyAssignment.Value.ConstantValue.Value is not int)
5253
{
5354
return;
5455
}
5556

56-
int propertyValue = System.Convert.ToInt32(propertyAssignment.Value.ConstantValue.Value);
57+
int propertyValue = Convert.ToInt32(propertyAssignment.Value.ConstantValue.Value, System.Globalization.CultureInfo.CurrentCulture);
5758

5859
if (propertyValue > MaximumAlertLimit)
5960
{

src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4322,6 +4322,25 @@
43224322
]
43234323
}
43244324
},
4325+
"CA2262": {
4326+
"id": "CA2262",
4327+
"shortDescription": "Checks MaxResponseHeadersLength to be sent in KB",
4328+
"fullDescription": "If someone mistakenly provides a big value for HttpClientHandler.MaxResponseHeadersLength will receive a warning",
4329+
"defaultLevel": "note",
4330+
"helpUri": "https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2262",
4331+
"properties": {
4332+
"category": "Usage",
4333+
"isEnabledByDefault": true,
4334+
"typeName": "ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectly",
4335+
"languages": [
4336+
"C#",
4337+
"Visual Basic"
4338+
],
4339+
"tags": [
4340+
"Telemetry"
4341+
]
4342+
}
4343+
},
43254344
"CA2300": {
43264345
"id": "CA2300",
43274346
"shortDescription": "Do not use insecure deserializer BinaryFormatter",

src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Usage/ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectlyTests.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
namespace Microsoft.NetCore.Analyzers.Usage.UnitTests
1010
{
11-
public class HttpResponseHeaderTestTests
11+
public class ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectlyTests
1212
{
1313
[Fact]
14-
public async Task Test_Amir()
14+
public async Task CA2262_ProvideCorrectValueFor_HttpClientHandlerMaxResponseHeader_DiagnosticAsync()
1515
{
1616
await VerifyCS.VerifyAnalyzerAsync(@"
1717
using System;
@@ -26,23 +26,25 @@ public void TestMethod() {
2626
2727
HttpClientHandler handler3 = new HttpClientHandler()
2828
{
29-
MaxResponseHeadersLength = GetValue() // Do you really mean 16 MB?
29+
MaxResponseHeadersLength = GetValue()
3030
};
3131
32-
// HttpClientHandler handler = new HttpClientHandler()
33-
// {
34-
// MaxResponseHeadersLength = val // Do you really mean 16 MB?
35-
// };
32+
HttpClientHandler handler = new HttpClientHandler()
33+
{
34+
{|#0:MaxResponseHeadersLength = val|}
35+
};
3636
3737
HttpClientHandler handler2 = new HttpClientHandler()
3838
{
39-
MaxResponseHeadersLength = 1414 // Do you really mean 16 MB?
39+
{|#1:MaxResponseHeadersLength = 1414|}
4040
};
4141
}
4242
}
4343
4444
",
45-
VerifyCS.Diagnostic(ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectly.RuleId));
45+
VerifyCS.Diagnostic(ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectly.RuleId).WithLocation(0).WithArguments(242424),
46+
VerifyCS.Diagnostic(ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectly.RuleId).WithLocation(1).WithArguments(1414)
47+
);
4648
}
4749
}
4850
}

0 commit comments

Comments
 (0)