Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProvideCorrectArgumentsToFormattingMethodsAnalyzer throws IndexOutOfRangeException when building Microsoft.Extensions.Logging.Abstractions #90357

Closed
ericstj opened this issue Aug 11, 2023 · 5 comments · Fixed by #91222
Assignees
Labels
area-Meta code-analyzer Marks an issue that suggests a Roslyn analyzer
Milestone

Comments

@ericstj
Copy link
Member

ericstj commented Aug 11, 2023

Description

When building Microsoft.Extensions.Logging.Abstractions I see the diagnostic

error AD0001: Analyzer 'Microsoft.NetCore.Analyzers.Runtime.ProvideCorrectArgumentsToFormattingMethodsAnalyzer' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'

I'll suppress this when enabling AD0001 as warning. This issue will track fixing that analyzer and removing the warning suppression

Reproduction Steps

Remove AD0001 from Microsoft.Extensions.Logging.Abstractions.csproj and build it.

Expected behavior

Builds without warning.

Actual behavior

Warning as above

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 11, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 11, 2023
@ghost
Copy link

ghost commented Aug 14, 2023

Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When building Microsoft.Extensions.Logging.Abstractions I see the diagnostic

error AD0001: Analyzer 'Microsoft.NetCore.Analyzers.Runtime.ProvideCorrectArgumentsToFormattingMethodsAnalyzer' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'

I'll suppress this when enabling AD0001 as warning. This issue will track fixing that analyzer and removing the warning suppression

Reproduction Steps

Remove AD0001 from Microsoft.Extensions.Logging.Abstractions.csproj and build it.

Expected behavior

Builds without warning.

Actual behavior

Warning as above

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: ericstj
Assignees: -
Labels:

untriaged, area-Extensions-Logging, needs-area-label

Milestone: -

@tarekgh tarekgh removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 14, 2023
@tarekgh tarekgh added this to the 8.0.0 milestone Aug 14, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 14, 2023
@tarekgh
Copy link
Member

tarekgh commented Aug 23, 2023

I have investigated this and found this is issue in the analyzer that not handling the case when using a method with StringSyntaxAttribute parameter and not having any other parameters. CompositeFormat.Parse is an example of that. And The actual line throwing IndexOutOfRangeException is https://github.com/dotnet/roslyn-analyzers/blob/7e4877c40535652d7d44a238ea48b03f47f63e29/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethods.cs#L428C18-L428C18.

We already have a PR dotnet/roslyn-analyzers#6885 for fixing the analyzer.

@buyaa-n as we talked offline, you are going to follow up with the analyzer PR and then flow the fix to the runtime repo with removing the warning suppression in the project. Please ensure porting the fixes to 8.0 release branch. Thanks!

@tarekgh tarekgh added area-Meta code-analyzer Marks an issue that suggests a Roslyn analyzer and removed area-Extensions-Logging labels Aug 23, 2023
@ghost
Copy link

ghost commented Aug 23, 2023

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When building Microsoft.Extensions.Logging.Abstractions I see the diagnostic

error AD0001: Analyzer 'Microsoft.NetCore.Analyzers.Runtime.ProvideCorrectArgumentsToFormattingMethodsAnalyzer' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'

I'll suppress this when enabling AD0001 as warning. This issue will track fixing that analyzer and removing the warning suppression

Reproduction Steps

Remove AD0001 from Microsoft.Extensions.Logging.Abstractions.csproj and build it.

Expected behavior

Builds without warning.

Actual behavior

Warning as above

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: ericstj
Assignees: tarekgh
Labels:

area-Meta, code-analyzer

Milestone: 8.0.0

@tarekgh tarekgh assigned buyaa-n and unassigned tarekgh Aug 23, 2023
@buyaa-n
Copy link
Contributor

buyaa-n commented Aug 23, 2023

Thanks for finding the root cause of the issue @tarekgh !

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 28, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 28, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Meta code-analyzer Marks an issue that suggests a Roslyn analyzer
Projects
None yet
5 participants