Skip to content

Conversation

@Youssef1313
Copy link
Member

No description provided.

@Youssef1313 Youssef1313 requested a review from a team as a code owner August 19, 2023 19:11
{
var semanticModel = argument.SemanticModel!;

var symbol = semanticModel.GetSymbolInfo(argument.Value.Syntax, oaContext.CancellationToken).Symbol;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mavasani I assume semantic model calls are more expensive than getting info directly from IOperation?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely.

Comment on lines 189 to +193
(targetMethod.Equals(stringFormatMemberWithStringAndObjectParameter) ||
targetMethod.Equals(stringFormatMemberWithStringObjectAndObjectParameter) ||
targetMethod.Equals(stringFormatMemberWithStringObjectObjectAndObjectParameter) ||
targetMethod.Equals(stringFormatMemberWithStringAndParamsObjectParameter)))
targetMethod.Equals(stringFormatMemberWithStringAndParamsObjectParameter)) &&
!oaContext.Options.IsConfiguredToSkipAnalysis(IFormatProviderAlternateStringRule, targetMethod, oaContext.ContainingSymbol, oaContext.Compilation))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbol equality should be faster than IsConfiguredToSkipAnalysis

Comment on lines -327 to -333
private static IEnumerable<int> GetIndexesOfParameterType(IMethodSymbol targetMethod, INamedTypeSymbol formatProviderType)
{
return targetMethod.Parameters
.Select((Parameter, Index) => (Parameter, Index))
.Where(x => x.Parameter.Type.Equals(formatProviderType))
.Select(x => x.Index);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm now looping over arguments directly and than checking if the parameter is of interest. The new implementation should hopefully be more performant and more straightforward.

@codecov
Copy link

codecov bot commented Aug 19, 2023

Codecov Report

Merging #6865 (96dadc3) into main (3587540) will increase coverage by 0.00%.
The diff coverage is 77.77%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6865   +/-   ##
=======================================
  Coverage   96.39%   96.39%           
=======================================
  Files        1403     1403           
  Lines      330977   330968    -9     
  Branches    10890    10891    +1     
=======================================
- Hits       319055   319050    -5     
+ Misses       9188     9182    -6     
- Partials     2734     2736    +2     

@mavasani
Copy link

@buyaa-n for another review

Copy link

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@buyaa-n buyaa-n merged commit ff698b7 into dotnet:main Sep 12, 2023
@Youssef1313 Youssef1313 deleted the iformat branch September 13, 2023 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants