Skip to content

Not offering UseAutoProperty for volatile fields & when field used with ref#25431

Merged
DustinCampbell merged 10 commits intodotnet:masterfrom
Neme12:useAutoProperty
Apr 6, 2018
Merged

Not offering UseAutoProperty for volatile fields & when field used with ref#25431
DustinCampbell merged 10 commits intodotnet:masterfrom
Neme12:useAutoProperty

Conversation

@Neme12
Copy link
Copy Markdown
Contributor

@Neme12 Neme12 commented Mar 12, 2018

fixes #25379
fixes #25429

[Export]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal class CSharpUseAutoPropertyAnalyzer : AbstractUseAutoPropertyAnalyzer<PropertyDeclarationSyntax, FieldDeclarationSyntax, VariableDeclaratorSyntax, ExpressionSyntax>
internal class CSharpUseAutoPropertyAnalyzer : AbstractUseAutoPropertyAnalyzer<
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I only wrapped what went past the GitHub limit (130 characters)

private static void AddIneligibleField(ISymbol symbol, HashSet<IFieldSymbol> ineligibleFields)
{
if (symbol is IFieldSymbol field)
void AddSymbol(ISymbol symbol)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you still call this "AddIneligibleField"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@CyrusNajmabadi I originally did but then realized it might be a little misleading because it could add more than 1 symbol

Copy link
Copy Markdown
Contributor Author

@Neme12 Neme12 Mar 12, 2018

Choose a reason for hiding this comment

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

whereas the previous method called 'AddIneligibleField' only took the symbol (I changed that one into a local function, AddSymbol)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but I'm not saying it's a good name as is...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

okey dokey

Copy link
Copy Markdown
Contributor Author

@Neme12 Neme12 Mar 12, 2018

Choose a reason for hiding this comment

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

@CyrusNajmabadi wait, I didn't look properly that you pointed this at the local function itself... yes I could call this AddIneligibleField, but what about AddIneligibleFields then? did you notice both of them? should they have names differing in 1 letter only? I figured that it's ok for this to have a short name because it's a small 3 line local function inside a 5 line method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should they have names differing in 1 letter only?

That's fine. It's fairly common in our code base. A higher level functoin that operates on a collection of items, which calls a helper which works on a single element.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes I could call this AddIneligibleField

great.

@Neme12
Copy link
Copy Markdown
Contributor Author

Neme12 commented Mar 15, 2018

@dotnet-bot retest windows_debug_vs-integration_prtest please

@Neme12
Copy link
Copy Markdown
Contributor Author

Neme12 commented Mar 15, 2018

@dotnet-bot retest windows_release_vs-integration_prtest please

@jcouv jcouv added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Mar 17, 2018
@jcouv jcouv added this to the 15.8 milestone Mar 27, 2018
@Neme12
Copy link
Copy Markdown
Contributor Author

Neme12 commented Mar 29, 2018

retest perf_correctness_prtest please

Copy link
Copy Markdown
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

Very nice

@DustinCampbell
Copy link
Copy Markdown
Member

@dotnet-bot retest this please

@Neme12
Copy link
Copy Markdown
Contributor Author

Neme12 commented Apr 6, 2018

retest this please

@Neme12
Copy link
Copy Markdown
Contributor Author

Neme12 commented Apr 6, 2018

retest windows_debug_unit32_prtest please

@DustinCampbell DustinCampbell merged commit 591624d into dotnet:master Apr 6, 2018
@DustinCampbell
Copy link
Copy Markdown
Member

Thanks again @Neme12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UseAutoProperty generates invalid code when using ref on the field IDE0032 should not be reported for volatile fields

4 participants