★ wanayoo — archive 1999 https://github.com/code-cracker/code-cracker/issues/925Nouvelle recherche | Portail wanayoo
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

BUG: CC0021 generates a use NameOf for a constant defined as itself #925

Open
CZEMacLeod opened this issue May 25, 2017 · 4 comments
Open

BUG: CC0021 generates a use NameOf for a constant defined as itself #925

CZEMacLeod opened this issue May 25, 2017 · 4 comments
Assignees
Projects
Milestone

Comments

@CZEMacLeod
Copy link

@CZEMacLeod CZEMacLeod commented May 25, 2017

#Bug

CC0021 suggests using a constant definition name as itself which does not compile.

'the code that reproduces the bug
Class MyClass
    Public Const MyConst="MyConst"
End Class

Current output after fix applied:

'code fixed incorrectly
Class MyClass
    Public Const MyConst=NameOf(MyConst)
End Class

Error:
BC30500 Constant 'MyConst' cannot depend on its own value.

@carloscds
Copy link
Contributor

@carloscds carloscds commented May 30, 2017

@CZEMacLeod This analyzer checks if value of variable it´s equal your name and then suggest a fix;

@CZEMacLeod
Copy link
Author

@CZEMacLeod CZEMacLeod commented May 31, 2017

I'm not quite sure what you mean by that.
The problem is that CC0021 from the NuGet package version on NuGet.org in visual basic suggests replacing a text string value for a constant with the same name. If you accept this change, you get error BC30500 which means the code does not compile.

@carloscds
Copy link
Contributor

@carloscds carloscds commented Jun 6, 2017

@CZEMacLeod It's make sense, A solution it's ignore rule in variable declaration, when name and value are same. What do you think about ?

@CZEMacLeod
Copy link
Author

@CZEMacLeod CZEMacLeod commented Jun 6, 2017

Yeah - That is what is required. Do not offer CC0021 when the nameof operator would point to the item you are declaring.

@carloscds carloscds self-assigned this Jun 6, 2017
@giggio giggio added this to the 1.0.4 milestone Jun 13, 2017
@giggio giggio added this to Ready in CodeCracker Jun 13, 2017
@giggio giggio changed the title CC0021 generates a use NameOf for a constant defined as itself BUG: CC0021 generates a use NameOf for a constant defined as itself May 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.